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

GUI2K4.UT2K4SP_HighScores


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
//==============================================================================
// Single Player highscore list
//
// Written by Michiel Hendriks
// (c) 2003, Epic Games, Inc. All Rights Reserved
//==============================================================================

class UT2K4SP_HighScores extends UT2K4GUIPage;

var automated GUIImage imgBackground, imgDraw;
var automated GUIButton btnExport;
var automated GUIVertScrollBar sbScores;

/** highscore data file */
var SPHighScore HS;
/** used for drawing */
var float curY, incY, lineHeight;
/** finished scrolling the list */
var bool bFinished;
/** hilight this entry, pass an int value on HandleParameters to set it */
var int HilighEntry;
/** start drawing from this entry */
var int startoffset;
var GUIFont MainFont, TinyFont;

var localized string ColumnHeaders[4];
var localized string ClickToExit;

var array<xUtil.PlayerRecord> PlayerList;
var SpinnyWeap          SpinnyDude; // MUST be set to null when you leave the window
var vector              SpinnyDudeOffset;
var int                 nfov;

function InitComponent(GUIController MyController, GUIComponent MyOwner)
{
    Super.Initcomponent(MyController, MyOwner);
    HS = PlayerOwner().Level.Game.LoadDataObject(class'GUI2K4.SPHighScore', "SPHighScore", class'UT2K4SP_Main'.default.HighScoreFile);
    if (HS == none)
    {
        Log("UT2K4SP_HighScores - UT2004HighScores doesn't exist, creating...");
        HS = PlayerOwner().Level.Game.CreateDataObject(class'GUI2K4.SPHighScore', "SPHighScore", class'UT2K4SP_Main'.default.HighScoreFile);
    }
    MainFont = new class'fntUT2k4Large';
    TinyFont = new class'fntUT2k4Small';
    bInit = false;
    startoffset = 0;
    sbScores.ItemCount = HS.Scores.length;
    sbScores.ItemsPerPage = 10;
    sbScores.BigStep = 5;
    sbScores.CurPos = startoffset;

    class'xUtil'.static.GetPlayerList(PlayerList);
    // Spawn spinning character actor
    if ( SpinnyDude == None )
        SpinnyDude = PlayerOwner().spawn(class'XInterface.SpinnyWeap');

    SpinnyDude.SetDrawType(DT_Mesh);
    SpinnyDude.SetDrawScale(0.9);
    SpinnyDude.SpinRate = 2004;
    SpinnyDude.bPlayCrouches = false;
    SpinnyDude.bPlayRandomAnims = true;
    SpinnyDude.AnimChangeInterval = 5.0;
    SpinnyDude.AnimNames.length = 0;
    SpinnyDude.AnimNames[0] = 'idle_rest';
    SpinnyDude.AnimNames[1] = 'idle_rest';
    SpinnyDude.AnimNames[2] = 'idle_rest';
    SpinnyDude.AnimNames[3] = 'idle_rest';
    SpinnyDude.AnimNames[4] = 'idle_rest';
    SpinnyDude.AnimNames[5] = 'gesture_cheer';
    SpinnyDude.AnimNames[6] = 'gesture_taunt01';
    SpinnyDude.AnimNames[7] = 'gesture_taunt02';
    SpinnyDude.AnimNames[8] = 'pthrust';
    UpdateSpinnyDude();
}

event HandleParameters(string Param1, string Param2)
{
    SetTimer(0.02, true);
    HilighEntry = -1;
    if (Param1 != "") HilighEntry = int(Param1);
    else {
        bFinished = true;
        bTimerRepeat = false;
        TimerInterval = 0;
        sbScores.bVisible=true;
    }
}

event Opened( GUIComponent Sender )
{
    local rotator R;

    super.Opened(Sender);

    if ( SpinnyDude != None )
    {
        R.Yaw = 32768;
        SpinnyDude.SetRotation( R + PlayerOwner().Rotation );
    }
}

event Timer()
{
    if (!bInit) return;
    curY += incY;
    if (curY >= (lineHeight/2))
    {
        bFinished = true;
        bTimerRepeat = false;
        TimerInterval = 0;
        sbScores.bVisible=true;
        //btnExport.bVisible = true;
    }
}

function bool InternalOnDraw(canvas Canvas)
{
    local vector CamPos, X, Y, Z;
    local rotator CamRot;
    local float   oOrgX, oOrgY;
    local float   oClipX, oClipY;

    oOrgX = Canvas.OrgX;
    oOrgY = Canvas.OrgY;
    oClipX = Canvas.ClipX;
    oClipY = Canvas.ClipY;

    Canvas.OrgX = imgDraw.ActualLeft();
    Canvas.OrgY = imgDraw.ActualTop();
    Canvas.ClipX = imgDraw.ActualWidth();
    Canvas.ClipY = imgDraw.ActualHeight();

    canvas.GetCameraLocation(CamPos, CamRot);
    GetAxes(CamRot, X, Y, Z);

    SpinnyDude.SetLocation(CamPos + (SpinnyDudeOffset.X * X) + (SpinnyDudeOffset.Y * Y) + (SpinnyDudeOffset.Z * Z));
    canvas.DrawActorClipped(SpinnyDude, false,  imgDraw.ActualLeft(), imgDraw.ActualTop(), imgDraw.ActualWidth(), imgDraw.ActualHeight(), true, nFOV);
    Canvas.OrgX = oOrgX;
    Canvas.OrgY = oOrgY;
    Canvas.ClipX = oClipX;
    Canvas.ClipY = oClipY;

    OnDrawScores(Canvas);
    return false;
}

function OnDrawScores(Canvas Canvas)
{
    local int i;
    local float cX, cY, outX, outY;
    local float columns[5]; // collumn width

    if (!bInit)
    {
        lineHeight = Canvas.SizeY/11;
        if (!bFinished) curY = -1*HS.Scores.length*lineHeight;
        else curY = lineHeight/2;
        incY = Canvas.SizeY*0.01;
        bInit = true;
    }

    Canvas.Reset();
    Canvas.Style = 5;
    cY = CurY;
    cX = Canvas.SizeX*0.05;
    columns[0] = cX*2;                  // 10%
    columns[1] = columns[0]+cX*7;       // 35%
    columns[2] = columns[1]+cX*6;       // 30%
    columns[3] = columns[2]+cX*2;       // 10%
    columns[4] = columns[3]+cX*2;       // 10%
    for (i = 0; i < HS.Scores.length; i++)
    {
        if (cY > Canvas.SizeY) break;
        if (i+startoffset >= HS.Scores.length) break;
        if (cY+lineHeight > 0)
        {
            if (MainFont != None) Canvas.Font = MainFont.GetFont(Canvas.SizeX / 3);
            if (HilighEntry == i+startoffset) Canvas.SetDrawColor(255, 225, 0, 255); // highlight this line
            else if (HS.Scores[i+startoffset].bDrone) Canvas.SetDrawColor(255, 255, 255, 128); // not a real player
            else Canvas.SetDrawColor(255, 255, 255, 255);

            Canvas.DrawTextJustified((i+startoffset+1)$". ", 2, 0, cY, columns[0], cY+lineHeight);
            Canvas.DrawTextJustified(HS.Scores[i+startoffset].Name, 0, columns[0], cY, columns[2], cY+lineHeight);
            Canvas.StrLen(HS.Scores[i+startoffset].Name, outX, outY);
            Canvas.DrawTextJustified(class'UT2K4GameProfile'.static.MoneyToString(HS.Scores[i+startoffset].Balance), 2, columns[0], cY, columns[2], cY+lineHeight);
            Canvas.DrawTextJustified(string(HS.Scores[i+startoffset].Matches), 2, columns[2], cY, columns[3], cY+lineHeight);
            Canvas.DrawTextJustified(string(HS.Scores[i+startoffset].Wins), 2, columns[3], cY, columns[4], cY+lineHeight);

            if (TinyFont != None)
                Canvas.Font = TinyFont.GetFont(Canvas.SizeX);

//			Canvas.DrawTextJustified(class'UT2K4SPTab_ProfileNew'.default.DifficultyLevels[int(HS.Scores[i+startoffset].Difficulty)], 0, columns[0], cY+lineHeight-(outY/2), columns[1], cY+lineHeight);
            Canvas.DrawTextJustified(class'UT2K4SPTab_ProfileNew'.default.DifficultyLevels[int(HS.Scores[i+startoffset].Difficulty)], 0, columns[0], cY+outY+(LineHeight*0.2), columns[1], cY+lineHeight);
        }
        cY += lineHeight;
        if (bFinished && i == 9) break;
    }
    if (bFinished)
    {
        Canvas.SetDrawColor(255, 255, 255, 196);
        cY = lineHeight*0.1;
        if (TinyFont != None) Canvas.Font = TinyFont.GetFont(Canvas.SizeX);
        Canvas.DrawTextJustified(ColumnHeaders[0], 1, columns[0], cY, columns[1], cY+(lineHeight/2));
        Canvas.DrawTextJustified(ColumnHeaders[1], 1, columns[1], cY, columns[2], cY+(lineHeight/2));
        Canvas.DrawTextJustified(ColumnHeaders[2], 1, columns[2], cY, columns[3], cY+(lineHeight/2));
        Canvas.DrawTextJustified(ColumnHeaders[3], 1, columns[3], cY, columns[4], cY+(lineHeight/2));
        Canvas.CurX = cX/2;
        Canvas.DrawHorizontal(cY+(lineHeight/2), cX*18.5); // 90%

        if (TinyFont != None) Canvas.Font = TinyFont.GetFont(Canvas.SizeX);
        Canvas.TextSize(ClickToExit, outX, outY);
        outY *= 1.005;
        Canvas.SetDrawColor(0, 0, 0, 196);
        Canvas.DrawTextJustified(ClickToExit, 1, 0+Canvas.SizeX*0.001, (Canvas.SizeY-outY)*1.001, Canvas.SizeX*1.001, Canvas.SizeY*1.001);
        Canvas.SetDrawColor(226, 196, 0, 196);
        Canvas.DrawTextJustified(ClickToExit, 1, 0, Canvas.SizeY-outY, Canvas.SizeX, Canvas.SizeY);
    }
}

function bool OnImgClick(GUIComponent Sender)
{
    Log(Sender);
    return Controller.CloseMenu(false);
}

function bool OnExportClick(GUIComponent Sender)
{
    local GUIQuestionPage QPage;
    ExportToFile();
    if (Controller.OpenMenu("GUI2K4.GUI2K4QuestionPage"))
    {
        QPage=GUIQuestionPage(Controller.TopPage());
        QPage.SetupQuestion("High scores saved to: ..\\UserLogs\\UT2004_HighScores.txt", QBTN_Ok, QBTN_Ok);
    }
    return true;
}

function ExportToFile()
{
    local int i;
    local FileLog output;
    output = PlayerOwner().Spawn(class'FileLog');
    output.OpenLog("UT2004_HighScores", "txt");
    output.Logf(chr(9)$"name"$chr(9)$"balance"$chr(9)$"matches"$chr(9)$"wins");
    output.Logf("--------------------------------------------------------------------------------");
    for (i = 0; i < HS.Scores.length; i++)
    {
        output.Logf(string(i+1)$chr(9)$HS.Scores[i].Name$chr(9)$string(HS.Scores[i].Balance)$chr(9)$string(HS.Scores[i].Matches)$chr(9)$string(HS.Scores[i].Wins));
    }
    output.CloseLog();
}

function bool WindowOnKeyEvent(out byte Key, out byte State, float delta)
{
    if (!bFinished) return false;
    if (State != 1) return false;
    if ((Key == 0x26) || (Key == 236)) //up
    {
        sbScores.WheelUp();
        return true;
    }
    else if ((Key == 0x28) || (Key == 237)) //down
    {
        sbScores.WheelDown();
        return true;
    }
    // debug stuff
    else if (Key == 0x32) // 2
    {
        SpinnyDudeOffset.X = SpinnyDudeOffset.X+1;
    }
    else if (Key == 0x31) // 1
    {
        SpinnyDudeOffset.X = SpinnyDudeOffset.X-1;
    }
    else if (Key == 0x34) // 4
    {
        SpinnyDudeOffset.Y = SpinnyDudeOffset.Y+1;
    }
    else if (Key == 0x33) // 3
    {
        SpinnyDudeOffset.Y = SpinnyDudeOffset.Y-1;
    }
    else if (Key == 0x36) // 6
    {
        SpinnyDudeOffset.Z = SpinnyDudeOffset.Z+1;
    }
    else if (Key == 0x35) // 5
    {
        SpinnyDudeOffset.Z = SpinnyDudeOffset.Z-1;
    }
    else  if (Key == 0x38) // 8
    {
        SpinnyDude.SpinRate = SpinnyDude.SpinRate+1;
    }
    else  if (Key == 0x37) // 7
    {
        SpinnyDude.SpinRate = SpinnyDude.SpinRate-1;
    }
    else if (Key == 0x30) // 0
    {
        Log("SpinnyDudeOffset ="@SpinnyDudeOffset@" SpinnyDudeSpinRate ="@SpinnyDude.SpinRate);
    }

    return false;
}

function OnScrollPosChanged(int NewPos)
{
    startoffset=NewPos;
}

function UpdateSpinnyDude()
{
    local int idx;
    local xUtil.PlayerRecord Rec;
    local Mesh PlayerMesh;
    local Material BodySkin, HeadSkin;
    local string BodySkinName, HeadSkinName;
    local UT2K4GameProfile GP;

    GP = UT2K4GameProfile(PlayerOwner().Level.Game.CurrentGameProfile);
    if (GP != none)
    {
        if (GP.bCompleted && (GP.PlayerCharacter ~= "Mr.Crow"))
        {
            PlayerMesh = Mesh(DynamicLoadObject("GenericSD.TC", class'Mesh'));
            SpinnyDude.LinkMesh(PlayerMesh);
            SpinnyDude.Skins[0] = texture(DynamicLoadObject("GenericSD.ToiletCar", class'Texture'));
            SpinnyDudeOffset=vect(354.00,0.00,-19.00);
            SpinnyDude.bPlayRandomAnims = false;
            return;
        }
        if (GP.bCompleted)
        {
            if (HS.UnlockedChars.length > 0)
                BodySkinName = HS.UnlockedChars[HS.UnlockedChars.length-1];
        }
    }

    idx = -1;
    if (BodySkinName != "")
    {
        for (idx = 0; idx < Playerlist.length; idx++)
        {
            if (PlayerList[idx].DefaultName ~= BodySkinName) break;
        }
        BodySkinName = "";
    }

    if (idx >= Playerlist.Length || idx == -1) idx = rand(Playerlist.Length);
    if ( idx < 0 || idx >= Playerlist.Length )
        return;

    Rec = PlayerList[idx];

    if (Rec.Race ~= "Juggernaut" || Rec.DefaultName~="Axon" || Rec.DefaultName~="Cyclops" || Rec.DefaultName ~="Virus" )
        SpinnyDudeOffset=vect(273.0,0.00,-11.00);
    else
        SpinnyDudeOffset=vect(273.0,0.00,-17.00);

    PlayerMesh = Mesh(DynamicLoadObject(Rec.MeshName, class'Mesh'));
    if(PlayerMesh == None)
    {
        Log("Could not load mesh: "$Rec.MeshName$" for player: "$Rec.DefaultName);
        return;
    }

    // Get the body skin
    BodySkinName = Rec.BodySkinName;

    // Get the head skin
    HeadSkinName = Rec.FaceSkinName;

    BodySkin = Material(DynamicLoadObject(BodySkinName, class'Material'));
    if(BodySkin == None)
    {
        Log("Could not load body material: "$Rec.BodySkinName$" For player: "$Rec.DefaultName);
        return;
    }

    HeadSkin = Material(DynamicLoadObject(HeadSkinName, class'Material'));
    if(HeadSkin == None)
    {
        Log("Could not load head material: "$HeadSkinName$" For player: "$Rec.DefaultName);
        return;
    }

    SpinnyDude.LinkMesh(PlayerMesh);
    SpinnyDude.Skins[0] = BodySkin;
    SpinnyDude.Skins[1] = HeadSkin;
    SpinnyDude.LoopAnim( 'Idle_Rest', 1.0/SpinnyDude.Level.TimeDilation );
}

function Free()
{
    Super.Free();
    if ( SpinnyDude != None ) SpinnyDude.Destroy();
    SpinnyDude = None;
}

defaultproperties
{
     Begin Object Class=GUIImage Name=SPMimgBackground
         Image=MaterialSequence'2K4Menus.Controls.background_anim'
         ImageStyle=ISTY_Scaled
         ImageRenderStyle=MSTY_Normal
         WinHeight=1.000000
         RenderWeight=0.001000
         bAcceptsInput=Wahr
         bNeverFocus=Wahr
         OnClick=UT2K4SP_HighScores.OnImgClick
         OnKeyEvent=UT2K4SP_HighScores.WindowOnKeyEvent
     End Object
     imgBackground=GUIImage'GUI2K4.UT2K4SP_HighScores.SPMimgBackground'

     Begin Object Class=GUIImage Name=SPMimgDraw
         WinHeight=1.000000
         RenderWeight=0.002000
         bAcceptsInput=Wahr
         bNeverFocus=Wahr
         OnDraw=UT2K4SP_HighScores.InternalOnDraw
         OnClick=UT2K4SP_HighScores.OnImgClick
         OnKeyEvent=UT2K4SP_HighScores.WindowOnKeyEvent
     End Object
     imgDraw=GUIImage'GUI2K4.UT2K4SP_HighScores.SPMimgDraw'

     Begin Object Class=GUIButton Name=SPMbtnExport
         Caption="SAVE TO FILE"
         FontScale=FNS_Small
         WinTop=0.950000
         WinLeft=0.400000
         WinWidth=0.200000
         WinHeight=0.004000
         RenderWeight=0.200000
         bVisible=Falsch
         OnClick=UT2K4SP_HighScores.OnExportClick
         OnKeyEvent=SPMbtnExport.InternalOnKeyEvent
     End Object
     btnExport=GUIButton'GUI2K4.UT2K4SP_HighScores.SPMbtnExport'

     Begin Object Class=GUIVertScrollBar Name=SPMsbScores
         PositionChanged=UT2K4SP_HighScores.OnScrollPosChanged
         WinLeft=0.962500
         WinWidth=0.037500
         WinHeight=1.000000
         RenderWeight=1.000000
         bVisible=Falsch
         OnPreDraw=SPMsbScores.GripPreDraw
     End Object
     sbScores=GUIVertScrollBar'GUI2K4.UT2K4SP_HighScores.SPMsbScores'

     ColumnHeaders(0)="name"
     ColumnHeaders(1)="balance"
     ColumnHeaders(2)="matches"
     ColumnHeaders(3)="wins"
     ClickToExit="C L I C K   T O   E X I T"
     SpinnyDudeOffset=(X=273.000000,Z=-11.000000)
     nfov=15
     WinTop=0.000000
     WinHeight=1.000000
     OnKeyEvent=UT2K4SP_HighScores.WindowOnKeyEvent
}

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