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"
20#include "imgui/imgui.h"
49 std::string
GetId()
const override {
return "dungeon.item_editor"; }
81 ImGui::TextDisabled(tr(
"No room data available"));
87 ImGui::TextDisabled(tr(
"No room selected"));
95 if (show_room_items) {
169 ImGui::TextColored(theme.status_warning,
179 ImGui::TextColored(theme.text_secondary_gray,
190 float available_height = ImGui::GetContentRegionAvail().y;
192 float reserved_height = 120.0f;
194 const float grid_height =
197 std::min(400.0f, available_height - reserved_height))
198 : std::max(1.0f, available_height);
201 float panel_width = ImGui::GetContentRegionAvail().x;
203 std::max(36.0f, std::min(48.0f, (panel_width - 40.0f) / 6.0f));
205 std::max(1,
static_cast<int>(panel_width / (item_size + 8)));
207 ImGui::BeginChild(
"##ItemGrid", ImVec2(0, grid_height),
true,
208 ImGuiWindowFlags_HorizontalScrollbar);
209 ImGui::BeginDisabled(!can_edit);
215 ImGui::PushID(
static_cast<int>(i));
220 button_color.x = std::min(1.0f, button_color.x + 0.2f);
221 button_color.y = std::min(1.0f, button_color.y + 0.2f);
222 button_color.z = std::min(1.0f, button_color.z + 0.2f);
227 {ImGuiCol_Button, button_color},
228 {ImGuiCol_ButtonHovered,
229 ImVec4(std::min(1.0f, button_color.x + 0.1f),
230 std::min(1.0f, button_color.y + 0.1f),
231 std::min(1.0f, button_color.z + 0.1f), 1.0f)},
232 {ImGuiCol_ButtonActive,
233 ImVec4(std::min(1.0f, button_color.x + 0.2f),
234 std::min(1.0f, button_color.y + 0.2f),
235 std::min(1.0f, button_color.z + 0.2f), 1.0f)},
241 absl::StrFormat(
"%s\n%02X", icon,
static_cast<int>(i));
243 ImGui::Button(label.c_str(), ImVec2(item_size, item_size));
245 absl::StrFormat(
"place_item_%02X", i));
246 if (picked && can_edit) {
251 true,
static_cast<uint8_t
>(i));
256 if (ImGui::IsItemHovered()) {
257 ImGui::SetTooltip(tr(
"%s (0x%02X)\nClick to select for placement"),
263 ImVec2 min = ImGui::GetItemRectMin();
264 ImVec2 max = ImGui::GetItemRectMax();
266 ImGui::ColorConvertFloat4ToU32(theme.dungeon_selection_primary);
267 ImGui::GetWindowDrawList()->AddRect(min, max, sel_color, 0.0f, 0, 2.0f);
273 if (col < items_per_row) {
280 ImGui::EndDisabled();
287 const auto& items = room.GetPotItems();
288 int selected_item_index = -1;
291 const auto selected_entity =
293 if (selected_entity.type == EntityType::Item) {
294 selected_item_index =
static_cast<int>(selected_entity.index);
298 ImGui::Text(
ICON_MD_LIST " Room Items (%zu):", items.size());
307 ImGui::TextColored(theme.text_secondary_gray,
312 if (selected_item_index >= 0 &&
313 selected_item_index <
static_cast<int>(items.size()) &&
316 ImGui::BeginDisabled(!can_edit);
317 uint8_t raw_item_type = items[selected_item_index].item;
318 ImGui::AlignTextToFramePadding();
319 ImGui::TextUnformatted(tr(
"Selected raw type"));
321 ImGui::SetNextItemWidth(72.0f);
323 "##SelectedItemRawType", ImGuiDataType_U8, &raw_item_type,
"%02X",
324 ImGuiInputTextFlags_CharsHexadecimal,
325 {
reinterpret_cast<uintptr_t
>(
rooms_),
327 static_cast<uint64_t
>(selected_item_index)});
329 "Selected pot item raw type byte");
330 ImGui::EndDisabled();
331 if (type_changed && can_edit) {
339 float list_height = std::max(100.0f, ImGui::GetContentRegionAvail().y);
340 ImGui::BeginChild(
"##ItemList", ImVec2(0, list_height),
true);
341 for (
size_t i = 0; i < items.size(); ++i) {
342 const auto& item = items[i];
344 ImGui::PushID(
static_cast<int>(i));
346 const char* item_name =
349 const std::string row_label =
350 absl::StrFormat(
"[%zu] %s (0x%02X)", i, item_name, item.item);
351 const bool row_selected = ImGui::Selectable(
352 row_label.c_str(), selected_item_index ==
static_cast<int>(i));
354 "selectable", absl::StrFormat(
"item_row_%zu", i),
355 "Select a pot item in the current dungeon room");
357 ImGui::TextColored(theme.text_secondary_gray,
"@ (%d,%d)",
358 item.GetTileX(), item.GetTileY());
371 if (item_id == 0 || item_id == 22) {
373 }
else if (item_id >= 1 && item_id <= 7) {
375 }
else if (item_id == 8) {
377 }
else if (item_id >= 15 && item_id <= 17) {
379 }
else if (item_id >= 23 && item_id <= 27) {
387 if (item_id == 0 || item_id == 22) {
389 }
else if (item_id == 1 || item_id == 7) {
391 }
else if (item_id == 4 || item_id == 6 || item_id == 11 || item_id == 19 ||
394 }
else if (item_id == 8) {
396 }
else if (item_id == 5 || item_id == 10) {
398 }
else if (item_id == 9) {
400 }
else if (item_id == 12 || item_id == 13) {
402 }
else if (item_id == 14) {
404 }
else if (item_id >= 15 && item_id <= 17) {
406 }
else if (item_id == 18) {
408 }
else if (item_id == 20) {
410 }
else if (item_id == 23) {
412 }
else if (item_id == 24) {
414 }
else if (item_id == 25) {
416 }
else if (item_id == 26) {
418 }
else if (item_id == 27) {
420 }
else if (item_id == 2) {
422 }
else if (item_id == 3) {
InteractionContext * context() const
Get the interaction context.
DungeonRoomStore * rooms() const
int current_room_id() const
DungeonObjectInteraction & object_interaction()
bool IsObjectInteractionEnabled() const
bool header_read_only() const
void SetItemPlacementMode(bool enabled, uint8_t item_id=0)
SelectedEntity GetSelectedEntity() const
bool IsItemPlacementActive() const
InteractionCoordinator & entity_coordinator()
Get the interaction coordinator for entity handling.
bool HasEntitySelection() const
void SelectEntity(EntityType type, size_t index)
ItemInteractionHandler & item_handler()
TileObjectHandler & tile_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.
void DrawContent(bool show_room_items)
ImVec4 GetItemTypeColor(int item_id, const AgentUITheme &theme)
void SetCanvasViewer(DungeonCanvasViewer *viewer)
void SetOpenSelectionInspectorCallback(std::function< void()> callback)
bool HasMatchingViewer() const
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.
void DrawItemSelector(bool show_room_items)
DungeonCanvasViewer * canvas_viewer_
void Draw(bool *) override
Draw the panel content.
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)
DungeonRoomStore * rooms_
uint8_t GetItemId() const
Get current item ID for placement.
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 DrawDungeonPotItemSaveNotice()
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