# WBP_JournalDocumentViewer — Widget (Document and Journal Viewer)

**File:** [`Content/Framework/UI/WBP_JournalDocumentViewer`](Content/Framework/UI/WBP_JournalDocumentViewer.uasset)
**Parent Class:** `UUserWidget`
**Dependencies:** [`BPC_DocumentArchiveSystem`](../04-inventory/BPC_DocumentArchiveSystem.md), [`BPC_JournalSystem`](../04-inventory/BPC_JournalSystem.md)

**Purpose:** Displays collected documents, notes, and the player journal. Supports text scrolling, page turns, and image plates. Read-only presentation — never modifies game state.

---

## Variables

| Name | Type | Description |
|------|------|-------------|
| `ActiveDocument` | S_DocumentEntry | Currently displayed document |
| `DocumentList` | Array of S_DocumentEntry | All collected documents for sidebar navigation |
| `ActiveJournalEntry` | S_JournalEntry | Currently displayed journal entry |
| `JournalEntryList` | Array of S_JournalEntry | All journal entries for sidebar navigation |
| `bShowPageTurnAnim` | Bool | Enable page turn animation |
| `FontStyle` | E_DocumentFontStyle | Handwritten, Typewritten, Digital |
| `ViewMode` | E_DocumentViewMode | Document, Journal, or Combined |
| `DocumentTitleText` | TextBlock | Active document title |
| `DocumentBodyText` | RichTextBlock | Scrollable document body |
| `DocumentImage` | Image | Optional plate/figure image |
| `SidebarList` | ListView | Navigation sidebar |

## Enums

```cpp
E_DocumentFontStyle
{
    Handwritten,
    Typewritten,
    Digital,
    BloodScrawled
}

E_DocumentViewMode
{
    DocumentsOnly,
    JournalOnly,
    CombinedTimeline
}
```

## Functions / Events

| Name | Inputs | Outputs | What it does |
|------|--------|---------|--------------|
| `OpenDocument` | DocumentTag: GameplayTag | — | Loads document from archive, displays with font style |
| `CloseDocument` | — | — | Returns to document list |
| `OpenJournal` | EntryTag: GameplayTag | — | Loads journal entry, displays |
| `NextDocument` | — | — | Selects next document in list |
| `PreviousDocument` | — | — | Selects previous document in list |
| `NextPage` | — | — | Scrolls body text to next page |
| `PreviousPage` | — | — | Scrolls body text to previous page |
| `SetViewMode` | Mode: E_DocumentViewMode | — | Switches between document/journal/combined |
| `MarkAsRead` | DocumentTag: GameplayTag | — | Sets bIsRead on document entry |
| `RefreshList` | — | — | Rebuilds sidebar from archive and journal systems |
| `SortByChapter` | — | — | Sorts documents/entries by discovery chapter |
| `SortByType` | — | — | Sorts documents by type, entries by date |

## Event Dispatchers

| Name | Parameters | Fired when |
|------|-----------|-----------|
| `OnDocumentOpened` | DocumentTag: GameplayTag | Player opens a document |
| `OnDocumentClosed` | — | Player closes document viewer |
| `OnDocumentRead` | DocumentTag: GameplayTag | Document marked as read |

## Blueprint Flow Diagram

```mermaid
flowchart TD
    A[Player opens Journal/Documents] --> B[ViewMode = CombinedTimeline]
    B --> C[RefreshList from BPC_DocumentArchiveSystem + BPC_JournalSystem]
    C --> D[Populate SidebarList]
    D --> E[Wait for selection]

    E --> F{Item selected?}
    F -->|Document| G[OpenDocument with DocumentTag]
    F -->|Journal Entry| H[OpenJournal with EntryTag]

    G --> I[Set ActiveDocument = entry from archive]
    I --> J[Display title, body text, optional image]
    I --> K[MarkAsRead]

    H --> L[Set ActiveJournalEntry]
    L --> M[Display heading, body, timestamp]
```

## Communications With

| Target System | Method | Why |
|---------------|--------|-----|
| `BPC_DocumentArchiveSystem` | Direct read | Get all found documents |
| `BPC_JournalSystem` | Direct read | Get all journal entries |
| `WBP_InventoryMenu` | Parent navigation | Open from inventory tab |
| `SS_UIManager` | Push/Pop | Menu stack management |

## Reuse Notes

- The `E_DocumentFontStyle` enum lets each project set the visual tone per document type
- `ViewMode` can be restricted to DocumentsOnly for games without a journal
- The page-turn anim is optional; disable for performance or minimalist UI
- RichTextBlock supports markup — use for emphasis, different speaker colours, or lore highlight