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
10
11namespace yaze::editor {
12
13using ImGui::BeginTable;
14using ImGui::TableNextColumn;
15
16void OverworldToolbar::Draw(int& current_world, int& current_map,
17 bool& current_map_lock, EditingMode& current_mode,
18 EntityEditMode& entity_edit_mode,
19 PanelManager* panel_manager, bool has_selection,
20 bool scratch_has_data, Rom* rom,
21 zelda3::Overworld* overworld) {
22 if (!overworld || !overworld->is_loaded() || !panel_manager) return;
23
24 // Simplified canvas toolbar - Navigation and Mode controls
25 if (BeginTable("CanvasToolbar", 8,
26 ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit,
27 ImVec2(0, 0), -1)) {
28 ImGui::TableSetupColumn("World", ImGuiTableColumnFlags_WidthFixed,
30 ImGui::TableSetupColumn("Map", ImGuiTableColumnFlags_WidthFixed,
32 ImGui::TableSetupColumn("Area Size", ImGuiTableColumnFlags_WidthFixed,
34 ImGui::TableSetupColumn("Lock", ImGuiTableColumnFlags_WidthFixed,
36 ImGui::TableSetupColumn("Mode", ImGuiTableColumnFlags_WidthFixed,
37 124.0f); // Mouse/Brush/Fill
38 ImGui::TableSetupColumn("Entity",
39 ImGuiTableColumnFlags_WidthStretch); // Entity status
40 ImGui::TableSetupColumn("Panels", ImGuiTableColumnFlags_WidthFixed, 320.0f);
41 ImGui::TableSetupColumn("Sidebar", ImGuiTableColumnFlags_WidthFixed, 50.0f);
42
43 TableNextColumn();
44 ImGui::SetNextItemWidth(kComboWorldWidth);
45 ImGui::Combo("##world", &current_world, kWorldNames, 3);
46
47 TableNextColumn();
48 ImGui::Text("%d (0x%02X)", current_map, current_map);
49
50 TableNextColumn();
51 // Use centralized version detection
52 auto rom_version = zelda3::OverworldVersionHelper::GetVersion(*rom);
53
54 // ALL ROMs support Small/Large. Only v3+ supports Wide/Tall.
55 int current_area_size =
56 static_cast<int>(overworld->overworld_map(current_map)->area_size());
57 ImGui::SetNextItemWidth(kComboAreaSizeWidth);
58
60 // v3+ ROM: Show all 4 area size options
61 if (ImGui::Combo("##AreaSize", &current_area_size, kAreaSizeNames, 4)) {
62 auto status = overworld->ConfigureMultiAreaMap(
63 current_map, static_cast<zelda3::AreaSizeEnum>(current_area_size));
64 if (status.ok()) {
67 }
68 }
69 } else {
70 // Vanilla/v1/v2 ROM: Show only Small/Large (first 2 options)
71 const char* limited_names[] = {"Small (1x1)", "Large (2x2)"};
72 int limited_size = (current_area_size == 0 || current_area_size == 1)
73 ? current_area_size
74 : 0;
75
76 if (ImGui::Combo("##AreaSize", &limited_size, limited_names, 2)) {
77 // limited_size is 0 (Small) or 1 (Large)
78 auto size = (limited_size == 1) ? zelda3::AreaSizeEnum::LargeArea
80 auto status = overworld->ConfigureMultiAreaMap(current_map, size);
81 if (status.ok()) {
84 }
85 }
86
87 if (rom_version == zelda3::OverworldVersion::kVanilla ||
89 HOVER_HINT("Small (1x1) and Large (2x2) maps. Wide/Tall require v3+");
90 }
91 }
92
93 TableNextColumn();
95 current_map_lock ? "Unlock Map" : "Lock Map")) {
96 current_map_lock = !current_map_lock;
97 }
98
99 TableNextColumn();
100 // Mode Controls
101 {
103 "Mouse Mode (1)\nNavigate, pan, and manage entities",
104 current_mode == EditingMode::MOUSE)) {
105 current_mode = EditingMode::MOUSE;
106 }
107
108 ImGui::SameLine(0, 2);
110 "Brush Mode (2/B)\nDraw tiles on the map\nRight-click or I to sample tile16 under cursor",
111 current_mode == EditingMode::DRAW_TILE)) {
112 current_mode = EditingMode::DRAW_TILE;
113 }
114
115 ImGui::SameLine(0, 2);
117 "Fill Screen Mode (F)\nFill the 32x32 screen under the cursor with the selected tile\nRight-click or I to sample tile16 under cursor",
118 current_mode == EditingMode::FILL_TILE)) {
119 current_mode = EditingMode::FILL_TILE;
120 }
121 }
122
123 TableNextColumn();
124 // Entity Status or Version Badge
125 const auto& theme = AgentUI::GetTheme();
126 if (entity_edit_mode != EntityEditMode::NONE) {
127 const char* entity_icon = "";
128 const char* entity_label = "";
129 switch (entity_edit_mode) {
131 entity_icon = ICON_MD_DOOR_FRONT;
132 entity_label = "Entrances";
133 break;
135 entity_icon = ICON_MD_DOOR_BACK;
136 entity_label = "Exits";
137 break;
139 entity_icon = ICON_MD_GRASS;
140 entity_label = "Items";
141 break;
143 entity_icon = ICON_MD_PEST_CONTROL_RODENT;
144 entity_label = "Sprites";
145 break;
147 entity_icon = ICON_MD_ADD_LOCATION;
148 entity_label = "Transports";
149 break;
151 entity_icon = ICON_MD_MUSIC_NOTE;
152 entity_label = "Music";
153 break;
154 default:
155 break;
156 }
157 ImGui::TextColored(theme.selection_secondary, "%s %s", entity_icon,
158 entity_label);
159 } else {
160 // Show ROM version badge when no entity mode is active
161 const char* version_label = "Vanilla";
162 ImVec4 version_color = theme.status_inactive;
163 bool show_upgrade = false;
164
165 switch (rom_version) {
167 version_label = "Vanilla";
168 version_color = theme.text_warning_yellow;
169 show_upgrade = true;
170 break;
172 version_label = "ZSC v1";
173 version_color = theme.status_active;
174 break;
176 version_label = "ZSC v2";
177 version_color = theme.status_active;
178 break;
180 version_label = "ZSC v3";
181 version_color = theme.status_success;
182 break;
183 default:
184 break;
185 }
186
187 ImGui::TextColored(version_color, ICON_MD_INFO " %s", version_label);
188 HOVER_HINT("ROM version determines available overworld features.\n"
189 "v2+: Custom BG colors, main palettes\n"
190 "v3+: Wide/Tall maps, custom tile GFX, animated GFX");
191
192 if (show_upgrade && on_upgrade_rom_version) {
193 ImGui::SameLine();
194 if (gui::PrimaryButton(ICON_MD_UPGRADE " Upgrade")) {
195 on_upgrade_rom_version(3); // Upgrade to v3
196 }
197 HOVER_HINT("Upgrade ROM to ZSCustomOverworld v3\n"
198 "Enables all advanced features");
199 }
200 }
201
202 TableNextColumn();
203 // Panel Toggle Controls - using PanelManager for visibility
204 {
205 gui::StyleVarGuard panel_spacing_guard(ImGuiStyleVar_ItemSpacing,
206 ImVec2(4, 0));
207
208 // Tile16 Editor toggle (Ctrl+T)
209 if (gui::ToolbarIconButton(ICON_MD_EDIT, "Tile16 Editor (Ctrl+T)",
212 }
213
214 ImGui::SameLine();
215 // Tile16 Selector toggle
216 if (gui::ToolbarIconButton(ICON_MD_GRID_ON, "Tile16 Selector",
219 }
220
221 ImGui::SameLine();
222 // Tile8 Selector toggle
223 if (gui::ToolbarIconButton(ICON_MD_GRID_VIEW, "Tile8 Selector",
226 }
227
228 ImGui::SameLine();
229 // Area Graphics toggle
230 if (gui::ToolbarIconButton(ICON_MD_IMAGE, "Area Graphics",
233 }
234
235 ImGui::SameLine();
236 // GFX Groups toggle
237 if (gui::ToolbarIconButton(ICON_MD_LAYERS, "GFX Groups",
240 }
241
242 ImGui::SameLine();
243 // Usage Stats toggle
244 if (gui::ToolbarIconButton(ICON_MD_ANALYTICS, "Usage Statistics",
247 }
248
249 ImGui::SameLine();
250 // Scratch Space toggle
251 if (gui::ToolbarIconButton(ICON_MD_AUTO_FIX_HIGH, "Scratch Workspace",
254 }
255 }
256
257 TableNextColumn();
258 // Sidebar Toggle (Map Properties)
259 if (gui::ToolbarIconButton(ICON_MD_TUNE, "Toggle Map Properties Sidebar",
262 }
263
264 ImGui::EndTable();
265 }
266}
267
268} // 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:28
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
RAII guard for ImGui style vars.
Definition style_guard.h:68
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:261
auto is_loaded() const
Definition overworld.h:583
auto overworld_map(int i) const
Definition overworld.h:528
absl::Status ConfigureMultiAreaMap(int parent_index, AreaSizeEnum size)
Configure a multi-area map structure (Large/Wide/Tall)
Definition overworld.cc:309
#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_TUNE
Definition icons.h:2022
#define ICON_MD_GRASS
Definition icons.h:891
#define ICON_MD_FORMAT_COLOR_FILL
Definition icons.h:830
#define ICON_MD_EDIT
Definition icons.h:645
#define ICON_MD_DOOR_BACK
Definition icons.h:612
#define ICON_MD_AUTO_FIX_HIGH
Definition icons.h:218
#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
const AgentUITheme & GetTheme()
Editors are the view controllers for the application.
constexpr const char * kAreaSizeNames[]
constexpr float kTableColumnWorld
constexpr const char * kWorldNames[]
constexpr float kComboWorldWidth
constexpr float kTableColumnMap
constexpr float kTableColumnAreaSize
constexpr float kComboAreaSizeWidth
constexpr float kTableColumnLock
bool PrimaryButton(const char *label, const ImVec2 &size, const char *panel_id, const char *anim_id)
Draw a primary action button (accented color).
bool ToolbarIconButton(const char *icon, const char *tooltip, bool is_active)
Convenience wrapper for toolbar-sized icon buttons.
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