yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
object_tile_editor_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_PANELS_OBJECT_TILE_EDITOR_PANEL_H_
2#define YAZE_APP_EDITOR_DUNGEON_PANELS_OBJECT_TILE_EDITOR_PANEL_H_
3
4#include <array>
5#include <functional>
6#include <memory>
7#include <string>
8
11#include "app/gfx/core/bitmap.h"
14#include "app/gui/core/icons.h"
15#include "rom/rom.h"
17#include "zelda3/dungeon/room.h"
18
19namespace yaze {
20namespace editor {
21
33 public:
35
36 std::string GetId() const override { return "dungeon.object_tile_editor"; }
37 std::string GetDisplayName() const override { return "Object Tile Editor"; }
38 std::string GetIcon() const override { return ICON_MD_GRID_ON; }
39 std::string GetEditorCategory() const override { return "Dungeon"; }
40 int GetPriority() const override { return 65; }
41 float GetPreferredWidth() const override { return 550.0f; }
42
43 void Draw(bool* p_open) override;
44
45 void OpenForObject(int16_t object_id, int room_id,
46 std::array<zelda3::Room, 0x128>* rooms);
47 void OpenForNewObject(int width, int height, const std::string& filename,
48 int16_t object_id, int room_id,
49 std::array<zelda3::Room, 0x128>* rooms);
50 void Close();
51 bool IsOpen() const { return is_open_; }
52
54
55 // Callback fired on first successful save of a new object
57 std::function<void(int, const std::string&)> cb) {
58 on_object_created_ = std::move(cb);
59 }
60
61 private:
62 void DrawTileGrid();
63 void DrawSourceSheet();
64 void DrawTileProperties();
65 void DrawActionBar();
67
69 void RenderTile8Atlas();
70
71 // Apply: write back, re-render room, reset modified flags.
72 // If confirm_shared is true and tile data is shared, opens confirmation modal
73 // instead of applying immediately.
74 void ApplyChanges(bool confirm_shared = true);
75
76 // State
77 std::unique_ptr<zelda3::ObjectTileEditor> tile_editor_;
82
83 // Canvases
84 gui::Canvas tile_grid_canvas_{"##ObjTileGrid", ImVec2(256, 256)};
85 gui::Canvas source_sheet_canvas_{"##ObjTileSource", ImVec2(256, 512)};
86
87 // Bitmaps
90 bool preview_dirty_ = true;
91 bool atlas_dirty_ = true;
92
93 // Shared tile data confirmation
96
97 // New object creation state
98 bool is_new_object_ = false;
99 std::function<void(int, const std::string&)> on_object_created_;
100
101 // Context
105 int16_t current_object_id_ = -1;
106 std::array<zelda3::Room, 0x128>* rooms_ = nullptr;
108 bool is_open_ = false;
109};
110
111} // namespace editor
112} // namespace yaze
113
114#endif // YAZE_APP_EDITOR_DUNGEON_PANELS_OBJECT_TILE_EDITOR_PANEL_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Base interface for all logical panel components.
Panel for editing the tile8 composition of dungeon objects.
void OpenForNewObject(int width, int height, const std::string &filename, int16_t object_id, int room_id, std::array< zelda3::Room, 0x128 > *rooms)
void ApplyChanges(bool confirm_shared=true)
void SetCurrentPaletteGroup(const gfx::PaletteGroup &group)
int GetPriority() const override
Get display priority for menu ordering.
ObjectTileEditorPanel(gfx::IRenderer *renderer, Rom *rom)
void SetObjectCreatedCallback(std::function< void(int, const std::string &)> cb)
std::unique_ptr< zelda3::ObjectTileEditor > tile_editor_
std::function< void(int, const std::string &) on_object_created_)
float GetPreferredWidth() const override
Get preferred width for this panel (optional)
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
std::string GetEditorCategory() const override
Editor category this panel belongs to.
std::array< zelda3::Room, 0x128 > * rooms_
std::string GetIcon() const override
Material Design icon for this panel.
void Draw(bool *p_open) override
Draw the panel content.
void OpenForObject(int16_t object_id, int room_id, std::array< zelda3::Room, 0x128 > *rooms)
std::string GetId() const override
Unique identifier for this panel.
Represents a bitmap image optimized for SNES ROM hacking.
Definition bitmap.h:67
Defines an abstract interface for all rendering operations.
Definition irenderer.h:60
Modern, robust canvas for drawing and manipulating graphics.
Definition canvas.h:150
#define ICON_MD_GRID_ON
Definition icons.h:896
Represents a group of palettes.
Editable tile8 layout captured from an object's draw trace.