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
valteu committed Jun 7, 2024
2 parents e41447b + fb8924d commit 253e121
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 111 deletions.
34 changes: 16 additions & 18 deletions source/GM-TE/GMTEEditableTileMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ GMTEEditableTileMap >> handlesMouseMove: anEvent [
]

{
#category : #updating,
#category : #'as yet unclassified',
#'squeak_changestamp' : 'TW 5/22/2024 15:48'
}
GMTEEditableTileMap >> initialize [
Expand Down Expand Up @@ -68,34 +68,33 @@ GMTEEditableTileMap >> model: anObject [

{
#category : #'event handling',
#'squeak_changestamp' : 'Alex M 5/28/2024 12:54'
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 20:25'
}
GMTEEditableTileMap >> mouseDown: anEvent [
"TODO: make this useful."

| clickedTile tmpActiveLayer|
| clickedTile activeLayer|

tmpActiveLayer := self model selectedLayer.
activeLayer := self model selectedLayer.

clickedTile := self tileFromPosition: anEvent position layer: tmpActiveLayer.
clickedTile := self tileFromPosition: anEvent position layer: activeLayer.

self updateTile: clickedTile inLayer: tmpActiveLayer FromEvent: anEvent.
self updateTile: clickedTile inLayer: activeLayer FromEvent: anEvent.

^ true.
]

{
#category : #'event handling',
#'squeak_changestamp' : 'Alex M 5/28/2024 12:52'
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 20:25'
}
GMTEEditableTileMap >> mouseMove: anEvent [

| hoveredTile hoveredTileVisual tmpActiveLayer |
| hoveredTile hoveredTileVisual activeLayer |

"TODO currently hard coded"
tmpActiveLayer := self model selectedLayer.
activeLayer := self model selectedLayer.

hoveredTile := self tileFromPosition: anEvent position layer: tmpActiveLayer.
hoveredTile := self tileFromPosition: anEvent position layer: activeLayer.
hoveredTileVisual := self tileVisualFromPosition: anEvent position.

self tileSelectionSet clearAllHighlightings.
Expand All @@ -104,7 +103,7 @@ GMTEEditableTileMap >> mouseMove: anEvent [
ifNotNil: [self tileSelectionSet highlightTile: hoveredTileVisual].

"TODO why another ifNil check here?"
self updateTile: hoveredTile inLayer: tmpActiveLayer FromEvent: anEvent.
self updateTile: hoveredTile inLayer: activeLayer FromEvent: anEvent.

"This solves the bug but not the root of the issue. TODO further investigation."
"self updateTiles."
Expand Down Expand Up @@ -144,8 +143,8 @@ GMTEEditableTileMap >> tileSelectionSet: anObject [
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Alex M 5/28/2024 15:36'
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 22:14'
}
GMTEEditableTileMap >> updateTile: aTile inLayer: aLayer FromEvent: anEvent [
| tileIdx hoveredTile |
Expand All @@ -157,7 +156,7 @@ GMTEEditableTileMap >> updateTile: aTile inLayer: aLayer FromEvent: anEvent [
ifNil: [
tileIdx := self tileIdxFromPosition: anEvent position.
tileIdx ifNil: [^nil].
hoveredTile := self generateTileAtlayer: aLayer x: tileIdx x y: tileIdx y stack: self tileMatrixStack.].
hoveredTile := self generateTileAtlayer: aLayer x: tileIdx x y: tileIdx y stack: self tileMatrixStack tileType: GMTETile.].
self updateTileSprite: hoveredTile.
self model savedSinceModified: false].
((anEvent yellowButtonPressed) and: [hoveredTile notNil])
Expand All @@ -166,12 +165,11 @@ GMTEEditableTileMap >> updateTile: aTile inLayer: aLayer FromEvent: anEvent [
tileIdx := self tileIdxFromPosition: anEvent position.
self tileMatrixStack layer: aLayer at: tileIdx y at: tileIdx x put: nil.
hoveredTile abandon].
self model savedSinceModified: false.
].
self model savedSinceModified: false.].
]

{
#category : #'as yet unclassified',
#category : #updating,
#'squeak_changestamp' : 'Alex M 5/23/2024 10:14'
}
GMTEEditableTileMap >> updateTileSprite: aTile [
Expand Down
12 changes: 6 additions & 6 deletions source/GM-TE/GMTEEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -123,26 +123,26 @@ GMTEEditor class >> fromTileHeight: aHeight widht: aWidth [

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'JS 6/4/2024 18:21'
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 22:22'
}
GMTEEditor class >> getTileMapFromFilePath: aFilePath [

|aFileStream tileMap|
"TODO: Check if .morph is a tileMap"
aFileStream := (MultiByteBinaryOrTextStream with: ((FileStream readOnlyFileNamed: aFilePath) binary contentsOfEntireFile)) binary reset.
aFileStream := (MultiByteBinaryOrTextStream with: ((FileStream readOnlyFileNamed: aFilePath) binary contentsOfEntireFile)) binary setToPlaceholder.
tileMap := aFileStream fileInObjectAndCode.
(tileMap isKindOf: GMTEEditableTileMap) ifFalse: [^nil].
^GMTETileMap newFrom: (tileMap copy).
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'JS 6/4/2024 18:21'
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 22:22'
}
GMTEEditor class >> getTileMapFromProjectName: aName withPath: aPath [

|aFileStream tileMap|
aFileStream := (MultiByteBinaryOrTextStream with: ((GitAssetLoader for: aName) loadAsset: aPath)) binary reset.
aFileStream := (MultiByteBinaryOrTextStream with: ((GitAssetLoader for: aName) loadAsset: aPath)) binary setToPlaceholder.
tileMap := aFileStream fileInObjectAndCode.
(tileMap isKindOf: GMTEEditableTileMap) ifFalse: [^nil].
^GMTETileMap newFrom: (tileMap copy).
Expand Down Expand Up @@ -546,7 +546,7 @@ GMTEEditor >> import [

{
#category : #'button functions',
#'squeak_changestamp' : 'jj 6/5/2024 01:21'
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 22:22'
}
GMTEEditor >> importFromMorph [
"import tilemap into editor from a .morph file"
Expand All @@ -556,7 +556,7 @@ GMTEEditor >> importFromMorph [

stream ifNil: [^self].

aFileStream := (MultiByteBinaryOrTextStream with: ((FileStream readOnlyFileNamed: stream fullName) binary contentsOfEntireFile)) binary reset.
aFileStream := (MultiByteBinaryOrTextStream with: ((FileStream readOnlyFileNamed: stream fullName) binary contentsOfEntireFile)) binary setToPlaceholder.
tileMap := aFileStream fileInObjectAndCode.
(tileMap isKindOf: GMTEEditableTileMap) ifFalse: [^self].

Expand Down
4 changes: 2 additions & 2 deletions source/GM-TE/GMTETile.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ GMTETile class >> position: aPoint extent: anExtent [

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'TW 5/22/2024 23:33'
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 22:22'
}
GMTETile >> reset [
GMTETile >> setToPlaceholder [

self setPlaceholderColor: GMTETile placeHolderColor
]
60 changes: 36 additions & 24 deletions source/GM-TE/GMTETileMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,25 @@ GMTETileMap >> correctedTilePosition: aPoint [
^ (self tileCornerOffset + aPoint + self topLeft) floor
]

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 21:53'
}
GMTETileMap >> disableVisualLayer [

self tileMatrixStackVisual doTiles: [ :aTile | aTile removeBorderHighlighting]

]

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 21:52'
}
GMTETileMap >> enableVisualLayer [

self tileMatrixStackVisual doTiles: [ :aTile | aTile applyBorderHighlighting]
]

{
#category : #'import/export',
#'squeak_changestamp' : 'Ivo Zilkenat 5/20/2024 20:54'
Expand All @@ -132,11 +151,16 @@ GMTETileMap >> exportAsImage [

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 5/27/2024 22:53'
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 20:32'
}
GMTETileMap >> extent: aPoint [

| oldExtent |
oldExtent := self extent.

super extent: aPoint.

(oldExtent = aPoint) ifTrue: [^nil].
self tileMatrixStack ifNotNil: [self rescaleMap].
]

Expand Down Expand Up @@ -178,16 +202,16 @@ GMTETileMap >> fullGridSizeWidth: anObject [

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 5/27/2024 23:40'
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 21:33'
}
GMTETileMap >> generateTileAtlayer: aLayer x: x y: y stack: aStack [
GMTETileMap >> generateTileAtlayer: aLayer x: x y: y stack: aStack tileType: aTileClass [

| tilePos correctedTilePos newTile |

tilePos := self tilePosFromVirtual: x@y.
correctedTilePos := self correctedTilePosition: tilePos.

newTile := (GMTETile
newTile := (aTileClass
position: correctedTilePos
extent: self tileSizeWidth@self tileSizeHeight)
lock;
Expand All @@ -205,19 +229,19 @@ GMTETileMap >> generateTileAtlayer: aLayer x: x y: y stack: aStack [

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 5/27/2024 23:32'
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 21:28'
}
GMTETileMap >> generateVisualTiles [
"Create grid tile matrix datastructure"

1 to: self tileHeight do: [:y |
1 to: self tileWidth do: [:x |
self generateTileAtlayer: 1 x: x y: y stack: self tileMatrixStackVisual]].
self generateTileAtlayer: 1 x: x y: y stack: self tileMatrixStackVisual tileType: GMTETileVisual]].

]

{
#category : #updating,
#category : #'as yet unclassified',
#'squeak_changestamp' : 'TW 5/22/2024 15:48'
}
GMTETileMap >> initialize [
Expand Down Expand Up @@ -371,23 +395,11 @@ GMTETileMap >> mapTileWidth: anObject [

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 5/27/2024 23:21'
}
GMTETileMap >> processTiles [
"comment stating purpose of message"

(self tileMatrixStackVisual layer: 1) do: [ :tile |
tile borderColor: Color white.
tile borderWidth: 2]

]

{
#category : #updating,
#'squeak_changestamp' : 'Valentin Teutschbein 5/20/2024 20:30'
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 20:27'
}
GMTETileMap >> rescaleMap [

self tileSelectionSet clearAllHighlightings.
self rescaleMapWidth: self tileWidth height: self tileHeight padding: self mapPadding
]

Expand Down Expand Up @@ -685,7 +697,7 @@ GMTETileMap >> updateDimensions [

{
#category : #updating,
#'squeak_changestamp' : 'Valentin 5/28/2024 13:18'
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 21:54'
}
GMTETileMap >> updateMap [
"Update map by: fitting grid to current screen, generating tile matrix, adding sprites"
Expand All @@ -696,9 +708,9 @@ GMTETileMap >> updateMap [
self tileMatrixStack: (GMTETileMatrixStack fromWidth: self tileWidth height: self tileHeight).
self tileMatrixStackVisual: (GMTETileMatrixStack fromWidth: self tileWidth height: self tileHeight).
self tileMatrixStackVisual morphicLayerStartingOffset: 10. "TODO: Number ?"
self generateVisualTiles]
self generateVisualTiles.
self enableVisualLayer]
ifNotNil: [self updateTiles].
self processTiles
]

{
Expand Down
4 changes: 2 additions & 2 deletions source/GM-TE/GMTETileMatrixLayer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Class {
}

{
#category : #'as yet unclassified',
#category : #enumerating,
#'squeak_changestamp' : 'Valentin Teutschbein 6/7/2024 20:55'
}
GMTETileMatrixLayer >> doTiles: aBlock [
Expand All @@ -15,7 +15,7 @@ GMTETileMatrixLayer >> doTiles: aBlock [
]

{
#category : #'as yet unclassified',
#category : #removing,
#'squeak_changestamp' : 'Valentin Teutschbein 6/7/2024 20:50'
}
GMTETileMatrixLayer >> free [
Expand Down
Loading

0 comments on commit 253e121

Please sign in to comment.