@@ -22,6 +22,15 @@ GMTEEditorTileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPaddi
22
22
model: aModel
23
23
]
24
24
25
+ {
26
+ #category : #accessing ,
27
+ #' squeak_changestamp' : ' JS 7/12/2024 14:48'
28
+ }
29
+ GMTEEditorTileMap >> brush [
30
+
31
+ ^ model brush
32
+ ]
33
+
25
34
{
26
35
#category : #accessing ,
27
36
#' squeak_changestamp' : ' Valentin Teutschbein 7/12/2024 14:15'
@@ -85,6 +94,22 @@ GMTEEditorTileMap >> handlesMouseOver: anEvent [
85
94
^ true
86
95
]
87
96
97
+ {
98
+ #category : #' event handling' ,
99
+ #' squeak_changestamp' : ' JS 7/12/2024 15:15'
100
+ }
101
+ GMTEEditorTileMap >> highlightTilesFromIndices: anIndexSet [
102
+
103
+ | hoveredHighlightingTile |
104
+ self tileSelectionSet clearAllHighlightings.
105
+ anIndexSet ifNil: [^ nil ].
106
+
107
+ (anIndexSet select: [:c |
108
+ (self tileMatrixStack layer: self model selectedLayers anyOne) inBounds: c]) do: [:t |
109
+ hoveredHighlightingTile := self highlightingTileFromIndex: t.
110
+ hoveredHighlightingTile ifNotNil: [self tileSelectionSet highlightTile: hoveredHighlightingTile]]
111
+ ]
112
+
88
113
{
89
114
#category : #initialization ,
90
115
#' squeak_changestamp' : ' Alex M 6/28/2024 20:24'
@@ -118,71 +143,64 @@ GMTEEditorTileMap >> model: anObject [
118
143
119
144
{
120
145
#category : #' event handling' ,
121
- #' squeak_changestamp' : ' JS 7/11 /2024 14:13 '
146
+ #' squeak_changestamp' : ' JS 7/12 /2024 15:19 '
122
147
}
123
148
GMTEEditorTileMap >> mouseDown: anEvent [
124
- " Implements placement of tiles"
125
149
126
150
| selectedIndex |
127
- self flag: ' refactor; method extraction for "Add tiles to layer" to minimize redundancy with mouseMove? ' .
128
- self model singleLayerSelected ifFalse: [ ^ nil ].
151
+ self model singleLayerSelected ifFalse: [ ^ nil ] .
152
+
129
153
selectedIndex := self tileIndexFromPosition: anEvent position.
130
- self model brush firstMatrixIndex: selectedIndex.
131
- self model brush executeWithMatrixIndex: selectedIndex andLayer: (self tileMatrixStack layer: self model selectedLayers anyOne).
132
- anEvent yellowButtonPressed ifTrue: [self tileSelectionSet highlightImage: nil ].
154
+ self brush firstMatrixIndex: selectedIndex.
133
155
134
- ^ true
156
+ self brush executeWithMatrixIndex: selectedIndex andLayer: (self tileMatrixStack layer: self selectedLayers anyOne).
157
+ anEvent yellowButtonPressed ifTrue: [self tileSelectionSet highlightImage: nil ]
135
158
]
136
159
137
160
{
138
161
#category : #' event handling' ,
139
- #' squeak_changestamp' : ' Ivo Zilkenat 7/11 /2024 17 :18'
162
+ #' squeak_changestamp' : ' JS 7/12 /2024 15 :18'
140
163
}
141
164
GMTEEditorTileMap >> mouseLeave: anEvent [
142
165
143
- self tileSelectionSet clearAllHighlightings.
144
-
145
- ^ true
166
+ self tileSelectionSet clearAllHighlightings
146
167
]
147
168
148
169
{
149
170
#category : #' event handling' ,
150
- #' squeak_changestamp' : ' Ivo Zilkenat 7/11 /2024 17:01 '
171
+ #' squeak_changestamp' : ' JS 7/12 /2024 15:17 '
151
172
}
152
173
GMTEEditorTileMap >> mouseMove: anEvent [
153
174
" Implements highlighting of tiles when hovering"
154
175
155
- | hoveredTileHighlighting activeLayer selectedCoordinates |
176
+ | activeLayer selectedIndices |
156
177
self model singleLayerSelected ifFalse: [^ nil ].
157
178
158
- activeLayer := self model selectedLayers anyOne.
159
- selectedCoordinates := self model brush executeWithMatrixIndex: (self tileIndexFromPosition: anEvent position) andLayer: (self tileMatrixStack layer: activeLayer).
160
- (anEvent redButtonPressed or : [anEvent yellowButtonPressed]) ifFalse: [self model brush resetOutputSet].
161
- self tileSelectionSet clearAllHighlightings.
179
+ activeLayer := self tileMatrixStack layer: self model selectedLayers anyOne.
180
+ selectedIndices := self model brush executeWithMatrixIndex: (self tileIndexFromPosition: anEvent position) andLayer: activeLayer.
162
181
163
- selectedCoordinates ifNil : [^ nil ].
182
+ (anEvent redButtonPressed or : [anEvent yellowButtonPressed]) ifFalse: [ self model brush resetOutputSet ].
164
183
165
- (selectedCoordinates select: [:c |
166
- (self tileMatrixStack layer: activeLayer) inBounds: c]) do: [:t |
167
- hoveredTileHighlighting := self highlightingTileFromIndex: t.
168
- hoveredTileHighlighting ifNotNil: [self tileSelectionSet highlightTile: hoveredTileHighlighting]]
184
+ self highlightTilesFromIndices: selectedIndices
169
185
]
170
186
171
187
{
172
188
#category : #' event handling' ,
173
- #' squeak_changestamp' : ' mcjj 7/11 /2024 16:20 '
189
+ #' squeak_changestamp' : ' JS 7/12 /2024 15:23 '
174
190
}
175
191
GMTEEditorTileMap >> mouseUp: anEvent [
176
192
177
- | indicesToAdd activeLayer |
178
- self model brush firstMatrixIndex: nil .
179
- indicesToAdd := self model brush outputSet.
180
- activeLayer := self model selectedLayers anyOne.
181
- self updateTiles: (indicesToAdd asCollection) inLayer: activeLayer FromEvent: anEvent.
193
+ | selectedIndices |
194
+ self brush firstMatrixIndex: nil .
195
+
196
+ selectedIndices := self brush outputSet asCollection.
197
+
198
+ self updateTiles: selectedIndices inLayer: self selectedLayers anyOne FromEvent: anEvent.
182
199
self model brush resetOutputSet.
200
+
183
201
(self previousTileStates isEmpty) ifFalse: [self saveTileEditChanges].
184
- self tileSelectionSet clearAllHighlightings.
185
- self tileSelectionSet highlightImage: (self model selectedTile)
202
+ self tileSelectionSet clearAllHighlightings;
203
+ highlightImage: (self model selectedTile)
186
204
187
205
]
188
206
@@ -317,6 +335,15 @@ GMTEEditorTileMap >> saveTileEditChanges [
317
335
self resetTileEditChanges.
318
336
]
319
337
338
+ {
339
+ #category : #accessing ,
340
+ #' squeak_changestamp' : ' JS 7/12/2024 14:49'
341
+ }
342
+ GMTEEditorTileMap >> selectedLayers [
343
+
344
+ ^ model selectedLayers
345
+ ]
346
+
320
347
{
321
348
#category : #accessing ,
322
349
#' squeak_changestamp' : ' jj 6/23/2024 13:35'
0 commit comments