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

Handles the main dungeon canvas rendering and interaction. More...

#include <dungeon_canvas_viewer.h>

Classes

struct  ObjectOutlineToggles
 
struct  ObjectRenderCache
 
struct  RoomLayerSettings
 

Public Member Functions

 DungeonCanvasViewer (Rom *rom=nullptr)
 
void DrawDungeonCanvas (int room_id)
 
void Draw (int room_id)
 
void SetRom (Rom *rom)
 
Romrom () const
 
void SetRooms (std::array< zelda3::Room, 0x128 > *rooms)
 
void set_active_rooms (const ImVector< int > &rooms)
 
void set_current_active_room_tab (int tab)
 
void set_current_palette_group_id (uint64_t id)
 
void SetCurrentPaletteId (uint64_t id)
 
void SetCurrentPaletteGroup (const gfx::PaletteGroup &group)
 
gui::Canvascanvas ()
 
const gui::Canvascanvas () const
 
DungeonObjectInteractionobject_interaction ()
 
void SetObjectInteractionEnabled (bool enabled)
 
bool IsObjectInteractionEnabled () const
 
void SetBG1Visible (int room_id, bool visible)
 
void SetBG2Visible (int room_id, bool visible)
 
bool IsBG1Visible (int room_id) const
 
bool IsBG2Visible (int room_id) const
 
void SetBG2LayerType (int room_id, int type)
 
int GetBG2LayerType (int room_id) const
 
void SetPreviewObject (const zelda3::RoomObject &object)
 
void ClearPreviewObject ()
 

Private Member Functions

void DisplayObjectInfo (const zelda3::RoomObject &object, int canvas_x, int canvas_y)
 
void RenderSprites (const zelda3::Room &room)
 
std::pair< int, int > RoomToCanvasCoordinates (int room_x, int room_y) const
 
std::pair< int, int > CanvasToRoomCoordinates (int canvas_x, int canvas_y) const
 
bool IsWithinCanvasBounds (int canvas_x, int canvas_y, int margin=32) const
 
void CalculateWallDimensions (const zelda3::RoomObject &object, int &width, int &height)
 
void DrawObjectPositionOutlines (const zelda3::Room &room)
 
absl::Status LoadAndRenderRoomGraphics (int room_id)
 
void DrawRoomBackgroundLayers (int room_id)
 
RoomLayerSettingsGetRoomLayerSettings (int room_id)
 

Private Attributes

Romrom_ = nullptr
 
gui::Canvas canvas_ {"##DungeonCanvas", ImVec2(0x200, 0x200)}
 
DungeonObjectInteraction object_interaction_
 
std::array< zelda3::Room, 0x128 > * rooms_ = nullptr
 
ImVector< int > active_rooms_
 
int current_active_room_tab_ = 0
 
bool object_interaction_enabled_ = true
 
std::map< int, RoomLayerSettingsroom_layer_settings_
 
uint64_t current_palette_group_id_ = 0
 
uint64_t current_palette_id_ = 0
 
gfx::PaletteGroup current_palette_group_
 
std::vector< ObjectRenderCacheobject_render_cache_
 
uint64_t last_palette_hash_ = 0
 
bool show_room_debug_info_ = false
 
bool show_texture_debug_ = false
 
bool show_object_bounds_ = false
 
bool show_layer_info_ = false
 
int layout_override_ = -1
 
ObjectOutlineToggles object_outline_toggles_
 

Detailed Description

Handles the main dungeon canvas rendering and interaction.

In Link to the Past, dungeon "layers" are not separate visual layers but a game concept where objects exist on different logical levels. Players move between these levels using stair objects that act as transitions between the different object planes.

Definition at line 24 of file dungeon_canvas_viewer.h.

Constructor & Destructor Documentation

◆ DungeonCanvasViewer()

yaze::editor::DungeonCanvasViewer::DungeonCanvasViewer ( Rom rom = nullptr)
inlineexplicit

Definition at line 26 of file dungeon_canvas_viewer.h.

Member Function Documentation

◆ DrawDungeonCanvas()

void yaze::editor::DungeonCanvasViewer::DrawDungeonCanvas ( int  room_id)
Todo:
Show object palette/selector

Definition at line 21 of file dungeon_canvas_viewer.cc.

References yaze::gui::Canvas::AddContextMenuItem(), yaze::gui::Canvas::ContextMenuItem::callback, canvas_, yaze::gui::Canvas::canvas_size(), yaze::editor::DungeonObjectInteraction::CheckForObjectSelection(), yaze::gui::Canvas::ClearContextMenuItems(), yaze::gui::Canvas::custom_step(), yaze::gui::Canvas::DrawBackground(), yaze::gui::Canvas::DrawContextMenu(), yaze::gui::Canvas::DrawGrid(), DrawObjectPositionOutlines(), yaze::gui::Canvas::DrawOverlay(), DrawRoomBackgroundLayers(), yaze::editor::DungeonObjectInteraction::DrawSelectBox(), yaze::editor::DungeonObjectInteraction::DrawSelectionHighlights(), yaze::gui::Canvas::DrawText(), yaze::gui::Canvas::ContextMenuItem::enabled_condition, yaze::gfx::Arena::Get(), GetRoomLayerSettings(), yaze::gui::Canvas::global_scale(), yaze::editor::DungeonObjectInteraction::HandleCanvasMouseInput(), yaze::editor::DungeonObjectInteraction::HandleDeleteSelected(), yaze::gui::Canvas::height(), ICON_MD_ADD, ICON_MD_BUG_REPORT, ICON_MD_CROP_SQUARE, ICON_MD_DELETE, ICON_MD_IMAGE, ICON_MD_INFO, ICON_MD_LAYERS, ICON_MD_PRINT, ICON_MD_REFRESH, yaze::gui::InputHexByte(), yaze::gui::InputHexWord(), yaze::Rom::is_loaded(), yaze::gui::k8x8, yaze::gui::Canvas::ContextMenuItem::label, layout_override_, LoadAndRenderRoomGraphics(), LOG_DEBUG, object_interaction_, object_interaction_enabled_, object_outline_toggles_, yaze::gfx::Arena::ProcessTextureQueue(), RenderSprites(), rom_, rooms_, yaze::gui::Canvas::SetCanvasSize(), yaze::editor::DungeonObjectInteraction::SetCurrentRoom(), yaze::gui::Canvas::SetGridSize(), yaze::editor::DungeonCanvasViewer::ObjectOutlineToggles::show_layer0_objects, yaze::editor::DungeonCanvasViewer::ObjectOutlineToggles::show_layer1_objects, yaze::editor::DungeonCanvasViewer::ObjectOutlineToggles::show_layer2_objects, show_layer_info_, show_object_bounds_, show_room_debug_info_, show_texture_debug_, yaze::editor::DungeonCanvasViewer::ObjectOutlineToggles::show_type1_objects, yaze::editor::DungeonCanvasViewer::ObjectOutlineToggles::show_type2_objects, yaze::editor::DungeonCanvasViewer::ObjectOutlineToggles::show_type3_objects, yaze::editor::DungeonObjectInteraction::ShowContextMenu(), yaze::gui::Canvas::ContextMenuItem::subitems, yaze::gui::Canvas::width(), and yaze::gui::Canvas::zero_point().

Referenced by Draw(), and yaze::editor::DungeonEditorV2::DrawRoomTab().

◆ Draw()

void yaze::editor::DungeonCanvasViewer::Draw ( int  room_id)

Definition at line 17 of file dungeon_canvas_viewer.cc.

References DrawDungeonCanvas().

Here is the call graph for this function:

◆ SetRom()

void yaze::editor::DungeonCanvasViewer::SetRom ( Rom rom)
inline

Definition at line 33 of file dungeon_canvas_viewer.h.

References rom(), and rom_.

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

Here is the call graph for this function:

◆ rom()

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

Definition at line 36 of file dungeon_canvas_viewer.h.

References rom_.

Referenced by SetRom().

◆ SetRooms()

void yaze::editor::DungeonCanvasViewer::SetRooms ( std::array< zelda3::Room, 0x128 > *  rooms)
inline

Definition at line 39 of file dungeon_canvas_viewer.h.

References rooms_.

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

◆ set_active_rooms()

void yaze::editor::DungeonCanvasViewer::set_active_rooms ( const ImVector< int > &  rooms)
inline

Definition at line 41 of file dungeon_canvas_viewer.h.

References active_rooms_.

◆ set_current_active_room_tab()

void yaze::editor::DungeonCanvasViewer::set_current_active_room_tab ( int  tab)
inline

Definition at line 42 of file dungeon_canvas_viewer.h.

References current_active_room_tab_.

◆ set_current_palette_group_id()

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

Definition at line 45 of file dungeon_canvas_viewer.h.

References current_palette_group_id_.

◆ SetCurrentPaletteId()

void yaze::editor::DungeonCanvasViewer::SetCurrentPaletteId ( uint64_t  id)
inline

Definition at line 46 of file dungeon_canvas_viewer.h.

References current_palette_id_.

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

◆ SetCurrentPaletteGroup()

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

Definition at line 47 of file dungeon_canvas_viewer.h.

References current_palette_group_.

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

◆ canvas() [1/2]

gui::Canvas & yaze::editor::DungeonCanvasViewer::canvas ( )
inline

Definition at line 50 of file dungeon_canvas_viewer.h.

References canvas_.

◆ canvas() [2/2]

const gui::Canvas & yaze::editor::DungeonCanvasViewer::canvas ( ) const
inline

Definition at line 51 of file dungeon_canvas_viewer.h.

References canvas_.

◆ object_interaction()

DungeonObjectInteraction & yaze::editor::DungeonCanvasViewer::object_interaction ( )
inline

◆ SetObjectInteractionEnabled()

void yaze::editor::DungeonCanvasViewer::SetObjectInteractionEnabled ( bool  enabled)
inline

◆ IsObjectInteractionEnabled()

bool yaze::editor::DungeonCanvasViewer::IsObjectInteractionEnabled ( ) const
inline

Definition at line 58 of file dungeon_canvas_viewer.h.

References object_interaction_enabled_.

◆ SetBG1Visible()

void yaze::editor::DungeonCanvasViewer::SetBG1Visible ( int  room_id,
bool  visible 
)
inline

Definition at line 61 of file dungeon_canvas_viewer.h.

References yaze::editor::DungeonCanvasViewer::RoomLayerSettings::bg1_visible, and GetRoomLayerSettings().

Here is the call graph for this function:

◆ SetBG2Visible()

void yaze::editor::DungeonCanvasViewer::SetBG2Visible ( int  room_id,
bool  visible 
)
inline

Definition at line 64 of file dungeon_canvas_viewer.h.

References yaze::editor::DungeonCanvasViewer::RoomLayerSettings::bg2_visible, and GetRoomLayerSettings().

Here is the call graph for this function:

◆ IsBG1Visible()

bool yaze::editor::DungeonCanvasViewer::IsBG1Visible ( int  room_id) const
inline

Definition at line 67 of file dungeon_canvas_viewer.h.

References room_layer_settings_.

◆ IsBG2Visible()

bool yaze::editor::DungeonCanvasViewer::IsBG2Visible ( int  room_id) const
inline

Definition at line 71 of file dungeon_canvas_viewer.h.

References room_layer_settings_.

◆ SetBG2LayerType()

void yaze::editor::DungeonCanvasViewer::SetBG2LayerType ( int  room_id,
int  type 
)
inline

Definition at line 77 of file dungeon_canvas_viewer.h.

References yaze::editor::DungeonCanvasViewer::RoomLayerSettings::bg2_layer_type, and GetRoomLayerSettings().

Here is the call graph for this function:

◆ GetBG2LayerType()

int yaze::editor::DungeonCanvasViewer::GetBG2LayerType ( int  room_id) const
inline

Definition at line 80 of file dungeon_canvas_viewer.h.

References room_layer_settings_.

◆ SetPreviewObject()

void yaze::editor::DungeonCanvasViewer::SetPreviewObject ( const zelda3::RoomObject object)
inline

◆ ClearPreviewObject()

void yaze::editor::DungeonCanvasViewer::ClearPreviewObject ( )
inline

◆ DisplayObjectInfo()

void yaze::editor::DungeonCanvasViewer::DisplayObjectInfo ( const zelda3::RoomObject object,
int  canvas_x,
int  canvas_y 
)
private

Definition at line 568 of file dungeon_canvas_viewer.cc.

References canvas_, and yaze::gui::Canvas::DrawText().

Here is the call graph for this function:

◆ RenderSprites()

void yaze::editor::DungeonCanvasViewer::RenderSprites ( const zelda3::Room room)
private

◆ RoomToCanvasCoordinates()

std::pair< int, int > yaze::editor::DungeonCanvasViewer::RoomToCanvasCoordinates ( int  room_x,
int  room_y 
) const
private

Definition at line 625 of file dungeon_canvas_viewer.cc.

Referenced by DrawObjectPositionOutlines(), and RenderSprites().

◆ CanvasToRoomCoordinates()

std::pair< int, int > yaze::editor::DungeonCanvasViewer::CanvasToRoomCoordinates ( int  canvas_x,
int  canvas_y 
) const
private

Definition at line 636 of file dungeon_canvas_viewer.cc.

References canvas_, and yaze::gui::Canvas::global_scale().

Here is the call graph for this function:

◆ IsWithinCanvasBounds()

bool yaze::editor::DungeonCanvasViewer::IsWithinCanvasBounds ( int  canvas_x,
int  canvas_y,
int  margin = 32 
) const
private

Definition at line 654 of file dungeon_canvas_viewer.cc.

References canvas_, yaze::gui::Canvas::height(), and yaze::gui::Canvas::width().

Referenced by RenderSprites().

Here is the call graph for this function:

◆ CalculateWallDimensions()

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

Definition at line 664 of file dungeon_canvas_viewer.cc.

◆ DrawObjectPositionOutlines()

◆ LoadAndRenderRoomGraphics()

absl::Status yaze::editor::DungeonCanvasViewer::LoadAndRenderRoomGraphics ( int  room_id)
private

◆ DrawRoomBackgroundLayers()

◆ GetRoomLayerSettings()

RoomLayerSettings & yaze::editor::DungeonCanvasViewer::GetRoomLayerSettings ( int  room_id)
inlineprivate

Member Data Documentation

◆ rom_

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

Definition at line 114 of file dungeon_canvas_viewer.h.

Referenced by DrawDungeonCanvas(), LoadAndRenderRoomGraphics(), rom(), and SetRom().

◆ canvas_

gui::Canvas yaze::editor::DungeonCanvasViewer::canvas_ {"##DungeonCanvas", ImVec2(0x200, 0x200)}
private

◆ object_interaction_

DungeonObjectInteraction yaze::editor::DungeonCanvasViewer::object_interaction_
private

◆ rooms_

std::array<zelda3::Room, 0x128>* yaze::editor::DungeonCanvasViewer::rooms_ = nullptr
private

◆ active_rooms_

ImVector<int> yaze::editor::DungeonCanvasViewer::active_rooms_
private

Definition at line 122 of file dungeon_canvas_viewer.h.

Referenced by set_active_rooms().

◆ current_active_room_tab_

int yaze::editor::DungeonCanvasViewer::current_active_room_tab_ = 0
private

Definition at line 123 of file dungeon_canvas_viewer.h.

Referenced by set_current_active_room_tab().

◆ object_interaction_enabled_

bool yaze::editor::DungeonCanvasViewer::object_interaction_enabled_ = true
private

◆ room_layer_settings_

std::map<int, RoomLayerSettings> yaze::editor::DungeonCanvasViewer::room_layer_settings_
private

◆ current_palette_group_id_

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

◆ current_palette_id_

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

Definition at line 143 of file dungeon_canvas_viewer.h.

Referenced by SetCurrentPaletteId().

◆ current_palette_group_

gfx::PaletteGroup yaze::editor::DungeonCanvasViewer::current_palette_group_
private

Definition at line 144 of file dungeon_canvas_viewer.h.

Referenced by LoadAndRenderRoomGraphics(), and SetCurrentPaletteGroup().

◆ object_render_cache_

std::vector<ObjectRenderCache> yaze::editor::DungeonCanvasViewer::object_render_cache_
private

Definition at line 154 of file dungeon_canvas_viewer.h.

◆ last_palette_hash_

uint64_t yaze::editor::DungeonCanvasViewer::last_palette_hash_ = 0
private

Definition at line 155 of file dungeon_canvas_viewer.h.

◆ show_room_debug_info_

bool yaze::editor::DungeonCanvasViewer::show_room_debug_info_ = false
private

Definition at line 158 of file dungeon_canvas_viewer.h.

Referenced by DrawDungeonCanvas().

◆ show_texture_debug_

bool yaze::editor::DungeonCanvasViewer::show_texture_debug_ = false
private

Definition at line 159 of file dungeon_canvas_viewer.h.

Referenced by DrawDungeonCanvas().

◆ show_object_bounds_

bool yaze::editor::DungeonCanvasViewer::show_object_bounds_ = false
private

Definition at line 160 of file dungeon_canvas_viewer.h.

Referenced by DrawDungeonCanvas().

◆ show_layer_info_

bool yaze::editor::DungeonCanvasViewer::show_layer_info_ = false
private

Definition at line 161 of file dungeon_canvas_viewer.h.

Referenced by DrawDungeonCanvas().

◆ layout_override_

int yaze::editor::DungeonCanvasViewer::layout_override_ = -1
private

Definition at line 162 of file dungeon_canvas_viewer.h.

Referenced by DrawDungeonCanvas().

◆ object_outline_toggles_

ObjectOutlineToggles yaze::editor::DungeonCanvasViewer::object_outline_toggles_
private

Definition at line 173 of file dungeon_canvas_viewer.h.

Referenced by DrawDungeonCanvas(), and DrawObjectPositionOutlines().


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