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
RedToxyl committed Jun 23, 2024
2 parents b299188 + 48b1518 commit 6221daf
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 48 deletions.
75 changes: 63 additions & 12 deletions source/GM-TE/GMTEEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ Class {
#category : #'GM-TE-UI'
}

{
#category : #constants,
#'squeak_changestamp' : 'jj 6/23/2024 17:15'
}
GMTEEditor class >> editorMinimumExtent [
"minimum extent of the tile editor"

^ 550 @ 400
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'jj 6/23/2024 14:08'
Expand Down Expand Up @@ -85,14 +95,55 @@ GMTEEditor class >> register [
TheWorldMenu registerOpenCommand: {'TileMap Editor'. {GMTEEditor. #new}}
]

{
#category : #constants,
#'squeak_changestamp' : 'jj 6/23/2024 17:33'
}
GMTEEditor class >> tileMapMaxGridSize [
"the maximum size of the tileMap per dimension"

^ 200
]

{
#category : #constants,
#'squeak_changestamp' : 'jj 6/23/2024 17:35'
}
GMTEEditor class >> tileMapMaxPaddingSize [
"the maximum size of the tileMap padding"

^ 0.9
]

{
#category : #constants,
#'squeak_changestamp' : 'jj 6/23/2024 17:33'
}
GMTEEditor class >> tileMapMinGridSize [
"the minimum size of the tileMap per dimension"

^ 0
]

{
#category : #constants,
#'squeak_changestamp' : 'jj 6/23/2024 17:34'
}
GMTEEditor class >> tileMapMinPaddingSize [
"the minimum size of the tileMap padding"

^ 0
]

{
#category : #'menu button functions',
#'squeak_changestamp' : 'jj 6/22/2024 20:35'
#'squeak_changestamp' : 'jj 6/23/2024 18:04'
}
GMTEEditor >> addLayer [
"adds a new tileMap layer"

| newLayerNumber |
(self layerCount >= GMTETileMap maxLayers) ifTrue: [^ nil].
newLayerNumber := self layerCount + 1.

self tileMap tileMatrixStack pushLayer.
Expand Down Expand Up @@ -154,7 +205,7 @@ GMTEEditor >> blendSelectedLayers [

{
#category : #building,
#'squeak_changestamp' : 'jj 6/22/2024 20:38'
#'squeak_changestamp' : 'jj 6/23/2024 17:29'
}
GMTEEditor >> buildWith: builder [
"builds the editor with ToolBuilder"
Expand All @@ -173,7 +224,7 @@ GMTEEditor >> buildWith: builder [
self createLayersSpecWithBuilder: builder.
self createInspectorSpecWithBuilder: builder};
closeAction: #onClose;
minimumExtent: 550@400).
minimumExtent: GMTEEditor editorMinimumExtent).

self commandBar: (newMorph submorphNamed: 'command bar').
"self commandBar vResizing: #rigid."
Expand Down Expand Up @@ -240,7 +291,7 @@ GMTEEditor >> commandBar: anObject [

{
#category : #'file loading',
#'squeak_changestamp' : 'TW 6/23/2024 18:43'
#'squeak_changestamp' : 'TW 6/23/2024 19:14'
}
GMTEEditor >> confirmPreviewOf: morphArray withDimensions: aPoint withTileSize: aNumber [
"shows a preview window for an imported tileset"
Expand All @@ -263,7 +314,7 @@ GMTEEditor >> confirmPreviewOf: morphArray withDimensions: aPoint withTileSize:
borderWidth:1;
yourself)].

imgwrapper extent: (img width min: 1700) @ (img height min: 800).
imgwrapper extent: (img width min: 1700) @ (img height min: 800). "TODO: is this a magic number we want to get rid off?"
imgwrapper scroller addMorph: img.

dialog := DialogWindow new
Expand Down Expand Up @@ -879,7 +930,7 @@ GMTEEditor >> initialize [

{
#category : #initialisation,
#'squeak_changestamp' : 'jj 6/22/2024 20:58'
#'squeak_changestamp' : 'jj 6/23/2024 17:27'
}
GMTEEditor >> initializeDefaultTileMapMatrix [
"initializes the tileMap with a standard 10 x 10 tileMap"
Expand Down Expand Up @@ -1005,7 +1056,7 @@ GMTEEditor >> layerViewer: anObject [

{
#category : #'file loading',
#'squeak_changestamp' : 'jj 6/22/2024 21:09'
#'squeak_changestamp' : 'jj 6/23/2024 17:31'
}
GMTEEditor >> loadTileSetWithDimensions: aPoint [
"loads a tile set with given tile dimensions"
Expand Down Expand Up @@ -1044,7 +1095,7 @@ GMTEEditor >> loadTileSetWithDimensions: aPoint [
"TODO: Maybe only send forms"
previews add: ((ImageMorph new) image: tile)]].

"TODO: This is maybe not the nicest way to write it. Maybe put more of it into confirmPreview?"
"TODO: This is maybe not the nicest way to write it. Maybe put more of it into confirmPreview?" "TODO: lots of potential magic numbers all over this method"
previewTileSize := (form width max: 500) / (form width / tileWidth).
previewDimensions := (form extent / aPoint * previewTileSize) + (2 * ((form width / tileWidth) @ (form height / tileHeight))).
(self confirmPreviewOf: previews withDimensions: previewDimensions withTileSize: previewTileSize) ifFalse:[^nil].
Expand Down Expand Up @@ -1156,28 +1207,28 @@ GMTEEditor >> openTileMapInWorld [

{
#category : #tilemap,
#'squeak_changestamp' : 'jj 6/22/2024 21:26'
#'squeak_changestamp' : 'jj 6/23/2024 17:33'
}
GMTEEditor >> parseGridSize: aText [
"converts an input grid size (height/width) if valid"

| newSize |
newSize := self parseSize: aText.
(newSize notNil and: [newSize isInteger and: [0 < newSize and: [newSize < 200]]])
(newSize notNil and: [newSize isInteger and: [GMTEEditor tileMapMinGridSize < newSize and: [newSize < GMTEEditor tileMapMaxGridSize]]])
ifTrue: [^ newSize]
ifFalse: [^ nil]
]

{
#category : #tilemap,
#'squeak_changestamp' : 'jj 6/22/2024 21:25'
#'squeak_changestamp' : 'jj 6/23/2024 17:35'
}
GMTEEditor >> parsePaddingSize: aText [
"converts an input padding size if valid"

| newSize |
newSize := self parseSize: aText.
(newSize notNil and: [0 <= newSize and: [newSize <= 0.9]])
(newSize notNil and: [GMTEEditor tileMapMinPaddingSize <= newSize and: [newSize <= GMTEEditor tileMapMaxPaddingSize]])
ifTrue: [^ newSize]
ifFalse: [^ nil]
]
Expand Down
18 changes: 14 additions & 4 deletions source/GM-TE/GMTEImageMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ Class {
#category : #'GM-TE-Core'
}

{
#category : #constants,
#'squeak_changestamp' : 'jj 6/23/2024 17:06'
}
GMTEImageMorph class >> placeholderDepth [
"TODO: comment"

^ 32
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'jj 6/22/2024 16:10'
Expand Down Expand Up @@ -68,25 +78,25 @@ GMTEImageMorph >> fullResolutionSprite: anObject [

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'TW 6/22/2024 01:16'
#'squeak_changestamp' : 'jj 6/23/2024 17:07'
}
GMTEImageMorph >> setPlaceholderWithColor: aColor [

| placeholderForm |
placeholderForm := Form extent: self extent depth: 32.
placeholderForm := Form extent: self extent depth: GMTEImageMorph placeholderDepth.
placeholderForm fillColor: aColor.
self fullResolutionSprite: placeholderForm.
self image: placeholderForm
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'TW 6/22/2024 01:16'
#'squeak_changestamp' : 'jj 6/23/2024 17:07'
}
GMTEImageMorph >> setPlaceholderWithExtent: anExtent color: aColor [

| placeholderForm |
placeholderForm := Form extent: anExtent depth: 32.
placeholderForm := Form extent: anExtent depth: GMTEImageMorph placeholderDepth.
placeholderForm fillColor: aColor.
self fullResolutionSprite: placeholderForm.
self image: placeholderForm
Expand Down
16 changes: 13 additions & 3 deletions source/GM-TE/GMTETileContainer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ Class {
#'squeak_changestamp' : 'Alex M 5/21/2024 16:50'
}

{
#category : #constants,
#'squeak_changestamp' : 'jj 6/23/2024 17:13'
}
GMTETileContainer class >> minTileSize [
"TODO: comment"

^ 40
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'jj 6/22/2024 16:50'
Expand Down Expand Up @@ -45,7 +55,7 @@ GMTETileContainer >> parent: anObject [

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'jj 6/23/2024 13:44'
#'squeak_changestamp' : 'jj 6/23/2024 17:13'
}
GMTETileContainer >> step [

Expand All @@ -54,10 +64,10 @@ GMTETileContainer >> step [
ifTrue: [^ nil].

self extent: self parent extent.
minTileSize := 40. "Magic number currently."
minTileSize := GMTETileContainer minTileSize.
n := self width / minTileSize.
gap := self width - (n floor * minTileSize) / n.
self submorphs do: [ :tile| tile extent: (minTileSize + gap - 2)]
self submorphs do: [ :tile| tile extent: (minTileSize + gap - 2)] "TODO: magic number"
]

{
Expand Down
33 changes: 27 additions & 6 deletions source/GM-TE/GMTETileMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ Class {
#category : #'GM-TE-Core'
}

{
#category : #constants,
#'squeak_changestamp' : 'jj 6/23/2024 16:59'
}
GMTETileMap class >> foregroundMorphicLayerNumber [
"TODO: comment"

^ 76
]

{
#category : #constants,
#'squeak_changestamp' : 'jj 6/23/2024 17:50'
}
GMTETileMap class >> maxLayers [
"the maximum amount of tileMatrixStack layers"

^ 80

]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'jj 6/22/2024 16:21'
Expand Down Expand Up @@ -343,13 +364,13 @@ GMTETileMap >> generateBackgroundTiles [

{
#category : #initialization,
#'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 23:24'
#'squeak_changestamp' : 'jj 6/23/2024 17:59'
}
GMTETileMap >> generateMatrixStacks [

self tileMatrixStackBackground: (GMTETileMatrixStack fromWidth: self tileWidth height: self tileHeight morphicLayerOffset: 101).
self tileMatrixStack: (GMTETileMatrixStack fromWidth: self mapTileWidth height: self mapTileHeight morphicLayerOffset: 100).
self tileMatrixStackVisual: (GMTETileMatrixStack fromWidth: self mapTileWidth height: self mapTileHeight morphicLayerOffset: 10). "TODO: Number ?"
self tileMatrixStackBackground: (GMTETileMatrixStack fromWidth: self tileWidth height: self tileHeight morphicLayerOffset: GMTETileMatrixStack morphicLayerOffsetDefault + 1).
self tileMatrixStack: (GMTETileMatrixStack fromWidth: self mapTileWidth height: self mapTileHeight morphicLayerOffset: GMTETileMatrixStack morphicLayerOffsetDefault).
self tileMatrixStackVisual: (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"
"self generateBackgroundTiles."
self generateVisualTiles.
self toggleBackgroundLayer
Expand Down Expand Up @@ -939,14 +960,14 @@ GMTETileMap >> tileWidth: anObject [

{
#category : #'dev-api',
#'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 22:49'
#'squeak_changestamp' : 'jj 6/23/2024 17:00'
}
GMTETileMap >> toForeground [
"Squeak Bar is 77.
(layerScreen - n) is the nth layer.
Most regular Physics Objects are Layer 2."

self morphicLayerNumber: 76
self morphicLayerNumber: GMTETileMap foregroundMorphicLayerNumber
]

{
Expand Down
30 changes: 25 additions & 5 deletions source/GM-TE/GMTETileMatrixStack.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Class {

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'jj 6/22/2024 16:27'
#'squeak_changestamp' : 'jj 6/23/2024 17:02'
}
GMTETileMatrixStack class >> fromWidth: aWidth height: aHeight [

^ self fromWidth: aWidth height: aHeight morphicLayerOffset: 100 "TODO: magic number"
^ self fromWidth: aWidth height: aHeight morphicLayerOffset: GMTETileMatrixStack morphicLayerOffsetDefault

]

Expand All @@ -36,6 +36,26 @@ GMTETileMatrixStack class >> fromWidth: aWidth height: aHeight morphicLayerOffse

]

{
#category : #constants,
#'squeak_changestamp' : 'jj 6/23/2024 16:53'
}
GMTETileMatrixStack class >> morphicLayerDistance [
"TODO: comment"

^ 2
]

{
#category : #constants,
#'squeak_changestamp' : 'jj 6/23/2024 16:55'
}
GMTETileMatrixStack class >> morphicLayerOffsetDefault [
"default offset for a tileMatrixStack"

^ 100
]

{
#category : #updating,
#'squeak_changestamp' : 'jj 6/22/2024 16:28'
Expand Down Expand Up @@ -266,14 +286,14 @@ GMTETileMatrixStack >> morphicLayerStartingOffset: anObject [

{
#category : #adding,
#'squeak_changestamp' : 'Alex M 6/22/2024 14:44'
#'squeak_changestamp' : 'jj 6/23/2024 18:02'
}
GMTETileMatrixStack >> pushLayer [

self matrixLayers addLast: (GMTETileMatrixLayer
width: self width
height: self height
layerIdx: (self morphicLayerStartingOffset - self layerCount - 2)) "TODO: outsource magic number"
layerIdx: (self morphicLayerStartingOffset - self layerCount - GMTETileMatrixStack morphicLayerDistance))
]

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

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Alex M 6/22/2024 14:57'
#'squeak_changestamp' : 'jj 6/23/2024 17:39'
}
GMTETileTray >> initialize [

super initialize.
self
layoutInset: (10@10);
layoutInset: (10@10);
cellInset: (10@10);
listDirection: #leftToRight;
wrapCentering: #center;
Expand Down
Loading

0 comments on commit 6221daf

Please sign in to comment.