Player12
An open source football management simulator
Loading...
Searching...
No Matches
runtime_editor_dialog.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// Football Management Project
3// Copyright (c) 2025 - 2026 Flavio Milinanni. All Rights Reserved.
4//
5// This file is part of the Football Management Project.
6// See the LICENSE file in the project root.
7// -----------------------------------------------------------------------------
8
9#pragma once
10
11#include <array>
12#include <map>
13#include <memory>
14#include <optional>
15#include <string>
16#include <string_view>
17#include <vector>
18
20#include "gui/nav_history.h"
22
26{
27 public:
28 explicit RuntimeEditorDialog(GameController& owner);
34 void open(const std::optional<NavEntry>& context);
35 void open(const EditorContext& context);
36 void render();
37 bool isOpen() const { return popup.opened; }
38 enum class Request
39 {
40 None,
41 Apply,
42 Undo
43 };
45 const std::vector<RuntimeEditor::Change>& changes() const
46 {
47 return pending_changes;
48 }
49 std::shared_ptr<GameController::EditorSession> session() const
50 {
51 return editor_session;
52 }
53 void finish(bool success, std::string message);
54
55 private:
57 struct Field
58 {
59 std::string name;
60 std::string text;
61 int type = SQLITE_TEXT;
62 bool readonly = false;
63 };
64 void refresh();
65 void chooseTable(const std::string& name);
66 static void renderAttributes(Field& field);
67 void selectRow(std::size_t index);
68 void stage();
69 void renderForm();
70 static void renderField(Field& field, const EditorField& descriptor);
71 static void renderNumber(Field& field, const EditorField& descriptor);
72 static void renderChoice(Field& field, const EditorField& descriptor);
73 void renderSection(std::string_view section,
74 const std::vector<EditorField>& descriptors);
75 void renderNavigation();
76 void renderBody(float footer);
77 void renderActions();
78 void renderConfirmation();
79 const EditorField* fieldDescriptor(const std::string& name) const;
80 void limitToGameplay();
81 void renderBrowser();
82 bool formDirty() const;
83 void close();
85 std::shared_ptr<GameController::EditorSession> editor_session;
86 std::vector<RuntimeEditor::Table> tables;
88 std::string selected_table;
91 std::map<std::string, RuntimeEditor::Value, std::less<>> context_filter;
92 std::map<std::string,
93 std::map<std::string, RuntimeEditor::Value, std::less<>>,
94 std::less<>>
96 std::array<char, 128> search{};
97 int offset = 0;
98 std::optional<RuntimeEditor::Row> original;
99 std::vector<Field> fields;
100 std::map<std::string, std::vector<EditorField>, std::less<>> presentations;
101 bool show_records = false;
102 std::string focus_label;
104 {
105 bool opened = false;
106 bool close_requested = false;
107 bool popup_requested = false;
108 bool undo_confirm = false;
109 };
111 std::string error;
113 std::vector<RuntimeEditor::Change> pending_changes;
114};
Manages the core game logic, interacting with teams, leagues, and players.
Definition game_controller.h:70
Definition runtime_editor_dialog.h:26
void chooseTable(const std::string &name)
Definition runtime_editor_dialog.cpp:588
const EditorField * fieldDescriptor(const std::string &name) const
Definition runtime_editor_dialog.cpp:704
PlayerID context_player
Definition runtime_editor_dialog.h:89
std::vector< RuntimeEditor::Table > tables
Definition runtime_editor_dialog.h:86
Request takeRequest()
Definition runtime_editor_dialog.cpp:1120
void renderNavigation()
Definition runtime_editor_dialog.cpp:1001
void finish(bool success, std::string message)
Definition runtime_editor_dialog.cpp:1127
TeamID context_team
Definition runtime_editor_dialog.h:90
~RuntimeEditorDialog()
Definition runtime_editor_dialog.cpp:258
std::map< std::string, RuntimeEditor::Value, std::less<> > context_filter
Definition runtime_editor_dialog.h:91
void renderActions()
Definition runtime_editor_dialog.cpp:1057
void renderConfirmation()
Definition runtime_editor_dialog.cpp:1093
static void renderChoice(Field &field, const EditorField &descriptor)
Definition runtime_editor_dialog.cpp:739
RuntimeEditor::Page page
Definition runtime_editor_dialog.h:87
std::vector< RuntimeEditor::Change > pending_changes
Definition runtime_editor_dialog.h:113
std::array< char, 128 > search
Definition runtime_editor_dialog.h:96
void renderForm()
Definition runtime_editor_dialog.cpp:837
RuntimeEditorDialog & operator=(RuntimeEditorDialog &&)=delete
PopupState popup
Definition runtime_editor_dialog.h:110
void renderBody(float footer)
Definition runtime_editor_dialog.cpp:1034
std::shared_ptr< GameController::EditorSession > session() const
Definition runtime_editor_dialog.h:49
void limitToGameplay()
Definition runtime_editor_dialog.cpp:718
static void renderField(Field &field, const EditorField &descriptor)
Definition runtime_editor_dialog.cpp:807
void render()
Definition runtime_editor_dialog.cpp:924
std::vector< Field > fields
Definition runtime_editor_dialog.h:99
const std::vector< RuntimeEditor::Change > & changes() const
Definition runtime_editor_dialog.h:45
Request request
Definition runtime_editor_dialog.h:112
RuntimeEditorDialog(RuntimeEditorDialog &&)=delete
std::string error
Definition runtime_editor_dialog.h:111
void open(const std::optional< NavEntry > &context)
Definition runtime_editor_dialog.cpp:266
void renderSection(std::string_view section, const std::vector< EditorField > &descriptors)
Definition runtime_editor_dialog.cpp:881
std::optional< RuntimeEditor::Row > original
Definition runtime_editor_dialog.h:98
void selectRow(std::size_t index)
Definition runtime_editor_dialog.cpp:399
std::string focus_label
Definition runtime_editor_dialog.h:102
void refresh()
Definition runtime_editor_dialog.cpp:374
void stage()
Definition runtime_editor_dialog.cpp:430
std::map< std::string, std::vector< EditorField >, std::less<> > presentations
Definition runtime_editor_dialog.h:100
RuntimeEditorDialog & operator=(const RuntimeEditorDialog &)=delete
std::string selected_table
Definition runtime_editor_dialog.h:88
bool isOpen() const
Definition runtime_editor_dialog.h:37
RuntimeEditorDialog(const RuntimeEditorDialog &)=delete
std::shared_ptr< GameController::EditorSession > editor_session
Definition runtime_editor_dialog.h:85
int offset
Definition runtime_editor_dialog.h:97
static void renderAttributes(Field &field)
Definition runtime_editor_dialog.cpp:647
bool formDirty() const
Definition runtime_editor_dialog.cpp:1141
bool show_records
Definition runtime_editor_dialog.h:101
GameController & controller
Definition runtime_editor_dialog.h:84
void close()
Definition runtime_editor_dialog.cpp:364
Request
Definition runtime_editor_dialog.h:39
std::map< std::string, std::map< std::string, RuntimeEditor::Value, std::less<> >, std::less<> > scoped_filters
Definition runtime_editor_dialog.h:95
void renderBrowser()
Definition runtime_editor_dialog.cpp:530
friend class GameFlowTest_GUIFlowLifecycle_Test
Definition runtime_editor_dialog.h:56
static void renderNumber(Field &field, const EditorField &descriptor)
Definition runtime_editor_dialog.cpp:762
const char * name
Definition input_actions.cpp:26
int index
Definition runtime_editor.cpp:94
Definition editor_context.h:23
Definition editor_fields.h:24
Definition runtime_editor_dialog.h:58
std::string name
Definition runtime_editor_dialog.h:59
bool readonly
Definition runtime_editor_dialog.h:62
int type
Definition runtime_editor_dialog.h:61
std::string text
Definition runtime_editor_dialog.h:60
Definition runtime_editor_dialog.h:104
bool undo_confirm
Definition runtime_editor_dialog.h:108
bool popup_requested
Definition runtime_editor_dialog.h:107
bool opened
Definition runtime_editor_dialog.h:105
bool close_requested
Definition runtime_editor_dialog.h:106
Definition runtime_editor.h:75
uint16_t TeamID
Type alias for Team identifiers.
Definition types.h:18
uint32_t PlayerID
Type alias for Player identifiers.
Definition types.h:21