From 31cc0ec927455e8c6ea808a87776db7a71ebaec0 Mon Sep 17 00:00:00 2001 From: Joshua Storost Date: Wed, 10 Jul 2024 13:20:42 +0200 Subject: [PATCH 1/9] new testfile for tests --- testMapFile.morph | Bin 28270 -> 27668 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/testMapFile.morph b/testMapFile.morph index 14d6c90c41414de90a9cf22854b797c0fde48351..3c046b80687bf83ed689a396818ca229f474a5d1 100644 GIT binary patch literal 27668 zcmdU2Z*W{!b>G$QzSaJd_R29$EM)CQ$g+fxEL(9Mr%ojKPh^sf6|V`nCW)VRpH`3E zeQ)#LTic=?keLi1hR|WA(?-)0TR=z97CrzSwFL%=z?TA@PFwXuX**Io4V{*0Df&Q4 z)4IQN?|W}o8;|1;WYVh{|K^>0&;4`GJ@=gREWhLb`1-d7&RAwOlYg$RspX?1hcf0| zX6#5Nr!Hg;A38jqxl~ad&2}>NS`iP&Gku2-kBvY0bjCC?V}~;Du2)<>)ya$OeM?%ATA3fL3tw1=TP#D`RL^GrFNWx?0gcsG%PmwpN+T*j3eX&TDgd$I{el zHXH~9!tDgCvrtiOJ7YUmz2MX>Er!;R51oxT*NP|2N(J&@ z>c%v2aLy4_gTzWt4>fvOsH|a$D{7^#iJ2}~s$o~^1#Aq{nHKRz#D+pvX_h4lY5_}~ z(rV5;OABI3cV<+_(JTYIt<>gKK2`Lr;bPCshuK16sqHe3R6-^A}b2F}mR*9QdQSuAbS+hcOi`F21_|VjpX%#g~E9OkA zHct#OvA8m8){UagBIZ?C1B==9*($NvEIwDSRHoeC0%?WCv}=xL*ibb~%<>7}s~4dW zm*A@7%O&%AwN}x@qRpbts@;Fn z=2dLez(AX|7fdMHaBLihiLK}cZb5#*cC;#sS7_*2qo`eD(JQ*GLyar}eb&(NgjyAc zuHXQxYOSFxz6s@tdUf`7$Co-K2IsV*Uaz(c3FS41nuG;6OpniZ4+(X$WrxJAxKeTX znKG~GrFn-brlps3gLM?OIesfmV-nX7hC#+kkFI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ye3D0&7C#7=Ar=7wfCClWP^-?6>$*oH>&?9hzRoGh!BRzQkB8aWXrzq3kogEkY_e7b# zWe`iD_n>b9#7=Ar=CX>=zbDG{&1My$IZ39kmQ{r2B$>V(h?T$S zMBIQ4^oR&K&-^JU@p@qG$$F9W;1<4 zbCN-+24W?46y-py#I~Rpyo6aG=I==cB{Em5ITZHBW z0~eM-Y&JfM5@-IqE3XDFEP&Q*{QCdlPTODz3SU8QXy#|60>VcNgdL3x*)Z@pRTIpH@ZdIO1f4ndfz`PJ#?KU(tX=4 zCjru@Qo**L(<}DXCb;Sr67I)*k>H>0gC~<{!gZ68=nbUASCI;~Jd+9raSiS2e^RQo zMQNzfhlMh~HuKfRR3yl*1@%_P4Py6Thf|^C7P4iT*2P|7?_ctY8t-k9qwHS#^lqW; zxX-uaCZX-P-?w9z&~_-k9sNSvG49*ZhvcOmq%%`)SwAzZmkH3RL_LqwN0?#)Fmeho zNH>7LArIL3HNcMT0QSFnx2)i4oNiyf`yRm9VZhh zwsJk-t}6lTo`OSvz|))V1MK-e;KrK)+v%3=bO+$_e*o@30eJIWfc$p=hiH)l9|!D- z0dA-RuK5L^n;6gLuK@1*Ea1)$1M)$@5H0eJ&jWTJ0$l$kz%^v$Yu^XhMAwGj`vTyO zp8#&(4>6yXZRR>uv_N1g;6phe#DC}0=;>f_ofVCw?ls)K;8e!yGE5l24&xQ!f< zp+)ZfF`$1Rp!aitt(OC?d?%ojDC==@MDYiJ+x7zXe;Tk?2K2ohu;bT&tB(P$m Date: Thu, 11 Jul 2024 18:27:42 +0200 Subject: [PATCH 2/9] Rotating works great --- source/GM-TE/GMTEEditor.class.st | 6 ++++-- source/GM-TE/GMTETileSelectionSet.class.st | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/source/GM-TE/GMTEEditor.class.st b/source/GM-TE/GMTEEditor.class.st index bba90be5..e40eb6cf 100644 --- a/source/GM-TE/GMTEEditor.class.st +++ b/source/GM-TE/GMTEEditor.class.st @@ -1756,12 +1756,14 @@ GMTEEditor >> resetSelectedLayers [ { #category : #TODO, - #'squeak_changestamp' : 'Alex M 6/25/2024 18:26' + #'squeak_changestamp' : 'mcjj 7/11/2024 17:52' } GMTEEditor >> rotateSelectedTile [ self selectedTile: (self selectedTile rotateBy: #right centerAt: (self selectedTile extent / 2)). - self tileMap tileSelectionSet highlightImage: self selectedTile + self tileMap tileSelectionSet removeAllHighlightings. + self tileMap tileSelectionSet highlightImage: self selectedTile. + self tileMap tileSelectionSet applyAllHighlightings ] { diff --git a/source/GM-TE/GMTETileSelectionSet.class.st b/source/GM-TE/GMTETileSelectionSet.class.st index 51ad30b8..44228e7d 100644 --- a/source/GM-TE/GMTETileSelectionSet.class.st +++ b/source/GM-TE/GMTETileSelectionSet.class.st @@ -7,6 +7,17 @@ Class { #category : #'GM-TE-TileMap' } +{ + #category : #highlighting, + #'squeak_changestamp' : 'mcjj 7/11/2024 17:11' +} +GMTETileSelectionSet >> applyAllHighlightings [ + + self do: [:tile | + self applyHighlightingVisuals: tile] + +] + { #category : #highlighting, #'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:51' @@ -71,6 +82,17 @@ GMTETileSelectionSet >> initialize: n [ ] +{ + #category : #highlighting, + #'squeak_changestamp' : 'mcjj 7/11/2024 17:52' +} +GMTETileSelectionSet >> removeAllHighlightings [ + "Remove applied highlightings if any" + + self do: [:tile | + self removeHighlightingVisuals: tile] +] + { #category : #highlighting, #'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:51' From 1f9e8985b2740518924a50b6ab647754c2110118 Mon Sep 17 00:00:00 2001 From: Jannis Jost Date: Fri, 12 Jul 2024 00:21:52 +0200 Subject: [PATCH 3/9] i love squeak can't even handle shi(f)t --- source/GM-TE/GMTEEditor.class.st | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/source/GM-TE/GMTEEditor.class.st b/source/GM-TE/GMTEEditor.class.st index 5a785de9..fedd96b3 100644 --- a/source/GM-TE/GMTEEditor.class.st +++ b/source/GM-TE/GMTEEditor.class.st @@ -1061,7 +1061,7 @@ GMTEEditor >> exportMenu [ { #category : #'input handling', - #'squeak_changestamp' : 'mcjj 7/11/2024 15:57' + #'squeak_changestamp' : 'mcjj 7/12/2024 00:19' } GMTEEditor >> filterEvent: aKeyboardEvent for: anObject [ | key | @@ -1069,22 +1069,15 @@ GMTEEditor >> filterEvent: aKeyboardEvent for: anObject [ aKeyboardEvent isKeystroke ifFalse: [^ aKeyboardEvent]. - key := aKeyboardEvent key. - + key := aKeyboardEvent keyCharacter. + aKeyboardEvent commandKeyPressed ifTrue: [ - aKeyboardEvent shiftPressed - ifTrue: [ - key caseOf: { - [$Z] -> [self redo]. - } otherwise: [^ aKeyboardEvent "no hit"]. - ^ aKeyboardEvent ignore "hit"] - ifFalse: [ - key caseOf: { - [$Z] -> [self undo]. - [$Y] -> [self redo]. - [$R] -> [self rotateSelectedTile]. - } otherwise: [^ aKeyboardEvent "no hit"]. - ^ aKeyboardEvent ignore "hit"]]. + key caseOf: { + [$z] -> [self undo]. + [$y] -> [self redo]. + [$r] -> [self rotateSelectedTile]. + } otherwise: [^ aKeyboardEvent "no hit"]. + ^ aKeyboardEvent ignore "hit"]. ^ aKeyboardEvent "no hit" ] From 42b77fe94144550d2fa45d651f0872e25bfd6dea Mon Sep 17 00:00:00 2001 From: Joshua Date: Fri, 12 Jul 2024 11:33:26 +0200 Subject: [PATCH 4/9] method extraction --- source/GM-TE/GMTEEditorTileMap.class.st | 75 ++++++++++++++----------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/source/GM-TE/GMTEEditorTileMap.class.st b/source/GM-TE/GMTEEditorTileMap.class.st index 430f16ec..5de7b5f5 100644 --- a/source/GM-TE/GMTEEditorTileMap.class.st +++ b/source/GM-TE/GMTEEditorTileMap.class.st @@ -62,6 +62,24 @@ GMTEEditorTileMap >> currentTileChanges: anObject [ currentTileChanges := anObject ] +{ + #category : #updating, + #'squeak_changestamp' : 'JS 7/12/2024 11:30' +} +GMTEEditorTileMap >> deleteTiles: aCoordinateCollection inLayer: aLayer [ + "delete tiles from editable matrix stack at given indices" + + | tile | + aCoordinateCollection do: [:c | + ((self tileMatrixStack layer: aLayer) inBounds: c) ifTrue: [ + tile := self tileMatrixStack layer: aLayer at: c y at: c x. + tile ifNotNil: [ + self savePreviousImageFromMatrixCoordinate: c inLayer: aLayer. + tile abandon. + self tileMatrixStack layer: aLayer at: c y at: c x put: nil. + self saveNewImageFromPosition: tile position inLayer: aLayer]]]. +] + { #category : #'event handling', #'squeak_changestamp' : 'jj 6/23/2024 13:35' @@ -190,6 +208,24 @@ GMTEEditorTileMap >> mouseUp: anEvent [ ] +{ + #category : #updating, + #'squeak_changestamp' : 'JS 7/12/2024 11:30' +} +GMTEEditorTileMap >> placeTiles: aCoordinateCollection inLayer: aLayer [ + "Add currently selected tile (model) to editable matrix stack at given indices" + + | tile | + aCoordinateCollection do: [:c | + self savePreviousImageFromMatrixCoordinate: c inLayer: aLayer. + ((self tileMatrixStack layer: aLayer) inBounds: c) ifTrue: [ + tile := self tileMatrixStack layer: aLayer at: c y at: c x. + tile ifNil: [ tile := self generateTileAtlayer: aLayer x: c x y: c y stack: tileMatrixStack tileType: GMTETile]. + self updateTileSprite: tile. + self saveNewImageFromPosition: tile position inLayer: aLayer]]. + +] + { #category : #accessing, #'squeak_changestamp' : 'Alex M 6/28/2024 19:44' @@ -345,39 +381,14 @@ GMTEEditorTileMap >> updateTileSprite: aTile [ { #category : #updating, - #'squeak_changestamp' : 'Alex M 7/11/2024 17:39' + #'squeak_changestamp' : 'JS 7/12/2024 11:31' } GMTEEditorTileMap >> updateTiles: aCoordinateCollection inLayer: aLayer FromEvent: anEvent [ - "Add currently selected tile (model) to editable matrix stack at mouse position" - | tile | - self flag: 'refactor'. + (self tileIndexFromPosition: anEvent position) ifNil: [^ nil]. - (anEvent redButtonChanged and: [self model selectedTile notNil]) - ifTrue: [ - aCoordinateCollection do: [:c | - self savePreviousImageFromMatrixCoordinate: c inLayer: aLayer. - ((self tileMatrixStack layer: aLayer) inBounds: c) ifTrue: [ - tile := self tileMatrixStack layer: aLayer at: c y at: c x. - tile - ifNil: [ tile := self generateTileAtlayer: aLayer x: c x y: c y stack: tileMatrixStack tileType: GMTETile]. - self updateTileSprite: tile. - self saveNewImageFromPosition: tile position inLayer: aLayer] - ]. - self model savedSinceModified: false]. - (anEvent yellowButtonChanged) - ifTrue: [ - aCoordinateCollection do: [:c | - | tilePos | - ((self tileMatrixStack layer: aLayer) inBounds: c) ifTrue: [ - tile := self tileMatrixStack layer: aLayer at: c y at: c x. - tile - ifNotNil: [ - self savePreviousImageFromMatrixCoordinate: c inLayer: aLayer. - tilePos := tile position. - tile abandon. - self tileMatrixStack layer: aLayer at: c y at: c x put: nil. - self saveNewImageFromPosition: tilePos inLayer: aLayer. - self model savedSinceModified: false]. - ] - ]] + + (anEvent redButtonChanged and: [self model selectedTile notNil]) ifTrue: [self placeTiles: aCoordinateCollection inLayer: aLayer]. + (anEvent yellowButtonChanged) ifTrue: [self deleteTiles: aCoordinateCollection inLayer: aLayer]. + + self model savedSinceModified: false ] From 5c9b3d73276883686b8d34b1e2a6a5b2021efa91 Mon Sep 17 00:00:00 2001 From: Valentin Teutschbein Date: Fri, 12 Jul 2024 14:22:17 +0200 Subject: [PATCH 5/9] refactored brush --- source/GM-TE/GMTEBrush.class.st | 183 ++++++++++++++---------- source/GM-TE/GMTEEditorTileMap.class.st | 100 +++++-------- 2 files changed, 137 insertions(+), 146 deletions(-) diff --git a/source/GM-TE/GMTEBrush.class.st b/source/GM-TE/GMTEBrush.class.st index a97ea5c2..8f6a8d69 100644 --- a/source/GM-TE/GMTEBrush.class.st +++ b/source/GM-TE/GMTEBrush.class.st @@ -1,3 +1,6 @@ +" +A GMTEBrush is responsible for returning a set of indices that are selected by the user and selecting the interchangeable algorithm for the execution. +" Class { #name : #GMTEBrush, #superclass : #Object, @@ -9,7 +12,8 @@ Class { 'firstMatrixIndex', 'outputSet' ], - #category : #'GM-TE-UI' + #category : #'GM-TE-UI', + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:49' } { @@ -22,54 +26,58 @@ GMTEBrush class >> borderingOffsets [ ] { - #category : #forms, - #'squeak_changestamp' : 'JS 7/11/2024 15:40' + #category : #brushHelper, + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:03' } GMTEBrush >> calculateOffsetsForRadius: aRadius [ |offsets| offsets := OrderedCollection new. - (0-radius to: radius) do: [:dx | - (0-radius to: radius) do: [:dy | + (0-self radius to: self radius) do: [:dx | + (0-self radius to: self radius) do: [:dy | ((dx squared + dy squared) <= aRadius squared) ifTrue: [offsets add: dx @ dy]]]. - ^offsets + ^ offsets ] { #category : #accessing, - #'squeak_changestamp' : 'Valentin Teutschbein 7/6/2024 12:48' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:40' } GMTEBrush >> currentBrush [ + ^ currentBrush ] { #category : #accessing, - #'squeak_changestamp' : 'Valentin Teutschbein 7/6/2024 12:48' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:40' } -GMTEBrush >> currentBrush: anObject [ - currentBrush := anObject +GMTEBrush >> currentBrush: aBrush [ + + currentBrush := aBrush ] { #category : #accessing, - #'squeak_changestamp' : 'Valentin Teutschbein 7/9/2024 08:47' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:41' } GMTEBrush >> currentMatrixIndex [ + ^ currentMatrixIndex ] { #category : #accessing, - #'squeak_changestamp' : 'Valentin Teutschbein 7/9/2024 08:47' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:41' } -GMTEBrush >> currentMatrixIndex: anObject [ - currentMatrixIndex := anObject +GMTEBrush >> currentMatrixIndex: anIndex [ + + currentMatrixIndex := anIndex ] { - #category : #'as yet unclassified', + #category : #execute, #'squeak_changestamp' : 'Valentin Teutschbein 7/11/2024 17:10' } GMTEBrush >> executeWithMatrixIndex: anIndex andLayer: aLayer [ @@ -81,8 +89,8 @@ GMTEBrush >> executeWithMatrixIndex: anIndex andLayer: aLayer [ ] { - #category : #forms, - #'squeak_changestamp' : 'Valentin Teutschbein 7/11/2024 17:10' + #category : #brushes, + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:26' } GMTEBrush >> fillBrush [ @@ -95,51 +103,49 @@ GMTEBrush >> fillBrush [ self outputSet add: self currentMatrixIndex. visited at: self currentMatrixIndex y at: self currentMatrixIndex x put: true. - self fillDfsWithVisited: visited andIndex: self currentMatrixIndex andOriginTile: startTile andSet: self outputSet. + self fillDfsWithVisited: visited andIndex: self currentMatrixIndex andOriginTile: startTile. ^ self outputSet ] { - #category : #forms, - #'squeak_changestamp' : 'JS 7/11/2024 18:28' + #category : #brushHelper, + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:32' } -GMTEBrush >> fillDfsWithVisited: aVisitedMatrix andIndex: anIndex andOriginTile: anOriginTile andSet: aSet [ - self flag: 'REFACTOR!'. - +GMTEBrush >> fillDfsWithVisited: aVisitedMatrix andIndex: anIndex andOriginTile: anOriginTile [ + + | newIndex newTile | GMTEBrush borderingOffsets do: [:offset | - | newIndex newTile tilesNil tilesSame | newIndex := offset + anIndex. ((self layer inBounds: newIndex) and: [(aVisitedMatrix at: newIndex y at: newIndex x) isNil]) ifTrue:[ newTile := self layer at: newIndex y at: newIndex x. - tilesNil := (anOriginTile isNil) and: [newTile isNil]. - tilesSame := (anOriginTile isNil not and: [newTile isNil not]) and: [anOriginTile imageForm bits hash = newTile imageForm bits hash]. - - (tilesNil or: tilesSame) ifTrue: [ - aSet add: newIndex. + (self tile: anOriginTile equalsTile: newTile) ifTrue: [ + self outputSet add: newIndex. aVisitedMatrix at: newIndex y at: newIndex x put: true. - self fillDfsWithVisited: aVisitedMatrix andIndex: newIndex andOriginTile: anOriginTile andSet: aSet]]] + self fillDfsWithVisited: aVisitedMatrix andIndex: newIndex andOriginTile: anOriginTile]]] ] { #category : #accessing, - #'squeak_changestamp' : 'Valentin Teutschbein 7/9/2024 08:49' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:41' } GMTEBrush >> firstMatrixIndex [ + ^ firstMatrixIndex ] { #category : #accessing, - #'squeak_changestamp' : 'Valentin Teutschbein 7/9/2024 08:49' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:42' } -GMTEBrush >> firstMatrixIndex: anObject [ - firstMatrixIndex := anObject +GMTEBrush >> firstMatrixIndex: anIndex [ + + firstMatrixIndex := anIndex ] { - #category : #forms, + #category : #initialization, #'squeak_changestamp' : 'JS 7/11/2024 13:59' } GMTEBrush >> initialize [ @@ -150,34 +156,36 @@ GMTEBrush >> initialize [ { #category : #accessing, - #'squeak_changestamp' : 'Valentin Teutschbein 7/6/2024 14:51' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:42' } GMTEBrush >> layer [ + ^ layer ] { #category : #accessing, - #'squeak_changestamp' : 'Valentin Teutschbein 7/6/2024 14:51' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:42' } -GMTEBrush >> layer: anObject [ - layer := anObject +GMTEBrush >> layer: aLayer [ + + layer := aLayer ] { - #category : #forms, - #'squeak_changestamp' : 'Valentin Teutschbein 7/11/2024 17:11' + #category : #brushes, + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:53' } GMTEBrush >> lineBrush [ self resetOutputSet. - self firstMatrixIndex ifNil: [^nil]. + self firstMatrixIndex ifNil: [^ nil]. - (self rasterizeLineBetweenAStart: self firstMatrixIndex andAnEnd: self currentMatrixIndex) do: [:point | + (self rasterizeLineBetweenStart: self firstMatrixIndex andEnd: self currentMatrixIndex) do: [:index | (self calculateOffsetsForRadius: self offsetCorrectedRadius) do: [:offset | - self outputSet add: (point + offset)]]. + self outputSet add: (index + offset)]]. - ^(self outputSet) + ^ self outputSet ] @@ -193,18 +201,20 @@ GMTEBrush >> offsetCorrectedRadius [ { #category : #accessing, - #'squeak_changestamp' : 'Valentin Teutschbein 7/9/2024 21:18' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:43' } GMTEBrush >> outputSet [ + ^ outputSet ] { #category : #accessing, - #'squeak_changestamp' : 'Valentin Teutschbein 7/9/2024 21:18' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:43' } -GMTEBrush >> outputSet: anObject [ - outputSet := anObject +GMTEBrush >> outputSet: aSet [ + + outputSet := aSet ] { @@ -218,15 +228,15 @@ GMTEBrush >> radius [ { #category : #accessing, - #'squeak_changestamp' : 'Valentin Teutschbein 7/11/2024 17:15' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:43' } -GMTEBrush >> radius: aNumber [ +GMTEBrush >> radius: aRadius [ - radius := aNumber + radius := aRadius ] { - #category : #forms, + #category : #brushes, #'squeak_changestamp' : 'Valentin Teutschbein 7/11/2024 17:09' } GMTEBrush >> radiusBrush [ @@ -239,62 +249,64 @@ GMTEBrush >> radiusBrush [ ] { - #category : #forms, - #'squeak_changestamp' : 'JS 7/11/2024 18:26' + #category : #brushHelper, + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:52' } -GMTEBrush >> rasterizeLineBetweenAStart: aStartPoint andAnEnd: anEndPoint [ +GMTEBrush >> rasterizeLineBetweenStart: aStartIndex andEnd: anEndIndex [ "implementation of Bresenhams Line Algorithm" - | linePointsCollection deltaX deltaY stepX stepY error error2 x y | + | lineIndexCollection deltaX deltaY stepX stepY error error2 x y index | - self flag: 'todo: method extraction? - Ich glaube geht schlecht'. + self flag: 'repeat formatting'. - deltaX := (anEndPoint x - aStartPoint x) abs. - deltaY := (anEndPoint y - aStartPoint y) abs. - stepX := (aStartPoint x < anEndPoint x) ifTrue: [1] ifFalse: [-1]. - stepY := (aStartPoint y < anEndPoint y) ifTrue: [1] ifFalse: [-1]. + deltaX := (anEndIndex x - aStartIndex x) abs. + deltaY := (anEndIndex y - aStartIndex y) abs. + stepX := (aStartIndex x < anEndIndex x) ifTrue: [1] ifFalse: [-1]. + stepY := (aStartIndex y < anEndIndex y) ifTrue: [1] ifFalse: [-1]. error := deltaX - deltaY. - x := aStartPoint x. - y := aStartPoint y. + x := aStartIndex x. + y := aStartIndex y. - linePointsCollection := OrderedCollection new. + lineIndexCollection := OrderedCollection new. - [ - | point | - point := x @ y. - linePointsCollection add: point. - (x = anEndPoint x and: [y = anEndPoint y]) ifTrue: [ - ^linePointsCollection]. + [ index := x @ y. + lineIndexCollection add: index. + (x = anEndIndex x and: [y = anEndIndex y]) ifTrue: [^ lineIndexCollection]. error2 := 2 * error. (error2 > (0 - deltaY)) ifTrue: [ error := error - deltaY. x := x + stepX]. (error2 < deltaX) ifTrue: [ error := error + deltaX. - y := y + stepY] - ] repeat + y := y + stepY]] repeat ] { - #category : #forms, - #'squeak_changestamp' : 'JS 7/11/2024 17:34' + #category : #brushes, + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:57' } GMTEBrush >> rectangleBrush [ + | endCol endRow startCol startRow | self resetOutputSet. self firstMatrixIndex ifNil: [^ nil]. - (self currentMatrixIndex x min: self firstMatrixIndex x) to: (self currentMatrixIndex x max: self firstMatrixIndex x) do: [:row | - (self currentMatrixIndex y min: self firstMatrixIndex y) to: (self currentMatrixIndex y max: self firstMatrixIndex y) do: [:col | - self outputSet add: (row @ col)]]. + 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). + + startRow to: endRow do: [:row | + startCol to: endCol do: [:col | + self outputSet add: (row@col)]]. ^ self outputSet ] { - #category : #select, + #category : #brushHelper, #'squeak_changestamp' : 'JS 7/11/2024 13:43' } GMTEBrush >> resetOutputSet [ @@ -337,3 +349,16 @@ GMTEBrush >> selectRectangleBrush [ self currentBrush: [self rectangleBrush] ] + +{ + #category : #brushHelper, + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 13:31' +} +GMTEBrush >> tile: aTile equalsTile: anotherTile [ + + | tilesNil tilesSame | + tilesNil := (aTile isNil) and: [anotherTile isNil]. + tilesSame := (aTile isNil not and: [anotherTile isNil not]) and: [aTile imageForm bits hash = anotherTile imageForm bits hash]. + + ^ (tilesNil or: [tilesSame]) +] diff --git a/source/GM-TE/GMTEEditorTileMap.class.st b/source/GM-TE/GMTEEditorTileMap.class.st index 5de7b5f5..dcc54e73 100644 --- a/source/GM-TE/GMTEEditorTileMap.class.st +++ b/source/GM-TE/GMTEEditorTileMap.class.st @@ -22,59 +22,37 @@ GMTEEditorTileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPaddi model: aModel ] -{ - #category : #TODO, - #'squeak_changestamp' : 'Valentin Teutschbein 7/5/2024 17:07' -} -GMTEEditorTileMap >> calculateTileCollectionFromPosition: aPos andLayer: aLayer [ - - | index rawCollection resultCollection | - self flag: 'remove method'. - index := self tileIndexFromPosition: aPos. - index ifNil: [^ nil]. - rawCollection := OrderedCollection new. - resultCollection := OrderedCollection new. - self flag: 'Add different algos'. - rawCollection add: (self tileMatrixStack layer: aLayer at: index y at: index x). - self halt. - - rawCollection add: (self tileMatrixStack layer: aLayer at: index y at: ((index x)+1)). - rawCollection do: [:t | - t ifNil: [resultCollection add: (self generateTileAtlayer: aLayer x: index x y: index y stack: self tileMatrixStack tileType: GMTETile)]. - t ifNotNil: [resultCollection add: t] - ]. - ^ resultCollection -] - { #category : #accessing, - #'squeak_changestamp' : 'Alex M 6/28/2024 19:28' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:15' } GMTEEditorTileMap >> currentTileChanges [ + ^ currentTileChanges ] { #category : #accessing, - #'squeak_changestamp' : 'Alex M 6/28/2024 19:28' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:18' } -GMTEEditorTileMap >> currentTileChanges: anObject [ - currentTileChanges := anObject +GMTEEditorTileMap >> currentTileChanges: aTileDictionary [ + + currentTileChanges := aTileDictionary ] { #category : #updating, - #'squeak_changestamp' : 'JS 7/12/2024 11:30' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:21' } -GMTEEditorTileMap >> deleteTiles: aCoordinateCollection inLayer: aLayer [ +GMTEEditorTileMap >> deleteTiles: anIndexSet inLayer: aLayer [ "delete tiles from editable matrix stack at given indices" | tile | - aCoordinateCollection do: [:c | + anIndexSet do: [:c | ((self tileMatrixStack layer: aLayer) inBounds: c) ifTrue: [ tile := self tileMatrixStack layer: aLayer at: c y at: c x. tile ifNotNil: [ - self savePreviousImageFromMatrixCoordinate: c inLayer: aLayer. + self savePreviousImageFromIndex: c inLayer: aLayer. tile abandon. self tileMatrixStack layer: aLayer at: c y at: c x put: nil. self saveNewImageFromPosition: tile position inLayer: aLayer]]]. @@ -210,14 +188,14 @@ GMTEEditorTileMap >> mouseUp: anEvent [ { #category : #updating, - #'squeak_changestamp' : 'JS 7/12/2024 11:30' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:21' } GMTEEditorTileMap >> placeTiles: aCoordinateCollection inLayer: aLayer [ "Add currently selected tile (model) to editable matrix stack at given indices" | tile | aCoordinateCollection do: [:c | - self savePreviousImageFromMatrixCoordinate: c inLayer: aLayer. + self savePreviousImageFromIndex: c inLayer: aLayer. ((self tileMatrixStack layer: aLayer) inBounds: c) ifTrue: [ tile := self tileMatrixStack layer: aLayer at: c y at: c x. tile ifNil: [ tile := self generateTileAtlayer: aLayer x: c x y: c y stack: tileMatrixStack tileType: GMTETile]. @@ -228,18 +206,20 @@ GMTEEditorTileMap >> placeTiles: aCoordinateCollection inLayer: aLayer [ { #category : #accessing, - #'squeak_changestamp' : 'Alex M 6/28/2024 19:44' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:16' } GMTEEditorTileMap >> previousTileStates [ + ^ previousTileStates ] { #category : #accessing, - #'squeak_changestamp' : 'Alex M 6/28/2024 19:44' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:18' } -GMTEEditorTileMap >> previousTileStates: anObject [ - previousTileStates := anObject +GMTEEditorTileMap >> previousTileStates: aTileDictionary [ + + previousTileStates := aTileDictionary ] { @@ -282,9 +262,9 @@ GMTEEditorTileMap >> resetTileEditChanges [ { #category : #'command processing', - #'squeak_changestamp' : 'Alex M 7/6/2024 01:31' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:20' } -GMTEEditorTileMap >> saveNewImageFromCoordinate: aCoordinate inLayer: aLayer [ +GMTEEditorTileMap >> saveNewImageFromIndex: aCoordinate inLayer: aLayer [ | tile | tile := self tileMatrixStack layer: aLayer at: aCoordinate y at: aCoordinate x. @@ -296,18 +276,18 @@ GMTEEditorTileMap >> saveNewImageFromCoordinate: aCoordinate inLayer: aLayer [ { #category : #'command processing', - #'squeak_changestamp' : 'Alex M 7/6/2024 01:34' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:20' } GMTEEditorTileMap >> saveNewImageFromPosition: aPosition inLayer: aLayer [ - self saveNewImageFromCoordinate: (self tileIndexFromPosition: aPosition) inLayer: aLayer + self saveNewImageFromIndex: (self tileIndexFromPosition: aPosition) inLayer: aLayer ] { #category : #'command processing', - #'squeak_changestamp' : 'Alex M 7/6/2024 01:54' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:20' } -GMTEEditorTileMap >> savePreviousImageFromCoordinate: aCoordinate inLayer: aLayer [ +GMTEEditorTileMap >> savePreviousImageFromIndex: aCoordinate inLayer: aLayer [ | tile | tile := self tileMatrixStack layer: aLayer at: aCoordinate y at: aCoordinate x. @@ -319,25 +299,11 @@ GMTEEditorTileMap >> savePreviousImageFromCoordinate: aCoordinate inLayer: aLaye { #category : #'command processing', - #'squeak_changestamp' : 'Valentin Teutschbein 7/6/2024 11:46' -} -GMTEEditorTileMap >> savePreviousImageFromMatrixCoordinate: aCoordinate inLayer: aLayer [ - | tile | - - tile := self tileMatrixStack layer: aLayer at: aCoordinate y at: aCoordinate x. - - tile - ifNil: [self previousTileStates at: {aCoordinate x. aCoordinate y. aLayer} ifAbsentPut: nil] - ifNotNil: [self previousTileStates at: {aCoordinate x. aCoordinate y. aLayer} ifAbsentPut: tile fullResolutionSprite] -] - -{ - #category : #'command processing', - #'squeak_changestamp' : 'Valentin Teutschbein 7/6/2024 11:58' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:20' } GMTEEditorTileMap >> savePreviousImageFromPosition: aPosition inLayer: aLayer [ - self savePreviousImageFromCoordinate: (self tileIndexFromPosition: aPosition) inLayer: aLayer + self savePreviousImageFromIndex: (self tileIndexFromPosition: aPosition) inLayer: aLayer ] { @@ -362,11 +328,11 @@ GMTEEditorTileMap >> tileSelectionSet [ { #category : #accessing, - #'squeak_changestamp' : 'TW 6/22/2024 01:25' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:16' } -GMTEEditorTileMap >> tileSelectionSet: anObject [ +GMTEEditorTileMap >> tileSelectionSet: aSet [ - tileSelectionSet := anObject + tileSelectionSet := aSet ] { @@ -381,14 +347,14 @@ GMTEEditorTileMap >> updateTileSprite: aTile [ { #category : #updating, - #'squeak_changestamp' : 'JS 7/12/2024 11:31' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:13' } -GMTEEditorTileMap >> updateTiles: aCoordinateCollection inLayer: aLayer FromEvent: anEvent [ +GMTEEditorTileMap >> updateTiles: anIndexSet inLayer: aLayer FromEvent: anEvent [ (self tileIndexFromPosition: anEvent position) ifNil: [^ nil]. - (anEvent redButtonChanged and: [self model selectedTile notNil]) ifTrue: [self placeTiles: aCoordinateCollection inLayer: aLayer]. - (anEvent yellowButtonChanged) ifTrue: [self deleteTiles: aCoordinateCollection inLayer: aLayer]. + (anEvent redButtonChanged and: [self model selectedTile notNil]) ifTrue: [self placeTiles: anIndexSet inLayer: aLayer]. + (anEvent yellowButtonChanged) ifTrue: [self deleteTiles: anIndexSet inLayer: aLayer]. self model savedSinceModified: false ] From 1f4979481666af270d1a136aae29539c64a9cc94 Mon Sep 17 00:00:00 2001 From: Joshua Storost Date: Fri, 12 Jul 2024 15:25:34 +0200 Subject: [PATCH 6/9] minor refactor --- source/GM-TE/GMTEEditorTileMap.class.st | 89 ++++++++++++++++--------- 1 file changed, 58 insertions(+), 31 deletions(-) diff --git a/source/GM-TE/GMTEEditorTileMap.class.st b/source/GM-TE/GMTEEditorTileMap.class.st index dcc54e73..7a619573 100644 --- a/source/GM-TE/GMTEEditorTileMap.class.st +++ b/source/GM-TE/GMTEEditorTileMap.class.st @@ -22,6 +22,15 @@ GMTEEditorTileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPaddi model: aModel ] +{ + #category : #accessing, + #'squeak_changestamp' : 'JS 7/12/2024 14:48' +} +GMTEEditorTileMap >> brush [ + + ^ model brush +] + { #category : #accessing, #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:15' @@ -85,6 +94,22 @@ GMTEEditorTileMap >> handlesMouseOver: anEvent [ ^ true ] +{ + #category : #'event handling', + #'squeak_changestamp' : 'JS 7/12/2024 15:15' +} +GMTEEditorTileMap >> highlightTilesFromIndices: anIndexSet [ + + | hoveredHighlightingTile | + self tileSelectionSet clearAllHighlightings. + anIndexSet ifNil: [^ nil]. + + (anIndexSet select: [:c | + (self tileMatrixStack layer: self model selectedLayers anyOne) inBounds: c]) do: [:t | + hoveredHighlightingTile := self highlightingTileFromIndex: t. + hoveredHighlightingTile ifNotNil: [self tileSelectionSet highlightTile: hoveredHighlightingTile]] +] + { #category : #initialization, #'squeak_changestamp' : 'Alex M 6/28/2024 20:24' @@ -118,71 +143,64 @@ GMTEEditorTileMap >> model: anObject [ { #category : #'event handling', - #'squeak_changestamp' : 'JS 7/11/2024 14:13' + #'squeak_changestamp' : 'JS 7/12/2024 15:19' } GMTEEditorTileMap >> mouseDown: anEvent [ - "Implements placement of tiles" | selectedIndex | - self flag: 'refactor; method extraction for "Add tiles to layer" to minimize redundancy with mouseMove?'. - self model singleLayerSelected ifFalse: [^nil]. + self model singleLayerSelected ifFalse: [^ nil]. + selectedIndex := self tileIndexFromPosition: anEvent position. - self model brush firstMatrixIndex: selectedIndex. - self model brush executeWithMatrixIndex: selectedIndex andLayer: (self tileMatrixStack layer: self model selectedLayers anyOne). - anEvent yellowButtonPressed ifTrue: [self tileSelectionSet highlightImage: nil]. + self brush firstMatrixIndex: selectedIndex. - ^ true + self brush executeWithMatrixIndex: selectedIndex andLayer: (self tileMatrixStack layer: self selectedLayers anyOne). + anEvent yellowButtonPressed ifTrue: [self tileSelectionSet highlightImage: nil] ] { #category : #'event handling', - #'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 17:18' + #'squeak_changestamp' : 'JS 7/12/2024 15:18' } GMTEEditorTileMap >> mouseLeave: anEvent [ - self tileSelectionSet clearAllHighlightings. - - ^ true + self tileSelectionSet clearAllHighlightings ] { #category : #'event handling', - #'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 17:01' + #'squeak_changestamp' : 'JS 7/12/2024 15:17' } GMTEEditorTileMap >> mouseMove: anEvent [ "Implements highlighting of tiles when hovering" - | hoveredTileHighlighting activeLayer selectedCoordinates | + | activeLayer selectedIndices | self model singleLayerSelected ifFalse: [^ nil]. - activeLayer := self model selectedLayers anyOne. - selectedCoordinates := self model brush executeWithMatrixIndex: (self tileIndexFromPosition: anEvent position) andLayer: (self tileMatrixStack layer: activeLayer). - (anEvent redButtonPressed or: [anEvent yellowButtonPressed]) ifFalse: [self model brush resetOutputSet]. - self tileSelectionSet clearAllHighlightings. + activeLayer := self tileMatrixStack layer: self model selectedLayers anyOne. + selectedIndices := self model brush executeWithMatrixIndex: (self tileIndexFromPosition: anEvent position) andLayer: activeLayer. - selectedCoordinates ifNil: [^ nil]. + (anEvent redButtonPressed or: [anEvent yellowButtonPressed]) ifFalse: [self model brush resetOutputSet]. - (selectedCoordinates select: [:c | - (self tileMatrixStack layer: activeLayer) inBounds: c]) do: [:t | - hoveredTileHighlighting := self highlightingTileFromIndex: t. - hoveredTileHighlighting ifNotNil: [self tileSelectionSet highlightTile: hoveredTileHighlighting]] + self highlightTilesFromIndices: selectedIndices ] { #category : #'event handling', - #'squeak_changestamp' : 'mcjj 7/11/2024 16:20' + #'squeak_changestamp' : 'JS 7/12/2024 15:23' } GMTEEditorTileMap >> mouseUp: anEvent [ - | indicesToAdd activeLayer | - self model brush firstMatrixIndex: nil. - indicesToAdd := self model brush outputSet. - activeLayer := self model selectedLayers anyOne. - self updateTiles: (indicesToAdd asCollection) inLayer: activeLayer FromEvent: anEvent. + | selectedIndices | + self brush firstMatrixIndex: nil. + + selectedIndices := self brush outputSet asCollection. + + self updateTiles: selectedIndices inLayer: self selectedLayers anyOne FromEvent: anEvent. self model brush resetOutputSet. + (self previousTileStates isEmpty) ifFalse: [self saveTileEditChanges]. - self tileSelectionSet clearAllHighlightings. - self tileSelectionSet highlightImage: (self model selectedTile) + self tileSelectionSet clearAllHighlightings; + highlightImage: (self model selectedTile) ] @@ -317,6 +335,15 @@ GMTEEditorTileMap >> saveTileEditChanges [ self resetTileEditChanges. ] +{ + #category : #accessing, + #'squeak_changestamp' : 'JS 7/12/2024 14:49' +} +GMTEEditorTileMap >> selectedLayers [ + + ^ model selectedLayers +] + { #category : #accessing, #'squeak_changestamp' : 'jj 6/23/2024 13:35' From fc582ffc3693bdbfe2c8ec9369349d57e324ebe6 Mon Sep 17 00:00:00 2001 From: Joshua Storost Date: Fri, 12 Jul 2024 17:05:05 +0200 Subject: [PATCH 7/9] EditorTileMap linting done --- source/GM-TE/GMTEBrush.class.st | 4 +- source/GM-TE/GMTEEditorTileMap.class.st | 149 +++++++++++------------- 2 files changed, 70 insertions(+), 83 deletions(-) diff --git a/source/GM-TE/GMTEBrush.class.st b/source/GM-TE/GMTEBrush.class.st index 8f6a8d69..616c22cb 100644 --- a/source/GM-TE/GMTEBrush.class.st +++ b/source/GM-TE/GMTEBrush.class.st @@ -78,9 +78,9 @@ GMTEBrush >> currentMatrixIndex: anIndex [ { #category : #execute, - #'squeak_changestamp' : 'Valentin Teutschbein 7/11/2024 17:10' + #'squeak_changestamp' : 'JS 7/12/2024 16:50' } -GMTEBrush >> executeWithMatrixIndex: anIndex andLayer: aLayer [ +GMTEBrush >> executeWithIndex: anIndex andLayer: aLayer [ anIndex ifNil: [^ nil]. self currentMatrixIndex: anIndex. diff --git a/source/GM-TE/GMTEEditorTileMap.class.st b/source/GM-TE/GMTEEditorTileMap.class.st index 7a619573..82018287 100644 --- a/source/GM-TE/GMTEEditorTileMap.class.st +++ b/source/GM-TE/GMTEEditorTileMap.class.st @@ -1,3 +1,6 @@ +" +A GMTEEditorTileMap is a Tilemap that can only be found in the editor or as an exported .morph file. It provides the additional methods for i/o compared to the regular tilemap. +" Class { #name : #GMTEEditorTileMap, #superclass : #GMTETileMap, @@ -7,7 +10,8 @@ Class { 'previousTileStates', 'currentTileChanges' ], - #category : #'GM-TE-TileMap' + #category : #'GM-TE-TileMap', + #'squeak_changestamp' : 'JS 7/12/2024 17:04' } { @@ -24,11 +28,11 @@ GMTEEditorTileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPaddi { #category : #accessing, - #'squeak_changestamp' : 'JS 7/12/2024 14:48' + #'squeak_changestamp' : 'JS 7/12/2024 16:55' } GMTEEditorTileMap >> brush [ - ^ model brush + ^ self model brush ] { @@ -51,7 +55,7 @@ GMTEEditorTileMap >> currentTileChanges: aTileDictionary [ { #category : #updating, - #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:21' + #'squeak_changestamp' : 'JS 7/12/2024 16:37' } GMTEEditorTileMap >> deleteTiles: anIndexSet inLayer: aLayer [ "delete tiles from editable matrix stack at given indices" @@ -64,7 +68,7 @@ GMTEEditorTileMap >> deleteTiles: anIndexSet inLayer: aLayer [ self savePreviousImageFromIndex: c inLayer: aLayer. tile abandon. self tileMatrixStack layer: aLayer at: c y at: c x put: nil. - self saveNewImageFromPosition: tile position inLayer: aLayer]]]. + self saveNewImageFromIndex: c inLayer: aLayer]]] ] { @@ -95,7 +99,7 @@ GMTEEditorTileMap >> handlesMouseOver: anEvent [ ] { - #category : #'event handling', + #category : #updating, #'squeak_changestamp' : 'JS 7/12/2024 15:15' } GMTEEditorTileMap >> highlightTilesFromIndices: anIndexSet [ @@ -134,18 +138,19 @@ GMTEEditorTileMap >> model [ { #category : #accessing, - #'squeak_changestamp' : 'TW 6/22/2024 01:25' + #'squeak_changestamp' : 'JS 7/12/2024 16:25' } -GMTEEditorTileMap >> model: anObject [ +GMTEEditorTileMap >> model: aModel [ - model := anObject + model := aModel ] { #category : #'event handling', - #'squeak_changestamp' : 'JS 7/12/2024 15:19' + #'squeak_changestamp' : 'JS 7/12/2024 16:50' } GMTEEditorTileMap >> mouseDown: anEvent [ + "prepare the brush for next operation on self" | selectedIndex | self model singleLayerSelected ifFalse: [^ nil]. @@ -153,42 +158,45 @@ GMTEEditorTileMap >> mouseDown: anEvent [ selectedIndex := self tileIndexFromPosition: anEvent position. self brush firstMatrixIndex: selectedIndex. - self brush executeWithMatrixIndex: selectedIndex andLayer: (self tileMatrixStack layer: self selectedLayers anyOne). + self brush executeWithIndex: selectedIndex andLayer: (self tileMatrixStack layer: self selectedLayers anyOne). anEvent yellowButtonPressed ifTrue: [self tileSelectionSet highlightImage: nil] ] { #category : #'event handling', - #'squeak_changestamp' : 'JS 7/12/2024 15:18' + #'squeak_changestamp' : 'JS 7/12/2024 16:27' } GMTEEditorTileMap >> mouseLeave: anEvent [ - + self tileSelectionSet clearAllHighlightings ] { #category : #'event handling', - #'squeak_changestamp' : 'JS 7/12/2024 15:17' + #'squeak_changestamp' : 'JS 7/12/2024 16:54' } GMTEEditorTileMap >> mouseMove: anEvent [ - "Implements highlighting of tiles when hovering" + "implements highlighting of tiles when hovering" - | activeLayer selectedIndices | + | activeLayer selectedIndices currentIndex | self model singleLayerSelected ifFalse: [^ nil]. activeLayer := self tileMatrixStack layer: self model selectedLayers anyOne. - selectedIndices := self model brush executeWithMatrixIndex: (self tileIndexFromPosition: anEvent position) andLayer: activeLayer. + currentIndex := self tileIndexFromPosition: anEvent position. + + selectedIndices := self brush executeWithIndex: currentIndex index andLayer: activeLayer. - (anEvent redButtonPressed or: [anEvent yellowButtonPressed]) ifFalse: [self model brush resetOutputSet]. + (anEvent redButtonPressed or: [anEvent yellowButtonPressed]) ifFalse: [self brush resetOutputSet]. self highlightTilesFromIndices: selectedIndices ] { #category : #'event handling', - #'squeak_changestamp' : 'JS 7/12/2024 15:23' + #'squeak_changestamp' : 'JS 7/12/2024 16:28' } GMTEEditorTileMap >> mouseUp: anEvent [ + "apply brush operation on tilemap" | selectedIndices | self brush firstMatrixIndex: nil. @@ -196,29 +204,30 @@ GMTEEditorTileMap >> mouseUp: anEvent [ selectedIndices := self brush outputSet asCollection. self updateTiles: selectedIndices inLayer: self selectedLayers anyOne FromEvent: anEvent. - self model brush resetOutputSet. + self brush resetOutputSet. (self previousTileStates isEmpty) ifFalse: [self saveTileEditChanges]. - self tileSelectionSet clearAllHighlightings; - highlightImage: (self model selectedTile) + self tileSelectionSet + clearAllHighlightings; + highlightImage: (self model selectedTile) ] { #category : #updating, - #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:21' + #'squeak_changestamp' : 'JS 7/12/2024 16:46' } GMTEEditorTileMap >> placeTiles: aCoordinateCollection inLayer: aLayer [ - "Add currently selected tile (model) to editable matrix stack at given indices" + "add currently selected tile (model) to editable matrix stack at given indices" | tile | aCoordinateCollection do: [:c | self savePreviousImageFromIndex: c inLayer: aLayer. ((self tileMatrixStack layer: aLayer) inBounds: c) ifTrue: [ tile := self tileMatrixStack layer: aLayer at: c y at: c x. - tile ifNil: [ tile := self generateTileAtlayer: aLayer x: c x y: c y stack: tileMatrixStack tileType: GMTETile]. - self updateTileSprite: tile. - self saveNewImageFromPosition: tile position inLayer: aLayer]]. + tile ifNil: [tile := self generateTileAtlayer: aLayer x: c x y: c y stack: tileMatrixStack tileType: GMTETile]. + self model selectedTile ifNotNil: [tile updateSprite: self model selectedTile]. + self saveNewImageFromIndex: c inLayer: aLayer]] ] @@ -252,12 +261,12 @@ GMTEEditorTileMap >> rescaleMap [ ] { - #category : #TODO, - #'squeak_changestamp' : 'Alex M 7/3/2024 23:50' + #category : #updating, + #'squeak_changestamp' : 'JS 7/12/2024 16:31' } GMTEEditorTileMap >> resetLayers: aSet [ - | layer | + | layer | aSet do: [:layerIndex | layer := self tileMatrixStack layer: layerIndex. layer withIndicesDo: [:tile :y :x | @@ -280,68 +289,52 @@ GMTEEditorTileMap >> resetTileEditChanges [ { #category : #'command processing', - #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:20' + #'squeak_changestamp' : 'JS 7/12/2024 16:34' } -GMTEEditorTileMap >> saveNewImageFromIndex: aCoordinate inLayer: aLayer [ - | tile | - - tile := self tileMatrixStack layer: aLayer at: aCoordinate y at: aCoordinate x. +GMTEEditorTileMap >> saveNewImageFromIndex: anIndex inLayer: aLayer [ + | tile | + tile := self tileMatrixStack layer: aLayer at: anIndex y at: anIndex x. + tile - ifNil: [self currentTileChanges at: {aCoordinate x. aCoordinate y. aLayer} put: nil] - ifNotNil: [self currentTileChanges at: {aCoordinate x. aCoordinate y. aLayer} put: tile fullResolutionSprite] + ifNil: [self currentTileChanges at: {anIndex x. anIndex y. aLayer} put: nil] + ifNotNil: [self currentTileChanges at: {anIndex x. anIndex y. aLayer} put: tile fullResolutionSprite] ] { #category : #'command processing', - #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:20' + #'squeak_changestamp' : 'JS 7/12/2024 16:40' } -GMTEEditorTileMap >> saveNewImageFromPosition: aPosition inLayer: aLayer [ - - self saveNewImageFromIndex: (self tileIndexFromPosition: aPosition) inLayer: aLayer -] +GMTEEditorTileMap >> savePreviousImageFromIndex: anIndex inLayer: aLayer [ -{ - #category : #'command processing', - #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:20' -} -GMTEEditorTileMap >> savePreviousImageFromIndex: aCoordinate inLayer: aLayer [ - | tile | - - tile := self tileMatrixStack layer: aLayer at: aCoordinate y at: aCoordinate x. + | tile | + tile := self tileMatrixStack layer: aLayer at: anIndex y at: anIndex x. tile - ifNil: [self previousTileStates at: {aCoordinate x. aCoordinate y. aLayer} ifAbsentPut: nil] - ifNotNil: [self previousTileStates at: {aCoordinate x. aCoordinate y. aLayer} ifAbsentPut: tile fullResolutionSprite] + ifNil: [self previousTileStates at: {anIndex x. anIndex y. aLayer} ifAbsentPut: nil] + ifNotNil: [self previousTileStates at: {anIndex x. anIndex y. aLayer} ifAbsentPut: tile fullResolutionSprite] ] { #category : #'command processing', - #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:20' -} -GMTEEditorTileMap >> savePreviousImageFromPosition: aPosition inLayer: aLayer [ - - self savePreviousImageFromIndex: (self tileIndexFromPosition: aPosition) inLayer: aLayer -] - -{ - #category : #'command processing', - #'squeak_changestamp' : 'JS 7/11/2024 14:07' + #'squeak_changestamp' : 'JS 7/12/2024 16:43' } GMTEEditorTileMap >> saveTileEditChanges [ - - self - model addCommand: (GMTEEditTilesCommand previousTiles: self previousTileStates currentTiles: self currentTileChanges tilemap: self). - self resetTileEditChanges. + + | command | + command := GMTEEditTilesCommand previousTiles: self previousTileStates currentTiles: self currentTileChanges tilemap: self. + + self model addCommand: command. + self resetTileEditChanges ] { #category : #accessing, - #'squeak_changestamp' : 'JS 7/12/2024 14:49' + #'squeak_changestamp' : 'JS 7/12/2024 16:55' } GMTEEditorTileMap >> selectedLayers [ - ^ model selectedLayers + ^ self model selectedLayers ] { @@ -364,24 +357,18 @@ GMTEEditorTileMap >> tileSelectionSet: aSet [ { #category : #updating, - #'squeak_changestamp' : 'Alex M 6/25/2024 18:08' -} -GMTEEditorTileMap >> updateTileSprite: aTile [ - "Helper function to apply sprite from tile selection to aTile" - - self model selectedTile ifNotNil: [aTile updateSprite: self model selectedTile] -] - -{ - #category : #updating, - #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:13' + #'squeak_changestamp' : 'JS 7/12/2024 16:52' } GMTEEditorTileMap >> updateTiles: anIndexSet inLayer: aLayer FromEvent: anEvent [ + | validLeftClick validRightClick | (self tileIndexFromPosition: anEvent position) ifNil: [^ nil]. - (anEvent redButtonChanged and: [self model selectedTile notNil]) ifTrue: [self placeTiles: anIndexSet inLayer: aLayer]. - (anEvent yellowButtonChanged) ifTrue: [self deleteTiles: anIndexSet inLayer: aLayer]. + validLeftClick := anEvent redButtonChanged and: [self model selectedTile notNil]. + validRightClick := anEvent yellowButtonChanged. + + validLeftClick ifTrue: [self placeTiles: anIndexSet inLayer: aLayer]. + validRightClick ifTrue: [self deleteTiles: anIndexSet inLayer: aLayer]. self model savedSinceModified: false ] From fb6501180f2f976ab3e3b722c742967820e90365 Mon Sep 17 00:00:00 2001 From: Valentin Teutschbein Date: Fri, 12 Jul 2024 17:08:01 +0200 Subject: [PATCH 8/9] fixed index naming bug --- source/GM-TE/GMTEEditorTileMap.class.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/GM-TE/GMTEEditorTileMap.class.st b/source/GM-TE/GMTEEditorTileMap.class.st index 82018287..6b50a4c4 100644 --- a/source/GM-TE/GMTEEditorTileMap.class.st +++ b/source/GM-TE/GMTEEditorTileMap.class.st @@ -173,7 +173,7 @@ GMTEEditorTileMap >> mouseLeave: anEvent [ { #category : #'event handling', - #'squeak_changestamp' : 'JS 7/12/2024 16:54' + #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 17:07' } GMTEEditorTileMap >> mouseMove: anEvent [ "implements highlighting of tiles when hovering" @@ -184,7 +184,7 @@ GMTEEditorTileMap >> mouseMove: anEvent [ activeLayer := self tileMatrixStack layer: self model selectedLayers anyOne. currentIndex := self tileIndexFromPosition: anEvent position. - selectedIndices := self brush executeWithIndex: currentIndex index andLayer: activeLayer. + selectedIndices := self brush executeWithIndex: currentIndex andLayer: activeLayer. (anEvent redButtonPressed or: [anEvent yellowButtonPressed]) ifFalse: [self brush resetOutputSet]. From 49ed11ba0b79ae80ef31a94d20ed7fc4bfb15c51 Mon Sep 17 00:00:00 2001 From: Aleksander Morgensterns Date: Fri, 12 Jul 2024 17:17:43 +0200 Subject: [PATCH 9/9] fixed unnecessary saving, deletion bug --- source/GM-TE/GMTEEditTilesCommand.class.st | 17 +++++++++++++++++ source/GM-TE/GMTEEditorTileMap.class.st | 15 +++++++-------- source/GM-TE/GMTETilemapSizeCommand.class.st | 17 ----------------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/source/GM-TE/GMTEEditTilesCommand.class.st b/source/GM-TE/GMTEEditTilesCommand.class.st index 1972bc86..3d5d2879 100644 --- a/source/GM-TE/GMTEEditTilesCommand.class.st +++ b/source/GM-TE/GMTEEditTilesCommand.class.st @@ -2,6 +2,7 @@ Class { #name : #GMTEEditTilesCommand, #superclass : #GMTECommand, #instVars : [ + 'editor', 'tileMap', 'previousSprites', 'currentSprites' @@ -47,6 +48,22 @@ GMTEEditTilesCommand >> do [ self placeTilesFromList: self currentSprites ] +{ + #category : #accessing, + #'squeak_changestamp' : 'Alex M 7/12/2024 17:12' +} +GMTEEditTilesCommand >> editor [ + ^ editor +] + +{ + #category : #accessing, + #'squeak_changestamp' : 'Alex M 7/12/2024 17:12' +} +GMTEEditTilesCommand >> editor: anObject [ + editor := anObject +] + { #category : #initialization, #'squeak_changestamp' : 'Alex M 6/28/2024 02:45' diff --git a/source/GM-TE/GMTEEditorTileMap.class.st b/source/GM-TE/GMTEEditorTileMap.class.st index 6b50a4c4..1fc66fb7 100644 --- a/source/GM-TE/GMTEEditorTileMap.class.st +++ b/source/GM-TE/GMTEEditorTileMap.class.st @@ -55,7 +55,7 @@ GMTEEditorTileMap >> currentTileChanges: aTileDictionary [ { #category : #updating, - #'squeak_changestamp' : 'JS 7/12/2024 16:37' + #'squeak_changestamp' : 'Alex M 7/12/2024 17:16' } GMTEEditorTileMap >> deleteTiles: anIndexSet inLayer: aLayer [ "delete tiles from editable matrix stack at given indices" @@ -68,7 +68,8 @@ GMTEEditorTileMap >> deleteTiles: anIndexSet inLayer: aLayer [ self savePreviousImageFromIndex: c inLayer: aLayer. tile abandon. self tileMatrixStack layer: aLayer at: c y at: c x put: nil. - self saveNewImageFromIndex: c inLayer: aLayer]]] + self saveNewImageFromIndex: c inLayer: aLayer. + self model savedSinceModified: false]]] ] { @@ -215,7 +216,7 @@ GMTEEditorTileMap >> mouseUp: anEvent [ { #category : #updating, - #'squeak_changestamp' : 'JS 7/12/2024 16:46' + #'squeak_changestamp' : 'Alex M 7/12/2024 17:15' } GMTEEditorTileMap >> placeTiles: aCoordinateCollection inLayer: aLayer [ "add currently selected tile (model) to editable matrix stack at given indices" @@ -227,8 +228,8 @@ GMTEEditorTileMap >> placeTiles: aCoordinateCollection inLayer: aLayer [ tile := self tileMatrixStack layer: aLayer at: c y at: c x. tile ifNil: [tile := self generateTileAtlayer: aLayer x: c x y: c y stack: tileMatrixStack tileType: GMTETile]. self model selectedTile ifNotNil: [tile updateSprite: self model selectedTile]. - self saveNewImageFromIndex: c inLayer: aLayer]] - + self saveNewImageFromIndex: c inLayer: aLayer. + self model savedSinceModified: false]] ] { @@ -357,7 +358,7 @@ GMTEEditorTileMap >> tileSelectionSet: aSet [ { #category : #updating, - #'squeak_changestamp' : 'JS 7/12/2024 16:52' + #'squeak_changestamp' : 'Alex M 7/12/2024 17:14' } GMTEEditorTileMap >> updateTiles: anIndexSet inLayer: aLayer FromEvent: anEvent [ @@ -369,6 +370,4 @@ GMTEEditorTileMap >> updateTiles: anIndexSet inLayer: aLayer FromEvent: anEvent validLeftClick ifTrue: [self placeTiles: anIndexSet inLayer: aLayer]. validRightClick ifTrue: [self deleteTiles: anIndexSet inLayer: aLayer]. - - self model savedSinceModified: false ] diff --git a/source/GM-TE/GMTETilemapSizeCommand.class.st b/source/GM-TE/GMTETilemapSizeCommand.class.st index fe18b4f0..fe683543 100644 --- a/source/GM-TE/GMTETilemapSizeCommand.class.st +++ b/source/GM-TE/GMTETilemapSizeCommand.class.st @@ -2,7 +2,6 @@ Class { #name : #GMTETilemapSizeCommand, #superclass : #GMTEEditTilesCommand, #instVars : [ - 'editor', 'method', 'prevSize', 'newSize', @@ -34,22 +33,6 @@ GMTETilemapSizeCommand >> do [ self editor perform: self method with: self newSize ] -{ - #category : #accessing, - #'squeak_changestamp' : 'Alex M 7/1/2024 18:00' -} -GMTETilemapSizeCommand >> editor [ - ^ editor -] - -{ - #category : #accessing, - #'squeak_changestamp' : 'Alex M 7/1/2024 18:00' -} -GMTETilemapSizeCommand >> editor: anObject [ - editor := anObject -] - { #category : #accessing, #'squeak_changestamp' : 'Alex M 7/1/2024 18:48'