Flag modding

Version

This article has been verified for the current PC version (3.1) of the game.

## Editing empire flags

In a new game screen, using graphical interface, editing flag of an empire is easy, but to code this flag in .txt files – using default Paradox flag emblems, patterns and colors – you need to know code names for all those elements. This guide should make this task considerably easier.

### Code from 00\_prescripted\_countries.txt

```
 empire\_flag = {
 	icon = {
 		category = "spherical"
 		file = "flag\_spherical\_21.dds"
 	}
 	background = {
 		category = "backgrounds"
 		file = "pattern\_01.dds"
 	}
 	colors = {
 		"turquoise"
 		"indigo"
 		"null"
 		"null"
 	}
 }

```

That’s the question: how are you supposed to know what emblems is `"spherical_21"` or, if you are like the creator of this guide, how turquoise color looks like? This page lists code for all those things.

All following flag symbols are encoded as `"flag_category_number.dds"` except Domination emblems which are simply coded as `"domination_number.dds"`.

### Flag colors

An actual list of colours can be found at: `./flags/colors.txt`
### Flag backgrounds and emblems

Flag backgroundsEmblems – Blocky categoryEmblems – Human categoryEmblems – Ornate categoryEmblems – Pirate categoryEmblems – Pointy categoryEmblems – Spherical categoryEmblems – Zoological categoryEmblems – Domination category
## Creating your own emblems

Emblems are simply squared images that the game sticks on top of a background to create a flag.

For each emblem 3 texture files in the Direct Draw Texture format (.dds) are required: a default, medium-sized one; a big one, usually white and displayed only on the galactic map; and a small one displayed next to units.

It is recommended to add the emblems using mods instead of placing them directly in the game folder to avoid any possible problems. More information on how to create them and where are they can be found are under Mods.

The textures should follow these specifications:

* All textures must be located in a subfolder of `<mod_root>\flags\`
* All three textures should have the same file name, for example `emblem.dds`
* The default texture should have a size of 128x128 pixels and should be in the folder `<mod_root>\flags\<folder>\`
* The map texture should have a size of 256x256 pixels and should be in the folder `<mod_root>\flags\<folder>\map\`
* The small texture should have a size of 24x24 pixels and should be in the folder `<mod_root>\flags\<folder>\small\`

There are a myriad of tools that can help you creating the textures for the emblems, among which there is:

* GIMP: useful for editing images, as well as saving them in .dds format.
* Paint.NET: simple image editor with .dds format compatibility.
* Krita: useful for editing images.
* Inkscape: useful for editing vector images.
* ImageMagick: useful for processing and converting images to .dds in batches.
* Adobe Photoshop: useful for editing images, as well as saving them in .dds format (with the NVIDIA plugin).
* Microsoft Visual Studio: useful for saving images in .dds.

### Guide

* Create a mod using the Stellaris Launcher.
* Create a folder named 'flags’ in the root folder, and a subfolder that you can name however you want in it, this folder is where all the textures files will be placed.
* Create 'usage.txt’ in the subfolder with the following contents, it will prevent AI empires from using the emblem in their flags (savegames will still work once you remove the mod):

```
random = no
show_in_designer = yes

```

* Create a folder named `'localisation'` in the root folder. You must place there localisation (.yml) files, otherwise the category you made for the emblem won't have a name! This is an example for the English translation, the name after `'FLAG_CATEGORY'` must match the name of the new folder you created under flags and make sure to save your localisation file with "UTF-8 with BOM" encoding otherwise it won't work:

```
l_english:
  FLAG_CATEGORY_new_flags:0 "New Flags!"

```

* Create your emblem! Remember that it should be a square image and that it is best to create out your image with a transparent backdrop.
* Now you need to generate the 3 texture files out of the image: the medium, large and small ones. Remember that they have to be .dds files and have to have determinate size each one. You can use GIMP with the .dds plugin, Photoshop with the NVIDIA plugin, ImageMagick, Paint.NET with the .dds plugin and others to convert your images to textures.
* Now place the medium texture in the folder you created under `flags`, create the folders `map` and `small` and place the big and small textures in each one, respectively, the folder structure should be like this now:

```
new_mod/
├─── flags
│	└─── new_flags
│		├─── emblem.dds
│		├─── usage.txt
│		├─── map
│		│	└─── emblem.dds
│		└─── small
│			└─── emblem.dds
└─── localisation
	├─── new_mod_l_braz_por.yml
	├─── new_mod_l_english.yml
	├─── new_mod_l_french.yml
	├─── new_mod_l_german.yml
	├─── new_mod_l_polish.yml
	├─── new_mod_l_russian.yml
	└─── new_mod_l_spanish.yml
5 directories, 11 files

```

Special considerations:

* Texture compression: Using DXT1 or DXT5 compression may introduce artifacts in the textures, use uncompressed textures (ARGB 8888) if this happens.
* Remember that the game recolors your image when showing it. Some colors may be distorted when you view your flags from the galaxy map.

### ImageMagick Helper Script

This batch script (.bat, Windows only) can help you generate the required textures to make emblems, it needs to have ImageMagick installed and its folder the PATH variable (enabled by default during install).

The script expects the images in PNG format under the folder "source", then creates the folder "textures", resizes the images and stores all three types of textures in the correct subfolders. Additionally it also whitens the map textures so you don't have to.

For creating the small emblems, the scripts uses blurring parameters picked for blurring a 512x512 image, pick one according to the size of yours.

```
	FOR %%a in (source\*.png) DO (
		::default emblems
		magick convert  "%%a" -resize 128x128 ^
 	-define dds:compression=dxt5 -define dds:cluster-fit=true -define dds:weight-by-alpha=true "textures\%%~na.dds"
		::small emblems
		magick convert "%%a" -fill black -colorize 100%% -background black -alpha background -channel RGBA -blur 32x32 -level 0,97%% ^
 	"%%a" -composite ^
 	-resize 24x24 ^
 	-define dds:compression=none ^
 	"textures\small\%%~na.dds"
		::map emblems
		magick convert  "%%a" -fill white -colorize 100%% ^
 	-resize 256x256 ^
 	-define dds:compression=dxt5 -define dds:cluster-fit=true -define dds:weight-by-alpha=true ^
 	"textures\map\%%~na.dds"
	)

```

* More complex scripts: https://gitlab.com/unduthegun/stellaris-emblem-lab/ (by Pau Ruiz Safont aka Undu)
* Web implementation (of this): https://9kenm.github.io/stellaris-emblem-maker/ (by MrKen)

## References

1. ↑ Custom Flag Example

**Modding**