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

GUI2K4.IAMultiColumnRulesPanel


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
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
//==============================================================================
//  This version of UT2K4PlayInfoPanel displays PlayInfo settings
//  on a single page, subdividing PlayInfo groups into sections
//
//  Created by Ron Prestenback
//  © 2003, Epic Games, Inc.  All Rights Reserved
//==============================================================================
class IAMultiColumnRulesPanel extends UT2K4PlayInfoPanel;

var automated moCheckBox                ch_Advanced;    // toggles advanced property display
var automated moButton                  b_Symbols;
var automated GUIImage					i_bk;

var() config string RedSym, BlueSym;
var() string        TeamSymbolPage;

var() editconst UT2K4GamePageBase p_Anchor;

function InitComponent(GUIController MyController, GUIComponent MyOwner)
{
    Super.InitComponent(MyController, MyOwner);

    // Set a pointer to the parent page for quick-access
    if (UT2K4GamePageBase(Controller.ActivePage) != None)
        p_Anchor = UT2K4GamePageBase(Controller.ActivePage);

    ch_Advanced.Checked(Controller.bExpertMode);
    lb_Rules.SetPosition(0.024912,0.080739, 0.950175,0.713178);
    li_Rules.ColumnWidth=0.96;
}

function Refresh()
{
    local int i;

	RedSym = default.RedSym;
	BlueSym = default.BlueSym;

    bRefresh = True;
    bUpdate = True;

	SetGamePI();

    // Clear any PlayInfo setting from our local copy of the PlayInfoData array
    if (InfoRules.Length > 0)
        InfoRules.Remove(0, InfoRules.Length);

	for ( i = 0; i < GamePI.Settings.Length; i++ )
		if ( ShouldDisplayRule(i) )
			InfoRules[InfoRules.Length] = GamePI.Settings[i];

    ClearRules();
    LoadRules();
}

protected function SetGamePI()
{
	GamePI = p_Anchor.RuleInfo;
	GamePI.Sort(0);
}

// No array index validation!
protected function bool ShouldDisplayRule(int Index)
{
	if ( GamePI.Settings[Index].bAdvanced && !Controller.bExpertMode )
		return false;

    // Remove all multiplayer-only PlayInfo settings - they will be displayed on Server Rules tab, if this is a multiplayer game.
    return !GamePI.Settings[Index].bMPOnly;
}

function LoadRules()
{
    local int i;

    // Now settings in PlayInfo have been sorted by Group
    // We can now simply check if this setting's group is different from the last,
    // and if so, create a header for it.
    for (i = 0; i < InfoRules.Length; i++)
    {
        if (i == 0 || InfoRules[i].Grouping != InfoRules[i - 1].Grouping)
            AddGroupHeader(i,li_Rules.Elements.Length == 0);

        // Now add the setting to the GUIMultiOptionList
        AddRule(InfoRules[i], i);
    }
    Super.LoadRules();

    if ( GamePI != None )
    {
    	i = GamePI.FindIndex("BotMode");
    	if ( i != -1 )
    		UpdateBotSetting(i);
    }

	UpdateAdvancedCheckbox();
	UpdateSymbolButton();
}

protected function StoreSetting( int Index, string NewValue )
{
    GamePI.StoreSetting(Index, NewValue);

    // Hack for bot setting
    if (InStr(GamePI.Settings[Index].SettingName, "BotMode") != -1)
    	UpdateBotSetting(Index);
}

// mother of all hacks - all just to make sure that in single player, botmode drop down doesn't display
// Use Map Defaults, and MinPlayers setting says "Number of Bots", instead of "Min Players"
function UpdateBotSetting(int BotModeIndex)
{
	local int MinPlayerListIndex, MinPlayerIndex;
	local moNumericEdit nu;

	if ( li_Rules == None || GamePI == None || p_Anchor == None || p_Anchor.c_Tabs == None || BotModeIndex < 0 || BotModeIndex >= GamePI.Settings.Length )
		return;

	// Find the PlayInfo index of the MinPlayers setting

	for ( MinPlayerIndex = 0; MinPlayerIndex < InfoRules.Length; MinPlayerIndex++ )
		if ( InStr(InfoRules[MinPlayerIndex].SettingName, "MinPlayers") != -1 )
			break;

	if ( MinPlayerIndex < InfoRules.Length )
	{
		// Find the MinPlayers component in the list (caption might be different, so must search by tag)
		MinPlayerListIndex = FindComponentWithTag(MinPlayerIndex);

		if ( li_Rules.ValidIndex(MinPlayerListIndex) )
			nu = moNumericEdit(li_Rules.Elements[MinPlayerListIndex]);
	}

	p_Anchor.UpdateBotSetting(GamePI.Settings[BotModeIndex].Value, nu);
}

function SymbolConfigClosed(optional bool bCancelled)
{
	local TeamSymbolConfig SymConfig;
	local Material Sym;
	local bool bSave;

	SymConfig = TeamSymbolConfig(Controller.ActivePage);

	if ( SymConfig.i_RedPreview.Image != None )
		Sym = SymConfig.i_RedPreview.Image;
	else Sym = None;

	if ( Sym != None )
	{
		bSave = !(string(Sym) ~= RedSym);
		RedSym = string(Sym);
	}
	else if ( RedSym != "" )
	{
		RedSym = "";
		bSave = True;
	}

	if ( SymConfig.i_BluePreview.Image != None )
		Sym = SymConfig.i_BluePreview.Image;
	else Sym = None;

	if ( Sym != None )
	{
		bSave = bSave || !(string(Sym) ~= BlueSym);
		BlueSym = string(Sym);
	}
	else if ( BlueSym != "" )
	{
		BlueSym = "";
		bSave = True;
	}

	if ( bSave )
		SaveConfig();
}

function InternalOnChange(GUIComponent Sender)
{
	local class<GameInfo> GameClass;

    if (Sender == ch_Advanced)
    {
    	// Save our preference
        Controller.bExpertMode = ch_Advanced.IsChecked();
        Controller.SaveConfig();

		// Reload the playinfo settings and repopulate the MultiOptionList
        p_Anchor.SetRuleInfo();
        //reload maplist
        p_Anchor.p_Main.InitMaps();
        return;
    }

    else if ( Sender == b_Symbols )
    {
    	GameClass = class<GameInfo>(GamePI.InfoClasses[0]);

		if ( RedSym == "" )
			RedSym = string(GameClass.static.GetRandomTeamSymbol(0));
		if ( BlueSym == "" )
			BlueSym = string(GameClass.static.GetRandomTeamSymbol(10));

    	if ( Controller.OpenMenu(TeamSymbolPage, RedSym, BlueSym) )
    		Controller.ActivePage.OnClose = SymbolConfigClosed;

    	return;
    }

    Super.InternalOnChange(Sender);
}

function UpdateSymbolButton()
{
	if ( p_Anchor.p_Main.GetIsTeamGame() )
		EnableComponent(b_Symbols);
	else DisableComponent(b_Symbols);
}

function UpdateAdvancedCheckbox()
{
	if ( Controller != None && Controller.bExpertMode != ch_Advanced.IsChecked() )
		ch_Advanced.SetComponentValue( Controller.bExpertMode, True );
}

function string Play()
{
	local string S;

	if ( RedSym != "" )
		S $= "?RedTeamSymbol=" $ RedSym;

	if ( BlueSym != "" )
		S $= "?BlueTeamSymbol=" $ BlueSym;

	return s;
}

DefaultProperties
{
	NumColumns=2
    TeamSymbolPage="GUI2K4.TeamSymbolConfig"

    Begin Object Class=moCheckBox Name=AdvancedButton
        OnChange=InternalOnChange
        Caption="View Advanced Options"
        Hint="Toggles whether advanced properties are displayed"
		WinWidth=0.300000
		WinHeight=0.040000
		WinLeft=0.136725
		WinTop=0.948334
        TabOrder=1
        RenderWeight=1.0
        bSquare=True
        bBoundToParent=True
        bScaleToParent=True
        bAutoSizeCaption=True
    End Object
    ch_Advanced=AdvancedButton

	Begin Object Class=moButton Name=SymbolButton
		WinWidth=0.329346
		WinHeight=0.056282
		WinLeft=0.523664
		WinTop=0.936182
		ComponentWidth=0.4
		bAutoSizeCaption=True
		OnChange=InternalOnChange
		Caption="Team Symbols"
		ButtonCaption="Configure"
		Hint="Choose the banner symbols for each team."
		TabOrder=2
	End Object
	b_Symbols=SymbolButton

	Begin Object class=GUIImage name=Bk1
		WinWidth=0.996997
		WinHeight=0.907930
		WinLeft=0.000505
		WinTop=0.014733
		ImageStyle=ISTY_Stretched
		Image=material'2K4Menus.Newcontrols.Display99'
	End Object
	i_BK=BK1

}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Di 5.9.2006 22:28:52.000 - Creation time: Do 14.8.2014 09:58:41.002 - Created with UnCodeX