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

KFGui.KFMapPage


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
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
class KFMapPage extends UT2K4Tab_MainSP;

var     automated           moComboBox                          co_Difficulty;
var     automated           moComboBox                          co_GameLength;
var     automated           moCheckBox                          ch_Sandbox;

var()   editconst noexport  PlayInfo                            GamePI;
var                         array<PlayInfo.PlayInfoData>        InfoRules;
var                         byte                                LastGameLengthIndex;
var                         int                                 DefaultInitialCountDownValue;
var							bool								bDisableCombos;

function bool Tick(Canvas Canvas)
{
	if ( bDisableCombos )
	{
		co_Difficulty.DisableMe();
		co_GameLength.DisableMe();
	}

	return super.OnDraw(Canvas);
}

function InitComponent(GUIController MyController, GUIComponent MyOwner)
{
	local array<CacheManager.MapRecord> TutMaps;

	OnDraw = Tick;

    super(UT2K4GameTabBase).InitComponent(MyController, MyOwner);

	if ( lb_Maps != None )
		li_Maps = lb_Maps.List;

	if ( li_Maps != None )
	{
	    li_Maps.OnDblClick = MapListDblClick;
	    li_Maps.bSorted = True;
	    lb_Maps.NotifyContextSelect = HandleContextSelect;
	}

	class'CacheManager'.static.InitCache();
    MapHandler = PlayerOwner().Spawn(class'MaplistManager');
    class'CacheManager'.static.GetMaplist(TutMaps, "TUT");

	lb_Maps.bBoundToParent=false;
	lb_Maps.bScaleToParent=false;

	sb_Selection.ManageComponent(lb_Maps);

	asb_Scroll.ManageComponent(lb_MapDesc);

    LastGameLengthIndex = 0;

    sb_Options.ManageComponent(co_Difficulty);
    sb_Options.ManageComponent(co_GameLength);
    sb_Options.ManageComponent(ch_Sandbox);
    sb_Options.ManageComponent(b_Maplist);

    SetGamePI();
}

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

function ShowPanel(bool bShow)
{
	local int DifficultyIndex;

	super.ShowPanel(bShow);

	DifficultyIndex = GamePI.FindIndex("GameDifficulty");

	if ( float(GamePI.Settings[DifficultyIndex].Value) < 2.0000 )
	{
		co_Difficulty.SetIndex(0);
	}
	else if ( float(GamePI.Settings[DifficultyIndex].Value) < 4.0000 )
	{
		co_Difficulty.SetIndex(1);
	}
	else if ( float(GamePI.Settings[DifficultyIndex].Value) < 5.0000 )
	{
		co_Difficulty.SetIndex(2);
	}
	else if ( float(GamePI.Settings[DifficultyIndex].Value) < 7.0000 )
	{
		co_Difficulty.SetIndex(3);
	}
	else
	{
	 	co_Difficulty.SetIndex(4);
	}
}

function RefreshOptions()
{
    local int i, j;
    local array<string> Range;

	SetGamePI();
    GamePI.GetSettings("", InfoRules);
	co_Difficulty.MyComboBox.Clear();
	co_GameLength.MyComboBox.Clear();

	for ( i = 0; i < InfoRules.Length; i++)
    {
        if ( InfoRules[i].DisplayName == co_Difficulty.Caption )
        {
            GamePI.SplitStringToArray(Range, InfoRules[i].Data, ";");

			for ( j = 0; j + 1 < Range.Length; j += 2 )
            {
                co_Difficulty.AddItem(Range[j+1], , Range[j]);
                co_Difficulty.Tag = i;
            }
        }
        else if ( InfoRules[i].DisplayName == co_GameLength.Caption )
        {
            GamePI.SplitStringToArray(Range, InfoRules[i].Data, ";");

			for ( j = 0; j + 1 < Range.Length; j += 2 )
            {
                co_GameLength.AddItem(Range[j+1], , Range[j]);
                co_GameLength.Tag = i;
            }
        }
    }

	co_GameLength.SetIndex(class'KFGameType'.default.KFGameLength);
	GameLengthChange(co_GameLength);
}

function InternalOnChange(GUIComponent Sender)
{
	if (GUIMultiOptionList(Sender) != None)
	{
		if (Controller.bCurMenuInitialized)
			UpdateSetting(GUIMultiOptionList(Sender).Get());
	}

	else if ( GUIMenuOption(Sender) != None && Controller.bCurMenuInitialized )
		UpdateSetting( GUIMenuOption(Sender) );
}

function UpdateSetting(GUIMenuOption Sender)
{
    local int i;
    local int Index;

    if ( Sender == none )
    {
        return;
    }

    i = Sender.Tag;

    if ( i < 0 )
    {
        return;
    }

    if ( InfoRules[i].DisplayName != Sender.Caption )
    {
    	if ( Controller.bModAuthor )
		{
		   	log("Corrupt list index detected in component"@Sender.Name,'ModAuthor');
    	}

        return;
    }

    Index = GamePI.FindIndex(InfoRules[i].SettingName);

    if ( InfoRules[i].DisplayName != Sender.Caption || Index == -1 )
    {
    	if ( Controller.bModAuthor )
    	{
	    	log("Invalid setting requested from PlayInfo!",'ModAuthor');
	    }

    	return;
    }

    StoreSetting(Index, Sender.GetComponentValue());
}

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


// Called when a new gametype is selected
function InitGameType()
{
    local int i;
    local array<CacheManager.GameRecord> Games;
    local bool bReloadMaps;

	// Get a list of all gametypes.
    class'CacheManager'.static.GetGameTypeList(Games);
	for (i = 0; i < Games.Length; i++)
    {
        if (Games[i].ClassName ~= Controller.LastGameType)
        {
        	bReloadMaps = CurrentGameType.MapPrefix != Games[i].MapPrefix;
            CurrentGameType = Games[i];
            break;
        }
    }

    if ( i == Games.Length )
    	return;

	// Enable/Disable extra options based on GameType
	if ( CurrentGameType.ClassName == "KFMod.KFGameType" )
	{
		co_GameLength.EnableMe();
		ch_Sandbox.EnableMe();
	}
	else
	{
		co_GameLength.DisableMe();
		ch_Sandbox.DisableMe();
	}

	// Update the gametype label's text
    SetGameTypeCaption();

    // Should the tutorial button be enabled?
    // CheckGameTutorial();

    // Load Maps for the new gametype, but only if it uses a different maplist
    if (bReloadMaps)
   		InitMaps();

    // Set the selected map
    i = li_Maps.FindIndexByValue(LastSelectedMap);
    if ( i == -1 )
    	i = 0;
    li_Maps.SetIndex(i);
    li_Maps.Expand(i);

	// Load the information (screenshot, desc., etc.) for the currently selected map
    // ReadMapInfo(li_Maps.GetParentCaption());
}

// Query the CacheManager for the maps that correspond to this gametype, then fill the main list
function InitMaps(optional string MapPrefix)
{
    local int i, j;
    local bool bTemp;
    local string Package, Item, Desc;
    local GUITreeNode StoredItem;
    local DecoText DT;

    // Make sure we have a map prefix
    if ( MapPrefix == "" )
    {
        MapPrefix = GetMapPrefix();
    }

    // Temporarily disable notification in all components
    bTemp = Controller.bCurMenuInitialized;
    Controller.bCurMenuInitialized = False;

    if ( li_Maps.IsValid() )
        li_Maps.GetElementAtIndex(li_Maps.Index, StoredItem);

    // Get the list of maps for the current gametype
    class'CacheManager'.static.GetMapList( CacheMaps, MapPrefix );
    if ( MapHandler.GetAvailableMaps(MapHandler.GetGameIndex(CurrentGameType.ClassName), Maps) )
    {
        li_Maps.bNotify = False;
        li_Maps.Clear();

        for ( i = 0; i < Maps.Length; i++ )
        {
            DT = None;
            if ( class'CacheManager'.static.IsDefaultContent(Maps[i].MapName) )
            {
                if ( bOnlyShowCustom )
                    continue;
            }
            else if ( bOnlyShowOfficial )
                continue;

            j = FindCacheRecordIndex(Maps[i].MapName);
            if ( class'CacheManager'.static.Is2003Content(Maps[i].MapName) )
            {
                if ( CacheMaps[j].TextName != "" )
                {
                    if ( !Divide(CacheMaps[j].TextName, ".", Package, Item) )
                {
                        Package = "XMaps";
                        Item = CacheMaps[j].TextName;
                    }
                }

                DT = class'xUtil'.static.LoadDecoText(Package, Item);
            }

            if ( DT != None )
                Desc = JoinArray(DT.Rows, "|");
            else
                Desc = CacheMaps[j].Description;


            // KF Map Hack
            if ( CurrentGameType.MapPrefix ~= "KF" )
            {
				if (Maps[i].MapName != "KF-Intro" && Maps[i].MapName != "KF-Menu")
					li_Maps.AddItem( Maps[i].MapName, Maps[i].MapName, ,,Desc);
            }
            else
				li_Maps.AddItem( Maps[i].MapName, Maps[i].MapName, ,,Desc);
        }
    }

    if ( li_Maps.bSorted )
        li_Maps.SortList();

    if ( StoredItem.Caption != "" )
    {
        i = li_Maps.FindFullIndex(StoredItem.Caption, StoredItem.Value, StoredItem.ParentCaption);
        if ( i != -1 )
            li_Maps.SilentSetIndex(i);
    }

    li_Maps.bNotify = True;

    Controller.bCurMenuInitialized = bTemp;
}

function SandBoxChange(GUIComponent Sender)
{
    local int CountDownIndex, DifficultyIndex;

	if ( ch_Sandbox.IsChecked() )
    {
    	bDisableCombos = true;

        co_GameLength.SetIndex(3);

        sb_Options.DisableComponent(co_Difficulty);
        sb_Options.DisableComponent(co_GameLength);

        UT2K4MainPage(OwnerPage()).c_Tabs.TabStack[1].EnableMe();
    }
    else
    {
    	bDisableCombos = false;

        sb_Options.EnableComponent(co_Difficulty);
        sb_Options.EnableComponent(co_GameLength);

		co_GameLength.SetIndex(LastGameLengthIndex);

        CountDownIndex = GamePI.FindIndex("InitialCountDownValue");
        GamePI.StoreSetting(CountDownIndex, DefaultInitialCountDownValue);

        DifficultyIndex = GamePI.FindIndex("GameDifficulty");

		if ( float(GamePI.Settings[DifficultyIndex].Value) < 2.0000 )
		{
			co_Difficulty.SetIndex(0);
		}
		else if ( float(GamePI.Settings[DifficultyIndex].Value) < 4.0000 )
		{
			co_Difficulty.SetIndex(1);
		}
		else if ( float(GamePI.Settings[DifficultyIndex].Value) < 5.0000 )
		{
			co_Difficulty.SetIndex(2);
		}
		else if ( float(GamePI.Settings[DifficultyIndex].Value) < 7.0000 )
		{
			co_Difficulty.SetIndex(3);
		}
		else
		{
		 	co_Difficulty.SetIndex(4);
		}

		GameLengthChange(Sender);
		UT2K4MainPage(OwnerPage()).c_Tabs.TabStack[1].DisableMe();
    }
}

function GameLengthChange(GUIComponent Sender)
{
    if ( co_GameLength.GetIndex() != 3 )
    {
        LastGameLengthIndex = co_GameLength.GetIndex();
    }

    class'KFGameType'.default.KFGameLength = co_GameLength.GetIndex();
    class'KFGameType'.static.StaticSaveConfig();
    UpdateSetting(co_GameLength);

    if ( class'KFGameType'.default.KFGameLength == 3 )
    {
        ch_Sandbox.SetComponentValue(true);
        SandBoxChange(Sender);
    }
    else
    {
        if ( ch_Sandbox.IsChecked() )
        {
            ch_Sandbox.SetComponentValue(false);
            SandBoxChange(Sender);
            //co_GameLength.SetIndex(LastGameLengthIndex);
        }
    }
}

function GameDifficultyChange(GUIMenuOption Sender)
{
	local int NewIndex;


	NewIndex = co_Difficulty.GetIndex();

	if ( NewIndex == 0 )
	{
		class'KFGameType'.default.GameDifficulty = 1.0000;
	}
	else if ( NewIndex == 1 )
	{
		class'KFGameType'.default.GameDifficulty = 2.0000;
	}
	else if ( NewIndex == 3 )
	{
		class'KFGameType'.default.GameDifficulty = 4.0000;
	}
	else if ( NewIndex == 4 )
	{
		class'KFGameType'.default.GameDifficulty = 5.0000;
	}
	else
	{
		class'KFGameType'.default.GameDifficulty = 7.0000;
	}

	class'KFGameType'.static.StaticSaveConfig();
	UpdateSetting(Sender);
}

defaultproperties
{
     Begin Object Class=moComboBox Name=DifficultyCombo
         bReadOnly=True
         ComponentWidth=0.500000
         Caption="Difficulty"
         OnCreateComponent=DifficultyCombo.InternalOnCreateComponent
         Hint="Sets how skilled your opponents will be"
         WinTop=0.750547
         WinLeft=0.087169
         WinWidth=0.341797
         TabOrder=0
         OnChange=KFMapPage.GameDifficultyChange
     End Object
     co_Difficulty=moComboBox'KFGui.KFMapPage.DifficultyCombo'

     Begin Object Class=moComboBox Name=GameLengthCombo
         bReadOnly=True
         ComponentWidth=0.500000
         Caption="Game Length"
         OnCreateComponent=GameLengthCombo.InternalOnCreateComponent
         Hint="Sets how long the game will be"
         WinTop=0.750547
         WinLeft=0.087169
         WinWidth=0.341797
         TabOrder=1
         OnChange=KFMapPage.GameLengthChange
     End Object
     co_GameLength=moComboBox'KFGui.KFMapPage.GameLengthCombo'

     Begin Object Class=moCheckBox Name=SandboxCheck
         CaptionWidth=0.500000
         ComponentWidth=0.500000
         Caption="Enable Sandbox"
         OnCreateComponent=SandboxCheck.InternalOnCreateComponent
         Hint="Enable the advanced sandbox settings"
         WinTop=0.772865
         WinLeft=0.051758
         WinWidth=0.341797
         TabOrder=3
         OnChange=KFMapPage.SandBoxChange
     End Object
     ch_Sandbox=moCheckBox'KFGui.KFMapPage.SandboxCheck'

     DefaultInitialCountDownValue=60
     Begin Object Class=AltSectionBackground Name=ScrollSection
         bFillClient=True
         bNoCaption=True
         Caption="Map Desc"
         WinTop=0.525219
         WinLeft=0.546118
         WinWidth=0.409888
         WinHeight=0.437814
         OnPreDraw=ScrollSection.InternalPreDraw
     End Object
     asb_Scroll=AltSectionBackground'KFGui.KFMapPage.ScrollSection'

     Begin Object Class=moButton Name=MaplistButton
         ButtonCaption="Maplist Configuration"
         ComponentWidth=1.000000
         OnCreateComponent=MaplistButton.InternalOnCreateComponent
         Hint="Modify the maps that should be used in gameplay"
         WinTop=0.888587
         WinLeft=0.039258
         WinWidth=0.341797
         WinHeight=0.050000
         TabOrder=4
         OnChange=KFMapPage.MaplistConfigClick
     End Object
     b_Maplist=moButton'KFGui.KFMapPage.MaplistButton'

     b_Tutorial=None

     LastSelectedMap="KF-Test"
     ch_OfficialMapsOnly=None

}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fri 13-10-2023 03:17:26.000 - Creation time: Fri 13-10-2023 03:19:03.681 - Created with UnCodeX