yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
overworld_toolbar.cc
Go to the documentation of this file.
2
7
8namespace yaze::editor {
9
10using ImGui::BeginTable;
11using ImGui::TableNextColumn;
12
13void OverworldToolbar::Draw(int& current_world, int& current_map,
14 bool& current_map_lock, EditingMode& current_mode,
15 EntityEditMode& entity_edit_mode,
16 PanelManager* panel_manager, bool has_selection,
17 bool scratch_has_data, Rom* rom,
18 zelda3::Overworld* overworld) {
19 if (!overworld || !overworld->is_loaded() || !panel_manager) return;
20
21 // Simplified canvas toolbar - Navigation and Mode controls
22 if (BeginTable("CanvasToolbar", 8,
23 ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit,
24 ImVec2(0, 0), -1)) {
25 ImGui::TableSetupColumn("World", ImGuiTableColumnFlags_WidthFixed,
27 ImGui::TableSetupColumn("Map", ImGuiTableColumnFlags_WidthFixed,
29 ImGui::TableSetupColumn("Area Size", ImGuiTableColumnFlags_WidthFixed,
31 ImGui::TableSetupColumn("Lock", ImGuiTableColumnFlags_WidthFixed,
33 ImGui::TableSetupColumn("Mode", ImGuiTableColumnFlags_WidthFixed,
34 80.0f); // Mouse/Paint
35 ImGui::TableSetupColumn("Entity",
36 ImGuiTableColumnFlags_WidthStretch); // Entity status
37 ImGui::TableSetupColumn("Panels", ImGuiTableColumnFlags_WidthFixed, 320.0f);
38 ImGui::TableSetupColumn("Sidebar", ImGuiTableColumnFlags_WidthFixed, 50.0f);
39
40 TableNextColumn();
41 ImGui::SetNextItemWidth(kComboWorldWidth);
42 ImGui::Combo("##world", &current_world, kWorldNames, 3);
43
44 TableNextColumn();
45 ImGui::Text("%d (0x%02X)", current_map, current_map);
46
47 TableNextColumn();
48 // Use centralized version detection
49 auto rom_version = zelda3::OverworldVersionHelper::GetVersion(*rom);
50
51 // ALL ROMs support Small/Large. Only v3+ supports Wide/Tall.
52 int current_area_size =
53 static_cast<int>(overworld->overworld_map(current_map)->area_size());
54 ImGui::SetNextItemWidth(kComboAreaSizeWidth);
55
57 // v3+ ROM: Show all 4 area size options
58 if (ImGui::Combo("##AreaSize", &current_area_size, kAreaSizeNames, 4)) {
59 auto status = overworld->ConfigureMultiAreaMap(
60 current_map, static_cast<zelda3::AreaSizeEnum>(current_area_size));
61 if (status.ok()) {
64 }
65 }
66 } else {
67 // Vanilla/v1/v2 ROM: Show only Small/Large (first 2 options)
68 const char* limited_names[] = {"Small (1x1)", "Large (2x2)"};
69 int limited_size = (current_area_size == 0 || current_area_size == 1)
70 ? current_area_size
71 : 0;
72
73 if (ImGui::Combo("##AreaSize", &limited_size, limited_names, 2)) {
74 // limited_size is 0 (Small) or 1 (Large)
75 auto size = (limited_size == 1) ? zelda3::AreaSizeEnum::LargeArea
77 auto status = overworld->ConfigureMultiAreaMap(current_map, size);
78 if (status.ok()) {
81 }
82 }
83
84 if (rom_version == zelda3::OverworldVersion::kVanilla ||
86 HOVER_HINT("Small (1x1) and Large (2x2) maps. Wide/Tall require v3+");
87 }
88 }
89
90 TableNextColumn();
91 if (ImGui::Button(current_map_lock ? ICON_MD_LOCK : ICON_MD_LOCK_OPEN,
92 ImVec2(40, 0))) {
93 current_map_lock = !current_map_lock;
94 }
95 HOVER_HINT(current_map_lock ? "Unlock Map" : "Lock Map");
96
97 TableNextColumn();
98 // Mode Controls
99 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2, 0));
101 ImVec2(kIconButtonWidth, 0))) {
102 current_mode = EditingMode::MOUSE;
103 }
104 HOVER_HINT("Mouse Mode (1)\nNavigate, pan, and manage entities");
105
106 ImGui::SameLine();
108 ImVec2(kIconButtonWidth, 0))) {
109 current_mode = EditingMode::DRAW_TILE;
110 }
111 HOVER_HINT("Tile Paint Mode (2)\nDraw tiles on the map");
112 ImGui::PopStyleVar();
113
114 TableNextColumn();
115 // Entity Status or Version Badge
116 if (entity_edit_mode != EntityEditMode::NONE) {
117 const char* entity_icon = "";
118 const char* entity_label = "";
119 switch (entity_edit_mode) {
121 entity_icon = ICON_MD_DOOR_FRONT;
122 entity_label = "Entrances";
123 break;
125 entity_icon = ICON_MD_DOOR_BACK;
126 entity_label = "Exits";
127 break;
129 entity_icon = ICON_MD_GRASS;
130 entity_label = "Items";
131 break;
133 entity_icon = ICON_MD_PEST_CONTROL_RODENT;
134 entity_label = "Sprites";
135 break;
137 entity_icon = ICON_MD_ADD_LOCATION;
138 entity_label = "Transports";
139 break;
141 entity_icon = ICON_MD_MUSIC_NOTE;
142 entity_label = "Music";
143 break;
144 default:
145 break;
146 }
147 ImGui::TextColored(ImVec4(0.4f, 0.8f, 1.0f, 1.0f), "%s %s", entity_icon,
148 entity_label);
149 } else {
150 // Show ROM version badge when no entity mode is active
151 const char* version_label = "Vanilla";
152 ImVec4 version_color = ImVec4(0.6f, 0.6f, 0.6f, 1.0f); // Gray for vanilla
153 bool show_upgrade = false;
154
155 switch (rom_version) {
157 version_label = "Vanilla";
158 version_color = ImVec4(0.7f, 0.7f, 0.5f, 1.0f); // Muted yellow
159 show_upgrade = true;
160 break;
162 version_label = "ZSCustom v1";
163 version_color = ImVec4(0.5f, 0.7f, 0.9f, 1.0f); // Light blue
164 show_upgrade = true;
165 break;
167 version_label = "ZSCustom v2";
168 version_color = ImVec4(0.5f, 0.9f, 0.7f, 1.0f); // Light green
169 show_upgrade = true;
170 break;
172 version_label = "ZSCustom v3";
173 version_color = ImVec4(0.3f, 1.0f, 0.5f, 1.0f); // Bright green
174 break;
175 }
176
177 ImGui::TextColored(version_color, ICON_MD_INFO " %s", version_label);
178 HOVER_HINT("ROM version determines available overworld features.\n"
179 "v2+: Custom BG colors, main palettes\n"
180 "v3+: Wide/Tall maps, custom tile GFX, animated GFX");
181
182 if (show_upgrade && on_upgrade_rom_version) {
183 ImGui::SameLine();
184 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.2f, 0.5f, 0.8f, 1.0f));
185 if (ImGui::SmallButton(ICON_MD_UPGRADE " Upgrade")) {
186 on_upgrade_rom_version(3); // Upgrade to v3
187 }
188 ImGui::PopStyleColor();
189 HOVER_HINT("Upgrade ROM to ZSCustomOverworld v3\n"
190 "Enables all advanced features");
191 }
192 }
193
194 TableNextColumn();
195 // Panel Toggle Controls - using PanelManager for visibility
196 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 0));
197
198 // Tile16 Editor toggle (Ctrl+T)
199 bool tile16_editor_visible =
201 if (gui::ToggleButton(ICON_MD_EDIT, tile16_editor_visible,
202 ImVec2(kPanelToggleButtonWidth, 0))) {
204 }
205 HOVER_HINT("Tile16 Editor (Ctrl+T)");
206
207 ImGui::SameLine();
208
209 // Tile16 Selector toggle
210 bool tile16_selector_visible =
212 if (gui::ToggleButton(ICON_MD_GRID_ON, tile16_selector_visible,
213 ImVec2(kPanelToggleButtonWidth, 0))) {
215 }
216 HOVER_HINT("Tile16 Selector");
217
218 ImGui::SameLine();
219
220 // Tile8 Selector toggle
221 bool tile8_selector_visible =
223 if (gui::ToggleButton(ICON_MD_GRID_VIEW, tile8_selector_visible,
224 ImVec2(kPanelToggleButtonWidth, 0))) {
226 }
227 HOVER_HINT("Tile8 Selector");
228
229 ImGui::SameLine();
230
231 // Area Graphics toggle
232 bool area_gfx_visible =
234 if (gui::ToggleButton(ICON_MD_IMAGE, area_gfx_visible,
235 ImVec2(kPanelToggleButtonWidth, 0))) {
237 }
238 HOVER_HINT("Area Graphics");
239
240 ImGui::SameLine();
241
242 // GFX Groups toggle
243 bool gfx_groups_visible =
245 if (gui::ToggleButton(ICON_MD_LAYERS, gfx_groups_visible,
246 ImVec2(kPanelToggleButtonWidth, 0))) {
248 }
249 HOVER_HINT("GFX Groups");
250
251 ImGui::SameLine();
252
253 // Usage Stats toggle
254 bool usage_stats_visible =
256 if (gui::ToggleButton(ICON_MD_ANALYTICS, usage_stats_visible,
257 ImVec2(kPanelToggleButtonWidth, 0))) {
259 }
260 HOVER_HINT("Usage Statistics");
261
262 ImGui::SameLine();
263
264 // Scratch Space toggle
265 bool scratch_visible =
267 if (gui::ToggleButton(ICON_MD_BRUSH, scratch_visible,
268 ImVec2(kPanelToggleButtonWidth, 0))) {
270 }
271 HOVER_HINT("Scratch Workspace");
272
273 ImGui::PopStyleVar();
274
275 TableNextColumn();
276 // Sidebar Toggle (Map Properties)
277 bool properties_visible =
279 if (gui::ToggleButton(ICON_MD_TUNE, properties_visible,
280 ImVec2(kIconButtonWidth, 0))) {
282 }
283 HOVER_HINT("Toggle Map Properties Sidebar");
284
285 ImGui::EndTable();
286 }
287}
288
289} // namespace yaze::editor
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
std::function< void()> on_refresh_map
void Draw(int &current_world, int &current_map, bool &current_map_lock, EditingMode &current_mode, EntityEditMode &entity_edit_mode, PanelManager *panel_manager, bool has_selection, bool scratch_has_data, Rom *rom, zelda3::Overworld *overworld)
std::function< void()> on_refresh_graphics
std::function< void(int)> on_upgrade_rom_version
Central registry for all editor cards with session awareness and dependency injection.
bool TogglePanel(size_t session_id, const std::string &base_card_id)
bool IsPanelVisible(size_t session_id, const std::string &base_card_id) const
static OverworldVersion GetVersion(const Rom &rom)
Detect ROM version from ASM marker byte.
static bool SupportsAreaEnum(OverworldVersion version)
Check if ROM supports area enum system (v3+ only)
Represents the full Overworld data, light and dark world.
Definition overworld.h:217
auto is_loaded() const
Definition overworld.h:528
auto overworld_map(int i) const
Definition overworld.h:473
absl::Status ConfigureMultiAreaMap(int parent_index, AreaSizeEnum size)
Configure a multi-area map structure (Large/Wide/Tall)
Definition overworld.cc:306
#define ICON_MD_GRID_VIEW
Definition icons.h:897
#define ICON_MD_INFO
Definition icons.h:993
#define ICON_MD_UPGRADE
Definition icons.h:2047
#define ICON_MD_LOCK_OPEN
Definition icons.h:1142
#define ICON_MD_LOCK
Definition icons.h:1140
#define ICON_MD_DRAW
Definition icons.h:625
#define ICON_MD_BRUSH
Definition icons.h:325
#define ICON_MD_TUNE
Definition icons.h:2022
#define ICON_MD_GRASS
Definition icons.h:891
#define ICON_MD_EDIT
Definition icons.h:645
#define ICON_MD_DOOR_BACK
Definition icons.h:612
#define ICON_MD_MUSIC_NOTE
Definition icons.h:1264
#define ICON_MD_GRID_ON
Definition icons.h:896
#define ICON_MD_LAYERS
Definition icons.h:1068
#define ICON_MD_DOOR_FRONT
Definition icons.h:613
#define ICON_MD_IMAGE
Definition icons.h:982
#define ICON_MD_ADD_LOCATION
Definition icons.h:100
#define ICON_MD_MOUSE
Definition icons.h:1251
#define ICON_MD_PEST_CONTROL_RODENT
Definition icons.h:1430
#define ICON_MD_ANALYTICS
Definition icons.h:154
#define HOVER_HINT(string)
Definition macro.h:24
Editors are the view controllers for the application.
Definition agent_chat.cc:23
constexpr const char * kAreaSizeNames[]
constexpr float kPanelToggleButtonWidth
constexpr float kTableColumnWorld
constexpr const char * kWorldNames[]
constexpr float kComboWorldWidth
constexpr float kTableColumnMap
constexpr float kTableColumnAreaSize
constexpr float kIconButtonWidth
constexpr float kComboAreaSizeWidth
constexpr float kTableColumnLock
bool ToggleButton(const char *label, bool active, const ImVec2 &size)
AreaSizeEnum
Area size enumeration for v3+ ROMs.
@ kZSCustomV2
Parent system, BG colors, main palettes.
@ kZSCustomV1
Basic features, expanded pointers.
@ kVanilla
0xFF in ROM, no ZScream ASM applied
@ kZSCustomV3
Area enum, wide/tall areas, all features.
static constexpr const char * kMapProperties
static constexpr const char * kTile8Selector
static constexpr const char * kAreaGraphics
static constexpr const char * kScratchSpace
static constexpr const char * kTile16Editor
static constexpr const char * kTile16Selector
static constexpr const char * kGfxGroups
static constexpr const char * kUsageStats