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

DungeonEditor class for editing dungeons. More...

#include <dungeon_editor.h>

Inheritance diagram for yaze::editor::DungeonEditor:

Public Member Functions

 DungeonEditor (Rom *rom=nullptr)
 
void Initialize () override
 
absl::Status Load () override
 
absl::Status Update () override
 
absl::Status Undo () override
 
absl::Status Redo () override
 
absl::Status Cut () override
 
absl::Status Copy () override
 
absl::Status Paste () override
 
absl::Status Find () override
 
absl::Status Save () override
 
void add_room (int i)
 
void set_rom (Rom *rom)
 
Romrom () const
 
- Public Member Functions inherited from yaze::editor::Editor
 Editor ()=default
 
virtual ~Editor ()=default
 
virtual absl::Status Clear ()
 
EditorType type () const
 
void set_context (EditorContext *context)
 
bool * active ()
 
void set_active (bool active)
 

Private Types

enum  BackgroundType {
  kNoBackground , kBackground1 , kBackground2 , kBackground3 ,
  kBackgroundAny
}
 
enum  PlacementType {
  kNoType , kSprite , kItem , kDoor ,
  kBlock
}
 

Private Member Functions

absl::Status RefreshGraphics ()
 
void LoadDungeonRoomSize ()
 
absl::Status UpdateDungeonRoomView ()
 
void DrawToolset ()
 
void DrawRoomSelector ()
 
void DrawEntranceSelector ()
 
void DrawDungeonTabView ()
 
void DrawDungeonCanvas (int room_id)
 
void DrawRoomGraphics ()
 
void DrawTileSelector ()
 
void DrawObjectRenderer ()
 
void CalculateUsageStats ()
 
void DrawUsageStats ()
 
void DrawUsageGrid ()
 
void RenderSetUsage (const absl::flat_hash_map< uint16_t, int > &usage_map, uint16_t &selected_set, int spriteset_offset=0x00)
 

Private Attributes

int background_type_ = kNoBackground
 
int placement_type_ = kNoType
 
bool is_loaded_ = false
 
bool object_loaded_ = false
 
bool palette_showing_ = false
 
bool refresh_graphics_ = false
 
uint16_t current_entrance_id_ = 0
 
uint16_t current_room_id_ = 0
 
uint64_t current_palette_id_ = 0
 
uint64_t current_palette_group_id_ = 0
 
ImVector< int > active_rooms_
 
GfxGroupEditor gfx_group_editor_
 
PaletteEditor palette_editor_
 
gfx::SnesPalette current_palette_
 
gfx::SnesPalette full_palette_
 
gfx::PaletteGroup current_palette_group_
 
gui::Canvas canvas_ {"##DungeonCanvas", ImVec2(0x200, 0x200)}
 
gui::Canvas room_gfx_canvas_
 
gui::Canvas object_canvas_
 
std::array< gfx::Bitmap, kNumGfxSheetsgraphics_bin_
 
std::array< zelda3::Room, 0x128 > rooms_ = {}
 
std::array< zelda3::RoomEntrance, 0x8C > entrances_ = {}
 
absl::flat_hash_map< uint16_t, int > spriteset_usage_
 
absl::flat_hash_map< uint16_t, int > blockset_usage_
 
absl::flat_hash_map< uint16_t, int > palette_usage_
 
std::vector< int64_t > room_size_pointers_
 
std::vector< int64_t > room_sizes_
 
uint16_t selected_blockset_ = 0xFFFF
 
uint16_t selected_spriteset_ = 0xFFFF
 
uint16_t selected_palette_ = 0xFFFF
 
uint64_t total_room_size_ = 0
 
std::unordered_map< int, int > room_size_addresses_
 
std::unordered_map< int, ImVec4 > room_palette_
 
absl::Status status_
 
Romrom_
 

Additional Inherited Members

- Protected Attributes inherited from yaze::editor::Editor
bool active_ = false
 
EditorType type_
 
EditorContextcontext_ = nullptr
 

Detailed Description

DungeonEditor class for editing dungeons.

This class is currently a work in progress and is used for editing dungeons. It provides various functions for updating, cutting, copying, pasting, undoing, and redoing. It also includes methods for drawing the toolset, room selector, entrance selector, dungeon tab view, dungeon canvas, room graphics, tile selector, and object renderer. Additionally, it handles loading room entrances, calculating usage statistics, and rendering set usage.

Definition at line 41 of file dungeon_editor.h.

Member Enumeration Documentation

◆ BackgroundType

Enumerator
kNoBackground 
kBackground1 
kBackground2 
kBackground3 
kBackgroundAny 

Definition at line 87 of file dungeon_editor.h.

◆ PlacementType

Enumerator
kNoType 
kSprite 
kItem 
kDoor 
kBlock 

Definition at line 94 of file dungeon_editor.h.

Constructor & Destructor Documentation

◆ DungeonEditor()

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

Definition at line 43 of file dungeon_editor.h.

References yaze::editor::kDungeon, rom(), rom_, and yaze::editor::Editor::type_.

Here is the call graph for this function:

Member Function Documentation

◆ Initialize()

void yaze::editor::DungeonEditor::Initialize ( )
overridevirtual

Implements yaze::editor::Editor.

Definition at line 43 of file dungeon_editor.cc.

◆ Load()

◆ Update()

absl::Status yaze::editor::DungeonEditor::Update ( )
overridevirtual

Implements yaze::editor::Editor.

Definition at line 90 of file dungeon_editor.cc.

References DrawUsageStats(), is_loaded_, refresh_graphics_, RefreshGraphics(), RETURN_IF_ERROR, status_, and UpdateDungeonRoomView().

Here is the call graph for this function:

◆ Undo()

absl::Status yaze::editor::DungeonEditor::Undo ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 50 of file dungeon_editor.h.

Referenced by DrawToolset().

◆ Redo()

absl::Status yaze::editor::DungeonEditor::Redo ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 51 of file dungeon_editor.h.

Referenced by DrawToolset().

◆ Cut()

absl::Status yaze::editor::DungeonEditor::Cut ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 52 of file dungeon_editor.h.

◆ Copy()

absl::Status yaze::editor::DungeonEditor::Copy ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 53 of file dungeon_editor.h.

◆ Paste()

absl::Status yaze::editor::DungeonEditor::Paste ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 54 of file dungeon_editor.h.

◆ Find()

absl::Status yaze::editor::DungeonEditor::Find ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 55 of file dungeon_editor.h.

◆ Save()

absl::Status yaze::editor::DungeonEditor::Save ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 56 of file dungeon_editor.h.

◆ add_room()

void yaze::editor::DungeonEditor::add_room ( int i)
inline

Definition at line 58 of file dungeon_editor.h.

References active_rooms_.

◆ set_rom()

void yaze::editor::DungeonEditor::set_rom ( Rom * rom)
inline

Definition at line 60 of file dungeon_editor.h.

References rom(), and rom_.

Here is the call graph for this function:

◆ rom()

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

◆ RefreshGraphics()

◆ LoadDungeonRoomSize()

void yaze::editor::DungeonEditor::LoadDungeonRoomSize ( )
private

Definition at line 137 of file dungeon_editor.cc.

References room_size_addresses_, room_sizes_, and total_room_size_.

Referenced by Load().

◆ UpdateDungeonRoomView()

◆ DrawToolset()

◆ DrawRoomSelector()

◆ DrawEntranceSelector()

◆ DrawDungeonTabView()

void yaze::editor::DungeonEditor::DrawDungeonTabView ( )
private

◆ DrawDungeonCanvas()

void yaze::editor::DungeonEditor::DrawDungeonCanvas ( int room_id)
private

Definition at line 453 of file dungeon_editor.cc.

References canvas_, yaze::gfx::Arena::Get(), yaze::gui::InputHexByte(), yaze::gui::InputHexWord(), is_loaded_, and rooms_.

Referenced by DrawDungeonTabView().

Here is the call graph for this function:

◆ DrawRoomGraphics()

void yaze::editor::DungeonEditor::DrawRoomGraphics ( )
private

Definition at line 503 of file dungeon_editor.cc.

References current_room_id_, yaze::gfx::Arena::Get(), is_loaded_, room_gfx_canvas_, and rooms_.

Referenced by DrawTileSelector().

Here is the call graph for this function:

◆ DrawTileSelector()

void yaze::editor::DungeonEditor::DrawTileSelector ( )
private

Definition at line 531 of file dungeon_editor.cc.

References DrawObjectRenderer(), and DrawRoomGraphics().

Referenced by UpdateDungeonRoomView().

Here is the call graph for this function:

◆ DrawObjectRenderer()

void yaze::editor::DungeonEditor::DrawObjectRenderer ( )
private

◆ CalculateUsageStats()

void yaze::editor::DungeonEditor::CalculateUsageStats ( )
private

Definition at line 598 of file dungeon_editor.cc.

References blockset_usage_, palette_usage_, rooms_, and spriteset_usage_.

Referenced by DrawUsageStats(), and Load().

◆ DrawUsageStats()

void yaze::editor::DungeonEditor::DrawUsageStats ( )
private

◆ DrawUsageGrid()

void yaze::editor::DungeonEditor::DrawUsageGrid ( )
private

◆ RenderSetUsage()

void yaze::editor::DungeonEditor::RenderSetUsage ( const absl::flat_hash_map< uint16_t, int > & usage_map,
uint16_t & selected_set,
int spriteset_offset = 0x00 )
private

Definition at line 620 of file dungeon_editor.cc.

Referenced by DrawUsageStats().

Member Data Documentation

◆ background_type_

int yaze::editor::DungeonEditor::background_type_ = kNoBackground
private

Definition at line 96 of file dungeon_editor.h.

Referenced by DrawToolset().

◆ placement_type_

int yaze::editor::DungeonEditor::placement_type_ = kNoType
private

Definition at line 97 of file dungeon_editor.h.

Referenced by DrawToolset().

◆ is_loaded_

bool yaze::editor::DungeonEditor::is_loaded_ = false
private

Definition at line 99 of file dungeon_editor.h.

Referenced by DrawDungeonCanvas(), DrawRoomGraphics(), Load(), and Update().

◆ object_loaded_

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

Definition at line 100 of file dungeon_editor.h.

Referenced by DrawObjectRenderer().

◆ palette_showing_

bool yaze::editor::DungeonEditor::palette_showing_ = false
private

Definition at line 101 of file dungeon_editor.h.

Referenced by DrawToolset(), and UpdateDungeonRoomView().

◆ refresh_graphics_

bool yaze::editor::DungeonEditor::refresh_graphics_ = false
private

Definition at line 102 of file dungeon_editor.h.

Referenced by Update(), and UpdateDungeonRoomView().

◆ current_entrance_id_

uint16_t yaze::editor::DungeonEditor::current_entrance_id_ = 0
private

Definition at line 104 of file dungeon_editor.h.

Referenced by DrawEntranceSelector().

◆ current_room_id_

uint16_t yaze::editor::DungeonEditor::current_room_id_ = 0
private

◆ current_palette_id_

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

Definition at line 106 of file dungeon_editor.h.

Referenced by DrawRoomSelector(), RefreshGraphics(), and UpdateDungeonRoomView().

◆ current_palette_group_id_

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

Definition at line 107 of file dungeon_editor.h.

Referenced by Load(), and UpdateDungeonRoomView().

◆ active_rooms_

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

◆ gfx_group_editor_

GfxGroupEditor yaze::editor::DungeonEditor::gfx_group_editor_
private

Definition at line 111 of file dungeon_editor.h.

Referenced by DrawUsageStats().

◆ palette_editor_

PaletteEditor yaze::editor::DungeonEditor::palette_editor_
private

Definition at line 112 of file dungeon_editor.h.

◆ current_palette_

gfx::SnesPalette yaze::editor::DungeonEditor::current_palette_
private

Definition at line 113 of file dungeon_editor.h.

Referenced by UpdateDungeonRoomView().

◆ full_palette_

gfx::SnesPalette yaze::editor::DungeonEditor::full_palette_
private

Definition at line 114 of file dungeon_editor.h.

Referenced by Load().

◆ current_palette_group_

gfx::PaletteGroup yaze::editor::DungeonEditor::current_palette_group_
private

Definition at line 115 of file dungeon_editor.h.

Referenced by Load(), and RefreshGraphics().

◆ canvas_

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

Definition at line 117 of file dungeon_editor.h.

Referenced by DrawDungeonCanvas().

◆ room_gfx_canvas_

gui::Canvas yaze::editor::DungeonEditor::room_gfx_canvas_
private
Initial value:
{"##RoomGfxCanvas",
ImVec2(0x100 + 1, 0x10 * 0x40 + 1)}

Definition at line 118 of file dungeon_editor.h.

Referenced by DrawRoomGraphics().

◆ object_canvas_

gui::Canvas yaze::editor::DungeonEditor::object_canvas_
private

Definition at line 120 of file dungeon_editor.h.

Referenced by DrawObjectRenderer().

◆ graphics_bin_

std::array<gfx::Bitmap, kNumGfxSheets> yaze::editor::DungeonEditor::graphics_bin_
private

Definition at line 122 of file dungeon_editor.h.

◆ rooms_

std::array<zelda3::Room, 0x128> yaze::editor::DungeonEditor::rooms_ = {}
private

◆ entrances_

std::array<zelda3::RoomEntrance, 0x8C> yaze::editor::DungeonEditor::entrances_ = {}
private

Definition at line 125 of file dungeon_editor.h.

Referenced by DrawEntranceSelector(), and Load().

◆ spriteset_usage_

absl::flat_hash_map<uint16_t, int> yaze::editor::DungeonEditor::spriteset_usage_
private

Definition at line 128 of file dungeon_editor.h.

Referenced by CalculateUsageStats(), and DrawUsageStats().

◆ blockset_usage_

absl::flat_hash_map<uint16_t, int> yaze::editor::DungeonEditor::blockset_usage_
private

Definition at line 129 of file dungeon_editor.h.

Referenced by CalculateUsageStats(), and DrawUsageStats().

◆ palette_usage_

absl::flat_hash_map<uint16_t, int> yaze::editor::DungeonEditor::palette_usage_
private

Definition at line 130 of file dungeon_editor.h.

Referenced by CalculateUsageStats(), and DrawUsageStats().

◆ room_size_pointers_

std::vector<int64_t> yaze::editor::DungeonEditor::room_size_pointers_
private

Definition at line 132 of file dungeon_editor.h.

Referenced by DrawUsageGrid(), and Load().

◆ room_sizes_

std::vector<int64_t> yaze::editor::DungeonEditor::room_sizes_
private

Definition at line 133 of file dungeon_editor.h.

Referenced by DrawUsageGrid(), Load(), and LoadDungeonRoomSize().

◆ selected_blockset_

uint16_t yaze::editor::DungeonEditor::selected_blockset_ = 0xFFFF
private

Definition at line 135 of file dungeon_editor.h.

Referenced by DrawUsageGrid(), and DrawUsageStats().

◆ selected_spriteset_

uint16_t yaze::editor::DungeonEditor::selected_spriteset_ = 0xFFFF
private

Definition at line 136 of file dungeon_editor.h.

Referenced by DrawUsageGrid(), and DrawUsageStats().

◆ selected_palette_

uint16_t yaze::editor::DungeonEditor::selected_palette_ = 0xFFFF
private

Definition at line 137 of file dungeon_editor.h.

Referenced by DrawUsageGrid(), and DrawUsageStats().

◆ total_room_size_

uint64_t yaze::editor::DungeonEditor::total_room_size_ = 0
private

Definition at line 139 of file dungeon_editor.h.

Referenced by DrawUsageStats(), and LoadDungeonRoomSize().

◆ room_size_addresses_

std::unordered_map<int, int> yaze::editor::DungeonEditor::room_size_addresses_
private

Definition at line 141 of file dungeon_editor.h.

Referenced by Load(), and LoadDungeonRoomSize().

◆ room_palette_

std::unordered_map<int, ImVec4> yaze::editor::DungeonEditor::room_palette_
private

Definition at line 142 of file dungeon_editor.h.

Referenced by DrawUsageGrid(), and Load().

◆ status_

absl::Status yaze::editor::DungeonEditor::status_
private

Definition at line 144 of file dungeon_editor.h.

Referenced by Update().

◆ rom_

Rom* yaze::editor::DungeonEditor::rom_
private

Definition at line 146 of file dungeon_editor.h.

Referenced by DungeonEditor(), Load(), rom(), and set_rom().


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