Skip to content

Commit 4ac50c9

Browse files
author
Ivo Zilkenat
committed
Refactoring
1 parent 96ed5a3 commit 4ac50c9

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

source/GM-TE/GMTETileMap.class.st

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ GMTETileMap >> correctedTilePositionMap: aPoint [
270270

271271
{
272272
#category : #updating,
273-
#'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 18:32'
273+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:58'
274274
}
275275
GMTETileMap >> deleteTiles: anIndexSet inLayer: aLayer [
276276
"delete tiles from editable matrix stack at given indices"
@@ -297,11 +297,10 @@ GMTETileMap >> dimensionsSet [
297297

298298
{
299299
#category : #'import/export',
300-
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:21'
300+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:52'
301301
}
302302
GMTETileMap >> exportAsImage [
303-
"TODO:Add further options in the future like choosing file format?"
304-
303+
305304
self exportAsPNG
306305
]
307306

@@ -431,15 +430,25 @@ GMTETileMap >> generateHighlightingTiles [
431430

432431
{
433432
#category : #initialization,
434-
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:22'
433+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:54'
435434
}
436435
GMTETileMap >> generateMatrixStacks [
437436
"Generate the 3 matrix stacks (editable, highlighting, background)"
438437

439-
self tileMatrixStackBackground: (GMTETileMatrixStack fromWidth: self tileWidth height: self tileHeight morphicLayerOffset: GMTETileMatrixStack morphicLayerOffsetDefault + 1).
440-
self tileMatrixStack: (GMTETileMatrixStack fromWidth: self mapTileWidth height: self mapTileHeight morphicLayerOffset: GMTETileMatrixStack morphicLayerOffsetDefault).
441-
self tileMatrixStackHighlighting: (GMTETileMatrixStack fromWidth: self mapTileWidth height: self mapTileHeight morphicLayerOffset: GMTETileMatrixStack morphicLayerOffsetDefault - GMTETileMap maxLayers - GMTETileMatrixStack morphicLayerDistance). "ensures that the visual layer is always is front of every other layer"
442-
"self generateBackgroundTiles."
438+
"Ensures that the background layer is always behind every other layer"
439+
self tileMatrixStackBackground: (GMTETileMatrixStack
440+
fromWidth: self tileWidth
441+
height: self tileHeight
442+
morphicLayerOffset: (GMTETileMatrixStack morphicLayerOffsetDefault + 1)).
443+
self tileMatrixStack: (GMTETileMatrixStack
444+
fromWidth: self mapTileWidth
445+
height: self mapTileHeight
446+
morphicLayerOffset: GMTETileMatrixStack morphicLayerOffsetDefault).
447+
"Ensures that the visual layer is always is front of every other layer"
448+
self tileMatrixStackHighlighting: (GMTETileMatrixStack
449+
fromWidth: self mapTileWidth
450+
height: self mapTileHeight
451+
morphicLayerOffset: (GMTETileMatrixStack morphicLayerOffsetDefault - GMTETileMap maxLayers - GMTETileMatrixStack morphicLayerDistance)).
443452
self generateHighlightingTiles.
444453
self toggleBackgroundLayer
445454
]
@@ -613,7 +622,7 @@ GMTETileMap >> inViewPointToViewFraction: aPoint [
613622

614623
{
615624
#category : #initialization,
616-
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 17:04'
625+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:55'
617626
}
618627
GMTETileMap >> initialize [
619628

@@ -624,10 +633,7 @@ GMTETileMap >> initialize [
624633
forceMapSizeRatio: false;
625634
view: GMTEView new;
626635
hasStaticView: true;
627-
628-
"TODO: spike solution. Size 1@1 sets quadratic base image. Generic resizing not working yet"
629-
"TODO: default background tiles (must not exist but practical as a visual indicator)"
630-
backgroundTiles: GMTETile checkerBoardTile
636+
backgroundTiles: GMTETile checkerBoardTile
631637

632638
]
633639

@@ -785,12 +791,9 @@ GMTETileMap >> mouseMove: anEvent [
785791

786792
{
787793
#category : #'event handling',
788-
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 17:57'
794+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:51'
789795
}
790796
GMTETileMap >> mouseWheel: anEvent [
791-
792-
self flag: 'does not work'.
793-
"anEvent shiftPressed ifFalse: [^ nil]."
794797

795798
self hasStaticView ifTrue: [^ nil].
796799
anEvent isWheelDown ifTrue: [self zoomOutAt: (anEvent position - self topLeft)].
@@ -811,7 +814,7 @@ GMTETileMap >> moveViewBy: aPoint [
811814

812815
{
813816
#category : #updating,
814-
#'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 19:22'
817+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:58'
815818
}
816819
GMTETileMap >> placeTiles: anIndexSet inLayer: aLayer ofClass: aTileClass withImage: anImage [
817820

@@ -872,14 +875,13 @@ GMTETileMap >> rescaleMapWidth: aWidth height: aHeigth padding: aPadding [
872875

873876
{
874877
#category : #updating,
875-
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:55'
878+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:56'
876879
}
877880
GMTETileMap >> rescaleMatrixStacks [
878881
"Rescale matrix stacks to apply new dimensions"
879882

880883
self tileMatrixStack ifNotNil: [
881884
self tileMatrixStack rescaleToWidth: self mapTileWidth height: self mapTileHeight].
882-
"Rescaling returns a copy of the original tiles, which must be added as submorphs again. TODO: move responsibility to Stack?"
883885
self tileMatrixStack doTiles: [:tile |
884886
self addMorph: tile].
885887
self tileMatrixStackHighlighting ifNotNil: [
@@ -964,14 +966,13 @@ GMTETileMap >> setDimensionsWidth: aWidth height: aHeigth padding: aPadding [
964966

965967
{
966968
#category : #'dev-api',
967-
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:19'
969+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:51'
968970
}
969971
GMTETileMap >> showHighlightingLayer [
970972
"Shows / hides the grid"
971973

972974
self tileMatrixStackHighlighting visible: true.
973975
self changed
974-
"self rescaleMap."
975976
]
976977

977978
{
@@ -1331,7 +1332,7 @@ GMTETileMap >> updateTileMatrixStack: aStack [
13311332

13321333
{
13331334
#category : #updating,
1334-
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:41'
1335+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:58'
13351336
}
13361337
GMTETileMap >> updateTileMatrixStack: aStack posCorrectionBlock: aBlock [
13371338
"Update matrix stacks by applying new dimensions & positions"
@@ -1351,14 +1352,11 @@ GMTETileMap >> updateTileMatrixStack: aStack posCorrectionBlock: aBlock [
13511352

13521353
{
13531354
#category : #updating,
1354-
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 17:54'
1355+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:57'
13551356
}
13561357
GMTETileMap >> updateTiles [
13571358
"Collectively update all matrix stacks and therefore all tiles contained within"
1358-
1359-
"Background also has to rescale"
1360-
"TODO: This should be refactored"
1361-
"TODO: Rescaling is not very performant"
1359+
"Note: Rescaling is not very performant"
13621360

13631361
self
13641362
updateTilesBackground;

0 commit comments

Comments
 (0)