yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_overlay_controls.cc
Go to the documentation of this file.
2
3#include <array>
4#include <stdexcept>
5
7#include "imgui/imgui.h"
8#include "util/i18n/tr.h"
9
10namespace yaze::editor {
11
12namespace {
13
14constexpr std::array<DungeonOverlayControlSpec, 13> kOverlaySpecs = {{
16 {DungeonOverlayControlId::kGrid, "Grid (8x8)"},
18 {DungeonOverlayControlId::kHoverCoordinates, "Hover Coordinates"},
22 {DungeonOverlayControlId::kWaterFillOracle, "Water Fill (Oracle)"},
26 {DungeonOverlayControlId::kCustomObjects, "Custom Objects (Oracle)"},
27 {DungeonOverlayControlId::kCrumbleFloor, "Crumble Floor (Oracle)"},
28}};
29
30} // namespace
31
32const std::array<DungeonOverlayControlSpec, 13>&
34 return kOverlaySpecs;
35}
36
38 return ImGui::CalcTextSize("BG1").x + ImGui::CalcTextSize("BG2").x +
39 ImGui::CalcTextSize(tr("Sprites")).x + ImGui::GetFrameHeight() * 3.0f +
40 ImGui::GetStyle().ItemInnerSpacing.x * 3.0f +
41 ImGui::GetStyle().ItemSpacing.x * 2.0f;
42}
43
45 float height) {
46 (void)height;
47 if (room_id < 0 || room_id >= zelda3::kNumberOfRooms)
48 return;
49 ImGui::PushID("DungeonLayers");
50 gui::AutoWidgetScope scope("Dungeon/Layers");
51 const auto toggle = [&](const char* label, bool* enabled,
52 const char* tooltip) {
53 const bool changed = ImGui::Checkbox(label, enabled);
54 gui::AutoRegisterLastItem("checkbox", label);
55 if (ImGui::IsItemHovered())
56 ImGui::SetTooltip("%s", tooltip);
57 return changed;
58 };
59 bool bg1 = viewer.IsBG1Visible(room_id);
60 if (toggle("BG1", &bg1, "Show BG1"))
61 viewer.SetBG1Visible(room_id, bg1);
62 ImGui::SameLine();
63 bool bg2 = viewer.IsBG2Visible(room_id);
64 if (toggle("BG2", &bg2, "Show BG2"))
65 viewer.SetBG2Visible(room_id, bg2);
66 ImGui::SameLine();
67 bool sprites = viewer.AreSpritesVisible();
68 if (toggle(tr("Sprites"), &sprites, "Show room sprites"))
69 viewer.SetSpritesVisible(sprites);
70 ImGui::PopID();
71}
72
74 gui::AutoWidgetScope scope("Dungeon/ViewOptions");
75 for (const auto& spec : GetDungeonOverlayControlSpecs()) {
77 ImGui::SeparatorText(tr("Authoring"));
78 bool enabled = GetDungeonOverlayControlEnabled(viewer, spec.id);
79 if (ImGui::Checkbox(tr(spec.label), &enabled))
80 SetDungeonOverlayControlEnabled(viewer, spec.id, enabled);
81 gui::AutoRegisterLastItem("checkbox", spec.label);
82 }
83 bool pots = viewer.ArePotItemsVisible();
84 if (ImGui::Checkbox(tr("Pot items"), &pots))
85 viewer.SetPotItemsVisible(pots);
86}
87
121
123 DungeonOverlayControlId id, bool enabled) {
124 switch (id) {
126 viewer.SetChestContentsVisible(enabled);
127 return;
129 viewer.set_show_grid(enabled);
130 return;
132 viewer.set_show_object_bounds(enabled);
133 return;
135 viewer.set_show_coordinate_overlay(enabled);
136 return;
138 viewer.set_show_camera_quadrant_overlay(enabled);
139 return;
141 viewer.set_show_track_collision_overlay(enabled);
142 return;
144 viewer.set_show_custom_collision_overlay(enabled);
145 return;
147 viewer.set_show_water_fill_overlay(enabled);
148 return;
150 viewer.set_show_minecart_sprite_overlay(enabled);
151 return;
153 viewer.set_show_track_gap_overlay(enabled);
154 return;
156 viewer.set_show_track_route_overlay(enabled);
157 return;
159 viewer.set_show_crumble_floor(enabled);
160 return;
162 viewer.set_show_custom_objects_overlay(enabled);
163 return;
164 }
165
166 throw std::invalid_argument("unknown DungeonOverlayControlId");
167}
168
169} // namespace yaze::editor
void SetBG1Visible(int room_id, bool visible)
void SetBG2Visible(int room_id, bool visible)
RAII scope that enables automatic widget registration.
constexpr std::array< DungeonOverlayControlSpec, 13 > kOverlaySpecs
Editors are the view controllers for the application.
void DrawDungeonOverlayControls(DungeonCanvasViewer &viewer)
void SetDungeonOverlayControlEnabled(DungeonCanvasViewer &viewer, DungeonOverlayControlId id, bool enabled)
bool GetDungeonOverlayControlEnabled(const DungeonCanvasViewer &viewer, DungeonOverlayControlId id)
void DrawDungeonLayerControls(DungeonCanvasViewer &viewer, int room_id, float height)
const std::array< DungeonOverlayControlSpec, 13 > & GetDungeonOverlayControlSpecs()
void AutoRegisterLastItem(const std::string &widget_type, const std::string &explicit_label, const std::string &description)
Automatically register the last ImGui item.
constexpr int kNumberOfRooms
Automatic widget registration helpers for ImGui Test Engine integration.