yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_toolset.cc
Go to the documentation of this file.
1#include "dungeon_toolset.h"
2
3#include <algorithm>
4#include <array>
5
10#include "imgui/imgui.h"
11
12namespace yaze::editor {
13
14namespace {
15
16struct ToolDef {
17 const char* icon;
18 const char* tooltip;
19 const char* shortcut;
21};
22
23constexpr std::array<ToolDef, 7> kToolDefs = {{
24 {ICON_MD_NEAR_ME, "Select", "Esc", DungeonToolset::kNoType},
27 {ICON_MD_GRASS, "Items", "I", DungeonToolset::kItem},
31}};
32
33} // namespace
34
36 const auto& theme = gui::ThemeManager::Get().GetCurrentTheme();
37
38 // Undo / Redo buttons
39 if (gui::ThemedIconButton(ICON_MD_UNDO, "Undo (Ctrl+Z)")) {
42 }
43 ImGui::SameLine();
44 if (gui::ThemedIconButton(ICON_MD_REDO, "Redo (Ctrl+Y)")) {
47 }
48
49 ImGui::SameLine(0, 12.0f);
50 ImGui::TextDisabled("|");
51 ImGui::SameLine(0, 12.0f);
52
53 // Background layer radio buttons (compact)
54 auto bg_radio = [&](const char* label, BackgroundType type, const char* tip) {
55 if (ImGui::RadioButton(label, background_type_ == type)) {
56 background_type_ = type;
57 }
58 if (ImGui::IsItemHovered()) {
59 ImGui::SetTooltip("%s", tip);
60 }
61 ImGui::SameLine();
62 };
63
64 bg_radio("All", kBackgroundAny, "Show all layers");
65 bg_radio("BG1", kBackground1, "Background 1 only");
66 bg_radio("BG2", kBackground2, "Background 2 only");
67 bg_radio("BG3", kBackground3, "Background 3 only");
68
69 ImGui::SameLine(0, 12.0f);
70 ImGui::TextDisabled("|");
71 ImGui::SameLine(0, 12.0f);
72
73 // Placement mode tool strip — themed icon buttons with active highlighting
74 for (const auto& tool : kToolDefs) {
75 const bool is_active = (placement_type_ == tool.type);
76
77 if (gui::ThemedIconButton(tool.icon, nullptr, ImVec2(0, 0), is_active)) {
78 placement_type_ = tool.type;
79 }
80 if (ImGui::IsItemHovered()) {
81 ImGui::SetTooltip("%s (%s)", tool.tooltip, tool.shortcut);
82 }
83 ImGui::SameLine();
84 }
85
86 ImGui::SameLine(0, 12.0f);
87 ImGui::TextDisabled("|");
88 ImGui::SameLine(0, 12.0f);
89
90 // Palette toggle
91 if (gui::ThemedIconButton(ICON_MD_PALETTE, "Palette Editor")) {
94 }
95
96 ImGui::NewLine();
97}
98
100 for (const auto& tool : kToolDefs) {
101 if (tool.type == placement_type_) {
102 return tool.tooltip;
103 }
104 }
105 return "Select";
106}
107
108} // namespace yaze::editor
const char * GetToolModeName() const
std::function< void()> undo_callback_
std::function< void()> palette_toggle_callback_
std::function< void()> redo_callback_
const Theme & GetCurrentTheme() const
static ThemeManager & Get()
#define ICON_MD_REDO
Definition icons.h:1570
#define ICON_MD_GRASS
Definition icons.h:891
#define ICON_MD_WIDGETS
Definition icons.h:2156
#define ICON_MD_SENSOR_DOOR
Definition icons.h:1687
#define ICON_MD_INVENTORY
Definition icons.h:1011
#define ICON_MD_PEST_CONTROL
Definition icons.h:1429
#define ICON_MD_NEAR_ME
Definition icons.h:1277
#define ICON_MD_PALETTE
Definition icons.h:1370
#define ICON_MD_UNDO
Definition icons.h:2039
#define ICON_MD_NAVIGATION
Definition icons.h:1276
Editors are the view controllers for the application.
bool ThemedIconButton(const char *icon, const char *tooltip, const ImVec2 &size, bool is_active, bool is_disabled, const char *panel_id, const char *anim_id)
Draw a standard icon button with theme-aware colors.