Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Engine.SettingsProfile


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
/**
 * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
 */

/**
 * Used to copy data from any Settings class derivative, and store it in a .ini file;
 * Primarily used by the instant action and host game menus, to save game settings values
 */
Class SettingsProfile extends Object
	config(Game)
	perobjectconfig;


// A struct used to hold data retrieved from a databinding object property
struct DataBindingInfo
{
	var name Property;
	var string Value;
};

struct LocalizedSettingInfo
{
	var int ID;
	var int Value;
};


var config name				SettingsClassName;	// The class of the settings object which the current data was taken from

var config array<DataBindingInfo>	DataBindingProperties;	// A list of saved databinding object properties
var config array<LocalizedSettingInfo>	LocalizedSettings;	// A list of saved localized settings
var config array<DataBindingInfo>	PropertySettings;	// A list of saved property settings (uses 'DataBindingInfo' struct for convenience)


// Copies and saves the settings from the input object
function SaveSettings(Settings InObj)
{
	local array<Name> DBProperties;
	local int i, j;
	local DataBindingInfo CurProp;
	local LocalizedSettingInfo CurLocSetting;

	SettingsClassName = InObj.Class.Name;


	// First store all of the settings databinding properties
	DataBindingProperties.Length = 0;

	InObj.GetDataBindingProperties(DBProperties);

	for (i=0; i<DBProperties.Length; ++i)
	{
		if (InObj.GetDataBindingValue(DBProperties[i], CurProp.Value, True))
		{
			CurProp.Property = DBProperties[i];
			DataBindingProperties.AddItem(CurProp);
		}
	}


	// Then store the settings localized values
	LocalizedSettings.Length = 0;
	j = InObj.LocalizedSettings.Length;

	for (i=0; i<j; ++i)
	{
		// Skip settings that are still at their default values
		if (InObj.LocalizedSettings[i].ValueIndex == InObj.default.LocalizedSettings[i].ValueIndex)
			continue;


		CurLocSetting.ID = InObj.LocalizedSettings[i].ID;
		CurLocSetting.Value = InObj.LocalizedSettings[i].ValueIndex;

		LocalizedSettings.AddItem(CurLocSetting);
	}


	// Finally, store all of the settings properties
	PropertySettings.Length = 0;
	j = InObj.Properties.Length;

	for (i=0; i<j; ++i)
	{
		CurProp.Property = InObj.GetPropertyName(InObj.Properties[i].PropertyID);
		CurProp.Value = InObj.GetPropertyAsStringByName(CurProp.Property);

		// Don't add blank properties
		if (CurProp.Value != "")
			PropertySettings.AddItem(CurProp);
	}


	// Save the values
	SaveConfig();
}

// Transfers this profiles current settings to the specified input object
function TransferSettings(Settings InObj, optional bool bForceTransfer)
{
	local DataBindingInfo CurProp;
	local LocalizedSettingInfo CurLocSetting;
	local int i;

	if (InObj.Class.Name != SettingsClassName && !bForceTransfer)
		return;


	// Copy over all of the databinding values
	foreach DataBindingProperties(CurProp)
		InObj.SetDataBindingValue(CurProp.Property, CurProp.Value);


	// Copy over all of the localized values
	foreach LocalizedSettings(CurLocSetting)
	{
		i = InObj.LocalizedSettings.Find('ID', CurLocSetting.ID);

		if (i != INDEX_None)
			InObj.LocalizedSettings[i].ValueIndex = CurLocSetting.Value;
	}


	// Finally, copy over all of the properties
	foreach PropertySettings(CurProp)
		InObj.SetPropertyFromStringByName(CurProp.Property, CurProp.Value);
}

defaultproperties
{
   Name="Default__SettingsProfile"
   ObjectArchetype=Object'Core.Default__Object'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: tr 31-1-2018 17:18:32.000 - Creation time: sk 18-3-2018 10:01:14.193 - Created with UnCodeX