CtrlCfg.gph : Apply control=config items by code

Documentation, usage tips and configuration guides for Titan Two scripts and bytecodes published by the community users.

CtrlCfg.gph : Apply control=config items by code

Postby Scachi » Sat Dec 29, 2018 5:12 pm

As the Interactive Configuration supports "One Click Presets" for quite some time now I wanted to be able to reuse the same config item= string format to apply the settings defined in the item by code too.

I am using this technique in my "The Division rev2 Data" preset companion script already and have now created a header file for easier usage.

For a working example download the "CtrlCfg_Example" from the Online Resource.

Usage:
Download the Headerfile "CtrlCfg.gph" from the Online Resource.

Place this file into the same directory where your script file is.
Add this line to your script:
#include "CtrlCfg.gph"

Basic (not complete/non working) example of an Interactive Configuration control=config entry to show the syntax of an item from a config control:
Code: Select all
 
/*
[Presets]
shortdesc = "Presets"
control = config
item = All Yes: 0101000A
item = All No: 00000000
item = Yes/No: 0100000A
item = No/Yes: 00010000
item = First Yes: #00:01
item = Second No: #01:00
item = Third Max: #02:2710
*/


If you want to apply item = All Yes: 0101000A , all you need to do is calling the function like this:
Code: Select all
CtrlCfgSet("0101000A");

This will apply the settings and reload the scripts slot.

Or you can put all items into a single array and load a specific entry like this:
Code: Select all
char *Presets[] = {
"0101000A",  // item = All Yes:   // 0
"00000000",  // item = All No:    // 1
"0100000A",  // item = Yes/No:    // 2
"00010000",  // item = No/Yes:    // 3
"#00:01",    // item = First Yes: // 4
"#01:00",    // item = Second No: // 5
"#02:2710",  // item = Third Max: // 6
};
 
 
CtrlCfgSet(Presets[1]); // <- this line would be used by your script to load item All No: // 1
 

This will apply the settings and reload the scripts slot.

You can disable the automatic save and reload by adding more arguments to the function call:
Code: Select all
CtrlCfgSet("#00:01",TRUE); // this disables pmem_save() and disables scripts slot reload
CtrlCfgSet("#00:01",FALSE,TRUE); // this does pmem_save() but NOT the script reload


For a working example download the "CtrlCfg_Example" from the Online Resource.

For an easy way to create the config=control item strings you can use the IC-Bytetable tool.
For an example go to this post and scroll it a bit down to the section "Example : Create Interactive Configuration : One Click presets"

You can also use the small "bar with arrow" like icon (left one, shows "Copy Configuration" on mouse hover) in the title bar of the "Interactive Configuration" in GTuner IV and remove the leading "GIVICFG:" part.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: CtrlCfg.gph : Apply control=config items by code

Postby UK_Wildcats » Sun Aug 25, 2019 3:47 pm

Thank you for your help with my checkbox bit offset. I have been thinking more about the one click and being able to capture you settings. I know that users can drag while holding CTRL to maintain their settings. I was just wondering if here was a way to setup user's ability to have their own configuration without having to modify the code.

For example, the user creates a file with the GIVICFG configuration stored. The script/gamepack would then be able to read that file to get the data for a one click configuration.

Is this even possible or worth the effort?
User avatar
UK_Wildcats
Brigadier General
Brigadier General
 
Posts: 2243
Joined: Thu Jan 08, 2015 6:53 pm

Re: CtrlCfg.gph : Apply control=config items by code

Postby Scachi » Sun Aug 25, 2019 3:55 pm

I don't know of a way to have that included in the script itself.

There is the copy and paste buttons for that. The user can create the configuration and save the string to some different location. When applying the settings to the same script again he can copy it to clipboard and use the paste button to apply them to the script. No coding required for that, just copy&paste.

In GTuner Air you can do that. Save the same script with different settings.
I am missing this option GTuner IV. You have to do the copy paste there or edit the script when it is shared as source.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: CtrlCfg.gph : Apply control=config items by code

Postby UK_Wildcats » Sun Aug 25, 2019 7:55 pm

I was thinking that there would be a way to save it to file on the SD card or a memory slot that the script could then read.
User avatar
UK_Wildcats
Brigadier General
Brigadier General
 
Posts: 2243
Joined: Thu Jan 08, 2015 6:53 pm

Re: CtrlCfg.gph : Apply control=config items by code

Postby Prototype » Tue Sep 03, 2019 7:45 am

That would be great to save and load some presets from the SD card.
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic! :smile0517:
User avatar
Prototype
Major General
Major General
 
Posts: 3251
Joined: Sun Dec 16, 2012 1:43 pm

Re: CtrlCfg.gph : Apply control=config items by code

Postby Scachi » Tue Sep 03, 2019 8:32 am

prototype wrote:That would be great to save and load some presets from the SD card.

I think we should discuss this all in a new topic.

UK_Wildcats_Fans wrote:..cut...
I was just wondering if here was a way to setup user's ability to have their own configuration without having to modify the code.

For example, the user creates a file with the GIVICFG configuration stored. The script/gamepack would then be able to read that file to get the data for a one click configuration.

One click configuration to use requires GTuner IV or GTuner Air.
Storing different settings for one script is exactly what GTuner Air allows to do in a bit different way. You have to download the same script again, configure and save it with a custom name.
This could be extended with some copy function to avoid having it to download again and edit option to select another input translator file from the online resource (in case of an update of the IT).

GTuner IV does not have this feature at the moment. I would like to see this feature in GTuner IV too.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: CtrlCfg.gph : Apply control=config items by code

Postby Prototype » Tue Sep 03, 2019 9:15 am

Scachi wrote:
prototype wrote:That would be great to save and load some presets from the SD card.

I think we should discuss this all in a new topic.

I'm agree that deserve a dedicated topic...
Scachi wrote:GTuner IV does not have this feature at the moment. I would like to see this feature in GTuner IV too.

...on Github's requests !
Scachi wrote:Storing different settings for one script is exactly what GTuner Air allows to do in a bit different way.

Yes like the copy/paste but by saving the settings to the SD card to reload them :joia:
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic! :smile0517:
User avatar
Prototype
Major General
Major General
 
Posts: 3251
Joined: Sun Dec 16, 2012 1:43 pm


Return to User's Script Documentation

Who is online

Users browsing this forum: No registered users and 29 guests