Playing with the Settings page

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

jh1

New Member
Jul 21, 2004
38
0
0
Just wondering, where is the page stored for Game Settings? (The page with with Goal Score, Time Limit, etc.) I have modified the audio and visual pages (GUI2K4/UT2K4Tab_AudioSettings and UT2K4Tab_DetailSettings) with success, but cannot find code to build off of for said page.

All I basically want to do is to strip the Goal Score and Time Limit into one slimmed down page. Any help is much appreciated
 

jh1

New Member
Jul 21, 2004
38
0
0
One of the problems I'm having is that I'm not reading off the INI properly i think to load my goal score....Here's some code snippets, I'm not exactly sure why it isn't reading the value

Code:
Begin Object Class=HMenuNumericEdit Name=NEScore
		WinWidth=0.200000
		WinHeight=0.0350000
		WinLeft=0.745
		OnCreateComponent=NEScore.InternalOnCreateComponent
         IniOption="@Internal"
         IniDefault="1000"
         Hint="Final Score"
           OnChange=HSettingsPageProduction.InternalOnChange
         OnLoadINI=HSettingsPageProduction.InternalOnLoadINI
        WinTop = 0.39
        TabOrder = 1
        MinValue = 0
        MaxValue = 10000
        Step = 1
    End Object
    NE_Score=HMenuNumericEdit'HBPackages.HBSettingsPageProduction.NEScore'

...

function InternalOnLoadINI(GUIComponent Sender, string s)
{
	local int i;
	local PlayerController PC;
	local bool bIsWin32;
	PC = PlayerOwner();

	switch (Sender)
	{

	
	case NE_Score:
		fScore = float(PC.ConsoleCommand("get ini:HPackages.MyMod.GoalScore"));
		NE_Score.SetComponentValue(fScore,true);
		break;

...

ini file in my mod/system folder

[HPackages.MyMod]
NetWait=5
bForceRespawn=False
bAdjustSkill=False
bAllowTaunts=True
bAllowTrans=False
SpawnProtectionTime=2.000000
LateEntryLives=1
LoginMenuClass=GUI2K4.UT2K4PlayerLoginMenu
bAllowPrivateChat=True
bWeaponStay=True
bAllowWeaponThrowing=True
ResetTimeDelay=0
GoalScore=25
MaxLives=0
TimeLimit=20

It's always just loading to zero, and I don't know why...
 

Bonehed316

New Member
Oct 15, 2001
208
0
0
41
Florida
Visit site
I bet its your console command. First off, you might not even need a console command, and if you dont, you shouldnt use one.

But the console command works like this: "get ini:MyPackage.MyClass VariableName" Note the space.

But if you can, I bet you dont need to use a console command if you just need the default value for the class. You can simply use class'MyPackage.MyClass'.default.VariableName instead to get the result, and you can set it the same way (just switch the left and right in the statement). After you set the variable, you must save it using StaticSaveConfig(). There are examples of this in the menus already.
 

[SAS]Solid Snake

New Member
Jun 7, 2002
2,633
0
0
40
New Zealand
www.digitalconfectioners.com
Well, what you say is somewhat correct but it isn't for some other cases. Console commands should be freely used when they are required such as getting the binds of a key or setting the resolution.

However, for the above situation what Bonehed316 has suggested is probably the best method. However, the use of StaticSaveConfig() is incorrect.

StaticSaveConfig() saves the default value that you specified in the script, thus is used for returning values to their default properties. Thus the more appropriate function you want to use is just SaveConfig().

Here is more on dealing with INI's and configs,
http://wiki.beyondunreal.com/wiki/Config_Vars_And_.Ini_Files
 

Bonehed316

New Member
Oct 15, 2001
208
0
0
41
Florida
Visit site
Well, the menu's all use StaticSaveConfig() because you cant call SaveConfig() when you dont have an actual OBJECT reference. So since there is no object reference, you reference the CLASS, and set the DEFAULT values (which is why you use StaticSaveConfig) for the CLASS, then next time the class is spawned it will have the updated value. I assume you wouldn't want to change GoalScore in the middle of the game.

This is how UT2004 menus work. The only time they use console commands for menus is mostly for variables when you want the value be updated NOW, and you dont have an object reference (like texture detail and so forth).

StaticSaveConfig() does not return variables to their defaults, it SAVES their defaults to the ini file. ResetConfig is what returns them to their default defaults (specified in the script, or the initial value of the datatype if not specified in the script).
 

Bonehed316

New Member
Oct 15, 2001
208
0
0
41
Florida
Visit site
And if that's not good enough, here:

UT2K4Tab_GameSettings.uc
Code:
function SaveSettings()
{
	...

	if ( bSpeechRec != bool(PC.ConsoleCommand("get ini:Engine.Engine.ViewportManager UseSpeechRecognition")) )
    	PC.ConsoleCommand("set ini:Engine.Engine.ViewportManager UseSpeechRecognition"@bSpeechRec);

	...
	
	if (PC.Pawn != None)
	{

		PC.Pawn.bWeaponBob = bBob;
		PC.Pawn.SaveConfig();
	}
	else if (class'Engine.Pawn'.default.bWeaponBob != bBob)
	{
		class'Engine.Pawn'.default.bWeaponBob = bBob;
		class'Engine.Pawn'.static.StaticSaveConfig();
	}

	...
}

function ResetClicked()
{
	...

	class'Engine.Pawn'.static.ResetConfig("bWeaponBob");

	...
}

As you can plainly see, when there is an object reference, they set the value and call SaveConfig(), and when there is no reference they set the default value and call StaticSaveConfig(), unless they need the setting to be applied NOW for which they use console commands, and when you hit the "Defaults" button, it calls ResetConfig().

The difference between returning variables to their defaults and saving their defaults is profound, and essential when dealing with menu's, which rarely ever have object references. This is also why the GUI2K4 package comes so far down on the EditPackages list, it needs class references to be able to set the values coming from the menus.
 

[SAS]Solid Snake

New Member
Jun 7, 2002
2,633
0
0
40
New Zealand
www.digitalconfectioners.com
The only time they use console commands for menus is mostly for variables when you want the value be updated NOW, and you dont have an object reference.
I disagree. Unreal uses console commands to retrieve other information or to do other types of functions that are not normally presented within script. For example, how do you propose you retrieve the bind key information (from xUser.ini) without the use of console? How do you propose you set the resolution of the game and also check if the resolutions are able to be used?

There are many ways to do one thing, and it is dependent on the situation. It appears from the above code both StaticSaveConfig() and SaveConfig() are applied, since both are somewhat doing the same thing.

StaticSaveConfig() does not return variables to their defaults, it SAVES their defaults to the ini file.
Say for example you were using an instance of an object and you changed its variable. You could then save the variable into the ini file, which the ini would save the value of the instanced variable. The next time the variable is looked up again, it will read the altered instance variable. If you then just did StaticSaveConfig(), it will then write the default value to the ini, thus returning the variable to their designated default. It is all dependent on how you use it.

ResetConfig is what returns them to their default defaults (specified in the script, or the initial value of the datatype if not specified in the script).
Are you sure? Last time I checked, this returned values to what was saved in the ini. However, that is also dependent. If certain conditions are met, a ClearConfig() like function is used instead.
 
Last edited:

Bonehed316

New Member
Oct 15, 2001
208
0
0
41
Florida
Visit site
Unreal uses console commands for keybinds because there is no other way to get them from the menus, there is no object reference, and plus its just a lot easier. And I never said console commands are bad, I merely stated that you shouldnt use them unless you need to (when there is no object reference). You agreed with me, so why are you still harping on it?


As for StaticSaveConfig(), I know it depends on how you use it, thats why I am correcting you for correcting me. StaticSaveConfig() does not save the values specified in the script, it saves the defaults (which are specified in the scripts normally), but if you modify the defaults at runtime and call StaticSaveConfig(), it saves the modified defaults, not the values defined in the script, so your statement is inaccurate, and the differences are very important.

ResetConfig() resets the value to the value defined in the script (even if you change the defaults at runtime), and yes I'm sure because this is how the menus work, they rely on this fact in order to work. If it returned to the value saved in the ini file, hitting the "Defaults" button on the menus wouldnt reset the values to the defaults (the values specified in the script defaults) after they have been changed and saved to the ini, effectively making the button useless.

There is a ClearConfig() function that works exactly like ResetConfig(), but I'm not sure exactly what it does, as I have never used it.
 

[SAS]Solid Snake

New Member
Jun 7, 2002
2,633
0
0
40
New Zealand
www.digitalconfectioners.com
The only time they use console commands for menus is mostly for variables when you want the value be updated NOW, and you dont have an object reference (like texture detail and so forth).
This statement itself is incorrect. Certain variables aren't accessible by script at all (Such as finding out the rendering device) so whether or not you have an instance reference doesn't matter at all, and is actually out of the scope of this area.

StaticSaveConfig() saves the default value that you specified in the script, thus is used for returning values to their default properties. Thus the more appropriate function you want to use is just SaveConfig().
I fail to see how my explanation on the use of StaticSaveConfig() is incorrect. StaticSaveConfig saves the default value of the class/object. If you change the default and then save it using StaticSaveConfig, how is that any different to changing the variable for that instance and then saving it? Actually, if you change the default value within run time, it does actually alter the script for the level instance. Thus any instance of the class spawned afterwards will also reflect that change, not because it is a config variable but because you actually changed the class default variable value. This is seen with nonconfig variables.

Most of the menus from what I have seen appear to store a temporary value for the buttons settings (with some exceptions) and are saved later on (when the AcceptClicked() function is called). Thus the mechanism you proposed doesn't seem to add up, as your claiming that when the button is altered the ini value is also altered as well. As always there are a few exceptions. Some GUI options do actually want to save their settings as soon as they are applied and call the SaveSettings() function, but not all do.

ResetConfig and ClearConfig do actually differ in some respects. If you feel the Wiki is provided incorrect information regarding ResetConfig and ClearConfig, do change it, otherwise the mistake will continue to be incorrectly referenced as I may have done.
 

Bonehed316

New Member
Oct 15, 2001
208
0
0
41
Florida
Visit site
I gave the main use for console commands in the menus, not all of them. I am aware the keybinds can not be changed through any other method, nor can video resolution, color depth, and several other properties. The same goes for disconnecting to the menu, it is almost always a console comand to disconnect from the match.

Your statement was inaccurate because you said that my implementation of StaticSaveConfig() would be incorrect, which it is not. If you will take a gander through the settings menus, you will see that they use StaticSaveConfig() always when they are trying to modify a script level variable without an actual reference to the object. SaveConfig() wont work without an object to call it on. You can do as you wish and check for a reference to it if you want, but then if you are able to access the menu midgame, you will be changing the GaolScore in the middle of the game, which is pretty silly if you ask me. Thats just a personal preference, but I dont think it's fair, and it might end up breaking things. Therefor, the best way to do it is to modify the default value for the class and StaticSaveConfig() so that from now on when the class is spawned it will have and load the correct value.

Most of the menus do have a temporary variable for each value, which is loaded when the menu opens and maintained until you close the menu some way. The menus are set up to allow an "Apply" button, but this was not kept for some reason, probably because it had to be pressed (in the implementation in the existing code) for each page before you switched tabs or the values would be lost. Therefor, when the menu is closed the temp values are saved, and not before then. Infact, SaveSettings() is called when the menu is closed, unless the menu was cancelled. Some variables, like resolution and others, are applied as soon as the option is changed in the menu.

But as I said, I am not sure what ClearConfig() does, except that it accepts a string for a variable name just like ResetConfig(), but I know that ResetConfig() resets the variable to the value given in the scripts, otherwise the "Defaults" button would not actually reset values to their defaults, but to the last saved value, which is just silly.
 

[SAS]Solid Snake

New Member
Jun 7, 2002
2,633
0
0
40
New Zealand
www.digitalconfectioners.com
I misunderstood the original statement.

After you set the variable, you must save it using StaticSaveConfig().
I must have thought that you meant the instance variable and not the default. The connection between the first sentence and the last sentence did not 'click' to me. My apologies.

Walking towards Uni made me rethink this thread. I was too rash on my decision in the first post. I admit to the inaccuracy of that post. My apologies.
 
Last edited:

jh1

New Member
Jul 21, 2004
38
0
0
Thanks for all of your help, it has been really useful, both of you. I'm off to try these things now, thanks again.