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 Member Functions

 ObjectSelectorContent (Rom *rom, DungeonCanvasViewer *canvas_viewer, std::shared_ptr< zelda3::DungeonObjectEditor > object_editor=nullptr, ToastManager *toast_manager=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.
 
std::string GetWorkflowGroup () const override
 Optional workflow group for hack-centric actions.
 
float GetPreferredWidth () const override
 Get preferred width for this panel (optional)
 
void Draw (bool *p_open) override
 Draw the panel content.
 
void DrawInWorkbench ()
 
bool DrawMinecartPalette ()
 
void OnOpen () override
 Called when panel becomes visible.
 
void OnClose () override
 Called when panel is hidden.
 
DungeonObjectSelector & object_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 SetToastManager (ToastManager *toast_manager)
 
void SetPlacementError (const std::string &message)
 
void SetOpenObjectEditorCallback (std::function< void()> callback)
 
void DetachRuntimeContext ()
 
- 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 WindowPresentationPolicy GetPresentationPolicy () const
 How this content is hosted and advertised by workspace chrome.
 
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 HasExactPreferredWidth () const
 Whether GetPreferredWidth() is an exact content width.
 
virtual float GetPreferredHeight () const
 Get preferred height for this panel (optional)
 
virtual bool PrefersFloating () const
 
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

DungeonCanvasViewer * ResolveCanvasViewer ()
 
void DrawObjectSelector (float minimum_grid_height=1.0f)
 
void DrawContent (bool show_placement_summary)
 
void DrawInteractionSummary (bool show_placement_summary)
 

Private Attributes

Rom * rom_ = nullptr
 
DungeonCanvasViewer * canvas_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
 
std::shared_ptr< zelda3::DungeonObjectEditor > object_editor_
 
ToastManager * toast_manager_ = nullptr
 
std::string last_placement_error_
 
double placement_error_time_ = -1.0
 
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 the active DungeonCanvasViewer so the selector can stay focused on choosing assets and initiating placement.

Features:

  • Object browser with graphical previews
  • Placement initiation and feedback
  • Object templates for common patterns
See also
WindowContent - Base interface
DungeonObjectSelector - Object browser component

Definition at line 41 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 52 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 53 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 54 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 55 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 56 of file object_selector_content.h.

◆ GetWorkflowGroup()

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

◆ Draw()

void yaze::editor::ObjectSelectorContent::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 122 of file object_selector_content.cc.

References DrawContent().

Here is the call graph for this function:

◆ DrawInWorkbench()

void yaze::editor::ObjectSelectorContent::DrawInWorkbench ( )

Definition at line 132 of file object_selector_content.cc.

References DrawContent().

Here is the call graph for this function:

◆ DrawMinecartPalette()

bool yaze::editor::ObjectSelectorContent::DrawMinecartPalette ( )

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

◆ object_selector()

◆ SetCurrentRoom()

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

◆ SetCanvasViewerProvider()

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

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

◆ SetContext()

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

◆ 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().

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

Here is the call graph for this function:

◆ SetCurrentPaletteGroup()

◆ SelectObject()

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

Definition at line 231 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()

◆ SetToastManager()

void yaze::editor::ObjectSelectorContent::SetToastManager ( ToastManager * toast_manager)
inline

Definition at line 114 of file object_selector_content.h.

References toast_manager_.

◆ SetPlacementError()

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

◆ SetOpenObjectEditorCallback()

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

Definition at line 122 of file object_selector_content.h.

References open_object_editor_callback_.

◆ DetachRuntimeContext()

void yaze::editor::ObjectSelectorContent::DetachRuntimeContext ( )

◆ ResolveCanvasViewer()

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

◆ DrawObjectSelector()

void yaze::editor::ObjectSelectorContent::DrawObjectSelector ( float minimum_grid_height = 1.0f)
private

Definition at line 256 of file object_selector_content.cc.

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

Referenced by DrawContent().

Here is the call graph for this function:

◆ DrawContent()

◆ DrawInteractionSummary()

Member Data Documentation

◆ rom_

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

Definition at line 139 of file object_selector_content.h.

Referenced by DetachRuntimeContext(), 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

◆ current_room_id_

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

Definition at line 142 of file object_selector_content.h.

Referenced by DrawInteractionSummary(), and SetCurrentRoom().

◆ object_selector_

◆ preview_object_

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

Definition at line 149 of file object_selector_content.h.

Referenced by ObjectSelectorContent().

◆ has_preview_object_

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

◆ object_editor_

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

Definition at line 151 of file object_selector_content.h.

Referenced by DetachRuntimeContext(), and ObjectSelectorContent().

◆ toast_manager_

ToastManager* yaze::editor::ObjectSelectorContent::toast_manager_ = nullptr
private

◆ kPlacementErrorDuration

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

Definition at line 155 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 156 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 157 of file object_selector_content.h.

Referenced by DrawInteractionSummary(), and SetPlacementError().

◆ 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: