mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 18:16:38 +00:00
afe072f7d0
Resolves #2594 ## Description: - Added an optional `--maps` flag to the map-generator that allows passing a subset of maps to process. - Updated `README.md` w/ documentation for using the new flag Used the [go/flag](https://pkg.go.dev/flag) package. Running without the flag, or with no arguments matches existing behavior of processing all the maps defined in `main.go` `go run .` `go run . --maps=` New behavior is triggered to process a subset of maps by passing the `--maps` flag. Multiple maps are defined in a comma-separated list `go run . --maps=world,africa` Or a single map (useful for map development) `go run . --maps=fourislands` If an invalid map is passed, the process aborts and renders the error ```bash go run . --maps=invalidmapname Error generating terrain maps: map "invalidmapname" is not defined exit status 1 ``` By using the default flag package, we get `--help` for free: ```bash go run . --help Usage of <path-to-exe>/exe/map-generator: -maps string optional comma-separated list of maps to process. ex: --maps=world,eastasia,big_plains ``` I do not write GO often. Gemini contributed to this syntax. ## 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
79 lines
1.9 KiB
Markdown
79 lines
1.9 KiB
Markdown
# 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>`
|
|
|
|
By default, this will process all defined maps.
|
|
|
|
Use `--maps` to process a single map:
|
|
|
|
`go run . --maps=fourislands`
|
|
|
|
To process a subset of maps, pass a comma-separated list:
|
|
|
|
`go run . --maps=northamerica,world`
|
|
|
|
## 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.
|
|
|
|
## 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)
|
|
|
|
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 .
|
|
```
|