diff --git a/source/GM-TE/GMTECommand.class.st b/source/GM-TE/GMTECommand.class.st index 72d80e4a..4b41ddd3 100644 --- a/source/GM-TE/GMTECommand.class.st +++ b/source/GM-TE/GMTECommand.class.st @@ -1,7 +1,7 @@ Class { #name : #GMTECommand, #superclass : #Object, - #category : #'GM-TE-CommandProcessor' + #category : #'GM-TE-UI' } { diff --git a/source/GM-TE/GMTEEditTilesCommand.class.st b/source/GM-TE/GMTEEditTilesCommand.class.st index 83ab3505..eb162e5e 100644 --- a/source/GM-TE/GMTEEditTilesCommand.class.st +++ b/source/GM-TE/GMTEEditTilesCommand.class.st @@ -6,7 +6,7 @@ Class { 'previousSprites', 'currentSprites' ], - #category : #'GM-TE-CommandProcessor' + #category : #'GM-TE-UI' } { diff --git a/source/GM-TE/GMTEEditor.class.st b/source/GM-TE/GMTEEditor.class.st index 5b1a8821..ca0d85ea 100644 --- a/source/GM-TE/GMTEEditor.class.st +++ b/source/GM-TE/GMTEEditor.class.st @@ -73,6 +73,15 @@ GMTEEditor class >> getVisibilityIndicator: aBoolean [ ifFalse: [^ ' (h)'] ] +{ + #category : #constants, + #'squeak_changestamp' : 'Alex M 7/2/2024 17:46' +} +GMTEEditor class >> maxNumberOfCommands [ + + ^ 10 +] + { #category : #fileHandling, #'squeak_changestamp' : 'jj 6/23/2024 14:09' @@ -159,13 +168,16 @@ GMTEEditor class >> tileMapMinPaddingSize [ { #category : #'command processing', - #'squeak_changestamp' : 'Alex M 6/28/2024 19:52' + #'squeak_changestamp' : 'Alex M 7/2/2024 17:50' } GMTEEditor >> addCommand: aCommand [ "when a new change is made, all timestamps from the 'future' are deleted" [self commands size > self currentCommand] whileTrue: [self commands removeLast]. + (self commands size > self class maxNumberOfCommands) ifTrue: [self commands removeFirst. + self currentCommand: self currentCommand - 1]. + self commands add: aCommand. self currentCommand: self currentCommand + 1 ] @@ -1355,6 +1367,17 @@ GMTEEditor >> redo [ self savedSinceModified: false] ] +{ + #category : #TODO, + #'squeak_changestamp' : 'Alex M 7/2/2024 16:35' +} +GMTEEditor >> redoAllCommandsUntil: aValue [ + + "TODO: This is used for workarounds, better solutions required." + aValue to: 1 by: -1 do: [:i | (commands at: i) undo]. + 1 to: aValue do: [:i | (commands at: i) do] +] + { #category : #'layer button functions', #'squeak_changestamp' : 'TW 6/23/2024 21:50' @@ -1781,13 +1804,17 @@ GMTEEditor >> trayViewer: anObject [ { #category : #'command processing', - #'squeak_changestamp' : 'Alex M 7/1/2024 20:24' + #'squeak_changestamp' : 'Alex M 7/2/2024 17:32' } GMTEEditor >> undo [ - + "A bit hacky, maybe fix later" (self currentCommand > 1) ifTrue: [(self commands at: self currentCommand) undo. self currentCommand: self currentCommand - 1. - self savedSinceModified: false] + ((self commands at: self currentCommand + 1) class = GMTETilemapSizeCommand) + ifTrue: [self redoAllCommandsUntil: self currentCommand]. + self savedSinceModified: false]. + + ] { diff --git a/source/GM-TE/GMTEPlaceHolderCommand.class.st b/source/GM-TE/GMTEPlaceHolderCommand.class.st index 4a9f851c..80218f20 100644 --- a/source/GM-TE/GMTEPlaceHolderCommand.class.st +++ b/source/GM-TE/GMTEPlaceHolderCommand.class.st @@ -1,7 +1,7 @@ Class { #name : #GMTEPlaceHolderCommand, #superclass : #GMTECommand, - #category : #'GM-TE-CommandProcessor' + #category : #'GM-TE-UI' } { diff --git a/source/GM-TE/GMTETilemapSizeCommand.class.st b/source/GM-TE/GMTETilemapSizeCommand.class.st index acf5fa22..77964fcd 100644 --- a/source/GM-TE/GMTETilemapSizeCommand.class.st +++ b/source/GM-TE/GMTETilemapSizeCommand.class.st @@ -8,7 +8,7 @@ Class { 'newSize', 'savedTiles' ], - #category : #'GM-TE-CommandProcessor' + #category : #'GM-TE-UI' } { @@ -27,12 +27,11 @@ GMTETilemapSizeCommand class >> prevValue: aNumber1 newValue: aNumber2 method: a { #category : #execution, - #'squeak_changestamp' : 'Alex M 7/1/2024 18:52' + #'squeak_changestamp' : 'Alex M 7/2/2024 16:36' } GMTETilemapSizeCommand >> do [ - self editor perform: self method with: self newSize. - self restoreTiles + self editor perform: self method with: self newSize ] { @@ -101,14 +100,17 @@ GMTETilemapSizeCommand >> prevSize: anObject [ { #category : #execution, - #'squeak_changestamp' : 'Alex M 7/1/2024 18:23' + #'squeak_changestamp' : 'Alex M 7/2/2024 17:23' } GMTETilemapSizeCommand >> restoreTiles [ + "TODO: Use function of tilemap" + + "self editor redoAllCommandsUntil: self editor currentCommand - 1." ] { #category : #execution, - #'squeak_changestamp' : 'Alex M 7/1/2024 18:52' + #'squeak_changestamp' : 'Alex M 7/2/2024 17:22' } GMTETilemapSizeCommand >> undo [