yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
session_coordinator.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_SYSTEM_SESSION_COORDINATOR_H_
2#define YAZE_APP_EDITOR_SYSTEM_SESSION_COORDINATOR_H_
3
4#include <deque>
5#include <string>
6#include <vector>
7
8#include "absl/status/status.h"
11#include "app/rom.h"
12#include "imgui/imgui.h"
13
14// Forward declarations
15namespace yaze {
16class Rom;
17namespace editor {
18class EditorManager;
19class EditorSet;
20class EditorCardRegistry;
21}
22}
23
24namespace yaze {
25namespace editor {
26
27// Forward declarations
28class EditorSet;
29class ToastManager;
30
41 public:
42 explicit SessionCoordinator(void* sessions_ptr,
43 EditorCardRegistry* card_registry,
44 ToastManager* toast_manager,
45 UserSettings* user_settings);
47
48 void SetEditorManager(EditorManager* manager) { editor_manager_ = manager; }
49
50 // Session lifecycle management
51 void CreateNewSession();
54 void CloseSession(size_t index);
55 void RemoveSession(size_t index);
56 void SwitchToSession(size_t index);
57
58 // Session activation and queries
59 void ActivateSession(size_t index);
60 size_t GetActiveSessionIndex() const;
61 void* GetActiveSession() const;
63 Rom* GetCurrentRom() const;
65 void* GetSession(size_t index) const;
66 bool HasMultipleSessions() const;
67 size_t GetActiveSessionCount() const;
68 bool HasDuplicateSession(const std::string& filepath) const;
69
70 // Session UI components
72 void DrawSessionManager();
74 void DrawSessionTabs();
76
77 // Session information
78 std::string GetSessionDisplayName(size_t index) const;
79 std::string GetActiveSessionDisplayName() const;
80 void RenameSession(size_t index, const std::string& new_name);
81 std::string GenerateUniqueEditorTitle(const std::string& editor_name, size_t session_index) const;
82
83 // Session state management
84 void SetActiveSessionIndex(size_t index);
85 void UpdateSessionCount();
86
87 // Card coordination across sessions
90 void ShowCardsInCategory(const std::string& category);
91 void HideCardsInCategory(const std::string& category);
92
93 // Session validation
94 bool IsValidSessionIndex(size_t index) const;
95 bool IsSessionActive(size_t index) const;
96 bool IsSessionLoaded(size_t index) const;
97
98 // Session statistics
99 size_t GetTotalSessionCount() const;
100 size_t GetLoadedSessionCount() const;
101 size_t GetEmptySessionCount() const;
102
103 // Session operations with error handling
104 absl::Status LoadRomIntoSession(const std::string& filename, size_t session_index = SIZE_MAX);
105 absl::Status SaveActiveSession(const std::string& filename = "");
106 absl::Status SaveSessionAs(size_t session_index, const std::string& filename);
107 absl::StatusOr<RomSession*> CreateSessionFromRom(Rom&& rom, const std::string& filepath);
108
109 // Session cleanup
111 void ClearAllSessions();
112
113 // Session navigation
114 void FocusNextSession();
116 void FocusFirstSession();
117 void FocusLastSession();
118
119 // Session UI state
124
129
130 // Helper methods
131 void UpdateActiveSession();
132 void ValidateSessionIndex(size_t index) const;
133 std::string GenerateUniqueSessionName(const std::string& base_name) const;
135 void ShowSessionOperationResult(const std::string& operation, bool success);
136
137 // UI helper methods
138 void DrawSessionTab(size_t index, bool is_active);
139 void DrawSessionContextMenu(size_t index);
140 void DrawSessionBadge(size_t index);
141 ImVec4 GetSessionColor(size_t index) const;
142 std::string GetSessionIcon(size_t index) const;
143
144 // Session validation helpers
145 bool IsSessionEmpty(size_t index) const;
146 bool IsSessionClosed(size_t index) const;
147 bool IsSessionModified(size_t index) const;
148 private:
149 // Core dependencies
151 void* sessions_ptr_; // std::deque<EditorManager::RomSession>*
155
156 // Session state
158 size_t session_count_ = 0;
159
160 // UI state
166
167 // Session limits
168 static constexpr size_t kMaxSessions = 8;
169 static constexpr size_t kMinSessions = 1;
170};
171
172} // namespace editor
173} // namespace yaze
174
175#endif // YAZE_APP_EDITOR_SYSTEM_SESSION_COORDINATOR_H_
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:74
Central registry for all editor cards with session awareness and dependency injection.
The EditorManager controls the main editor window and manages the various editor classes.
Contains a complete set of editors for a single ROM instance.
High-level orchestrator for multi-session UI.
void * GetSession(size_t index) const
std::string GenerateUniqueEditorTitle(const std::string &editor_name, size_t session_index) const
absl::StatusOr< RomSession * > CreateSessionFromRom(Rom &&rom, const std::string &filepath)
absl::Status SaveSessionAs(size_t session_index, const std::string &filename)
absl::Status SaveActiveSession(const std::string &filename="")
ImVec4 GetSessionColor(size_t index) const
absl::Status LoadRomIntoSession(const std::string &filename, size_t session_index=SIZE_MAX)
std::string GetSessionDisplayName(size_t index) const
void RenameSession(size_t index, const std::string &new_name)
bool IsSessionModified(size_t index) const
void SetEditorManager(EditorManager *manager)
bool HasDuplicateSession(const std::string &filepath) const
bool IsSessionClosed(size_t index) const
std::string GetSessionIcon(size_t index) const
void ShowCardsInCategory(const std::string &category)
std::string GetActiveSessionDisplayName() const
void ShowSessionOperationResult(const std::string &operation, bool success)
bool IsValidSessionIndex(size_t index) const
bool IsSessionEmpty(size_t index) const
void DrawSessionTab(size_t index, bool is_active)
bool IsSessionActive(size_t index) const
void HideCardsInCategory(const std::string &category)
void ValidateSessionIndex(size_t index) const
bool IsSessionLoaded(size_t index) const
std::string GenerateUniqueSessionName(const std::string &base_name) const
Manages user preferences and settings persistence.
Main namespace for the application.
Definition controller.cc:20
Represents a single session, containing a ROM and its associated editors.