yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::ObjectTileEditorPanel Class Reference

Panel for editing the tile8 composition of dungeon objects. More...

#include <object_tile_editor_panel.h>

Inheritance diagram for yaze::editor::ObjectTileEditorPanel:

Classes

struct  SourceImpactDisplayCacheKey
 
struct  SourceImpactSnapshot
 

Public Types

using StandardWritePreflightCallback
 
using StandardTilesAppliedCallback = std::function<void()>
 

Public Member Functions

 ObjectTileEditorPanel (gfx::IRenderer *renderer, Rom *rom)
 
std::string GetId () const override
 Unique identifier for this panel.
 
std::string GetDisplayName () const override
 Human-readable name shown in menus and title bars.
 
std::string GetIcon () const override
 Material Design icon for this panel.
 
std::string GetEditorCategory () const override
 Editor category this panel belongs to.
 
int GetPriority () const override
 Get display priority for menu ordering.
 
float GetPreferredWidth () const override
 Get preferred width for this panel (optional)
 
float GetPreferredHeight () const override
 Get preferred height for this panel (optional)
 
void Draw (bool *p_open) override
 Draw the panel content.
 
void OnClose () override
 Called when panel is hidden.
 
absl::Status OpenForObject (int16_t object_id, int room_id, DungeonRoomStore *rooms)
 
absl::Status OpenForObject (int16_t object_id, int room_id, DungeonRoomStore *rooms, const gfx::PaletteGroup &palette_group)
 
absl::Status OpenForNewObject (int width, int height, const std::string &filename, int16_t object_id, int room_id, DungeonRoomStore *rooms)
 
void Close ()
 
bool IsOpen () const
 
bool HasUnappliedChanges () const
 
void SetCurrentPaletteGroup (const gfx::PaletteGroup &group)
 
void SetCurrentPaletteGroupForRoom (int room_id, const gfx::PaletteGroup &group)
 
void SetObjectCreatedCallback (std::function< void(int, const std::string &)> cb)
 
void SetStandardWritePreflightCallback (StandardWritePreflightCallback callback)
 
void SetStandardTilesAppliedCallback (StandardTilesAppliedCallback callback)
 
- Public Member Functions inherited from yaze::editor::WindowContent
virtual ~WindowContent ()=default
 
virtual void OnFirstDraw ()
 Called once before the first Draw() in a session.
 
virtual bool RequiresLazyInit () const
 Whether this panel uses lazy initialization.
 
void InvalidateLazyInit ()
 Reset lazy init state so OnFirstDraw() runs again.
 
virtual void OnOpen ()
 Called when panel becomes visible.
 
virtual void OnFocus ()
 Called when panel receives focus.
 
virtual WindowLifecycle GetWindowLifecycle () const
 Get the lifecycle category for this window.
 
virtual WindowContextScope GetContextScope () const
 Optional context binding for this window (room/selection/etc)
 
virtual WindowScope GetScope () const
 Get the registration scope for this window.
 
virtual bool IsEnabled () const
 Check if this panel is currently enabled.
 
virtual std::string GetDisabledTooltip () const
 Get tooltip text when panel is disabled.
 
virtual std::string GetShortcutHint () const
 Get keyboard shortcut hint for display.
 
virtual std::string GetWorkflowGroup () const
 Optional workflow group for hack-centric actions.
 
virtual std::string GetWorkflowLabel () const
 Optional workflow label for menus/command palette.
 
virtual std::string GetWorkflowDescription () const
 Optional workflow description for menus/command palette.
 
virtual int GetWorkflowPriority () const
 Optional workflow ordering priority (lower sorts first).
 
virtual bool PreferAutoHideTabBar () const
 Whether the dock node hosting this panel should auto-hide its tab bar.
 
virtual bool IsVisibleByDefault () const
 Whether this panel should be visible by default.
 
virtual std::string GetParentPanelId () const
 Get parent panel ID for cascade behavior.
 
virtual bool CascadeCloseChildren () const
 Whether closing this panel should close child panels.
 
void DrawWithLazyInit (bool *p_open)
 Execute lazy initialization if needed, then call Draw()
 

Private Types

enum class  ActionStatusTone { kNone , kWarning , kSuccess , kError }
 

Private Member Functions

void ClearRenderedBitmaps ()
 
void ClearActionStatus ()
 
void SetActionStatus (ActionStatusTone tone, std::string message)
 
void ResetTransientState ()
 
std::string BuildWindowTitle () const
 
void SelectFirstCellIfAvailable ()
 
absl::StatusOr< SourceImpactSnapshotAnalyzeSourceImpactSnapshot () const
 
absl::StatusOr< int > GetSharedTileDataUsageCount () const
 
absl::StatusOr< int > GetDisplayedSharedTileDataUsageCount ()
 
absl::StatusOr< bool > HasSharedTileDataConflict () const
 
uint64_t BuildSourceImpactProvenanceFingerprint () const
 
bool HasRenderableRoomContext () const
 
void RefreshRenderedViewsFromCurrentRoom ()
 
void DrawTileGrid ()
 
void DrawSourceSheet ()
 
void DrawTileProperties ()
 
void DrawActionBar (bool *p_open)
 
void HandleKeyboardShortcuts (bool *p_open)
 
void RequestSafeWindowClose (bool *p_open)
 
void RenderObjectPreview ()
 
void RenderTile8Atlas ()
 
void SyncSourceSelectionFromSelectedCell ()
 
absl::Status WriteBackCurrentLayout ()
 
void ApplyChanges (bool confirm_shared=true)
 

Private Attributes

std::unique_ptr< zelda3::ObjectTileEditortile_editor_
 
zelda3::ObjectTileLayout current_layout_
 
int selected_cell_index_ = -1
 
int selected_source_tile_ = -1
 
int source_palette_ = 2
 
gui::Canvas tile_grid_canvas_ {"##ObjTileGrid", ImVec2(256, 256)}
 
gui::Canvas source_sheet_canvas_ {"##ObjTileSource", ImVec2(256, 512)}
 
gfx::Bitmap object_preview_bmp_
 
gfx::Bitmap tile8_atlas_bmp_
 
bool preview_dirty_ = true
 
bool atlas_dirty_ = true
 
bool show_shared_confirm_ = false
 
int shared_object_count_ = 0
 
std::optional< SourceImpactSnapshotpending_shared_confirmation_
 
int shared_tile_data_usage_override_ = -1
 
std::optional< SourceImpactDisplayCacheKeysource_impact_display_cache_key_
 
std::optional< absl::StatusOr< int > > source_impact_display_cache_result_
 
ActionStatusTone action_status_tone_ = ActionStatusTone::kNone
 
std::string action_status_message_
 
bool is_new_object_ = false
 
std::function< void(int, const std::string &) on_object_created_ )
 
StandardWritePreflightCallback standard_write_preflight_
 
StandardTilesAppliedCallback on_standard_tiles_applied_
 
gfx::IRendererrenderer_
 
Romrom_
 
int current_room_id_ = -1
 
int16_t current_object_id_ = -1
 
DungeonRoomStorerooms_ = nullptr
 
gfx::PaletteGroup current_palette_group_
 
bool is_open_ = false
 

Friends

struct ObjectTileEditorPanelTestAccess
 

Additional Inherited Members

- Protected Member Functions inherited from yaze::editor::WindowContent
void InvalidateCache ()
 Invalidate all cached computations.
 
template<typename T >
T & GetCached (const std::string &key, std::function< T()> compute)
 Get or compute a cached value.
 
bool IsCacheValid () const
 Check if cache has been invalidated.
 
void ClearCache ()
 Clear all cached values (more aggressive than InvalidateCache)
 

Detailed Description

Panel for editing the tile8 composition of dungeon objects.

Shows an interactive grid of an object's constituent 8x8 tiles alongside a tile source sheet from the room's graphics buffer. Users can click a cell in the grid, then pick a replacement tile from the source sheet. Tile properties (palette, flip, priority) can be edited per-cell.

Standard-object sessions open from the dungeon canvas selection menu. New custom-object sessions are prepared by the custom object workshop.

Definition at line 42 of file object_tile_editor_panel.h.

Member Typedef Documentation

◆ StandardWritePreflightCallback

Initial value:
std::function<absl::Status(
const std::vector<std::pair<uint32_t, uint32_t>>&)>

Definition at line 44 of file object_tile_editor_panel.h.

◆ StandardTilesAppliedCallback

Definition at line 46 of file object_tile_editor_panel.h.

Member Enumeration Documentation

◆ ActionStatusTone

Enumerator
kNone 
kWarning 
kSuccess 
kError 

Definition at line 95 of file object_tile_editor_panel.h.

Constructor & Destructor Documentation

◆ ObjectTileEditorPanel()

yaze::editor::ObjectTileEditorPanel::ObjectTileEditorPanel ( gfx::IRenderer * renderer,
Rom * rom )

Definition at line 23 of file object_tile_editor_panel.cc.

References tile_editor_.

Member Function Documentation

◆ GetId()

std::string yaze::editor::ObjectTileEditorPanel::GetId ( ) const
inlineoverridevirtual

Unique identifier for this panel.

Returns
Panel ID in format "{category}.{name}" (e.g., "dungeon.room_selector")

IDs should be:

  • Lowercase with underscores
  • Prefixed with editor category
  • Unique across all panels

Implements yaze::editor::WindowContent.

Definition at line 50 of file object_tile_editor_panel.h.

Referenced by yaze::editor::DungeonEditorV2::Load(), and yaze::editor::DungeonEditorV2::OpenObjectTileEditorForObject().

◆ GetDisplayName()

std::string yaze::editor::ObjectTileEditorPanel::GetDisplayName ( ) const
inlineoverridevirtual

Human-readable name shown in menus and title bars.

Returns
Display name (e.g., "Room Selector")

Implements yaze::editor::WindowContent.

Definition at line 51 of file object_tile_editor_panel.h.

◆ GetIcon()

std::string yaze::editor::ObjectTileEditorPanel::GetIcon ( ) const
inlineoverridevirtual

Material Design icon for this panel.

Returns
Icon constant (e.g., ICON_MD_LIST)

Implements yaze::editor::WindowContent.

Definition at line 52 of file object_tile_editor_panel.h.

References ICON_MD_GRID_ON.

◆ GetEditorCategory()

std::string yaze::editor::ObjectTileEditorPanel::GetEditorCategory ( ) const
inlineoverridevirtual

Editor category this panel belongs to.

Returns
Category name matching EditorType (e.g., "Dungeon", "Overworld")

Implements yaze::editor::WindowContent.

Definition at line 53 of file object_tile_editor_panel.h.

◆ GetPriority()

int yaze::editor::ObjectTileEditorPanel::GetPriority ( ) const
inlineoverridevirtual

Get display priority for menu ordering.

Returns
Priority value (lower = higher in list, default 50)

Reimplemented from yaze::editor::WindowContent.

Definition at line 54 of file object_tile_editor_panel.h.

◆ GetPreferredWidth()

float yaze::editor::ObjectTileEditorPanel::GetPreferredWidth ( ) const
inlineoverridevirtual

Get preferred width for this panel (optional)

Returns
Preferred width in pixels, or 0 to use default (250px)

Override this to specify content-based sizing. For example, a tile selector with 8 tiles at 16px × 2.0 scale would return ~276px.

Reimplemented from yaze::editor::WindowContent.

Definition at line 55 of file object_tile_editor_panel.h.

◆ GetPreferredHeight()

float yaze::editor::ObjectTileEditorPanel::GetPreferredHeight ( ) const
inlineoverridevirtual

Get preferred height for this panel (optional)

Returns
Preferred height in pixels, or 0 to use the default height.

Override this with GetPreferredWidth() for panels whose first-use window must be large enough to keep their primary controls visible.

Reimplemented from yaze::editor::WindowContent.

Definition at line 56 of file object_tile_editor_panel.h.

◆ Draw()

void yaze::editor::ObjectTileEditorPanel::Draw ( bool * p_open)
overridevirtual

Draw the panel content.

Parameters
p_openPointer to visibility flag (nullptr if not closable)

Called by WorkspaceWindowManager when the panel is visible. Do NOT call ImGui::Begin/End - the PanelWindow wrapper handles that. Just draw your content directly.

Implements yaze::editor::WindowContent.

Definition at line 335 of file object_tile_editor_panel.cc.

References ApplyChanges(), BuildWindowTitle(), yaze::zelda3::ObjectTileLayout::cells, current_layout_, current_room_id_, DrawActionBar(), DrawSourceSheet(), DrawTileGrid(), DrawTileProperties(), HandleKeyboardShortcuts(), is_open_, pending_shared_confirmation_, shared_object_count_, and show_shared_confirm_.

◆ OnClose()

void yaze::editor::ObjectTileEditorPanel::OnClose ( )
overridevirtual

Called when panel is hidden.

Use this to cleanup state, release resources, or save state. Called after the panel is hidden.

Reimplemented from yaze::editor::WindowContent.

Definition at line 138 of file object_tile_editor_panel.cc.

References Close(), current_layout_, and yaze::zelda3::ObjectTileLayout::HasModifications().

Here is the call graph for this function:

◆ OpenForObject() [1/2]

absl::Status yaze::editor::ObjectTileEditorPanel::OpenForObject ( int16_t object_id,
int room_id,
DungeonRoomStore * rooms )

Definition at line 59 of file object_tile_editor_panel.cc.

References current_palette_group_, and OpenForObject().

Referenced by OpenForObject(), and yaze::editor::DungeonEditorV2::OpenObjectTileEditorForObject().

Here is the call graph for this function:

◆ OpenForObject() [2/2]

◆ OpenForNewObject()

absl::Status yaze::editor::ObjectTileEditorPanel::OpenForNewObject ( int width,
int height,
const std::string & filename,
int16_t object_id,
int room_id,
DungeonRoomStore * rooms )

◆ Close()

◆ IsOpen()

bool yaze::editor::ObjectTileEditorPanel::IsOpen ( ) const
inline

◆ HasUnappliedChanges()

bool yaze::editor::ObjectTileEditorPanel::HasUnappliedChanges ( ) const
inline

◆ SetCurrentPaletteGroup()

void yaze::editor::ObjectTileEditorPanel::SetCurrentPaletteGroup ( const gfx::PaletteGroup & group)

◆ SetCurrentPaletteGroupForRoom()

void yaze::editor::ObjectTileEditorPanel::SetCurrentPaletteGroupForRoom ( int room_id,
const gfx::PaletteGroup & group )

◆ SetObjectCreatedCallback()

void yaze::editor::ObjectTileEditorPanel::SetObjectCreatedCallback ( std::function< void(int, const std::string &)> cb)
inline

Definition at line 80 of file object_tile_editor_panel.h.

References on_object_created_.

◆ SetStandardWritePreflightCallback()

void yaze::editor::ObjectTileEditorPanel::SetStandardWritePreflightCallback ( StandardWritePreflightCallback callback)
inline

Definition at line 85 of file object_tile_editor_panel.h.

References standard_write_preflight_.

◆ SetStandardTilesAppliedCallback()

void yaze::editor::ObjectTileEditorPanel::SetStandardTilesAppliedCallback ( StandardTilesAppliedCallback callback)
inline

Definition at line 90 of file object_tile_editor_panel.h.

References on_standard_tiles_applied_.

◆ ClearRenderedBitmaps()

void yaze::editor::ObjectTileEditorPanel::ClearRenderedBitmaps ( )
private

Definition at line 28 of file object_tile_editor_panel.cc.

References object_preview_bmp_, and tile8_atlas_bmp_.

Referenced by ResetTransientState().

◆ ClearActionStatus()

void yaze::editor::ObjectTileEditorPanel::ClearActionStatus ( )
private

◆ SetActionStatus()

void yaze::editor::ObjectTileEditorPanel::SetActionStatus ( ActionStatusTone tone,
std::string message )
private

Definition at line 38 of file object_tile_editor_panel.cc.

References action_status_message_, and action_status_tone_.

Referenced by ApplyChanges(), and RequestSafeWindowClose().

◆ ResetTransientState()

◆ BuildWindowTitle()

◆ SelectFirstCellIfAvailable()

void yaze::editor::ObjectTileEditorPanel::SelectFirstCellIfAvailable ( )
private

◆ AnalyzeSourceImpactSnapshot()

absl::StatusOr< ObjectTileEditorPanel::SourceImpactSnapshot > yaze::editor::ObjectTileEditorPanel::AnalyzeSourceImpactSnapshot ( ) const
private

◆ GetSharedTileDataUsageCount()

absl::StatusOr< int > yaze::editor::ObjectTileEditorPanel::GetSharedTileDataUsageCount ( ) const
private

Definition at line 245 of file object_tile_editor_panel.cc.

References AnalyzeSourceImpactSnapshot().

Referenced by GetDisplayedSharedTileDataUsageCount(), and HasSharedTileDataConflict().

Here is the call graph for this function:

◆ GetDisplayedSharedTileDataUsageCount()

absl::StatusOr< int > yaze::editor::ObjectTileEditorPanel::GetDisplayedSharedTileDataUsageCount ( )
private

◆ HasSharedTileDataConflict()

absl::StatusOr< bool > yaze::editor::ObjectTileEditorPanel::HasSharedTileDataConflict ( ) const
private

Definition at line 309 of file object_tile_editor_panel.cc.

References GetSharedTileDataUsageCount().

Here is the call graph for this function:

◆ BuildSourceImpactProvenanceFingerprint()

◆ HasRenderableRoomContext()

bool yaze::editor::ObjectTileEditorPanel::HasRenderableRoomContext ( ) const
private

◆ RefreshRenderedViewsFromCurrentRoom()

void yaze::editor::ObjectTileEditorPanel::RefreshRenderedViewsFromCurrentRoom ( )
private

Definition at line 323 of file object_tile_editor_panel.cc.

References atlas_dirty_, HasRenderableRoomContext(), preview_dirty_, RenderObjectPreview(), and RenderTile8Atlas().

Referenced by ApplyChanges().

Here is the call graph for this function:

◆ DrawTileGrid()

◆ DrawSourceSheet()

◆ DrawTileProperties()

void yaze::editor::ObjectTileEditorPanel::DrawTileProperties ( )
private

◆ DrawActionBar()

◆ HandleKeyboardShortcuts()

void yaze::editor::ObjectTileEditorPanel::HandleKeyboardShortcuts ( bool * p_open)
private

◆ RequestSafeWindowClose()

void yaze::editor::ObjectTileEditorPanel::RequestSafeWindowClose ( bool * p_open)
private

Definition at line 954 of file object_tile_editor_panel.cc.

References Close(), current_layout_, yaze::zelda3::ObjectTileLayout::HasModifications(), ICON_MD_WARNING, kWarning, and SetActionStatus().

Referenced by HandleKeyboardShortcuts().

Here is the call graph for this function:

◆ RenderObjectPreview()

void yaze::editor::ObjectTileEditorPanel::RenderObjectPreview ( )
private

◆ RenderTile8Atlas()

void yaze::editor::ObjectTileEditorPanel::RenderTile8Atlas ( )
private

◆ SyncSourceSelectionFromSelectedCell()

void yaze::editor::ObjectTileEditorPanel::SyncSourceSelectionFromSelectedCell ( )
private

◆ WriteBackCurrentLayout()

absl::Status yaze::editor::ObjectTileEditorPanel::WriteBackCurrentLayout ( )
private

◆ ApplyChanges()

Friends And Related Symbol Documentation

◆ ObjectTileEditorPanelTestAccess

friend struct ObjectTileEditorPanelTestAccess
friend

Definition at line 140 of file object_tile_editor_panel.h.

Member Data Documentation

◆ tile_editor_

std::unique_ptr<zelda3::ObjectTileEditor> yaze::editor::ObjectTileEditorPanel::tile_editor_
private

◆ current_layout_

◆ selected_cell_index_

int yaze::editor::ObjectTileEditorPanel::selected_cell_index_ = -1
private

◆ selected_source_tile_

int yaze::editor::ObjectTileEditorPanel::selected_source_tile_ = -1
private

◆ source_palette_

int yaze::editor::ObjectTileEditorPanel::source_palette_ = 2
private

◆ tile_grid_canvas_

gui::Canvas yaze::editor::ObjectTileEditorPanel::tile_grid_canvas_ {"##ObjTileGrid", ImVec2(256, 256)}
private

Definition at line 148 of file object_tile_editor_panel.h.

◆ source_sheet_canvas_

gui::Canvas yaze::editor::ObjectTileEditorPanel::source_sheet_canvas_ {"##ObjTileSource", ImVec2(256, 512)}
private

Definition at line 149 of file object_tile_editor_panel.h.

◆ object_preview_bmp_

gfx::Bitmap yaze::editor::ObjectTileEditorPanel::object_preview_bmp_
private

◆ tile8_atlas_bmp_

gfx::Bitmap yaze::editor::ObjectTileEditorPanel::tile8_atlas_bmp_
private

◆ preview_dirty_

◆ atlas_dirty_

bool yaze::editor::ObjectTileEditorPanel::atlas_dirty_ = true
private

◆ show_shared_confirm_

bool yaze::editor::ObjectTileEditorPanel::show_shared_confirm_ = false
private

Definition at line 158 of file object_tile_editor_panel.h.

Referenced by ApplyChanges(), Draw(), and ResetTransientState().

◆ shared_object_count_

int yaze::editor::ObjectTileEditorPanel::shared_object_count_ = 0
private

Definition at line 159 of file object_tile_editor_panel.h.

Referenced by ApplyChanges(), Draw(), and ResetTransientState().

◆ pending_shared_confirmation_

std::optional<SourceImpactSnapshot> yaze::editor::ObjectTileEditorPanel::pending_shared_confirmation_
private

Definition at line 160 of file object_tile_editor_panel.h.

Referenced by ApplyChanges(), Draw(), and ResetTransientState().

◆ shared_tile_data_usage_override_

int yaze::editor::ObjectTileEditorPanel::shared_tile_data_usage_override_ = -1
private

Definition at line 161 of file object_tile_editor_panel.h.

Referenced by AnalyzeSourceImpactSnapshot(), and ResetTransientState().

◆ source_impact_display_cache_key_

std::optional<SourceImpactDisplayCacheKey> yaze::editor::ObjectTileEditorPanel::source_impact_display_cache_key_
private

◆ source_impact_display_cache_result_

std::optional<absl::StatusOr<int> > yaze::editor::ObjectTileEditorPanel::source_impact_display_cache_result_
private

◆ action_status_tone_

ActionStatusTone yaze::editor::ObjectTileEditorPanel::action_status_tone_ = ActionStatusTone::kNone
private

Definition at line 171 of file object_tile_editor_panel.h.

Referenced by ClearActionStatus(), DrawActionBar(), and SetActionStatus().

◆ action_status_message_

std::string yaze::editor::ObjectTileEditorPanel::action_status_message_
private

Definition at line 172 of file object_tile_editor_panel.h.

Referenced by ClearActionStatus(), DrawActionBar(), and SetActionStatus().

◆ is_new_object_

bool yaze::editor::ObjectTileEditorPanel::is_new_object_ = false
private

◆ on_object_created_

std::function<void(int, const std::string&) yaze::editor::ObjectTileEditorPanel::on_object_created_)
private

Definition at line 176 of file object_tile_editor_panel.h.

Referenced by ApplyChanges(), and SetObjectCreatedCallback().

◆ standard_write_preflight_

StandardWritePreflightCallback yaze::editor::ObjectTileEditorPanel::standard_write_preflight_
private

◆ on_standard_tiles_applied_

StandardTilesAppliedCallback yaze::editor::ObjectTileEditorPanel::on_standard_tiles_applied_
private

Definition at line 178 of file object_tile_editor_panel.h.

Referenced by ApplyChanges(), and SetStandardTilesAppliedCallback().

◆ renderer_

gfx::IRenderer* yaze::editor::ObjectTileEditorPanel::renderer_
private

Definition at line 181 of file object_tile_editor_panel.h.

◆ rom_

Rom* yaze::editor::ObjectTileEditorPanel::rom_
private

◆ current_room_id_

int yaze::editor::ObjectTileEditorPanel::current_room_id_ = -1
private

◆ current_object_id_

int16_t yaze::editor::ObjectTileEditorPanel::current_object_id_ = -1
private

◆ rooms_

DungeonRoomStore* yaze::editor::ObjectTileEditorPanel::rooms_ = nullptr
private

◆ current_palette_group_

gfx::PaletteGroup yaze::editor::ObjectTileEditorPanel::current_palette_group_
private

◆ is_open_

bool yaze::editor::ObjectTileEditorPanel::is_open_ = false
private

The documentation for this class was generated from the following files: