Skip to content

Commit

Permalink
reintroduced and expanded onClose
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksander Morgensterns committed Jul 10, 2024
1 parent 07307c9 commit 4485bff
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 112 deletions.
2 changes: 1 addition & 1 deletion source/GM-TE/GMTEDeleteLayersCommand.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #GMTEDeleteLayersCommand,
#superclass : #GMTETilemapSizeCommand,
#superclass : #GMTEEditTilesCommand,
#instVars : [
'layers'
],
Expand Down
60 changes: 26 additions & 34 deletions source/GM-TE/GMTEEditTilesCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,38 @@ GMTEEditTilesCommand >> currentSprites: anObject [

{
#category : #execution,
#'squeak_changestamp' : 'TW 7/2/2024 17:54'
#'squeak_changestamp' : 'Alex M 7/10/2024 13:42'
}
GMTEEditTilesCommand >> do [

self placeTilesFromList: self currentSprites
]

{
#category : #initialization,
#'squeak_changestamp' : 'Alex M 6/28/2024 02:45'
}
GMTEEditTilesCommand >> initialize [

self
previousSprites: Dictionary new;
currentSprites: Dictionary new
]

{
#category : #execution,
#'squeak_changestamp' : 'Alex M 7/10/2024 13:44'
}
GMTEEditTilesCommand >> placeTilesFromList: aList [
| tile sprite layer x y |

self currentSprites keysDo: [ :coordinates |
aList keysDo: [ :coordinates |
x := coordinates at: 1.
y := coordinates at: 2.
layer := coordinates at: 3.

tile := self tileMap tileMatrixStack layer: layer at: y at: x.
sprite := self currentSprites at: coordinates.
sprite := aList at: coordinates.
tile
ifNil: [sprite
ifNotNil: [
Expand All @@ -61,18 +81,7 @@ GMTEEditTilesCommand >> do [
ifNil: [
self tileMap tileMatrixStack layer: layer at: y at: x put: nil.
tile abandon]
ifNotNil: [tile updateSprite: (self currentSprites at: coordinates)]]]
]

{
#category : #initialization,
#'squeak_changestamp' : 'Alex M 6/28/2024 02:45'
}
GMTEEditTilesCommand >> initialize [

self
previousSprites: Dictionary new;
currentSprites: Dictionary new
ifNotNil: [tile updateSprite: (aList at: coordinates)]]]
]

{
Expand Down Expand Up @@ -109,26 +118,9 @@ GMTEEditTilesCommand >> tileMap: anObject [

{
#category : #execution,
#'squeak_changestamp' : 'TW 7/2/2024 17:54'
#'squeak_changestamp' : 'Alex M 7/10/2024 13:43'
}
GMTEEditTilesCommand >> undo [
| tile sprite layer x y |

self previousSprites keysDo: [ :coordinates |
x := coordinates at: 1.
y := coordinates at: 2.
layer := coordinates at: 3.

tile := self tileMap tileMatrixStack layer: layer at: y at: x.
sprite := self previousSprites at: coordinates.
tile
ifNil: [sprite
ifNotNil: [
tile := tileMap generateTileAtlayer: layer x: x y: y stack: self tileMap tileMatrixStack tileType: GMTETile.
tile updateSprite: sprite]]
ifNotNil: [sprite
ifNil: [
self tileMap tileMatrixStack layer: layer at: y at: x put: nil.
tile abandon]
ifNotNil: [tile updateSprite: (self previousSprites at: coordinates)]]]
self placeTilesFromList: self previousSprites
]
70 changes: 14 additions & 56 deletions source/GM-TE/GMTEEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ GMTEEditor >> brushButtons: anObject [

{
#category : #building,
#'squeak_changestamp' : 'mcjj 7/10/2024 16:51'
#'squeak_changestamp' : 'TW 7/9/2024 18:15'
}
GMTEEditor >> buildWith: builder [
"builds the editor with ToolBuilder"
Expand All @@ -393,7 +393,7 @@ GMTEEditor >> buildWith: builder [
self createInspectorSpecWithBuilder: builder};
closeAction: #onClose;
minimumExtent: GMTEEditor editorMinimumExtent).

self commandBar: (newMorph submorphNamed: 'command bar').
"self commandBar vResizing: #rigid."
self tileStore: (newMorph submorphNamed: 'tile store').
Expand Down Expand Up @@ -422,8 +422,7 @@ GMTEEditor >> buildWith: builder [

self
initializeDefaultTileMapMatrix;
associatedMorph: newMorph;
setupInputHandlingFor: newMorph.
associatedMorph: newMorph.

^ newMorph
]
Expand Down Expand Up @@ -968,15 +967,6 @@ GMTEEditor >> disableSingleLayerButtons [
GMTEEditor singleLayerActionNames do: [:aString | (self associatedMorph submorphNamed: aString) enabled: false ]
]

{
#category : #'input handling',
#'squeak_changestamp' : 'mcjj 7/10/2024 16:47'
}
GMTEEditor >> dropKeyboardFocus: anEvent [

anEvent hand releaseKeyboardFocus: self associatedMorph
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'TW 6/25/2024 17:51'
Expand Down Expand Up @@ -1106,15 +1096,6 @@ GMTEEditor >> getGridWidthAsString [
^ self getGridWidth asString
]

{
#category : #'input handling',
#'squeak_changestamp' : 'mcjj 7/10/2024 16:46'
}
GMTEEditor >> getKeyboardFocus: anEvent [

anEvent hand newKeyboardFocus: self associatedMorph
]

{
#category : #'layer manipulation',
#'squeak_changestamp' : 'TW 6/23/2024 21:50'
Expand Down Expand Up @@ -1182,18 +1163,6 @@ GMTEEditor >> getTileRatioAsString [
^ self getTileRatio asString
]

{
#category : #'input handling',
#'squeak_changestamp' : 'mcjj 7/10/2024 16:49'
}
GMTEEditor >> handleKeyStroke: anEvent [

| keyValue |
keyValue := anEvent key.
Transcript show: keyValue
"keyValue = $A"
]

{
#category : #'menu button functions',
#'squeak_changestamp' : 'TW 6/23/2024 20:09'
Expand Down Expand Up @@ -1518,15 +1487,14 @@ GMTEEditor >> moveLayerUp [

{
#category : #building,
#'squeak_changestamp' : 'Alex M 6/28/2024 21:27'
#'squeak_changestamp' : 'Alex M 7/11/2024 00:34'
}
GMTEEditor >> onClose [
"asks the user whether they want to save their progress"

"self savedSinceModified
self savedSinceModified
ifFalse: [(PopUpMenu confirm: 'Save before closing?')
ifTrue: [self exportAsMorph]]"
"COMMENTED FOR EASIER DEBUGGING"
ifTrue: [self exportAsMorph]]
]

{
Expand Down Expand Up @@ -1646,13 +1614,15 @@ GMTEEditor >> ratio: anObject [

{
#category : #'command processing',
#'squeak_changestamp' : 'TW 7/2/2024 17:47'
#'squeak_changestamp' : 'Alex M 7/10/2024 14:17'
}
GMTEEditor >> redo [

(self currentCommand < self commands size)
ifTrue: [
self currentCommand: self currentCommand + 1.
self
savedSinceModified: false;
currentCommand: self currentCommand + 1.
(self commands at: self currentCommand) do.
self savedSinceModified: false]
]
Expand Down Expand Up @@ -2016,20 +1986,6 @@ GMTEEditor >> settingsMenu [
builder open: aMenuSpec
]

{
#category : #'input handling',
#'squeak_changestamp' : 'mcjj 7/10/2024 16:49'
}
GMTEEditor >> setupInputHandlingFor: aMorph [

aMorph
on: #mouseMove send: #getKeyboardFocus: to: self;
on: #mouseLeave send: #dropKeyboardFocus: to: self;
on: #keyStroke send: #handleKeyStroke: to: self.

aMorph eventHandler wantsEveryMouseMove: true
]

{
#category : #'layer manipulation',
#'squeak_changestamp' : 'jj 6/22/2024 21:43'
Expand Down Expand Up @@ -2176,14 +2132,16 @@ GMTEEditor >> trayViewer: anObject [

{
#category : #'command processing',
#'squeak_changestamp' : 'Alex M 7/10/2024 03:49'
#'squeak_changestamp' : 'Alex M 7/10/2024 14:17'
}
GMTEEditor >> undo [

self flag: 'DO THIS USING TILEMAP FUNCTIONS'.
(self currentCommand > 1)
ifTrue: [(self commands at: self currentCommand) undo.
self currentCommand: self currentCommand - 1.
self
savedSinceModified: false;
currentCommand: self currentCommand - 1.
({GMTETilemapSizeCommand. GMTEDeleteLayersCommand} includes: (self commands at: self currentCommand + 1) class)
ifTrue: [self redoAllCommandsUntil: self currentCommand].
self savedSinceModified: false]
Expand Down
29 changes: 11 additions & 18 deletions source/GM-TE/GMTEEditorTileMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,6 @@ GMTEEditorTileMap >> handlesMouseMove: anEvent [
^ true
]

{
#category : #'event handling',
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 13:12'
}
GMTEEditorTileMap >> handlesMouseOver: anEvent [

^ true
]

{
#category : #initialization,
#'squeak_changestamp' : 'Alex M 6/28/2024 20:24'
Expand Down Expand Up @@ -139,15 +130,6 @@ GMTEEditorTileMap >> mouseDown: anEvent [
^ true
]

{
#category : #'event handling',
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 13:14'
}
GMTEEditorTileMap >> mouseLeave: anEvent [

self tileSelectionSet clearAllHighlightings
]

{
#category : #'event handling',
#'squeak_changestamp' : 'Valentin Teutschbein 7/10/2024 13:06'
Expand Down Expand Up @@ -202,6 +184,17 @@ GMTEEditorTileMap >> previousTileStates: anObject [
previousTileStates := anObject
]

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:35'
}
GMTEEditorTileMap >> rescaleMap [
"Override super behavior such that highlightings are removed during rescale events"

self tileSelectionSet clearAllHighlightings.
super rescaleMap
]

{
#category : #TODO,
#'squeak_changestamp' : 'Alex M 7/3/2024 23:50'
Expand Down
4 changes: 2 additions & 2 deletions source/GM-TE/GMTETileMatrixStack.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ GMTETileMatrixStack >> removeLayersAt: aSet [

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

newLayers := OrderedCollection new.
newLayers := LinkedList new.

self doLayers: [:layer |
newLayer := layer asRescaledToWidth: aWidth height: aHeight.
Expand Down
2 changes: 1 addition & 1 deletion source/GM-TE/GMTETilemapSizeCommand.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #GMTETilemapSizeCommand,
#superclass : #GMTECommand,
#superclass : #GMTEEditTilesCommand,
#instVars : [
'editor',
'method',
Expand Down

0 comments on commit 4485bff

Please sign in to comment.