Skip to content

Commit

Permalink
added basics of editing
Browse files Browse the repository at this point in the history
  • Loading branch information
RedToxyl committed May 22, 2024
1 parent b004807 commit ab13c72
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 7 deletions.
56 changes: 55 additions & 1 deletion source/GM-TE/GMTEEditableTileMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,38 @@ Class {
#name : #GMTEEditableTileMap,
#superclass : #GMTETileMap,
#instVars : [
'tileSelectionSet'
'tileSelectionSet',
'model'
],
#category : #'GM-TE-Core'
}

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'TW 5/22/2024 16:41'
}
GMTEEditableTileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPadding sizeRatio: aRatio model: aModel [

^ self new
setDimensionsWidth: aWidth height: aHeight padding: aPadding;
tileSizeRatio: aRatio;
model: aModel.
]

{
#category : #'event handling',
#'squeak_changestamp' : 'TW 5/22/2024 16:55'
}
GMTEEditableTileMap >> handlesMouseDown: anEvent [
"TODO: make this useful."

| clickedTile |

clickedTile := self tileFromPosition: anEvent position.
clickedTile ifNotNil: [self updateTileSprite: clickedTile].
^ true.
]

{
#category : #'event handling',
#'squeak_changestamp' : 'TW 5/22/2024 15:48'
Expand All @@ -26,6 +53,24 @@ GMTEEditableTileMap >> initialize [
self tileSelectionSet: GMTETileSelectionSet new.
]

{
#category : #accessing,
#'squeak_changestamp' : 'TW 5/22/2024 16:45'
}
GMTEEditableTileMap >> model [

^model
]

{
#category : #accessing,
#'squeak_changestamp' : 'TW 5/22/2024 16:40'
}
GMTEEditableTileMap >> model: anObject [

model := anObject.
]

{
#category : #'event handling',
#'squeak_changestamp' : 'TW 5/22/2024 15:47'
Expand Down Expand Up @@ -61,3 +106,12 @@ GMTEEditableTileMap >> tileSelectionSet: anObject [

tileSelectionSet := anObject.
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'TW 5/22/2024 16:55'
}
GMTEEditableTileMap >> updateTileSprite: aTile [

self model selectedTile ifNotNil: [aTile image: (self model selectedTile image scaledToSize: self tileWidth @ self tileHeight)].
]
12 changes: 6 additions & 6 deletions source/GM-TE/GMTEEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,11 @@ GMTEEditor >> createTrayWithBuilder: aBuilder [

{
#category : #accessing,
#'squeak_changestamp' : 'TW 5/22/2024 16:15'
#'squeak_changestamp' : 'TW 5/22/2024 16:36'
}
GMTEEditor >> deselectTile [

"TODO implement the lower part resetting selected tile view"
"TODO implement the lower part: resetting selected tile in tray view"
self selectTile: nil.
self tileMapMatrix tileSelectionSet highlightImage: nil.
"self trayViewer submorphs first
Expand Down Expand Up @@ -426,11 +426,11 @@ GMTEEditor >> initialize [

{
#category : #initialisation,
#'squeak_changestamp' : 'TW 5/22/2024 15:51'
#'squeak_changestamp' : 'TW 5/22/2024 16:41'
}
GMTEEditor >> initializeTileMapMatrix [

self tileMapMatrix: (GMTEEditableTileMap tileWidth: 10 tileHeight: 10 padding: 0.15 sizeRatio: 1).
self tileMapMatrix: (GMTEEditableTileMap tileWidth: 10 tileHeight: 10 padding: 0.15 sizeRatio: 1 model: self).
self tileViewer addMorph: tileMapMatrix.
self tileMapMatrix
position: (tileMapMatrix owner position);
Expand All @@ -440,11 +440,11 @@ GMTEEditor >> initializeTileMapMatrix [

{
#category : #initialisation,
#'squeak_changestamp' : 'TW 5/22/2024 16:10'
#'squeak_changestamp' : 'TW 5/22/2024 16:41'
}
GMTEEditor >> initializeTileMapMatrixWithHeight: aHeight width: aWidth [

self tileMapMatrix: (GMTEEditableTileMap tileWidth: aWidth tileHeight: aHeight padding: 0.15 sizeRatio: 1).
self tileMapMatrix: (GMTEEditableTileMap tileWidth: aWidth tileHeight: aHeight padding: 0.15 sizeRatio: 1 model: self).
self tileViewer addMorph: tileMapMatrix.
self tileMapMatrix
position: (tileMapMatrix owner position);
Expand Down

0 comments on commit ab13c72

Please sign in to comment.