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

Browse and place dungeon objects. More...

#include <object_selector_content.h>

Inheritance diagram for yaze::editor::ObjectSelectorContent:

Public Types

using TileEditorCallback = std::function<void(int16_t object_id)>
 

Public Member Functions

 ObjectSelectorContent (gfx::IRenderer *renderer, Rom *rom, DungeonCanvasViewer *canvas_viewer, std::shared_ptr< zelda3::DungeonObjectEditor > object_editor=nullptr)
 
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)
 
void Draw (bool *p_open) override
 Draw the panel content.
 
void OnOpen () override
 Called when panel becomes visible.
 
void OnClose () override
 Called when panel is hidden.
 
DungeonObjectSelectorobject_selector ()
 
void SetCurrentRoom (int room_id)
 
void SetCanvasViewerProvider (std::function< DungeonCanvasViewer *()> provider)
 
void SetCanvasViewer (DungeonCanvasViewer *viewer)
 
void SetContext (EditorContext ctx)
 
void SetGameData (zelda3::GameData *game_data)
 
void SetRooms (DungeonRoomStore *rooms)
 
void SetCurrentPaletteGroup (const gfx::PaletteGroup &group)
 
void SelectObject (int obj_id)
 
void SetAgentOptimizedLayout (bool enabled)
 
void CancelPlacement ()
 
void SetPlacementError (const std::string &message)
 
void SetOpenObjectEditorCallback (std::function< void()> callback)
 
void OpenStaticObjectEditor (int object_id)
 
void CloseStaticObjectEditor ()
 
bool IsStaticEditorOpen () const
 
int GetStaticEditorObjectId () const
 
void set_tile_editor_callback (TileEditorCallback 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 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 Member Functions

DungeonCanvasViewerResolveCanvasViewer ()
 
void DrawObjectSelector ()
 
void DrawInteractionSummary ()
 
void DrawStaticObjectEditor ()
 
void DrawRoomValidationBar ()
 

Private Attributes

Romrom_ = nullptr
 
DungeonCanvasViewercanvas_viewer_ = nullptr
 
std::function< DungeonCanvasViewer *()> canvas_viewer_provider_
 
int current_room_id_ = 0
 
DungeonObjectSelector object_selector_
 
zelda3::RoomObject preview_object_ {0, 0, 0, 0, 0}
 
bool has_preview_object_ = false
 
gfx::IRendererrenderer_
 
std::shared_ptr< zelda3::DungeonObjectEditorobject_editor_
 
bool static_editor_open_ = false
 
int static_editor_object_id_ = -1
 
gfx::Bitmap static_preview_bitmap_
 
gui::Canvas static_preview_canvas_ {"##StaticObjectPreview", ImVec2(128, 128)}
 
zelda3::ObjectDrawInfo static_editor_draw_info_
 
std::unique_ptr< zelda3::ObjectParserobject_parser_
 
gfx::BackgroundBuffer static_preview_buffer_ {128, 128}
 
bool static_preview_rendered_ = false
 
std::string last_placement_error_
 
double placement_error_time_ = -1.0
 
TileEditorCallback tile_editor_callback_
 
std::function< void()> open_object_editor_callback_
 

Static Private Attributes

static constexpr double kPlacementErrorDuration = 2.0
 

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

Browse and place dungeon objects.

This content owns object browsing and placement. Selection editing lives in ObjectEditorContent so the selector can stay focused on choosing assets and initiating placement.

Features:

  • Object browser with graphical previews
  • Static object editor (opened via double-click)
  • Inline placement previews via the canvas/object grid
  • Object templates for common patterns
  • Lightweight placement feedback
See also
WindowContent - Base interface
DungeonObjectSelector - Object browser component

Definition at line 45 of file object_selector_content.h.

Member Typedef Documentation

◆ TileEditorCallback

using yaze::editor::ObjectSelectorContent::TileEditorCallback = std::function<void(int16_t object_id)>

Definition at line 132 of file object_selector_content.h.

Constructor & Destructor Documentation

◆ ObjectSelectorContent()

Member Function Documentation

◆ GetId()

std::string yaze::editor::ObjectSelectorContent::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 55 of file object_selector_content.h.

◆ GetDisplayName()

std::string yaze::editor::ObjectSelectorContent::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 56 of file object_selector_content.h.

◆ GetIcon()

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

Material Design icon for this panel.

Returns
Icon constant (e.g., ICON_MD_LIST)

Implements yaze::editor::WindowContent.

Definition at line 57 of file object_selector_content.h.

References ICON_MD_CONSTRUCTION.

◆ GetEditorCategory()

std::string yaze::editor::ObjectSelectorContent::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 58 of file object_selector_content.h.

◆ GetPriority()

int yaze::editor::ObjectSelectorContent::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 59 of file object_selector_content.h.

◆ GetPreferredWidth()

float yaze::editor::ObjectSelectorContent::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 60 of file object_selector_content.h.

◆ Draw()

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

◆ OnOpen()

void yaze::editor::ObjectSelectorContent::OnOpen ( )
inlineoverridevirtual

Called when panel becomes visible.

Use this to initialize state, load resources, or start animations. Called after the panel is shown but before first Draw().

Reimplemented from yaze::editor::WindowContent.

Definition at line 67 of file object_selector_content.h.

◆ OnClose()

void yaze::editor::ObjectSelectorContent::OnClose ( )
inlineoverridevirtual

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 68 of file object_selector_content.h.

◆ object_selector()

DungeonObjectSelector & yaze::editor::ObjectSelectorContent::object_selector ( )
inline

Definition at line 74 of file object_selector_content.h.

References object_selector_.

Referenced by yaze::editor::DungeonEditorV2::Load().

◆ SetCurrentRoom()

void yaze::editor::ObjectSelectorContent::SetCurrentRoom ( int room_id)
inline

Definition at line 79 of file object_selector_content.h.

References current_room_id_, object_selector_, and yaze::editor::DungeonObjectSelector::set_current_room_id().

Here is the call graph for this function:

◆ SetCanvasViewerProvider()

void yaze::editor::ObjectSelectorContent::SetCanvasViewerProvider ( std::function< DungeonCanvasViewer *()> provider)
inline

Definition at line 83 of file object_selector_content.h.

References canvas_viewer_provider_.

◆ SetCanvasViewer()

void yaze::editor::ObjectSelectorContent::SetCanvasViewer ( DungeonCanvasViewer * viewer)
inline

Definition at line 87 of file object_selector_content.h.

References canvas_viewer_.

Referenced by yaze::editor::DungeonEditorV2::~DungeonEditorV2().

◆ SetContext()

void yaze::editor::ObjectSelectorContent::SetContext ( EditorContext ctx)
inline

Definition at line 89 of file object_selector_content.h.

References object_selector_, yaze::editor::EditorContext::rom, rom_, and yaze::editor::DungeonObjectSelector::SetContext().

Here is the call graph for this function:

◆ SetGameData()

void yaze::editor::ObjectSelectorContent::SetGameData ( zelda3::GameData * game_data)
inline

◆ SetRooms()

void yaze::editor::ObjectSelectorContent::SetRooms ( DungeonRoomStore * rooms)
inline

Definition at line 98 of file object_selector_content.h.

References object_selector_, and yaze::editor::DungeonObjectSelector::set_rooms().

Here is the call graph for this function:

◆ SetCurrentPaletteGroup()

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

◆ SelectObject()

void yaze::editor::ObjectSelectorContent::SelectObject ( int obj_id)

Definition at line 176 of file object_selector_content.cc.

References object_selector_, and yaze::editor::DungeonObjectSelector::SelectObject().

Referenced by yaze::editor::DungeonEditorV2::SelectObject().

Here is the call graph for this function:

◆ SetAgentOptimizedLayout()

void yaze::editor::ObjectSelectorContent::SetAgentOptimizedLayout ( bool enabled)

◆ CancelPlacement()

void yaze::editor::ObjectSelectorContent::CancelPlacement ( )

◆ SetPlacementError()

void yaze::editor::ObjectSelectorContent::SetPlacementError ( const std::string & message)

◆ SetOpenObjectEditorCallback()

void yaze::editor::ObjectSelectorContent::SetOpenObjectEditorCallback ( std::function< void()> callback)
inline

Definition at line 118 of file object_selector_content.h.

References open_object_editor_callback_.

◆ OpenStaticObjectEditor()

◆ CloseStaticObjectEditor()

void yaze::editor::ObjectSelectorContent::CloseStaticObjectEditor ( )

◆ IsStaticEditorOpen()

bool yaze::editor::ObjectSelectorContent::IsStaticEditorOpen ( ) const
inline

Definition at line 128 of file object_selector_content.h.

References static_editor_open_.

◆ GetStaticEditorObjectId()

int yaze::editor::ObjectSelectorContent::GetStaticEditorObjectId ( ) const
inline

Definition at line 129 of file object_selector_content.h.

References static_editor_object_id_.

◆ set_tile_editor_callback()

void yaze::editor::ObjectSelectorContent::set_tile_editor_callback ( TileEditorCallback callback)
inline

Definition at line 133 of file object_selector_content.h.

References tile_editor_callback_.

◆ ResolveCanvasViewer()

DungeonCanvasViewer * yaze::editor::ObjectSelectorContent::ResolveCanvasViewer ( )
private

Definition at line 70 of file object_selector_content.cc.

References canvas_viewer_, and canvas_viewer_provider_.

Referenced by Draw(), and DrawInteractionSummary().

◆ DrawObjectSelector()

void yaze::editor::ObjectSelectorContent::DrawObjectSelector ( )
private

Definition at line 198 of file object_selector_content.cc.

References yaze::editor::DungeonObjectSelector::DrawObjectAssetBrowser(), and object_selector_.

Referenced by Draw().

Here is the call graph for this function:

◆ DrawInteractionSummary()

◆ DrawStaticObjectEditor()

◆ DrawRoomValidationBar()

Member Data Documentation

◆ rom_

Rom* yaze::editor::ObjectSelectorContent::rom_ = nullptr
private

Definition at line 150 of file object_selector_content.h.

Referenced by OpenStaticObjectEditor(), and SetContext().

◆ canvas_viewer_

DungeonCanvasViewer* yaze::editor::ObjectSelectorContent::canvas_viewer_ = nullptr
private

◆ canvas_viewer_provider_

std::function<DungeonCanvasViewer*()> yaze::editor::ObjectSelectorContent::canvas_viewer_provider_
private

Definition at line 152 of file object_selector_content.h.

Referenced by ResolveCanvasViewer(), and SetCanvasViewerProvider().

◆ current_room_id_

int yaze::editor::ObjectSelectorContent::current_room_id_ = 0
private

◆ object_selector_

◆ preview_object_

zelda3::RoomObject yaze::editor::ObjectSelectorContent::preview_object_ {0, 0, 0, 0, 0}
private

Definition at line 160 of file object_selector_content.h.

Referenced by DrawInteractionSummary(), and ObjectSelectorContent().

◆ has_preview_object_

bool yaze::editor::ObjectSelectorContent::has_preview_object_ = false
private

◆ renderer_

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

Definition at line 162 of file object_selector_content.h.

Referenced by OpenStaticObjectEditor().

◆ object_editor_

std::shared_ptr<zelda3::DungeonObjectEditor> yaze::editor::ObjectSelectorContent::object_editor_
private

Definition at line 163 of file object_selector_content.h.

Referenced by ObjectSelectorContent().

◆ static_editor_open_

bool yaze::editor::ObjectSelectorContent::static_editor_open_ = false
private

◆ static_editor_object_id_

int yaze::editor::ObjectSelectorContent::static_editor_object_id_ = -1
private

◆ static_preview_bitmap_

gfx::Bitmap yaze::editor::ObjectSelectorContent::static_preview_bitmap_
private

Definition at line 168 of file object_selector_content.h.

◆ static_preview_canvas_

gui::Canvas yaze::editor::ObjectSelectorContent::static_preview_canvas_ {"##StaticObjectPreview", ImVec2(128, 128)}
private

Definition at line 169 of file object_selector_content.h.

Referenced by DrawStaticObjectEditor().

◆ static_editor_draw_info_

zelda3::ObjectDrawInfo yaze::editor::ObjectSelectorContent::static_editor_draw_info_
private

Definition at line 170 of file object_selector_content.h.

Referenced by DrawStaticObjectEditor(), and OpenStaticObjectEditor().

◆ object_parser_

std::unique_ptr<zelda3::ObjectParser> yaze::editor::ObjectSelectorContent::object_parser_
private

Definition at line 171 of file object_selector_content.h.

Referenced by ObjectSelectorContent(), and OpenStaticObjectEditor().

◆ static_preview_buffer_

gfx::BackgroundBuffer yaze::editor::ObjectSelectorContent::static_preview_buffer_ {128, 128}
private

Definition at line 172 of file object_selector_content.h.

Referenced by DrawStaticObjectEditor(), and OpenStaticObjectEditor().

◆ static_preview_rendered_

bool yaze::editor::ObjectSelectorContent::static_preview_rendered_ = false
private

Definition at line 173 of file object_selector_content.h.

Referenced by DrawStaticObjectEditor(), and OpenStaticObjectEditor().

◆ kPlacementErrorDuration

constexpr double yaze::editor::ObjectSelectorContent::kPlacementErrorDuration = 2.0
staticconstexprprivate

Definition at line 176 of file object_selector_content.h.

Referenced by DrawInteractionSummary(), and SetPlacementError().

◆ last_placement_error_

std::string yaze::editor::ObjectSelectorContent::last_placement_error_
private

Definition at line 177 of file object_selector_content.h.

Referenced by DrawInteractionSummary(), and SetPlacementError().

◆ placement_error_time_

double yaze::editor::ObjectSelectorContent::placement_error_time_ = -1.0
private

Definition at line 178 of file object_selector_content.h.

Referenced by DrawInteractionSummary(), and SetPlacementError().

◆ tile_editor_callback_

TileEditorCallback yaze::editor::ObjectSelectorContent::tile_editor_callback_
private

Definition at line 181 of file object_selector_content.h.

Referenced by DrawStaticObjectEditor(), and set_tile_editor_callback().

◆ open_object_editor_callback_

std::function<void()> yaze::editor::ObjectSelectorContent::open_object_editor_callback_
private

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