Skip to content

Commit

Permalink
Fixes to the Tilemap Editor, introduced ReadMe button
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Wolf committed Nov 7, 2024
1 parent decb909 commit 199f1c1
Show file tree
Hide file tree
Showing 14 changed files with 220 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -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

137 changes: 137 additions & 0 deletions src/GameMecha-TileEditor.package/GMTEEditor.class/class/helpMessage.st
Original file line number Diff line number Diff line change
@@ -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.'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
startup
utility
startup
"Opens the editor with a startup wizard"

Expand Down
Original file line number Diff line number Diff line change
@@ -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
exportAsImage;
showHighlightingLayer
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exportMenu
aMenuSpec := builder pluggableMenuSpec new.

aMenuSpec
add: 'Tilemap'
add: 'Tilemap File'
target: self
selector: #exportAsMorph
argumentList: {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dev-api
getTileCoordinatesFrom: aPoint
"Returns the tile coordinates that correspond to a x-y-position"

^ self tilePosFromVirtual: aPoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dev-api
tileMapSize
"Returns the size of the TileMap in tiles"

^ self tileWidth @ self tileHeight
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dev-api
tileSize
"Returns the size of a single tile of the tilemap as a point"

^ self tileSizeWidth @ self tileSizeHeight
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -94,13 +97,15 @@
"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",
"tileMatrixStackBackground:" : "TW 6/22/2024 01:23",
"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",
Expand Down

0 comments on commit 199f1c1

Please sign in to comment.