Files
OpenFrontIO/map-generator/README.md
T
Aaron Tidwell 2bfe245a72 Add format:map-generator command (#2563)
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
2025-12-09 19:46:13 -08:00

1.6 KiB

MapGenerator

This is a tool to generate map files for OpenFront.

Installation

  1. Install go https://go.dev/doc/install
  2. Install dependencies: go mod download
  3. Run the generator: go run .

Creating a new map

  1. Create a new folder in assets/maps/<map_name>
  2. Create image.png
  3. Create info.json with name and countries
  4. Add the map name in main.go
  5. Run the generator: go run .
  6. Find the output folder at ../resources/maps/<map_name>

Create image.png

  1. Download world map (warning very large file)
  2. Crop the file (recommend Gimp)
  • We recommend roughly 2 million pixels for performance reasons
  • Do not go over 4 million pixels.

Create info.json

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 .