Skip to content

Commit

Permalink
Use golden color to highlight cells that are sometimes possible to edit
Browse files Browse the repository at this point in the history
relates to #6845
  • Loading branch information
ihhub committed May 19, 2024
1 parent 98e65cd commit 3f65b8d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/fheroes2/editor/editor_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,12 +655,16 @@ namespace Interface
if ( brushSize.width > 0 && brushSize.height > 0 ) {
const fheroes2::Point indices = getBrushAreaIndicies( brushSize, _tileUnderCursor );

_gameArea.renderTileAreaSelect( display, indices.x, indices.y );
assert( Maps::isValidAbsIndex( indices.x ) );
const bool isActionObject = MP2::isOffGameActionObject( world.GetTiles( indices.x ).GetObject() );
const bool isRenderForActionObject = ( isActionObject && brushSize.width == 1 && brushSize.height == 1 && _editorPanel.isDetailEdit() );

_gameArea.renderTileAreaSelect( display, indices.x, indices.y, isRenderForActionObject );
}
else if ( _editorPanel.isTerrainEdit() || _editorPanel.isEraseMode() ) {
assert( brushSize == fheroes2::Rect() );
// Render area selection from the tile where the left mouse button was pressed till the tile under the cursor.
_gameArea.renderTileAreaSelect( display, _selectedTile, _tileUnderCursor );
_gameArea.renderTileAreaSelect( display, _selectedTile, _tileUnderCursor, false );
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/fheroes2/gui/interface_gamearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ void Interface::GameArea::Redraw( fheroes2::Image & dst, int flag, bool isPuzzle
updateObjectAnimationInfo();
}

void Interface::GameArea::renderTileAreaSelect( fheroes2::Image & dst, const int32_t startTile, const int32_t endTile ) const
void Interface::GameArea::renderTileAreaSelect( fheroes2::Image & dst, const int32_t startTile, const int32_t endTile, const bool isActionObject ) const
{
if ( startTile < 0 || endTile < 0 ) {
return;
Expand All @@ -802,10 +802,12 @@ void Interface::GameArea::renderTileAreaSelect( fheroes2::Image & dst, const int
const int32_t limitedLineWidth = std::min( 2, overlappedRoi.width );
const int32_t limitedLineHeight = std::min( 2, overlappedRoi.height );

fheroes2::Fill( dst, overlappedRoi.x, overlappedRoi.y, overlappedRoi.width, limitedLineHeight, 181 );
fheroes2::Fill( dst, overlappedRoi.x, overlappedRoi.y + 2, limitedLineWidth, overlappedRoi.height - 4, 181 );
fheroes2::Fill( dst, overlappedRoi.x, overlappedRoi.y + overlappedRoi.height - limitedLineHeight, overlappedRoi.width, limitedLineHeight, 181 );
fheroes2::Fill( dst, overlappedRoi.x + overlappedRoi.width - limitedLineWidth, overlappedRoi.y + 2, limitedLineWidth, overlappedRoi.height - 4, 181 );
const uint8_t color = ( isActionObject ? 115 : 181 );

fheroes2::Fill( dst, overlappedRoi.x, overlappedRoi.y, overlappedRoi.width, limitedLineHeight, color );
fheroes2::Fill( dst, overlappedRoi.x, overlappedRoi.y + 2, limitedLineWidth, overlappedRoi.height - 4, color );
fheroes2::Fill( dst, overlappedRoi.x, overlappedRoi.y + overlappedRoi.height - limitedLineHeight, overlappedRoi.width, limitedLineHeight, color );
fheroes2::Fill( dst, overlappedRoi.x + overlappedRoi.width - limitedLineWidth, overlappedRoi.y + 2, limitedLineWidth, overlappedRoi.height - 4, color );
}

void Interface::GameArea::updateMapFogDirections()
Expand Down
2 changes: 1 addition & 1 deletion src/fheroes2/gui/interface_gamearea.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ namespace Interface
// Interface::BaseInterface::Redraw() instead to avoid issues in the "no interface" mode
void Redraw( fheroes2::Image & dst, int flag, bool isPuzzleDraw = false ) const;

void renderTileAreaSelect( fheroes2::Image & dst, const int32_t startTile, const int32_t endTile ) const;
void renderTileAreaSelect( fheroes2::Image & dst, const int32_t startTile, const int32_t endTile, const bool isActionObject ) const;

void BlitOnTile( fheroes2::Image & dst, const fheroes2::Image & src, int32_t ox, int32_t oy, const fheroes2::Point & mp, bool flip, uint8_t alpha ) const;

Expand Down

0 comments on commit 3f65b8d

Please sign in to comment.