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 Jul 12, 2024
2 parents 8328d97 + 7a56ec3 commit 96ed5a3
Show file tree
Hide file tree
Showing 12 changed files with 287 additions and 255 deletions.
5 changes: 5 additions & 0 deletions source/GM-TE/GMTEBlendLayersCommand.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #GMTEBlendLayersCommand,
#superclass : #GMTETilemapSizeCommand,
#category : #'GM-TE-UI'
}
53 changes: 0 additions & 53 deletions source/GM-TE/GMTECompositeCommand.class.st

This file was deleted.

11 changes: 7 additions & 4 deletions source/GM-TE/GMTEDeleteLayersCommand.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #GMTEDeleteLayersCommand,
#superclass : #GMTEEditTilesCommand,
#superclass : #GMTETilemapSizeCommand,
#instVars : [
'layers'
],
Expand All @@ -9,13 +9,15 @@ Class {

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Alex M 7/10/2024 04:21'
#'squeak_changestamp' : 'Alex M 7/12/2024 18:57'
}
GMTEDeleteLayersCommand class >> fromLayers: aLayerList editor: anEditor [

^ (self new)
layers: ((SortedCollection sortBlock: [:a :b | a < b]) addAll: aLayerList; yourself);
editor: anEditor;
newSize: 0 @ 0;
saveTiles;
yourself
]

Expand Down Expand Up @@ -47,9 +49,10 @@ GMTEDeleteLayersCommand >> layers: anObject [

{
#category : #execution,
#'squeak_changestamp' : 'Alex M 7/10/2024 04:05'
#'squeak_changestamp' : 'Alex M 7/12/2024 18:55'
}
GMTEDeleteLayersCommand >> undo [

self editor addTilemapLayersAt: self layers
self editor addTilemapLayersAt: self layers.
self restoreTiles
]
9 changes: 5 additions & 4 deletions source/GM-TE/GMTEEditTilesCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,23 @@ GMTEEditTilesCommand >> initialize [

{
#category : #execution,
#'squeak_changestamp' : 'Alex M 7/10/2024 13:44'
#'squeak_changestamp' : 'Alex M 7/12/2024 19:47'
}
GMTEEditTilesCommand >> placeTilesFromList: aList [
| tile sprite layer x y |
| tile sprite layer x y tileMap |

tileMap := self tileMap.
aList keysDo: [ :coordinates |
x := coordinates at: 1.
y := coordinates at: 2.
layer := coordinates at: 3.

tile := self tileMap tileMatrixStack layer: layer at: y at: x.
tile := tileMap tileMatrixStack layer: layer at: y at: x.
sprite := aList at: coordinates.
tile
ifNil: [sprite
ifNotNil: [
tile := tileMap generateTileAtlayer: layer x: x y: y stack: self tileMap tileMatrixStack tileType: GMTETile.
tile := tileMap generateTileAtlayer: layer x: x y: y stack: tileMap tileMatrixStack tileType: GMTETile.
tile updateSprite: sprite]]
ifNotNil: [sprite
ifNil: [
Expand Down
63 changes: 37 additions & 26 deletions source/GM-TE/GMTEEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,11 @@ GMTEEditor >> associatedMorph [

{
#category : #accessing,
#'squeak_changestamp' : 'TW 6/25/2024 15:55'
#'squeak_changestamp' : 'mcjj 7/12/2024 19:38'
}
GMTEEditor >> associatedMorph: anObject [

associatedMorph := anObject.
associatedMorph := anObject
]

{
Expand Down Expand Up @@ -450,11 +450,11 @@ GMTEEditor >> brushButtons [

{
#category : #accessing,
#'squeak_changestamp' : 'TW 7/9/2024 18:19'
#'squeak_changestamp' : 'mcjj 7/12/2024 19:38'
}
GMTEEditor >> brushButtons: anObject [

brushButtons := anObject.
brushButtons := anObject
]

{
Expand Down Expand Up @@ -1065,12 +1065,15 @@ GMTEEditor >> exportAsImage [

{
#category : #'menu button functions',
#'squeak_changestamp' : 'jj 6/23/2024 14:14'
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 19:18'
}
GMTEEditor >> exportAsMorph [
"saves the current tileMap as a .morph file, which allows for reimporting"

(self tileMap copy model: nil) saveOnFile.
((self tileMap veryDeepCopy)
model: nil;
resetView
) saveOnFile.
self savedSinceModified: true
]

Expand Down Expand Up @@ -1101,11 +1104,12 @@ GMTEEditor >> exportMenu [

{
#category : #'input handling',
#'squeak_changestamp' : 'mcjj 7/12/2024 17:12'
#'squeak_changestamp' : 'mcjj 7/12/2024 19:34'
}
GMTEEditor >> filterEvent: aKeyboardEvent for: anObject [
| key |
"handles keyboard shortcuts"

| key |
aKeyboardEvent isKeystroke
ifFalse: [^ aKeyboardEvent].

Expand All @@ -1118,7 +1122,6 @@ GMTEEditor >> filterEvent: aKeyboardEvent for: anObject [
[$o] -> [self importFromTileset].
[$g] -> [self toggleGrid].
[$h] -> [self toggleBackgroundTiles].
[$r] -> [self rotateSelectedTile].

[$a] -> [self addLayer].
[$n] -> [self renameLayer].
Expand All @@ -1129,6 +1132,7 @@ GMTEEditor >> filterEvent: aKeyboardEvent for: anObject [

[$z] -> [self undo].
[$y] -> [self redo].
[$r] -> [self rotateSelectedTile].
[$1] -> [self selectRadiusBrush].
[$2] -> [self selectLineBrush].
[$3] -> [self selectFillBrush].
Expand Down Expand Up @@ -1800,6 +1804,16 @@ GMTEEditor >> renameLayer [

]

{
#category : #tilemap,
#'squeak_changestamp' : 'Alex M 7/12/2024 19:51'
}
GMTEEditor >> rescaleGridDimensions: aPoint [

(self getGridWidth = aPoint x) ifFalse: [self rescaleGridWidth: aPoint x].
(self getGridHeight = aPoint y) ifFalse: [self rescaleGridHeight: aPoint y].
]

{
#category : #tilemap,
#'squeak_changestamp' : 'Alex M 7/1/2024 21:04'
Expand Down Expand Up @@ -2072,38 +2086,37 @@ GMTEEditor >> setBrushRadiusFromText: aText [

{
#category : #tilemap,
#'squeak_changestamp' : 'Alex M 7/1/2024 21:06'
#'squeak_changestamp' : 'Alex M 7/12/2024 20:03'
}
GMTEEditor >> setGridHeight: aText [
"adjusts the grid height"

| oldHeight newHeight |
oldHeight := self getGridHeight.
| oldSize newHeight |
oldSize := self getGridWidth @ self getGridHeight.
newHeight := self parseGridSize: aText.
newHeight ifNotNil: [
self
rescaleGridHeight: newHeight;
addCommand: (GMTETilemapSizeCommand prevValue: oldHeight newValue: newHeight method: #rescaleGridHeight: editor: self)].
addCommand: (GMTETilemapSizeCommand prevSize: oldSize newSize: oldSize x @ newHeight editor: self);
rescaleGridHeight: newHeight].
^ true


]

{
#category : #tilemap,
#'squeak_changestamp' : 'Alex M 7/1/2024 21:06'
#'squeak_changestamp' : 'Alex M 7/12/2024 20:06'
}
GMTEEditor >> setGridWidth: aText [
"adjusts the grid width"
"TODO: Fix visual layer bug"

| oldWidth newWidth |
oldWidth := self getGridWidth.
| oldSize newWidth |
oldSize := self getGridWidth @ self getGridHeight.
newWidth := self parseGridSize: aText.
oldWidth ifNotNil: [
newWidth ifNotNil: [
self
rescaleGridWidth: newWidth;
addCommand: (GMTETilemapSizeCommand prevValue: oldWidth newValue: newWidth method: #rescaleGridWidth: editor: self)].
addCommand: (GMTETilemapSizeCommand prevSize: oldSize newSize: newWidth @ oldSize y editor: self);
rescaleGridWidth: newWidth].
^ true

]
Expand Down Expand Up @@ -2298,7 +2311,7 @@ GMTEEditor >> trayViewer: anObject [

{
#category : #'command processing',
#'squeak_changestamp' : 'Alex M 7/10/2024 14:17'
#'squeak_changestamp' : 'Alex M 7/12/2024 19:52'
}
GMTEEditor >> undo [

Expand All @@ -2307,10 +2320,8 @@ GMTEEditor >> undo [
ifTrue: [(self commands at: self currentCommand) undo.
self
savedSinceModified: false;
currentCommand: self currentCommand - 1.
({GMTETilemapSizeCommand. GMTEDeleteLayersCommand} includes: (self commands at: self currentCommand + 1) class)
ifTrue: [self redoAllCommandsUntil: self currentCommand].
self savedSinceModified: false]
currentCommand: self currentCommand - 1;
savedSinceModified: false]
]

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

{
#category : #'as yet unclassified',
#category : #'instance creation',
#'squeak_changestamp' : 'jj 6/23/2024 13:36'
}
GMTEEditorTileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPadding sizeRatio: aRatio model: aModel [
Expand Down Expand Up @@ -55,7 +55,7 @@ GMTEEditorTileMap >> currentTileChanges: aTileDictionary [

{
#category : #updating,
#'squeak_changestamp' : 'Alex M 7/12/2024 17:16'
#'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 18:28'
}
GMTEEditorTileMap >> deleteTiles: anIndexSet inLayer: aLayer [
"delete tiles from editable matrix stack at given indices"
Expand Down Expand Up @@ -198,12 +198,15 @@ GMTEEditorTileMap >> mouseMove: anEvent [

{
#category : #'event handling',
#'squeak_changestamp' : 'JS 7/12/2024 16:28'
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 18:27'
}
GMTEEditorTileMap >> mouseUp: anEvent [
"apply brush operation on tilemap"

| selectedIndices |
"Make sure view is not currently moved. Implies that shift must still be held down"
anEvent shiftPressed ifTrue: [^ nil].

self brush firstMatrixIndex: nil.

selectedIndices := self brush outputSet asCollection.
Expand All @@ -220,13 +223,13 @@ GMTEEditorTileMap >> mouseUp: anEvent [

{
#category : #updating,
#'squeak_changestamp' : 'Alex M 7/12/2024 17:15'
#'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 18:27'
}
GMTEEditorTileMap >> placeTiles: aCoordinateCollection inLayer: aLayer [
GMTEEditorTileMap >> placeTiles: anIndexSet inLayer: aLayer [
"add currently selected tile (model) to editable matrix stack at given indices"

| tile |
aCoordinateCollection do: [:c |
anIndexSet do: [:c |
self savePreviousImageFromIndex: c inLayer: aLayer.
((self tileMatrixStack layer: aLayer) inBounds: c) ifTrue: [
tile := self tileMatrixStack layer: aLayer at: c y at: c x.
Expand Down Expand Up @@ -294,11 +297,13 @@ GMTEEditorTileMap >> resetTileEditChanges [

{
#category : #'command processing',
#'squeak_changestamp' : 'JS 7/12/2024 16:34'
#'squeak_changestamp' : 'Alex M 7/12/2024 18:44'
}
GMTEEditorTileMap >> saveNewImageFromIndex: anIndex inLayer: aLayer [

| tile |

anIndex ifNil: [^ nil].

tile := self tileMatrixStack layer: aLayer at: anIndex y at: anIndex x.

tile
Expand Down Expand Up @@ -375,3 +380,14 @@ GMTEEditorTileMap >> updateTiles: anIndexSet inLayer: aLayer FromEvent: anEvent
validLeftClick ifTrue: [self placeTiles: anIndexSet inLayer: aLayer].
validRightClick ifTrue: [self deleteTiles: anIndexSet inLayer: aLayer].
]

{
#category : #view,
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 18:13'
}
GMTEEditorTileMap >> zoomAt: aPoint by: aFloat [

super zoomAt: aPoint by: aFloat.
self flag: 'refactor?'.
self tileSelectionSet clearAllHighlightings
]
Loading

0 comments on commit 96ed5a3

Please sign in to comment.