Skip to content

Commit

Permalink
fixed outofbounds highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Storost committed Jul 6, 2024
1 parent f828485 commit 7191579
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions source/GM-TE/GMTEEditorTileMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,24 @@ GMTEEditorTileMap >> model: anObject [

{
#category : #'event handling',
#'squeak_changestamp' : 'Valentin Teutschbein 7/6/2024 13:13'
#'squeak_changestamp' : 'JS 7/6/2024 14:23'
}
GMTEEditorTileMap >> mouseDown: anEvent [
"Implements placement of tiles"

| selectedCoordinates activeLayer |
self model singleLayerSelected
ifTrue: [
activeLayer := self model selectedLayers anyOne.

selectedCoordinates := self model brush executeWithMatrixIndex: (self tileIndexFromPosition: anEvent position).
self updateTiles: selectedCoordinates inLayer: activeLayer FromEvent: anEvent].
self model singleLayerSelected ifFalse: [^nil].
activeLayer := self model selectedLayers anyOne.

selectedCoordinates := self model brush executeWithMatrixIndex: (self tileIndexFromPosition: anEvent position).
self updateTiles: selectedCoordinates inLayer: activeLayer FromEvent: anEvent.

^ true
]

{
#category : #'event handling',
#'squeak_changestamp' : 'Valentin Teutschbein 7/6/2024 13:17'
#'squeak_changestamp' : 'JS 7/6/2024 14:31'
}
GMTEEditorTileMap >> mouseMove: anEvent [
"Implements highlighting of tiles when hovering"
Expand All @@ -141,13 +140,16 @@ GMTEEditorTileMap >> mouseMove: anEvent [

activeLayer := self model selectedLayers anyOne.
selectedCoordinates := self model brush executeWithMatrixIndex: (self tileIndexFromPosition: anEvent position).

self tileSelectionSet clearAllHighlightings.

selectedCoordinates ifNil: [
self tileSelectionSet clearAllHighlightings.
^ nil].
self tileSelectionSet clearAllHighlightings.
selectedCoordinates do: [:c|

(selectedCoordinates select: [:c | (self tileMatrixStack layer: activeLayer) inBounds: c]) do: [:c|
hoveredTileHighlighting := self highlightingTileFromIndex: c.
hoveredTileHighlighting ifNotNil: [self tileSelectionSet highlightTile: hoveredTileHighlighting]].

self updateTiles: selectedCoordinates inLayer: activeLayer FromEvent: anEvent.
]

Expand Down

0 comments on commit 7191579

Please sign in to comment.