yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_settings_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_PANELS_DUNGEON_SETTINGS_PANEL_H
2#define YAZE_APP_EDITOR_DUNGEON_PANELS_DUNGEON_SETTINGS_PANEL_H
3
8#include "core/features.h"
9
10namespace yaze::editor {
11
13 public:
15 : viewer_(viewer) {}
16
17 std::string GetId() const override { return "dungeon.settings"; }
18 std::string GetDisplayName() const override { return "Dungeon Settings"; }
19 std::string GetIcon() const override { return ICON_MD_SETTINGS; }
20 std::string GetEditorCategory() const override { return "Dungeon"; }
21
22 void SetCanvasViewer(DungeonCanvasViewer* viewer) { viewer_ = viewer; }
23 void SetSaveRoomCallback(std::function<void(int)> callback) {
24 save_room_callback_ = std::move(callback);
25 }
26 void SetSaveAllRoomsCallback(std::function<void()> callback) {
27 save_all_rooms_callback_ = std::move(callback);
28 }
29 void SetCurrentRoomId(int* room_id) { current_room_id_ = room_id; }
30
31 void Draw(bool* p_open) override {
32 (void)p_open;
33
34 if (ImGui::CollapsingHeader(ICON_MD_WORKSPACES " UI",
35 ImGuiTreeNodeFlags_DefaultOpen)) {
36 ImGui::Indent();
37 auto& flags = core::FeatureFlags::get().dungeon;
38 ImGui::Checkbox("Use Dungeon Workbench (single window)",
39 &flags.kUseWorkbench);
40 if (ImGui::IsItemHovered()) {
41 ImGui::SetTooltip(
42 "When enabled, the dungeon editor uses a single stable Workbench "
43 "window instead of opening one panel per room.");
44 }
45 ImGui::Unindent();
46 }
47
48 if (ImGui::CollapsingHeader(ICON_MD_SAVE " Save Control",
49 ImGuiTreeNodeFlags_DefaultOpen)) {
50 ImGui::Indent();
51 auto& flags = core::FeatureFlags::get().dungeon;
52
53 ImGui::Text("Data Types to Save:");
54 ImGui::Checkbox("Room Objects", &flags.kSaveObjects);
55 ImGui::Checkbox("Sprites", &flags.kSaveSprites);
56 ImGui::Checkbox("Room Headers", &flags.kSaveRoomHeaders);
57 ImGui::Checkbox("Chests", &flags.kSaveChests);
58 ImGui::Checkbox("Pot Items", &flags.kSavePotItems);
59 ImGui::Checkbox("Palettes", &flags.kSavePalettes);
60 ImGui::Checkbox("Collision Maps", &flags.kSaveCollision);
61 ImGui::Checkbox("Water Fill Zones (Oracle)", &flags.kSaveWaterFillZones);
62 ImGui::Checkbox("Blocks (Pushable/etc)", &flags.kSaveBlocks);
63 ImGui::Checkbox("Torches", &flags.kSaveTorches);
64 ImGui::Checkbox("Pits", &flags.kSavePits);
65
66 ImGui::Separator();
67 if (ImGui::Button("Select All")) {
68 SetAllSaveFlags(true);
69 }
70 ImGui::SameLine();
71 if (ImGui::Button("Select None")) {
72 SetAllSaveFlags(false);
73 }
74
75 ImGui::Separator();
76 if (ImGui::Button(ICON_MD_SAVE " Save Current Room")) {
79 }
80 }
81 ImGui::SameLine();
82 if (ImGui::Button(ICON_MD_SAVE_ALT " Save All Rooms")) {
85 }
86 }
87
88 ImGui::Unindent();
89 }
90
91 if (ImGui::CollapsingHeader(ICON_MD_LAYERS " Room Overlays",
92 ImGuiTreeNodeFlags_DefaultOpen)) {
93 ImGui::Indent();
94 if (viewer_) {
95 for (const auto& spec : GetDungeonOverlayControlSpecs()) {
96 bool enabled = GetDungeonOverlayControlEnabled(*viewer_, spec.id);
97 if (ImGui::Checkbox(spec.label, &enabled)) {
98 SetDungeonOverlayControlEnabled(*viewer_, spec.id, enabled);
99 }
100 }
101 } else {
102 ImGui::TextDisabled("No active room viewer");
103 }
104 ImGui::Unindent();
105 }
106
107 if (ImGui::CollapsingHeader(ICON_MD_PALETTE " Layer Compositing",
108 ImGuiTreeNodeFlags_None)) {
109 ImGui::Indent();
110 if (viewer_ && current_room_id_ && *current_room_id_ >= 0 &&
111 *current_room_id_ < 0x128) {
113 } else {
114 ImGui::TextDisabled("No active room");
115 }
116 ImGui::Unindent();
117 }
118 }
119
120 private:
121 void SetAllSaveFlags(bool value) {
122 auto& flags = core::FeatureFlags::get().dungeon;
123 flags.kSaveObjects = value;
124 flags.kSaveSprites = value;
125 flags.kSaveRoomHeaders = value;
126 flags.kSaveChests = value;
127 flags.kSavePotItems = value;
128 flags.kSavePalettes = value;
129 flags.kSaveCollision = value;
130 flags.kSaveWaterFillZones = value;
131 flags.kSaveBlocks = value;
132 flags.kSaveTorches = value;
133 flags.kSavePits = value;
134 }
135
136 void DrawLayerCompositingControls(int room_id);
137
139 std::function<void(int)> save_room_callback_;
140 std::function<void()> save_all_rooms_callback_;
141 int* current_room_id_ = nullptr;
142};
143
144} // namespace yaze::editor
145
146#endif
static Flags & get()
Definition features.h:118
std::function< void(int)> save_room_callback_
void SetSaveRoomCallback(std::function< void(int)> callback)
std::string GetEditorCategory() const override
Editor category this panel belongs to.
void SetSaveAllRoomsCallback(std::function< void()> callback)
void Draw(bool *p_open) override
Draw the panel content.
std::string GetIcon() const override
Material Design icon for this panel.
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
std::string GetId() const override
Unique identifier for this panel.
void SetCanvasViewer(DungeonCanvasViewer *viewer)
DungeonSettingsPanel(DungeonCanvasViewer *viewer=nullptr)
Base interface for all logical panel components.
#define ICON_MD_SAVE_ALT
Definition icons.h:1645
#define ICON_MD_SETTINGS
Definition icons.h:1699
#define ICON_MD_LAYERS
Definition icons.h:1068
#define ICON_MD_SAVE
Definition icons.h:1644
#define ICON_MD_PALETTE
Definition icons.h:1370
#define ICON_MD_WORKSPACES
Definition icons.h:2186
Editors are the view controllers for the application.
void SetDungeonOverlayControlEnabled(DungeonCanvasViewer &viewer, DungeonOverlayControlId id, bool enabled)
bool GetDungeonOverlayControlEnabled(const DungeonCanvasViewer &viewer, DungeonOverlayControlId id)
const std::array< DungeonOverlayControlSpec, 11 > & GetDungeonOverlayControlSpecs()
struct yaze::core::FeatureFlags::Flags::Dungeon dungeon