Skip to content

Commit 4485bff

Browse files
author
Aleksander Morgensterns
committed
reintroduced and expanded onClose
1 parent 07307c9 commit 4485bff

6 files changed

+55
-112
lines changed

source/GM-TE/GMTEDeleteLayersCommand.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Class {
22
#name : #GMTEDeleteLayersCommand,
3-
#superclass : #GMTETilemapSizeCommand,
3+
#superclass : #GMTEEditTilesCommand,
44
#instVars : [
55
'layers'
66
],

source/GM-TE/GMTEEditTilesCommand.class.st

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,38 @@ GMTEEditTilesCommand >> currentSprites: anObject [
4040

4141
{
4242
#category : #execution,
43-
#'squeak_changestamp' : 'TW 7/2/2024 17:54'
43+
#'squeak_changestamp' : 'Alex M 7/10/2024 13:42'
4444
}
4545
GMTEEditTilesCommand >> do [
46+
47+
self placeTilesFromList: self currentSprites
48+
]
49+
50+
{
51+
#category : #initialization,
52+
#'squeak_changestamp' : 'Alex M 6/28/2024 02:45'
53+
}
54+
GMTEEditTilesCommand >> initialize [
55+
56+
self
57+
previousSprites: Dictionary new;
58+
currentSprites: Dictionary new
59+
]
60+
61+
{
62+
#category : #execution,
63+
#'squeak_changestamp' : 'Alex M 7/10/2024 13:44'
64+
}
65+
GMTEEditTilesCommand >> placeTilesFromList: aList [
4666
| tile sprite layer x y |
4767

48-
self currentSprites keysDo: [ :coordinates |
68+
aList keysDo: [ :coordinates |
4969
x := coordinates at: 1.
5070
y := coordinates at: 2.
5171
layer := coordinates at: 3.
5272

5373
tile := self tileMap tileMatrixStack layer: layer at: y at: x.
54-
sprite := self currentSprites at: coordinates.
74+
sprite := aList at: coordinates.
5575
tile
5676
ifNil: [sprite
5777
ifNotNil: [
@@ -61,18 +81,7 @@ GMTEEditTilesCommand >> do [
6181
ifNil: [
6282
self tileMap tileMatrixStack layer: layer at: y at: x put: nil.
6383
tile abandon]
64-
ifNotNil: [tile updateSprite: (self currentSprites at: coordinates)]]]
65-
]
66-
67-
{
68-
#category : #initialization,
69-
#'squeak_changestamp' : 'Alex M 6/28/2024 02:45'
70-
}
71-
GMTEEditTilesCommand >> initialize [
72-
73-
self
74-
previousSprites: Dictionary new;
75-
currentSprites: Dictionary new
84+
ifNotNil: [tile updateSprite: (aList at: coordinates)]]]
7685
]
7786

7887
{
@@ -109,26 +118,9 @@ GMTEEditTilesCommand >> tileMap: anObject [
109118

110119
{
111120
#category : #execution,
112-
#'squeak_changestamp' : 'TW 7/2/2024 17:54'
121+
#'squeak_changestamp' : 'Alex M 7/10/2024 13:43'
113122
}
114123
GMTEEditTilesCommand >> undo [
115-
| tile sprite layer x y |
116124

117-
self previousSprites keysDo: [ :coordinates |
118-
x := coordinates at: 1.
119-
y := coordinates at: 2.
120-
layer := coordinates at: 3.
121-
122-
tile := self tileMap tileMatrixStack layer: layer at: y at: x.
123-
sprite := self previousSprites at: coordinates.
124-
tile
125-
ifNil: [sprite
126-
ifNotNil: [
127-
tile := tileMap generateTileAtlayer: layer x: x y: y stack: self tileMap tileMatrixStack tileType: GMTETile.
128-
tile updateSprite: sprite]]
129-
ifNotNil: [sprite
130-
ifNil: [
131-
self tileMap tileMatrixStack layer: layer at: y at: x put: nil.
132-
tile abandon]
133-
ifNotNil: [tile updateSprite: (self previousSprites at: coordinates)]]]
125+
self placeTilesFromList: self previousSprites
134126
]

source/GM-TE/GMTEEditor.class.st

Lines changed: 14 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ GMTEEditor >> brushButtons: anObject [
373373

374374
{
375375
#category : #building,
376-
#'squeak_changestamp' : 'mcjj 7/10/2024 16:51'
376+
#'squeak_changestamp' : 'TW 7/9/2024 18:15'
377377
}
378378
GMTEEditor >> buildWith: builder [
379379
"builds the editor with ToolBuilder"
@@ -393,7 +393,7 @@ GMTEEditor >> buildWith: builder [
393393
self createInspectorSpecWithBuilder: builder};
394394
closeAction: #onClose;
395395
minimumExtent: GMTEEditor editorMinimumExtent).
396-
396+
397397
self commandBar: (newMorph submorphNamed: 'command bar').
398398
"self commandBar vResizing: #rigid."
399399
self tileStore: (newMorph submorphNamed: 'tile store').
@@ -422,8 +422,7 @@ GMTEEditor >> buildWith: builder [
422422

423423
self
424424
initializeDefaultTileMapMatrix;
425-
associatedMorph: newMorph;
426-
setupInputHandlingFor: newMorph.
425+
associatedMorph: newMorph.
427426

428427
^ newMorph
429428
]
@@ -968,15 +967,6 @@ GMTEEditor >> disableSingleLayerButtons [
968967
GMTEEditor singleLayerActionNames do: [:aString | (self associatedMorph submorphNamed: aString) enabled: false ]
969968
]
970969

971-
{
972-
#category : #'input handling',
973-
#'squeak_changestamp' : 'mcjj 7/10/2024 16:47'
974-
}
975-
GMTEEditor >> dropKeyboardFocus: anEvent [
976-
977-
anEvent hand releaseKeyboardFocus: self associatedMorph
978-
]
979-
980970
{
981971
#category : #'as yet unclassified',
982972
#'squeak_changestamp' : 'TW 6/25/2024 17:51'
@@ -1106,15 +1096,6 @@ GMTEEditor >> getGridWidthAsString [
11061096
^ self getGridWidth asString
11071097
]
11081098

1109-
{
1110-
#category : #'input handling',
1111-
#'squeak_changestamp' : 'mcjj 7/10/2024 16:46'
1112-
}
1113-
GMTEEditor >> getKeyboardFocus: anEvent [
1114-
1115-
anEvent hand newKeyboardFocus: self associatedMorph
1116-
]
1117-
11181099
{
11191100
#category : #'layer manipulation',
11201101
#'squeak_changestamp' : 'TW 6/23/2024 21:50'
@@ -1182,18 +1163,6 @@ GMTEEditor >> getTileRatioAsString [
11821163
^ self getTileRatio asString
11831164
]
11841165

1185-
{
1186-
#category : #'input handling',
1187-
#'squeak_changestamp' : 'mcjj 7/10/2024 16:49'
1188-
}
1189-
GMTEEditor >> handleKeyStroke: anEvent [
1190-
1191-
| keyValue |
1192-
keyValue := anEvent key.
1193-
Transcript show: keyValue
1194-
"keyValue = $A"
1195-
]
1196-
11971166
{
11981167
#category : #'menu button functions',
11991168
#'squeak_changestamp' : 'TW 6/23/2024 20:09'
@@ -1518,15 +1487,14 @@ GMTEEditor >> moveLayerUp [
15181487

15191488
{
15201489
#category : #building,
1521-
#'squeak_changestamp' : 'Alex M 6/28/2024 21:27'
1490+
#'squeak_changestamp' : 'Alex M 7/11/2024 00:34'
15221491
}
15231492
GMTEEditor >> onClose [
15241493
"asks the user whether they want to save their progress"
15251494

1526-
"self savedSinceModified
1495+
self savedSinceModified
15271496
ifFalse: [(PopUpMenu confirm: 'Save before closing?')
1528-
ifTrue: [self exportAsMorph]]"
1529-
"COMMENTED FOR EASIER DEBUGGING"
1497+
ifTrue: [self exportAsMorph]]
15301498
]
15311499

15321500
{
@@ -1646,13 +1614,15 @@ GMTEEditor >> ratio: anObject [
16461614

16471615
{
16481616
#category : #'command processing',
1649-
#'squeak_changestamp' : 'TW 7/2/2024 17:47'
1617+
#'squeak_changestamp' : 'Alex M 7/10/2024 14:17'
16501618
}
16511619
GMTEEditor >> redo [
16521620

16531621
(self currentCommand < self commands size)
16541622
ifTrue: [
1655-
self currentCommand: self currentCommand + 1.
1623+
self
1624+
savedSinceModified: false;
1625+
currentCommand: self currentCommand + 1.
16561626
(self commands at: self currentCommand) do.
16571627
self savedSinceModified: false]
16581628
]
@@ -2016,20 +1986,6 @@ GMTEEditor >> settingsMenu [
20161986
builder open: aMenuSpec
20171987
]
20181988

2019-
{
2020-
#category : #'input handling',
2021-
#'squeak_changestamp' : 'mcjj 7/10/2024 16:49'
2022-
}
2023-
GMTEEditor >> setupInputHandlingFor: aMorph [
2024-
2025-
aMorph
2026-
on: #mouseMove send: #getKeyboardFocus: to: self;
2027-
on: #mouseLeave send: #dropKeyboardFocus: to: self;
2028-
on: #keyStroke send: #handleKeyStroke: to: self.
2029-
2030-
aMorph eventHandler wantsEveryMouseMove: true
2031-
]
2032-
20331989
{
20341990
#category : #'layer manipulation',
20351991
#'squeak_changestamp' : 'jj 6/22/2024 21:43'
@@ -2176,14 +2132,16 @@ GMTEEditor >> trayViewer: anObject [
21762132

21772133
{
21782134
#category : #'command processing',
2179-
#'squeak_changestamp' : 'Alex M 7/10/2024 03:49'
2135+
#'squeak_changestamp' : 'Alex M 7/10/2024 14:17'
21802136
}
21812137
GMTEEditor >> undo [
21822138

21832139
self flag: 'DO THIS USING TILEMAP FUNCTIONS'.
21842140
(self currentCommand > 1)
21852141
ifTrue: [(self commands at: self currentCommand) undo.
2186-
self currentCommand: self currentCommand - 1.
2142+
self
2143+
savedSinceModified: false;
2144+
currentCommand: self currentCommand - 1.
21872145
({GMTETilemapSizeCommand. GMTEDeleteLayersCommand} includes: (self commands at: self currentCommand + 1) class)
21882146
ifTrue: [self redoAllCommandsUntil: self currentCommand].
21892147
self savedSinceModified: false]

source/GM-TE/GMTEEditorTileMap.class.st

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,6 @@ GMTEEditorTileMap >> handlesMouseMove: anEvent [
8080
^ true
8181
]
8282

83-
{
84-
#category : #'event handling',
85-
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 13:12'
86-
}
87-
GMTEEditorTileMap >> handlesMouseOver: anEvent [
88-
89-
^ true
90-
]
91-
9283
{
9384
#category : #initialization,
9485
#'squeak_changestamp' : 'Alex M 6/28/2024 20:24'
@@ -139,15 +130,6 @@ GMTEEditorTileMap >> mouseDown: anEvent [
139130
^ true
140131
]
141132

142-
{
143-
#category : #'event handling',
144-
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 13:14'
145-
}
146-
GMTEEditorTileMap >> mouseLeave: anEvent [
147-
148-
self tileSelectionSet clearAllHighlightings
149-
]
150-
151133
{
152134
#category : #'event handling',
153135
#'squeak_changestamp' : 'Valentin Teutschbein 7/10/2024 13:06'
@@ -202,6 +184,17 @@ GMTEEditorTileMap >> previousTileStates: anObject [
202184
previousTileStates := anObject
203185
]
204186

187+
{
188+
#category : #updating,
189+
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:35'
190+
}
191+
GMTEEditorTileMap >> rescaleMap [
192+
"Override super behavior such that highlightings are removed during rescale events"
193+
194+
self tileSelectionSet clearAllHighlightings.
195+
super rescaleMap
196+
]
197+
205198
{
206199
#category : #TODO,
207200
#'squeak_changestamp' : 'Alex M 7/3/2024 23:50'

source/GM-TE/GMTETileMatrixStack.class.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ GMTETileMatrixStack >> removeLayersAt: aSet [
392392

393393
{
394394
#category : #updating,
395-
#'squeak_changestamp' : 'Valentin Teutschbein 7/10/2024 13:59'
395+
#'squeak_changestamp' : 'TW 6/22/2024 01:27'
396396
}
397397
GMTETileMatrixStack >> rescaleToWidth: aWidth height: aHeight [
398398
"This will rescale layers be recreating them"
@@ -402,7 +402,7 @@ GMTETileMatrixStack >> rescaleToWidth: aWidth height: aHeight [
402402
width: aWidth;
403403
height: aHeight.
404404

405-
newLayers := OrderedCollection new.
405+
newLayers := LinkedList new.
406406

407407
self doLayers: [:layer |
408408
newLayer := layer asRescaledToWidth: aWidth height: aHeight.

source/GM-TE/GMTETilemapSizeCommand.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Class {
22
#name : #GMTETilemapSizeCommand,
3-
#superclass : #GMTECommand,
3+
#superclass : #GMTEEditTilesCommand,
44
#instVars : [
55
'editor',
66
'method',

0 commit comments

Comments
 (0)