1#ifndef YAZE_APP_EDITOR_DUNGEON_PANELS_ITEM_EDITOR_PANEL_H_
2#define YAZE_APP_EDITOR_DUNGEON_PANELS_ITEM_EDITOR_PANEL_H_
10#include "absl/strings/str_format.h"
19#include "imgui/imgui.h"
48 std::string
GetId()
const override {
return "dungeon.item_editor"; }
59 void Draw(
bool* p_open)
override {
62 ImGui::TextDisabled(tr(
"No room data available"));
68 ImGui::TextDisabled(tr(
"No room selected"));
135 ImGui::TextColored(theme.status_warning,
145 ImGui::TextColored(theme.text_secondary_gray,
155 float available_height = ImGui::GetContentRegionAvail().y;
157 float reserved_height = 120.0f;
160 std::max(150.0f, std::min(400.0f, available_height - reserved_height));
163 float panel_width = ImGui::GetContentRegionAvail().x;
165 std::max(36.0f, std::min(48.0f, (panel_width - 40.0f) / 6.0f));
167 std::max(1,
static_cast<int>(panel_width / (item_size + 8)));
169 ImGui::BeginChild(
"##ItemGrid", ImVec2(0, grid_height),
true,
170 ImGuiWindowFlags_HorizontalScrollbar);
176 ImGui::PushID(
static_cast<int>(i));
181 button_color.x = std::min(1.0f, button_color.x + 0.2f);
182 button_color.y = std::min(1.0f, button_color.y + 0.2f);
183 button_color.z = std::min(1.0f, button_color.z + 0.2f);
188 {ImGuiCol_Button, button_color},
189 {ImGuiCol_ButtonHovered,
190 ImVec4(std::min(1.0f, button_color.x + 0.1f),
191 std::min(1.0f, button_color.y + 0.1f),
192 std::min(1.0f, button_color.z + 0.1f), 1.0f)},
193 {ImGuiCol_ButtonActive,
194 ImVec4(std::min(1.0f, button_color.x + 0.2f),
195 std::min(1.0f, button_color.y + 0.2f),
196 std::min(1.0f, button_color.z + 0.2f), 1.0f)},
202 absl::StrFormat(
"%s\n%02X", icon,
static_cast<int>(i));
203 if (ImGui::Button(label.c_str(), ImVec2(item_size, item_size))) {
208 true,
static_cast<uint8_t
>(i));
213 if (ImGui::IsItemHovered()) {
214 ImGui::SetTooltip(tr(
"%s (0x%02X)\nClick to select for placement"),
220 ImVec2 min = ImGui::GetItemRectMin();
221 ImVec2 max = ImGui::GetItemRectMax();
223 ImGui::ColorConvertFloat4ToU32(theme.dungeon_selection_primary);
224 ImGui::GetWindowDrawList()->AddRect(min, max, sel_color, 0.0f, 0, 2.0f);
230 if (col < items_per_row) {
243 const auto& items = room.GetPotItems();
244 int selected_item_index = -1;
247 const auto selected_entity =
250 selected_item_index =
static_cast<int>(selected_entity.index);
254 ImGui::Text(
ICON_MD_LIST " Room Items (%zu):", items.size());
263 ImGui::TextColored(theme.text_secondary_gray,
268 if (selected_item_index >= 0 &&
269 selected_item_index <
static_cast<int>(items.size()) &&
271 uint8_t raw_item_type = items[selected_item_index].item;
272 ImGui::AlignTextToFramePadding();
273 ImGui::TextUnformatted(tr(
"Selected raw type"));
275 ImGui::SetNextItemWidth(72.0f);
277 "##SelectedItemRawType", ImGuiDataType_U8, &raw_item_type,
"%02X",
278 ImGuiInputTextFlags_CharsHexadecimal,
279 {
reinterpret_cast<uintptr_t
>(
rooms_),
281 static_cast<uint64_t
>(selected_item_index)});
283 "Selected pot item raw type byte");
292 float list_height = std::max(100.0f, ImGui::GetContentRegionAvail().y);
293 ImGui::BeginChild(
"##ItemList", ImVec2(0, list_height),
true);
294 for (
size_t i = 0; i < items.size(); ++i) {
295 const auto& item = items[i];
297 ImGui::PushID(
static_cast<int>(i));
299 const char* item_name =
302 const std::string row_label =
303 absl::StrFormat(
"[%zu] %s (0x%02X)", i, item_name, item.item);
304 const bool row_selected = ImGui::Selectable(
305 row_label.c_str(), selected_item_index ==
static_cast<int>(i));
307 "selectable", absl::StrFormat(
"item_row_%zu", i),
308 "Select a pot item in the current dungeon room");
310 ImGui::TextColored(theme.text_secondary_gray,
"@ (%d,%d)",
311 item.GetTileX(), item.GetTileY());
324 if (item_id == 0 || item_id == 22) {
326 }
else if (item_id >= 1 && item_id <= 7) {
328 }
else if (item_id == 8) {
330 }
else if (item_id >= 15 && item_id <= 17) {
332 }
else if (item_id >= 23 && item_id <= 27) {
340 if (item_id == 0 || item_id == 22) {
342 }
else if (item_id == 1 || item_id == 7) {
344 }
else if (item_id == 4 || item_id == 6 || item_id == 11 || item_id == 19 ||
347 }
else if (item_id == 8) {
349 }
else if (item_id == 5 || item_id == 10) {
351 }
else if (item_id == 9) {
353 }
else if (item_id == 12 || item_id == 13) {
355 }
else if (item_id == 14) {
357 }
else if (item_id >= 15 && item_id <= 17) {
359 }
else if (item_id == 18) {
361 }
else if (item_id == 20) {
363 }
else if (item_id == 23) {
365 }
else if (item_id == 24) {
367 }
else if (item_id == 25) {
369 }
else if (item_id == 26) {
371 }
else if (item_id == 27) {
373 }
else if (item_id == 2) {
375 }
else if (item_id == 3) {
DungeonObjectInteraction & object_interaction()
void SetItemPlacementMode(bool enabled, uint8_t item_id=0)
SelectedEntity GetSelectedEntity() const
InteractionCoordinator & entity_coordinator()
Get the interaction coordinator for entity handling.
bool HasEntitySelection() const
void SelectEntity(EntityType type, size_t index)
ItemInteractionHandler & item_handler()
WindowContent for placing and managing dungeon pot items.
std::string GetIcon() const override
Material Design icon for this panel.
static constexpr size_t kPotItemCount
static constexpr const char * kPotItemNames[]
int GetPriority() const override
Get display priority for menu ordering.
ImVec4 GetItemTypeColor(int item_id, const AgentUITheme &theme)
void SetCanvasViewer(DungeonCanvasViewer *viewer)
void SetOpenSelectionInspectorCallback(std::function< void()> callback)
std::function< void(const zelda3::PotItem &) item_placed_callback_)
std::string GetEditorCategory() const override
Editor category this panel belongs to.
void DrawPlacementControls()
std::string GetId() const override
Unique identifier for this panel.
DungeonCanvasViewer * canvas_viewer_
void SetItemPlacedCallback(std::function< void(const zelda3::PotItem &)> callback)
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
const char * GetItemTypeIcon(int item_id)
std::function< void()> open_selection_inspector_callback_
std::string GetWorkflowGroup() const override
Optional workflow group for hack-centric actions.
ItemEditorPanel(int *current_room_id, DungeonRoomStore *rooms, DungeonCanvasViewer *canvas_viewer=nullptr)
void Draw(bool *p_open) override
Draw the panel content.
DungeonRoomStore * rooms_
bool MutateItemType(size_t index, uint8_t new_type)
Change one pot item's raw type byte in place.
Base interface for all logical window content components.
RAII guard for ImGui style colors.
#define ICON_MD_FLUTTER_DASH
#define ICON_MD_LANDSCAPE
#define ICON_MD_SWAP_HORIZ
#define ICON_MD_AUTO_AWESOME
#define ICON_MD_BUG_REPORT
#define ICON_MD_TOGGLE_ON
#define ICON_MD_BROKEN_IMAGE
#define ICON_MD_INVENTORY
#define ICON_MD_ARROW_UPWARD
#define ICON_MD_OPEN_IN_NEW
#define ICON_MD_MONETIZATION_ON
const AgentUITheme & GetTheme()
void AutoRegisterLastItem(const std::string &widget_type, const std::string &explicit_label, const std::string &description)
Automatically register the last ImGui item.
bool InputScalarDeferred(const char *label, ImGuiDataType data_type, void *data, const char *format, ImGuiInputTextFlags flags, InputScalarTargetIdentity target_identity)
Centralized theme colors for Agent UI components.
ImVec4 dungeon_sprite_layer0
ImVec4 dungeon_object_chest
ImVec4 dungeon_object_pot
ImVec4 dungeon_object_stairs
ImVec4 dungeon_object_default