Modern UI contract: envelope, career and manager ids, session and desktop reads
First engine delivery for the Modern interface handoff (docs/new_ui/integration, issue #15): ModernSession::ui_read answers in the draft envelope with careerId, worldId, stateRevision, date, season, scope and Money in minor units. Careers and human managers get persistent ids (saved in state/modern.json, older saves get them on load). Reads: session and desktop. Engine decisions on the P0 points in docs/new_engine/ui-anbindung.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9061123c7e
commit
3336d01004
9 files changed
+342
-2
No files matched your search
@@ -774,6 +774,7 @@ ModernSession::ModernSession(const std::filesystem::path &data, uint32_t watcom_
|
||||
throw FormatError(saved_turn_error_);
|
||||
if (!native)
|
||||
capture_source_desk_callargs();
|
||||
modern::ensure_ui_identities(g_); // saves from before the interface contract get their ids now
|
||||
}
|
||||
|
||||
int ModernSession::runtime_club(int master) const { return runtime_club(g_, master); }
|
||||
@@ -947,6 +948,7 @@ bool ModernSession::commit_manager_join(ui::CareerInitializationResult& result,
|
||||
next.desktop = desktop_projection(next_revision); next.managers = managers_;
|
||||
next.preparation = preparation_projection(next_revision);
|
||||
ui::validate_preparation_context(next.preparation);
|
||||
modern::ensure_ui_identities(g_); // the new manager's contract id
|
||||
result = std::move(next); revision = next_revision; manager_join_.reset();
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
@@ -4317,6 +4319,7 @@ bool ModernSession::finish(ui::CareerInitializationResult& result, std::string&
|
||||
capture_source_desk_callargs();
|
||||
// Both UI projections must reflect the freshly initialized driver cursor.
|
||||
// Reuse its prepared groups; these projections do not prepare an event or draw RNG.
|
||||
modern::ensure_ui_identities(g_); // career and manager ids of the interface contract
|
||||
result.desktop = desktop_projection(1);
|
||||
result.preparation = preparation_projection(1);
|
||||
for (size_t m = 0; m < managers_.size(); ++m)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
#include "modern/content/projections.hpp"
|
||||
#include "modern/content/statistics.hpp"
|
||||
#include "modern/content/ui_contract.hpp"
|
||||
#include "modern/content/world_expand.hpp"
|
||||
// The engine side of the UI's career handoff (src/ui/flow.hpp, ENGINE_BINDING.md).
|
||||
//
|
||||
@@ -835,6 +836,18 @@ public:
|
||||
cli::Json read(const cli::Json& request) const {
|
||||
return query_projection(g_, int(g_.memory.has(::bmh::layout::ActiveManager) ? g_.memory.u8(::bmh::layout::ActiveManager) : 0), request);
|
||||
}
|
||||
// The interface contract (docs/new_engine/ui-anbindung.md): a read in the contract's envelope
|
||||
// for the manager at the desk, at the revision the caller holds. Read-only.
|
||||
cli::Json ui_read(const cli::Json& request, uint64_t revision) const {
|
||||
UiContext context;
|
||||
context.state_revision = revision;
|
||||
context.manager = int(g_.memory.has(::bmh::layout::ActiveManager) ? g_.memory.u8(::bmh::layout::ActiveManager) : 0);
|
||||
const ui::DeskState desk = desktop_projection(revision);
|
||||
context.next_opponent = desk.next_opponent;
|
||||
context.next_competition = desk.next_competition_label;
|
||||
context.next_away = desk.next_match_away;
|
||||
return modern::ui_read(g_, context, request);
|
||||
}
|
||||
ModernState& state() { return g_; }
|
||||
const TurnResultSnapshot& last_turn_results() const { return turn_driver_.last_results; }
|
||||
// Owned presentation for the event completed by the last accepted kickoff.
|
||||
|
||||
Reference in new issue
Block a user