mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 09:50:43 +00:00
2bfe245a72
I'd like to submit some PRs in the future to add additional options for logging and debugging to the map-generator, however I don't want to introduce any code style changes in feature requests. ## Description: I noticed there was not any style guide or formatting being done for the go files, and went with the simplest built-in approach w/ [go fmt](https://go.dev/blog/gofmt) - Adds a `format:map-generator` npm command that will run the default `go fmt` in the `map-generator` directory to format the go code. - Runs the formatter and commits the changes to `main.go` and `map_generator.go` - Updates the `map-generator` README: - Updated location for generated files - Updated Links to use markdown links - Add `info.json` example - Add in-game enabling instructions with list of files to modify - Add development tools section with format command ## Please complete the following: - [X] I have added screenshots for all UI updates - [X] I process any text displayed to the user through translateText() and I've added it to the en.json file - [X] I have added relevant tests to the test directory - [X] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: tidwell
1.6 KiB
1.6 KiB
MapGenerator
This is a tool to generate map files for OpenFront.
Installation
- Install go https://go.dev/doc/install
- Install dependencies:
go mod download - Run the generator:
go run .
Creating a new map
- Create a new folder in
assets/maps/<map_name> - Create image.png
- Create info.json with name and countries
- Add the map name in main.go
- Run the generator:
go run . - Find the output folder at
../resources/maps/<map_name>
Create image.png
- Download world map (warning very large file)
- Crop the file (recommend Gimp)
- We recommend roughly 2 million pixels for performance reasons
- Do not go over 4 million pixels.
Create info.json
- Look at existing info.json for structure
- Use country codes found here
Example:
{
"name": "MySampleMap",
"nations": [
{
"coordinates": [396, 364],
"name": "United States",
"strength": 3,
"flag": "us"
}
]
}
To Enable In-Game
- Add a translation for the map name to
resources/lang/en.json - Add the MapDescription
src/client/components/Maps.ts - Add the numPlayersConfig
src/core/configuration/DefaultConfig.ts - Add the GameMapType
src/core/game/Game.ts - To add to the map playlist, modify
src/server/MapPlaylist.ts
Notes
- Islands smaller than 30 tiles (pixels) are automatically removed by the script.
- Bodies of water smaller than 200 tiles (pixels) are also removed.
🛠️ Development Tools
-
Format map-generator code:
go fmt .