yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
door_editor_content.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_INSPECTORS_DOOR_EDITOR_CONTENT_H_
2#define YAZE_APP_EDITOR_DUNGEON_INSPECTORS_DOOR_EDITOR_CONTENT_H_
3
4#include <functional>
5#include <string>
6#include <unordered_map>
7#include <vector>
9
10#include <SDL.h>
11
15#include "app/gui/core/icons.h"
17
18namespace yaze::editor {
19
21 public:
22 std::string GetId() const override { return "dungeon.door_editor"; }
23 std::string GetDisplayName() const override { return "Door Editor"; }
24 std::string GetIcon() const override { return ICON_MD_DOOR_FRONT; }
25 std::string GetEditorCategory() const override { return "Dungeon"; }
26 int GetPriority() const override { return 68; }
27 std::string GetWorkflowGroup() const override { return "Editors"; }
28 float GetPreferredWidth() const override { return 420.0f; }
29
30 void Draw(bool* p_open) override;
31 void DrawInWorkbench();
32 void OnClose() override;
33
34 void SetCurrentRoom(int room_id) { current_room_id_ = room_id; }
35 void SetCanvasViewerProvider(std::function<DungeonCanvasViewer*()> provider) {
36 canvas_viewer_provider_ = std::move(provider);
37 }
39 void SetRooms(DungeonRoomStore* rooms) { rooms_ = rooms; }
40 void SetOpenSelectionInspectorCallback(std::function<void()> callback) {
41 open_selection_inspector_callback_ = std::move(callback);
42 }
43
44 // Callback fired by the "Jump to Reciprocal" button. Takes the neighbor
45 // room id and the index of the paired door in that room.
47 std::function<void(int neighbor_room_id, size_t reciprocal_door_index)>
48 callback) {
49 on_jump_to_reciprocal_door_ = std::move(callback);
50 }
51
52 private:
53 void DrawContent(bool show_room_doors);
54 bool HasMatchingViewer() const;
55 bool CanEditRoom() const;
57 void CancelPlacement();
58
60 std::vector<uint8_t> pixels;
61 int width = 0;
62 int height = 0;
63 };
64
66 const zelda3::Room& room);
67
68 mutable std::unordered_map<int, CachedDoorPreview> door_preview_cache_;
69 mutable uint64_t cached_door_graphics_revision_ = 0;
70
78 std::function<void(int, size_t)> on_jump_to_reciprocal_door_;
80};
81
82} // namespace yaze::editor
83
84#endif // YAZE_APP_EDITOR_DUNGEON_INSPECTORS_DOOR_EDITOR_CONTENT_H_
workbench::DungeonBrowserState browser_state_
void SetOpenSelectionInspectorCallback(std::function< void()> callback)
void SetJumpToReciprocalDoorCallback(std::function< void(int neighbor_room_id, size_t reciprocal_door_index)> callback)
std::string GetId() const override
Unique identifier for this panel.
const CachedDoorPreview & GetOrCreateDoorPreview(zelda3::DoorType type, const zelda3::Room &room)
int GetPriority() const override
Get display priority for menu ordering.
DungeonCanvasViewer * ResolveCanvasViewer()
float GetPreferredWidth() const override
Get preferred width for this panel (optional)
std::string GetEditorCategory() const override
Editor category this panel belongs to.
std::function< DungeonCanvasViewer *()> canvas_viewer_provider_
void OnClose() override
Called when panel is hidden.
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
void SetCanvasViewerProvider(std::function< DungeonCanvasViewer *()> provider)
void Draw(bool *p_open) override
Draw the panel content.
std::unordered_map< int, CachedDoorPreview > door_preview_cache_
void SetRooms(DungeonRoomStore *rooms)
std::function< void()> open_selection_inspector_callback_
std::function< void(int, size_t)> on_jump_to_reciprocal_door_
void SetCanvasViewer(DungeonCanvasViewer *viewer)
std::string GetWorkflowGroup() const override
Optional workflow group for hack-centric actions.
std::string GetIcon() const override
Material Design icon for this panel.
void DrawContent(bool show_room_doors)
Base interface for all logical window content components.
#define ICON_MD_DOOR_FRONT
Definition icons.h:613
Editors are the view controllers for the application.
DoorType
Door types from ALTTP.
Definition door_types.h:33
@ NormalDoor
Normal door (upper layer)