Every source file in ui, app, game, formats, cli, audio and launch that had none now starts with a short English comment: what it implements, what state it owns and how it relates to its neighbours (request/acknowledge flow, pairs of files, random generator use). Comment lines only; the full build and the runnable tests are unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
59 lines
2.3 KiB
C++
59 lines
2.3 KiB
C++
// SPDX-License-Identifier: GPL-3.0-only
|
|
// Mailbox screen: paged view of the manager's messages with keep and delete actions.
|
|
// MailboxScreen renders a MailboxState (see mailbox_state.hpp) over the desktop background. Article actions
|
|
// are requests (MailboxActionRequest) held in pending(); only the app adapter writes recipient and keep
|
|
// bits, then calls acknowledge() with the new state or reject(). Navigation changes neither the
|
|
// notification flag nor random generators. Implementation: mailbox_screen.cpp.
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <filesystem>
|
|
#include <string_view>
|
|
#include <optional>
|
|
|
|
#include "formats/font.hpp"
|
|
#include "formats/le.hpp"
|
|
#include "formats/textd.hpp"
|
|
#include "ui/mailbox_state.hpp"
|
|
|
|
namespace bmh::ui {
|
|
|
|
// Owned message pages. Article actions are requests; only the app adapter writes
|
|
// recipient/keep bits. Navigation leaves the notification flag and RNG untouched.
|
|
class MailboxScreen {
|
|
public:
|
|
MailboxScreen(const std::filesystem::path& data, MailboxState state,
|
|
std::string manager_name, Image desktop_background);
|
|
Image render() const;
|
|
bool click(int x, int y, bool right = false);
|
|
bool key(std::string_view value);
|
|
bool close_requested() const { return close_requested_; }
|
|
void cancel_close_request() { close_requested_ = false; }
|
|
size_t page() const { return page_; }
|
|
size_t page_count() const;
|
|
const MailboxState& state() const { return state_; }
|
|
const std::optional<MailboxActionRequest>& pending() const { return pending_; }
|
|
void acknowledge(MailboxState state);
|
|
void reject(std::string reason);
|
|
std::string state_json() const;
|
|
private:
|
|
MailboxState state_;
|
|
std::string manager_name_; // owned UTF-8
|
|
Image desktop_background_, atlas_;
|
|
LeImage exe_;
|
|
TextDb texts_;
|
|
Font font_;
|
|
size_t page_ = 0;
|
|
bool close_requested_ = false;
|
|
std::string feedback_;
|
|
MailboxActionKind action_mode_ = MailboxActionKind::none;
|
|
std::optional<MailboxActionRequest> pending_;
|
|
void validate_state(const MailboxState&) const;
|
|
void text(Image&, int x, int baseline, std::string_view original_bytes,
|
|
uint8_t color, int right) const;
|
|
void body(Image&, int x, int baseline, int right, int bottom,
|
|
std::string_view utf8, uint8_t color) const;
|
|
};
|
|
|
|
} // namespace bmh::ui
|