From 24951908cd824c13d22263bf48fecb90fa73fd56 Mon Sep 17 00:00:00 2001 From: Aleksander Morgensterns Date: Sat, 22 Jun 2024 14:48:31 +0200 Subject: [PATCH] applied code style to GM-Core, fixed small tilemap bug --- source/GM-TE/GMTEEditor.class.st | 11 +++-- source/GM-TE/GMTEEditorTileMap.class.st | 44 +++++++---------- source/GM-TE/GMTEImageMorph.class.st | 21 ++++---- source/GM-TE/GMTETile.class.st | 8 ++-- source/GM-TE/GMTETileMap.class.st | 9 ++-- source/GM-TE/GMTETileMatrixLayer.class.st | 8 ++-- source/GM-TE/GMTETileMatrixStack.class.st | 56 +++++++++++----------- source/GM-TE/GMTETileSelectionSet.class.st | 35 +++++--------- 8 files changed, 86 insertions(+), 106 deletions(-) diff --git a/source/GM-TE/GMTEEditor.class.st b/source/GM-TE/GMTEEditor.class.st index 2b1717c6..f4beb88f 100644 --- a/source/GM-TE/GMTEEditor.class.st +++ b/source/GM-TE/GMTEEditor.class.st @@ -432,7 +432,7 @@ GMTEEditor >> createInspectorSpecWithBuilder: aBuilder [ { #category : #building, - #'squeak_changestamp' : 'Alex M 6/22/2024 01:54' + #'squeak_changestamp' : 'Alex M 6/22/2024 02:12' } GMTEEditor >> createLayersSpecWithBuilder: aBuilder [ @@ -451,7 +451,8 @@ GMTEEditor >> createLayersSpecWithBuilder: aBuilder [ frame: (LayoutFrame fractions: (0 @ 0 corner: 1 @ 0) offsets: (0 @ 0 corner: 0 @ 30)). aBuilder pluggablePanelSpec new - frame: (LayoutFrame fractions: (0.8 @ 0 corner: 1 @ 1) offsets: (0 @ 30 corner: 0 @ 0)); + frame: (LayoutFrame fractions: (1 @ 0 corner: 1 @ 1) offsets: (-30 @ 30 corner: 0 @ 0)); + children: { aBuilder pluggableImageButtonSpec new model:self; @@ -509,7 +510,7 @@ GMTEEditor >> createLayersSpecWithBuilder: aBuilder [ getSelectionList: #layerAt:; setSelectionList: #layerAt:put:; autoDeselect: false; - frame: (LayoutFrame fractions: (0 @ 0 corner: 0.8 @ 1) offsets: (0 @ 30 corner: 0 @ 0))}; + frame: (LayoutFrame fractions: (0 @ 0 corner: 1 @ 1) offsets: (0 @ 30 corner: -30 @ 0))}; verticalResizing: #shrinkWrap; yourself @@ -581,12 +582,12 @@ GMTEEditor >> createToolBarSpecWithBuilder: aBuilder [ { #category : #building, - #'squeak_changestamp' : 'Alex M 6/14/2024 00:49' + #'squeak_changestamp' : 'TW 6/9/2024 18:12' } GMTEEditor >> createTraySpecWithBuilder: aBuilder [ ^aBuilder pluggableScrollPaneSpec new name: 'tray'; - frame: (LayoutFrame fractions: (0.2 @ 0.8 corner: 1 @ 1) offsets: (0 @ 0 corner: -175 @ 0)); + frame: (LayoutFrame fractions: (0.2 @ 0.8 corner: 0.8 @ 1) offsets: nil); minimumHeight:75; yourself ] diff --git a/source/GM-TE/GMTEEditorTileMap.class.st b/source/GM-TE/GMTEEditorTileMap.class.st index 87828cea..7a13a643 100644 --- a/source/GM-TE/GMTEEditorTileMap.class.st +++ b/source/GM-TE/GMTEEditorTileMap.class.st @@ -10,11 +10,11 @@ Class { { #category : #'as yet unclassified', - #'squeak_changestamp' : 'JS 6/4/2024 16:56' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:39' } GMTEEditorTileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPadding sizeRatio: aRatio model: aModel [ - ^ self new + ^(self new) setDimensionsWidth: aWidth height: aHeight padding: aPadding; tileSizeRatio: aRatio; model: aModel. @@ -31,20 +31,20 @@ GMTEEditorTileMap >> blendLayers: aSet [ { #category : #'event handling', - #'squeak_changestamp' : 'Ivo Zilkenat 6/22/2024 03:11' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:39' } GMTEEditorTileMap >> handlesMouseDown: anEvent [ - ^ true + ^true ] { #category : #'event handling', - #'squeak_changestamp' : 'Ivo Zilkenat 6/22/2024 03:11' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:39' } GMTEEditorTileMap >> handlesMouseMove: anEvent [ - ^ true + ^true ] { @@ -77,11 +77,11 @@ GMTEEditorTileMap >> model: anObject [ { #category : #'event handling', - #'squeak_changestamp' : 'Ivo Zilkenat 6/21/2024 22:23' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:39' } GMTEEditorTileMap >> mouseDown: anEvent [ - | clickedTile activeLayer| + | clickedTile activeLayer | self model singleLayerSelected ifTrue: [ @@ -89,12 +89,12 @@ GMTEEditorTileMap >> mouseDown: anEvent [ clickedTile := self tileFromPosition: anEvent position layer: activeLayer. self updateTile: clickedTile inLayer: activeLayer FromEvent: anEvent]. - ^ true + ^true ] { #category : #'event handling', - #'squeak_changestamp' : 'TW 6/20/2024 16:35' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:40' } GMTEEditorTileMap >> mouseMove: anEvent [ @@ -108,19 +108,12 @@ GMTEEditorTileMap >> mouseMove: anEvent [ self tileSelectionSet clearAllHighlightings. - hoveredTileVisual - ifNotNil: [self tileSelectionSet highlightTile: hoveredTileVisual]. + hoveredTileVisual ifNotNil: [self tileSelectionSet highlightTile: hoveredTileVisual]. "TODO why another ifNil check here?" self updateTile: hoveredTile inLayer: activeLayer FromEvent: anEvent] "This solves the bug but not the root of the issue. TODO further investigation." - "self updateTiles." - "hoveredTileVisual - extent: self tileSizeWidth@self tileSizeHeight; - borderColor: Color white; - color: Color veryLightGray; - borderWidth: 2" ] { @@ -162,11 +155,11 @@ GMTEEditorTileMap >> resetLayers: aSet [ { #category : #accessing, - #'squeak_changestamp' : 'TW 5/22/2024 15:49' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:40' } GMTEEditorTileMap >> tileSelectionSet [ - ^ tileSelectionSet + ^tileSelectionSet ] { @@ -180,9 +173,10 @@ GMTEEditorTileMap >> tileSelectionSet: anObject [ { #category : #updating, - #'squeak_changestamp' : 'Ivo Zilkenat 6/21/2024 22:23' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:40' } GMTEEditorTileMap >> updateTile: aTile inLayer: aLayer FromEvent: anEvent [ + | tileIdx hoveredTile | hoveredTile := aTile. @@ -195,7 +189,7 @@ GMTEEditorTileMap >> updateTile: aTile inLayer: aLayer FromEvent: anEvent [ tileIdx ifNil: [^nil]. hoveredTile := self generateTileAtlayer: aLayer x: tileIdx x y: tileIdx y stack: self tileMatrixStack tileType: GMTETile]. "Set tile to currently selected tile" - self updateTileSpriteFromModel: hoveredTile. + self updateTileSprite: hoveredTile. self model savedSinceModified: false]. ((anEvent yellowButtonPressed) and: [hoveredTile notNil]) @@ -210,11 +204,9 @@ GMTEEditorTileMap >> updateTile: aTile inLayer: aLayer FromEvent: anEvent [ { #category : #updating, - #'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 22:44' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:41' } GMTEEditorTileMap >> updateTileSprite: aTile [ - self model selectedTile - ifNotNil: - [aTile applyTileSprite: (self model selectedTile)] + self model selectedTile ifNotNil: [aTile applyTileSprite: self model selectedTile] ] diff --git a/source/GM-TE/GMTEImageMorph.class.st b/source/GM-TE/GMTEImageMorph.class.st index 3df5c6b1..2277e4c6 100644 --- a/source/GM-TE/GMTEImageMorph.class.st +++ b/source/GM-TE/GMTEImageMorph.class.st @@ -9,13 +9,13 @@ Class { { #category : #'as yet unclassified', - #'squeak_changestamp' : 'Alex M 6/17/2024 18:45' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:30' } GMTEImageMorph >> asBlendedWithImageMorph: anImageMorph [ - anImageMorph - ifNil: [^ self]. - ^ (ImageMorph new) + anImageMorph ifNil: [^self]. + + ^(ImageMorph new) image: ((FormCanvas on: self image) image: (anImageMorph image) at: 0@0 @@ -29,12 +29,10 @@ GMTEImageMorph >> asBlendedWithImageMorph: anImageMorph [ { #category : #accessing, - #'squeak_changestamp' : 'TW 6/22/2024 01:16' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:28' } GMTEImageMorph >> extent: anExtent [ "override ImageMorph extent functionality. ALWAYS KEEPS RATIO" - - "self image: (self image scaledToSize: anExtent)." super extent: anExtent. self image: (self fullResolutionSprite scaledToSize: anExtent) @@ -42,22 +40,21 @@ GMTEImageMorph >> extent: anExtent [ { #category : #removing, - #'squeak_changestamp' : 'Ivo Zilkenat 6/8/2024 22:01' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:29' } GMTEImageMorph >> free [ - (self owner) ifNotNil: [ - self owner removeMorph: self]. + self owner ifNotNil: [self owner removeMorph: self]. self abandon ] { #category : #accessing, - #'squeak_changestamp' : 'TW 5/22/2024 17:15' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:30' } GMTEImageMorph >> fullResolutionSprite [ - ^ fullResolutionSprite + ^fullResolutionSprite ] { diff --git a/source/GM-TE/GMTETile.class.st b/source/GM-TE/GMTETile.class.st index 3138cc31..be24daff 100644 --- a/source/GM-TE/GMTETile.class.st +++ b/source/GM-TE/GMTETile.class.st @@ -15,23 +15,23 @@ GMTETile class >> placeHolderColor [ { #category : #'as yet unclassified', - #'squeak_changestamp' : 'TW 5/22/2024 23:32' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:31' } GMTETile class >> position: aPoint extent: anExtent [ "comment stating purpose of message" - ^ self new + ^(self new) setPlaceholderWithExtent: anExtent color: self placeHolderColor; position: aPoint ] { #category : #'as yet unclassified', - #'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 22:43' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:34' } GMTETile >> applyTileSprite: aTile [ - self updateSprite: (aTile fullResolutionSprite) + self updateSprite: aTile fullResolutionSprite ] { diff --git a/source/GM-TE/GMTETileMap.class.st b/source/GM-TE/GMTETileMap.class.st index b581a2be..f9f5e335 100644 --- a/source/GM-TE/GMTETileMap.class.st +++ b/source/GM-TE/GMTETileMap.class.st @@ -34,7 +34,7 @@ Class { { #category : #'as yet unclassified', - #'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 22:57' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:38' } GMTETileMap class >> newFromEditableTileMap: aMap [ @@ -44,23 +44,22 @@ GMTETileMap class >> newFromEditableTileMap: aMap [ aMap tileMatrixStackBackground reset. "This fixed the temporary issue of orphaned morphs after copy" - newMap := (GMTETileMap newFrom: (aMap veryDeepCopy)) + newMap := (GMTETileMap newFrom: (aMap veryDeepCopy)) updateMap; hideVisualLayer; yourself. - aMap generateBackgroundTiles. "Part of the above fix" ^newMap ] { #category : #'as yet unclassified', - #'squeak_changestamp' : 'JS 6/4/2024 16:56' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:38' } GMTETileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPadding sizeRatio: aRatio [ - ^ self new + ^(self new) setDimensionsWidth: aWidth height: aHeight padding: aPadding; tileSizeRatio: aRatio ] diff --git a/source/GM-TE/GMTETileMatrixLayer.class.st b/source/GM-TE/GMTETileMatrixLayer.class.st index 1ee11a09..dc79d1de 100644 --- a/source/GM-TE/GMTETileMatrixLayer.class.st +++ b/source/GM-TE/GMTETileMatrixLayer.class.st @@ -105,11 +105,11 @@ GMTETileMatrixLayer >> initialize [ { #category : #accessing, - #'squeak_changestamp' : 'Ivo Zilkenat 6/11/2024 19:09' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:42' } GMTETileMatrixLayer >> layerIdx [ - ^ layerIdx + ^layerIdx ] { @@ -143,11 +143,11 @@ GMTETileMatrixLayer >> updateLayerIdx: anIdx [ { #category : #accessing, - #'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:17' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:42' } GMTETileMatrixLayer >> visible [ - ^ visible + ^visible ] { diff --git a/source/GM-TE/GMTETileMatrixStack.class.st b/source/GM-TE/GMTETileMatrixStack.class.st index 9be5cbc7..bb2de748 100644 --- a/source/GM-TE/GMTETileMatrixStack.class.st +++ b/source/GM-TE/GMTETileMatrixStack.class.st @@ -13,7 +13,7 @@ Class { { #category : #'as yet unclassified', - #'squeak_changestamp' : 'Ivo Zilkenat 6/12/2024 14:27' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:43' } GMTETileMatrixStack class >> fromWidth: aWidth height: aHeight [ @@ -23,11 +23,11 @@ GMTETileMatrixStack class >> fromWidth: aWidth height: aHeight [ { #category : #'as yet unclassified', - #'squeak_changestamp' : 'Ivo Zilkenat 6/12/2024 14:25' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:43' } GMTETileMatrixStack class >> fromWidth: aWidth height: aHeight morphicLayerOffset: anOffset [ - ^GMTETileMatrixStack new + ^(GMTETileMatrixStack new) width: aWidth; height: aHeight; morphicLayerStartingOffset: anOffset; @@ -119,11 +119,11 @@ GMTETileMatrixStack >> doTilesXYLidx: aBlock [ { #category : #accessing, - #'squeak_changestamp' : 'Ivo Zilkenat 5/27/2024 21:16' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:43' } GMTETileMatrixStack >> height [ - ^ height + ^height ] { @@ -156,50 +156,51 @@ GMTETileMatrixStack >> hideLayers: aSet [ { #category : #initilization, - #'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 23:12' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:44' } GMTETileMatrixStack >> initialize [ super initialize. - self matrixLayers: LinkedList new. - self visible: true + self + matrixLayers: LinkedList new; + visible: true "TODO: no base layer created" ] { #category : #accessing, - #'squeak_changestamp' : 'Ivo Zilkenat 6/12/2024 18:28' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:44' } GMTETileMatrixStack >> layer: aLayerIdx [ - ^ self matrixLayers at: aLayerIdx + ^self matrixLayers at: aLayerIdx ] { #category : #accessing, - #'squeak_changestamp' : 'TW 5/28/2024 11:15' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:44' } GMTETileMatrixStack >> layer: aLayerIdx at: x at: y [ - ^ (self matrixLayers at: aLayerIdx) at: x at: y + ^(self matrixLayers at: aLayerIdx) at: x at: y ] { #category : #accessing, - #'squeak_changestamp' : 'Ivo Zilkenat 6/12/2024 17:38' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:44' } GMTETileMatrixStack >> layer: aLayerIdx at: x at: y put: aTile [ - ^ (self matrixLayers at: aLayerIdx) addTile: aTile at: x at: y + ^(self matrixLayers at: aLayerIdx) addTile: aTile at: x at: y ] { #category : #accessing, - #'squeak_changestamp' : 'Ivo Zilkenat 5/27/2024 21:23' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:44' } GMTETileMatrixStack >> layerCount [ - ^ self matrixLayers size + ^self matrixLayers size ] { @@ -231,11 +232,11 @@ GMTETileMatrixStack >> mapLayers: anOrderedCollection withUnaryBlock: aBlock [ { #category : #accessing, - #'squeak_changestamp' : 'Ivo Zilkenat 5/27/2024 21:15' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:44' } GMTETileMatrixStack >> matrixLayers [ - ^ matrixLayers + ^matrixLayers ] { @@ -249,11 +250,11 @@ GMTETileMatrixStack >> matrixLayers: anObject [ { #category : #accessing, - #'squeak_changestamp' : 'Valentin 5/28/2024 13:16' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:44' } GMTETileMatrixStack >> morphicLayerStartingOffset [ - ^ morphicLayerStartingOffset + ^morphicLayerStartingOffset ] { @@ -267,9 +268,10 @@ GMTETileMatrixStack >> morphicLayerStartingOffset: anObject [ { #category : #adding, - #'squeak_changestamp' : 'Ivo Zilkenat 6/11/2024 19:22' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:44' } GMTETileMatrixStack >> pushLayer [ + self matrixLayers addLast: (GMTETileMatrixLayer width: self width height: self height @@ -437,11 +439,11 @@ GMTETileMatrixStack >> toggleLayerVisibility: anIdx [ { #category : #updating, - #'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 23:12' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:46' } GMTETileMatrixStack >> toggleVisibility [ - (self visible) + self visible ifTrue: [self visible: false] ifFalse: [self visible: true] @@ -449,11 +451,11 @@ GMTETileMatrixStack >> toggleVisibility [ { #category : #accessing, - #'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 23:09' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:46' } GMTETileMatrixStack >> visible [ - ^ visible + ^visible ] { @@ -470,11 +472,11 @@ GMTETileMatrixStack >> visible: aBool [ { #category : #accessing, - #'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 22:05' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:46' } GMTETileMatrixStack >> width [ - ^ width + ^width ] { diff --git a/source/GM-TE/GMTETileSelectionSet.class.st b/source/GM-TE/GMTETileSelectionSet.class.st index fe604b54..e2eecf4f 100644 --- a/source/GM-TE/GMTETileSelectionSet.class.st +++ b/source/GM-TE/GMTETileSelectionSet.class.st @@ -9,14 +9,9 @@ Class { { #category : #highlighting, - #'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 21:14' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:46' } GMTETileSelectionSet >> applyHighlightingVisuals: aTile [ - "comment stating purpose of message" - - "aTile morphicLayerNumber: 99." - "aTile borderWidth: 2." - "aTile borderColor: Color red." aTile applyDecoMorphHighlighting: self highlightImage @@ -34,11 +29,11 @@ GMTETileSelectionSet >> clearAllHighlightings [ { #category : #accessing, - #'squeak_changestamp' : 'TW 5/22/2024 15:59' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:46' } GMTETileSelectionSet >> highlightImage [ - ^ highlightImage + ^highlightImage ] { @@ -52,13 +47,14 @@ GMTETileSelectionSet >> highlightImage: anObject [ { #category : #highlighting, - #'squeak_changestamp' : 'TW 6/22/2024 01:28' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:46' } GMTETileSelectionSet >> highlightTile: aTile [ "comment stating purpose of message" - self add: aTile. - self applyHighlightingVisuals: aTile + self + add: aTile; + applyHighlightingVisuals: aTile ] { @@ -74,27 +70,20 @@ GMTETileSelectionSet >> initialize: n [ { #category : #highlighting, - #'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 21:14' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:47' } GMTETileSelectionSet >> removeHighlightingVisuals: aTile [ - "comment stating purpose of message" - - - "TODO: Use constants here" - "aTile morphicLayerNumber: 100." - "aTile borderWidth: 2." - "aTile borderColor: Color white." aTile removeDecoMorphHighlighting ] { #category : #highlighting, - #'squeak_changestamp' : 'TW 6/22/2024 01:28' + #'squeak_changestamp' : 'Alex M 6/22/2024 14:47' } GMTETileSelectionSet >> unhighlightTile: aTile [ - "comment stating purpose of message" - self remove: aTile. - self removeHighlightingVisuals: aTile + self + remove: aTile; + removeHighlightingVisuals: aTile ]