Manages tile painting, fill, selection, and eyedropper operations. More...
#include <tile_painting_manager.h>

Classes | |
| struct | TilePosition |
Public Member Functions | |
| TilePaintingManager (const TilePaintingDependencies &deps, const TilePaintingCallbacks &callbacks) | |
| void | CheckForOverworldEdits () |
| Main entry point: check for tile edits (paint, fill, stamp). | |
| void | CheckForSelectRectangle () |
| Draw and create the tile16 IDs that are currently selected. | |
| const TileBrush * | selection_brush () const |
| The captured selection, independent of its source or preview position. | |
| absl::Status | PasteBrush (const TileBrush &brush) |
| void | RenderUpdatedMapBitmap (const ImVec2 &click_position, const std::vector< uint8_t > &tile_data) |
| Update bitmap pixels after a single tile paint. | |
| bool | PickTile16FromHoveredCanvas () |
| Eyedropper: pick the tile16 under the hovered canvas position. | |
| void | ToggleBrushTool () |
| Toggle between DRAW_TILE and MOUSE modes. | |
| void | ActivateFillTool () |
| Toggle FILL_TILE mode on/off. | |
| const gfx::Bitmap & | map_brush_preview (int map_id) const |
Private Types | |
| using | ChangedMaps = std::array<bool, zelda3::kNumOverworldMaps> |
Private Member Functions | |
| TilePosition | HoveredTile () const |
| bool | IsValidTile (TilePosition position) const |
| std::vector< std::vector< uint16_t > > & | WorldTiles () const |
| void | CaptureSelection () |
| void | DrawBrushPreview (const TileBrush &brush, TilePosition anchor, bool mark_selection, int alpha) |
| std::vector< uint8_t > | Tile16PixelsForMap (int map_id, int tile_id) const |
| void | PaintPattern (const TileBrush &brush, TilePosition anchor, int width, int height, bool finalize=true) |
| bool | PaintTile (TilePosition position, int tile_id, ChangedMaps &changed_maps) |
| void | RenderMapTile (int map_id, TilePosition position, const std::vector< uint8_t > &tile_data) |
Private Attributes | |
| TilePaintingDependencies | deps_ |
| TilePaintingCallbacks | callbacks_ |
| bool | paint_gesture_owned_ = false |
| bool | single_paint_pending_ = false |
| bool | selection_gesture_owned_ = false |
| TileBrush | brush_ |
| std::array< gfx::Bitmap, zelda3::kNumOverworldMaps > | map_brush_previews_ |
Manages tile painting, fill, selection, and eyedropper operations.
Owns captured brush contents and canvas gestures. All destinations use world Tile16 coordinates; callbacks publish undo and refresh affected maps.
Definition at line 58 of file tile_painting_manager.h.
|
private |
Definition at line 100 of file tile_painting_manager.h.
| yaze::editor::TilePaintingManager::TilePaintingManager | ( | const TilePaintingDependencies & | deps, |
| const TilePaintingCallbacks & | callbacks ) |
Definition at line 34 of file tile_painting_manager.cc.
| void yaze::editor::TilePaintingManager::CheckForOverworldEdits | ( | ) |
Main entry point: check for tile edits (paint, fill, stamp).
Definition at line 76 of file tile_painting_manager.cc.
References callbacks_, CheckForSelectRectangle(), yaze::editor::TilePaintingDependencies::current_mode, yaze::editor::TilePaintingDependencies::current_tile16, deps_, yaze::editor::DRAW_TILE, DrawBrushPreview(), yaze::editor::FILL_TILE, yaze::editor::TilePaintingCallbacks::finalize_paint_operation, HoveredTile(), IsValidTile(), yaze::editor::kTile16Size, yaze::editor::TilePaintingDependencies::ow_map_canvas, paint_gesture_owned_, PaintPattern(), selection_brush(), single_paint_pending_, and yaze::editor::TilePaintingManager::TilePosition::x.
| void yaze::editor::TilePaintingManager::CheckForSelectRectangle | ( | ) |
Draw and create the tile16 IDs that are currently selected.
Definition at line 307 of file tile_painting_manager.cc.
References brush_, callbacks_, CaptureSelection(), yaze::editor::TilePaintingDependencies::current_map, yaze::editor::TilePaintingDependencies::current_tile16, deps_, DrawBrushPreview(), HoveredTile(), IsValidTile(), yaze::editor::kTile16Size, yaze::editor::TilePaintingDependencies::ow_map_canvas, yaze::editor::TilePaintingCallbacks::request_tile16_selection, yaze::editor::TilePaintingCallbacks::scroll_blockset_to_current_tile, yaze::gui::Canvas::select_rect_active(), yaze::editor::TilePaintingDependencies::selected_tile16_ids, selection_brush(), selection_gesture_owned_, and WorldTiles().
Referenced by CheckForOverworldEdits().
| const TileBrush * yaze::editor::TilePaintingManager::selection_brush | ( | ) | const |
The captured selection, independent of its source or preview position.
Definition at line 71 of file tile_painting_manager.cc.
References brush_, deps_, yaze::editor::TilePaintingDependencies::ow_map_canvas, yaze::gui::Canvas::select_rect_active(), and yaze::editor::TileBrush::valid().
Referenced by CheckForOverworldEdits(), and CheckForSelectRectangle().

| absl::Status yaze::editor::TilePaintingManager::PasteBrush | ( | const TileBrush & | brush | ) |
Paste a validated pattern at the current canvas cursor, using the same clipping, per-map refresh, and undo path as rectangle painting.
Definition at line 132 of file tile_painting_manager.cc.
References deps_, yaze::editor::TileBrush::height, HoveredTile(), yaze::gui::Canvas::IsMouseHovering(), yaze::editor::TilePaintingDependencies::ow_map_canvas, PaintPattern(), yaze::editor::TileBrush::valid(), and yaze::editor::TileBrush::width.

| void yaze::editor::TilePaintingManager::RenderUpdatedMapBitmap | ( | const ImVec2 & | click_position, |
| const std::vector< uint8_t > & | tile_data ) |
Update bitmap pixels after a single tile paint.
Definition at line 254 of file tile_painting_manager.cc.
References yaze::editor::TilePaintingDependencies::current_map, deps_, yaze::gfx::Arena::Get(), yaze::zelda3::kNumOverworldMaps, yaze::editor::TilePaintingDependencies::maps_bmp, yaze::gfx::Arena::QueueTextureCommand(), RenderMapTile(), and yaze::gfx::Arena::UPDATE.

| bool yaze::editor::TilePaintingManager::PickTile16FromHoveredCanvas | ( | ) |
Eyedropper: pick the tile16 under the hovered canvas position.
Definition at line 443 of file tile_painting_manager.cc.
References callbacks_, yaze::editor::TilePaintingDependencies::current_tile16, yaze::editor::TilePaintingDependencies::current_world, deps_, yaze::gui::Canvas::global_scale(), yaze::gui::Canvas::hover_mouse_pos(), yaze::gui::Canvas::IsMouseHovering(), yaze::editor::kOverworldMapSize, yaze::editor::kTile16Size, yaze::util::logf(), yaze::zelda3::Overworld::mutable_map_tiles(), yaze::editor::TilePaintingDependencies::overworld, yaze::editor::TilePaintingDependencies::ow_map_canvas, yaze::editor::TilePaintingCallbacks::request_tile16_selection, yaze::editor::TilePaintingCallbacks::scroll_blockset_to_current_tile, yaze::editor::Tile16Editor::SetCurrentTile(), and yaze::editor::TilePaintingDependencies::tile16_editor.
| void yaze::editor::TilePaintingManager::ToggleBrushTool | ( | ) |
Toggle between DRAW_TILE and MOUSE modes.
Definition at line 519 of file tile_painting_manager.cc.
References yaze::editor::TilePaintingDependencies::current_mode, deps_, yaze::editor::DRAW_TILE, yaze::gui::kEntityManipulation, yaze::gui::kTilePainting, yaze::editor::MOUSE, yaze::editor::TilePaintingDependencies::ow_map_canvas, and yaze::gui::Canvas::SetUsageMode().

| void yaze::editor::TilePaintingManager::ActivateFillTool | ( | ) |
Toggle FILL_TILE mode on/off.
Definition at line 536 of file tile_painting_manager.cc.
References yaze::editor::TilePaintingDependencies::current_mode, deps_, yaze::editor::DRAW_TILE, yaze::editor::FILL_TILE, yaze::gui::kTilePainting, yaze::editor::TilePaintingDependencies::ow_map_canvas, and yaze::gui::Canvas::SetUsageMode().

|
inline |
Last brush preview piece built for map_id: the brush drawn with that map's own tile16 graphics and palette (tests and diagnostics).
Definition at line 91 of file tile_painting_manager.h.
References yaze::gfx::Bitmap::at(), and map_brush_previews_.

|
private |
Definition at line 42 of file tile_painting_manager.cc.
References deps_, yaze::gui::Canvas::global_scale(), yaze::editor::kTile16Size, and yaze::editor::TilePaintingDependencies::ow_map_canvas.
Referenced by CheckForOverworldEdits(), CheckForSelectRectangle(), and PasteBrush().

|
private |
Definition at line 60 of file tile_painting_manager.cc.
References yaze::editor::TilePaintingDependencies::current_world, deps_, WorldTiles(), yaze::editor::TilePaintingManager::TilePosition::x, and yaze::editor::TilePaintingManager::TilePosition::y.
Referenced by CaptureSelection(), CheckForOverworldEdits(), CheckForSelectRectangle(), DrawBrushPreview(), PaintPattern(), and PaintTile().

|
private |
Definition at line 38 of file tile_painting_manager.cc.
References yaze::editor::TilePaintingDependencies::current_world, deps_, yaze::zelda3::Overworld::GetMapTiles(), and yaze::editor::TilePaintingDependencies::overworld.
Referenced by CaptureSelection(), CheckForSelectRectangle(), IsValidTile(), and PaintTile().

|
private |
Definition at line 269 of file tile_painting_manager.cc.
References brush_, yaze::editor::TilePaintingDependencies::current_world, deps_, IsValidTile(), yaze::editor::kTile16Size, yaze::editor::TilePaintingDependencies::ow_map_canvas, yaze::gui::Canvas::selected_points(), yaze::editor::TilePaintingDependencies::selected_tile16_ids, yaze::editor::TileBrush::tile_ids, and WorldTiles().
Referenced by CheckForSelectRectangle().

|
private |
Definition at line 351 of file tile_painting_manager.cc.
References yaze::editor::TileBrush::at(), yaze::gfx::Tilemap::atlas, yaze::editor::BuildMapBrushPreview(), yaze::editor::TilePaintingDependencies::current_world, deps_, yaze::zelda3::Overworld::EnsureMapBuilt(), yaze::editor::TileBrush::height, IsValidTile(), yaze::editor::kTile16Size, map_brush_previews_, yaze::gui::Canvas::mutable_selected_points(), yaze::editor::TilePaintingDependencies::overworld, yaze::zelda3::Overworld::overworld_map(), yaze::editor::TilePaintingDependencies::ow_map_canvas, yaze::editor::SyncMapBrushPreview(), yaze::editor::TilePaintingDependencies::tile16_blockset, yaze::editor::TileBrush::width, yaze::gfx::Bitmap::width(), yaze::editor::TilePaintingManager::TilePosition::x, and yaze::editor::TilePaintingManager::TilePosition::y.
Referenced by CheckForOverworldEdits(), and CheckForSelectRectangle().
|
private |
Definition at line 215 of file tile_painting_manager.cc.
References yaze::gfx::Tilemap::atlas, deps_, yaze::gfx::GetTilemapData(), yaze::gfx::Bitmap::is_active(), yaze::editor::TilePaintingDependencies::overworld, yaze::zelda3::Overworld::overworld_map(), yaze::editor::TilePaintingDependencies::tile16_blockset, and yaze::editor::Tile16PixelsFromBlockset().
Referenced by PaintTile().

|
private |
Definition at line 143 of file tile_painting_manager.cc.
References yaze::editor::TileBrush::at(), callbacks_, yaze::editor::TilePaintingDependencies::current_map, yaze::editor::TilePaintingDependencies::current_world, deps_, yaze::editor::TilePaintingCallbacks::finalize_paint_operation, yaze::gfx::Arena::Get(), yaze::editor::TileBrush::height, IsValidTile(), yaze::zelda3::kNumOverworldMaps, yaze::editor::TilePaintingDependencies::maps_bmp, PaintTile(), yaze::gfx::Arena::QueueTextureCommand(), yaze::editor::TilePaintingCallbacks::refresh_overworld_map_on_demand, yaze::editor::TilePaintingDependencies::rom, yaze::editor::TilePaintingCallbacks::select_map_for_editing, yaze::Rom::set_dirty(), single_paint_pending_, yaze::gfx::Arena::UPDATE, yaze::editor::TileBrush::valid(), yaze::editor::TileBrush::width, yaze::editor::TilePaintingManager::TilePosition::x, and yaze::editor::TilePaintingManager::TilePosition::y.
Referenced by CheckForOverworldEdits(), and PasteBrush().
|
private |
Definition at line 189 of file tile_painting_manager.cc.
References callbacks_, yaze::editor::TilePaintingCallbacks::create_undo_point, yaze::editor::TilePaintingDependencies::current_world, deps_, IsValidTile(), yaze::editor::TilePaintingDependencies::maps_bmp, RenderMapTile(), Tile16PixelsForMap(), WorldTiles(), yaze::editor::TilePaintingManager::TilePosition::x, and yaze::editor::TilePaintingManager::TilePosition::y.
Referenced by PaintPattern().

|
private |
Definition at line 232 of file tile_painting_manager.cc.
References deps_, yaze::editor::kOverworldMapSize, yaze::editor::kTile16Size, yaze::editor::TilePaintingDependencies::maps_bmp, yaze::editor::TilePaintingManager::TilePosition::x, and yaze::editor::TilePaintingManager::TilePosition::y.
Referenced by PaintTile(), and RenderUpdatedMapBitmap().
|
private |
Definition at line 119 of file tile_painting_manager.h.
Referenced by ActivateFillTool(), CaptureSelection(), CheckForOverworldEdits(), CheckForSelectRectangle(), DrawBrushPreview(), HoveredTile(), IsValidTile(), PaintPattern(), PaintTile(), PasteBrush(), PickTile16FromHoveredCanvas(), RenderMapTile(), RenderUpdatedMapBitmap(), selection_brush(), Tile16PixelsForMap(), ToggleBrushTool(), and WorldTiles().
|
private |
Definition at line 120 of file tile_painting_manager.h.
Referenced by CheckForOverworldEdits(), CheckForSelectRectangle(), PaintPattern(), PaintTile(), and PickTile16FromHoveredCanvas().
|
private |
Definition at line 121 of file tile_painting_manager.h.
Referenced by CheckForOverworldEdits().
|
private |
Definition at line 122 of file tile_painting_manager.h.
Referenced by CheckForOverworldEdits(), and PaintPattern().
|
private |
Definition at line 123 of file tile_painting_manager.h.
Referenced by CheckForSelectRectangle().
|
private |
Definition at line 124 of file tile_painting_manager.h.
Referenced by CaptureSelection(), CheckForSelectRectangle(), and selection_brush().
|
private |
Definition at line 125 of file tile_painting_manager.h.
Referenced by DrawBrushPreview(), and map_brush_preview().