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

Handles object selection, preview, and editing UI. More...

#include <dungeon_object_selector.h>

Public Member Functions

 DungeonObjectSelector (Rom *rom=nullptr)
 
 ~DungeonObjectSelector ()
 
void SetContext (EditorContext ctx)
 
EditorContext context () const
 
void SetRom (Rom *rom)
 
Romrom () const
 
void SetGameData (zelda3::GameData *game_data)
 
zelda3::GameDatagame_data () const
 
void set_rooms (DungeonRoomStore *rooms)
 
DungeonRoomStoreget_rooms ()
 
void set_current_room_id (int room_id)
 
void SetCurrentPaletteGroup (const gfx::PaletteGroup &palette_group)
 
void SetObjectSelectedCallback (std::function< void(const zelda3::RoomObject &)> callback)
 
void SetPlacementInvalidatedCallback (std::function< void()> callback)
 
const zelda3::RoomObjectGetPreviewObject () const
 
bool IsObjectLoaded () const
 
void DrawObjectAssetBrowser ()
 
void SelectObject (int obj_id, int subtype=-1)
 
void SetTileEditorPanel (ObjectTileEditorPanel *panel)
 
void SetOpenTileEditorWindowCallback (std::function< bool()> callback)
 
void SetOpenMinecartEditorWindowCallback (std::function< bool()> callback)
 
void InvalidatePreviewCache ()
 
void SynchronizeCustomObjectGeneration ()
 
void DetachRuntimeContext ()
 
std::size_t preview_cache_invalidations_for_testing () const
 
bool object_previews_enabled_for_testing () const
 
int selected_object_id_for_testing () const
 
bool matches_object_filter_for_testing (int obj_id, int filter_type)
 
std::string object_type_symbol_for_testing (int object_id)
 

Static Public Member Functions

static bool IsRepresentableChestObjectId (int object_id)
 

Private Types

enum class  BrowserMode { kObjects , kCustomAssets }
 

Private Member Functions

bool MatchesObjectFilter (int obj_id, int filter_type)
 
bool MatchesObjectSearch (int obj_id, const std::string &name, int subtype=-1) const
 
void CalculateObjectDimensions (const zelda3::RoomObject &object, int &width, int &height)
 
bool DrawObjectPreview (const zelda3::RoomObject &object, ImVec2 top_left, ImVec2 box_size)
 
zelda3::RoomObject MakePreviewObject (int obj_id) const
 
void EnsureRegistryInitialized ()
 
ImU32 GetObjectTypeColor (int object_id)
 
std::string GetObjectTypeSymbol (int object_id)
 
absl::Status GetCustomObjectAssetStatus (int object_id, int subtype)
 
void DrawCustomObjectAssetBrowser ()
 
absl::Status OpenExistingCustomObjectEditor (int16_t object_id, int subtype, int room_id)
 
void RetirePreviewCache ()
 
void SynchronizePreviewCacheRoomContext (const zelda3::Room &room)
 
bool GetOrCreatePreview (const zelda3::RoomObject &object, gfx::BackgroundBuffer **out)
 

Static Private Member Functions

static uint32_t MakeLayoutCacheKey (int object_id, uint8_t preview_size, const zelda3::Room *room)
 

Private Attributes

BrowserMode browser_mode_ = BrowserMode::kObjects
 
int custom_asset_family_id_ = 0x31
 
int custom_asset_subtype_ = 0
 
ObjectTileEditorPaneltile_editor_panel_ = nullptr
 
std::function< bool()> open_tile_editor_window_callback_
 
std::function< bool()> open_minecart_editor_window_callback_
 
std::string custom_object_action_error_
 
Romrom_ = nullptr
 
zelda3::GameDatagame_data_ = nullptr
 
uint64_t observed_custom_object_generation_ = 0
 
bool observed_custom_objects_enabled_ = false
 
std::map< uint32_t, absl::Status > custom_asset_status_cache_
 
DungeonRoomStorerooms_ = nullptr
 
int current_room_id_ = 0
 
gfx::PaletteGroup current_palette_group_
 
zelda3::DungeonObjectRegistry object_registry_
 
zelda3::RoomObject preview_object_ {0, 0, 0, 0, 0}
 
bool object_loaded_ = false
 
bool preview_uses_custom_override_ = false
 
std::function< void(const zelda3::RoomObject &) object_selected_callback_ )
 
std::function< void()> placement_invalidated_callback_
 
int selected_object_id_ = -1
 
int object_type_filter_ = 0
 
int object_stream_filter_ = 0
 
int object_grid_density_ = 0
 
char object_search_buffer_ [64] = {0}
 
bool registry_initialized_ = false
 
bool enable_object_previews_ = true
 
std::map< uint64_t, std::unique_ptr< gfx::BackgroundBuffer > > preview_cache_
 
uint8_t cached_preview_blockset_ = 0xFF
 
uint8_t cached_preview_entrance_blockset_ = 0xFF
 
uint8_t cached_preview_palette_ = 0xFF
 
uint8_t cached_preview_floor1_ = 0xFF
 
uint8_t cached_preview_floor2_ = 0xFF
 
int cached_preview_room_id_ = -1
 
uint64_t cached_preview_graphics_revision_ = 0
 
std::map< uint32_t, zelda3::ObjectTileLayoutlayout_cache_
 
std::size_t preview_cache_invalidations_ = 0
 

Friends

struct DungeonObjectSelectorTestAccess
 

Detailed Description

Handles object selection, preview, and editing UI.

Definition at line 62 of file dungeon_object_selector.h.

Member Enumeration Documentation

◆ BrowserMode

Enumerator
kObjects 
kCustomAssets 

Definition at line 155 of file dungeon_object_selector.h.

Constructor & Destructor Documentation

◆ DungeonObjectSelector()

yaze::editor::DungeonObjectSelector::DungeonObjectSelector ( Rom * rom = nullptr)
inlineexplicit

Definition at line 64 of file dungeon_object_selector.h.

◆ ~DungeonObjectSelector()

yaze::editor::DungeonObjectSelector::~DungeonObjectSelector ( )

Definition at line 217 of file dungeon_object_selector.cc.

References RetirePreviewCache().

Here is the call graph for this function:

Member Function Documentation

◆ SetContext()

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

◆ context()

EditorContext yaze::editor::DungeonObjectSelector::context ( ) const
inline

Definition at line 72 of file dungeon_object_selector.h.

References game_data_, and rom_.

◆ SetRom()

void yaze::editor::DungeonObjectSelector::SetRom ( Rom * rom)
inline

Definition at line 75 of file dungeon_object_selector.h.

References rom(), and rom_.

Here is the call graph for this function:

◆ rom()

Rom * yaze::editor::DungeonObjectSelector::rom ( ) const
inline

Definition at line 76 of file dungeon_object_selector.h.

References rom_.

Referenced by SetRom().

◆ SetGameData()

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

Definition at line 77 of file dungeon_object_selector.h.

References game_data(), and game_data_.

Referenced by yaze::editor::ObjectSelectorContent::SetGameData().

Here is the call graph for this function:

◆ game_data()

zelda3::GameData * yaze::editor::DungeonObjectSelector::game_data ( ) const
inline

Definition at line 78 of file dungeon_object_selector.h.

References game_data_.

Referenced by SetGameData().

◆ set_rooms()

void yaze::editor::DungeonObjectSelector::set_rooms ( DungeonRoomStore * rooms)
inline

Definition at line 81 of file dungeon_object_selector.h.

References rooms_.

Referenced by yaze::editor::ObjectSelectorContent::SetRooms().

◆ get_rooms()

DungeonRoomStore * yaze::editor::DungeonObjectSelector::get_rooms ( )
inline

◆ set_current_room_id()

void yaze::editor::DungeonObjectSelector::set_current_room_id ( int room_id)
inline

◆ SetCurrentPaletteGroup()

void yaze::editor::DungeonObjectSelector::SetCurrentPaletteGroup ( const gfx::PaletteGroup & palette_group)
inline

Definition at line 93 of file dungeon_object_selector.h.

References current_palette_group_, and InvalidatePreviewCache().

Referenced by yaze::editor::ObjectSelectorContent::SetCurrentPaletteGroup().

Here is the call graph for this function:

◆ SetObjectSelectedCallback()

void yaze::editor::DungeonObjectSelector::SetObjectSelectedCallback ( std::function< void(const zelda3::RoomObject &)> callback)
inline

◆ SetPlacementInvalidatedCallback()

void yaze::editor::DungeonObjectSelector::SetPlacementInvalidatedCallback ( std::function< void()> callback)
inline

◆ GetPreviewObject()

const zelda3::RoomObject & yaze::editor::DungeonObjectSelector::GetPreviewObject ( ) const
inline

Definition at line 107 of file dungeon_object_selector.h.

References preview_object_.

◆ IsObjectLoaded()

bool yaze::editor::DungeonObjectSelector::IsObjectLoaded ( ) const
inline

Definition at line 108 of file dungeon_object_selector.h.

References object_loaded_.

◆ DrawObjectAssetBrowser()

void yaze::editor::DungeonObjectSelector::DrawObjectAssetBrowser ( )

Definition at line 320 of file dungeon_object_selector.cc.

References yaze::zelda3::DrawRoutineSymbology::badge, yaze::gui::BeginRoomObjectDragSource(), browser_mode_, yaze::zelda3::ObjectTileEditor::CaptureObjectLayout(), current_palette_group_, current_room_id_, yaze::Rom::data(), yaze::zelda3::DefaultRoomObjectSizeForPlacement(), DrawCustomObjectAssetBrowser(), DrawObjectPreview(), yaze::zelda3::DrawRoutineSymbology::dual_layer, enable_object_previews_, yaze::zelda3::DrawRoutineSymbology::family, yaze::core::FeatureFlags::get(), yaze::zelda3::CustomObjectManager::Get(), yaze::zelda3::ObjectDrawer::GetDrawRoutineId(), yaze::zelda3::GetObjectName(), yaze::zelda3::GetObjectSubtype(), GetObjectTypeColor(), GetObjectTypeSymbol(), yaze::zelda3::GetSymbologyForObject(), yaze::editor::AgentUI::GetTheme(), kCustomAssets, yaze::core::FeatureFlags::Flags::kEnableCustomObjects, yaze::zelda3::kNumberOfRooms, kObjects, layout_cache_, MakeLayoutCacheKey(), MakePreviewObject(), yaze::editor::MatchesDungeonObjectStreamFilter(), MatchesObjectFilter(), MatchesObjectSearch(), object_grid_density_, object_search_buffer_, object_stream_filter_, object_type_filter_, yaze::editor::ResolveDungeonObjectSelectorGridLayout(), rom_, rooms_, yaze::zelda3::CustomObjectManager::RuntimeObjectIds(), yaze::zelda3::CustomObjectManager::RuntimeSubtypeCountForObject(), selected_object_id_, SelectObject(), and SynchronizeCustomObjectGeneration().

Referenced by yaze::editor::ObjectSelectorContent::DrawObjectSelector().

◆ SelectObject()

◆ SetTileEditorPanel()

void yaze::editor::DungeonObjectSelector::SetTileEditorPanel ( ObjectTileEditorPanel * panel)
inline

Definition at line 117 of file dungeon_object_selector.h.

References tile_editor_panel_.

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

◆ SetOpenTileEditorWindowCallback()

void yaze::editor::DungeonObjectSelector::SetOpenTileEditorWindowCallback ( std::function< bool()> callback)
inline

◆ SetOpenMinecartEditorWindowCallback()

void yaze::editor::DungeonObjectSelector::SetOpenMinecartEditorWindowCallback ( std::function< bool()> callback)
inline

◆ InvalidatePreviewCache()

◆ SynchronizeCustomObjectGeneration()

◆ DetachRuntimeContext()

◆ preview_cache_invalidations_for_testing()

std::size_t yaze::editor::DungeonObjectSelector::preview_cache_invalidations_for_testing ( ) const
inline

Definition at line 138 of file dungeon_object_selector.h.

References preview_cache_invalidations_.

◆ object_previews_enabled_for_testing()

bool yaze::editor::DungeonObjectSelector::object_previews_enabled_for_testing ( ) const
inline

Definition at line 141 of file dungeon_object_selector.h.

References enable_object_previews_.

◆ selected_object_id_for_testing()

int yaze::editor::DungeonObjectSelector::selected_object_id_for_testing ( ) const
inline

Definition at line 144 of file dungeon_object_selector.h.

References selected_object_id_.

◆ matches_object_filter_for_testing()

bool yaze::editor::DungeonObjectSelector::matches_object_filter_for_testing ( int obj_id,
int filter_type )
inline

Definition at line 145 of file dungeon_object_selector.h.

References MatchesObjectFilter().

Here is the call graph for this function:

◆ object_type_symbol_for_testing()

std::string yaze::editor::DungeonObjectSelector::object_type_symbol_for_testing ( int object_id)
inline

Definition at line 148 of file dungeon_object_selector.h.

References GetObjectTypeSymbol().

Here is the call graph for this function:

◆ IsRepresentableChestObjectId()

bool yaze::editor::DungeonObjectSelector::IsRepresentableChestObjectId ( int object_id)
static

Definition at line 221 of file dungeon_object_selector.cc.

References yaze::zelda3::ObjectCategories::GetObjectCategory().

Here is the call graph for this function:

◆ MatchesObjectFilter()

bool yaze::editor::DungeonObjectSelector::MatchesObjectFilter ( int obj_id,
int filter_type )
private

Definition at line 720 of file dungeon_object_selector.cc.

References yaze::zelda3::ObjectCategories::GetObjectCategory().

Referenced by DrawObjectAssetBrowser(), and matches_object_filter_for_testing().

Here is the call graph for this function:

◆ MatchesObjectSearch()

bool yaze::editor::DungeonObjectSelector::MatchesObjectSearch ( int obj_id,
const std::string & name,
int subtype = -1 ) const
private

Definition at line 730 of file dungeon_object_selector.cc.

References object_search_buffer_.

Referenced by DrawObjectAssetBrowser().

◆ CalculateObjectDimensions()

void yaze::editor::DungeonObjectSelector::CalculateObjectDimensions ( const zelda3::RoomObject & object,
int & width,
int & height )
private

Definition at line 772 of file dungeon_object_selector.cc.

References yaze::zelda3::DimensionService::Get(), and yaze::zelda3::DimensionService::GetPixelDimensions().

Here is the call graph for this function:

◆ DrawObjectPreview()

◆ MakePreviewObject()

zelda3::RoomObject yaze::editor::DungeonObjectSelector::MakePreviewObject ( int obj_id) const
private

Definition at line 903 of file dungeon_object_selector.cc.

References yaze::zelda3::DefaultRoomObjectSizeForPlacement(), rom_, and yaze::zelda3::RoomObject::SetRom().

Referenced by DrawCustomObjectAssetBrowser(), and DrawObjectAssetBrowser().

Here is the call graph for this function:

◆ EnsureRegistryInitialized()

void yaze::editor::DungeonObjectSelector::EnsureRegistryInitialized ( )
private

Definition at line 779 of file dungeon_object_selector.cc.

References object_registry_, yaze::zelda3::DungeonObjectRegistry::RegisterVanillaRange(), and registry_initialized_.

Here is the call graph for this function:

◆ GetObjectTypeColor()

ImU32 yaze::editor::DungeonObjectSelector::GetObjectTypeColor ( int object_id)
private

Definition at line 226 of file dungeon_object_selector.cc.

References yaze::zelda3::ObjectCategories::GetObjectCategory(), and yaze::editor::AgentUI::GetTheme().

Referenced by DrawObjectAssetBrowser().

Here is the call graph for this function:

◆ GetObjectTypeSymbol()

std::string yaze::editor::DungeonObjectSelector::GetObjectTypeSymbol ( int object_id)
private

Definition at line 248 of file dungeon_object_selector.cc.

References yaze::zelda3::ObjectCategories::GetObjectCategory().

Referenced by DrawObjectAssetBrowser(), and object_type_symbol_for_testing().

Here is the call graph for this function:

◆ GetCustomObjectAssetStatus()

absl::Status yaze::editor::DungeonObjectSelector::GetCustomObjectAssetStatus ( int object_id,
int subtype )
private

◆ DrawCustomObjectAssetBrowser()

◆ OpenExistingCustomObjectEditor()

absl::Status yaze::editor::DungeonObjectSelector::OpenExistingCustomObjectEditor ( int16_t object_id,
int subtype,
int room_id )
private

◆ RetirePreviewCache()

void yaze::editor::DungeonObjectSelector::RetirePreviewCache ( )
private

Definition at line 917 of file dungeon_object_selector.cc.

References yaze::gfx::Arena::Get(), and preview_cache_.

Referenced by InvalidatePreviewCache(), and ~DungeonObjectSelector().

Here is the call graph for this function:

◆ SynchronizePreviewCacheRoomContext()

◆ MakeLayoutCacheKey()

uint32_t yaze::editor::DungeonObjectSelector::MakeLayoutCacheKey ( int object_id,
uint8_t preview_size,
const zelda3::Room * room )
staticprivate

Definition at line 950 of file dungeon_object_selector.cc.

References yaze::zelda3::Room::floor1(), and yaze::zelda3::Room::floor2().

Referenced by DrawObjectAssetBrowser().

Here is the call graph for this function:

◆ GetOrCreatePreview()

Friends And Related Symbol Documentation

◆ DungeonObjectSelectorTestAccess

friend struct DungeonObjectSelectorTestAccess
friend

Definition at line 154 of file dungeon_object_selector.h.

Member Data Documentation

◆ browser_mode_

BrowserMode yaze::editor::DungeonObjectSelector::browser_mode_ = BrowserMode::kObjects
private

Definition at line 176 of file dungeon_object_selector.h.

Referenced by DrawObjectAssetBrowser().

◆ custom_asset_family_id_

int yaze::editor::DungeonObjectSelector::custom_asset_family_id_ = 0x31
private

Definition at line 177 of file dungeon_object_selector.h.

Referenced by DrawCustomObjectAssetBrowser().

◆ custom_asset_subtype_

int yaze::editor::DungeonObjectSelector::custom_asset_subtype_ = 0
private

Definition at line 178 of file dungeon_object_selector.h.

Referenced by DrawCustomObjectAssetBrowser().

◆ tile_editor_panel_

ObjectTileEditorPanel* yaze::editor::DungeonObjectSelector::tile_editor_panel_ = nullptr
private

◆ open_tile_editor_window_callback_

std::function<bool()> yaze::editor::DungeonObjectSelector::open_tile_editor_window_callback_
private

◆ open_minecart_editor_window_callback_

std::function<bool()> yaze::editor::DungeonObjectSelector::open_minecart_editor_window_callback_
private

◆ custom_object_action_error_

std::string yaze::editor::DungeonObjectSelector::custom_object_action_error_
private

◆ rom_

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

◆ game_data_

zelda3::GameData* yaze::editor::DungeonObjectSelector::game_data_ = nullptr
private

◆ observed_custom_object_generation_

uint64_t yaze::editor::DungeonObjectSelector::observed_custom_object_generation_ = 0
private

◆ observed_custom_objects_enabled_

bool yaze::editor::DungeonObjectSelector::observed_custom_objects_enabled_ = false
private

◆ custom_asset_status_cache_

std::map<uint32_t, absl::Status> yaze::editor::DungeonObjectSelector::custom_asset_status_cache_
private

◆ rooms_

◆ current_room_id_

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

◆ current_palette_group_

gfx::PaletteGroup yaze::editor::DungeonObjectSelector::current_palette_group_
private

◆ object_registry_

zelda3::DungeonObjectRegistry yaze::editor::DungeonObjectSelector::object_registry_
private

Definition at line 199 of file dungeon_object_selector.h.

Referenced by EnsureRegistryInitialized().

◆ preview_object_

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

◆ object_loaded_

bool yaze::editor::DungeonObjectSelector::object_loaded_ = false
private

◆ preview_uses_custom_override_

bool yaze::editor::DungeonObjectSelector::preview_uses_custom_override_ = false
private

◆ object_selected_callback_

std::function<void(const zelda3::RoomObject&) yaze::editor::DungeonObjectSelector::object_selected_callback_)
private

◆ placement_invalidated_callback_

std::function<void()> yaze::editor::DungeonObjectSelector::placement_invalidated_callback_
private

◆ selected_object_id_

int yaze::editor::DungeonObjectSelector::selected_object_id_ = -1
private

◆ object_type_filter_

int yaze::editor::DungeonObjectSelector::object_type_filter_ = 0
private

Definition at line 214 of file dungeon_object_selector.h.

Referenced by DrawObjectAssetBrowser().

◆ object_stream_filter_

int yaze::editor::DungeonObjectSelector::object_stream_filter_ = 0
private

Definition at line 215 of file dungeon_object_selector.h.

Referenced by DrawObjectAssetBrowser().

◆ object_grid_density_

int yaze::editor::DungeonObjectSelector::object_grid_density_ = 0
private

◆ object_search_buffer_

char yaze::editor::DungeonObjectSelector::object_search_buffer_[64] = {0}
private

Definition at line 217 of file dungeon_object_selector.h.

Referenced by DrawObjectAssetBrowser(), and MatchesObjectSearch().

◆ registry_initialized_

bool yaze::editor::DungeonObjectSelector::registry_initialized_ = false
private

Definition at line 220 of file dungeon_object_selector.h.

Referenced by EnsureRegistryInitialized().

◆ enable_object_previews_

bool yaze::editor::DungeonObjectSelector::enable_object_previews_ = true
private

◆ preview_cache_

std::map<uint64_t, std::unique_ptr<gfx::BackgroundBuffer> > yaze::editor::DungeonObjectSelector::preview_cache_
private

Definition at line 228 of file dungeon_object_selector.h.

Referenced by GetOrCreatePreview(), and RetirePreviewCache().

◆ cached_preview_blockset_

uint8_t yaze::editor::DungeonObjectSelector::cached_preview_blockset_ = 0xFF
private

◆ cached_preview_entrance_blockset_

uint8_t yaze::editor::DungeonObjectSelector::cached_preview_entrance_blockset_ = 0xFF
private

Definition at line 230 of file dungeon_object_selector.h.

Referenced by SynchronizePreviewCacheRoomContext().

◆ cached_preview_palette_

uint8_t yaze::editor::DungeonObjectSelector::cached_preview_palette_ = 0xFF
private

◆ cached_preview_floor1_

uint8_t yaze::editor::DungeonObjectSelector::cached_preview_floor1_ = 0xFF
private

◆ cached_preview_floor2_

uint8_t yaze::editor::DungeonObjectSelector::cached_preview_floor2_ = 0xFF
private

◆ cached_preview_room_id_

int yaze::editor::DungeonObjectSelector::cached_preview_room_id_ = -1
private

Definition at line 234 of file dungeon_object_selector.h.

Referenced by SynchronizePreviewCacheRoomContext().

◆ cached_preview_graphics_revision_

uint64_t yaze::editor::DungeonObjectSelector::cached_preview_graphics_revision_ = 0
private

Definition at line 235 of file dungeon_object_selector.h.

Referenced by SynchronizePreviewCacheRoomContext().

◆ layout_cache_

std::map<uint32_t, zelda3::ObjectTileLayout> yaze::editor::DungeonObjectSelector::layout_cache_
private

Definition at line 237 of file dungeon_object_selector.h.

Referenced by DrawObjectAssetBrowser(), and InvalidatePreviewCache().

◆ preview_cache_invalidations_

std::size_t yaze::editor::DungeonObjectSelector::preview_cache_invalidations_ = 0
private

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