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

GUI2K4.UT2K4Tab_GameTypeBase


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
//==============================================================================
//  Created on: 12/11/2003
//  Base class for GameType tab of the Instant Action & Host Multiplayer pages
//
//  Written by Ron Prestenback
//  © 2003, Epic Games, Inc. All Rights Reserved
//==============================================================================

class UT2K4Tab_GameTypeBase extends UT2K4GameTabBase;

struct SortHack
{
	var string GameClass;
	var byte Weight;
};

var array<SortHack>                GamePos;
var UT2K4Tab_MainBase              tp_Main;
var array<CacheManager.GameRecord> GameTypes;

// Components for left side
var automated GUISectionBackground sb_Games;
var automated GUIListBox           lb_Games;
var GUIList                        li_Games;

// Components for right side
var automated GUISectionBackground sb_Preview;
var automated GUILabel             l_NoPreview;
var automated GUIImage             i_GamePreview;
var automated AltSectionBackground i_Bk;
var automated GUIScrollTextBox     lb_GameDesc;

var localized string EpicGameCaption, CustomGameCaption;

delegate OnChangeGameType(bool bIsCustom);

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

    li_Games = lb_Games.List;
    li_Games.bHotTrack = True;
    li_Games.OnTrack = InternalOnTrack;
    li_Games.CompareItem = GametypeSort;
    PopulateGameTypes();
    InitPreview();
    lb_GameDesc.MyScrollText.Style = lb_GameDesc.Style;

    i_BK.ManageComponent(lb_GameDesc);

}

function PopulateGameTypes()
{
    local int i,cnt;

    class'CacheManager'.static.GetGameTypeList(GameTypes);

	// Get the list of valid gametypes, and separate them into the appropriate lists
	// All official gametypes go into the large listbox
	// All custom gametypes go into the combo box (sorry guys!)
    for (i = 0; i < GameTypes.Length; i++)
    {
		if ( HasMaps(GameTypes[i]) )
		{
			if (GameTypes[i].GameTypeGroup < 3)
	            AddEpicGameType( GameTypes[i].GameName, GameTypes[i].MapListClassName);
			else
				cnt++;
		}
		else if (GameTypes[i].GameTypeGroup >= 3)
		{
			Log("Gametype"@GameTypes[i].ClassName@"found but it has no maps", 'Warning');
		}
    }

//	li_Games.SortList();

	if (cnt>0)
	{
	    li_Games.Add(CustomGameCaption,None,"",true);

	    for (i = 0; i < GameTypes.Length; i++)
	    {
			if ( HasMaps(GameTypes[i]) )
			{
				if (GameTypes[i].GameTypeGroup >= 3)
		            AddEpicGameType( GameTypes[i].GameName, GameTypes[i].MapListClassName);
		    }
	    }
		li_Games.Insert(0,EpicGameCaption,None,"",true,true);
		li_Games.SetIndex(1);
	}



}

function bool HasMaps( CacheManager.GameRecord TestRec )
{
    local array<CacheManager.MapRecord> Records;

    if ( TestRec.MapPrefix != "" )
    {
    	class'CacheManager'.static.GetMapList(Records, TestRec.MapPrefix);
    	return Records.Length > 0;
    }

    return false;
}

function InitPreview()
{
    local Material Screenie;
    local int Index;

    Index = FindRecordIndex(li_Games.Get(True));
    if ( Index >= 0 && Index < GameTypes.Length )
    {
	    Screenie = Material(DynamicLoadObject(GameTypes[Index].ScreenshotRef, class'Material'));
	    if ( GameTypes[Index].Description != "" )
	    	lb_GameDesc.SetContent(GameTypes[Index].Description);
	    else lb_GameDesc.SetContent(class'UT2K4Tab_MainBase'.default.MessageNoInfo);
	}
	else lb_GameDesc.SetContent(class'UT2K4Tab_MainBase'.default.MessageNoInfo);

	i_GamePreview.Image = Screenie;
	i_GamePreview.SetVisibility( Screenie != None );
	l_NoPreview.SetVisibility(Screenie == None);
	i_BK.Caption = li_Games.Get();
}

function int GametypeSort(GUIListElem ElemA, GUIListElem ElemB)
{
	local byte A,B;

	A = GetWeight(FindGameClass(ElemA.Item),ElemA.bSection);
	B = GetWeight(FindGameClass(ElemB.Item),ElemB.bSection);
	if (A==B)
	{
		if ( ElemA.Item > ElemB.Item )
			return 1;

		else if ( ElemA.Item < ElemB.Item )
			return -1;

		return 0;
	}
	else
		return A-B;


	return GetWeight(FindGameClass(ElemA.Item), ElemA.bSection) - GetWeight(FindGameClass(ElemB.Item), ElemA.bSection);
}

function byte GetWeight( string GameClass, bool bSection )
{
	local int i;

    if (bSection)
    	return 254;

	for ( i = 0; i < GamePos.Length; i++ )
	{
		if ( GamePos[i].GameClass ~= GameClass )
			return GamePos[i].Weight;
	}

	return 255;
}

function AddEpicGameType(string GameName, string MapList)
{
    li_Games.Add(GameName, None, MapList);
}


function InternalOnChange(GUIComponent Sender)
{
    local int Index;

    Index = FindRecordIndex(li_Games.Get());
    if ( Index < 0 || Index >= GameTypes.Length )
    	return;

    if ( Controller.LastGameType == "" || GameTypes[Index].ClassName != Controller.LastGameType )
    {
    	InitPreview();
    	Controller.LastGameType = GameTypes[Index].ClassName;
    }

    if (Sender == lb_Games)
    {

		if ( li_Games.IsSection() )
			return;

		OnChangeGameType(False);
    }
}

function InternalOnTrack(GUIComponent Sender, int OldIndex)
{
    if (!li_Games.IsValid())
        return;

	if (li_Games.IsSection())
	{
		li_Games.Index = OldIndex;
		return;
	}

	InitPreview();
}

function int FindRecordIndex(string GameName)
{
    local int i;

    for (i = 0; i < GameTypes.Length; i++)
        if (GameTypes[i].GameName ~= GameName)
            return i;

    return -1;
}

function string FindGameClass(string GameName)
{
	local int i;

	for ( i = 0; i < GameTypes.Length; i++ )
	{
		if ( GameTypes[i].GameName ~= GameName )
			return GameTypes[i].ClassName;
	}

	return "";
}

event SetVisibility( bool bIsVisible )
{
	Super.SetVisibility(bIsVisible);

	i_GamePreview.SetVisibility( i_GamePreview.Image != None );
	l_NoPreview.SetVisibility( i_GamePreview.Image == None );
}

defaultproperties
{
     GamePos(0)=(GameClass="UT2K4Assault.ASGameInfo")
     GamePos(1)=(GameClass="Onslaught.ONSOnslaughtGame",Weight=1)
     GamePos(2)=(GameClass="xGame.xDeathMatch",Weight=2)
     GamePos(3)=(GameClass="xGame.xCTFGame",Weight=3)
     GamePos(4)=(GameClass="xGame.xTeamGame",Weight=4)
     GamePos(5)=(GameClass="xGame.xDoubleDom",Weight=5)
     GamePos(6)=(GameClass="xGame.xBombingRun",Weight=6)
     GamePos(7)=(GameClass="BonusPack.xMutantGame",Weight=7)
     GamePos(8)=(GameClass="SkaarjPack.Invasion",Weight=8)
     GamePos(9)=(GameClass="BonusPack.xLastManStandingGame",Weight=9)
     GamePos(10)=(GameClass="xGame.xVehicleCTFGame",Weight=10)
     GamePos(11)=(GameClass="xGame.InstagibCTF",Weight=11)
     Begin Object Class=GUISectionBackground Name=GameTypeLeftGroup
         Caption="Available Game Types"
         TopPadding=0.025000
         BottomPadding=0.025000
         WinTop=0.043125
         WinLeft=0.023750
         WinWidth=0.482500
         WinHeight=0.941490
         TabOrder=0
         OnPreDraw=GameTypeLeftGroup.InternalPreDraw
     End Object
     sb_Games=GUISectionBackground'GUI2K4.UT2K4Tab_GameTypeBase.GameTypeLeftGroup'

     Begin Object Class=GUIListBox Name=UT2004Games
         SelectedStyleName="ListSelection"
         bVisibleWhenEmpty=True
         bSorted=True
         OnCreateComponent=UT2004Games.InternalOnCreateComponent
         FontScale=FNS_Large
         WinTop=0.144225
         WinLeft=0.045599
         WinWidth=0.438457
         WinHeight=0.796982
         TabOrder=0
         bBoundToParent=True
         bScaleToParent=True
         OnChange=UT2K4Tab_GameTypeBase.InternalOnChange
     End Object
     lb_Games=GUIListBox'GUI2K4.UT2K4Tab_GameTypeBase.UT2004Games'

     Begin Object Class=GUISectionBackground Name=GameTypeRightGroup
         Caption="Preview"
         WinTop=0.043125
         WinLeft=0.513243
         WinWidth=0.464649
         WinHeight=0.941490
         OnPreDraw=GameTypeRightGroup.InternalPreDraw
     End Object
     sb_Preview=GUISectionBackground'GUI2K4.UT2K4Tab_GameTypeBase.GameTypeRightGroup'

     Begin Object Class=GUILabel Name=NoPreview
         Caption="No Preview Available"
         TextAlign=TXTA_Center
         TextColor=(B=0,G=255,R=247)
         TextFont="UT2HeaderFont"
         bTransparent=False
         bMultiLine=True
         VertAlign=TXTA_Center
         WinTop=0.142826
         WinLeft=0.539224
         WinWidth=0.411862
         WinHeight=0.316545
     End Object
     l_NoPreview=GUILabel'GUI2K4.UT2K4Tab_GameTypeBase.NoPreview'

     Begin Object Class=GUIImage Name=GameTypePreview
         ImageStyle=ISTY_Scaled
         ImageRenderStyle=MSTY_Normal
         WinTop=0.142826
         WinLeft=0.539224
         WinWidth=0.411862
         WinHeight=0.316545
         RenderWeight=0.200000
     End Object
     i_GamePreview=GUIImage'GUI2K4.UT2K4Tab_GameTypeBase.GameTypePreview'

     Begin Object Class=AltSectionBackground Name=Bk1
         WinTop=0.478553
         WinLeft=0.535622
         WinWidth=0.419030
         WinHeight=0.474455
         RenderWeight=0.300000
         OnPreDraw=Bk1.InternalPreDraw
     End Object
     i_bk=AltSectionBackground'GUI2K4.UT2K4Tab_GameTypeBase.Bk1'

     Begin Object Class=GUIScrollTextBox Name=GameTypeDescription
         bNoTeletype=True
         CharDelay=0.002500
         EOLDelay=0.500000
         OnCreateComponent=GameTypeDescription.InternalOnCreateComponent
         WinTop=0.556774
         WinLeft=0.565270
         WinWidth=0.362056
         WinHeight=0.325716
         bTabStop=False
         bNeverFocus=True
     End Object
     lb_GameDesc=GUIScrollTextBox'GUI2K4.UT2K4Tab_GameTypeBase.GameTypeDescription'

     EpicGameCaption="Default Game Types"
     CustomGameCaption="Custom Game Type"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: pr 5-2-2018 12:35:54.000 - Creation time: sk 18-3-2018 09:50:24.457 - Created with UnCodeX