diff --git a/source/GM-TE/GMTEEditor.class.st b/source/GM-TE/GMTEEditor.class.st index a3ff7b46..90274ab0 100644 --- a/source/GM-TE/GMTEEditor.class.st +++ b/source/GM-TE/GMTEEditor.class.st @@ -13,7 +13,6 @@ Class { 'savedSinceModified', 'inspector', 'morphBuilders', - 'layerData', 'backgroundTile', 'tileMap' ], @@ -60,6 +59,17 @@ GMTEEditor class >> getTileMapFromProjectName: aName withPath: aPath [ ^ GMTEEditor getTileMapFromFileBinary: ((GitAssetLoader for: aName) loadAsset: aPath) ] +{ + #category : #constants, + #'squeak_changestamp' : 'TW 6/23/2024 19:59' +} +GMTEEditor class >> getVisibilityIndicator: aBoolean [ + + aBoolean + ifTrue: [^ '(h)'] + ifFalse: [^ '(v)'] +] + { #category : #'as yet unclassified', #'squeak_changestamp' : 'jj 6/23/2024 14:09' @@ -257,19 +267,6 @@ GMTEEditor >> buildWith: builder [ ^ newMorph ] -{ - #category : #'layer manipulation', - #'squeak_changestamp' : 'jj 6/22/2024 21:45' -} -GMTEEditor >> collectLayerData [ - "transfers layer data from an imported tileMap to update the layerViewer" - - self layerData: OrderedCollection new. - 1 to: self layerCount do: [ :i | - self storeLayerN: i withVisibility: (self tileMap tileMatrixStack layerVisible: i)] - -] - { #category : #accessing, #'squeak_changestamp' : 'jj 6/22/2024 20:39' @@ -703,19 +700,6 @@ GMTEEditor >> exportMenu [ builder open: aMenuSpec ] -{ - #category : #'layer manipulation', - #'squeak_changestamp' : 'jj 6/22/2024 20:50' -} -GMTEEditor >> forgetLayers: aSet [ - "TODO: comment" - - | toBeForgotten | - toBeForgotten := self selectedLayers asSortedCollection reversed. - toBeForgotten do: [:i | self layerData removeAt: i]. - self changed: #getLayerList -] - { #category : #helper, #'squeak_changestamp' : 'jj 6/22/2024 20:51' @@ -772,15 +756,14 @@ GMTEEditor >> getGridWidthAsString [ { #category : #'layer manipulation', - #'squeak_changestamp' : 'jj 6/22/2024 20:54' + #'squeak_changestamp' : 'TW 6/23/2024 20:13' } GMTEEditor >> getLayerList [ "returns the layer list" - ^ self layerData collect: [ :layerData | - layerData second - ifTrue: [layerData first, ' (v)'] - ifFalse: [layerData first, ' (h)']] + self tileMap ifNil: [^ OrderedCollection new]. + + ^ self tileMap tileMatrixStack matrixLayers collect: [:aLayer | aLayer displayName, (GMTEEditor getVisibilityIndicator: aLayer visible)] ] { @@ -840,7 +823,7 @@ GMTEEditor >> getTileRatioAsString [ { #category : #'menu button functions', - #'squeak_changestamp' : 'jj 6/23/2024 14:05' + #'squeak_changestamp' : 'TW 6/23/2024 20:09' } GMTEEditor >> importFromMorph [ "import tilemap into editor from a .morph file" @@ -856,7 +839,7 @@ GMTEEditor >> importFromMorph [ changed: #getTileRatioAsString; changed: #getGridWidthAsString; changed: #getGridHeightAsString; - collectLayerData + changed: #getLayerList ] { @@ -911,21 +894,20 @@ GMTEEditor >> importMenu [ { #category : #initialisation, - #'squeak_changestamp' : 'jj 6/22/2024 20:57' + #'squeak_changestamp' : 'TW 6/23/2024 20:14' } GMTEEditor >> initialize [ "starts the tile editor" super initialize. self - layerData: OrderedCollection new; selectedLayers: Set new; - storeLayerN: 1; selectLayer: 1; morphBuilders: Dictionary new; open; ratio: 1; - savedSinceModified: true + savedSinceModified: true; + changed: #getLayerList ] { @@ -1015,26 +997,6 @@ GMTEEditor >> layerCount [ ^ self tileMap tileMatrixStack layerCount ] -{ - #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:06' -} -GMTEEditor >> layerData [ - "TODO: comment, what is this" - - ^ layerData - -] - -{ - #category : #accessing, - #'squeak_changestamp' : 'TW 6/22/2024 01:31' -} -GMTEEditor >> layerData: anObject [ - - layerData := anObject -] - { #category : #accessing, #'squeak_changestamp' : 'jj 6/22/2024 21:07' @@ -1264,7 +1226,7 @@ GMTEEditor >> ratio: anObject [ { #category : #'layer button functions', - #'squeak_changestamp' : 'jj 6/22/2024 21:28' + #'squeak_changestamp' : 'TW 6/23/2024 20:07' } GMTEEditor >> renameLayer [ "renames the selected layer with a user chosen name" @@ -1274,9 +1236,10 @@ GMTEEditor >> renameLayer [ ifTrue: [ selectedLayer := self getSelectedLayer. newName := FillInTheBlankMorph - request: 'New Name:' initialAnswer: (self layerData at: selectedLayer) first. + request: 'New Name:' initialAnswer: (self tileMap layerNameOf: selectedLayer). (newName isNil or: newName isEmpty) - ifFalse: [self updateLayerNameOf: selectedLayer to: newName]] + ifFalse: [self tileMap setLayerNameOf: selectedLayer to: newName]]. + self changed: #getLayerList ] @@ -1521,24 +1484,12 @@ GMTEEditor >> storeLayerN: aNumber [ { #category : #'layer manipulation', - #'squeak_changestamp' : 'jj 6/22/2024 21:46' -} -GMTEEditor >> storeLayerN: aNumber withVisibility: aBoolean [ - "TODO: comment" - - self layerData add: {'Layer ', aNumber . aBoolean}. - self changed: #getLayerList -] - -{ - #category : #'layer manipulation', - #'squeak_changestamp' : 'jj 6/22/2024 21:49' + #'squeak_changestamp' : 'TW 6/23/2024 20:05' } GMTEEditor >> swapLayer: anIndex with: anotherIndex [ "swaps two layers" | selectionOfA | - self layerData swap: anIndex with: anotherIndex. self tileMap tileMatrixStack swapLayer: anIndex with: anotherIndex. selectionOfA := self layerAt: anIndex. self @@ -1627,14 +1578,12 @@ GMTEEditor >> toggleGrid [ { #category : #'layer button functions', - #'squeak_changestamp' : 'jj 6/22/2024 21:52' + #'squeak_changestamp' : 'TW 6/23/2024 20:05' } GMTEEditor >> toggleSelectedLayerVisibility [ "toggles the visibility of the selected layers" - self selectedLayers do: [:i | - self tileMap tileMatrixStack toggleLayerVisibility: i. - self layerData at: i put: {(self layerData at: i) first . (self layerData at: i) second not}]. + self selectedLayers do: [:i |self tileMap tileMatrixStack toggleLayerVisibility: i]. self changed: #getLayerList ] @@ -1669,20 +1618,6 @@ GMTEEditor >> unselectTile [ self trayViewer morph submorphs first visible: false ] -{ - #category : #building, - #'squeak_changestamp' : 'jj 6/22/2024 21:52' -} -GMTEEditor >> updateLayerNameOf: anIndex to: aString [ - "updates the name of a layer" - - | visibility | - visibility := (self layerData at: anIndex) second. - - self layerData at: anIndex put: {aString. visibility}. - self changed: #getLayerList -] - { #category : #building, #'squeak_changestamp' : 'jj 6/23/2024 13:45' diff --git a/source/GM-TE/GMTETileMap.class.st b/source/GM-TE/GMTETileMap.class.st index 62bea544..a485008d 100644 --- a/source/GM-TE/GMTETileMap.class.st +++ b/source/GM-TE/GMTETileMap.class.st @@ -485,6 +485,15 @@ GMTETileMap >> initialize [ ] +{ + #category : #accessing, + #'squeak_changestamp' : 'TW 6/23/2024 20:01' +} +GMTETileMap >> layerNameOf: anIndex [ + + ^ self tileMatrixStack layerNameOf: anIndex +] + { #category : #'dev-api', #'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 22:53' @@ -717,6 +726,15 @@ GMTETileMap >> setDimensionsWidth: aWidth height: aHeigth padding: aPadding [ mapPadding: aPadding ] +{ + #category : #accessing, + #'squeak_changestamp' : 'TW 6/23/2024 20:03' +} +GMTETileMap >> setLayerNameOf: anIndex to: aString [ + + ^ self tileMatrixStack setLayerNameOf: anIndex to: aString +] + { #category : #'dev-api', #'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 23:11' diff --git a/source/GM-TE/GMTETileMatrixLayer.class.st b/source/GM-TE/GMTETileMatrixLayer.class.st index 1457312a..751c17cd 100644 --- a/source/GM-TE/GMTETileMatrixLayer.class.st +++ b/source/GM-TE/GMTETileMatrixLayer.class.st @@ -3,7 +3,8 @@ Class { #superclass : #GMTEStaticCoordinateMatrix, #instVars : [ 'layerIdx', - 'visible' + 'visible', + 'displayName' ], #category : #'GM-TE-Core' } @@ -69,6 +70,24 @@ GMTETileMatrixLayer >> belowLayer: aLayer [ ^ (self aboveLayer: aLayer) not ] +{ + #category : #accessing, + #'squeak_changestamp' : 'TW 6/23/2024 19:53' +} +GMTETileMatrixLayer >> displayName [ + + ^ displayName +] + +{ + #category : #accessing, + #'squeak_changestamp' : 'TW 6/23/2024 19:53' +} +GMTETileMatrixLayer >> displayName: anObject [ + + displayName := anObject +] + { #category : #enumerating, #'squeak_changestamp' : 'jj 6/23/2024 13:56' @@ -92,17 +111,6 @@ GMTETileMatrixLayer >> free [ self setNil ] -{ - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:25' -} -GMTETileMatrixLayer >> initialize [ - - super initialize. - - self visible: true -] - { #category : #accessing, #'squeak_changestamp' : 'jj 6/22/2024 16:24' diff --git a/source/GM-TE/GMTETileMatrixStack.class.st b/source/GM-TE/GMTETileMatrixStack.class.st index 68e54aee..1974b83f 100644 --- a/source/GM-TE/GMTETileMatrixStack.class.st +++ b/source/GM-TE/GMTETileMatrixStack.class.st @@ -223,7 +223,16 @@ GMTETileMatrixStack >> layerCount [ ] { - #category : #'as yet unclassified', + #category : #accessing, + #'squeak_changestamp' : 'TW 6/23/2024 20:01' +} +GMTETileMatrixStack >> layerNameOf: anIdx [ + + ^ (self layer: anIdx) displayName +] + +{ + #category : #accessing, #'squeak_changestamp' : 'jj 6/22/2024 16:29' } GMTETileMatrixStack >> layerVisible: anIdx [ @@ -390,6 +399,15 @@ GMTETileMatrixStack >> resetLayers: aSet [ self resetLayer: layerIdx] ] +{ + #category : #accessing, + #'squeak_changestamp' : 'TW 6/23/2024 20:02' +} +GMTETileMatrixStack >> setLayerNameOf: anIdx to: aString [ + + ^ (self layer: anIdx) displayName: aString +] + { #category : #updating, #'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:09' diff --git a/source/GM-Test.package/GMTileEditorTest.class/instance/testAddLayerButton.st b/source/GM-Test.package/GMTileEditorTest.class/instance/testAddLayerButton.st index e178e2f8..a51c4e58 100644 --- a/source/GM-Test.package/GMTileEditorTest.class/instance/testAddLayerButton.st +++ b/source/GM-Test.package/GMTileEditorTest.class/instance/testAddLayerButton.st @@ -2,7 +2,7 @@ layerTests testAddLayerButton "tests the addLayer button function" - self assert: editor layerData size = 1. + self assert: editor layerCount = 1. self assert: (editor selectedLayers includes: 1). self clickButton: (editor layerViewer submorphNamed: 'addLayer'). - self assert: editor layerData size = 2 \ No newline at end of file + self assert: editor layerCount = 2 \ No newline at end of file diff --git a/source/GM-Test.package/GMTileEditorTest.class/methodProperties.json b/source/GM-Test.package/GMTileEditorTest.class/methodProperties.json index d2fa3196..0d537bd8 100644 --- a/source/GM-Test.package/GMTileEditorTest.class/methodProperties.json +++ b/source/GM-Test.package/GMTileEditorTest.class/methodProperties.json @@ -10,7 +10,7 @@ "loadTestMapFileToFileDirectory" : "JS 6/23/2024 18:18", "setUp" : "jj 6/23/2024 18:55", "tearDown" : "jj 6/22/2024 20:24", - "testAddLayerButton" : "JS 6/23/2024 18:29", + "testAddLayerButton" : "TW 6/23/2024 20:08", "testDeleteLayer" : "jj 6/22/2024 20:25", "testDirectImport" : "jj 6/22/2024 20:30", "testDirectImportFromAssetbrowser" : "jj 6/22/2024 20:30",