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

XInterface.Tab_SPLadderBase


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
// Contains common fonctionality for Ladder Pages
///////////////////////////////////////////////////

class Tab_SPLadderBase extends Tab_SPPanelBase;

var GUIScrollTextBox    ScrollInfo;
var GUIImage            MapPicHolder;
var GUILabel            MapNameLabel;
var LadderButton        ActiveLadderButton;

function UpdateLadderButton(LadderButton Btn, int LadderIndex, int MatchIndex)
{
local GameProfile GP;

    GP = PlayerOwner().Level.Game.CurrentGameProfile;
    if (GP != None)
    {
        if (Btn.MatchInfo == None)
        {
            Btn.MatchInfo = GP.GetMatchInfo(LadderIndex, MatchIndex);
            Btn.MatchIndex = MatchIndex;
            Btn.LadderIndex = LadderIndex;
        }
        Btn.SetState(GP.LadderRung[LadderIndex]);
    }
    else
        Btn.SetState(-1);
}

function LadderButton NewLadderButton(int LadderIndex, int MatchIndex, float Left, float Top)
{
local LadderButton Btn;

    Btn = new class'LadderButton';
    Btn.WinLeft = Left;
    Btn.WinWidth = 0.090234;
    Btn.WinHeight = 0.113672;
    Btn.WinTop = Top;
    Btn.OnClick=MatchButtonClick;
    Btn.OnDblClick=MatchDoubleClick;
    Btn.InitComponent(Controller, Self);
    Controls[Controls.Length] = Btn;
    UpdateLadderButton(Btn, LadderIndex, MatchIndex);
    return Btn;
}

function bool SetActiveMatch(int ladder, out array<LadderButton> Btns)
{
local int Rung;

    Rung = GetProfile().LadderRung[ladder];
    if (Rung < 0 || Rung >= Btns.Length)
    {
        return false;
    }

    if (GetProfile().FindFirstUnfinishedLadder() == ladder)
        Btns[Rung].OnClick(Btns[Rung]);
    else
        ShowMatchInfo(Btns[Rung].MatchInfo);

    return true;
}

// send DoShowMatchInfo to all ladder pages, keeps the images selected
function bool ShowMatchInfo(MatchInfo MI)
{
local GUITabControl TC;
local int i;
local bool retval;

    retval = true;
    TC = MyTabControl();
    if ( MI != None && TC != None )
    {
        for (i = 0; i<TC.Controls.Length; i++)
        {
            if (Tab_SPLadderBase(TC.Controls[i]) != None)
            {
                retval = retval && Tab_SPLadderBase(TC.Controls[i]).DoShowMatchInfo ( MI );
            }
        }
        return retval;
    }

    return false;
}

function bool DoShowMatchInfo(MatchInfo MI) {
local LevelSummary L;
local Material Screenshot;
local string s,mName;
local int p;

    if ( MI == none ) {
        return false;
    }

    // Load MapShot
    L = LevelSummary(DynamicLoadObject(MI.LevelName$".LevelSummary", class'LevelSummary'));

    p = instr(MI.LevelName,"-");
    if (p<0)
        mName = MI.LevelName;
    else
        mName = Right(MI.LevelName,Len(MI.LevelName)-p-1);

    Screenshot = Material(DynamicLoadObject("MapThumbnails.Shot"$mName, class'Material'));

    if (Screenshot==None)
    {
        Screenshot = Material(DynamicLoadObject(MI.LevelName$".Screenshot", class'Material'));
    }
    if (Screenshot==None)
    {
        if (L.ScreenShot==None)
            Screenshot = Material'InterfaceContent.Menu.NoLevelPreview';
        else
            Screenshot = L.Screenshot;
    }
    MapPicHolder.Image = Screenshot;

    if ( MapPicHolder.Image == None )
    {
        MapPicHolder.Image = Material'InterfaceContent.Menu.NoLevelPreview';
    }

    // Set Scroll Content
    s = Controller.LoadDecoText("XMaps",mName);

    ScrollInfo.SetContent(S$class'Tab_IABombingRun'.default.GoalScoreText$":"@int(MI.GoalScore));

    // Set MapName Label
    if ( MI.MenuName != "" )   // replace mapname with menuname if exists
        MapNameLabel.Caption = MI.MenuName;
    else
        MapNameLabel.Caption = L.Title;

    return true;
}

function bool MatchButtonClick(GUIComponent Sender)
{
local LadderButton LButton;
local GameProfile GP;

    GP = GetProfile();
    if ( GP != None && LadderButton(Sender) != None )
    {
        ShowMatchInfo(LadderButton(Sender).MatchInfo);
        LButton=LadderButton(GP.NextMatchObject);
        if (LButton != None)        // Reset to non active state
            LButton.SetState(GP.LadderRung[LButton.LadderIndex]);
        LButton=LadderButton(Sender);
        GP.CurrentLadder = LButton.LadderIndex;
        GP.CurrentMenuRung = LButton.MatchIndex;
        GP.NextMatchObject = LButton;
        LButton.StyleName = "LadderButtonActive";
        LButton.Style = Controller.GetStyle(LButton.StyleName,LButton.FontScale);
        MatchUpdated(LButton.LadderIndex, LButton.MatchIndex);
        if ( GetProfile().ChampBorderObject != none )
            GUIImage(GetProfile().ChampBorderObject).bVisible=false;
    }
    return true;
}

// quick way of hitting 'play'
function bool MatchDoubleClick(GUIComponent Sender)
{
    local UT2SinglePlayerMain SPM;
    // no need to call single button click (matchbuttonclick) first, apparently
    SPM = UT2SinglePlayerMain(MyButton.MenuOwner.MenuOwner);
    return SPM.ButtonClick(SPM.ButtonPlay);
}

function int SetYellowBar(int ladder, int index, out array<LadderButton> Buttons)
{
local int Rung;
local GUIComponent Ctrl;

    Ctrl = Controls[index];

    if (GetProfile() != None)
        Rung = GetProfile().LadderRung[ladder];
    else
        Rung = -1;

    // Reset Lock & Bars pictures
    if (Rung == -1)
    {
        Ctrl.bVisible=false;
    }
    else if (Rung >= Buttons.Length)
    {
        Ctrl.WinTop = Controls[index-1].WinTop;
        Ctrl.WinHeight = Controls[index-1].WinHeight;
        Ctrl.bVisible = true;
        return 1;
    }
    else
    {
        Ctrl.WinTop = Buttons[Rung].WinTop + Buttons[Rung].WinHeight/2;
        Ctrl.WinHeight = Buttons[0].WinTop - Ctrl.WinTop;
        Ctrl.bVisible = true;
    }
    return 0;
}

function bool CanShowPanel()
{
    if ( GetProfile() == none )
        return false;

    return super.CanShowPanel();
}

function Material DLOMaterial(string MaterialFullName)
{
    return Material(DynamicLoadObject(MaterialFullName, class'Material', true));
}

defaultproperties
{
}

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