yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::app::editor::OverworldEditor Class Reference

Manipulates the Overworld and OverworldMap data in a Rom. More...

#include <overworld_editor.h>

Inheritance diagram for yaze::app::editor::OverworldEditor:
Collaboration diagram for yaze::app::editor::OverworldEditor:

Public Member Functions

 OverworldEditor ()
 
void InitializeZeml ()
 
absl::Status Update () final
 
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 ()
 
auto overworld ()
 
int jump_to_tab ()
 
absl::Status LoadGraphics ()
 Load the Bitmap objects for each OverworldMap.
 
- Public Member Functions inherited from yaze::app::editor::Editor
 Editor ()=default
 
virtual ~Editor ()=default
 
EditorType type () const
 
- Public Member Functions inherited from yaze::app::SharedRom
 SharedRom ()=default
 
virtual ~SharedRom ()=default
 
std::shared_ptr< Romshared_rom ()
 
auto rom ()
 
- Public Member Functions inherited from yaze::app::editor::EntranceContext
absl::Status LoadEntranceTileTypes (Rom &rom)
 
- Public Member Functions inherited from yaze::app::core::ExperimentFlags
 ExperimentFlags ()=default
 
virtual ~ExperimentFlags ()=default
 
auto flags () const
 
Flagsmutable_flags ()
 
std::string Serialize () const
 

Public Attributes

int jump_to_tab_ = -1
 

Private Types

enum class  EditingMode {
  DRAW_TILE , ENTRANCES , EXITS , ITEMS ,
  SPRITES , TRANSPORTS , MUSIC , PAN
}
 
enum  OverworldProperty {
  LW_AREA_GFX , DW_AREA_GFX , LW_AREA_PAL , DW_AREA_PAL ,
  LW_SPR_GFX_PART1 , LW_SPR_GFX_PART2 , DW_SPR_GFX_PART1 , DW_SPR_GFX_PART2 ,
  LW_SPR_PAL_PART1 , LW_SPR_PAL_PART2 , DW_SPR_PAL_PART1 , DW_SPR_PAL_PART2
}
 

Private Member Functions

void DrawFullscreenCanvas ()
 Draws the canvas, tile16 selector, and toolset in fullscreen.
 
void DrawToolset ()
 Toolset for entrances, exits, items, sprites, and transports.
 
void DrawOverworldMapSettings ()
 Draws the overworld map settings. Graphics, palettes, etc.
 
void DrawCustomOverworldMapSettings ()
 
void RefreshChildMap (int i)
 
void RefreshOverworldMap ()
 
absl::Status RefreshMapPalette ()
 
void RefreshMapProperties ()
 
absl::Status RefreshTile16Blockset ()
 
void DrawOverworldEntrances (ImVec2 canvas_p, ImVec2 scrolling, bool holes=false)
 
void DrawOverworldExits (ImVec2 zero, ImVec2 scrolling)
 
void DrawOverworldItems ()
 
void DrawOverworldSprites ()
 
void DrawOverworldMaps ()
 
void DrawOverworldEdits ()
 
void RenderUpdatedMapBitmap (const ImVec2 &click_position, const std::vector< uint8_t > &tile_data)
 
void CheckForOverworldEdits ()
 Check for changes to the overworld map.
 
void CheckForSelectRectangle ()
 Draw and create the tile16 IDs that are currently selected.
 
absl::Status CheckForCurrentMap ()
 Check for changes to the overworld map. Calls RefreshOverworldMap and RefreshTile16Blockset on the current map if it is modified and is actively being edited.
 
void CheckForMousePan ()
 
void DrawOverworldCanvas ()
 Allows the user to make changes to the overworld map.
 
absl::Status DrawTile16Selector ()
 
void DrawTile8Selector ()
 
absl::Status DrawAreaGraphics ()
 
absl::Status DrawTileSelector ()
 
absl::Status LoadSpriteGraphics ()
 
void DrawOverworldProperties ()
 
absl::Status UpdateUsageStats ()
 
void DrawUsageGrid ()
 
void DrawDebugWindow ()
 

Private Attributes

EditingMode current_mode = EditingMode::DRAW_TILE
 
EditingMode previous_mode = EditingMode::DRAW_TILE
 
int current_world_ = 0
 
int current_map_ = 0
 
int current_parent_ = 0
 
int current_entrance_id_ = 0
 
int current_exit_id_ = 0
 
int current_item_id_ = 0
 
int current_sprite_id_ = 0
 
int current_blockset_ = 0
 
int game_state_ = 1
 
int current_tile16_ = 0
 
int selected_entrance_ = 0
 
int selected_usage_map_ = 0xFFFF
 
bool all_gfx_loaded_ = false
 
bool map_blockset_loaded_ = false
 
bool selected_tile_loaded_ = false
 
bool show_tile16_editor_ = false
 
bool overworld_canvas_fullscreen_ = false
 
bool middle_mouse_dragging_ = false
 
bool is_dragging_entity_ = false
 
std::vector< uint8_t > selected_tile_data_
 
std::vector< std::vector< uint8_t > > tile16_individual_data_
 
std::vector< gfx::Bitmaptile16_individual_
 
std::vector< std::vector< uint8_t > > tile8_individual_data_
 
std::vector< gfx::Bitmaptile8_individual_
 
Tile16Editor tile16_editor_
 
GfxGroupEditor gfx_group_editor_
 
PaletteEditor palette_editor_
 
gfx::SnesPalette palette_
 
gfx::Bitmap selected_tile_bmp_
 
gfx::Bitmap tile16_blockset_bmp_
 
gfx::Bitmap current_gfx_bmp_
 
gfx::Bitmap all_gfx_bmp
 
gfx::BitmapTable maps_bmp_
 
gfx::BitmapTable current_graphics_set_
 
gfx::BitmapTable sprite_previews_
 
zelda3::overworld::Overworld overworld_
 
zelda3::OWBlockset refresh_blockset_
 
zelda3::Sprite current_sprite_
 
zelda3::overworld::OverworldEntrance current_entrance_
 
zelda3::overworld::OverworldExit current_exit_
 
zelda3::overworld::OverworldItem current_item_
 
zelda3::GameEntitycurrent_entity_
 
zelda3::GameEntitydragged_entity_
 
gui::Canvas ow_map_canvas_
 
gui::Canvas current_gfx_canvas_
 
gui::Canvas blockset_canvas_
 
gui::Canvas graphics_bin_canvas_
 
gui::Canvas properties_canvas_
 
gui::zeml::Node layout_node_
 
absl::Status status_
 

Additional Inherited Members

- Static Public Attributes inherited from yaze::app::SharedRom
static std::shared_ptr< Romshared_rom_ = nullptr
 
- Protected Attributes inherited from yaze::app::editor::Editor
EditorType type_
 
- Static Protected Attributes inherited from yaze::app::editor::context::GfxContext
static std::unordered_map< uint8_t, gfx::Palettesetpalettesets_
 

Detailed Description

Manipulates the Overworld and OverworldMap data in a Rom.

The OverworldEditor class is responsible for managing the editing and manipulation of the overworld in a game. The user can drag and drop tiles, modify OverworldEntrance, OverworldExit, Sprite, and OverworldItem as well as change the gfx and palettes used in each overworld map.

The Overworld itself is a series of bitmap images which exist inside each OverworldMap object. The drawing of the overworld is done using the Canvas class in conjunction with these underlying Bitmap objects.

Provides access to the GfxGroupEditor and Tile16Editor through popup windows.

Definition at line 107 of file overworld_editor.h.

Member Enumeration Documentation

◆ EditingMode

Enumerator
DRAW_TILE 
ENTRANCES 
EXITS 
ITEMS 
SPRITES 
TRANSPORTS 
MUSIC 
PAN 

Definition at line 220 of file overworld_editor.h.

◆ OverworldProperty

Enumerator
LW_AREA_GFX 
DW_AREA_GFX 
LW_AREA_PAL 
DW_AREA_PAL 
LW_SPR_GFX_PART1 
LW_SPR_GFX_PART2 
DW_SPR_GFX_PART1 
DW_SPR_GFX_PART2 
LW_SPR_PAL_PART1 
LW_SPR_PAL_PART2 
DW_SPR_PAL_PART1 
DW_SPR_PAL_PART2 

Definition at line 234 of file overworld_editor.h.

Constructor & Destructor Documentation

◆ OverworldEditor()

yaze::app::editor::OverworldEditor::OverworldEditor ( )
inline

Member Function Documentation

◆ InitializeZeml()

void yaze::app::editor::OverworldEditor::InitializeZeml ( )

◆ Update()

◆ Undo()

absl::Status yaze::app::editor::OverworldEditor::Undo ( )
inlineoverridevirtual

Implements yaze::app::editor::Editor.

Definition at line 118 of file overworld_editor.h.

Referenced by DrawToolset().

◆ Redo()

absl::Status yaze::app::editor::OverworldEditor::Redo ( )
inlineoverridevirtual

Implements yaze::app::editor::Editor.

Definition at line 119 of file overworld_editor.h.

Referenced by DrawToolset().

◆ Cut()

absl::Status yaze::app::editor::OverworldEditor::Cut ( )
inlineoverridevirtual

Implements yaze::app::editor::Editor.

Definition at line 120 of file overworld_editor.h.

◆ Copy()

absl::Status yaze::app::editor::OverworldEditor::Copy ( )
inlineoverridevirtual

Implements yaze::app::editor::Editor.

Definition at line 121 of file overworld_editor.h.

◆ Paste()

absl::Status yaze::app::editor::OverworldEditor::Paste ( )
inlineoverridevirtual

Implements yaze::app::editor::Editor.

Definition at line 122 of file overworld_editor.h.

◆ Find()

absl::Status yaze::app::editor::OverworldEditor::Find ( )
inlineoverridevirtual

Implements yaze::app::editor::Editor.

Definition at line 123 of file overworld_editor.h.

◆ Save()

◆ overworld()

auto yaze::app::editor::OverworldEditor::overworld ( )
inline

Definition at line 128 of file overworld_editor.h.

References overworld_.

Referenced by DrawOverworldCanvas(), LoadGraphics(), and Save().

◆ jump_to_tab()

int yaze::app::editor::OverworldEditor::jump_to_tab ( )
inline

Definition at line 133 of file overworld_editor.h.

References jump_to_tab_.

Referenced by yaze::app::editor::EditorManager::ManageActiveEditors().

◆ LoadGraphics()

◆ DrawFullscreenCanvas()

void yaze::app::editor::OverworldEditor::DrawFullscreenCanvas ( )
private

Draws the canvas, tile16 selector, and toolset in fullscreen.

Definition at line 77 of file overworld_editor.cc.

References DrawOverworldCanvas(), DrawToolset(), yaze::app::core::ExperimentFlags::flags(), and overworld_canvas_fullscreen_.

Referenced by Update().

Here is the call graph for this function:

◆ DrawToolset()

◆ DrawOverworldMapSettings()

◆ DrawCustomOverworldMapSettings()

◆ RefreshChildMap()

◆ RefreshOverworldMap()

◆ RefreshMapPalette()

◆ RefreshMapProperties()

void yaze::app::editor::OverworldEditor::RefreshMapProperties ( )
private

◆ RefreshTile16Blockset()

◆ DrawOverworldEntrances()

◆ DrawOverworldExits()

◆ DrawOverworldItems()

◆ DrawOverworldSprites()

◆ DrawOverworldMaps()

void yaze::app::editor::OverworldEditor::DrawOverworldMaps ( )
private

◆ DrawOverworldEdits()

◆ RenderUpdatedMapBitmap()

void yaze::app::editor::OverworldEditor::RenderUpdatedMapBitmap ( const ImVec2 & click_position,
const std::vector< uint8_t > & tile_data )
private

◆ CheckForOverworldEdits()

void yaze::app::editor::OverworldEditor::CheckForOverworldEdits ( )
private

Check for changes to the overworld map.

This function either draws the tile painter with the current tile16 or group of tile16 data with ow_map_canvas_ and DrawOverworldEdits or it checks for left mouse button click/drag to select a tile16 or group of tile16 data from the overworld map canvas. Similar to ZScream selection.

Definition at line 486 of file overworld_editor.cc.

References blockset_canvas_, CheckForSelectRectangle(), current_tile16_, current_world_, DrawOverworldEdits(), yaze::app::gui::Canvas::DrawTilePainter(), yaze::app::zelda3::overworld::Overworld::GetTileFromPosition(), yaze::app::editor::kTile16Size, yaze::app::zelda3::overworld::Overworld::mutable_map_tiles(), overworld_, ow_map_canvas_, yaze::app::gui::Canvas::points(), RefreshOverworldMap(), yaze::app::gui::Canvas::select_rect_active(), yaze::app::gui::Canvas::selected_points(), yaze::app::gui::Canvas::selected_tiles(), and tile16_individual_.

Referenced by DrawOverworldCanvas().

Here is the call graph for this function:

◆ CheckForSelectRectangle()

◆ CheckForCurrentMap()

absl::Status yaze::app::editor::OverworldEditor::CheckForCurrentMap ( )
private

Check for changes to the overworld map. Calls RefreshOverworldMap and RefreshTile16Blockset on the current map if it is modified and is actively being edited.

Definition at line 575 of file overworld_editor.cc.

References current_map_, current_parent_, current_world_, yaze::app::gui::Canvas::DrawOutline(), yaze::app::core::Renderer::GetInstance(), yaze::app::editor::kOverworldMapSize, maps_bmp_, overworld_, yaze::app::zelda3::overworld::Overworld::overworld_map(), ow_map_canvas_, RefreshOverworldMap(), RefreshTile16Blockset(), RETURN_IF_ERROR, yaze::app::core::Renderer::UpdateBitmap(), and yaze::app::gui::Canvas::zero_point().

Referenced by DrawOverworldCanvas().

Here is the call graph for this function:

◆ CheckForMousePan()

void yaze::app::editor::OverworldEditor::CheckForMousePan ( )
private

Definition at line 624 of file overworld_editor.cc.

References current_mode, middle_mouse_dragging_, ow_map_canvas_, PAN, previous_mode, and yaze::app::gui::Canvas::set_draggable().

Referenced by DrawOverworldCanvas().

Here is the call graph for this function:

◆ DrawOverworldCanvas()

◆ DrawTile16Selector()

◆ DrawTile8Selector()

◆ DrawAreaGraphics()

◆ DrawTileSelector()

absl::Status yaze::app::editor::OverworldEditor::DrawTileSelector ( )
private

◆ LoadSpriteGraphics()

absl::Status yaze::app::editor::OverworldEditor::LoadSpriteGraphics ( )
private

◆ DrawOverworldProperties()

◆ UpdateUsageStats()

◆ DrawUsageGrid()

void yaze::app::editor::OverworldEditor::DrawUsageGrid ( )
private

Definition at line 1416 of file overworld_editor.cc.

References selected_usage_map_.

Referenced by UpdateUsageStats().

◆ DrawDebugWindow()

void yaze::app::editor::OverworldEditor::DrawDebugWindow ( )
private

Member Data Documentation

◆ jump_to_tab_

int yaze::app::editor::OverworldEditor::jump_to_tab_ = -1

◆ current_mode

◆ previous_mode

EditingMode yaze::app::editor::OverworldEditor::previous_mode = EditingMode::DRAW_TILE
private

Definition at line 232 of file overworld_editor.h.

Referenced by CheckForMousePan().

◆ current_world_

◆ current_map_

◆ current_parent_

int yaze::app::editor::OverworldEditor::current_parent_ = 0
private

Definition at line 251 of file overworld_editor.h.

Referenced by CheckForCurrentMap(), and RefreshOverworldMap().

◆ current_entrance_id_

int yaze::app::editor::OverworldEditor::current_entrance_id_ = 0
private

Definition at line 252 of file overworld_editor.h.

Referenced by DrawOverworldEntrances().

◆ current_exit_id_

int yaze::app::editor::OverworldEditor::current_exit_id_ = 0
private

Definition at line 253 of file overworld_editor.h.

Referenced by DrawOverworldExits().

◆ current_item_id_

int yaze::app::editor::OverworldEditor::current_item_id_ = 0
private

Definition at line 254 of file overworld_editor.h.

Referenced by DrawOverworldItems().

◆ current_sprite_id_

int yaze::app::editor::OverworldEditor::current_sprite_id_ = 0
private

Definition at line 255 of file overworld_editor.h.

Referenced by DrawOverworldSprites().

◆ current_blockset_

int yaze::app::editor::OverworldEditor::current_blockset_ = 0
private

Definition at line 256 of file overworld_editor.h.

Referenced by RefreshTile16Blockset().

◆ game_state_

int yaze::app::editor::OverworldEditor::game_state_ = 1
private

◆ current_tile16_

int yaze::app::editor::OverworldEditor::current_tile16_ = 0
private

◆ selected_entrance_

int yaze::app::editor::OverworldEditor::selected_entrance_ = 0
private

Definition at line 259 of file overworld_editor.h.

Referenced by UpdateUsageStats().

◆ selected_usage_map_

int yaze::app::editor::OverworldEditor::selected_usage_map_ = 0xFFFF
private

Definition at line 260 of file overworld_editor.h.

Referenced by DrawUsageGrid(), and UpdateUsageStats().

◆ all_gfx_loaded_

bool yaze::app::editor::OverworldEditor::all_gfx_loaded_ = false
private

Definition at line 262 of file overworld_editor.h.

Referenced by DrawOverworldCanvas(), DrawTile8Selector(), and Update().

◆ map_blockset_loaded_

bool yaze::app::editor::OverworldEditor::map_blockset_loaded_ = false
private

Definition at line 263 of file overworld_editor.h.

Referenced by DrawTile16Selector(), and LoadGraphics().

◆ selected_tile_loaded_

bool yaze::app::editor::OverworldEditor::selected_tile_loaded_ = false
private

Definition at line 264 of file overworld_editor.h.

◆ show_tile16_editor_

bool yaze::app::editor::OverworldEditor::show_tile16_editor_ = false
private

Definition at line 265 of file overworld_editor.h.

Referenced by DrawTile16Selector(), and DrawToolset().

◆ overworld_canvas_fullscreen_

bool yaze::app::editor::OverworldEditor::overworld_canvas_fullscreen_ = false
private

Definition at line 266 of file overworld_editor.h.

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

◆ middle_mouse_dragging_

bool yaze::app::editor::OverworldEditor::middle_mouse_dragging_ = false
private

Definition at line 267 of file overworld_editor.h.

Referenced by CheckForMousePan().

◆ is_dragging_entity_

bool yaze::app::editor::OverworldEditor::is_dragging_entity_ = false
private

◆ selected_tile_data_

std::vector<uint8_t> yaze::app::editor::OverworldEditor::selected_tile_data_
private

Definition at line 270 of file overworld_editor.h.

◆ tile16_individual_data_

std::vector<std::vector<uint8_t> > yaze::app::editor::OverworldEditor::tile16_individual_data_
private

Definition at line 271 of file overworld_editor.h.

Referenced by DrawOverworldEdits(), and LoadGraphics().

◆ tile16_individual_

std::vector<gfx::Bitmap> yaze::app::editor::OverworldEditor::tile16_individual_
private

◆ tile8_individual_data_

std::vector<std::vector<uint8_t> > yaze::app::editor::OverworldEditor::tile8_individual_data_
private

Definition at line 274 of file overworld_editor.h.

◆ tile8_individual_

std::vector<gfx::Bitmap> yaze::app::editor::OverworldEditor::tile8_individual_
private

Definition at line 275 of file overworld_editor.h.

◆ tile16_editor_

Tile16Editor yaze::app::editor::OverworldEditor::tile16_editor_
private

Definition at line 277 of file overworld_editor.h.

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

◆ gfx_group_editor_

GfxGroupEditor yaze::app::editor::OverworldEditor::gfx_group_editor_
private

Definition at line 278 of file overworld_editor.h.

Referenced by DrawOverworldProperties(), and DrawToolset().

◆ palette_editor_

PaletteEditor yaze::app::editor::OverworldEditor::palette_editor_
private

Definition at line 279 of file overworld_editor.h.

◆ palette_

gfx::SnesPalette yaze::app::editor::OverworldEditor::palette_
private

◆ selected_tile_bmp_

gfx::Bitmap yaze::app::editor::OverworldEditor::selected_tile_bmp_
private

Definition at line 283 of file overworld_editor.h.

◆ tile16_blockset_bmp_

gfx::Bitmap yaze::app::editor::OverworldEditor::tile16_blockset_bmp_
private

◆ current_gfx_bmp_

gfx::Bitmap yaze::app::editor::OverworldEditor::current_gfx_bmp_
private

Definition at line 285 of file overworld_editor.h.

Referenced by LoadGraphics(), and Update().

◆ all_gfx_bmp

gfx::Bitmap yaze::app::editor::OverworldEditor::all_gfx_bmp
private

Definition at line 286 of file overworld_editor.h.

◆ maps_bmp_

◆ current_graphics_set_

gfx::BitmapTable yaze::app::editor::OverworldEditor::current_graphics_set_
private

Definition at line 289 of file overworld_editor.h.

Referenced by DrawAreaGraphics().

◆ sprite_previews_

gfx::BitmapTable yaze::app::editor::OverworldEditor::sprite_previews_
private

Definition at line 290 of file overworld_editor.h.

Referenced by LoadSpriteGraphics().

◆ overworld_

◆ refresh_blockset_

zelda3::OWBlockset yaze::app::editor::OverworldEditor::refresh_blockset_
private

Definition at line 293 of file overworld_editor.h.

◆ current_sprite_

zelda3::Sprite yaze::app::editor::OverworldEditor::current_sprite_
private

Definition at line 295 of file overworld_editor.h.

Referenced by DrawOverworldSprites().

◆ current_entrance_

zelda3::overworld::OverworldEntrance yaze::app::editor::OverworldEditor::current_entrance_
private

Definition at line 297 of file overworld_editor.h.

Referenced by DrawOverworldEntrances().

◆ current_exit_

zelda3::overworld::OverworldExit yaze::app::editor::OverworldEditor::current_exit_
private

Definition at line 298 of file overworld_editor.h.

Referenced by DrawOverworldExits().

◆ current_item_

zelda3::overworld::OverworldItem yaze::app::editor::OverworldEditor::current_item_
private

Definition at line 299 of file overworld_editor.h.

Referenced by DrawOverworldItems().

◆ current_entity_

zelda3::GameEntity* yaze::app::editor::OverworldEditor::current_entity_
private

◆ dragged_entity_

zelda3::GameEntity* yaze::app::editor::OverworldEditor::dragged_entity_
private

◆ ow_map_canvas_

◆ current_gfx_canvas_

gui::Canvas yaze::app::editor::OverworldEditor::current_gfx_canvas_
private
Initial value:
{"CurrentGfx", kCurrentGfxCanvasSize,
constexpr ImVec2 kCurrentGfxCanvasSize(0x100+1, 0x10 *0x40+1)

Definition at line 306 of file overworld_editor.h.

Referenced by DrawAreaGraphics().

◆ blockset_canvas_

gui::Canvas yaze::app::editor::OverworldEditor::blockset_canvas_
private
Initial value:
{"OwBlockset", kBlocksetCanvasSize,
constexpr ImVec2 kBlocksetCanvasSize(0x100+1, 0x2000+1)

Definition at line 308 of file overworld_editor.h.

Referenced by CheckForOverworldEdits(), and DrawTile16Selector().

◆ graphics_bin_canvas_

gui::Canvas yaze::app::editor::OverworldEditor::graphics_bin_canvas_
private
Initial value:
{"GraphicsBin", kGraphicsBinCanvasSize,
constexpr ImVec2 kGraphicsBinCanvasSize(0x100+1, kNumSheetsToLoad *0x40+1)

Definition at line 310 of file overworld_editor.h.

Referenced by DrawTile8Selector().

◆ properties_canvas_

gui::Canvas yaze::app::editor::OverworldEditor::properties_canvas_
private

Definition at line 312 of file overworld_editor.h.

Referenced by DrawOverworldProperties(), and UpdateUsageStats().

◆ layout_node_

gui::zeml::Node yaze::app::editor::OverworldEditor::layout_node_
private

Definition at line 313 of file overworld_editor.h.

Referenced by InitializeZeml(), and Update().

◆ status_

absl::Status yaze::app::editor::OverworldEditor::status_
private

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