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

UTGame.UTUIFrontEnd_WeaponReplacementMenu


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
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
class UTUIFrontEnd_WeaponReplacementMenu extends UTUIFrontEnd
	dependson(UTMutator_WeaponReplacement);


/** Replacement info. */
var transient array<ReplacementInfo> WeaponsToReplace;
var transient array<ReplacementInfo> AmmoToReplace;

/** Reference to option list. */
var transient UTUIOptionList		OptionList;

/** Reference ot the options datastore. */
var transient UTUIDataStore_Options OptionsDataStore;

/** Reference to the string list datastore. */
var transient UTUIDataStore_StringList StringListDataStore;

/** Reference to the menu item datastore. */
var transient UTUIDataStore_MenuItems MenuItemDataStore;

/** List of possible weapon classes. */
var transient array<string>	WeaponClassNames;
var transient array<string>	WeaponFriendlyNames;
var transient array<UTUIDataProvider_Weapon> WeaponProviders;

event PostInitialize()
{
	Super.PostInitialize();

	WeaponsToReplace = class'UTMutator_WeaponReplacement'.default.WeaponsToReplace;
	AmmoToReplace = class'UTMutator_WeaponReplacement'.default.AmmoToReplace;

	OptionList = UTUIOptionList(FindChild('lstOptions', true));
	OptionList.OnAcceptOptions=OnAcceptOptions;

	// Get datastore references
	OptionsDataStore = UTUIDataStore_Options(FindDataStore('UTOptions'));
	StringListDataStore = UTUIDataStore_StringList(FindDataStore('UTStringList'));
	MenuItemDataStore = UTUIDataStore_MenuItems(FindDataStore('UTMenuItems'));
	
	BuildWeaponOptions();	
}

/** Actiated event for the scene. */
event SceneActivated(bool bInitialActivation)
{
	Super.SceneActivated(bInitialActivation);

	OptionList.SetFocus(none);
}

/** Callback for when the option list is accepted. */
function OnAcceptOptions(UIScreenObject InObj, int PlayerIndex)
{
	OnAccept();
}

/** Builds the weapons option lists. */
function BuildWeaponOptions()
{
	local int WeaponIdx;
	local int SelectedIdx;
	local int NameIdx;
	local array<UTUIResourceDataProvider> OutProviders;
	local array<UTUIResourceDataProvider> WeaponOptions;
	local bool bAddWeapon;
	local string ClassPath;

	// Build a list of weapons
	WeaponProviders.length = 0;
	WeaponClassNames.length = 0;
	WeaponFriendlyNames.length = 0;

	if(MenuItemDataStore.GetProviderSet('Weapons', OutProviders))
	{
		for(WeaponIdx=0; WeaponIdx<OutProviders.length; WeaponIdx++)
		{
			bAddWeapon=true;

			
			ClassPath = UTUIDataProvider_Weapon(OutProviders[WeaponIdx]).ClassName;

			// Remove content weapons from console
			if (class'WorldInfo'.static.IsConsoleBuild() && Left(ClassPath, 14) ~= "UTGameContent.")
			{
				bAddWeapon=false;
			}

			if(bAddWeapon)
			{
				WeaponProviders.AddItem(UTUIDataProvider_Weapon(OutProviders[WeaponIdx]));
				WeaponClassNames.AddItem(ClassPath);
				WeaponFriendlyNames.AddItem(UTUIDataProvider_Weapon(OutProviders[WeaponIdx]).FriendlyName);
			}
		}
	}

	// Generate weapon set if we havent already.
	OptionsDataStore.GetSet('ReplacementWeapons', WeaponOptions);

	if(WeaponOptions.length==0)
	{
		OptionsDataStore.AppendToSet('ReplacementWeapons', WeaponFriendlyNames.length);
		OptionsDataStore.GetSet('ReplacementWeapons', WeaponOptions);

		// Generate set of options and set of possible values
		for(WeaponIdx=0; WeaponIdx<WeaponFriendlyNames.length; WeaponIdx++)
		{
			ClassPath = GetClassFieldName(WeaponClassNames[WeaponIdx]);
			
			UTUIDataProvider_MenuOption(WeaponOptions[WeaponIdx]).DataStoreMarkup = "<UTStringList:"$ClassPath$">";
			UTUIDataProvider_MenuOption(WeaponOptions[WeaponIdx]).CustomFriendlyName = WeaponFriendlyNames[WeaponIdx];

			StringListDataStore.Empty(name(ClassPath));
			for(NameIdx=0; NameIdx<WeaponFriendlyNames.length; NameIdx++)
			{
				StringListDataStore.AddStr(name(ClassPath), WeaponFriendlyNames[NameIdx]);
			}

			StringListDataStore.SetCurrentValueIndex(name(ClassPath), WeaponIdx);
		}

		OptionList.bRegenOptions=true;
	}
	else
	{
		for(WeaponIdx=0; WeaponIdx<WeaponFriendlyNames.length; WeaponIdx++)
		{
			ClassPath = GetClassFieldName(WeaponClassNames[WeaponIdx]);
			StringListDataStore.SetCurrentValueIndex(name(ClassPath), WeaponIdx);
		}
	}

	// Set defaults
	for(WeaponIdx=0; WeaponIdx<WeaponsToReplace.length; WeaponIdx++)
	{
		for(SelectedIdx=0; SelectedIdx<WeaponClassNames.length; SelectedIdx++)
		{
			if(WeaponsToReplace[WeaponIdx].NewClassPath==WeaponClassNames[SelectedIdx])
			{
				ClassPath = GetClassFieldName(string(WeaponsToReplace[WeaponIdx].OldClassName));
				StringListDataStore.SetCurrentValueIndex(name(ClassPath), SelectedIdx);
			}
		}
	}

	OptionList.RefreshAllOptions();
}

/** @return string	Returns a fieldname given a weapon class name. */
function string GetClassFieldName(string ClassName)
{
	ClassName = Right(ClassName, Len(ClassName) - InStr(ClassName, ".") - 1);
	ClassName = Repl(ClassName, ".", "_");
	ClassName = "ReplaceWeapon_"$ClassName;
	return ClassName;
}

/** Sets up the scene's button bar. */
function SetupButtonBar()
{
	ButtonBar.Clear();
	ButtonBar.AppendButton("<Strings:UTGameUI.ButtonCallouts.Back>", OnButtonBar_Back);
	ButtonBar.AppendButton("<Strings:UTGameUI.ButtonCallouts.Accept>", OnButtonBar_Accept);
}

/** Callback for when the user wants to back out of this screen. */
function OnBack()
{
	CloseScene(self);
}

/** Callback for when the user accepts the changes. */
function OnAccept()
{
	local int WeaponIdx;
	local string ClassPath;
	local int SelectedIdx;

	WeaponsToReplace.length=0;
	AmmoToReplace.length=0;

	for(WeaponIdx=0; WeaponIdx<WeaponClassNames.length; WeaponIdx++)
	{
		ClassPath=GetClassFieldName(WeaponClassNames[WeaponIdx]);
		SelectedIdx=StringListDataStore.GetCurrentValueIndex(name(ClassPath));
		if(SelectedIdx!=WeaponIdx)
		{
			WeaponsToReplace.length=WeaponsToReplace.length+1;
			WeaponsToReplace[WeaponsToReplace.length-1].NewClassPath = WeaponProviders[SelectedIdx].ClassName;
			WeaponsToReplace[WeaponsToReplace.length-1].OldClassName = name(Right(WeaponProviders[WeaponIdx].ClassName, Len(WeaponProviders[WeaponIdx].ClassName) - InStr(WeaponProviders[WeaponIdx].ClassName, ".") - 1));
			
			AmmoToReplace.length=AmmoToReplace.length+1;
			AmmoToReplace[AmmoToReplace.length-1].NewClassPath = WeaponProviders[SelectedIdx].AmmoClassPath;
			AmmoToReplace[AmmoToReplace.length-1].OldClassName = name(Right(WeaponProviders[WeaponIdx].AmmoClassPath, Len(WeaponProviders[WeaponIdx].AmmoClassPath) - InStr(WeaponProviders[WeaponIdx].AmmoClassPath, ".") - 1));
		}
	}

	class'UTMutator_WeaponReplacement'.default.WeaponsToReplace = WeaponsToReplace;
	class'UTMutator_WeaponReplacement'.default.AmmoToReplace = AmmoToReplace;
	class'UTMutator_WeaponReplacement'.static.StaticSaveConfig();

	CloseScene(self);
}

/** Buttonbar Callbacks. */
function bool OnButtonBar_Back(UIScreenObject InButton, int InPlayerIndex)
{
	OnBack();

	return true;
}

function bool OnButtonBar_Accept(UIScreenObject InButton, int InPlayerIndex)
{
	OnAccept();

	return true;
}


/**
 * Provides a hook for unrealscript to respond to input using actual input key names (i.e. Left, Tab, etc.)
 *
 * Called when an input key event is received which this widget responds to and is in the correct state to process.  The
 * keys and states widgets receive input for is managed through the UI editor's key binding dialog (F8).
 *
 * This delegate is called BEFORE kismet is given a chance to process the input.
 *
 * @param	EventParms	information about the input event.
 *
 * @return	TRUE to indicate that this input key was processed; no further processing will occur on this input key event.
 */
function bool HandleInputKey( const out InputEventParameters EventParms )
{
	local bool bResult;

	bResult=false;

	if(EventParms.EventType==IE_Released)
	{
		if(EventParms.InputKeyName=='XboxTypeS_B' || EventParms.InputKeyName=='Escape')
		{
			OnBack();
			bResult=true;
		}
	}

	return bResult;
}

defaultproperties
{
   Begin Object Class=UIComp_Event Name=SceneEventComponent ObjName=SceneEventComponent Archetype=UIComp_Event'UTGame.Default__UTUIFrontEnd:SceneEventComponent'
      ObjectArchetype=UIComp_Event'UTGame.Default__UTUIFrontEnd:SceneEventComponent'
   End Object
   EventProvider=SceneEventComponent
   Name="Default__UTUIFrontEnd_WeaponReplacementMenu"
   ObjectArchetype=UTUIFrontEnd'UTGame.Default__UTUIFrontEnd'
}

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