Jump to content

Species_Classes and Portraits text file generator 1.0.8


3 Screenshots

About This File

What does it do:

I made this file so I could add species to Vanilla Framework and have them 'just work'.
After looking at the policies and species_classes files, I was deterred.

 

So this program was made to look at a series of images, organized by file structure, and then create the required species_classes and portraits files automatically.

It is also written in python (with comments) and should be adjustable to anyone's file structure.

Thus, you can collect the images you like and have them show up in game without making/changing the species_classes and portraits files.

 

Setup:
So this script was made for the naming convention in Vanilla Framework, but can work with others.

 

The code takes a target path to a mod folder (YourModName for example) and then assumes that you have the path:

YourModName\gfx\models

and is this path is a series of folders that correspond to the playable races:
Models_VF.png.e4ce8d198a6cbf30aae4f234d3de680c.png

The code will auto ignore any folders it doens't recognise the name of.

 

It then checks for sub-folders to make species from:
image.png.1925c3f2ff359101d2d95fdffa50c4ea.png

The code will check inside in the Species Type (e.g. Aquatics) folder and ignore anything that isn't also a folder.

In this case it assumes that Aqua01, Aqua02, ... Aqua06 are all separate species. There is no naming convention requirement here, the species can be called anything!

 

Assuming the folder looks like this:
Aquatics_VF.png.daeff0c584d85193f455068dfe37a8a7.png

A list of .dds files are generated such that:

'01AquaF1.dds', '01AquaF10.dds', '01AquaF11.dds', '01AquaF12.dds', '01AquaF13.dds', '01AquaF14.dds', '01AquaF15.dds', '01AquaF2.dds',
'01AquaF3.dds', '01AquaF4.dds', '01AquaF5.dds', '01AquaF6.dds', '01AquaF7.dds', '01AquaF8.dds', '01AquaF9.dds'
are all female.
'01AquaH1.dds','01AquaH2.dds', '01AquaH3.dds' are all futa.
'01AquaM1.dds', '01AquaM2.dds' are all male.


The code then iterates through all the folders it recognises and using the sub-folders a sspecies it generates ALL of the portraits text files for playable races (and pre-sapients), and all the species classes for playable races (not pre-sapients).

 

It will go back to the folder YourModName and look for the two paths:

YourModName\portraits\portraits

YourModName\common\species_classes

If it doesn't find them, it will create them.

Portraits_VF.png.847fe6641f1a1657d5b52b8ddf450c8b.png

I've removed the _test in the picture, so it will now overwrite the Vanilla Framework (or others) if it has the same name.

 

Code:

 

File Names:


 

Spoiler

Inside each folder should be a list of .dds files.

There is also now a variable for file extension for the pictures:

pic_types='(dds|png)'

Change it if you want to support other types, like jpg for example:

pic_types='(dds|png|jpg)'

I personally don't know what Stellaris supports outside dds and png, so change at your own risk.

 

The code will then try to sort them into genders if the files are named a certain way.
The sorting is done by regular expression where each gender has a list of expressions that are acceptable.

The first is looking for the end of the file name to be (gender as M F or H)(some number).dds

The second is looking for female in ANY part of the file path.

 

Here is the search list:

# these are regular expression search terms.

names = [['[Ff][0-9]+\.'+pic_types+'$','(?i)female'],

         ['[Mm][0-9]+\.'+pic_types+'$','(?i)male'],

         ['[Hh][0-9]+\.'+pic_types+'$','(?i)futa','(?i)indeterminate']]

 

Add more or change them if you have different ways of storing your files.

 

WARNING:

-------------------------------------------------------------------------------------------------------------------

It will search for females, then males, then futa.

It will search through every item in each list stopping at the FIRST thing found.

So for example:

if your mod has females in the name, EVERY portrait will ALWAYS be female ONLY.

To stop this, just change the code by removing the '(?i)female' entry (similar for the other gender entries).

i.e.

names = [['[Ff][0-9]+\.'+pic_types+'$'],

         ['[Mm][0-9]+\.'+pic_types+'$'],

         ['[Hh][0-9]+\.'+pic_types+'$']]

-------------------------------------------------------------------------------------------------------------------

 

If it can't sort them, it will assume a mono-gendered set of portraits.

 

Leaders:

 

Spoiler

The new version now checks for leader classes in the FILE PATH. So sorting by folders, or file names should both work.
Looking at line 64 :

leader_names_search = {

        'ruler':['(?i)ruler'],

        'pop':['(?i)pop'],

        'scientist':['(?i)scientist'],

        'governor':['(?i)governor'],

        'general':['(?i)general'],

        'admiral':['(?i)admiral'],

        'envoy':['(?i)envoy'],

    }

There is a list of regular expressions that are used for each leader class to find them.

here '(?i)ruler' will search for the string 'ruler' and ignore case.

Adding to the list will add checks for that ruler.

i.e. changing it to:
        'ruler':['(?i)ruler','_r_'],

will cause the code to search first for the ruler word, then for underscore r underscore.

 

Look at the function

def leader_dict_sorter(leader_dict)

on line 315 and

def pic_to_leader(pic_list,name_search=leader_names_search)

on line 272 for details on how it searches.

 

This search occurs AFTER the gender search.

 

Sets that have no leader types detected will now produce smaller portrait files.

 

How to use:

 

Firstly you'll need python installed.
Later if I get to it I'll see if I can make it an executable or something.

But in this form it is safer as people can read it to see what it's doing.

 

Taken straight from the python file:

 

--- HOW TO RUN THE CODE ----
----------------------------
Assuming something like Linux, run in terminal:
python3 Stell_VanF.py --folderpath 'Some/Path/To/Paradox Interactive/Stellaris/mod/YourModName' --run_all True

 

Or Windows:
python3 Stell_VanF` 1_0_5.py --folderpath 'C:\Users\CHANGEYOURNAME\Documents\Paradox Interactive\Stellaris\mod\YourModName' --run_all True
 

There is a verbose flag that can be used.

i.e. python3 Stell_VanF.py --folderpath 'C:\Users\CHANGEYOURNAME\Documents\Paradox Interactive\Stellaris\mod\YourModName' --run_all True --verbose True

All command line flags:
python3 Stell_VanF.py --folderpath 'C:\Users\CHANGEYOURNAME\Documents\Paradox Interactive\Stellaris\mod\YourModName' --run_all True --verbose True --vanilla_framework True --block_base_species True

 

Just be prepared to have your screen flooded if you have many portrait files.

 

Or just run it in idle like I do ?

I should have explained more, my bad:
example code:

folderpath= r'C:\Users\CHANGEYOURNAME\Documents\Paradox Interactive\Stellaris\mod\YourModName'
run_the_lot(folderpath=folderpath,dospecies_class=False,block_base_species=False,vanilla_framework=True,verbose=False)

(values are set to the defaults in the above example, i.e. verbose is default set to false)

 

Here is step by step of what you need to to in IDLE:

Spoiler

First, Open a new IDLE window (i.e. just run idle) and then open the file from the file menu:

IDLE_1.png.7c092e70b4a85d071d9b3f267901ef3d.png

Select the version (probably latest and the only one you'd have):

IDLE_2.png.47e819e0d2a27323afa89df99cf55a23.png

When it's open, run the module:

IDLE_3.png.8d66eb6a59d24fc5a1faf7609bbade61.png

You're now able to execute all the functions yourself, and play with them if you like.
But in this next picture I have highlighted the last few lines of code in a red box in my python file.
These last line are what the command line is trying to execute if you use the command line.
To do what it's doing, just assign the path to Vanilla Framework (or another mod) to a variable (can be any name, but I'll use folder path), then use run_the_lot([Variable Name Here]).

NOTE:

You'll notice I have an r in front of the string path, this is because the windows path names are interpreted as escape commands. The r makes it a real string and ignores those commands. The r is not needed for Linux/Mac, but should have no effect if still included. (it is necessary on Windows tho).

Here's a picture:

IDLE_4.png.2d5dc72a0a44ac20cc4357cb83e01381.png


This should solve the problem.

If you want to see the inputs that the command line can understand (and where they are used in the code), they are the paser.add_argument lines near the top of the file.
 

As a side note:

Since you are using IDLE you can examine what each function is doing, which can be intimidating but fun!
Other than run_the_lot, all functions should be returning strings, lists, dictionaries or something else.
run_the_lot will try to write files to the computer, so messing with it can be annoying to clean up.
The rest of the funtions will at worst clutter your screen with text, which can easily be solved by opening a new window and starting again.

 

 

VIDEO!

I've added a video to the downloads with an example run on just pictures.

The file path inside the test mod is required. (e.g. YourModName\gfx\models\Aquatic\Aqua01\example1.dds)

 


----------------------------

 

I'll continue to post updates as I improve the script.
Feel free to use/modify this script, and to suggest changes if you like.

 

TL;DR:

-Putt all your species pictues (any name as .dds files) into sub-folders (any name e.g. Aqua01) for each set of pictures

-The sets of pictures need to be in a folders that corresponds to a playable races (e.g. Aquatic) (Species Type folders shown in the first figure by the red dashes.)

Species Type folders need to be here:

YourModName\gfx\models

 

(So for the example: YourModName\gfx\models\Aquatic\Aqua01\example1.dds )

 

run the code pointing to:

C:\Users\CHANGEYOURNAME\Documents\Paradox Interactive\Stellaris\mod\YourModName

 

Done! your species will show up in the game when you load YourModName!


I also generally recommend anyone to read a script before they use it.
 

 

Example 1: Making A Race From An Old Mod

 

Spoiler

Lets resurrect an old portraits mod:

 

I'll use Stellaris Sexy Xenos and more (SSX) 1.11.8 1.11.8 (4 june 2021)

 

  • Download the mod
  • I'm going to bring back the Egyptians (because they have male and female pics)
  • Looks like this:
Spoiler

 

 

image.png.1313175a5a10189fe49e5d7d831321dc.png

image.png.62e6128853ebabb96c97e090602fe12f.png

image.png.0354351eaaccc4051b33706179b6a7f4.png

 

  • Now to sort, I'm going to make a folder called female and a folder called male.
Spoiler

image.png.861692184392360b1d1073739922b6c3.png

  • Now I run the code
Spoiler

SCR_005.jpg.80a206b53e9ebc51db619a3815010869.jpg

 

SCR_001.thumb.jpg.1f5895e0428e3eaeac7d13f328f2388e.jpg

SCR_004.thumb.jpg.c6d61126766b73e7e4e76707dbaa4eb7.jpgSCR_003.thumb.jpg.861c1e724c952db37a929e4d515fdd30.jpg

SCR_002.thumb.jpg.d6c9ef534aa3a8528743795c6309e669.jpg

  • It works

 

 

ASPIRATIONS LIST:

 

  • Add non_VF mode, and possibly make that the default (currently has no actual effect to the end user, other than clutter in the files)
    • Not so hard... maybe
  • Tackle events
    • Probably very painful
  • Read current entries for species lists and portrait lists
    • time consuming and difficult to decide what to do in edge cases
  • GUI?
    • Would cost lots of time and only add a little functionality at the moment, but would make it more accessible to others.
  • Executable
    • No idea how hard, but guessing hard. Would make it accessible to non-python users

 

What's New in Version 1.0.5

Fixed two bugs:

  1. The code would actually pickup non image files and add them if they were in the folder
  2. The default image in portraits is now checked only once and not every gender, this prevents a bug when one gender had no leaders, but the others did

 

The names variable is now a list of lists (like the leaders) and will check against each.

Default behavior is now to check file names as it would for like Vanilla Framework, then look for 'Female','Male' ect. in the file path.

What's New in Version 1.0.6
 

Minor updates:
 

  1. Will now name species classes as VF did (with the _classes)
  2. Changed the logic it uses to determine gender. Has no effect on the end user, but the profile files (and the python file itself) are much smaller now.

 

What's New in Version 1.0.7

 

Minor update:
 
run_the_lot will now check the inputs it has received and tell you if it's going to fail, rather than the code failing somewhere random down the line. Hopefully making it easier to pick up typos and missing definitions,

What's New in Version 1.0.8

 

3 New additions:

-vanilla_framework flag to determine if event portraits should be written to the portraits files. These are hard coded so I'll need to update if VF gets updated. But good to turn off if you have a custom portrait set or if VF gets updated and this doesn't.

-More error flags for when folders are not found or ignored.

-block_base_species flag for generating 00_species_classes.txt and 01_base_species_classes.txt which will block the base species portraits from appearing in the game.

Edited by Goregath


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use