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 | SuspendCanvasGestures () |
| 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. | |
| void | SetSelectionBrush (TileBrush brush) |
| void | ClearSelectionBrush () |
| absl::Status | PasteBrush (const TileBrush &brush) |
| absl::Status | PlaceBrushAt (const TileBrush &brush, int x, int y) |
| absl::StatusOr< int > | ApplyGuardedCells (int map_id, const std::vector< GuardedTileCell > &cells) |
| 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 |
| int | AllocatedRowsForWorld (int world) const |
| bool | IsValidMapGridPosition (int world, int map_x, int map_y) const |
| bool | IsProjectTile (TilePosition position) const |
| absl::StatusOr< uint16_t > | ReadTile (TilePosition position) const |
| bool | IsValidTile (TilePosition position) const |
| void | FinalizePendingPaint () |
| 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 |
| absl::Status | PaintPattern (const TileBrush &brush, TilePosition anchor, int width, int height, bool finalize=true) |
| bool | PaintTile (TilePosition position, int tile_id, ChangedMaps &changed_maps) |
| void | RefreshChangedMaps (const 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 | project_paint_pending_ = false |
| bool | gesture_project_ = false |
| int | gesture_world_ = 0 |
| EditingMode | gesture_mode_ = EditingMode::DRAW_TILE |
| bool | selection_gesture_owned_ = false |
| bool | external_brush_active_ = 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 79 of file tile_painting_manager.h.
|
private |
Definition at line 138 of file tile_painting_manager.h.
| yaze::editor::TilePaintingManager::TilePaintingManager | ( | const TilePaintingDependencies & | deps, |
| const TilePaintingCallbacks & | callbacks ) |
Definition at line 31 of file tile_painting_manager.cc.
| void yaze::editor::TilePaintingManager::CheckForOverworldEdits | ( | ) |
Main entry point: check for tile edits (paint, fill, stamp).
Definition at line 149 of file tile_painting_manager.cc.
References CheckForSelectRectangle(), yaze::editor::TilePaintingDependencies::current_mode, yaze::editor::TilePaintingDependencies::current_tile16, yaze::editor::TilePaintingDependencies::current_world, deps_, yaze::editor::DRAW_TILE, DrawBrushPreview(), yaze::editor::FILL_TILE, FinalizePendingPaint(), gesture_mode_, gesture_project_, gesture_world_, HoveredTile(), IsProjectTile(), IsValidTile(), yaze::editor::kTile16Size, yaze::editor::TilePaintingDependencies::ow_map_canvas, paint_gesture_owned_, PaintPattern(), selection_brush(), and yaze::editor::TilePaintingManager::TilePosition::x.
| void yaze::editor::TilePaintingManager::SuspendCanvasGestures | ( | ) |
Finish pending painting before another tool owns the canvas. Releases may occur while that tool handles input, so discard gesture ownership without discarding an already captured tile brush.
Definition at line 143 of file tile_painting_manager.cc.
References FinalizePendingPaint(), paint_gesture_owned_, and selection_gesture_owned_.

| void yaze::editor::TilePaintingManager::CheckForSelectRectangle | ( | ) |
Draw and create the tile16 IDs that are currently selected.
Definition at line 491 of file tile_painting_manager.cc.
References brush_, callbacks_, CaptureSelection(), yaze::editor::TilePaintingDependencies::current_map, yaze::editor::TilePaintingDependencies::current_tile16, deps_, DrawBrushPreview(), external_brush_active_, HoveredTile(), yaze::editor::kTile16Size, yaze::editor::TilePaintingDependencies::ow_map_canvas, ReadTile(), 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(), and selection_gesture_owned_.
Referenced by CheckForOverworldEdits().
| const TileBrush * yaze::editor::TilePaintingManager::selection_brush | ( | ) | const |
The captured selection, independent of its source or preview position.
Definition at line 105 of file tile_painting_manager.cc.
References brush_, deps_, external_brush_active_, yaze::editor::TilePaintingDependencies::ow_map_canvas, yaze::gui::Canvas::select_rect_active(), and yaze::editor::TileBrush::valid().
Referenced by CheckForOverworldEdits(), and CheckForSelectRectangle().

| void yaze::editor::TilePaintingManager::SetSelectionBrush | ( | TileBrush | brush | ) |
Definition at line 113 of file tile_painting_manager.cc.
References brush_, deps_, external_brush_active_, yaze::editor::TilePaintingDependencies::selected_tile16_ids, yaze::editor::TileBrush::tile_ids, and yaze::editor::TileBrush::valid().

| void yaze::editor::TilePaintingManager::ClearSelectionBrush | ( | ) |
Definition at line 121 of file tile_painting_manager.cc.
References brush_, yaze::gui::Canvas::ClearSelection(), deps_, external_brush_active_, yaze::editor::TilePaintingDependencies::ow_map_canvas, and yaze::editor::TilePaintingDependencies::selected_tile16_ids.

| 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 220 of file tile_painting_manager.cc.
References deps_, FinalizePendingPaint(), 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.
|
inline |
Definition at line 103 of file tile_painting_manager.h.
References FinalizePendingPaint(), yaze::editor::TileBrush::height, PaintPattern(), and yaze::editor::TileBrush::width.

| absl::StatusOr< int > yaze::editor::TilePaintingManager::ApplyGuardedCells | ( | int | map_id, |
| const std::vector< GuardedTileCell > & | cells ) |
Write every cell of one ROM map in the displayed world as a single undo step, or none of them: any cell whose live Tile16 differs from expected refuses the whole stencil. Returns the number of cells changed.
Definition at line 288 of file tile_painting_manager.cc.
References callbacks_, yaze::editor::TilePaintingDependencies::current_world, deps_, yaze::editor::TilePaintingCallbacks::finalize_paint_operation, FinalizePendingPaint(), IsProjectTile(), yaze::zelda3::kNumOverworldMaps, yaze::zelda3::kNumTile16Individual, PaintTile(), ReadTile(), RefreshChangedMaps(), yaze::editor::TilePaintingDependencies::rom, yaze::Rom::set_dirty(), and yaze::editor::TilePaintingManager::TilePosition::x.
| 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 437 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 639 of file tile_painting_manager.cc.
References callbacks_, yaze::editor::TilePaintingDependencies::current_tile16, deps_, HoveredTile(), yaze::gui::Canvas::IsMouseHovering(), yaze::util::logf(), yaze::editor::TilePaintingDependencies::ow_map_canvas, ReadTile(), 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 669 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 686 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 129 of file tile_painting_manager.h.
References yaze::gfx::Bitmap::at(), and map_brush_previews_.

|
private |
Definition at line 39 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(), PasteBrush(), and PickTile16FromHoveredCanvas().

|
private |
Definition at line 57 of file tile_painting_manager.cc.
References yaze::editor::TilePaintingCallbacks::allocated_rows, and callbacks_.
Referenced by CaptureSelection(), and IsValidMapGridPosition().
|
private |
Definition at line 63 of file tile_painting_manager.cc.
References AllocatedRowsForWorld().
Referenced by DrawBrushPreview(), and ReadTile().

|
private |
Definition at line 69 of file tile_painting_manager.cc.
References callbacks_, yaze::editor::TilePaintingDependencies::current_world, deps_, yaze::editor::TilePaintingCallbacks::is_project_tile, yaze::editor::TilePaintingManager::TilePosition::x, and yaze::editor::TilePaintingManager::TilePosition::y.
Referenced by ApplyGuardedCells(), CheckForOverworldEdits(), DrawBrushPreview(), PaintPattern(), PaintTile(), and ReadTile().
|
private |
Definition at line 75 of file tile_painting_manager.cc.
References callbacks_, yaze::editor::TilePaintingDependencies::current_world, deps_, IsProjectTile(), IsValidMapGridPosition(), yaze::zelda3::kNumOverworldMaps, yaze::editor::TilePaintingCallbacks::read_project_tile, WorldTiles(), yaze::editor::TilePaintingManager::TilePosition::x, and yaze::editor::TilePaintingManager::TilePosition::y.
Referenced by ApplyGuardedCells(), CaptureSelection(), CheckForSelectRectangle(), IsValidTile(), and PickTile16FromHoveredCanvas().

|
private |
Definition at line 101 of file tile_painting_manager.cc.
References ReadTile().
Referenced by CheckForOverworldEdits(), DrawBrushPreview(), PaintPattern(), and PaintTile().

|
private |
Definition at line 132 of file tile_painting_manager.cc.
References callbacks_, yaze::editor::TilePaintingCallbacks::finalize_paint_operation, yaze::editor::TilePaintingCallbacks::finalize_project_paint, project_paint_pending_, and single_paint_pending_.
Referenced by ApplyGuardedCells(), CheckForOverworldEdits(), PaintPattern(), PasteBrush(), PlaceBrushAt(), and SuspendCanvasGestures().
|
private |
Definition at line 35 of file tile_painting_manager.cc.
References yaze::editor::TilePaintingDependencies::current_world, deps_, yaze::zelda3::Overworld::GetMapTiles(), and yaze::editor::TilePaintingDependencies::overworld.
Referenced by PaintTile(), and ReadTile().

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

|
private |
Definition at line 537 of file tile_painting_manager.cc.
References yaze::editor::TileBrush::at(), yaze::gfx::Tilemap::atlas, yaze::editor::BuildMapBrushPreview(), callbacks_, yaze::editor::TilePaintingDependencies::current_world, deps_, yaze::zelda3::Overworld::EnsureMapBuilt(), yaze::editor::TileBrush::height, IsProjectTile(), IsValidMapGridPosition(), IsValidTile(), yaze::zelda3::kNumOverworldMaps, 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::TilePaintingCallbacks::project_tile_atlas, 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 398 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 231 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, FinalizePendingPaint(), yaze::editor::TileBrush::height, IsProjectTile(), IsValidTile(), paint_gesture_owned_, yaze::editor::TilePaintingCallbacks::paint_project_pattern, PaintTile(), project_paint_pending_, RefreshChangedMaps(), yaze::editor::TilePaintingDependencies::rom, yaze::editor::TilePaintingCallbacks::select_map_for_editing, yaze::Rom::set_dirty(), single_paint_pending_, yaze::editor::TileBrush::valid(), yaze::editor::TileBrush::width, yaze::editor::TilePaintingManager::TilePosition::x, and yaze::editor::TilePaintingManager::TilePosition::y.
Referenced by CheckForOverworldEdits(), PasteBrush(), and PlaceBrushAt().
|
private |
Definition at line 372 of file tile_painting_manager.cc.
References callbacks_, yaze::editor::TilePaintingCallbacks::create_undo_point, yaze::editor::TilePaintingDependencies::current_world, deps_, IsProjectTile(), IsValidTile(), yaze::editor::TilePaintingDependencies::maps_bmp, RenderMapTile(), Tile16PixelsForMap(), WorldTiles(), yaze::editor::TilePaintingManager::TilePosition::x, and yaze::editor::TilePaintingManager::TilePosition::y.
Referenced by ApplyGuardedCells(), and PaintPattern().
|
private |
Definition at line 360 of file tile_painting_manager.cc.
References callbacks_, deps_, yaze::gfx::Arena::Get(), yaze::zelda3::kNumOverworldMaps, yaze::editor::TilePaintingDependencies::maps_bmp, yaze::gfx::Arena::QueueTextureCommand(), yaze::editor::TilePaintingCallbacks::refresh_overworld_map_on_demand, and yaze::gfx::Arena::UPDATE.
Referenced by ApplyGuardedCells(), and PaintPattern().

|
private |
Definition at line 415 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 163 of file tile_painting_manager.h.
Referenced by ActivateFillTool(), ApplyGuardedCells(), CaptureSelection(), CheckForOverworldEdits(), CheckForSelectRectangle(), ClearSelectionBrush(), DrawBrushPreview(), HoveredTile(), IsProjectTile(), PaintPattern(), PaintTile(), PasteBrush(), PickTile16FromHoveredCanvas(), ReadTile(), RefreshChangedMaps(), RenderMapTile(), RenderUpdatedMapBitmap(), selection_brush(), SetSelectionBrush(), Tile16PixelsForMap(), ToggleBrushTool(), and WorldTiles().
|
private |
Definition at line 164 of file tile_painting_manager.h.
Referenced by AllocatedRowsForWorld(), ApplyGuardedCells(), CheckForSelectRectangle(), DrawBrushPreview(), FinalizePendingPaint(), IsProjectTile(), PaintPattern(), PaintTile(), PickTile16FromHoveredCanvas(), ReadTile(), and RefreshChangedMaps().
|
private |
Definition at line 165 of file tile_painting_manager.h.
Referenced by CheckForOverworldEdits(), PaintPattern(), and SuspendCanvasGestures().
|
private |
Definition at line 166 of file tile_painting_manager.h.
Referenced by FinalizePendingPaint(), and PaintPattern().
|
private |
Definition at line 167 of file tile_painting_manager.h.
Referenced by FinalizePendingPaint(), and PaintPattern().
|
private |
Definition at line 168 of file tile_painting_manager.h.
Referenced by CheckForOverworldEdits().
|
private |
Definition at line 169 of file tile_painting_manager.h.
Referenced by CheckForOverworldEdits().
|
private |
Definition at line 170 of file tile_painting_manager.h.
Referenced by CheckForOverworldEdits().
|
private |
Definition at line 171 of file tile_painting_manager.h.
Referenced by CheckForSelectRectangle(), and SuspendCanvasGestures().
|
private |
Definition at line 172 of file tile_painting_manager.h.
Referenced by CheckForSelectRectangle(), ClearSelectionBrush(), selection_brush(), and SetSelectionBrush().
|
private |
Definition at line 173 of file tile_painting_manager.h.
Referenced by CaptureSelection(), CheckForSelectRectangle(), ClearSelectionBrush(), selection_brush(), and SetSelectionBrush().
|
private |
Definition at line 174 of file tile_painting_manager.h.
Referenced by DrawBrushPreview(), and map_brush_preview().