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 TilesAppliedCallback = std::function<void()>
 

Public Member Functions

 ObjectTileEditorPanel (gfx::IRenderer *renderer, Rom *rom)
 
 ~ObjectTileEditorPanel () override
 
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.
 
std::string GetWorkflowGroup () const override
 Optional workflow group for hack-centric actions.
 
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 OpenForCustomObject (int16_t object_id, int subtype, int room_id, DungeonRoomStore *rooms)
 
absl::Status OpenForCustomObject (int16_t object_id, int subtype, int room_id, DungeonRoomStore *rooms, const gfx::PaletteGroup &palette_group)
 
void Close ()
 
bool IsOpen () const
 
int current_room_id () const
 
bool HasUnappliedChanges () const
 
void SetCurrentPaletteGroup (const gfx::PaletteGroup &group)
 
void SetCurrentPaletteGroupForRoom (int room_id, const gfx::PaletteGroup &group)
 
void SetStandardWritePreflightCallback (StandardWritePreflightCallback callback)
 
void SetTilesAppliedCallback (TilesAppliedCallback 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 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::Status AddFirstTileToEmptyCustomLayout ()
 
void RevertCurrentLayout ()
 
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 ()
 
void SyncSourceAttributesFromSelectedCell ()
 
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
 
uint16_t source_attributes_ = 0
 
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
 
uint64_t room_graphics_revision_ = 0
 
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_
 
StandardWritePreflightCallback standard_write_preflight_
 
TilesAppliedCallback on_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. Existing fixed-slot custom assets open from the Custom Assets browser.

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.

◆ TilesAppliedCallback

Definition at line 46 of file object_tile_editor_panel.h.

Member Enumeration Documentation

◆ ActionStatusTone

Enumerator
kNone 
kWarning 
kSuccess 
kError 

Definition at line 94 of file object_tile_editor_panel.h.

Constructor & Destructor Documentation

◆ ObjectTileEditorPanel()

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

Definition at line 37 of file object_tile_editor_panel.cc.

References tile_editor_.

◆ ~ObjectTileEditorPanel()

yaze::editor::ObjectTileEditorPanel::~ObjectTileEditorPanel ( )
override

Definition at line 42 of file object_tile_editor_panel.cc.

References ClearRenderedBitmaps().

Here is the call graph for this function:

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 51 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 52 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 53 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 54 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 55 of file object_tile_editor_panel.h.

◆ GetWorkflowGroup()

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

Optional workflow group for hack-centric actions.

Returns
Non-empty group name to surface this panel in hack workflows.

Reimplemented from yaze::editor::WindowContent.

Definition at line 56 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 57 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 58 of file object_tile_editor_panel.h.

◆ Draw()

◆ 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 183 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 81 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]

◆ OpenForCustomObject() [1/2]

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

Definition at line 128 of file object_tile_editor_panel.cc.

References current_palette_group_, and OpenForCustomObject().

Referenced by yaze::editor::DungeonObjectSelector::OpenExistingCustomObjectEditor(), and OpenForCustomObject().

Here is the call graph for this function:

◆ OpenForCustomObject() [2/2]

◆ Close()

◆ IsOpen()

◆ current_room_id()

int yaze::editor::ObjectTileEditorPanel::current_room_id ( ) 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 )

◆ SetStandardWritePreflightCallback()

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

◆ SetTilesAppliedCallback()

void yaze::editor::ObjectTileEditorPanel::SetTilesAppliedCallback ( TilesAppliedCallback callback)
inline

◆ ClearRenderedBitmaps()

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

Definition at line 46 of file object_tile_editor_panel.cc.

References yaze::gfx::Arena::Get(), object_preview_bmp_, yaze::gfx::Arena::RetireBitmap(), and tile8_atlas_bmp_.

Referenced by ResetTransientState(), and ~ObjectTileEditorPanel().

Here is the call graph for this function:

◆ ClearActionStatus()

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

◆ SetActionStatus()

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

◆ ResetTransientState()

◆ BuildWindowTitle()

std::string yaze::editor::ObjectTileEditorPanel::BuildWindowTitle ( ) const
private

◆ SelectFirstCellIfAvailable()

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

◆ AddFirstTileToEmptyCustomLayout()

◆ RevertCurrentLayout()

◆ AnalyzeSourceImpactSnapshot()

◆ GetSharedTileDataUsageCount()

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

Definition at line 382 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 456 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 470 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 1214 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()

◆ RenderTile8Atlas()

◆ SyncSourceSelectionFromSelectedCell()

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

◆ SyncSourceAttributesFromSelectedCell()

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

◆ WriteBackCurrentLayout()

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

◆ ApplyChanges()

Friends And Related Symbol Documentation

◆ ObjectTileEditorPanelTestAccess

friend struct ObjectTileEditorPanelTestAccess
friend

Definition at line 142 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_

◆ selected_source_tile_

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

◆ source_palette_

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

◆ source_attributes_

uint16_t yaze::editor::ObjectTileEditorPanel::source_attributes_ = 0
private

◆ tile_grid_canvas_

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

Definition at line 151 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 152 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_

◆ room_graphics_revision_

uint64_t yaze::editor::ObjectTileEditorPanel::room_graphics_revision_ = 0
private

Definition at line 159 of file object_tile_editor_panel.h.

Referenced by Draw(), and ResetTransientState().

◆ show_shared_confirm_

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

Definition at line 162 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 163 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 164 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 165 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 175 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 176 of file object_tile_editor_panel.h.

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

◆ standard_write_preflight_

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

◆ on_tiles_applied_

TilesAppliedCallback yaze::editor::ObjectTileEditorPanel::on_tiles_applied_
private

Definition at line 179 of file object_tile_editor_panel.h.

Referenced by ApplyChanges(), and SetTilesAppliedCallback().

◆ renderer_

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

Definition at line 182 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: