yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_editor_system.h
Go to the documentation of this file.
1#ifndef YAZE_APP_ZELDA3_DUNGEON_DUNGEON_EDITOR_SYSTEM_H
2#define YAZE_APP_ZELDA3_DUNGEON_DUNGEON_EDITOR_SYSTEM_H
3
4#include <chrono>
5#include <functional>
6#include <memory>
7#include <unordered_map>
8#include <vector>
9
10#include "absl/status/status.h"
11#include "absl/status/statusor.h"
13#include "rom/rom.h"
14#include "zelda3/dungeon/room.h"
16#include "zelda3/game_data.h"
17
18namespace yaze {
19namespace zelda3 {
20
33 public:
34 // Editor state
35 struct EditorState {
37 bool is_dirty = false;
38 std::chrono::steady_clock::time_point last_save_time;
39 };
40
41 explicit DungeonEditorSystem(Rom* rom, GameData* game_data = nullptr);
43
44 void SetGameData(GameData* game_data) { game_data_ = game_data; }
45
46 // System initialization and management
47 absl::Status Initialize();
48 absl::Status LoadDungeon(int dungeon_id);
49 absl::Status SaveDungeon();
50 absl::Status SaveRoom(int room_id);
51 absl::Status ReloadRoom(int room_id);
52
53 // Room management
54 absl::Status SetCurrentRoom(int room_id);
55 int GetCurrentRoom() const;
56 absl::StatusOr<Room> GetRoom(int room_id);
57
58 // Object editing (delegated to DungeonObjectEditor)
59 std::shared_ptr<DungeonObjectEditor> GetObjectEditor();
60
61 // Undo/Redo system
62 absl::Status Undo();
63 absl::Status Redo();
64 bool CanUndo() const;
65 bool CanRedo() const;
66 void ClearHistory();
67
68 // Event callbacks
69 using RoomChangedCallback = std::function<void(int room_id)>;
71
72 // Getters
74 Rom* GetROM() const;
75 bool IsDirty() const;
76
77 // ROM management
78 void SetROM(Rom* rom);
79 void SetExternalRoom(Room* room);
80
81 private:
82 absl::Status InitializeObjectEditor();
83 absl::Status LoadRoomData(int room_id);
84 absl::Status SaveRoomData(int room_id);
85
87 GameData* game_data_ = nullptr;
88 std::shared_ptr<DungeonObjectEditor> object_editor_;
89
91
92 // Room data storage
93 std::unordered_map<int, Room> rooms_;
94
95 // Event callbacks
97
98 // Undo/Redo system - stores room object snapshots
99 struct UndoPoint {
101 std::unordered_map<int, Room> rooms;
102 std::chrono::steady_clock::time_point timestamp;
103 };
104
105 std::vector<UndoPoint> undo_history_;
106 std::vector<UndoPoint> redo_history_;
107 static constexpr size_t kMaxUndoHistory = 100;
108};
109
113std::unique_ptr<DungeonEditorSystem> CreateDungeonEditorSystem(
114 Rom* rom, GameData* game_data = nullptr);
115
116} // namespace zelda3
117} // namespace yaze
118
119#endif // YAZE_APP_ZELDA3_DUNGEON_DUNGEON_EDITOR_SYSTEM_H
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:24
void SetGameData(GameData *game_data)
void SetRoomChangedCallback(RoomChangedCallback callback)
std::shared_ptr< DungeonObjectEditor > object_editor_
DungeonEditorSystem(Rom *rom, GameData *game_data=nullptr)
std::shared_ptr< DungeonObjectEditor > GetObjectEditor()
absl::Status SetCurrentRoom(int room_id)
std::unordered_map< int, Room > rooms_
absl::Status LoadDungeon(int dungeon_id)
std::function< void(int room_id)> RoomChangedCallback
absl::StatusOr< Room > GetRoom(int room_id)
std::unique_ptr< DungeonEditorSystem > CreateDungeonEditorSystem(Rom *rom, GameData *game_data)
Factory function to create dungeon editor system.
std::chrono::steady_clock::time_point last_save_time
std::chrono::steady_clock::time_point timestamp