yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
planning_editor.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_PLANNING_PLANNING_EDITOR_H_
2#define YAZE_APP_EDITOR_PLANNING_PLANNING_EDITOR_H_
3
4#include <optional>
5#include <string>
6#include <string_view>
7
8#include "absl/status/status.h"
9#include "app/editor/editor.h"
10#include "core/project_plan.h"
11
12namespace yaze::editor {
13
14// Checks a typed route-step Id before it replaces `current_id`. Rejects an
15// empty (or all-whitespace) Id and an Id another step already uses. Leaving
16// the Id unchanged is OK.
17absl::Status ValidateStepIdEdit(const core::ProjectPlan& plan,
18 std::string_view current_id,
19 std::string_view proposed_id);
20
21// Project planning: goal, milestones, play route and open decisions, kept in
22// the yaze.plan/1 file named by the project's [planning] section. Works with
23// or without a ROM and never writes the ROM; Save() writes only the plan file.
24class PlanningEditor : public Editor {
26
27 public:
29
30 void Initialize() override;
31 absl::Status Load() override { return absl::OkStatus(); }
32 absl::Status Save() override;
33 absl::Status Update() override;
34
35 absl::Status Undo() override { return absl::OkStatus(); }
36 absl::Status Redo() override { return absl::OkStatus(); }
37 absl::Status Cut() override { return absl::OkStatus(); }
38 absl::Status Copy() override { return absl::OkStatus(); }
39 absl::Status Paste() override { return absl::OkStatus(); }
40 absl::Status Find() override { return absl::OkStatus(); }
41 bool CanUndo() const override { return false; }
42 bool CanRedo() const override { return false; }
43 bool CanCut() const override { return false; }
44 bool CanCopy() const override { return false; }
45 bool CanPaste() const override { return false; }
46
47 void DrawOverview();
48 void DrawRoute();
49
50 bool dirty() const { return dirty_; }
51 bool HasPendingProjectDraftChanges() const { return dirty_; }
52 // Called only after an authorized project replacement succeeds, or an
53 // explicit discard. A failed or canceled open must preserve the draft.
55 const std::optional<core::ProjectPlan>& plan() const { return plan_; }
56
57 private:
58 // Loads the plan when the project's [planning] path changes.
59 absl::Status SyncWithProject();
60 absl::Status Reload(bool discard_changes = false);
61 bool DrawPlanHeader();
62 void DrawNoPlan();
63 void DrawGoal();
64 void DrawMilestones();
65 void DrawRouteStrip();
66 void DrawDecisionQueue();
67 void DrawReferences();
68 void DrawAgentStatus();
69 // Read-only agent observation for "<kind>:<id>", drawn under the user's
70 // editable fields for that entry.
71 void DrawAgentObservation(const std::string& key);
72 void DrawStepList();
73 void DrawStepDetail();
74 void DrawItems();
75 void DrawTargets(const std::vector<std::string>& targets, const char* id);
76 void OpenTarget(const std::string& target);
77 void MarkDirty() { dirty_ = true; }
78
79 enum class RemovalKind { kNone, kStep, kItem };
80 // Remove acts only through RequestRemoval -> confirm dialog ->
81 // ConfirmPendingRemoval; the request itself changes no plan data.
82 void RequestRemoval(RemovalKind kind, const std::string& id,
83 std::string label);
86 void DrawRemovalConfirm();
87 // Commits the Id buffer typed for `step_id`; keeps the old Id and sets
88 // step_id_error_ when validation fails.
89 void CommitStepIdEdit(std::string step_id);
90
91 std::string plan_path_;
92 std::string project_path_;
93 std::string loaded_source_;
94 std::optional<core::ProjectPlan> plan_;
95 std::string load_error_;
96 std::string save_error_;
97 std::string new_plan_path_;
98 bool dirty_ = false;
99 bool panels_registered_ = false;
106 // Step Id edit buffer; step_id_edit_for_ is the step it was seeded from.
107 std::string step_id_edit_;
108 std::string step_id_edit_for_;
109 std::string step_id_error_;
110};
111
112} // namespace yaze::editor
113
114#endif // YAZE_APP_EDITOR_PLANNING_PLANNING_EDITOR_H_
Interface for editor classes.
Definition editor.h:252
EditorType type_
Definition editor.h:381
void RequestRemoval(RemovalKind kind, const std::string &id, std::string label)
absl::Status Redo() override
absl::Status Cut() override
bool CanUndo() const override
absl::Status Reload(bool discard_changes=false)
absl::Status Save() override
bool CanCopy() const override
absl::Status Undo() override
absl::Status Paste() override
absl::Status Load() override
bool CanCut() const override
const std::optional< core::ProjectPlan > & plan() const
void CommitStepIdEdit(std::string step_id)
bool CanRedo() const override
void DrawAgentObservation(const std::string &key)
void DrawTargets(const std::vector< std::string > &targets, const char *id)
bool HasPendingProjectDraftChanges() const
absl::Status Find() override
absl::Status Copy() override
bool CanPaste() const override
std::optional< core::ProjectPlan > plan_
absl::Status Update() override
void OpenTarget(const std::string &target)
Editors are the view controllers for the application.
absl::Status ValidateStepIdEdit(const core::ProjectPlan &plan, std::string_view current_id, std::string_view proposed_id)