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

XInterface.UT2SP_LadderLoading


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
class UT2SP_LadderLoading extends UT2LoadingPageBase;

#exec OBJ LOAD FILE=InterfaceContent.utx

var UT2003GameProfile GameProf;
var MatchInfo myMatchInfo;
var UnrealTeamInfo EnemyTeamInfo;
    
var Color   White, Yellow, Blue, Red;
var Material Box, CharFrame;
var array<xUtil.PlayerRecord> PlayerList;
var localized string StatNames[5];
var localized string LoadingMessage;

// initialize data structures, then call each of the render functions in turn
simulated event init()
{
    local class<UnrealTeamInfo> UTIclass;

    GameProf = UT2003GameProfile(Level.Game.CurrentGameProfile);

    AddBackground();            // Background is the Map Faded FullScreen Shot.

    if ( GameProf == None || GameProf.bInLadderGame == false ) {
        Log("UT2SP_LadderLoading::init() could not find GameProfile or not in a ladder game.");
        AddLoading();               // adds loading screen
        return;
    }

    myMatchInfo = GameProf.GetMatchInfo(GameProf.CurrentLadder, GameProf.CurrentMenuRung);

    if ( myMatchInfo == None ) {
        Log("UT2SP_LadderLoading::init() could not find MatchInfo.");
        AddLoading();               // adds loading screen
        return;
    }

    UTIclass = class<UnrealTeamInfo>(DynamicLoadObject(myMatchInfo.EnemyTeamName,class'Class'));
    EnemyTeamInfo = spawn(UTIClass);

    if ( EnemyTeamInfo == None ) {
        Log("UT2SP_LadderLoading::init() could not find Enemy UnrealTeamInfo data.");
        AddLoading();               // adds loading screen
        return;
    }

    // PreLoad the Player List so we can access Player Portraits
    class'xUtil'.static.GetPlayerList(PlayerList);

    AddTitle();                 // Title would be the Ladder type (or GameType).
    AddPlayerRoster();           
    AddOpponentRoster();
    AddTeamCompare();   
}

simulated function AddLoading()
{
    AddJustifiedText(LoadingMessage, 1, 0.0, 0.0, 1.0, 1.0).FontName = "XInterface.UT2LargeFont";
}

// Todo: Get Background Texture from GameProfile ?
simulated function AddBackground()
{
local Material Tex;

    Tex = DLOTexture("InterfaceContent.Backgrounds.bg10");

    // Fallback texture .. should we choose another one ?
    if (Tex == None)
        Tex = DLOTexture("InterfaceContent.Backgrounds.bg11");

    if (Tex != None)
        AddImage(Tex, 0.0, 0.0, 1.0, 1.0).DrawColor=Class'Canvas'.static.MakeColor(128,128,192);
}


simulated function AddTitle()
{
    local string Title;
    local class<GameInfo> GIClass;

    GIClass = class<GameInfo>(DynamicLoadObject(myMatchInfo.GameType, class'Class'));
    Title = LoadingMessage@GIClass.default.GameName;
    AddJustifiedText(Title, 1, 0.0, 0.0, 0.075, 1.0).FontName = "XInterface.UT2LargeFont";
}

simulated function AddPlayerRoster()
{
local int i, numplayers;
local array<string> Players;

    Players[0] = GameProf.PlayerCharacter;

    numplayers = myMatchInfo.NumBots / 2;  // purposeful integer truncate on odd number of bots
    for (i = 0; i<numplayers; i++) 
    {
        Players[i+1] = GameProf.PlayerTeam[GameProf.PlayerLineup[i]];
    }

    AddTeamBar(0, GameProf.TeamSymbolName, Players, 0.095, class'Canvas'.static.MakeColor(64, 64, 255));
}

simulated function AddOpponentRoster()
{
local int i, numplayers;
local array<string> Players;

    numplayers = myMatchInfo.NumBots /2;
    if ( myMatchInfo.NumBots % 2 == 1 ) 
    {
        numplayers++;  // bot team get the extra player
    }

    for (i = 0; i<numplayers; i++) 
    {
        Players[i] = EnemyTeamInfo.RosterNames[i];
    }

    AddTeamBar(1, EnemyTeamInfo.TeamSymbolName, Players, 0.75, class'Canvas'.static.MakeColor(255, 0, 0), true);
}

simulated function AddTeamBar(int TeamId, string TeamIconName, out array<string> Crew, float top, Color TeamColor, optional bool bNameUp)
{
local Material TSym, Portrait;
local float ILeft, ISpace, ImgW, ImgH, IconBoxW, IconBoxH, IconBox2Left;
local int i;
//local DrawOpImage	Opi;

    // Part 1: Get The Team Symbol
    TSym = DLOTexture(TeamIconName);

    // Precompute a couple of sizes
    ImgW = 0.075;
    ImgH = 0.2;
    ISpace = 0.03 + (7-Crew.Length) * 0.01;
    IconBoxW = ImgW * 2;
    IconBoxH = ImgH;
    IconBox2Left = 0.98 - IconBoxW;

    // Figure out where we will start adding them
    ILeft = (1.0 - (Crew.Length * (ImgW + ISpace) - ISpace)) / 2.0;

    TeamColor.A = 70;
    // Add Team Logos, only if not straight deathmatch
    if (myMatchInfo.GameType != "xGame.xDeathmatch") {
        if (TeamId == 0)
            AddImage(TSym, top, 0.02, IconBoxH * 2, IconBoxW * 2).DrawColor = TeamColor;
        else
            AddImage(TSym, top - IconBoxH, IconBox2Left - IconBoxW, IconBoxH * 2, IconBoxW * 2).DrawColor = TeamColor;
    }

    TeamColor.A = 255;

    // Add Crew Portraits
    for (i=0; i<Crew.Length; i++)
    {
        //Log("Crew member "$Crew[i]$" is "$i$" of "$Crew.Length);
        Portrait = FindPlayerInPlayerList(Crew[i]).Portrait;
        AddImage(Portrait, top, ILeft, ImgH, ImgW);
        AddImage(CharFrame, top, ILeft, ImgH, ImgW);
        ILeft = ILeft + ImgW + ISpace;
    }

}

simulated function AddTeamCompare()
{
local array<int> Team1Stat, Team2Stat;
local string TxtFont, tmp;
local float TopLine, LineSpc;
local int i;
local DrawOpText    Op;

    Team1Stat[0] = class'xUtil'.static.TeamAccuracyRating(GameProf);
    Team1Stat[1] = class'xUtil'.static.TeamAggressivenessRating(GameProf);
    Team1Stat[2] = class'xUtil'.static.TeamAgilityRating(GameProf);
    Team1Stat[3] = class'xUtil'.static.TeamTacticsRating(GameProf);

    Team2Stat[0] = class'xUtil'.static.TeamInfoAccuracyRating(EnemyTeamInfo);
    Team2Stat[1] = class'xUtil'.static.TeamInfoAggressivenessRating(EnemyTeamInfo);
    Team2Stat[2] = class'xUtil'.static.TeamInfoAgilityRating(EnemyTeamInfo);
    Team2Stat[3] = class'xUtil'.static.TeamInfoTacticsRating(EnemyTeamInfo);

    TopLine = 0.34;
    LineSpc = 0.425/6;
    TxtFont = "XInterface.UT2HeaderFont";

    Op = AddJustifiedText(StatNames[0], 1, TopLine, 0, LineSpc, 1.0);
    Op.FontName = "XInterface.UT2HeaderFont";  
    Op.DrawColor = Yellow;

    Op = AddJustifiedText(GameProf.TeamName, 1, TopLine, 0.05, LineSpc, 0.40);
    Op.FontName = "Xinterface.UT2HeaderFont";
    Op.DrawColor = Blue;

    Op = AddJustifiedText(EnemyTeamInfo.TeamName, 1, TopLine, 0.55, LineSpc, 0.40);
    Op.FontName = "Xinterface.UT2HeaderFont";
    Op.DrawColor = Red;

    for (i = 1; i<5; i++)
    {
        TopLine += LineSpc;
        AddJustifiedText(StatNames[i], 1, TopLine, 0, LineSpc, 1.0).FontName = "XInterface.UT2HeaderFont";  // Centered
        
        tmp = string(Team1Stat[i-1]);
        tmp = tmp$"%";
        Op = AddJustifiedText(tmp, 1, TopLine, 0.10, LineSpc, 0.30);
        Op.FontName = "Xinterface.UT2HeaderFont";
        if (Team1Stat[i-1] >= Team2Stat[i-1])
            Op.DrawColor = Yellow;

        tmp = string(Team2Stat[i-1]);
        tmp = tmp$"%";
        Op = AddJustifiedText(tmp, 1, TopLine, 0.6, LineSpc, 0.30);
        Op.FontName = "Xinterface.UT2HeaderFont";
        if (Team2Stat[i-1] >= Team1Stat[i-1])
            Op.DrawColor = Yellow;
    }
}

simulated function xUtil.PlayerRecord FindPlayerInPlayerList(string playername) {
    local xUtil.PlayerRecord retval;
    local int i;

    for ( i=0; i< PlayerList.length; i++ ) {
        if ( PlayerList[i].DefaultName == playername ) {
            return PlayerList[i];
        }
    }
    return retval;
}

defaultproperties
{
     White=(B=255,G=255,R=255,A=255)
     Yellow=(G=255,R=255,A=255)
     Blue=(B=255,G=64,R=64,A=255)
     Red=(R=255,A=255)
     Box=Texture'InterfaceContent.Menu.BorderBoxD'
     CharFrame=FinalBlend'InterfaceContent.Menu.CharFrame_Final'
     StatNames(0)="VS"
     StatNames(1)="Accuracy"
     StatNames(2)="Aggressiveness"
     StatNames(3)="Agility"
     StatNames(4)="Tactics"
     LoadingMessage="Loading..."
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fr 30.3.2007 08:43:48.000 - Creation time: Mo 16.4.2007 11:20:57.000 - Created with UnCodeX