Skip to content

Commit 96ed5a3

Browse files
committed
Merge origin/tmm-dev into tmm-dev
2 parents 8328d97 + 7a56ec3 commit 96ed5a3

12 files changed

+287
-255
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Class {
2+
#name : #GMTEBlendLayersCommand,
3+
#superclass : #GMTETilemapSizeCommand,
4+
#category : #'GM-TE-UI'
5+
}

source/GM-TE/GMTECompositeCommand.class.st

Lines changed: 0 additions & 53 deletions
This file was deleted.

source/GM-TE/GMTEDeleteLayersCommand.class.st

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Class {
22
#name : #GMTEDeleteLayersCommand,
3-
#superclass : #GMTEEditTilesCommand,
3+
#superclass : #GMTETilemapSizeCommand,
44
#instVars : [
55
'layers'
66
],
@@ -9,13 +9,15 @@ Class {
99

1010
{
1111
#category : #'as yet unclassified',
12-
#'squeak_changestamp' : 'Alex M 7/10/2024 04:21'
12+
#'squeak_changestamp' : 'Alex M 7/12/2024 18:57'
1313
}
1414
GMTEDeleteLayersCommand class >> fromLayers: aLayerList editor: anEditor [
1515

1616
^ (self new)
1717
layers: ((SortedCollection sortBlock: [:a :b | a < b]) addAll: aLayerList; yourself);
1818
editor: anEditor;
19+
newSize: 0 @ 0;
20+
saveTiles;
1921
yourself
2022
]
2123

@@ -47,9 +49,10 @@ GMTEDeleteLayersCommand >> layers: anObject [
4749

4850
{
4951
#category : #execution,
50-
#'squeak_changestamp' : 'Alex M 7/10/2024 04:05'
52+
#'squeak_changestamp' : 'Alex M 7/12/2024 18:55'
5153
}
5254
GMTEDeleteLayersCommand >> undo [
5355

54-
self editor addTilemapLayersAt: self layers
56+
self editor addTilemapLayersAt: self layers.
57+
self restoreTiles
5558
]

source/GM-TE/GMTEEditTilesCommand.class.st

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,23 @@ GMTEEditTilesCommand >> initialize [
7777

7878
{
7979
#category : #execution,
80-
#'squeak_changestamp' : 'Alex M 7/10/2024 13:44'
80+
#'squeak_changestamp' : 'Alex M 7/12/2024 19:47'
8181
}
8282
GMTEEditTilesCommand >> placeTilesFromList: aList [
83-
| tile sprite layer x y |
83+
| tile sprite layer x y tileMap |
8484

85+
tileMap := self tileMap.
8586
aList keysDo: [ :coordinates |
8687
x := coordinates at: 1.
8788
y := coordinates at: 2.
8889
layer := coordinates at: 3.
8990

90-
tile := self tileMap tileMatrixStack layer: layer at: y at: x.
91+
tile := tileMap tileMatrixStack layer: layer at: y at: x.
9192
sprite := aList at: coordinates.
9293
tile
9394
ifNil: [sprite
9495
ifNotNil: [
95-
tile := tileMap generateTileAtlayer: layer x: x y: y stack: self tileMap tileMatrixStack tileType: GMTETile.
96+
tile := tileMap generateTileAtlayer: layer x: x y: y stack: tileMap tileMatrixStack tileType: GMTETile.
9697
tile updateSprite: sprite]]
9798
ifNotNil: [sprite
9899
ifNil: [

source/GM-TE/GMTEEditor.class.st

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,11 @@ GMTEEditor >> associatedMorph [
374374

375375
{
376376
#category : #accessing,
377-
#'squeak_changestamp' : 'TW 6/25/2024 15:55'
377+
#'squeak_changestamp' : 'mcjj 7/12/2024 19:38'
378378
}
379379
GMTEEditor >> associatedMorph: anObject [
380380

381-
associatedMorph := anObject.
381+
associatedMorph := anObject
382382
]
383383

384384
{
@@ -450,11 +450,11 @@ GMTEEditor >> brushButtons [
450450

451451
{
452452
#category : #accessing,
453-
#'squeak_changestamp' : 'TW 7/9/2024 18:19'
453+
#'squeak_changestamp' : 'mcjj 7/12/2024 19:38'
454454
}
455455
GMTEEditor >> brushButtons: anObject [
456456

457-
brushButtons := anObject.
457+
brushButtons := anObject
458458
]
459459

460460
{
@@ -1065,12 +1065,15 @@ GMTEEditor >> exportAsImage [
10651065

10661066
{
10671067
#category : #'menu button functions',
1068-
#'squeak_changestamp' : 'jj 6/23/2024 14:14'
1068+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 19:18'
10691069
}
10701070
GMTEEditor >> exportAsMorph [
10711071
"saves the current tileMap as a .morph file, which allows for reimporting"
10721072

1073-
(self tileMap copy model: nil) saveOnFile.
1073+
((self tileMap veryDeepCopy)
1074+
model: nil;
1075+
resetView
1076+
) saveOnFile.
10741077
self savedSinceModified: true
10751078
]
10761079

@@ -1101,11 +1104,12 @@ GMTEEditor >> exportMenu [
11011104

11021105
{
11031106
#category : #'input handling',
1104-
#'squeak_changestamp' : 'mcjj 7/12/2024 17:12'
1107+
#'squeak_changestamp' : 'mcjj 7/12/2024 19:34'
11051108
}
11061109
GMTEEditor >> filterEvent: aKeyboardEvent for: anObject [
1107-
| key |
1110+
"handles keyboard shortcuts"
11081111

1112+
| key |
11091113
aKeyboardEvent isKeystroke
11101114
ifFalse: [^ aKeyboardEvent].
11111115

@@ -1118,7 +1122,6 @@ GMTEEditor >> filterEvent: aKeyboardEvent for: anObject [
11181122
[$o] -> [self importFromTileset].
11191123
[$g] -> [self toggleGrid].
11201124
[$h] -> [self toggleBackgroundTiles].
1121-
[$r] -> [self rotateSelectedTile].
11221125

11231126
[$a] -> [self addLayer].
11241127
[$n] -> [self renameLayer].
@@ -1129,6 +1132,7 @@ GMTEEditor >> filterEvent: aKeyboardEvent for: anObject [
11291132

11301133
[$z] -> [self undo].
11311134
[$y] -> [self redo].
1135+
[$r] -> [self rotateSelectedTile].
11321136
[$1] -> [self selectRadiusBrush].
11331137
[$2] -> [self selectLineBrush].
11341138
[$3] -> [self selectFillBrush].
@@ -1800,6 +1804,16 @@ GMTEEditor >> renameLayer [
18001804

18011805
]
18021806

1807+
{
1808+
#category : #tilemap,
1809+
#'squeak_changestamp' : 'Alex M 7/12/2024 19:51'
1810+
}
1811+
GMTEEditor >> rescaleGridDimensions: aPoint [
1812+
1813+
(self getGridWidth = aPoint x) ifFalse: [self rescaleGridWidth: aPoint x].
1814+
(self getGridHeight = aPoint y) ifFalse: [self rescaleGridHeight: aPoint y].
1815+
]
1816+
18031817
{
18041818
#category : #tilemap,
18051819
#'squeak_changestamp' : 'Alex M 7/1/2024 21:04'
@@ -2072,38 +2086,37 @@ GMTEEditor >> setBrushRadiusFromText: aText [
20722086

20732087
{
20742088
#category : #tilemap,
2075-
#'squeak_changestamp' : 'Alex M 7/1/2024 21:06'
2089+
#'squeak_changestamp' : 'Alex M 7/12/2024 20:03'
20762090
}
20772091
GMTEEditor >> setGridHeight: aText [
20782092
"adjusts the grid height"
20792093

2080-
| oldHeight newHeight |
2081-
oldHeight := self getGridHeight.
2094+
| oldSize newHeight |
2095+
oldSize := self getGridWidth @ self getGridHeight.
20822096
newHeight := self parseGridSize: aText.
20832097
newHeight ifNotNil: [
20842098
self
2085-
rescaleGridHeight: newHeight;
2086-
addCommand: (GMTETilemapSizeCommand prevValue: oldHeight newValue: newHeight method: #rescaleGridHeight: editor: self)].
2099+
addCommand: (GMTETilemapSizeCommand prevSize: oldSize newSize: oldSize x @ newHeight editor: self);
2100+
rescaleGridHeight: newHeight].
20872101
^ true
20882102

20892103

20902104
]
20912105

20922106
{
20932107
#category : #tilemap,
2094-
#'squeak_changestamp' : 'Alex M 7/1/2024 21:06'
2108+
#'squeak_changestamp' : 'Alex M 7/12/2024 20:06'
20952109
}
20962110
GMTEEditor >> setGridWidth: aText [
20972111
"adjusts the grid width"
2098-
"TODO: Fix visual layer bug"
20992112

2100-
| oldWidth newWidth |
2101-
oldWidth := self getGridWidth.
2113+
| oldSize newWidth |
2114+
oldSize := self getGridWidth @ self getGridHeight.
21022115
newWidth := self parseGridSize: aText.
2103-
oldWidth ifNotNil: [
2116+
newWidth ifNotNil: [
21042117
self
2105-
rescaleGridWidth: newWidth;
2106-
addCommand: (GMTETilemapSizeCommand prevValue: oldWidth newValue: newWidth method: #rescaleGridWidth: editor: self)].
2118+
addCommand: (GMTETilemapSizeCommand prevSize: oldSize newSize: newWidth @ oldSize y editor: self);
2119+
rescaleGridWidth: newWidth].
21072120
^ true
21082121

21092122
]
@@ -2298,7 +2311,7 @@ GMTEEditor >> trayViewer: anObject [
22982311

22992312
{
23002313
#category : #'command processing',
2301-
#'squeak_changestamp' : 'Alex M 7/10/2024 14:17'
2314+
#'squeak_changestamp' : 'Alex M 7/12/2024 19:52'
23022315
}
23032316
GMTEEditor >> undo [
23042317

@@ -2307,10 +2320,8 @@ GMTEEditor >> undo [
23072320
ifTrue: [(self commands at: self currentCommand) undo.
23082321
self
23092322
savedSinceModified: false;
2310-
currentCommand: self currentCommand - 1.
2311-
({GMTETilemapSizeCommand. GMTEDeleteLayersCommand} includes: (self commands at: self currentCommand + 1) class)
2312-
ifTrue: [self redoAllCommandsUntil: self currentCommand].
2313-
self savedSinceModified: false]
2323+
currentCommand: self currentCommand - 1;
2324+
savedSinceModified: false]
23142325
]
23152326

23162327
{

source/GM-TE/GMTEEditorTileMap.class.st

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Class {
1515
}
1616

1717
{
18-
#category : #'as yet unclassified',
18+
#category : #'instance creation',
1919
#'squeak_changestamp' : 'jj 6/23/2024 13:36'
2020
}
2121
GMTEEditorTileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPadding sizeRatio: aRatio model: aModel [
@@ -55,7 +55,7 @@ GMTEEditorTileMap >> currentTileChanges: aTileDictionary [
5555

5656
{
5757
#category : #updating,
58-
#'squeak_changestamp' : 'Alex M 7/12/2024 17:16'
58+
#'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 18:28'
5959
}
6060
GMTEEditorTileMap >> deleteTiles: anIndexSet inLayer: aLayer [
6161
"delete tiles from editable matrix stack at given indices"
@@ -198,12 +198,15 @@ GMTEEditorTileMap >> mouseMove: anEvent [
198198

199199
{
200200
#category : #'event handling',
201-
#'squeak_changestamp' : 'JS 7/12/2024 16:28'
201+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 18:27'
202202
}
203203
GMTEEditorTileMap >> mouseUp: anEvent [
204204
"apply brush operation on tilemap"
205205

206206
| selectedIndices |
207+
"Make sure view is not currently moved. Implies that shift must still be held down"
208+
anEvent shiftPressed ifTrue: [^ nil].
209+
207210
self brush firstMatrixIndex: nil.
208211

209212
selectedIndices := self brush outputSet asCollection.
@@ -220,13 +223,13 @@ GMTEEditorTileMap >> mouseUp: anEvent [
220223

221224
{
222225
#category : #updating,
223-
#'squeak_changestamp' : 'Alex M 7/12/2024 17:15'
226+
#'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 18:27'
224227
}
225-
GMTEEditorTileMap >> placeTiles: aCoordinateCollection inLayer: aLayer [
228+
GMTEEditorTileMap >> placeTiles: anIndexSet inLayer: aLayer [
226229
"add currently selected tile (model) to editable matrix stack at given indices"
227-
230+
228231
| tile |
229-
aCoordinateCollection do: [:c |
232+
anIndexSet do: [:c |
230233
self savePreviousImageFromIndex: c inLayer: aLayer.
231234
((self tileMatrixStack layer: aLayer) inBounds: c) ifTrue: [
232235
tile := self tileMatrixStack layer: aLayer at: c y at: c x.
@@ -294,11 +297,13 @@ GMTEEditorTileMap >> resetTileEditChanges [
294297

295298
{
296299
#category : #'command processing',
297-
#'squeak_changestamp' : 'JS 7/12/2024 16:34'
300+
#'squeak_changestamp' : 'Alex M 7/12/2024 18:44'
298301
}
299302
GMTEEditorTileMap >> saveNewImageFromIndex: anIndex inLayer: aLayer [
300-
301303
| tile |
304+
305+
anIndex ifNil: [^ nil].
306+
302307
tile := self tileMatrixStack layer: aLayer at: anIndex y at: anIndex x.
303308

304309
tile
@@ -375,3 +380,14 @@ GMTEEditorTileMap >> updateTiles: anIndexSet inLayer: aLayer FromEvent: anEvent
375380
validLeftClick ifTrue: [self placeTiles: anIndexSet inLayer: aLayer].
376381
validRightClick ifTrue: [self deleteTiles: anIndexSet inLayer: aLayer].
377382
]
383+
384+
{
385+
#category : #view,
386+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 18:13'
387+
}
388+
GMTEEditorTileMap >> zoomAt: aPoint by: aFloat [
389+
390+
super zoomAt: aPoint by: aFloat.
391+
self flag: 'refactor?'.
392+
self tileSelectionSet clearAllHighlightings
393+
]

0 commit comments

Comments
 (0)