yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
map_properties.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_OVERWORLD_MAP_PROPERTIES_H
2#define YAZE_APP_EDITOR_OVERWORLD_MAP_PROPERTIES_H
3
4#include <functional>
5#include <string>
6#include <vector>
7
8#include "absl/status/status.h"
9#include "absl/status/statusor.h"
13#include "rom/rom.h"
15
16// Forward declaration
17namespace yaze {
18namespace project {
19struct YazeProject;
20}
21namespace editor {
22class OverworldEditor;
23struct SharedClipboard;
24} // namespace editor
25} // namespace yaze
26
27namespace yaze {
28namespace editor {
29
31 public:
32 // Callback types for refresh operations
33 using RefreshCallback = std::function<void()>;
34 using RefreshPaletteCallback = std::function<absl::Status()>;
35 using ForceRefreshGraphicsCallback = std::function<void(int)>;
37 std::function<absl::Status(const OverworldPropertyEdit&)>;
38 using PropertyEditBatchCallback = std::function<absl::Status(
39 const std::vector<OverworldPropertyEdit>&, const std::string&)>;
41 std::function<absl::Status(const std::string&, int, const std::string&)>;
42
44 zelda3::Overworld* overworld, Rom* rom,
45 std::array<gfx::Bitmap, zelda3::kNumOverworldMaps>* maps_bmp = nullptr,
46 gui::Canvas* canvas = nullptr, int* game_state = nullptr)
47 : overworld_(overworld),
48 rom_(rom),
49 maps_bmp_(maps_bmp),
50 canvas_(canvas),
51 game_state_(game_state) {}
52
53 // Set callbacks for refresh operations
55 RefreshCallback refresh_map_properties,
56 RefreshCallback refresh_overworld_map,
57 RefreshPaletteCallback refresh_map_palette,
58 RefreshPaletteCallback refresh_tile16_blockset = nullptr,
59 ForceRefreshGraphicsCallback force_refresh_graphics = nullptr) {
60 refresh_map_properties_ = std::move(refresh_map_properties);
61 refresh_overworld_map_ = std::move(refresh_overworld_map);
62 refresh_map_palette_ = std::move(refresh_map_palette);
63 refresh_tile16_blockset_ = std::move(refresh_tile16_blockset);
64 force_refresh_graphics_ = std::move(force_refresh_graphics);
65 }
66
67 // Set callbacks for entity operations
69 std::function<void(const std::string&)> insert_callback) {
70 entity_insert_callback_ = std::move(insert_callback);
71 }
72
73 // Set callback for tile16 editing from context menu
74 void SetTile16EditCallback(std::function<void()> callback) {
75 edit_tile16_callback_ = std::move(callback);
76 }
77
78 void SetTile16SampleCallback(std::function<bool()> callback) {
79 sample_tile16_callback_ = std::move(callback);
80 }
81
82 void SetMapSelectionCallback(std::function<void(int, bool)> callback) {
83 map_selection_callback_ = std::move(callback);
84 }
85
87 property_edit_callback_ = std::move(callback);
88 }
89
93
97
98 // Main interface methods
99 void DrawCanvasToolbar(int& current_world, int& current_map,
100 bool& current_map_lock,
101 bool& show_map_properties_panel,
102 bool& show_custom_bg_color_editor,
103 bool& show_overlay_editor, bool& show_overlay_preview,
104 int& game_state, EditingMode& current_mode,
105 EntityEditMode& entity_edit_mode);
106
107 void DrawMapPropertiesPanel(int current_map, bool& show_map_properties_panel);
108
109 void DrawCustomBackgroundColorEditor(int current_map,
110 bool& show_custom_bg_color_editor);
111
112 void DrawOverlayEditor(int current_map, bool& show_overlay_editor);
113
114 // Overlay preview functionality
115 void DrawOverlayPreviewOnMap(int current_map, int current_world,
116 bool show_overlay_preview);
117
118 // Context menu integration
119 void SetupCanvasContextMenu(gui::Canvas& canvas, int current_map,
120 bool& current_map_lock,
121 bool& show_map_properties_panel,
122 bool& show_custom_bg_color_editor,
123 bool& show_overlay_editor, int current_mode = 0,
124 project::YazeProject* project = nullptr,
125 SharedClipboard* shared_clipboard = nullptr);
126
127 absl::Status ApplyPropertyEdit(const OverworldPropertyEdit& edit);
128 absl::Status ApplyPropertyEdits(
129 const std::vector<OverworldPropertyEdit>& edits,
130 const std::string& description = {});
131 absl::Status ApplyPropertyEditDirect(const OverworldPropertyEdit& edit);
132 absl::Status CheckPropertyEditSupported(
133 const OverworldPropertyEdit& edit) const;
134 absl::StatusOr<int> ReadPropertyValue(
135 const OverworldPropertyEdit& edit) const;
136
137 // Utility methods - now call the callbacks
139 void RefreshOverworldMap();
140 absl::Status RefreshMapPalette();
141 absl::Status RefreshTile16Blockset();
142 void ForceRefreshGraphics(int map_index);
143
144 // Helper to refresh sibling map graphics for multi-area maps
145 void RefreshSiblingMapGraphics(int map_index, bool include_self = false);
146
147 private:
148 // Property category drawers
149 void DrawGraphicsPopup(int current_map, int game_state);
150 void DrawPalettesPopup(int current_map, int game_state,
151 bool& show_custom_bg_color_editor);
152 void DrawPropertiesPopup(int current_map, bool& show_map_properties_panel,
153 bool& show_overlay_preview, int& game_state);
154
155 // Overlay and mosaic functionality
156 void DrawMosaicControls(int current_map);
157 void DrawOverlayControls(int current_map, bool& show_overlay_preview);
158 std::string GetOverlayDescription(uint16_t overlay_id);
159
160 // Integrated toolset popup functions
161 void DrawToolsPopup(int& current_mode);
162 void DrawViewPopup();
164
165 // Tab content drawers
166 void DrawBasicPropertiesTab(int current_map);
167 void DrawSpritePropertiesTab(int current_map);
168 void DrawCustomFeaturesTab(int current_map);
169 void DrawTileGraphicsTab(int current_map);
170 void DrawMusicTab(int current_map);
171
172 int CurrentGameState() const;
173 int CurrentGameState(int fallback) const;
174 void SetCurrentGameState(int game_state);
175 void PrepareMapForGraphicsRefresh(int map_index);
176
179 std::array<gfx::Bitmap, zelda3::kNumOverworldMaps>* maps_bmp_;
183
184 // Callbacks for refresh operations
190
191 // Callback for entity insertion (generic, editor handles entity types)
192 std::function<void(const std::string&)> entity_insert_callback_;
193
194 // Callback for tile16 editing from context menu
195 std::function<void()> edit_tile16_callback_;
196 std::function<bool()> sample_tile16_callback_;
197
198 // Callback for explicit map selection/pinning from the context menu.
199 std::function<void(int, bool)> map_selection_callback_;
203
204 // Using centralized UI constants from ui_constants.h
205};
206
207} // namespace editor
208} // namespace yaze
209
210#endif // YAZE_APP_EDITOR_OVERWORLD_MAP_PROPERTIES_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:28
ResourceLabelEditCallback resource_label_edit_callback_
void PrepareMapForGraphicsRefresh(int map_index)
absl::Status ApplyPropertyEdit(const OverworldPropertyEdit &edit)
std::array< gfx::Bitmap, zelda3::kNumOverworldMaps > * maps_bmp_
std::function< void()> RefreshCallback
std::function< void()> edit_tile16_callback_
void SetPropertyEditCallback(PropertyEditCallback callback)
void DrawOverlayEditor(int current_map, bool &show_overlay_editor)
PropertyEditBatchCallback property_edit_batch_callback_
void DrawPropertiesPopup(int current_map, bool &show_map_properties_panel, bool &show_overlay_preview, int &game_state)
void SetTile16EditCallback(std::function< void()> callback)
std::function< bool()> sample_tile16_callback_
std::function< void(int, bool)> map_selection_callback_
RefreshPaletteCallback refresh_tile16_blockset_
void DrawOverlayPreviewOnMap(int current_map, int current_world, bool show_overlay_preview)
absl::Status ApplyPropertyEdits(const std::vector< OverworldPropertyEdit > &edits, const std::string &description={})
absl::Status CheckPropertyEditSupported(const OverworldPropertyEdit &edit) const
void SetEntityCallbacks(std::function< void(const std::string &)> insert_callback)
void DrawMosaicControls(int current_map)
void DrawMapPropertiesPanel(int current_map, bool &show_map_properties_panel)
void SetResourceLabelEditCallback(ResourceLabelEditCallback callback)
MapPropertiesSystem(zelda3::Overworld *overworld, Rom *rom, std::array< gfx::Bitmap, zelda3::kNumOverworldMaps > *maps_bmp=nullptr, gui::Canvas *canvas=nullptr, int *game_state=nullptr)
std::function< void(int)> ForceRefreshGraphicsCallback
void SetTile16SampleCallback(std::function< bool()> callback)
void SetPropertyEditBatchCallback(PropertyEditBatchCallback callback)
void SetRefreshCallbacks(RefreshCallback refresh_map_properties, RefreshCallback refresh_overworld_map, RefreshPaletteCallback refresh_map_palette, RefreshPaletteCallback refresh_tile16_blockset=nullptr, ForceRefreshGraphicsCallback force_refresh_graphics=nullptr)
std::function< void(const std::string &) entity_insert_callback_)
void DrawSpritePropertiesTab(int current_map)
void DrawToolsPopup(int &current_mode)
RefreshPaletteCallback refresh_map_palette_
void DrawBasicPropertiesTab(int current_map)
void DrawCustomFeaturesTab(int current_map)
void DrawPalettesPopup(int current_map, int game_state, bool &show_custom_bg_color_editor)
void SetCurrentGameState(int game_state)
void SetupCanvasContextMenu(gui::Canvas &canvas, int current_map, bool &current_map_lock, bool &show_map_properties_panel, bool &show_custom_bg_color_editor, bool &show_overlay_editor, int current_mode=0, project::YazeProject *project=nullptr, SharedClipboard *shared_clipboard=nullptr)
void DrawCustomBackgroundColorEditor(int current_map, bool &show_custom_bg_color_editor)
std::function< absl::Status(const OverworldPropertyEdit &)> PropertyEditCallback
absl::StatusOr< int > ReadPropertyValue(const OverworldPropertyEdit &edit) const
std::function< absl::Status( const std::vector< OverworldPropertyEdit > &, const std::string &)> PropertyEditBatchCallback
void DrawCanvasToolbar(int &current_world, int &current_map, bool &current_map_lock, bool &show_map_properties_panel, bool &show_custom_bg_color_editor, bool &show_overlay_editor, bool &show_overlay_preview, int &game_state, EditingMode &current_mode, EntityEditMode &entity_edit_mode)
std::function< absl::Status(const std::string &, int, const std::string &)> ResourceLabelEditCallback
absl::Status ApplyPropertyEditDirect(const OverworldPropertyEdit &edit)
void SetMapSelectionCallback(std::function< void(int, bool)> callback)
std::function< absl::Status()> RefreshPaletteCallback
void RefreshSiblingMapGraphics(int map_index, bool include_self=false)
void DrawTileGraphicsTab(int current_map)
ForceRefreshGraphicsCallback force_refresh_graphics_
std::string GetOverlayDescription(uint16_t overlay_id)
PropertyEditCallback property_edit_callback_
void DrawOverlayControls(int current_map, bool &show_overlay_preview)
void DrawGraphicsPopup(int current_map, int game_state)
Modern, robust canvas for drawing and manipulating graphics.
Definition canvas.h:64
Represents the full Overworld data, light and dark world.
Definition overworld.h:389
Modern project structure with comprehensive settings consolidation.
Definition project.h:172