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

The ScreenEditor class allows the user to edit a variety of screens in the game or create a custom menu. More...

#include <screen_editor.h>

Inheritance diagram for yaze::editor::ScreenEditor:

Public Member Functions

 ScreenEditor (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 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)
 
virtual bool IsRomLoaded () const
 
virtual std::string GetRomStatus () const
 

Public Attributes

std::vector< zelda3::DungeonMapdungeon_maps_
 

Private Types

enum class  EditingMode { DRAW , EDIT }
 

Private Member Functions

void DrawTitleScreenEditor ()
 
void DrawNamingScreenEditor ()
 
void DrawOverworldMapEditor ()
 
void DrawInventoryMenuEditor ()
 
void DrawToolset ()
 
void DrawDungeonMapToolset ()
 
void DrawInventoryToolset ()
 
absl::Status LoadDungeonMapTile16 (const std::vector< uint8_t > &gfx_data, bool bin_mode=false)
 
absl::Status SaveDungeonMapTile16 ()
 
void DrawDungeonMapScreen (int i)
 
void DrawDungeonMapsTabs ()
 
void DrawDungeonMapsEditor ()
 Draw dungeon maps editor with enhanced ROM hacking features.
 
void DrawDungeonMapsRoomGfx ()
 Draw dungeon room graphics editor with enhanced tile16 editing.
 
void LoadBinaryGfx ()
 

Private Attributes

EditingMode current_mode_ = EditingMode::DRAW
 
bool show_dungeon_maps_ = false
 
bool show_inventory_menu_ = false
 
bool show_overworld_map_ = false
 
bool show_title_screen_ = false
 
bool show_naming_screen_ = false
 
bool binary_gfx_loaded_ = false
 
uint8_t selected_room = 0
 
int selected_tile16_ = 0
 
int selected_tile8_ = 0
 
int selected_dungeon = 0
 
int floor_number = 1
 
bool copy_button_pressed = false
 
bool paste_button_pressed = false
 
std::vector< gfx::Bitmaptile8_individual_
 
zelda3::DungeonMapLabels dungeon_map_labels_
 
gfx::SnesPalette palette_
 
gfx::BitmapTable sheets_
 
gfx::Tilemap tile16_blockset_
 
std::array< gfx::TileInfo, 4 > current_tile16_info
 
gui::Canvas current_tile_canvas_
 
gui::Canvas screen_canvas_
 
gui::Canvas tilesheet_canvas_
 
gui::Canvas tilemap_canvas_
 
zelda3::Inventory inventory_
 
Romrom_
 
absl::Status status_
 

Additional Inherited Members

- Protected Member Functions inherited from yaze::editor::Editor
std::string MakeCardTitle (const std::string &base_title) const
 
template<typename T >
absl::StatusOr< T > SafeRomAccess (std::function< T()> accessor, const std::string &operation="") const
 
- Protected Attributes inherited from yaze::editor::Editor
bool active_ = false
 
EditorType type_
 
EditorContextcontext_ = nullptr
 

Detailed Description

The ScreenEditor class allows the user to edit a variety of screens in the game or create a custom menu.

This class is currently a work in progress (WIP) and provides functionality for updating the screens, saving dungeon maps, drawing different types of screens, loading dungeon maps, and managing various properties related to the editor.

The screens that can be edited include the title screen, naming screen, overworld map, inventory menu, and more.

Definition at line 34 of file screen_editor.h.

Member Enumeration Documentation

◆ EditingMode

enum class yaze::editor::ScreenEditor::EditingMode
strongprivate
Enumerator
DRAW 
EDIT 

Definition at line 77 of file screen_editor.h.

Constructor & Destructor Documentation

◆ ScreenEditor()

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

Definition at line 36 of file screen_editor.h.

References yaze::editor::kScreen, screen_canvas_, yaze::gui::Canvas::SetCanvasSize(), and yaze::editor::Editor::type_.

Here is the call graph for this function:

Member Function Documentation

◆ Initialize()

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

◆ Load()

absl::Status yaze::editor::ScreenEditor::Load ( )
overridevirtual
Todo:
Load roomset gfx based on dungeon ID

int current_tile8 = 0; int tile_data_offset = 0; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 32; j++) { std::vector<uint8_t> tile_data(64, 0); // 8x8 tile (64 bytes int tile_index = current_tile8 + j; int x = (j % 8) * 8; int y = (j / 8) * 8; sheets_[i].Get8x8Tile(tile_index, x, y, tile_data, tile_data_offset); tile8_individual_.emplace_back(gfx::Bitmap(8, 8, 4, tile_data)); tile8_individual_.back().SetPalette(*rom()->mutable_dungeon_palette(3)); Queue texture creation via Arena's deferred system gfx::Arena::Get().QueueTextureCommand( gfx::Arena::TextureCommandType::CREATE, &tile8_individual_.back()); } tile_data_offset = 0; }

Implements yaze::editor::Editor.

Definition at line 87 of file screen_editor.cc.

References ASSIGN_OR_RETURN, dungeon_map_labels_, dungeon_maps_, yaze::gfx::Arena::Get(), yaze::zelda3::LoadDungeonMaps(), yaze::zelda3::LoadDungeonMapTile16(), RETURN_IF_ERROR, rom(), sheets_, and tile16_blockset_.

Referenced by yaze::editor::EditorManager::LoadAssets().

Here is the call graph for this function:

◆ Update()

◆ Undo()

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

Implements yaze::editor::Editor.

Definition at line 44 of file screen_editor.h.

◆ Redo()

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

Implements yaze::editor::Editor.

Definition at line 45 of file screen_editor.h.

◆ Cut()

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

Implements yaze::editor::Editor.

Definition at line 46 of file screen_editor.h.

◆ Copy()

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

Implements yaze::editor::Editor.

Definition at line 47 of file screen_editor.h.

◆ Paste()

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

Implements yaze::editor::Editor.

Definition at line 48 of file screen_editor.h.

◆ Find()

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

Implements yaze::editor::Editor.

Definition at line 49 of file screen_editor.h.

◆ Save()

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

Implements yaze::editor::Editor.

Definition at line 50 of file screen_editor.h.

◆ set_rom()

void yaze::editor::ScreenEditor::set_rom ( Rom rom)
inline

Definition at line 51 of file screen_editor.h.

References rom(), and rom_.

Here is the call graph for this function:

◆ rom()

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

◆ DrawTitleScreenEditor()

void yaze::editor::ScreenEditor::DrawTitleScreenEditor ( )
private

Definition at line 617 of file screen_editor.cc.

Referenced by Update().

◆ DrawNamingScreenEditor()

void yaze::editor::ScreenEditor::DrawNamingScreenEditor ( )
private

Definition at line 620 of file screen_editor.cc.

Referenced by Update().

◆ DrawOverworldMapEditor()

void yaze::editor::ScreenEditor::DrawOverworldMapEditor ( )
private

Definition at line 623 of file screen_editor.cc.

Referenced by Update().

◆ DrawInventoryMenuEditor()

◆ DrawToolset()

◆ DrawDungeonMapToolset()

void yaze::editor::ScreenEditor::DrawDungeonMapToolset ( )
private

Definition at line 626 of file screen_editor.cc.

◆ DrawInventoryToolset()

void yaze::editor::ScreenEditor::DrawInventoryToolset ( )
private

◆ LoadDungeonMapTile16()

absl::Status yaze::editor::ScreenEditor::LoadDungeonMapTile16 ( const std::vector< uint8_t > &  gfx_data,
bool  bin_mode = false 
)
private

◆ SaveDungeonMapTile16()

absl::Status yaze::editor::ScreenEditor::SaveDungeonMapTile16 ( )
private

◆ DrawDungeonMapScreen()

◆ DrawDungeonMapsTabs()

void yaze::editor::ScreenEditor::DrawDungeonMapsTabs ( )
private

◆ DrawDungeonMapsEditor()

void yaze::editor::ScreenEditor::DrawDungeonMapsEditor ( )
private

Draw dungeon maps editor with enhanced ROM hacking features.

Enhanced Features:

  • Multi-mode editing (DRAW, EDIT, SELECT)
  • Real-time tile16 preview and editing
  • Floor/basement management for complex dungeons
  • Copy/paste operations for floor layouts
  • Integration with ROM tile16 data

Performance Notes:

  • Lazy loading of dungeon graphics
  • Cached tile16 rendering for fast updates
  • Batch operations for multiple tile changes
  • Efficient memory management for large dungeons

Definition at line 517 of file screen_editor.cc.

References current_mode_, DRAW, yaze::gui::Canvas::DrawBackground(), yaze::gui::Canvas::DrawBitmapTable(), yaze::gui::Canvas::DrawContextMenu(), DrawDungeonMapsRoomGfx(), DrawDungeonMapsTabs(), yaze::gui::Canvas::DrawGrid(), yaze::gui::Canvas::DrawOverlay(), yaze::gui::Canvas::DrawTileSelector(), EDIT, yaze::gui::Canvas::GetTileIdFromMousePos(), ICON_MD_DRAW, ICON_MD_EDIT, ICON_MD_SAVE, LoadBinaryGfx(), PRINT_IF_ERROR, yaze::Rom::resource_label(), rom(), yaze::zelda3::SaveDungeonMapTile16(), yaze::core::ResourceLabelManager::SelectableLabelWithNameEdit(), selected_dungeon, selected_tile8_, sheets_, tile16_blockset_, and tilemap_canvas_.

Referenced by Update().

◆ DrawDungeonMapsRoomGfx()

void yaze::editor::ScreenEditor::DrawDungeonMapsRoomGfx ( )
private

Draw dungeon room graphics editor with enhanced tile16 editing.

Enhanced Features:

  • Interactive tile16 selector with visual feedback
  • Real-time tile16 composition from 4x 8x8 tiles
  • Tile metadata editing (mirroring, palette, etc.)
  • Integration with ROM graphics buffer
  • Undo/redo support for tile modifications

Performance Notes:

  • Cached tile16 rendering to avoid repeated composition
  • Efficient tile selector with grid-based snapping
  • Batch tile updates to minimize ROM writes
  • Lazy loading of tile graphics data

Definition at line 427 of file screen_editor.cc.

References yaze::gfx::Tilemap::atlas, yaze::gfx::Arena::CREATE, current_tile16_info, current_tile_canvas_, yaze::gui::Canvas::DrawBackground(), yaze::gui::Canvas::DrawBitmap(), yaze::gui::Canvas::DrawContextMenu(), yaze::gui::Canvas::DrawGrid(), yaze::gui::Canvas::DrawOverlay(), yaze::gui::Canvas::DrawTilePainter(), yaze::gui::Canvas::DrawTileSelector(), dungeon_maps_, floor_number, yaze::gfx::Arena::Get(), yaze::gfx::TileCache::GetTile(), yaze::gui::InputTileInfo(), yaze::gfx::ModifyTile16(), yaze::gui::Canvas::mutable_points(), yaze::gui::Canvas::points(), yaze::gfx::Arena::QueueTextureCommand(), yaze::gfx::RenderTile16(), rom(), screen_canvas_, selected_dungeon, selected_room, selected_tile16_, selected_tile8_, tile16_blockset_, tile8_individual_, yaze::gfx::Tilemap::tile_cache, yaze::gfx::Tilemap::tile_info, tilesheet_canvas_, and yaze::gfx::UpdateTile16().

Referenced by DrawDungeonMapsEditor().

◆ LoadBinaryGfx()

Member Data Documentation

◆ dungeon_maps_

◆ current_mode_

EditingMode yaze::editor::ScreenEditor::current_mode_ = EditingMode::DRAW
private

Definition at line 79 of file screen_editor.h.

Referenced by DrawDungeonMapsEditor(), and DrawInventoryToolset().

◆ show_dungeon_maps_

bool yaze::editor::ScreenEditor::show_dungeon_maps_ = false
private

Definition at line 83 of file screen_editor.h.

Referenced by DrawToolset(), Initialize(), and Update().

◆ show_inventory_menu_

bool yaze::editor::ScreenEditor::show_inventory_menu_ = false
private

Definition at line 84 of file screen_editor.h.

Referenced by DrawToolset(), Initialize(), and Update().

◆ show_overworld_map_

bool yaze::editor::ScreenEditor::show_overworld_map_ = false
private

Definition at line 85 of file screen_editor.h.

Referenced by DrawToolset(), Initialize(), and Update().

◆ show_title_screen_

bool yaze::editor::ScreenEditor::show_title_screen_ = false
private

Definition at line 86 of file screen_editor.h.

Referenced by DrawToolset(), Initialize(), and Update().

◆ show_naming_screen_

bool yaze::editor::ScreenEditor::show_naming_screen_ = false
private

Definition at line 87 of file screen_editor.h.

Referenced by DrawToolset(), Initialize(), and Update().

◆ binary_gfx_loaded_

bool yaze::editor::ScreenEditor::binary_gfx_loaded_ = false
private

Definition at line 89 of file screen_editor.h.

Referenced by LoadBinaryGfx().

◆ selected_room

uint8_t yaze::editor::ScreenEditor::selected_room = 0
private

◆ selected_tile16_

int yaze::editor::ScreenEditor::selected_tile16_ = 0
private

Definition at line 93 of file screen_editor.h.

Referenced by DrawDungeonMapsRoomGfx().

◆ selected_tile8_

int yaze::editor::ScreenEditor::selected_tile8_ = 0
private

Definition at line 94 of file screen_editor.h.

Referenced by DrawDungeonMapsEditor(), and DrawDungeonMapsRoomGfx().

◆ selected_dungeon

int yaze::editor::ScreenEditor::selected_dungeon = 0
private

◆ floor_number

int yaze::editor::ScreenEditor::floor_number = 1
private

◆ copy_button_pressed

bool yaze::editor::ScreenEditor::copy_button_pressed = false
private

Definition at line 98 of file screen_editor.h.

Referenced by DrawDungeonMapsTabs().

◆ paste_button_pressed

bool yaze::editor::ScreenEditor::paste_button_pressed = false
private

Definition at line 99 of file screen_editor.h.

Referenced by DrawDungeonMapsTabs().

◆ tile8_individual_

std::vector<gfx::Bitmap> yaze::editor::ScreenEditor::tile8_individual_
private

Definition at line 101 of file screen_editor.h.

Referenced by DrawDungeonMapsRoomGfx().

◆ dungeon_map_labels_

zelda3::DungeonMapLabels yaze::editor::ScreenEditor::dungeon_map_labels_
private

Definition at line 102 of file screen_editor.h.

Referenced by DrawDungeonMapScreen(), DrawDungeonMapsTabs(), and Load().

◆ palette_

gfx::SnesPalette yaze::editor::ScreenEditor::palette_
private

Definition at line 104 of file screen_editor.h.

Referenced by DrawInventoryMenuEditor().

◆ sheets_

gfx::BitmapTable yaze::editor::ScreenEditor::sheets_
private

Definition at line 105 of file screen_editor.h.

Referenced by DrawDungeonMapsEditor(), Load(), and LoadBinaryGfx().

◆ tile16_blockset_

gfx::Tilemap yaze::editor::ScreenEditor::tile16_blockset_
private

◆ current_tile16_info

std::array<gfx::TileInfo, 4> yaze::editor::ScreenEditor::current_tile16_info
private

Definition at line 107 of file screen_editor.h.

Referenced by DrawDungeonMapsRoomGfx().

◆ current_tile_canvas_

gui::Canvas yaze::editor::ScreenEditor::current_tile_canvas_
private
Initial value:
{"##CurrentTileCanvas", ImVec2(32, 32),

Definition at line 109 of file screen_editor.h.

Referenced by DrawDungeonMapsRoomGfx().

◆ screen_canvas_

gui::Canvas yaze::editor::ScreenEditor::screen_canvas_
private

◆ tilesheet_canvas_

gui::Canvas yaze::editor::ScreenEditor::tilesheet_canvas_
private

Definition at line 112 of file screen_editor.h.

Referenced by DrawDungeonMapsRoomGfx(), and DrawInventoryMenuEditor().

◆ tilemap_canvas_

gui::Canvas yaze::editor::ScreenEditor::tilemap_canvas_
private
Initial value:
{"##TilemapCanvas", ImVec2(128 + 2, (192) + 4),

Definition at line 113 of file screen_editor.h.

Referenced by DrawDungeonMapsEditor().

◆ inventory_

zelda3::Inventory yaze::editor::ScreenEditor::inventory_
private

Definition at line 116 of file screen_editor.h.

Referenced by DrawInventoryMenuEditor().

◆ rom_

Rom* yaze::editor::ScreenEditor::rom_
private

Definition at line 117 of file screen_editor.h.

Referenced by rom(), and set_rom().

◆ status_

absl::Status yaze::editor::ScreenEditor::status_
private

Definition at line 118 of file screen_editor.h.

Referenced by DrawInventoryMenuEditor(), LoadBinaryGfx(), and Update().


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