Skip to content

Commit

Permalink
applied code style to GM-Core, fixed small tilemap bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksander Morgensterns committed Jun 22, 2024
1 parent 66c3027 commit 2495190
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 106 deletions.
11 changes: 6 additions & 5 deletions source/GM-TE/GMTEEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ GMTEEditor >> createInspectorSpecWithBuilder: aBuilder [

{
#category : #building,
#'squeak_changestamp' : 'Alex M 6/22/2024 01:54'
#'squeak_changestamp' : 'Alex M 6/22/2024 02:12'
}
GMTEEditor >> createLayersSpecWithBuilder: aBuilder [

Expand All @@ -451,7 +451,8 @@ GMTEEditor >> createLayersSpecWithBuilder: aBuilder [
frame: (LayoutFrame fractions: (0 @ 0 corner: 1 @ 0) offsets: (0 @ 0 corner: 0 @ 30)).

aBuilder pluggablePanelSpec new
frame: (LayoutFrame fractions: (0.8 @ 0 corner: 1 @ 1) offsets: (0 @ 30 corner: 0 @ 0));
frame: (LayoutFrame fractions: (1 @ 0 corner: 1 @ 1) offsets: (-30 @ 30 corner: 0 @ 0));

children: {
aBuilder pluggableImageButtonSpec new
model:self;
Expand Down Expand Up @@ -509,7 +510,7 @@ GMTEEditor >> createLayersSpecWithBuilder: aBuilder [
getSelectionList: #layerAt:;
setSelectionList: #layerAt:put:;
autoDeselect: false;
frame: (LayoutFrame fractions: (0 @ 0 corner: 0.8 @ 1) offsets: (0 @ 30 corner: 0 @ 0))};
frame: (LayoutFrame fractions: (0 @ 0 corner: 1 @ 1) offsets: (0 @ 30 corner: -30 @ 0))};
verticalResizing: #shrinkWrap;

yourself
Expand Down Expand Up @@ -581,12 +582,12 @@ GMTEEditor >> createToolBarSpecWithBuilder: aBuilder [

{
#category : #building,
#'squeak_changestamp' : 'Alex M 6/14/2024 00:49'
#'squeak_changestamp' : 'TW 6/9/2024 18:12'
}
GMTEEditor >> createTraySpecWithBuilder: aBuilder [
^aBuilder pluggableScrollPaneSpec new
name: 'tray';
frame: (LayoutFrame fractions: (0.2 @ 0.8 corner: 1 @ 1) offsets: (0 @ 0 corner: -175 @ 0));
frame: (LayoutFrame fractions: (0.2 @ 0.8 corner: 0.8 @ 1) offsets: nil);
minimumHeight:75;
yourself
]
Expand Down
44 changes: 18 additions & 26 deletions source/GM-TE/GMTEEditorTileMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Class {

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'JS 6/4/2024 16:56'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:39'
}
GMTEEditorTileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPadding sizeRatio: aRatio model: aModel [

^ self new
^(self new)
setDimensionsWidth: aWidth height: aHeight padding: aPadding;
tileSizeRatio: aRatio;
model: aModel.
Expand All @@ -31,20 +31,20 @@ GMTEEditorTileMap >> blendLayers: aSet [

{
#category : #'event handling',
#'squeak_changestamp' : 'Ivo Zilkenat 6/22/2024 03:11'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:39'
}
GMTEEditorTileMap >> handlesMouseDown: anEvent [

^ true
^true
]

{
#category : #'event handling',
#'squeak_changestamp' : 'Ivo Zilkenat 6/22/2024 03:11'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:39'
}
GMTEEditorTileMap >> handlesMouseMove: anEvent [

^ true
^true
]

{
Expand Down Expand Up @@ -77,24 +77,24 @@ GMTEEditorTileMap >> model: anObject [

{
#category : #'event handling',
#'squeak_changestamp' : 'Ivo Zilkenat 6/21/2024 22:23'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:39'
}
GMTEEditorTileMap >> mouseDown: anEvent [

| clickedTile activeLayer|
| clickedTile activeLayer |

self model singleLayerSelected
ifTrue: [
activeLayer := self model selectedLayers anyOne.
clickedTile := self tileFromPosition: anEvent position layer: activeLayer.
self updateTile: clickedTile inLayer: activeLayer FromEvent: anEvent].

^ true
^true
]

{
#category : #'event handling',
#'squeak_changestamp' : 'TW 6/20/2024 16:35'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:40'
}
GMTEEditorTileMap >> mouseMove: anEvent [

Expand All @@ -108,19 +108,12 @@ GMTEEditorTileMap >> mouseMove: anEvent [

self tileSelectionSet clearAllHighlightings.

hoveredTileVisual
ifNotNil: [self tileSelectionSet highlightTile: hoveredTileVisual].
hoveredTileVisual ifNotNil: [self tileSelectionSet highlightTile: hoveredTileVisual].

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

"This solves the bug but not the root of the issue. TODO further investigation."
"self updateTiles."
"hoveredTileVisual
extent: self tileSizeWidth@self tileSizeHeight;
borderColor: Color white;
color: Color veryLightGray;
borderWidth: 2"
]

{
Expand Down Expand Up @@ -162,11 +155,11 @@ GMTEEditorTileMap >> resetLayers: aSet [

{
#category : #accessing,
#'squeak_changestamp' : 'TW 5/22/2024 15:49'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:40'
}
GMTEEditorTileMap >> tileSelectionSet [

^ tileSelectionSet
^tileSelectionSet
]

{
Expand All @@ -180,9 +173,10 @@ GMTEEditorTileMap >> tileSelectionSet: anObject [

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/21/2024 22:23'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:40'
}
GMTEEditorTileMap >> updateTile: aTile inLayer: aLayer FromEvent: anEvent [

| tileIdx hoveredTile |

hoveredTile := aTile.
Expand All @@ -195,7 +189,7 @@ GMTEEditorTileMap >> updateTile: aTile inLayer: aLayer FromEvent: anEvent [
tileIdx ifNil: [^nil].
hoveredTile := self generateTileAtlayer: aLayer x: tileIdx x y: tileIdx y stack: self tileMatrixStack tileType: GMTETile].
"Set tile to currently selected tile"
self updateTileSpriteFromModel: hoveredTile.
self updateTileSprite: hoveredTile.
self model savedSinceModified: false].

((anEvent yellowButtonPressed) and: [hoveredTile notNil])
Expand All @@ -210,11 +204,9 @@ GMTEEditorTileMap >> updateTile: aTile inLayer: aLayer FromEvent: anEvent [

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 22:44'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:41'
}
GMTEEditorTileMap >> updateTileSprite: aTile [

self model selectedTile
ifNotNil:
[aTile applyTileSprite: (self model selectedTile)]
self model selectedTile ifNotNil: [aTile applyTileSprite: self model selectedTile]
]
21 changes: 9 additions & 12 deletions source/GM-TE/GMTEImageMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Class {

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Alex M 6/17/2024 18:45'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:30'
}
GMTEImageMorph >> asBlendedWithImageMorph: anImageMorph [
anImageMorph
ifNil: [^ self].

^ (ImageMorph new)
anImageMorph ifNil: [^self].

^(ImageMorph new)
image: ((FormCanvas on: self image)
image: (anImageMorph image)
at: 0@0
Expand All @@ -29,35 +29,32 @@ GMTEImageMorph >> asBlendedWithImageMorph: anImageMorph [

{
#category : #accessing,
#'squeak_changestamp' : 'TW 6/22/2024 01:16'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:28'
}
GMTEImageMorph >> extent: anExtent [
"override ImageMorph extent functionality. ALWAYS KEEPS RATIO"

"self image: (self image scaledToSize: anExtent)."

super extent: anExtent.
self image: (self fullResolutionSprite scaledToSize: anExtent)
]

{
#category : #removing,
#'squeak_changestamp' : 'Ivo Zilkenat 6/8/2024 22:01'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:29'
}
GMTEImageMorph >> free [

(self owner) ifNotNil: [
self owner removeMorph: self].
self owner ifNotNil: [self owner removeMorph: self].
self abandon
]

{
#category : #accessing,
#'squeak_changestamp' : 'TW 5/22/2024 17:15'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:30'
}
GMTEImageMorph >> fullResolutionSprite [

^ fullResolutionSprite
^fullResolutionSprite
]

{
Expand Down
8 changes: 4 additions & 4 deletions source/GM-TE/GMTETile.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ GMTETile class >> placeHolderColor [

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'TW 5/22/2024 23:32'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:31'
}
GMTETile class >> position: aPoint extent: anExtent [
"comment stating purpose of message"

^ self new
^(self new)
setPlaceholderWithExtent: anExtent color: self placeHolderColor;
position: aPoint
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 22:43'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:34'
}
GMTETile >> applyTileSprite: aTile [

self updateSprite: (aTile fullResolutionSprite)
self updateSprite: aTile fullResolutionSprite
]

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

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 22:57'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:38'
}
GMTETileMap class >> newFromEditableTileMap: aMap [

Expand All @@ -44,23 +44,22 @@ GMTETileMap class >> newFromEditableTileMap: aMap [

aMap tileMatrixStackBackground reset. "This fixed the temporary issue of orphaned morphs after copy"

newMap := (GMTETileMap newFrom: (aMap veryDeepCopy))
newMap := (GMTETileMap newFrom: (aMap veryDeepCopy))
updateMap;
hideVisualLayer;
yourself.


aMap generateBackgroundTiles. "Part of the above fix"
^newMap
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'JS 6/4/2024 16:56'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:38'
}
GMTETileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPadding sizeRatio: aRatio [

^ self new
^(self new)
setDimensionsWidth: aWidth height: aHeight padding: aPadding;
tileSizeRatio: aRatio
]
Expand Down
8 changes: 4 additions & 4 deletions source/GM-TE/GMTETileMatrixLayer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ GMTETileMatrixLayer >> initialize [

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 6/11/2024 19:09'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:42'
}
GMTETileMatrixLayer >> layerIdx [

^ layerIdx
^layerIdx
]

{
Expand Down Expand Up @@ -143,11 +143,11 @@ GMTETileMatrixLayer >> updateLayerIdx: anIdx [

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:17'
#'squeak_changestamp' : 'Alex M 6/22/2024 14:42'
}
GMTETileMatrixLayer >> visible [

^ visible
^visible
]

{
Expand Down
Loading

0 comments on commit 2495190

Please sign in to comment.