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

Manages tile painting, fill, selection, and eyedropper operations. More...

#include <tile_painting_manager.h>

Collaboration diagram for yaze::editor::TilePaintingManager:

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_
 

Detailed Description

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.

Member Typedef Documentation

◆ ChangedMaps

Definition at line 138 of file tile_painting_manager.h.

Constructor & Destructor Documentation

◆ TilePaintingManager()

yaze::editor::TilePaintingManager::TilePaintingManager ( const TilePaintingDependencies & deps,
const TilePaintingCallbacks & callbacks )

Definition at line 31 of file tile_painting_manager.cc.

Member Function Documentation

◆ CheckForOverworldEdits()

◆ SuspendCanvasGestures()

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_.

Here is the call graph for this function:

◆ CheckForSelectRectangle()

◆ selection_brush()

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().

Here is the call graph for this function:

◆ SetSelectionBrush()

void yaze::editor::TilePaintingManager::SetSelectionBrush ( TileBrush brush)

◆ ClearSelectionBrush()

void yaze::editor::TilePaintingManager::ClearSelectionBrush ( )

◆ PasteBrush()

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.

◆ PlaceBrushAt()

absl::Status yaze::editor::TilePaintingManager::PlaceBrushAt ( const TileBrush & brush,
int x,
int y )
inline

Definition at line 103 of file tile_painting_manager.h.

References FinalizePendingPaint(), yaze::editor::TileBrush::height, PaintPattern(), and yaze::editor::TileBrush::width.

Here is the call graph for this function:

◆ ApplyGuardedCells()

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.

◆ RenderUpdatedMapBitmap()

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

◆ PickTile16FromHoveredCanvas()

◆ ToggleBrushTool()

void yaze::editor::TilePaintingManager::ToggleBrushTool ( )

◆ ActivateFillTool()

void yaze::editor::TilePaintingManager::ActivateFillTool ( )

◆ map_brush_preview()

const gfx::Bitmap & yaze::editor::TilePaintingManager::map_brush_preview ( int map_id) const
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_.

Here is the call graph for this function:

◆ HoveredTile()

TilePaintingManager::TilePosition yaze::editor::TilePaintingManager::HoveredTile ( ) const
private

◆ AllocatedRowsForWorld()

int yaze::editor::TilePaintingManager::AllocatedRowsForWorld ( int world) const
private

◆ IsValidMapGridPosition()

bool yaze::editor::TilePaintingManager::IsValidMapGridPosition ( int world,
int map_x,
int map_y ) const
private

Definition at line 63 of file tile_painting_manager.cc.

References AllocatedRowsForWorld().

Referenced by DrawBrushPreview(), and ReadTile().

Here is the call graph for this function:

◆ IsProjectTile()

◆ ReadTile()

◆ IsValidTile()

bool yaze::editor::TilePaintingManager::IsValidTile ( TilePosition position) const
private

Definition at line 101 of file tile_painting_manager.cc.

References ReadTile().

Referenced by CheckForOverworldEdits(), DrawBrushPreview(), PaintPattern(), and PaintTile().

Here is the call graph for this function:

◆ FinalizePendingPaint()

◆ WorldTiles()

std::vector< std::vector< uint16_t > > & yaze::editor::TilePaintingManager::WorldTiles ( ) const
private

◆ CaptureSelection()

◆ DrawBrushPreview()

◆ Tile16PixelsForMap()

std::vector< uint8_t > yaze::editor::TilePaintingManager::Tile16PixelsForMap ( int map_id,
int tile_id ) const
private

◆ PaintPattern()

◆ PaintTile()

◆ RefreshChangedMaps()

void yaze::editor::TilePaintingManager::RefreshChangedMaps ( const ChangedMaps & changed_maps)
private

◆ RenderMapTile()

void yaze::editor::TilePaintingManager::RenderMapTile ( int map_id,
TilePosition position,
const std::vector< uint8_t > & tile_data )
private

Member Data Documentation

◆ deps_

◆ callbacks_

◆ paint_gesture_owned_

bool yaze::editor::TilePaintingManager::paint_gesture_owned_ = false
private

◆ single_paint_pending_

bool yaze::editor::TilePaintingManager::single_paint_pending_ = false
private

Definition at line 166 of file tile_painting_manager.h.

Referenced by FinalizePendingPaint(), and PaintPattern().

◆ project_paint_pending_

bool yaze::editor::TilePaintingManager::project_paint_pending_ = false
private

Definition at line 167 of file tile_painting_manager.h.

Referenced by FinalizePendingPaint(), and PaintPattern().

◆ gesture_project_

bool yaze::editor::TilePaintingManager::gesture_project_ = false
private

Definition at line 168 of file tile_painting_manager.h.

Referenced by CheckForOverworldEdits().

◆ gesture_world_

int yaze::editor::TilePaintingManager::gesture_world_ = 0
private

Definition at line 169 of file tile_painting_manager.h.

Referenced by CheckForOverworldEdits().

◆ gesture_mode_

EditingMode yaze::editor::TilePaintingManager::gesture_mode_ = EditingMode::DRAW_TILE
private

Definition at line 170 of file tile_painting_manager.h.

Referenced by CheckForOverworldEdits().

◆ selection_gesture_owned_

bool yaze::editor::TilePaintingManager::selection_gesture_owned_ = false
private

Definition at line 171 of file tile_painting_manager.h.

Referenced by CheckForSelectRectangle(), and SuspendCanvasGestures().

◆ external_brush_active_

bool yaze::editor::TilePaintingManager::external_brush_active_ = false
private

◆ brush_

TileBrush yaze::editor::TilePaintingManager::brush_
private

◆ map_brush_previews_

std::array<gfx::Bitmap, zelda3::kNumOverworldMaps> yaze::editor::TilePaintingManager::map_brush_previews_
private

Definition at line 174 of file tile_painting_manager.h.

Referenced by DrawBrushPreview(), and map_brush_preview().


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