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)
 
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 set_current_palette_group_id (uint64_t id)
 
void SetCurrentPaletteGroup (const gfx::PaletteGroup &palette_group)
 
void SetCurrentPaletteId (uint64_t palette_id)
 
void SetCustomObjectsFolder (const std::string &folder)
 
void SetObjectSelectedCallback (std::function< void(const zelda3::RoomObject &)> callback)
 
void SetObjectDoubleClickCallback (std::function< void(int)> callback)
 
const zelda3::RoomObjectGetPreviewObject () const
 
bool IsObjectLoaded () const
 
void DrawObjectAssetBrowser ()
 
void SelectObject (int obj_id, int subtype=-1)
 
void SetTileEditorPanel (ObjectTileEditorPanel *panel)
 
void SetProject (project::YazeProject *project)
 
void InvalidatePreviewCache ()
 
void SetStaticEditorObjectId (int obj_id)
 
int GetStaticEditorObjectId () const
 

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, float size)
 
zelda3::RoomObject MakePreviewObject (int obj_id) const
 
void EnsureRegistryInitialized ()
 
ImU32 GetObjectTypeColor (int object_id)
 
std::string GetObjectTypeSymbol (int object_id)
 
void EnsureCustomObjectsInitialized ()
 
void DrawNewCustomObjectDialog ()
 
bool GetOrCreatePreview (const zelda3::RoomObject &object, float size, gfx::BackgroundBuffer **out)
 

Private Attributes

bool show_create_dialog_ = false
 
int create_width_ = 4
 
int create_height_ = 4
 
int create_object_id_ = 0x31
 
char create_filename_ [128] = {0}
 
ObjectTileEditorPaneltile_editor_panel_ = nullptr
 
project::YazeProjectproject_ = nullptr
 
Romrom_ = nullptr
 
zelda3::GameDatagame_data_ = nullptr
 
std::string custom_objects_folder_
 
bool custom_objects_initialized_ = false
 
DungeonRoomStorerooms_ = nullptr
 
int current_room_id_ = 0
 
uint64_t current_palette_group_id_ = 0
 
uint64_t current_palette_id_ = 0
 
gfx::PaletteGroup current_palette_group_
 
zelda3::DungeonObjectRegistry object_registry_
 
zelda3::RoomObject preview_object_ {0, 0, 0, 0, 0}
 
gfx::SnesPalette preview_palette_
 
bool object_loaded_ = false
 
std::function< void(const zelda3::RoomObject &) object_selected_callback_ )
 
std::function< void(int)> object_double_click_callback_
 
int selected_object_id_ = -1
 
int static_editor_object_id_ = -1
 
int object_type_filter_ = 0
 
int object_subtype_tab_ = 0
 
char object_search_buffer_ [64] = {0}
 
bool registry_initialized_ = false
 
bool enable_object_previews_ = false
 
std::map< uint64_t, std::unique_ptr< gfx::BackgroundBuffer > > preview_cache_
 
uint8_t cached_preview_blockset_ = 0xFF
 
uint8_t cached_preview_palette_ = 0xFF
 
int cached_preview_room_id_ = -1
 
std::map< uint32_t, zelda3::ObjectTileLayoutlayout_cache_
 

Detailed Description

Handles object selection, preview, and editing UI.

Definition at line 32 of file dungeon_object_selector.h.

Constructor & Destructor Documentation

◆ DungeonObjectSelector()

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

Definition at line 34 of file dungeon_object_selector.h.

Member Function Documentation

◆ SetContext()

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

◆ context()

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

Definition at line 41 of file dungeon_object_selector.h.

References game_data_, and rom_.

◆ SetRom()

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

Definition at line 44 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 45 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 46 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

◆ set_rooms()

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

Definition at line 50 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

◆ set_current_palette_group_id()

void yaze::editor::DungeonObjectSelector::set_current_palette_group_id ( uint64_t id)
inline

Definition at line 55 of file dungeon_object_selector.h.

References current_palette_group_id_.

◆ SetCurrentPaletteGroup()

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

◆ SetCurrentPaletteId()

void yaze::editor::DungeonObjectSelector::SetCurrentPaletteId ( uint64_t palette_id)
inline

Definition at line 61 of file dungeon_object_selector.h.

References current_palette_id_.

◆ SetCustomObjectsFolder()

void yaze::editor::DungeonObjectSelector::SetCustomObjectsFolder ( const std::string & folder)

◆ SetObjectSelectedCallback()

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

◆ SetObjectDoubleClickCallback()

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

◆ GetPreviewObject()

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

Definition at line 77 of file dungeon_object_selector.h.

References preview_object_.

◆ IsObjectLoaded()

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

Definition at line 78 of file dungeon_object_selector.h.

References object_loaded_.

◆ DrawObjectAssetBrowser()

◆ SelectObject()

◆ SetTileEditorPanel()

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

Definition at line 87 of file dungeon_object_selector.h.

References tile_editor_panel_.

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

◆ SetProject()

void yaze::editor::DungeonObjectSelector::SetProject ( project::YazeProject * project)
inline

Definition at line 90 of file dungeon_object_selector.h.

References project_.

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

◆ InvalidatePreviewCache()

void yaze::editor::DungeonObjectSelector::InvalidatePreviewCache ( )

◆ SetStaticEditorObjectId()

void yaze::editor::DungeonObjectSelector::SetStaticEditorObjectId ( int obj_id)
inline

◆ GetStaticEditorObjectId()

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

Definition at line 99 of file dungeon_object_selector.h.

References static_editor_object_id_.

◆ MatchesObjectFilter()

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

Definition at line 682 of file dungeon_object_selector.cc.

Referenced by DrawObjectAssetBrowser().

◆ MatchesObjectSearch()

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

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

bool yaze::editor::DungeonObjectSelector::DrawObjectPreview ( const zelda3::RoomObject & object,
ImVec2 top_left,
float size )
private

Definition at line 880 of file dungeon_object_selector.cc.

References yaze::gfx::BackgroundBuffer::bitmap(), and GetOrCreatePreview().

Referenced by DrawObjectAssetBrowser().

Here is the call graph for this function:

◆ MakePreviewObject()

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

Definition at line 776 of file dungeon_object_selector.cc.

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

Referenced by DrawObjectAssetBrowser().

Here is the call graph for this function:

◆ EnsureRegistryInitialized()

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

Definition at line 750 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 34 of file dungeon_object_selector.cc.

References 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 89 of file dungeon_object_selector.cc.

Referenced by DrawObjectAssetBrowser().

◆ EnsureCustomObjectsInitialized()

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

◆ DrawNewCustomObjectDialog()

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

◆ GetOrCreatePreview()

Member Data Documentation

◆ show_create_dialog_

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

Definition at line 117 of file dungeon_object_selector.h.

Referenced by DrawNewCustomObjectDialog(), and DrawObjectAssetBrowser().

◆ create_width_

int yaze::editor::DungeonObjectSelector::create_width_ = 4
private

Definition at line 118 of file dungeon_object_selector.h.

Referenced by DrawNewCustomObjectDialog().

◆ create_height_

int yaze::editor::DungeonObjectSelector::create_height_ = 4
private

Definition at line 119 of file dungeon_object_selector.h.

Referenced by DrawNewCustomObjectDialog().

◆ create_object_id_

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

Definition at line 120 of file dungeon_object_selector.h.

Referenced by DrawNewCustomObjectDialog(), and DrawObjectAssetBrowser().

◆ create_filename_

char yaze::editor::DungeonObjectSelector::create_filename_[128] = {0}
private

Definition at line 121 of file dungeon_object_selector.h.

Referenced by DrawNewCustomObjectDialog(), and DrawObjectAssetBrowser().

◆ tile_editor_panel_

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

◆ project_

project::YazeProject* yaze::editor::DungeonObjectSelector::project_ = nullptr
private

Definition at line 125 of file dungeon_object_selector.h.

Referenced by SetProject().

◆ rom_

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

◆ game_data_

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

◆ custom_objects_folder_

std::string yaze::editor::DungeonObjectSelector::custom_objects_folder_
private

◆ custom_objects_initialized_

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

◆ rooms_

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

◆ current_room_id_

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

◆ current_palette_group_id_

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

◆ current_palette_id_

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

Definition at line 138 of file dungeon_object_selector.h.

Referenced by SetCurrentPaletteId().

◆ 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 141 of file dungeon_object_selector.h.

Referenced by EnsureRegistryInitialized().

◆ preview_object_

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

◆ preview_palette_

gfx::SnesPalette yaze::editor::DungeonObjectSelector::preview_palette_
private

Definition at line 145 of file dungeon_object_selector.h.

Referenced by DrawObjectAssetBrowser(), and SelectObject().

◆ object_loaded_

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

Definition at line 146 of file dungeon_object_selector.h.

Referenced by DrawObjectAssetBrowser(), IsObjectLoaded(), and SelectObject().

◆ object_selected_callback_

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

◆ object_double_click_callback_

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

◆ selected_object_id_

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

Definition at line 153 of file dungeon_object_selector.h.

Referenced by DrawObjectAssetBrowser(), and SelectObject().

◆ static_editor_object_id_

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

◆ object_type_filter_

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

Definition at line 157 of file dungeon_object_selector.h.

Referenced by DrawObjectAssetBrowser().

◆ object_subtype_tab_

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

Definition at line 158 of file dungeon_object_selector.h.

◆ object_search_buffer_

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

Definition at line 159 of file dungeon_object_selector.h.

Referenced by DrawObjectAssetBrowser(), and MatchesObjectSearch().

◆ registry_initialized_

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

Definition at line 162 of file dungeon_object_selector.h.

Referenced by EnsureRegistryInitialized().

◆ enable_object_previews_

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

Definition at line 165 of file dungeon_object_selector.h.

Referenced by DrawObjectAssetBrowser().

◆ preview_cache_

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

Definition at line 170 of file dungeon_object_selector.h.

Referenced by GetOrCreatePreview(), and InvalidatePreviewCache().

◆ cached_preview_blockset_

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

Definition at line 171 of file dungeon_object_selector.h.

Referenced by GetOrCreatePreview().

◆ cached_preview_palette_

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

Definition at line 172 of file dungeon_object_selector.h.

Referenced by GetOrCreatePreview().

◆ cached_preview_room_id_

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

Definition at line 173 of file dungeon_object_selector.h.

Referenced by GetOrCreatePreview().

◆ layout_cache_

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

Definition at line 175 of file dungeon_object_selector.h.

Referenced by DrawObjectAssetBrowser(), and InvalidatePreviewCache().


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