From 199f1c130e091d9e253597ddac10b1f83a72ade9 Mon Sep 17 00:00:00 2001 From: Thomas Wolf <@dasd> Date: Thu, 7 Nov 2024 14:46:21 +0100 Subject: [PATCH] Fixes to the Tilemap Editor, introduced ReadMe button --- .../GMTEEditor.class/class/displayHelp.st | 21 +++ .../GMTEEditor.class/class/helpMessage.st | 137 ++++++++++++++++++ .../GMTEEditor.class/class/startup.st | 2 +- .../instance/exportAsImage.st | 10 +- .../instance/exportAsMorph.st | 13 +- .../GMTEEditor.class/instance/exportMenu.st | 2 +- .../GMTEEditor.class/instance/settingsMenu.st | 5 + .../GMTEEditor.class/methodProperties.json | 12 +- .../GMTETileMap.class/class/fromFileName..st | 10 ++ .../instance/atTileCoordinates..st | 5 + .../instance/getTileCoordinatesFrom..st | 5 + .../GMTETileMap.class/instance/tileMapSize.st | 5 + .../GMTETileMap.class/instance/tileSize.st | 5 + .../GMTETileMap.class/methodProperties.json | 5 + 14 files changed, 220 insertions(+), 17 deletions(-) create mode 100644 src/GameMecha-TileEditor.package/GMTEEditor.class/class/displayHelp.st create mode 100644 src/GameMecha-TileEditor.package/GMTEEditor.class/class/helpMessage.st create mode 100644 src/GameMecha-TileEditor.package/GMTETileMap.class/class/fromFileName..st create mode 100644 src/GameMecha-TileEditor.package/GMTETileMap.class/instance/atTileCoordinates..st create mode 100644 src/GameMecha-TileEditor.package/GMTETileMap.class/instance/getTileCoordinatesFrom..st create mode 100644 src/GameMecha-TileEditor.package/GMTETileMap.class/instance/tileMapSize.st create mode 100644 src/GameMecha-TileEditor.package/GMTETileMap.class/instance/tileSize.st diff --git a/src/GameMecha-TileEditor.package/GMTEEditor.class/class/displayHelp.st b/src/GameMecha-TileEditor.package/GMTEEditor.class/class/displayHelp.st new file mode 100644 index 00000000..e4c6a376 --- /dev/null +++ b/src/GameMecha-TileEditor.package/GMTEEditor.class/class/displayHelp.st @@ -0,0 +1,21 @@ +utility +displayHelp + "Shows a window with the ReadMe" + + |temp dialog| + + temp := PluggableTextMorphPlus new. + temp + setText: GMTEEditor helpMessage; + extent: RealEstateAgent scaleFactor * (1000 @ 400); + readOnly: true. + + dialog := DialogWindow new + title: 'ReadMe'; + addPaneMorph: temp; + createCancelButton: 'Close' translated value: false; + registerKeyboardShortcuts. + + dialog paneMorph extent: temp extent. + dialog getUserResponse + \ No newline at end of file diff --git a/src/GameMecha-TileEditor.package/GMTEEditor.class/class/helpMessage.st b/src/GameMecha-TileEditor.package/GMTEEditor.class/class/helpMessage.st new file mode 100644 index 00000000..f3dc83bf --- /dev/null +++ b/src/GameMecha-TileEditor.package/GMTEEditor.class/class/helpMessage.st @@ -0,0 +1,137 @@ +constants +helpMessage + + ^ '# GM - TileEditor +## Starting the editor +You can start the editor by running "GMTEEditor new". +> By running "GMTEEditor register" you can add the editor to the Apps menu. +## Menu functions +### Import +#### Importing a tile set +After providing a tile height in pixels you can select a tile set file that is automatically cut into tiles and loaded into the tile store. +#### Importing a tilemap +Import a previously exported tile map to keep working on it. +### Export +#### Export as tilemap +Export your current progress on the tilemap to a file. +> Can be reimported to continue working on it. +#### Export as PNG +Save the tilemap as a picture. +### Open in world + Opens the current tilemap morph to experiment with its current state. + ### Toggle grid + Toggles the visibility of the map grid. + ### Toggle Background + Toggles the dynamic filling of the tile maps background with the background tile. + > The background tile can be selected by right clicking a tile in the tile store. +### Reset View +Reset your view after zooming in/out or moving your view. + ## Tile Store + Select a tile by left clicking it. + Select a background tile by right clicking it. + ## Tilemap + Place tiles on the current layer by left clicking. + Remove tiles on the current layer by right clicking + > You can place / remove multiple tiles by holding left / right click and dragging your mouse over the desired tiles. + > You can rotate your currently selected tile by pressing ctrl/alt +r + + Zoom in/out by scrolling. + Hold shift, left click and drag your mouse to move your view. + ## Toolbar + ### Undo/Redo + Un-/Redo your last action, whether that is a layer action, a drawing/erasing action or resizing the tilemap. + ### Brushes + You can choose from a selection from brushes. + Additionally you can choose a radius which applies to the (default) brush and the line tool. + #### (default) Brush + Places tiles where you click and, depending on the radius, around it. + #### Line Tool + Click and drag to draw a line between start and end point. + A larger radius leads to a thicker line. + #### Fill tool + Click on a tile to replace all alike connected tiles with a new tile. + #### Rectangle Tool + Place a rectangle of tiles by clicking in the upper left corner and dragging to the lower right corner of the desired rectangle. When you release the mouse button the area is filled with your selected tile. + ## Inspector Tab + Allows you to adjust the tilemaps attributes. + ### Grid height / width + Adjusts the height / width of the tilemap. + ### Padding + The distance between the grid and the edge of the tilemap. + ## Layer Tab + ### Selecting layers + Select and deselect layers to manipulate them. + > You can select multiple layers by shift + clicking. + > Some layer actions only work if just one layer is selected. + ### Layer Actions + #### Add Layer + Adds a new layer in front of the other layers. + #### Move up / down + Moves the currently selected layer up / down by one. + #### Renaming + Allows you to choose a custom name for the currently selected layer. + #### Clearing + Clears all currently selected layers. + #### Blending + Blends all currently selected layers into one. + #### Deleting + Deletes all currently selected layers. + #### Toggling visibility + Shows / hides all currently selected layers. + ## Keyboard Shortcuts + There are keyboard shortcuts for quick access to the editor functions. + ### Menu Functions +|Function | Shortcut| +|-------------------------------|-----------------------------| +|Import Tilemap|`ctrl/alt + i` | +|Import Tileset|`ctrl/alt + o` | +|Export Tilemap|`ctrl/alt + s` | +|Toggle Grid|`ctrl/alt + g` | +|Toggle Background|`ctrl/alt + h` | +### Layer Functions +|Function | Shortcut| +|-------------------------------|-----------------------------| +|Add Layer|`ctrl/alt + a` | +|Rename Layer|`ctrl/alt + n` | +|Clear selected Layers|`ctrl/alt + c` | +|Blend selected Layers|`ctrl/alt + b` | +|Delete selected Layers|`ctrl/alt + x` | +|Toggle visibility of selected Layers|`ctrl/alt + v` | +### Tools +|Function | Shortcut| +|-------------------------------|-----------------------------| +|Undo|`ctrl/alt + z` | +|Redo|`ctrl/alt + y` | +|Rotate selected Tile|`ctrl/alt + r` | +|Select (default) brush|`alt + 1` | +|Select Line Tool|`alt + 2` | +|Select Fill Tool|`alt + 3` | +|Select Rectangle Tool|`alt + 4` | + ## Dev API + The tilemap offers an API for developement. + ### toFullScreen + Automatically rescales your tilemap to fill out the screen. + ### mapGridOnly + Reduces the tileMap to the grid and removes the dynamic background frame. + ### toggleVisualLayer + Toggles the visibility of the grid. + ### showVisualLayer / hideVisualLayer + Shows / hides the grid. + ### toForeground + Ensures that the tilemap morph is drawn in front oft the squeak UI. + ### toFullScreenMode + Enables fullscreen mode. + ### toggleBackgroundLayer + Toggles the dynamic filling of the maps background with the background tile. + ### deleteTiles: anIndexSet inLayer: aLayer + Delete the tiles specified by the indices in anIndexSet in the specified layer. + ### placeTiles: anIndexSet inLayer: aLayer ofClass: aTileClass withImage: anImage + Place tiles specified by the indices in anIndexSet in the specified layer with a provided image. The argument aTileClass allows to add custom tiles, which inherit from GMTETile. + ### placeTiles: anIndexSet inLayer: aLayer withImage: anImage + Place GMTETiles specified by the indices in anIndexSet in the specified layer with a provided image. + ## Using your tilemap for your game + The TileEditor offers class-side methods (GMTEEditor) which load your tilemap from a local file path / the Git Asset Browser without starting the TileEditor so you can use it in your game. + ### GMTEEditor getTileMapFromFilePath: `your local filepath` + Used to import a tilemap directly from a file. Returns a tilemap from a given local filepath, which should point to a .morph file previously exported from the TileEditor. + ### GMTEEditor getTileMapFromProjectName: `name of your project in Git Browser` withPath: `your filepath in Git Asset Browser` + Used to import a tilemap from the Git Asset Browser in Squeak. Returns a tilemap from the projectname and a relative filepath in the Asset Browser, which should point to a .morph file previously exported from the TileEditor.' \ No newline at end of file diff --git a/src/GameMecha-TileEditor.package/GMTEEditor.class/class/startup.st b/src/GameMecha-TileEditor.package/GMTEEditor.class/class/startup.st index 390a9605..2d2327d8 100644 --- a/src/GameMecha-TileEditor.package/GMTEEditor.class/class/startup.st +++ b/src/GameMecha-TileEditor.package/GMTEEditor.class/class/startup.st @@ -1,4 +1,4 @@ -startup +utility startup "Opens the editor with a startup wizard" diff --git a/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/exportAsImage.st b/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/exportAsImage.st index 38f2d0d0..c56016a8 100644 --- a/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/exportAsImage.st +++ b/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/exportAsImage.st @@ -1,9 +1,9 @@ -menu buttons +accessing exportAsImage "Exports the current tile map as a png" - - exportTilemap := self tileMap veryDeepCopy. - exportTilemap + + self tileMap hideHighlightingLayer; resetView; - exportAsImage \ No newline at end of file + exportAsImage; + showHighlightingLayer \ No newline at end of file diff --git a/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/exportAsMorph.st b/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/exportAsMorph.st index ffea6469..0efb7ca5 100644 --- a/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/exportAsMorph.st +++ b/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/exportAsMorph.st @@ -1,9 +1,12 @@ -menu buttons +accessing exportAsMorph - "Saves the current tileMap as a .morph file, which allows for reimporting" + "Saves the current tileMap as a .morph file (as EditorTileMap), which allows for reimporting" + | currentModel | - ((self tileMap veryDeepCopy) + currentModel := self tileMap model. + self tileMap model: nil; - resetView - ) saveOnFile. + resetView; + saveOnFile; + model: currentModel. self savedSinceModified: true \ No newline at end of file diff --git a/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/exportMenu.st b/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/exportMenu.st index 8dd178a4..9ded8775 100644 --- a/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/exportMenu.st +++ b/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/exportMenu.st @@ -7,7 +7,7 @@ exportMenu aMenuSpec := builder pluggableMenuSpec new. aMenuSpec - add: 'Tilemap' + add: 'Tilemap File' target: self selector: #exportAsMorph argumentList: {}; diff --git a/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/settingsMenu.st b/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/settingsMenu.st index 3961fa39..f6d1c850 100644 --- a/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/settingsMenu.st +++ b/src/GameMecha-TileEditor.package/GMTEEditor.class/instance/settingsMenu.st @@ -20,6 +20,11 @@ settingsMenu add: 'Reset View' target: self selector: #resetView + argumentList: {}; + + add: 'Please Help' + target: self class + selector: #displayHelp argumentList: {}. builder open: aMenuSpec \ No newline at end of file diff --git a/src/GameMecha-TileEditor.package/GMTEEditor.class/methodProperties.json b/src/GameMecha-TileEditor.package/GMTEEditor.class/methodProperties.json index 457f8917..bad4fe6c 100644 --- a/src/GameMecha-TileEditor.package/GMTEEditor.class/methodProperties.json +++ b/src/GameMecha-TileEditor.package/GMTEEditor.class/methodProperties.json @@ -1,5 +1,6 @@ { "class" : { + "displayHelp" : "TW 11/7/2024 14:45", "editorMinimumExtent" : "mcjj 7/12/2024 21:41", "getInputFieldSize" : "mcjj 7/12/2024 21:41", "getTileMapFromFileBinary:" : "mcjj 7/12/2024 21:41", @@ -9,6 +10,7 @@ "hLayoutFrame:ofN:" : "mcjj 7/12/2024 21:47", "hLayoutFrame:ofN:vSymmetric:" : "tw 7/11/2024 17:03", "hLayoutFrame:ofN:vUp:down:" : "mcjj 7/12/2024 21:45", + "helpMessage" : "TW 11/7/2024 14:29", "initialize" : "tw 7/12/2024 16:21", "maxBrushRadius" : "mcjj 7/12/2024 21:48", "maxNumberOfCommands" : "mcjj 7/12/2024 21:48", @@ -19,7 +21,7 @@ "privateGetEditorTileMapFromFilePath:" : "mcjj 7/12/2024 21:53", "register" : "mcjj 7/12/2024 21:53", "singleLayerActionNames" : "mcjj 7/12/2024 21:54", - "startup" : "mcjj 7/12/2024 21:57", + "startup" : "TW 11/7/2024 14:23", "startupMinimumExtent" : "mcjj 7/12/2024 21:56", "tileMapMaxGridSize" : "mcjj 7/12/2024 21:57", "tileMapMaxPaddingSize" : "mcjj 7/12/2024 21:57", @@ -66,9 +68,9 @@ "deselectTile" : "tw 7/12/2024 23:19", "disableSingleLayerButtons" : "tw 7/12/2024 22:36", "enableSingleLayerButtons" : "tw 7/12/2024 22:36", - "exportAsImage" : "tw 7/12/2024 23:21", - "exportAsMorph" : "tw 7/12/2024 23:10", - "exportMenu" : "tw 7/12/2024 23:10", + "exportAsImage" : "TW 11/7/2024 14:01", + "exportAsMorph" : "TW 11/7/2024 14:01", + "exportMenu" : "TW 11/7/2024 14:02", "filterEvent:for:" : "tw 7/12/2024 23:04", "getBrushRadius" : "tw 7/12/2024 21:58", "getBrushRadiusAsString" : "TW 7/9/2024 11:30", @@ -135,7 +137,7 @@ "setGridHeight:" : "tw 7/12/2024 23:38", "setGridWidth:" : "tw 7/12/2024 23:38", "setPadding:" : "tw 7/12/2024 23:38", - "settingsMenu" : "tw 7/12/2024 23:12", + "settingsMenu" : "TW 11/7/2024 14:12", "showConfirmationWindowOf:withDimensions:withTileSize:" : "Alex M 7/12/2024 23:41", "singleLayerSelected" : "tw 7/12/2024 23:09", "swapLayer:with:" : "tw 7/12/2024 23:10", diff --git a/src/GameMecha-TileEditor.package/GMTETileMap.class/class/fromFileName..st b/src/GameMecha-TileEditor.package/GMTETileMap.class/class/fromFileName..st new file mode 100644 index 00000000..1b116259 --- /dev/null +++ b/src/GameMecha-TileEditor.package/GMTETileMap.class/class/fromFileName..st @@ -0,0 +1,10 @@ +constants +fromFileName: fullName + "Imports a TileMap from a .morph file and optionally converts from EditorTileMap to a TileMap" + + | aFileStream tileMap | + aFileStream := (MultiByteBinaryOrTextStream with: ((FileStream readOnlyFileNamed: fullName) binary contentsOfEntireFile)) binary reset. + tileMap := aFileStream fileInObjectAndCode. + (tileMap class = GMTEEditorTileMap) + ifTrue: [tileMap := GMTETileMap newFromEditableTileMap: tileMap]. + ^ tileMap \ No newline at end of file diff --git a/src/GameMecha-TileEditor.package/GMTETileMap.class/instance/atTileCoordinates..st b/src/GameMecha-TileEditor.package/GMTETileMap.class/instance/atTileCoordinates..st new file mode 100644 index 00000000..efbef887 --- /dev/null +++ b/src/GameMecha-TileEditor.package/GMTETileMap.class/instance/atTileCoordinates..st @@ -0,0 +1,5 @@ +dev-api +atTileCoordinates: aPoint + "Returns the top left corner of a given tile in tile coordinates" + + ^ self correctedTilePositionMap: (self tilePosFromVirtual: aPoint) \ No newline at end of file diff --git a/src/GameMecha-TileEditor.package/GMTETileMap.class/instance/getTileCoordinatesFrom..st b/src/GameMecha-TileEditor.package/GMTETileMap.class/instance/getTileCoordinatesFrom..st new file mode 100644 index 00000000..9bfa6559 --- /dev/null +++ b/src/GameMecha-TileEditor.package/GMTETileMap.class/instance/getTileCoordinatesFrom..st @@ -0,0 +1,5 @@ +dev-api +getTileCoordinatesFrom: aPoint + "Returns the tile coordinates that correspond to a x-y-position" + + ^ self tilePosFromVirtual: aPoint \ No newline at end of file diff --git a/src/GameMecha-TileEditor.package/GMTETileMap.class/instance/tileMapSize.st b/src/GameMecha-TileEditor.package/GMTETileMap.class/instance/tileMapSize.st new file mode 100644 index 00000000..d2043256 --- /dev/null +++ b/src/GameMecha-TileEditor.package/GMTETileMap.class/instance/tileMapSize.st @@ -0,0 +1,5 @@ +dev-api +tileMapSize + "Returns the size of the TileMap in tiles" + + ^ self tileWidth @ self tileHeight \ No newline at end of file diff --git a/src/GameMecha-TileEditor.package/GMTETileMap.class/instance/tileSize.st b/src/GameMecha-TileEditor.package/GMTETileMap.class/instance/tileSize.st new file mode 100644 index 00000000..483d54e8 --- /dev/null +++ b/src/GameMecha-TileEditor.package/GMTETileMap.class/instance/tileSize.st @@ -0,0 +1,5 @@ +dev-api +tileSize + "Returns the size of a single tile of the tilemap as a point" + + ^ self tileSizeWidth @ self tileSizeHeight \ No newline at end of file diff --git a/src/GameMecha-TileEditor.package/GMTETileMap.class/methodProperties.json b/src/GameMecha-TileEditor.package/GMTETileMap.class/methodProperties.json index 2f089311..2fe701ef 100644 --- a/src/GameMecha-TileEditor.package/GMTETileMap.class/methodProperties.json +++ b/src/GameMecha-TileEditor.package/GMTETileMap.class/methodProperties.json @@ -1,6 +1,7 @@ { "class" : { "foregroundMorphicLayerNumber" : "Ivo Zilkenat 7/12/2024 23:44", + "fromFileName:" : "TW 11/7/2024 14:03", "maxLayers" : "Ivo Zilkenat 7/12/2024 23:44", "newFromEditableTileMap:" : "mcjj 7/12/2024 23:10", "tileWidth:tileHeight:padding:sizeRatio:" : "jj 6/22/2024 16:12", @@ -9,6 +10,7 @@ "absPointToViewCenter:" : "Ivo Zilkenat 7/12/2024 23:27", "absPointToViewFraction:" : "Ivo Zilkenat 7/12/2024 23:28", "areDimensionsSet" : "Ivo Zilkenat 7/12/2024 23:31", + "atTileCoordinates:" : "TW 11/7/2024 14:04", "backgroundTiles" : "Ivo Zilkenat 6/19/2024 22:28", "backgroundTiles:" : "jj 6/24/2024 11:10", "basicBackgroundTiles:" : "Ivo Zilkenat 6/22/2024 01:21", @@ -41,6 +43,7 @@ "generateTileAtPos:withExtent:withType:" : "Ivo Zilkenat 7/12/2024 23:30", "generateTileAtlayer:x:y:stack:tileType:" : "Ivo Zilkenat 6/24/2024 11:25", "generateTileAtlayer:x:y:stack:tileType:posCorrectionBlock:" : "Ivo Zilkenat 7/12/2024 23:36", + "getTileCoordinatesFrom:" : "TW 11/7/2024 14:05", "getTileFromLayer:x:y:" : "jj 6/22/2024 16:13", "getTileFromLayer:x:y:stack:" : "jj 6/22/2024 16:13", "handlesMouseDown:" : "Ivo Zilkenat 7/12/2024 20:18", @@ -94,6 +97,7 @@ "tileHeight" : "Ivo Zilkenat 5/19/2024 15:57", "tileHeight:" : "TW 6/22/2024 01:23", "tileIndexFromPosition:" : "Ivo Zilkenat 7/12/2024 23:31", + "tileMapSize" : "TW 11/7/2024 14:05", "tileMatrixStack" : "Ivo Zilkenat 5/27/2024 22:03", "tileMatrixStack:" : "TW 6/22/2024 01:23", "tileMatrixStackBackground" : "Ivo Zilkenat 6/19/2024 21:43", @@ -101,6 +105,7 @@ "tileMatrixStackHighlighting" : "Ivo Zilkenat 5/27/2024 22:20", "tileMatrixStackHighlighting:" : "TW 6/22/2024 01:23", "tilePosFromVirtual:" : "Ivo Zilkenat 6/24/2024 11:15", + "tileSize" : "TW 11/7/2024 14:05", "tileSizeHeight" : "Ivo Zilkenat 5/19/2024 16:09", "tileSizeHeight:" : "TW 6/22/2024 01:23", "tileSizeRatio" : "Ivo Zilkenat 5/19/2024 16:34",