yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
item_editor_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_PANELS_ITEM_EDITOR_PANEL_H_
2#define YAZE_APP_EDITOR_DUNGEON_PANELS_ITEM_EDITOR_PANEL_H_
3
4#include <functional>
5#include <string>
6#include <unordered_map>
7#include <utility>
8#include <vector>
10
11#include <SDL.h>
12
17#include "app/gui/core/icons.h"
18#include "imgui/imgui.h"
19#include "zelda3/dungeon/room.h"
20
21namespace yaze {
22namespace editor {
23
32 public:
33 ItemEditorPanel(int* current_room_id, DungeonRoomStore* rooms,
34 DungeonCanvasViewer* canvas_viewer = nullptr)
35 : current_room_id_(current_room_id),
36 rooms_(rooms),
37 canvas_viewer_(canvas_viewer) {}
38
39 std::string GetId() const override { return "dungeon.item_editor"; }
40 std::string GetDisplayName() const override { return "Item Editor"; }
41 std::string GetIcon() const override { return ICON_MD_INVENTORY; }
42 std::string GetEditorCategory() const override { return "Dungeon"; }
43 int GetPriority() const override { return 66; }
44 std::string GetWorkflowGroup() const override { return "Editors"; }
45
46 void Draw(bool* p_open) override;
47 void DrawInWorkbench();
48
50
52 std::function<void(const zelda3::PotItem&)> callback) {
53 item_placed_callback_ = std::move(callback);
54 }
55 void SetOpenSelectionInspectorCallback(std::function<void()> callback) {
56 open_selection_inspector_callback_ = std::move(callback);
57 }
58
59 private:
60 void DrawContent(bool show_room_items);
61 bool HasMatchingViewer() const;
62 bool CanEditRoom() const;
64 void DrawItemSelector(bool show_room_items);
65 void DrawRoomItems();
66 ImVec4 GetItemTypeColor(int item_id, const AgentUITheme& theme) const;
67 const char* GetItemTypeIcon(int item_id) const;
68
70 std::vector<uint8_t> pixels;
71 SDL_Rect bounds{0, 0, 0, 0};
72 };
73
74 const CachedItemPreview& GetOrCreateItemPreview(uint8_t item_id,
75 const zelda3::Room& room);
76
77 mutable std::unordered_map<uint8_t, CachedItemPreview> item_preview_cache_;
78 mutable uint64_t cached_item_graphics_revision_ = 0;
79
80 int* current_room_id_ = nullptr;
83
86 bool placement_mode_ = false;
87
88 std::function<void(const zelda3::PotItem&)> item_placed_callback_;
90};
91
92} // namespace editor
93} // namespace yaze
94
95#endif // YAZE_APP_EDITOR_DUNGEON_PANELS_ITEM_EDITOR_PANEL_H_
WindowContent for placing and managing dungeon pot items.
std::string GetIcon() const override
Material Design icon for this panel.
int GetPriority() const override
Get display priority for menu ordering.
void DrawContent(bool show_room_items)
void SetCanvasViewer(DungeonCanvasViewer *viewer)
void SetOpenSelectionInspectorCallback(std::function< void()> callback)
std::unordered_map< uint8_t, CachedItemPreview > item_preview_cache_
std::function< void(const zelda3::PotItem &) item_placed_callback_)
std::string GetEditorCategory() const override
Editor category this panel belongs to.
std::string GetId() const override
Unique identifier for this panel.
void DrawItemSelector(bool show_room_items)
DungeonCanvasViewer * canvas_viewer_
const char * GetItemTypeIcon(int item_id) const
void SetItemPlacedCallback(std::function< void(const zelda3::PotItem &)> callback)
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
ImVec4 GetItemTypeColor(int item_id, const AgentUITheme &theme) const
workbench::DungeonBrowserState browser_state_
const CachedItemPreview & GetOrCreateItemPreview(uint8_t item_id, const zelda3::Room &room)
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.
Base interface for all logical window content components.
#define ICON_MD_INVENTORY
Definition icons.h:1011
Centralized theme colors for Agent UI components.
Definition agent_theme.h:19