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
This commit is contained in:
Aaron Tidwell
2025-12-09 22:46:13 -05:00
committed by GitHub
parent 089d9ab402
commit 2bfe245a72
4 changed files with 159 additions and 124 deletions
+40 -5
View File
@@ -10,24 +10,59 @@ This is a tool to generate map files for OpenFront.
## Creating a new map
1. Create a new folder in assets/maps/<map_name>
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 generated/maps/<map_name>
6. Find the output folder at `../resources/maps/<map_name>`
## Create image.png
1. Download world map (warning very large file) https://drive.google.com/file/d/1W2oMPj1L5zWRyPhh8LfmnY3_kve-FBR2/view?usp=sharing
2. Crop the file (recommend Gimp), we recommend roughly 2 million pixels for performance reasons. Do not go over 4 million pixels.
1. [Download world map (warning very large file)](https://drive.google.com/file/d/1W2oMPj1L5zWRyPhh8LfmnY3_kve-FBR2/view?usp=sharing)
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
- Look at existing info.json for structure
- Use country codes found here: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
- [Use country codes found here](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
Example:
```json
{
"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**:
```bash
go fmt .
```