• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

CustomGameOptions mod for Modders (including source code)

w00kien00kie

New member
This is a new mod aimed at modders so they can easily add new Custom Game Options to their overhauls without having to write any C# code (well very little anyway). The game options are just added via a standard 7days XML patch file and then the variables can be used in any other Harmony patch (this is the only C# you need to do). 

All you need to do to use is download the Compiled mod, add your own <gameoptions .../> xml to the windows.xml and then use the variables anywhere in your Harmony patches. 

Compiled Mod
https://gitlab.com/wookienookie/customgameoptionsmod/-/archive/main/customgameoptionsmod-main.zip

Source Code (if you want to poke around the actual code, this is not need to run the mod)

https://gitlab.com/wookienookie/CustomGameOptions
 

Example of Custom Options in game : 

image.png

I've included an example windows.xml config patch in /XUi_Menu/windows.xml

NOTE : The 'name' parameter in the <gameoption> xml MUST start with the work 'Custom' otherwise the code will treat it as a normal vanilla gameoption and everything will error!

(Highly advise to set a value for the new xml parameter default_value="" for each <gameoption> you add )

image.png

You will need to add Localization as well, ive included a Localisation.txt example but you dont have to use that location for your own text changes. 
Note : Localization in <GameOptions/> is a bit odd but not hard, ill write some notes up with examples later.

 

There is also an example of how to use the variables within your Harmony patches (commented out by default) in the source code : 

image.png

I have tested this in SP, MP and on a dedicated server BUT this is still a new approach and i am expecting some issues. Please thoroughly test within your own mods/overhauls. Any problems let me know.

This mod is just using standard C# code and supported Harmony patches (i.e. doesnt need BepInEx).

Im sure ive forgotten to add all the notes i needed to so will update this first post as and when i remember what ive missed. 
 

Wookie Nookie

 
Last edited by a moderator:
Ok so how would a non programmer like me use this. Let's say I want an option to make it rain all of the time.

...I get that your code does the UI stuff for me but I'd still have to write the bit that makes it rain, and reference your setting, right?

So in a more realistic scenario, I could use this to turn mods on and off, right? 

If the latter is the case, can you write a sample code that does this, then we can just add the modfolder name to it or something?

 
As you said, this will need some code to actually use the variables, hence why it's more aimed at modders.

Turning on and off mods is something I've thought about doing in the past, we may be able to use this approach to do this now. I'll have a think about it

 
Ok so how would a non programmer like me use this. Let's say I want an option to make it rain all of the time.

...I get that your code does the UI stuff for me but I'd still have to write the bit that makes it rain, and reference your setting, right?

So in a more realistic scenario, I could use this to turn mods on and off, right? 

If the latter is the case, can you write a sample code that does this, then we can just add the modfolder name to it or something?
As you said, this will need some code to actually use the variables, hence why it's more aimed at modders.

Turning on and off mods is something I've thought about doing in the past, we may be able to use this approach to do this now. I'll have a think about it
A modlet, that can enable/disable other modlets and load modlets from your custom "mods" folders, already exists. Link

 
Last edited by a moderator:
Back
Top