yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
sprite_editor_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_PANELS_SPRITE_EDITOR_PANEL_H_
2#define YAZE_APP_EDITOR_DUNGEON_PANELS_SPRITE_EDITOR_PANEL_H_
3
4#include <functional>
5#include <string>
6#include <unordered_map>
7#include <vector>
9
10#include <SDL.h>
11
14
15namespace yaze {
16namespace zelda3 {
17class Room;
18class Sprite;
19} // namespace zelda3
20namespace editor {
21
22class DungeonCanvasViewer;
23class DungeonRoomStore;
24
33 public:
34 SpriteEditorPanel(int* current_room_id, DungeonRoomStore* rooms,
35 DungeonCanvasViewer* canvas_viewer = nullptr);
36
37 std::string GetId() const override;
38 std::string GetDisplayName() const override;
39 std::string GetIcon() const override;
40 std::string GetEditorCategory() const override;
41 int GetPriority() const override;
42 std::string GetWorkflowGroup() const override;
43
44 void Draw(bool* p_open) override;
45 void DrawInWorkbench();
46
49 std::function<void(const zelda3::Sprite&)> callback);
50 void SetOpenSelectionInspectorCallback(std::function<void()> callback);
51
52 private:
53 void DrawContent(bool show_room_sprites);
55 void DrawSpriteSelector(bool show_room_sprites);
56 void DrawRoomSprites();
57
58 std::string SpriteName(int sprite_id) const;
59 bool MatchesFilter(int sprite_id) const;
60
62 std::vector<uint8_t> pixels;
63 SDL_Rect bounds{0, 0, 0, 0};
64 };
65
66 const CachedSpritePreview& GetOrCreateSpritePreview(int sprite_id,
67 const zelda3::Room& room);
68
69 int* current_room_id_ = nullptr;
72
73 mutable std::unordered_map<int, CachedSpritePreview> sprite_preview_cache_;
74 mutable uint64_t cached_graphics_revision_ = 0;
76
77 // Selection state
80 char search_filter_[64] = {0};
81
82 std::function<void(const zelda3::Sprite&)> sprite_placed_callback_;
84};
85
86} // namespace editor
87} // namespace yaze
88
89#endif // YAZE_APP_EDITOR_DUNGEON_PANELS_SPRITE_EDITOR_PANEL_H_
WindowContent for placing and managing dungeon sprites.
std::function< void(const zelda3::Sprite &) sprite_placed_callback_)
workbench::DungeonBrowserState browser_state_
std::string SpriteName(int sprite_id) const
void SetOpenSelectionInspectorCallback(std::function< void()> callback)
void DrawContent(bool show_room_sprites)
void SetCanvasViewer(DungeonCanvasViewer *viewer)
std::unordered_map< int, CachedSpritePreview > sprite_preview_cache_
std::string GetEditorCategory() const override
Editor category this panel belongs to.
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
void Draw(bool *p_open) override
Draw the panel content.
std::string GetWorkflowGroup() const override
Optional workflow group for hack-centric actions.
bool MatchesFilter(int sprite_id) const
std::function< void()> open_selection_inspector_callback_
void DrawSpriteSelector(bool show_room_sprites)
zelda3::SpritePreviewResourceCache sprite_preview_resources_
void SetSpritePlacedCallback(std::function< void(const zelda3::Sprite &)> callback)
const CachedSpritePreview & GetOrCreateSpritePreview(int sprite_id, const zelda3::Room &room)
std::string GetId() const override
Unique identifier for this panel.
int GetPriority() const override
Get display priority for menu ordering.
SpriteEditorPanel(int *current_room_id, DungeonRoomStore *rooms, DungeonCanvasViewer *canvas_viewer=nullptr)
std::string GetIcon() const override
Material Design icon for this panel.
Base interface for all logical window content components.
A class for managing sprites in the overworld and underworld.
Definition sprite.h:39