Skip to content

Commit

Permalink
Merge origin/tmm-dev into tmm-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivo Zilkenat committed Jun 24, 2024
2 parents bd3880f + 93701a1 commit d77da24
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 57 deletions.
12 changes: 6 additions & 6 deletions source/GM-TE/GMTEEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ GMTEEditor >> createInspectorSpecWithBuilder: aBuilder [

{
#category : #building,
#'squeak_changestamp' : 'TW 6/23/2024 23:14'
#'squeak_changestamp' : 'jj 6/23/2024 23:48'
}
GMTEEditor >> createLayersSpecWithBuilder: aBuilder [
"creates the spec for layer viewer"
Expand All @@ -442,7 +442,7 @@ GMTEEditor >> createLayersSpecWithBuilder: aBuilder [
fractions: (0.8 @ 0.25 corner: 1 @ 1));
children: {
(aBuilder pluggablePanelSpec new)
frame: (LayoutFrame fractions: (1 @ 0 corner: 1 @ 1) offsets: (-30 @ 30 corner: 0 @ 0));
frame: (LayoutFrame fractions: (0.85 @ 0 corner: 1 @ 1) offsets: (0 @ 30 corner: 0 @ 0));

children: {
(aBuilder pluggableImageButtonSpec new)
Expand Down Expand Up @@ -508,7 +508,7 @@ GMTEEditor >> createLayersSpecWithBuilder: aBuilder [
getSelectionList: #layerAt:;
setSelectionList: #layerAt:put:;
autoDeselect: false;
frame: (LayoutFrame fractions: (0 @ 0 corner: 1 @ 1) offsets: (0 @ 30 corner: -30 @ 0))};
frame: (LayoutFrame fractions: (0 @ 0 corner: 0.85 @ 1) offsets: (0 @ 30 corner: 0 @ 0))};
verticalResizing: #shrinkWrap;
yourself
]
Expand Down Expand Up @@ -1336,15 +1336,15 @@ GMTEEditor >> selectOnlyLayer: anIndex [

{
#category : #accessing,
#'squeak_changestamp' : 'jj 6/22/2024 21:40'
#'squeak_changestamp' : 'jj 6/24/2024 11:33'
}
GMTEEditor >> selectTile: anObject [
"selects a tile from the tile store"

"TODO: might be problematic with tray. Maybe give tiles in the store IDs?"
(anObject = self selectedTile)
ifTrue:[self unselectTile]
ifFalse:[
ifTrue: [self unselectTile]
ifFalse: [
self selectedTile: anObject.
self tileMap tileSelectionSet highlightImage: anObject fullResolutionSprite.
self trayViewer morph submorphs first
Expand Down
7 changes: 4 additions & 3 deletions source/GM-TE/GMTEImageMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ GMTEImageMorph >> setPlaceholderWithExtent: anExtent color: aColor [

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:03'
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:55'
}
GMTEImageMorph >> updateSprite: anImage [
"Update sprite by also carrying the fullResolutionSprite"

self fullResolutionSprite: anImage.
self extent: self extent
self
fullResolutionSprite: anImage;
extent: self extent
]
77 changes: 41 additions & 36 deletions source/GM-TE/GMTETileMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,13 @@ GMTETileMap >> backgroundTiles [

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 6/22/2024 01:21'
#'squeak_changestamp' : 'jj 6/24/2024 11:10'
}
GMTETileMap >> backgroundTiles: anObject [

self basicBackgroundTiles: anObject.
self updateMap
self
basicBackgroundTiles: anObject;
updateMap

]

Expand Down Expand Up @@ -278,15 +279,16 @@ GMTETileMap >> extent: aPoint [

{
#category : #'dev-api',
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:18'
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:55'
}
GMTETileMap >> fitBackgroundToMap [
GMTETileMap >> fitBackgroundToMap [
"Forces the tile map morph to fit the map grid"

self mapPadding: 0.0.
self forceMapSizeRatio: true.
self extent: (self mapSizeWidth) @ (self mapSizeHeight).
self changed

self
mapPadding: 0.0;
forceMapSizeRatio: true;
extent: (self mapSizeWidth) @ (self mapSizeHeight);
changed
]

{
Expand Down Expand Up @@ -345,23 +347,22 @@ GMTETileMap >> fullGridSizeWidth: anObject [

{
#category : #initialization,
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:23'
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:55'
}
GMTETileMap >> generateBackgroundTiles [
"Fill the background matrix stack with tiles automatically"

self backgroundTiles ifNil: [^ nil].

self tileMatrixStackBackground doTilesXYLidx: [ :x :y :l |
"It is assumed that the visual stack consists of only one layer"
"It is assumed that the background stack consists of only one layer"
self generateTileAtlayer: l x: x y: y stack: self tileMatrixStackBackground tileType: GMTETile posCorrectionBlock: [ :aPoint |
self correctedTilePositionBackground: aPoint]].

self tileMatrixStackBackground doTiles: [ :tile |
tile applyTileSprite: self backgroundTiles]



]

{
Expand Down Expand Up @@ -463,13 +464,14 @@ GMTETileMap >> getTileFromLayer: aLayer x: x y: y stack: aStack [

{
#category : #'dev-api',
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:20'
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:55'
}
GMTETileMap >> hideVisualLayer [
"Hide the grid"

self tileMatrixStackVisual visible: false.
self changed
self
tileMatrixStackVisual visible: false;
changed

]

Expand All @@ -494,14 +496,15 @@ GMTETileMap >> initialize [

{
#category : #'dev-api',
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:19'
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:56'
}
GMTETileMap >> mapGridOnly [
"Fit background to grid and make it transparent if background generation is disabled"

self fitBackgroundToMap.
self color: Color transparent.
self changed

self
fitBackgroundToMap;
color: Color transparent;
changed
]

{
Expand Down Expand Up @@ -652,7 +655,7 @@ GMTETileMap >> rescaleMapWidth: aWidth height: aHeigth [

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/8/2024 21:59'
#'squeak_changestamp' : 'jj 6/24/2024 11:05'
}
GMTETileMap >> rescaleMapWidth: aWidth height: aHeigth padding: aPadding [
"Rescale map & trigger update"
Expand All @@ -662,26 +665,26 @@ GMTETileMap >> rescaleMapWidth: aWidth height: aHeigth padding: aPadding [
sizeChanged := (aWidth ~= self mapTileWidth) or: [aHeigth ~= self mapTileHeight].

self setDimensionsWidth: aWidth height: aHeigth padding: aPadding.
(sizeChanged) ifTrue: [
self rescaleMatrixStacks].
sizeChanged ifTrue: [self rescaleMatrixStacks].
self updateMap
]

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:28'
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:55'
}
GMTETileMap >> rescaleMatrixStacks [
"Rescale matrix stacks to apply new dimensions"

(self tileMatrixStack) ifNotNil: [
self tileMatrixStack ifNotNil: [
self tileMatrixStack rescaleToWidth: self mapTileWidth height: self mapTileHeight].
"Rescaling returns a copy of the original tiles, which must be added as submorphs again. TODO: move responsibility to Stack?"
self tileMatrixStack doTiles: [ :tile |
self addMorph: tile].
(self tileMatrixStackVisual) ifNotNil: [
self tileMatrixStackVisual rescaleToWidth: self mapTileWidth height: self mapTileHeight.
self tileMatrixStackVisual reset.
self tileMatrixStackVisual ifNotNil: [
self tileMatrixStackVisual
rescaleToWidth: self mapTileWidth height: self mapTileHeight;
reset.
self generateVisualTiles]
]

Expand Down Expand Up @@ -809,14 +812,14 @@ GMTETileMap >> tileHeight: anObject [

{
#category : #conversion,
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:14'
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:55'
}
GMTETileMap >> tileIdxFromPosition: aPoint [
"Answer the sender with a tile index (matrix[index x y][index x]) from a pixel position"

| uncorrectedPos idx |
uncorrectedPos := self revertCorrectedTilePositionMap: aPoint.
idx := (uncorrectedPos x / self tileSizeWidth + 1)@(uncorrectedPos y / self tileSizeHeight + 1).
idx := (uncorrectedPos x / self tileSizeWidth + 1) @ (uncorrectedPos y / self tileSizeHeight + 1).
idx := idx floor.

((self tileMatrixStackVisual layer: 1) validIdx: idx) ifFalse: [^ nil].
Expand Down Expand Up @@ -1131,7 +1134,7 @@ GMTETileMap >> updateTileMatrixStack: aStack posCorrectionBlock: aBlock [

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:31'
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:55'
}
GMTETileMap >> updateTiles [
"Collectively update all matrix stacks and therefore all tiles contained within"
Expand All @@ -1142,12 +1145,14 @@ GMTETileMap >> updateTiles [

(self tileMatrixStackBackground visible)
ifTrue: [
self tileMatrixStackBackground rescaleToWidth: self tileWidth height: self tileHeight.
self tileMatrixStackBackground reset.
self tileMatrixStackBackground
rescaleToWidth: self tileWidth height: self tileHeight;
reset.
self generateBackgroundTiles.
self updateTileMatrixStack: self tileMatrixStackBackground posCorrectionBlock: [ :aPoint |
self correctedTilePositionBackground: aPoint]].

self updateTileMatrixStack: self tileMatrixStack.
self updateTileMatrixStack: self tileMatrixStackVisual
self
updateTileMatrixStack: self tileMatrixStack;
updateTileMatrixStack: self tileMatrixStackVisual
]
4 changes: 2 additions & 2 deletions source/GM-TE/GMTETileMatrixLayer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ GMTETileMatrixLayer >> displayName: anObject [

{
#category : #enumerating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:39'
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:55'
}
GMTETileMatrixLayer >> doTiles: aBlock [
"Convenience method to apply aBlock to every tile (if not nil)"

"Instance variable must be used here"
(contents) ifNil: [^ nil].
contents ifNil: [^ nil].

self contents do: [:tile | tile ifNotNil: [aBlock value: tile]]
]
Expand Down
5 changes: 3 additions & 2 deletions source/GM-TE/GMTETileSelectionSet.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ GMTETileSelectionSet >> applyHighlightingVisuals: aTile [

{
#category : #highlighting,
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:51'
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:55'
}
GMTETileSelectionSet >> clearAllHighlightings [
"Clear tile selection and remove applied highlightings if any"

self do: [ :tile | self removeHighlightingVisuals: tile].
self do: [ :tile |
self removeHighlightingVisuals: tile].
self removeAll
]

Expand Down
19 changes: 11 additions & 8 deletions source/GM-TE/GMTETileVisual.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,26 @@ GMTETileVisual >> applyBorderHighlighting [

{
#category : #highlighting,
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:04'
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:55'
}
GMTETileVisual >> applyDecoMorphHighlighting: aForm [
"Set a form as a temporary decoration inside the tile"

| newDecoMorph |
aForm
ifNotNil: [
newDecoMorph := ImageMorph new
bounds: self bounds.
newDecoMorph image: (aForm scaledToSize: self extent)]
newDecoMorph := (ImageMorph new)
bounds: self bounds;
image: (aForm scaledToSize: self extent);
yourself]
ifNil: [
newDecoMorph := Morph new
bounds: self bounds.
newDecoMorph color: (Color black alpha: GMTETileVisual decoMorphAlphaValue)].
self addMorph: newDecoMorph.
self decorationMorph: newDecoMorph
bounds: self bounds;
color: (Color black alpha: GMTETileVisual decoMorphAlphaValue);
yourself].
self
addMorph: newDecoMorph;
decorationMorph: newDecoMorph
]

{
Expand Down

0 comments on commit d77da24

Please sign in to comment.