Implement multi-session support and welcome screen in EditorManager
- Removed the homepage display logic and replaced it with a welcome screen that appears when no ROM is loaded or no active editors are present. - Enhanced session management by iterating through all sessions to check for active editors, allowing for better multi-session docking. - Introduced new methods for generating unique editor titles based on session context and added feature flags for per-session configurations. - Added safeguards for ROM loading state checks in editor methods to prevent operations on unloaded ROMs.
This commit is contained in:
42
src/app/editor/editor_safeguards.h
Normal file
42
src/app/editor/editor_safeguards.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef YAZE_APP_EDITOR_SAFEGUARDS_H
|
||||
#define YAZE_APP_EDITOR_SAFEGUARDS_H
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
|
||||
// Macro for checking ROM loading state in editor methods
|
||||
#define REQUIRE_ROM_LOADED(rom_ptr, operation) \
|
||||
do { \
|
||||
if (!(rom_ptr) || !(rom_ptr)->is_loaded()) { \
|
||||
return absl::FailedPreconditionError( \
|
||||
absl::StrFormat("%s: ROM not loaded", (operation))); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// Macro for ROM state checking with custom error message
|
||||
#define CHECK_ROM_STATE(rom_ptr, message) \
|
||||
do { \
|
||||
if (!(rom_ptr) || !(rom_ptr)->is_loaded()) { \
|
||||
return absl::FailedPreconditionError(message); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// Helper function for generating consistent ROM status messages
|
||||
inline std::string GetRomStatusMessage(const Rom* rom) {
|
||||
if (!rom) return "No ROM loaded";
|
||||
if (!rom->is_loaded()) return "ROM failed to load";
|
||||
return absl::StrFormat("ROM loaded: %s", rom->title());
|
||||
}
|
||||
|
||||
// Helper function to check if ROM is in a valid state for editing
|
||||
inline bool IsRomReadyForEditing(const Rom* rom) {
|
||||
return rom && rom->is_loaded() && !rom->title().empty();
|
||||
}
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_APP_EDITOR_SAFEGUARDS_H
|
||||
Reference in New Issue
Block a user