From 4485bffee3302e58c15c8d88a16cd4eb4340edab Mon Sep 17 00:00:00 2001 From: Aleksander Morgensterns Date: Thu, 11 Jul 2024 00:34:37 +0200 Subject: [PATCH 1/2] 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', From d74333d40759f990aefa73fe3e3b77f3ab11a1c1 Mon Sep 17 00:00:00 2001 From: Joshua Date: Thu, 11 Jul 2024 14:15:23 +0200 Subject: [PATCH 2/2] minor codestyle fixes for brushes --- source/GM-TE/GMTEBrush.class.st | 194 ++++++++++++------------ source/GM-TE/GMTEEditorTileMap.class.st | 25 ++- 2 files changed, 109 insertions(+), 110 deletions(-) diff --git a/source/GM-TE/GMTEBrush.class.st b/source/GM-TE/GMTEBrush.class.st index 5d00dad2..078d9042 100644 --- a/source/GM-TE/GMTEBrush.class.st +++ b/source/GM-TE/GMTEBrush.class.st @@ -46,18 +46,18 @@ GMTEBrush >> currentMatrixIndex: anObject [ { #category : #'as yet unclassified', - #'squeak_changestamp' : 'Valentin Teutschbein 7/9/2024 08:47' + #'squeak_changestamp' : 'JS 7/11/2024 13:59' } GMTEBrush >> executeWithMatrixIndex: anIndex andLayer: aLayer [ self currentMatrixIndex: anIndex. self layer: aLayer. - ^ self currentBrush value. + ^ self currentBrush value ] { #category : #forms, - #'squeak_changestamp' : 'Valentin Teutschbein 7/9/2024 22:04' + #'squeak_changestamp' : 'JS 7/11/2024 14:07' } GMTEBrush >> fillBrush [ @@ -67,27 +67,27 @@ GMTEBrush >> fillBrush [ visited := Matrix rows: (self layer rowCount) columns: self layer columnCount. collection := OrderedCollection new. - startTile := layer at: self currentMatrixIndex y at: self currentMatrixIndex x. + startTile := self layer at: self currentMatrixIndex y at: self currentMatrixIndex x. - collection add: currentMatrixIndex. + collection add: self currentMatrixIndex. visited at: self currentMatrixIndex y at: self currentMatrixIndex x put: true. self fillDfsWithVisited: visited andIndex: self currentMatrixIndex andOriginTile: startTile andCollection: collection. self outputSet: collection asSet. - ^ self outputSet. + ^ self outputSet ] { #category : #forms, - #'squeak_changestamp' : 'JS 7/6/2024 16:46' + #'squeak_changestamp' : 'JS 7/11/2024 13:58' } GMTEBrush >> fillDfsWithVisited: aVisitedMatrix andIndex: anIndex andOriginTile: anOriginTile andCollection: aCollection [ | borderingOffsets | self flag: 'REFACTOR!'. borderingOffsets := {(-1)@0. 0@(-1). 1@0. 0@1}. - borderingOffsets do: [: offset| + borderingOffsets do: [:offset | | newIndex newTile | newIndex := offset + anIndex. ((self layer inBounds: newIndex) and: [(aVisitedMatrix at: newIndex y at: newIndex x) isNil]) ifTrue:[ @@ -97,10 +97,10 @@ GMTEBrush >> fillDfsWithVisited: aVisitedMatrix andIndex: anIndex andOriginTile: aVisitedMatrix at: newIndex y at: newIndex x put: true. self fillDfsWithVisited: aVisitedMatrix andIndex: newIndex andOriginTile: anOriginTile andCollection: aCollection]] ifNotNil: [ - (newTile isNil not and: [anOriginTile imageForm bits hash = newTile imageForm bits hash]) - ifTrue: [aCollection add: newIndex. - aVisitedMatrix at: newIndex y at: newIndex x put: true. - self fillDfsWithVisited: aVisitedMatrix andIndex: newIndex andOriginTile: anOriginTile andCollection: aCollection]]]] + (newTile isNil not and: [anOriginTile imageForm bits hash = newTile imageForm bits hash]) ifTrue: [ + aCollection add: newIndex. + aVisitedMatrix at: newIndex y at: newIndex x put: true. + self fillDfsWithVisited: aVisitedMatrix andIndex: newIndex andOriginTile: anOriginTile andCollection: aCollection]]]] ] { @@ -121,12 +121,21 @@ GMTEBrush >> firstMatrixIndex: anObject [ { #category : #forms, - #'squeak_changestamp' : 'Valentin Teutschbein 7/9/2024 21:33' + #'squeak_changestamp' : 'JS 7/11/2024 13:59' } GMTEBrush >> initialize [ super initialize. - self resetOutputSet. + self resetOutputSet +] + +{ + #category : #forms, + #'squeak_changestamp' : 'JS 7/11/2024 14:04' +} +GMTEBrush >> isPointInRadius: aPoint [ + self flag: 'to long? - refactor with lineBrush in mind'. + ^(( self currentMatrixIndex x - aPoint x) squared + ( self currentMatrixIndex y - aPoint y) squared <= (self radius - 1) squared) ] { @@ -147,56 +156,50 @@ GMTEBrush >> layer: anObject [ { #category : #forms, - #'squeak_changestamp' : 'Valentin Teutschbein 7/9/2024 22:53' + #'squeak_changestamp' : 'JS 7/11/2024 14:09' } GMTEBrush >> lineBrush [ - | radius collection start end deltaX deltaY stepX stepY error error2 x y offsets | - + | radius collection start end deltaX deltaY stepX stepY error error2 x y offsets | + self flag: 'refactor - do instead of collect or select'. radius := self radius - 1. self resetOutputSet. self flag: 'todo: method extraction'. - "Helper method to generate radius offsets" - offsets := OrderedCollection new. - (0-radius to: radius) do: [:dx | - (0-radius to: radius) do: [:dy | - (dx * dx + dy * dy <= (radius * radius)) ifTrue: [ - offsets add: dx @ dy. - ]. - ]. - ]. - - self resetOutputSet. - (self currentMatrixIndex isNil or: [self firstMatrixIndex isNil]) ifTrue: [^nil]. - - start := self firstMatrixIndex. - end := self currentMatrixIndex. - deltaX := (end x - start x) abs. - deltaY := (end y - start y) abs. - stepX := (start x < end x) ifTrue: [1] ifFalse: [-1]. - stepY := (start y < end y) ifTrue: [1] ifFalse: [-1]. - error := deltaX - deltaY. - x := start x. - y := start y. - - collection := OrderedCollection new. - - [ - | point | - point := x @ y. - offsets do: [:offset | collection add: (point + offset)]. - (x = end x and: [y = end y]) ifTrue: [ - self outputSet: collection asSet. - ^ self outputSet.]. - error2 := 2 * error. - (error2 > (0 - deltaY)) ifTrue: [ - error := error - deltaY. - x := x + stepX. - ]. - (error2 < deltaX) ifTrue: [ - error := error + deltaX. - y := y + stepY. - ]. - ] repeat. + "Helper method to generate radius offsets" + offsets := OrderedCollection new. + (0-radius to: radius) do: [:dx | + (0-radius to: radius) do: [:dy | + ((dx * dx) + (dy * dy) <= (radius * radius)) ifTrue: [offsets add: dx @ dy]]]. + + self resetOutputSet. + (self currentMatrixIndex isNil or: [self firstMatrixIndex isNil]) ifTrue: [^nil]. + + start := self firstMatrixIndex. + end := self currentMatrixIndex. + deltaX := (end x - start x) abs. + deltaY := (end y - start y) abs. + stepX := (start x < end x) ifTrue: [1] ifFalse: [-1]. + stepY := (start y < end y) ifTrue: [1] ifFalse: [-1]. + error := deltaX - deltaY. + x := start x. + y := start y. + + collection := OrderedCollection new. + + [ + | point | + point := x @ y. + offsets do: [:offset | collection add: (point + offset)]. + (x = end x and: [y = end y]) ifTrue: [ + self outputSet: collection asSet. + ^ self outputSet]. + error2 := 2 * error. + (error2 > (0 - deltaY)) ifTrue: [ + error := error - deltaY. + x := x + stepX]. + (error2 < deltaX) ifTrue: [ + error := error + deltaX. + y := y + stepY] + ] repeat ] @@ -234,71 +237,68 @@ GMTEBrush >> radius: anObject [ { #category : #forms, - #'squeak_changestamp' : 'Valentin Teutschbein 7/10/2024 12:37' + #'squeak_changestamp' : 'JS 7/11/2024 14:06' } GMTEBrush >> radiusBrush [ - | collection xMin xMax yMin yMax | - self currentMatrixIndex ifNil: [^nil]. + | collection xMin xMax yMin yMax | + self currentMatrixIndex ifNil: [^nil]. - collection := OrderedCollection new. + collection := OrderedCollection new. self flag: 'radius offset is bad'. - xMin := self currentMatrixIndex x - (self radius - 1). - xMax := self currentMatrixIndex x + (self radius - 1). - yMin := self currentMatrixIndex y - (self radius - 1). - yMax := self currentMatrixIndex y + (self radius - 1). + xMin := self currentMatrixIndex x - (self radius - 1). + xMax := self currentMatrixIndex x + (self radius - 1). + yMin := self currentMatrixIndex y - (self radius - 1). + yMax := self currentMatrixIndex y + (self radius - 1). - (xMin to: xMax) do: [:x | - (yMin to: yMax) do: [:y | - (( self currentMatrixIndex x - x) squared + ( self currentMatrixIndex y - y) squared <= (self radius - 1) squared) ifTrue: [ - collection add: x@y - ]. - ]. - ]. + self flag: 'select instead of do?'. + (xMin to: xMax) do: [:x | + (yMin to: yMax) do: [:y | + (self isPointInRadius: x @ y) ifTrue: [collection add: x @ y]]]. - collection do: [:i | self outputSet add: i]. + collection do: [:i | + self outputSet add: i]. - ^ self outputSet. + ^ self outputSet ] { #category : #forms, - #'squeak_changestamp' : 'Valentin Teutschbein 7/9/2024 22:04' + #'squeak_changestamp' : 'JS 7/11/2024 13:49' } GMTEBrush >> rectangleBrush [ - | collection startRow endRow startCol endCol | + | collection startRow endRow startCol endCol | self resetOutputSet. - (self currentMatrixIndex isNil or: [self firstMatrixIndex isNil]) ifTrue: [^nil]. - collection := OrderedCollection new. - - "Determine the starting and ending rows and columns" - - startRow := (self currentMatrixIndex x min: self firstMatrixIndex x). - endRow := (self currentMatrixIndex x max: self firstMatrixIndex x). - startCol := (self currentMatrixIndex y min: self firstMatrixIndex y). - endCol := (self currentMatrixIndex y max: self firstMatrixIndex y). - - "Fill the collection with all indices within the rectangle" - startRow to: endRow do: [:row | - startCol to: endCol do: [:col | - collection add: (row@col) - ]. - ]. + (self currentMatrixIndex isNil or: [self firstMatrixIndex isNil]) ifTrue: [^nil]. + collection := OrderedCollection new. + + "Determine the starting and ending rows and columns" + self flag: 'method extraction'. + startRow := (self currentMatrixIndex x min: self firstMatrixIndex x). + endRow := (self currentMatrixIndex x max: self firstMatrixIndex x). + startCol := (self currentMatrixIndex y min: self firstMatrixIndex y). + endCol := (self currentMatrixIndex y max: self firstMatrixIndex y). + + "Fill the collection with all indices within the rectangle" + startRow to: endRow do: [:row | + startCol to: endCol do: [:col | + collection add: (row @ col)]]. + self outputSet: collection asSet. - ^ self outputSet. + ^ self outputSet ] { #category : #select, - #'squeak_changestamp' : 'Valentin Teutschbein 7/9/2024 21:26' + #'squeak_changestamp' : 'JS 7/11/2024 13:43' } GMTEBrush >> resetOutputSet [ - self outputSet: Set new. + self outputSet: Set new ] { diff --git a/source/GM-TE/GMTEEditorTileMap.class.st b/source/GM-TE/GMTEEditorTileMap.class.st index 1f47a0f6..310e5d2e 100644 --- a/source/GM-TE/GMTEEditorTileMap.class.st +++ b/source/GM-TE/GMTEEditorTileMap.class.st @@ -113,18 +113,17 @@ GMTEEditorTileMap >> model: anObject [ { #category : #'event handling', - #'squeak_changestamp' : 'Valentin Teutschbein 7/10/2024 13:07' + #'squeak_changestamp' : 'JS 7/11/2024 14:13' } GMTEEditorTileMap >> mouseDown: anEvent [ "Implements placement of tiles" - | selectedCoordinates activeLayer selectedIndex | + | selectedIndex | self flag: 'refactor; method extraction for "Add tiles to layer" to minimize redundancy with mouseMove?'. self model singleLayerSelected ifFalse: [^nil]. - activeLayer := self model selectedLayers anyOne. selectedIndex := self tileIndexFromPosition: anEvent position. self model brush firstMatrixIndex: selectedIndex. - selectedCoordinates := self model brush executeWithMatrixIndex: selectedIndex andLayer: (self tileMatrixStack layer: activeLayer). + self model brush executeWithMatrixIndex: selectedIndex andLayer: (self tileMatrixStack layer: self model selectedLayers anyOne). anEvent yellowButtonPressed ifTrue: [self tileSelectionSet highlightImage: nil]. ^ true @@ -132,7 +131,7 @@ GMTEEditorTileMap >> mouseDown: anEvent [ { #category : #'event handling', - #'squeak_changestamp' : 'Valentin Teutschbein 7/10/2024 13:06' + #'squeak_changestamp' : 'JS 7/11/2024 14:01' } GMTEEditorTileMap >> mouseMove: anEvent [ "Implements highlighting of tiles when hovering" @@ -149,12 +148,12 @@ GMTEEditorTileMap >> mouseMove: anEvent [ (selectedCoordinates select: [:c | (self tileMatrixStack layer: activeLayer) inBounds: c]) do: [:t| hoveredTileHighlighting := self highlightingTileFromIndex: t. - hoveredTileHighlighting ifNotNil: [self tileSelectionSet highlightTile: hoveredTileHighlighting]]. + hoveredTileHighlighting ifNotNil: [self tileSelectionSet highlightTile: hoveredTileHighlighting]] ] { #category : #'event handling', - #'squeak_changestamp' : 'Valentin Teutschbein 7/10/2024 13:11' + #'squeak_changestamp' : 'JS 7/11/2024 14:11' } GMTEEditorTileMap >> mouseUp: anEvent [ @@ -164,8 +163,8 @@ GMTEEditorTileMap >> mouseUp: anEvent [ activeLayer := self model selectedLayers anyOne. self updateTiles: (indicesToAdd asCollection) inLayer: activeLayer FromEvent: anEvent. self model brush resetOutputSet. - (self previousTileStates size > 0) ifTrue: [self saveTileEditChanges]. - self tileSelectionSet highlightImage: (self model selectedTile). + (self previousTileStates isEmpty) ifFalse: [self saveTileEditChanges]. + self tileSelectionSet highlightImage: (self model selectedTile) ] { @@ -284,12 +283,12 @@ GMTEEditorTileMap >> savePreviousImageFromPosition: aPosition inLayer: aLayer [ { #category : #'command processing', - #'squeak_changestamp' : 'Valentin Teutschbein 7/6/2024 11:52' + #'squeak_changestamp' : 'JS 7/11/2024 14:07' } GMTEEditorTileMap >> saveTileEditChanges [ self - model addCommand: (GMTEEditTilesCommand previousTiles: previousTileStates currentTiles: currentTileChanges tilemap: self). + model addCommand: (GMTEEditTilesCommand previousTiles: self previousTileStates currentTiles: self currentTileChanges tilemap: self). self resetTileEditChanges. ] @@ -323,12 +322,12 @@ GMTEEditorTileMap >> updateTileSprite: aTile [ { #category : #updating, - #'squeak_changestamp' : 'Valentin Teutschbein 7/9/2024 22:07' + #'squeak_changestamp' : 'JS 7/11/2024 14:01' } GMTEEditorTileMap >> updateTiles: aCoordinateCollection inLayer: aLayer FromEvent: anEvent [ "Add currently selected tile (model) to editable matrix stack at mouse position" | tile | - self flag: 'saveNewImage confict with alex fix?'. + self flag: 'refactor'. (self tileIndexFromPosition: anEvent position) ifNil: [^ nil]. (anEvent redButtonChanged and: [self model selectedTile notNil]) ifTrue: [