1#ifndef YAZE_APP_EDITOR_OVERWORLDEDITOR_H
2#define YAZE_APP_EDITOR_OVERWORLDEDITOR_H
7#include "absl/status/status.h"
26#include "imgui/imgui.h"
80constexpr unsigned int k4BPP = 4;
92 ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable |
93 ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingStretchProp;
96 "Light World\0Dark World\0Extra World\0";
155 absl::Status
Load()
override;
156 absl::Status
Update() final;
157 absl::Status
Undo() override;
158 absl::Status
Redo() override;
159 absl::Status
Cut()
override {
return absl::UnimplementedError(
"Cut"); }
160 absl::Status
Copy()
override;
161 absl::Status
Paste()
override;
162 absl::Status
Find()
override {
return absl::UnimplementedError(
"Find"); }
163 absl::Status
Save()
override;
164 absl::Status
Clear()
override;
192 return "No ROM loaded";
194 return "ROM failed to load";
195 return absl::StrFormat(
"ROM loaded: %s",
rom_->
title());
343 const std::vector<uint8_t>& tile_data);
428 std::vector<std::pair<std::pair<int, int>,
int>>
433 void CreateUndoPoint(
int map_id,
int world,
int x,
int y,
int old_tile_id);
527 std::string
name =
"Scratch Space";
560 std::array<gfx::Bitmap, zelda3::kNumOverworldMaps>
maps_bmp_;
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Interface for editor classes.
zelda3::GameData * game_data() const
EditorDependencies dependencies_
Manage graphics group configurations in a Rom.
void SetGameData(zelda3::GameData *data)
Main UI class for editing overworld maps in A Link to the Past.
std::unique_ptr< UsageStatisticsCard > usage_stats_card_
absl::Status Clear() override
std::unique_ptr< MapPropertiesSystem > map_properties_system_
zelda3::OverworldItem current_item_
void HandleMapInteraction()
bool overworld_canvas_fullscreen_
bool map_blockset_loaded_
void HandleEntityInteraction()
Handle entity interaction in MOUSE mode Includes: right-click context menus, double-click navigation,...
static constexpr float kHoverBuildDelay
absl::Status DrawScratchSpace()
zelda3::OverworldEntranceTileTypes entrance_tiletypes_
zelda3::OverworldEntrance current_entrance_
void CenterOverworldView()
void HandleTile16Edit()
Handle tile16 editing from context menu (MOUSE mode) Gets the tile16 under the cursor and opens the T...
absl::Status ApplyZSCustomOverworldASM(int target_version)
Apply ZSCustomOverworld ASM patch to upgrade ROM version.
zelda3::Sprite current_sprite_
std::optional< OverworldUndoPoint > current_paint_operation_
std::string entity_insert_error_message_
absl::Status CheckForCurrentMap()
Check for map changes and refresh if needed.
void DrawOverworldEdits()
void CreateUndoPoint(int map_id, int world, int x, int y, int old_tile_id)
absl::Status Cut() override
absl::Status LoadScratchToSelection()
void ForceRefreshGraphics(int map_index)
std::vector< int > selected_tile16_ids_
zelda3::GameData * game_data_
gfx::Bitmap current_gfx_bmp_
gfx::Tilemap tile16_blockset_
absl::Status ClearScratchSpace()
void ProcessPendingEntityInsertion()
Process any pending entity insertion request Called from Update() - needed because ImGui::OpenPopup()...
std::vector< OverworldUndoPoint > undo_stack_
void CycleTileSelection(int delta)
zelda3::OverworldBlockset refresh_blockset_
gfx::Bitmap selected_tile_bmp_
void ResetOverworldView()
Tile16Editor tile16_editor_
void DrawScratchSpaceSelection()
gui::Canvas ow_map_canvas_
ScratchSpace scratch_space_
absl::Status Undo() override
void HandleEntityInsertion(const std::string &entity_type)
Handle entity insertion from context menu.
zelda3::GameEntity * dragged_entity_
std::array< gfx::Bitmap, zelda3::kNumOverworldMaps > maps_bmp_
bool show_map_properties_panel_
void RefreshOverworldMap()
void CheckForOverworldEdits()
Check for tile edits - handles painting and selection.
absl::Status UpdateROMVersionMarkers(int target_version)
Update ROM version markers and feature flags after ASM patching.
void ProcessPreloadQueue()
Process one map from the preload queue (called each frame)
void UpdateScratchBitmapTile(int tile_x, int tile_y, int tile_id)
zelda3::OverworldExit current_exit_
void UpdateBlocksetWithPendingTileChanges()
UsageStatisticsCard * usage_stats_card()
Access usage statistics card for panel.
void RefreshMapProperties()
void SetGameData(zelda3::GameData *game_data) override
void RefreshSiblingMapGraphics(int map_index, bool include_self=false)
std::vector< OverworldUndoPoint > redo_stack_
void DrawScratchSpacePattern()
gui::Canvas scratch_canvas_
void RenderUpdatedMapBitmap(const ImVec2 &click_position, const std::vector< uint8_t > &tile_data)
gui::Canvas * GetOverworldCanvas()
void set_current_map(int map_id)
Set the current map for editing (also updates world)
void DrawScratchSpaceEdits()
void RefreshOverworldMapOnDemand(int map_index)
On-demand map refresh that only updates what's actually needed.
gui::Canvas current_gfx_canvas_
std::string pending_entity_insert_type_
void Initialize() override
bool show_overlay_editor_
std::unique_ptr< OverworldSidebar > sidebar_
absl::Status Redo() override
static constexpr float kPreloadStartDelay
void SetupCanvasAutomation()
std::chrono::steady_clock::time_point last_paint_time_
void InvalidateGraphicsCache(int map_id=-1)
Invalidate cached graphics for a specific map or all maps.
void HandleOverworldPan()
DebugWindowCard * debug_window_card()
Access debug window card for panel.
void HandleEntityDoubleClick(zelda3::GameEntity *hovered_entity)
Handle double-click actions on entities (e.g., jump to room)
void DrawFullscreenCanvas()
bool dragged_entity_free_movement_
void DrawOverworldProperties()
void HandleEntityContextMenus(zelda3::GameEntity *hovered_entity)
Handle right-click context menus for entities.
absl::Status SaveCurrentSelectionToScratch()
bool AutomationSetTile(int x, int y, int tile_id)
absl::Status RefreshMapPalette()
void RefreshMultiAreaMapsSafely(int map_index, zelda3::OverworldMap *map)
Safely refresh multi-area maps without recursion.
void DrawOverworldCanvas()
Draw the main overworld canvas.
gui::Canvas blockset_canvas_
std::vector< int > preload_queue_
absl::Status RefreshTile16Blockset()
zelda3::Overworld & overworld()
Access the underlying Overworld data.
void UpdateBlocksetSelectorState()
void CheckForSelectRectangle()
Draw and create the tile16 IDs that are currently selected.
void RefreshChildMap(int map_index)
ImVec2 pending_entity_insert_pos_
void FinalizePaintOperation()
std::unique_ptr< OverworldEntityRenderer > entity_renderer_
auto & GetWorldTiles(int world)
absl::Status Load() override
absl::Status UpdateGfxGroupEditor()
void EnsureMapTexture(int map_index)
Ensure a specific map has its texture created.
std::vector< gfx::Bitmap > sprite_previews_
OverworldEditor(Rom *rom, const EditorDependencies &deps)
absl::Status Copy() override
std::string GetRomStatus() const override
absl::Status DrawAreaGraphics()
EntityEditMode entity_edit_mode_
std::unique_ptr< OverworldToolbar > toolbar_
PaletteEditor palette_editor_
bool IsRomLoaded() const override
Tile16Editor & tile16_editor()
Access the Tile16 Editor for panel integration.
GfxGroupEditor gfx_group_editor_
void ProcessDeferredTextures()
Create textures for deferred map bitmaps on demand.
absl::Status Update() final
std::unique_ptr< gui::TileSelectorWidget > blockset_selector_
bool show_overlay_preview_
void DrawEntityEditorPopups()
Draw entity editor popups and update entity data.
absl::Status Paste() override
void HandleEntityEditingShortcuts()
void ScrollBlocksetCanvasToCurrentTile()
Scroll the blockset canvas to show the current selected tile16.
static constexpr auto kPaintBatchTimeout
EditingMode previous_mode
static constexpr size_t kMaxUndoHistory
gui::Canvas graphics_bin_canvas_
gfx::BitmapTable current_graphics_set_
bool show_custom_bg_color_editor_
zelda3::Overworld overworld_
absl::Status LoadGraphics()
Load the Bitmap objects for each OverworldMap.
void RefreshChildMapOnDemand(int map_index)
On-demand child map refresh with selective updates.
absl::Status Find() override
absl::Status LoadSpriteGraphics()
gfx::IRenderer * renderer_
absl::Status Save() override
std::unique_ptr< DebugWindowCard > debug_window_card_
void ApplyUndoPoint(const OverworldUndoPoint &point)
void HandleOverworldZoom()
zelda3::GameEntity * current_entity_
void HandleUndoRedoShortcuts()
void HandleKeyboardShortcuts()
Handle keyboard shortcuts for the Overworld Editor Shortcuts: 1-2 (modes), 3-8 (entities),...
gui::Canvas properties_canvas_
int AutomationGetTile(int x, int y)
gfx::SnesPalette palette_
gfx::Bitmap tile16_blockset_bmp_
void QueueAdjacentMapsForPreload(int center_map)
Queue adjacent maps for background pre-loading.
absl::Status DrawTile16Selector()
void ClampOverworldScroll()
OverworldEditor(Rom *rom)
Allows the user to view and edit in game palettes.
Popup window to edit Tile16 data.
void SetGameData(zelda3::GameData *game_data)
Represents a bitmap image optimized for SNES ROM hacking.
Shared graphical context across editors.
Defines an abstract interface for all rendering operations.
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
Modern, robust canvas for drawing and manipulating graphics.
Base class for all overworld and dungeon entities.
Represents an overworld exit that transitions from dungeon to overworld.
Represents a single Overworld map screen.
Represents the full Overworld data, light and dark world.
void set_current_world(int world)
void SetGameData(GameData *game_data)
void set_current_map(int i)
A class for managing sprites in the overworld and underworld.
constexpr ImVec2 kOverworldCanvasSize(kOverworldMapSize *8, kOverworldMapSize *8)
constexpr absl::string_view kOWMapTable
constexpr ImGuiTableFlags kOWMapFlags
constexpr unsigned int kOverworldMapSize
constexpr float kOverworldMaxZoom
constexpr absl::string_view kWorldList
constexpr absl::string_view kGamePartComboString
constexpr float kOverworldMinZoom
constexpr unsigned int kNumSheetsToLoad
constexpr ImVec2 kCurrentGfxCanvasSize(0x100+1, 0x10 *0x40+1)
constexpr ImVec2 kBlocksetCanvasSize(0x100+1, 0x4000+1)
constexpr ImVec2 kGraphicsBinCanvasSize(0x100+1, kNumSheetsToLoad *0x40+1)
constexpr unsigned int kByteSize
constexpr float kOverworldZoomStep
constexpr unsigned int k4BPP
constexpr unsigned int kMessageIdSize
std::unordered_map< int, std::unique_ptr< gfx::Bitmap > > BitmapTable
constexpr int kNumOverworldMaps
std::vector< std::vector< uint16_t > > OverworldBlockset
Represents tile32 data for the overworld.
Unified dependency container for all editor types.
std::vector< std::pair< std::pair< int, int >, int > > tile_changes
std::chrono::steady_clock::time_point timestamp
gfx::Bitmap scratch_bitmap
std::vector< ImVec2 > selected_tiles
std::array< std::array< int, 32 >, 32 > tile_data
std::vector< ImVec2 > selected_points
Tilemap structure for SNES tile-based graphics management.