Jump to content

CustomGameOptions mod for Modders (including source code)


w00kien00kie

Recommended Posts

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.thumb.png.c2c370e12bc8f8d670bee06a00450e99.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.thumb.png.eef742d9b15021a5a6a1a61251666502.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.1110e6f7d52b874d2fe19cadec9bb2ea.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

Edited by w00kien00kie (see edit history)
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

21 hours ago, Guppycur said:

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?

21 hours ago, w00kien00kie said:

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

Edited by ntaklive (see edit history)
Link to comment
Share on other sites

  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...