From 4485bffee3302e58c15c8d88a16cd4eb4340edab Mon Sep 17 00:00:00 2001 From: Aleksander Morgensterns Date: Thu, 11 Jul 2024 00:34:37 +0200 Subject: [PATCH] reintroduced and expanded onClose --- source/GM-TE/GMTEDeleteLayersCommand.class.st | 2 +- source/GM-TE/GMTEEditTilesCommand.class.st | 60 +++++++--------- source/GM-TE/GMTEEditor.class.st | 70 ++++--------------- source/GM-TE/GMTEEditorTileMap.class.st | 29 +++----- source/GM-TE/GMTETileMatrixStack.class.st | 4 +- source/GM-TE/GMTETilemapSizeCommand.class.st | 2 +- 6 files changed, 55 insertions(+), 112 deletions(-) diff --git a/source/GM-TE/GMTEDeleteLayersCommand.class.st b/source/GM-TE/GMTEDeleteLayersCommand.class.st index 4be78980..a6eafdc3 100644 --- a/source/GM-TE/GMTEDeleteLayersCommand.class.st +++ b/source/GM-TE/GMTEDeleteLayersCommand.class.st @@ -1,6 +1,6 @@ Class { #name : #GMTEDeleteLayersCommand, - #superclass : #GMTETilemapSizeCommand, + #superclass : #GMTEEditTilesCommand, #instVars : [ 'layers' ], diff --git a/source/GM-TE/GMTEEditTilesCommand.class.st b/source/GM-TE/GMTEEditTilesCommand.class.st index 10b268af..1972bc86 100644 --- a/source/GM-TE/GMTEEditTilesCommand.class.st +++ b/source/GM-TE/GMTEEditTilesCommand.class.st @@ -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: [ @@ -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)]]] ] { @@ -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 ] diff --git a/source/GM-TE/GMTEEditor.class.st b/source/GM-TE/GMTEEditor.class.st index 3185e1f8..769d0efe 100644 --- a/source/GM-TE/GMTEEditor.class.st +++ b/source/GM-TE/GMTEEditor.class.st @@ -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" @@ -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'). @@ -422,8 +422,7 @@ GMTEEditor >> buildWith: builder [ self initializeDefaultTileMapMatrix; - associatedMorph: newMorph; - setupInputHandlingFor: newMorph. + associatedMorph: newMorph. ^ newMorph ] @@ -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' @@ -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' @@ -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' @@ -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]] ] { @@ -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] ] @@ -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' @@ -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] diff --git a/source/GM-TE/GMTEEditorTileMap.class.st b/source/GM-TE/GMTEEditorTileMap.class.st index 36891056..1f47a0f6 100644 --- a/source/GM-TE/GMTEEditorTileMap.class.st +++ b/source/GM-TE/GMTEEditorTileMap.class.st @@ -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' @@ -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' @@ -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' diff --git a/source/GM-TE/GMTETileMatrixStack.class.st b/source/GM-TE/GMTETileMatrixStack.class.st index 63f8cac9..bd6f27db 100644 --- a/source/GM-TE/GMTETileMatrixStack.class.st +++ b/source/GM-TE/GMTETileMatrixStack.class.st @@ -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" @@ -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. diff --git a/source/GM-TE/GMTETilemapSizeCommand.class.st b/source/GM-TE/GMTETilemapSizeCommand.class.st index 7613d036..fe18b4f0 100644 --- a/source/GM-TE/GMTETilemapSizeCommand.class.st +++ b/source/GM-TE/GMTETilemapSizeCommand.class.st @@ -1,6 +1,6 @@ Class { #name : #GMTETilemapSizeCommand, - #superclass : #GMTECommand, + #superclass : #GMTEEditTilesCommand, #instVars : [ 'editor', 'method',