diff --git a/source/GM-TE/GMTEEditor.class.st b/source/GM-TE/GMTEEditor.class.st index c5e97ea0..eb7e7a39 100644 --- a/source/GM-TE/GMTEEditor.class.st +++ b/source/GM-TE/GMTEEditor.class.st @@ -2,99 +2,98 @@ Class { #name : #GMTEEditor, #superclass : #Model, #instVars : [ - 'commandBar', 'tileStore', - 'tileViewer', - 'layerViewer', - 'trayViewer', 'selectedLayers', 'selectedTile', 'ratio', 'savedSinceModified', 'inspector', - 'morphBuilders', 'backgroundTile', 'tileMap', 'associatedMorph', 'commands', 'currentCommand', 'brush', - 'brushButtons' + 'brushButtons', + 'mapViewer', + 'tileTray' ], #category : #'GM-TE-UI' } { #category : #constants, - #'squeak_changestamp' : 'tw 7/12/2024 20:36' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:41' } GMTEEditor class >> editorMinimumExtent [ - "minimum extent of the tile editor" + "Minimum extent of the tile editor" ^ RealEstateAgent scaleFactor * (700 @ 400) ] { #category : #constants, - #'squeak_changestamp' : 'tw 7/12/2024 20:12' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:41' } GMTEEditor class >> getInputFieldSize [ - + "Attribute input field width" + ^ (TextStyle defaultFont approxWidthOfText: '1.00' asText) ] { #category : #fileHandling, - #'squeak_changestamp' : 'jj 6/23/2024 14:08' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:41' } GMTEEditor class >> getTileMapFromFileBinary: aFileBinary [ - "creates a tileMap from a file binary" + "Creates a tileMap from a file binary" ^ GMTETileMap newFrom: (GMTEEditor privateGetEditorTileMapFromFileBinary: aFileBinary) ] { #category : #fileHandling, - #'squeak_changestamp' : 'jj 6/23/2024 14:08' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:43' } GMTEEditor class >> getTileMapFromFilePath: aFilePath [ - "loads a tileMap from a local file path" + "Loads a tileMap from a local file path" ^ GMTETileMap newFrom: (GMTEEditor privateGetEditorTileMapFromFilePath: aFilePath) ] { #category : #fileHandling, - #'squeak_changestamp' : 'jj 6/23/2024 14:09' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:43' } GMTEEditor class >> getTileMapFromProjectName: aName withPath: aPath [ - "loads a tileMap from the git asset browser" + "Loads a tileMap from the git asset browser" ^ GMTEEditor getTileMapFromFileBinary: ((GitAssetLoader for: aName) loadAsset: aPath) ] { #category : #constants, - #'squeak_changestamp' : 'TW 6/23/2024 21:37' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:44' } GMTEEditor class >> getVisibilityIndicator: aBoolean [ - + aBoolean ifTrue: [^ ' (v)'] ifFalse: [^ ' (h)'] ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'tw 7/12/2024 18:33' + #category : #utility, + #'squeak_changestamp' : 'mcjj 7/12/2024 21:47' } GMTEEditor class >> hLayoutFrame: intI ofN: intN [ - + "Calculates the frame of equal sized specs" + ^ self hLayoutFrame: intI ofN: intN vSymmetric: 0 ] { - #category : #'as yet unclassified', + #category : #utility, #'squeak_changestamp' : 'tw 7/11/2024 17:03' } GMTEEditor class >> hLayoutFrame: intI ofN: intN vSymmetric: aFloat [ @@ -103,18 +102,17 @@ GMTEEditor class >> hLayoutFrame: intI ofN: intN vSymmetric: aFloat [ ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'tw 7/11/2024 17:05' + #category : #utility, + #'squeak_changestamp' : 'mcjj 7/12/2024 21:45' } GMTEEditor class >> hLayoutFrame: intI ofN: intN vUp: aFloat down: anotherFloat [ - "useful for building buttons, maybe move this to instance? TODO FLAG" ^ LayoutFrame fractions: ((intI - 1 / intN @ aFloat) corner: (intI / intN @ (1 - anotherFloat))) ] { - #category : #'as yet unclassified', + #category : #initialization, #'squeak_changestamp' : 'tw 7/12/2024 16:21' } GMTEEditor class >> initialize [ @@ -125,37 +123,40 @@ GMTEEditor class >> initialize [ { #category : #constants, - #'squeak_changestamp' : 'TW 7/9/2024 11:28' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:48' } GMTEEditor class >> maxBrushRadius [ - + "Maximum allowed radius for brushes" + ^ 50 ] { #category : #constants, - #'squeak_changestamp' : 'Ivo Zilkenat 7/9/2024 11:31' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:48' } GMTEEditor class >> maxNumberOfCommands [ + "Maximum amount of stored commands" ^ 50 ] { #category : #constants, - #'squeak_changestamp' : 'TW 7/9/2024 11:28' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:49' } GMTEEditor class >> minBrushRadius [ - + "Minimum allowed radius for brushes" + ^ 0 ] { #category : #fileHandling, - #'squeak_changestamp' : 'jj 6/23/2024 14:09' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:53' } GMTEEditor class >> privateGetEditorTileMapFromFileBinary: aFileBinary [ - "loads a EditorTileMap from a file binary" + "Loads a EditorTileMap from a file binary" |aFileStream tileMap| aFileStream := (MultiByteBinaryOrTextStream with: aFileBinary) binary reset. @@ -166,20 +167,20 @@ GMTEEditor class >> privateGetEditorTileMapFromFileBinary: aFileBinary [ { #category : #fileHandling, - #'squeak_changestamp' : 'jj 6/23/2024 14:07' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:53' } GMTEEditor class >> privateGetEditorTileMapFromFilePath: aFilePath [ - "loads a EditorTileMap from a local file path" + "Loads a EditorTileMap from a local file path" ^ GMTEEditor privateGetEditorTileMapFromFileBinary: (FileStream readOnlyFileNamed: aFilePath) binary contentsOfEntireFile ] { #category : #squeakutils, - #'squeak_changestamp' : 'tw 7/12/2024 16:20' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:53' } GMTEEditor class >> register [ - "adds the tile editor to app menu" + "Adds the tile editor to app menu" "Maybe call this on new?" TheWorldMenu registerOpenCommand: {'TileMap Editor'. {self. #startup}} @@ -187,18 +188,20 @@ GMTEEditor class >> register [ { #category : #constants, - #'squeak_changestamp' : 'TW 6/25/2024 15:53' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:54' } GMTEEditor class >> singleLayerActionNames [ - + "Layer actions that only work for one selected layer" + ^ {'buttonMoveLayerDown' . 'buttonMoveLayerUp' . 'buttonRenameLayer'} ] { #category : #startup, - #'squeak_changestamp' : 'Alex M 7/9/2024 17:59' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:57' } GMTEEditor class >> startup [ + "Opens the editor with a startup wizard" (DialogWindow new title: 'Wizard'; @@ -214,50 +217,50 @@ GMTEEditor class >> startup [ { #category : #constants, - #'squeak_changestamp' : 'Alex M 7/9/2024 17:33' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:56' } GMTEEditor class >> startupMinimumExtent [ - "minimum extent of the startup wizard" + "Minimum extent of the startup wizard" ^ 300@200 ] { #category : #constants, - #'squeak_changestamp' : 'jj 6/23/2024 17:33' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:57' } GMTEEditor class >> tileMapMaxGridSize [ - "the maximum size of the tileMap per dimension" + "Maximum size of the tileMap per dimension" ^ 200 ] { #category : #constants, - #'squeak_changestamp' : 'jj 6/23/2024 17:35' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:57' } GMTEEditor class >> tileMapMaxPaddingSize [ - "the maximum size of the tileMap padding" + "Maximum size of the tileMap padding" ^ 0.9 ] { #category : #constants, - #'squeak_changestamp' : 'jj 6/23/2024 17:33' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:57' } GMTEEditor class >> tileMapMinGridSize [ - "the minimum size of the tileMap per dimension" + "Minimum size of the tileMap per dimension" ^ 0 ] { #category : #constants, - #'squeak_changestamp' : 'jj 6/23/2024 17:34' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:57' } GMTEEditor class >> tileMapMinPaddingSize [ - "the minimum size of the tileMap padding" + "Minimum size of the tileMap padding" ^ 0 ] @@ -272,27 +275,27 @@ GMTEEditor class >> toolBarVSpace [ ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'tw 7/12/2024 18:33' + #category : #utility, + #'squeak_changestamp' : 'mcjj 7/12/2024 21:58' } GMTEEditor class >> vLayoutFrame: intI ofN: intN [ - + "Calculates the frame of equal sized specs" + ^ self vLayoutFrame: intI ofN: intN hSymmetric: 0 ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'tw 7/12/2024 18:26' + #category : #utility, + #'squeak_changestamp' : 'mcjj 7/12/2024 21:58' } GMTEEditor class >> vLayoutFrame: intI ofN: intN hLeft: aFloat right: anotherFloat [ - "useful for building buttons, maybe move this to instance? TODO FLAG" ^ LayoutFrame fractions: ((aFloat @ (intI - 1 / intN)) corner: (1 - anotherFloat @ (intI / intN))) ] { - #category : #'as yet unclassified', + #category : #utility, #'squeak_changestamp' : 'tw 7/12/2024 18:26' } GMTEEditor class >> vLayoutFrame: intI ofN: intN hSymmetric: aFloat [ @@ -365,9 +368,10 @@ GMTEEditor >> anyLayerSelected [ { #category : #accessing, - #'squeak_changestamp' : 'TW 6/25/2024 15:55' + #'squeak_changestamp' : 'tw 7/12/2024 21:49' } GMTEEditor >> associatedMorph [ + "The morph associated with the model" ^ associatedMorph ] @@ -383,20 +387,21 @@ GMTEEditor >> associatedMorph: anObject [ { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:51' + #'squeak_changestamp' : 'tw 7/12/2024 21:49' } GMTEEditor >> backgroundTile [ - "the tile used to dynamically fill the background of the map, if the user wishes so" + "The tile used to dynamically fill the background of the map, if the user wishes so" ^ backgroundTile ] { #category : #accessing, - #'squeak_changestamp' : 'Alex M 7/9/2024 15:41' + #'squeak_changestamp' : 'tw 7/12/2024 21:51' } GMTEEditor >> backgroundTile: anObject [ + self flag: 'cursed'. (backgroundTile = anObject) ifTrue: [backgroundTile := GMTETile checkerBoardTile] ifFalse: [backgroundTile := anObject]. @@ -436,17 +441,19 @@ GMTEEditor >> blendSelectedLayers [ { #category : #accessing, - #'squeak_changestamp' : 'Valentin Teutschbein 7/6/2024 12:54' + #'squeak_changestamp' : 'tw 7/12/2024 21:49' } GMTEEditor >> brush [ + ^ brush ] { #category : #accessing, - #'squeak_changestamp' : 'Valentin Teutschbein 7/6/2024 12:54' + #'squeak_changestamp' : 'tw 7/12/2024 21:51' } GMTEEditor >> brush: anObject [ + brush := anObject ] @@ -470,7 +477,7 @@ GMTEEditor >> brushButtons: anObject [ { #category : #building, - #'squeak_changestamp' : 'tw 7/12/2024 20:35' + #'squeak_changestamp' : 'tw 7/12/2024 22:10' } GMTEEditor >> buildWith: builder [ "builds the editor with ToolBuilder" @@ -494,21 +501,18 @@ GMTEEditor >> buildWith: builder [ newMorph addKeyboardCaptureFilter: self. - self commandBar: (newMorph submorphNamed: 'command bar'). "self commandBar vResizing: #rigid." self tileStore: (newMorph submorphNamed: 'tile store'). - self tileViewer: ((newMorph submorphNamed: 'main panel') submorphNamed: 'tile viewer'). - self layerViewer: (newMorph submorphNamed: 'layer viewer'). - self trayViewer: (newMorph submorphNamed: 'tray'). - self inspector: (newMorph submorphNamed: 'inspector'). - self tileViewer clipSubmorphs: true. + self mapViewer: ((newMorph submorphNamed: 'main panel') submorphNamed: 'tile viewer'). + self tileTray: (newMorph submorphNamed: 'tray'). + self mapViewer clipSubmorphs: true. panel := GMTETileContainer withParent: self tileStore. self tileStore morph: panel. self placeSelectedTileIntoTileTray. - self tileViewer + self mapViewer borderWidth: 2; borderColor: tileStore borderColor. @@ -531,36 +535,20 @@ GMTEEditor >> calculateAttributeContainerWidth: aString [ { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 20:39' -} -GMTEEditor >> commandBar [ - "panel that contains menu button functions" - - ^ commandBar -] - -{ - #category : #accessing, - #'squeak_changestamp' : 'TW 6/22/2024 01:14' -} -GMTEEditor >> commandBar: anObject [ - - commandBar := anObject -] - -{ - #category : #accessing, - #'squeak_changestamp' : 'Alex M 6/28/2024 19:48' + #'squeak_changestamp' : 'tw 7/12/2024 21:52' } GMTEEditor >> commands [ + "List of recent commands, used for undo/redo" + ^ commands ] { #category : #accessing, - #'squeak_changestamp' : 'Alex M 6/28/2024 19:48' + #'squeak_changestamp' : 'tw 7/12/2024 21:52' } GMTEEditor >> commands: anObject [ + commands := anObject ] @@ -962,17 +950,20 @@ GMTEEditor >> createTraySpecWithBuilder: aBuilder [ { #category : #accessing, - #'squeak_changestamp' : 'Alex M 6/28/2024 19:48' + #'squeak_changestamp' : 'tw 7/12/2024 21:53' } GMTEEditor >> currentCommand [ + "Index of the command whose state the editor is currently in" + ^ currentCommand ] { #category : #accessing, - #'squeak_changestamp' : 'Alex M 6/28/2024 19:48' + #'squeak_changestamp' : 'tw 7/12/2024 21:52' } GMTEEditor >> currentCommand: anObject [ + currentCommand := anObject ] @@ -1003,11 +994,11 @@ GMTEEditor >> deleteTilemapLayers: aLayerList [ ] { - #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 20:47' + #category : #'as yet unclassified', + #'squeak_changestamp' : 'tw 7/12/2024 21:53' } GMTEEditor >> deselectAllLayers [ - "empties the selected layers set" + "Empties the selected layers set" self selectedLayers: Set new; @@ -1016,7 +1007,7 @@ GMTEEditor >> deselectAllLayers [ ] { - #category : #accessing, + #category : #'as yet unclassified', #'squeak_changestamp' : 'TW 6/25/2024 17:50' } GMTEEditor >> deselectLayer: anIndex [ @@ -1035,7 +1026,7 @@ GMTEEditor >> deselectLayer: anIndex [ ] { - #category : #accessing, + #category : #'as yet unclassified', #'squeak_changestamp' : 'jj 6/22/2024 20:48' } GMTEEditor >> deselectTile [ @@ -1160,7 +1151,7 @@ GMTEEditor >> filterEvent: aKeyboardEvent for: anObject [ { #category : #accessing, - #'squeak_changestamp' : 'TW 7/9/2024 17:14' + #'squeak_changestamp' : 'tw 7/12/2024 21:58' } GMTEEditor >> getBrushRadius [ @@ -1190,10 +1181,10 @@ GMTEEditor >> getFileWithFileChooser [ { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 20:51' + #'squeak_changestamp' : 'tw 7/12/2024 21:54' } GMTEEditor >> getGridHeight [ - "returns the height (in tiles) of the tileMap" + "Returns the height (in tiles) of the tileMap" self tileMap ifNotNil: [^ self tileMap mapTileHeight] @@ -1212,10 +1203,10 @@ GMTEEditor >> getGridHeightAsString [ { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 20:52' + #'squeak_changestamp' : 'tw 7/12/2024 21:54' } GMTEEditor >> getGridWidth [ - "returns the width (in tiles) of the tileMap" + "Returns the width (in tiles) of the tileMap" self tileMap ifNotNil: [^ self tileMap mapTileWidth] @@ -1255,10 +1246,10 @@ GMTEEditor >> getMaximalSizeOfStrings: anOrderedCollection [ { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 20:54' + #'squeak_changestamp' : 'tw 7/12/2024 21:54' } GMTEEditor >> getPadding [ - "returns the padding of the tileMap" + "Returns the padding of the tileMap" self tileMap ifNotNil: [^ self tileMap mapPadding] @@ -1295,31 +1286,9 @@ GMTEEditor >> getSizeOfString: aString [ ^ TextStyle defaultFont approxWidthOfText: aString asText ] -{ - #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 20:56' -} -GMTEEditor >> getTileRatio [ - "returns the tileSizeRatio of the tileMap" - - self tileMap - ifNotNil: [^ self tileMap tileSizeRatio] - ifNil: [^ nil] -] - -{ - #category : #inspector, - #'squeak_changestamp' : 'jj 6/22/2024 20:56' -} -GMTEEditor >> getTileRatioAsString [ - "returns the tileSizeRatio of the tileMap as a string" - - ^ self getTileRatio asString -] - { #category : #'menu button functions', - #'squeak_changestamp' : 'TW 6/23/2024 20:09' + #'squeak_changestamp' : 'tw 7/12/2024 21:54' } GMTEEditor >> importFromMorph [ "import tilemap into editor from a .morph file" @@ -1332,7 +1301,6 @@ GMTEEditor >> importFromMorph [ self openTileMapInEditor: tileMap. self changed: #getPaddingAsString; - changed: #getTileRatioAsString; changed: #getGridWidthAsString; changed: #getGridHeightAsString; changed: #getLayerList @@ -1340,7 +1308,7 @@ GMTEEditor >> importFromMorph [ { #category : #'menu button functions', - #'squeak_changestamp' : 'jj 6/22/2024 20:57' + #'squeak_changestamp' : 'tw 7/12/2024 22:05' } GMTEEditor >> importFromTileset [ "loads a tileset into the tile store" @@ -1353,7 +1321,7 @@ GMTEEditor >> importFromTileset [ ifTrue: [^ nil] ifFalse:[tileHeight := tileHeight asInteger]. - dimensions := (tileHeight @ (tileHeight * self ratio)). + dimensions := (tileHeight @ tileHeight). tiles := self loadTileSetWithDimensions: dimensions. tiles ifNil: [^ nil]. @@ -1390,7 +1358,7 @@ GMTEEditor >> importMenu [ { #category : #initialization, - #'squeak_changestamp' : 'TW 7/9/2024 19:42' + #'squeak_changestamp' : 'tw 7/12/2024 22:02' } GMTEEditor >> initialize [ "starts the tile editor" @@ -1402,9 +1370,7 @@ GMTEEditor >> initialize [ selectedLayers: Set new; selectLayer: 1; brushButtons: GMTEButtonGroup new; - morphBuilders: Dictionary new; open; - ratio: 1; savedSinceModified: true; updateButtonEnabled; changed: #getLayerList; @@ -1436,44 +1402,24 @@ GMTEEditor >> initializeDefaultTileMapMatrix [ { #category : #initialization, - #'squeak_changestamp' : 'jj 6/22/2024 20:59' + #'squeak_changestamp' : 'tw 7/12/2024 22:09' } GMTEEditor >> initializeTileMapMatrixWithHeight: aHeight width: aWidth [ "initializes the tileMap with a tile map with a certain height and width" self tileMap: (GMTEEditorTileMap tileWidth: aWidth tileHeight: aHeight padding: 0.15 sizeRatio: 1 model: self). - self tileViewer addMorph: self tileMap. + self mapViewer addMorph: self tileMap. self tileMap position: (self tileMap owner position); hResizing: #spaceFill; vResizing: #spaceFill; updateMap. self - changed: #getTileRatioAsString; changed: #getGridWidthAsString; changed: #getGridHeightAsString; changed: #getPaddingAsString ] -{ - #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:02' -} -GMTEEditor >> inspector [ - "the inspector tab that allows to adjust the attributes of the tileMap" - - ^ inspector -] - -{ - #category : #accessing, - #'squeak_changestamp' : 'TW 6/22/2024 01:32' -} -GMTEEditor >> inspector: anObject [ - - inspector := anObject -] - { #category : #'layer manipulation', #'squeak_changestamp' : 'jj 6/22/2024 21:04' @@ -1511,25 +1457,6 @@ GMTEEditor >> layerCount [ ^ self tileMap tileMatrixStack layerCount ] -{ - #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:07' -} -GMTEEditor >> layerViewer [ - "panel that allows for manipulation of the tileMap layers" - - ^ layerViewer -] - -{ - #category : #accessing, - #'squeak_changestamp' : 'TW 6/22/2024 01:31' -} -GMTEEditor >> layerViewer: anObject [ - - layerViewer := anObject -] - { #category : #'file loading', #'squeak_changestamp' : 'jj 6/23/2024 17:31' @@ -1581,21 +1508,21 @@ GMTEEditor >> loadTileSetWithDimensions: aPoint [ { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:11' + #'squeak_changestamp' : 'tw 7/12/2024 22:09' } -GMTEEditor >> morphBuilders [ - "collection that contains the morph builders" +GMTEEditor >> mapViewer [ + "The panel that contains the tileMap" - ^ morphBuilders + ^ mapViewer ] { #category : #accessing, - #'squeak_changestamp' : 'TW 6/22/2024 01:31' + #'squeak_changestamp' : 'tw 7/12/2024 22:09' } -GMTEEditor >> morphBuilders: anObject [ +GMTEEditor >> mapViewer: anObject [ - morphBuilders := anObject + mapViewer := anObject ] { @@ -1642,7 +1569,7 @@ GMTEEditor >> onClose [ { #category : #initialization, - #'squeak_changestamp' : 'jj 6/22/2024 21:14' + #'squeak_changestamp' : 'tw 7/12/2024 22:09' } GMTEEditor >> open [ "builds the window" @@ -1650,13 +1577,13 @@ GMTEEditor >> open [ | newMorph | newMorph := ToolBuilder default build: self. newMorph openInWorld. - self tileViewer submorphs first updateMap. + self mapViewer submorphs first updateMap. ^ newMorph ] { #category : #helper, - #'squeak_changestamp' : 'Alex M 7/3/2024 23:57' + #'squeak_changestamp' : 'tw 7/12/2024 22:09' } GMTEEditor >> openTileMapInEditor: aTileMap [ "loads a tileMap into the editor" @@ -1664,7 +1591,7 @@ GMTEEditor >> openTileMapInEditor: aTileMap [ aTileMap tileSelectionSet highlightImage: nil. self tileMap: aTileMap. aTileMap model: self. - self tileViewer + self mapViewer removeAllMorphs; addMorph: aTileMap. self resetCommands. @@ -1738,7 +1665,7 @@ GMTEEditor >> parseSize: aText [ { #category : #building, - #'squeak_changestamp' : 'JS 7/12/2024 18:20' + #'squeak_changestamp' : 'tw 7/12/2024 22:09' } GMTEEditor >> placeSelectedTileIntoTileTray [ @@ -1749,30 +1676,11 @@ GMTEEditor >> placeSelectedTileIntoTileTray [ model: self; yourself. - self trayViewer morph + self tileTray morph color: Color transparent; addMorph: selectedTile ] -{ - #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:27' -} -GMTEEditor >> ratio [ - "the ratio of height to width of tiles" - - ^ ratio -] - -{ - #category : #accessing, - #'squeak_changestamp' : 'Alex M 6/22/2024 15:47' -} -GMTEEditor >> ratio: anObject [ - - ratio := anObject -] - { #category : #'command processing', #'squeak_changestamp' : 'Alex M 7/10/2024 14:17' @@ -1788,17 +1696,6 @@ 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' @@ -1894,7 +1791,7 @@ GMTEEditor >> resetSelectedLayers [ ] { - #category : #TODO, + #category : #'menu button functions', #'squeak_changestamp' : 'tw 7/12/2024 17:46' } GMTEEditor >> resetView [ @@ -1903,23 +1800,24 @@ GMTEEditor >> resetView [ ] { - #category : #TODO, - #'squeak_changestamp' : 'mcjj 7/11/2024 17:52' + #category : #'as yet unclassified', + #'squeak_changestamp' : 'tw 7/12/2024 21:48' } GMTEEditor >> rotateSelectedTile [ self selectedTile: (self selectedTile rotateBy: #right centerAt: (self selectedTile extent / 2)). - self tileMap tileSelectionSet removeAllHighlightings. - self tileMap tileSelectionSet highlightImage: self selectedTile. - self tileMap tileSelectionSet applyAllHighlightings + self tileMap tileSelectionSet + removeAllHighlightings; + highlightImage: self selectedTile; + applyAllHighlightings ] { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:31' + #'squeak_changestamp' : 'tw 7/12/2024 21:59' } GMTEEditor >> savedSinceModified [ - "whether the tileMap has been modified since the last save" + "Whether the tileMap has been modified since the last save" ^ savedSinceModified ] @@ -1934,7 +1832,7 @@ GMTEEditor >> savedSinceModified: anObject [ ] { - #category : #accessing, + #category : #'as yet unclassified', #'squeak_changestamp' : 'jj 6/22/2024 21:33' } GMTEEditor >> selectAllLayers [ @@ -1955,7 +1853,7 @@ GMTEEditor >> selectFillBrush [ ] { - #category : #accessing, + #category : #'as yet unclassified', #'squeak_changestamp' : 'TW 6/25/2024 17:50' } GMTEEditor >> selectLayer: anIndex [ @@ -1980,7 +1878,7 @@ GMTEEditor >> selectLineBrush [ ] { - #category : #accessing, + #category : #'as yet unclassified', #'squeak_changestamp' : 'jj 6/22/2024 21:35' } GMTEEditor >> selectOnlyLayer: anIndex [ @@ -2013,8 +1911,8 @@ GMTEEditor >> selectRectangleBrush [ ] { - #category : #accessing, - #'squeak_changestamp' : 'JS 7/12/2024 18:12' + #category : #'as yet unclassified', + #'squeak_changestamp' : 'tw 7/12/2024 22:09' } GMTEEditor >> selectTile: anObject [ "selects a tile from the tile store" @@ -2025,7 +1923,7 @@ GMTEEditor >> selectTile: anObject [ ifFalse: [ self selectedTile: anObject fullResolutionSprite. self tileMap tileSelectionSet highlightImage: anObject fullResolutionSprite. - (self trayViewer morph submorphNamed: 'selectedTile') + (self tileTray morph submorphNamed: 'selectedTile') visible: true; updateSprite: anObject fullResolutionSprite; extent: 75@75] @@ -2033,10 +1931,10 @@ GMTEEditor >> selectTile: anObject [ { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:41' + #'squeak_changestamp' : 'tw 7/12/2024 22:00' } GMTEEditor >> selectedLayers [ - "set that contains the selected layers" + "Set that contains the user selected layers" ^ selectedLayers ] @@ -2052,10 +1950,10 @@ GMTEEditor >> selectedLayers: anObject [ { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:41' + #'squeak_changestamp' : 'tw 7/12/2024 22:06' } GMTEEditor >> selectedTile [ - "selected tile that is placed on the map" + "Currently selected form for painting the map" ^ selectedTile ] @@ -2101,10 +1999,10 @@ GMTEEditor >> setBrushRadiusFromText: aText [ { #category : #tilemap, - #'squeak_changestamp' : 'Alex M 7/12/2024 20:03' + #'squeak_changestamp' : 'tw 7/12/2024 21:44' } GMTEEditor >> setGridHeight: aText [ - "adjusts the grid height" + "If text is a valid size, adjust grid height" | oldSize newHeight | oldSize := self getGridWidth @ self getGridHeight. @@ -2120,10 +2018,10 @@ GMTEEditor >> setGridHeight: aText [ { #category : #tilemap, - #'squeak_changestamp' : 'Alex M 7/12/2024 20:06' + #'squeak_changestamp' : 'tw 7/12/2024 21:44' } GMTEEditor >> setGridWidth: aText [ - "adjusts the grid width" + "If text is a valid size, adjust grid width" | oldSize newWidth | oldSize := self getGridWidth @ self getGridHeight. @@ -2138,10 +2036,10 @@ GMTEEditor >> setGridWidth: aText [ { #category : #tilemap, - #'squeak_changestamp' : 'jj 6/22/2024 21:42' + #'squeak_changestamp' : 'tw 7/12/2024 21:44' } GMTEEditor >> setPadding: aText [ - "adjusts the map padding" + "If text is a valid size, adjust map padding" | newSize | newSize := self parsePaddingSize: aText. @@ -2219,10 +2117,10 @@ GMTEEditor >> swapLayer: anIndex with: anotherIndex [ { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:49' + #'squeak_changestamp' : 'tw 7/12/2024 22:06' } GMTEEditor >> tileMap [ - "the tileMap that the editor works on" + "The tileMap that the editor works on" ^ tileMap ] @@ -2238,10 +2136,10 @@ GMTEEditor >> tileMap: anObject [ { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:49' + #'squeak_changestamp' : 'tw 7/12/2024 22:07' } GMTEEditor >> tileStore [ - "the panel that shows the imported tilesets" + "Panel where the user can select tiles" ^ tileStore ] @@ -2257,21 +2155,21 @@ GMTEEditor >> tileStore: anObject [ { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:50' + #'squeak_changestamp' : 'tw 7/12/2024 22:10' } -GMTEEditor >> tileViewer [ - "the panel that contains the tileMap" +GMTEEditor >> tileTray [ + "Lower panel. Shows selected tile, and could be expanded for more utility" - ^ tileViewer + ^ tileTray ] { #category : #accessing, - #'squeak_changestamp' : 'TW 6/22/2024 01:30' + #'squeak_changestamp' : 'tw 7/12/2024 22:10' } -GMTEEditor >> tileViewer: anObject [ +GMTEEditor >> tileTray: anObject [ - tileViewer := anObject + tileTray := anObject ] { @@ -2305,25 +2203,6 @@ GMTEEditor >> toggleSelectedLayerVisibility [ self changed: #getLayerList ] -{ - #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:52' -} -GMTEEditor >> trayViewer [ - "the panel that contains the selected tile" - - ^ trayViewer -] - -{ - #category : #accessing, - #'squeak_changestamp' : 'TW 6/22/2024 01:30' -} -GMTEEditor >> trayViewer: anObject [ - - trayViewer := anObject -] - { #category : #'command processing', #'squeak_changestamp' : 'Alex M 7/12/2024 19:52' @@ -2340,15 +2219,15 @@ GMTEEditor >> undo [ ] { - #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:52' + #category : #'as yet unclassified', + #'squeak_changestamp' : 'tw 7/12/2024 22:09' } GMTEEditor >> unselectTile [ "unselects the currently selected tile" self selectedTile: nil. self tileMap tileSelectionSet highlightImage: nil. - self trayViewer morph submorphs first visible: false + self tileTray morph submorphs first visible: false ] { diff --git a/source/GM-TE/GMTEImageButton.class.st b/source/GM-TE/GMTEImageButton.class.st index 5bbcab24..436b3efa 100644 --- a/source/GM-TE/GMTEImageButton.class.st +++ b/source/GM-TE/GMTEImageButton.class.st @@ -32,11 +32,11 @@ GMTEImageButton >> actionSelector [ { #category : #accessing, - #'squeak_changestamp' : 'jannis 2/8/2024 18:31' + #'squeak_changestamp' : 'tw 7/12/2024 21:25' } -GMTEImageButton >> actionSelector: aSymbolOrString [ +GMTEImageButton >> actionSelector: anObject [ - actionSelector := aSymbolOrString asSymbol + actionSelector := anObject asSymbol ] { @@ -51,20 +51,20 @@ GMTEImageButton >> arguments [ { #category : #accessing, - #'squeak_changestamp' : 'Thomas Wolf 2/4/2024 23:10' + #'squeak_changestamp' : 'tw 7/12/2024 21:25' } -GMTEImageButton >> arguments: aCollection [ +GMTEImageButton >> arguments: anObject [ - arguments := aCollection asArray copy + arguments := anObject asArray copy ] { #category : #accessing, - #'squeak_changestamp' : 'TW 7/9/2024 18:24' + #'squeak_changestamp' : 'tw 7/12/2024 21:10' } -GMTEImageButton >> basicButtonGroup: aCollection [ +GMTEImageButton >> basicButtonGroup: anObject [ - buttonGroup := aCollection + buttonGroup := anObject ] { @@ -88,16 +88,16 @@ GMTEImageButton >> buttonGroup [ { #category : #accessing, - #'squeak_changestamp' : 'tw 7/12/2024 17:08' + #'squeak_changestamp' : 'tw 7/12/2024 21:11' } -GMTEImageButton >> buttonGroup: aCollection [ +GMTEImageButton >> buttonGroup: anObject [ - self basicButtonGroup: aCollection. - aCollection register: self as: self groupName + self basicButtonGroup: anObject. + anObject register: self as: self groupName ] { - #category : #accessing, + #category : #'visual properties', #'squeak_changestamp' : 'jj 6/22/2024 16:48' } GMTEImageButton >> createStateImagesFrom: anImage [ @@ -115,7 +115,7 @@ GMTEImageButton >> createStateImagesFrom: anImage [ ] { - #category : #button, + #category : #logic, #'squeak_changestamp' : 'TW 7/9/2024 18:22' } GMTEImageButton >> doButtonAction [ @@ -132,15 +132,13 @@ GMTEImageButton >> doButtonAction [ ] { - #category : #accessing, - #'squeak_changestamp' : 'Alex M 7/6/2024 23:07' + #category : #'visual properties', + #'squeak_changestamp' : 'tw 7/12/2024 21:14' } GMTEImageButton >> dyeSprite: anImage with: aColor [ ^ anImage copy replaceColor: Color white withColor: Color transparent; - "replaceColor: Color black withColor: aColor; - yourself" dyed: aColor ] @@ -171,10 +169,11 @@ GMTEImageButton >> enabled: aBoolean [ { #category : #accessing, - #'squeak_changestamp' : 'tw 7/12/2024 17:03' + #'squeak_changestamp' : 'tw 7/12/2024 21:27' } GMTEImageButton >> groupName [ - + "How this button is identified in its group" + ^ groupName ] @@ -278,17 +277,7 @@ GMTEImageButton >> mouseUp: anEvent [ ] { - #category : #accessing, - #'squeak_changestamp' : 'tw 7/12/2024 17:21' -} -GMTEImageButton >> onlySelect [ - - self buttonGroup ifNotNil: [self buttonGroup singleSelect: self]. - -] - -{ - #category : #accessing, + #category : #logic, #'squeak_changestamp' : 'tw 7/12/2024 17:23' } GMTEImageButton >> select [ @@ -299,10 +288,11 @@ GMTEImageButton >> select [ { #category : #accessing, - #'squeak_changestamp' : 'TW 7/9/2024 19:01' + #'squeak_changestamp' : 'tw 7/12/2024 21:27' } GMTEImageButton >> selected [ - + "Is this button in a group currently selected" + ^ selected ] @@ -316,7 +306,7 @@ GMTEImageButton >> selected: anObject [ ] { - #category : #accessing, + #category : #'visual properties', #'squeak_changestamp' : 'TW 6/25/2024 15:39' } GMTEImageButton >> setImageMode: aString [ @@ -327,9 +317,10 @@ GMTEImageButton >> setImageMode: aString [ { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 16:49' + #'squeak_changestamp' : 'tw 7/12/2024 21:27' } GMTEImageButton >> stateSprites [ + "The sprites for the various states the button can assume, preferably in different colours" ^ stateSprites ] @@ -364,29 +355,46 @@ GMTEImageButton >> target: anObject [ { #category : #'visual properties', - #'squeak_changestamp' : 'tw 7/12/2024 18:39' + #'squeak_changestamp' : 'tw 7/12/2024 21:27' } GMTEImageButton >> updateVisualState: anEvent [ - + "Guard to check whether this button is allowed to react to mouse input" self enabled ifFalse: [ self setImageMode: 'disabled'. ^ nil]. self buttonGroup - ifNil: [ + ifNil: [self updateVisualStateUngrouped: anEvent] + ifNotNil: [self updateVisualStateGrouped: anEvent] +] + +{ + #category : #'visual properties', + #'squeak_changestamp' : 'tw 7/12/2024 21:17' +} +GMTEImageButton >> updateVisualStateGrouped: anEvent [ + + self selected + ifFalse: [ (self containsPoint: Sensor cursorPoint) ifTrue: [anEvent redButtonPressed ifTrue: [self setImageMode: 'pressed'] ifFalse:[self setImageMode: 'hovered']] ifFalse: [self setImageMode: 'unpressed']] - ifNotNil: [ - self selected - ifFalse: [ - (self containsPoint: Sensor cursorPoint) - ifTrue: [anEvent redButtonPressed - ifTrue: [self setImageMode: 'pressed'] - ifFalse:[self setImageMode: 'hovered']] - ifFalse: [self setImageMode: 'unpressed']]] +] + +{ + #category : #'visual properties', + #'squeak_changestamp' : 'tw 7/12/2024 21:18' +} +GMTEImageButton >> updateVisualStateUngrouped: anEvent [ + + (self containsPoint: Sensor cursorPoint) + ifTrue: [anEvent redButtonPressed + ifTrue: [self setImageMode: 'pressed'] + ifFalse:[self setImageMode: 'hovered']] + ifFalse: [self setImageMode: 'unpressed'] + ] diff --git a/source/GM-TE/GMTETileContainer.class.st b/source/GM-TE/GMTETileContainer.class.st index 3cdde14f..40aa41fb 100644 --- a/source/GM-TE/GMTETileContainer.class.st +++ b/source/GM-TE/GMTETileContainer.class.st @@ -1,5 +1,5 @@ " -It is not good code right now. Maybe find a nicer solution later +Contains and manages layout for TileSelectors. " Class { #name : #GMTETileContainer, @@ -8,21 +8,21 @@ Class { 'parent' ], #category : #'GM-TE-UI', - #'squeak_changestamp' : 'Alex M 5/21/2024 16:50' + #'squeak_changestamp' : 'mcjj 7/12/2024 22:18' } { #category : #constants, - #'squeak_changestamp' : 'jj 6/23/2024 17:13' + #'squeak_changestamp' : 'tw 7/12/2024 21:38' } GMTETileContainer class >> minTileSize [ - "TODO: comment" + "Minimal size of tile" - ^ 40 + ^ 40 * RealEstateAgent scaleFactor ] { - #category : #'as yet unclassified', + #category : #'instance creation', #'squeak_changestamp' : 'jj 6/22/2024 16:50' } GMTETileContainer class >> withParent: aParent [ @@ -54,11 +54,12 @@ GMTETileContainer >> parent: anObject [ ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'jj 6/23/2024 17:13' + #category : #updating, + #'squeak_changestamp' : 'tw 7/12/2024 21:33' } GMTETileContainer >> step [ - + "Workaround since ScrollPane doesn't resize it's submorphs. This is to ensure our TileContainer rearranges itself" + | n gap minTileSize | (self parent isNil or: [self parent extent = self extent]) ifTrue: [^ nil]. @@ -67,11 +68,11 @@ GMTETileContainer >> step [ minTileSize := GMTETileContainer minTileSize. n := self width / minTileSize. gap := self width - (n floor * minTileSize) / n. - self submorphs do: [:tile| tile extent: (minTileSize + gap - 2)] "TODO: magic number" + self submorphs do: [:tile| tile extent: (minTileSize + gap - 2)] "Edge has a width of 1" ] { - #category : #'as yet unclassified', + #category : #accessing, #'squeak_changestamp' : 'jj 6/22/2024 16:50' } GMTETileContainer >> stepTime [ diff --git a/source/GM-TE/GMTETileSelector.class.st b/source/GM-TE/GMTETileSelector.class.st index 14c9f7bb..ec819db6 100644 --- a/source/GM-TE/GMTETileSelector.class.st +++ b/source/GM-TE/GMTETileSelector.class.st @@ -1,10 +1,15 @@ +" +A clickable Morph to select tiles from the tile store. + +" Class { #name : #GMTETileSelector, #superclass : #GMTETile, #instVars : [ 'model' ], - #category : #'GM-TE-UI' + #category : #'GM-TE-UI', + #'squeak_changestamp' : 'mcjj 7/12/2024 22:09' } { @@ -20,23 +25,17 @@ GMTETileSelector >> extent: anExtent [ ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'jj 6/22/2024 16:50' + #category : #'input handling', + #'squeak_changestamp' : 'mcjj 7/12/2024 21:25' } GMTETileSelector >> handlesMouseDown: evt [ - evt redButtonPressed - ifTrue: [ - self model selectTile: self. - ^ true] - ifFalse: [ - self model backgroundTile: self. - ^ false] + ^ true ] { #category : #accessing, - #'squeak_changestamp' : 'Alex M 7/9/2024 15:16' + #'squeak_changestamp' : 'mcjj 7/12/2024 21:21' } GMTETileSelector >> image: anImage [ @@ -45,7 +44,7 @@ GMTETileSelector >> image: anImage [ at: 0@0 sourceRect: (anImage boundingBox) rule: Form blend) - form. + form ] { @@ -79,3 +78,14 @@ GMTETileSelector >> model: anObject [ model := anObject ] + +{ + #category : #'input handling', + #'squeak_changestamp' : 'mcjj 7/12/2024 21:26' +} +GMTETileSelector >> mouseDown: evt [ + + evt redButtonPressed + ifTrue: [self model selectTile: self] + ifFalse: [self model backgroundTile: self] +]