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

GUI2K4.UT2K4Tab_MidGameRulesCombo


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
//==============================================================================
//  Created on: 01/21/2004
//  This is a combination of the Rules & Maplist panels
//  Used for full-screen mid-game menus.
//
//  Written by Ron Prestenback
//  © 2003, Epic Games, Inc. All Rights Reserved
//==============================================================================

class UT2K4Tab_MidGameRulesCombo extends MidGamePanel;

struct AServerRule
{
    var string RuleName, RuleValue;
};

var() noexport array<AServerRule> ServerRules;

var noexport  GUIList    li_Maps;
var noexport  GUIMultiColumnList li_Rules;
var automated GUISectionBackground sb_Rules, sb_Maps;
var automated GUIListBox lb_Maps;
var automated GUIMultiColumnListBox lb_Rules;

var() localized string DefaultRulesText, DefaultMapsText;

var() bool bReceivedRules, bReceivedMaps;
var() bool bClient;

function InitComponent(GUIController InController, GUIComponent InOwner)
{
    Super.InitComponent(InController, InOwner);

    li_Rules = lb_Rules.List;
    li_Maps = lb_Maps.List;

    li_Rules.bInitializeList = false;
    li_Maps.bInitializeList = false;

    li_Maps.TextAlign = TXTA_Center;
    li_Maps.Add(DefaultMapsText);

    li_Rules.SortColumn = -1;
    li_Rules.OnDrawItem = DrawServerRule;

    sb_Rules.ManageComponent(lb_Rules);
    sb_Maps.Managecomponent(lb_Maps);
}

function ShowPanel(bool bShow)
{
    Super.ShowPanel(bShow);
    if ( bShow && (!bReceivedRules || !bReceivedMaps) )
    {
        SetTimer(1.0, True);
        Timer();
    }
}

function Timer()
{
    local xPlayer PC;

    PC = xPlayer(PlayerOwner());

    if ( PC == None )
    {
        bReceivedMaps = true;
        bReceivedRules = true;
        KillTimer();
        return;
    }

    if ( !bReceivedRules )
    {
        PC.ProcessRule = ProcessRule;
        PC.ServerRequestRules();
    }

    else if ( !bReceivedMaps )
    {
        PC.ProcessMapName = ProcessMapName;
        PC.ServerRequestMapList();
    }
}

function ProcessRule(string NewRule)
{
    local AServerRule Rule;

    bReceivedRules = true;
    if ( NewRule == "" )
    {
        ServerRules.Remove(0, ServerRules.Length);
        li_Rules.Clear();
    }
    else
    {
        if ( Divide(NewRule, "=", Rule.RuleName, Rule.RuleValue) )
        {
            ServerRules[ServerRules.Length] = Rule;
            li_Rules.AddedItem();
        }
    }
}

function ProcessMapName( string MapName )
{
    bReceivedMaps = true;
    if ( MapName == "" )
        li_Maps.Clear();
    else li_Maps.Add(MapName);
}

function bool RightClick( GUIComponent Sender )
{
    local PlayerController PC;

    if ( Controller.ActiveControl != li_Maps )
        return false;

    PC = PlayerOwner();
    if ( PC.Level.NetMode == NM_StandAlone )
        return true;

    if ( PC.PlayerReplicationInfo != None && PC.PlayerReplicationInfo.bAdmin )
        return true;

    return false;
}

function ContextClick(GUIContextMenu Sender, int Index)
{
    local PlayerController PC;
    local string MapName;

    PC = PlayerOwner();
    MapName = li_Maps.Get();

    // TODO Add handler for response from server
    if (MapName != "")
    {
        if ( Index == 0 )
        {
            if ( PC.Level.NetMode == NM_StandAlone )
                Console(Controller.Master.Console).DelayedConsoleCommand("open"@MapName);
            else if ( PC.Level.NetMode == NM_ListenServer )
                Console(Controller.Master.Console).DelayedConsoleCommand("switch"@MapName);
            else PC.AdminCommand("switch"@MapName);

            Controller.CloseAll(False,True);
        }
        else if ( Index == 1 )
            PC.AdminCommand("maplist del"@MapName);
    }
}

function DrawServerRule(Canvas Canvas, int i, float X, float Y, float W, float H, bool bSelected, bool bPending)
{
    local float CellLeft, CellWidth;

    li_Rules.GetCellLeftWidth( 0, CellLeft, CellWidth );
    li_Rules.Style.DrawText( Canvas, li_Rules.MenuState, CellLeft, Y, CellWidth, H, TXTA_Left, ServerRules[i].RuleName, li_Rules.FontScale );

    li_Rules.GetCellLeftWidth( 1, CellLeft, CellWidth );
    li_Rules.Style.DrawText( Canvas, li_Rules.MenuState, CellLeft, Y, CellWidth, H, TXTA_Left, ServerRules[i].RuleValue, li_Rules.FontScale );
}

defaultproperties
{
     Begin Object Class=AltSectionBackground Name=sbRules
         bFillClient=Wahr
         Caption="Server Rules"
         WinTop=0.020438
         WinLeft=0.023625
         WinWidth=0.944875
         WinHeight=0.455783
         bBoundToParent=Wahr
         bScaleToParent=Wahr
         OnPreDraw=sbRules.InternalPreDraw
     End Object
     sb_Rules=AltSectionBackground'GUI2K4.UT2K4Tab_MidGameRulesCombo.sbRules'

     Begin Object Class=AltSectionBackground Name=sbMaps
         bFillClient=Wahr
         Caption="Map Rotation"
         WinTop=0.482921
         WinLeft=0.055125
         WinWidth=0.881875
         WinHeight=0.436125
         bBoundToParent=Wahr
         bScaleToParent=Wahr
         OnPreDraw=sbMaps.InternalPreDraw
     End Object
     sb_Maps=AltSectionBackground'GUI2K4.UT2K4Tab_MidGameRulesCombo.sbMaps'

     Begin Object Class=GUIListBox Name=ComboMaplistBox
         SelectedStyleName="BrowserListSelection"
         bVisibleWhenEmpty=Wahr
         OnCreateComponent=ComboMaplistBox.InternalOnCreateComponent
         StyleName="ServerBrowserGrid"
         WinTop=0.045905
         WinLeft=0.517829
         WinWidth=0.478167
         WinHeight=0.922516
         bBoundToParent=Wahr
         bScaleToParent=Wahr
     End Object
     lb_Maps=GUIListBox'GUI2K4.UT2K4Tab_MidGameRulesCombo.ComboMaplistBox'

     Begin Object Class=GUIMultiColumnListBox Name=ComboRulesListbox
         bDisplayHeader=Falsch
         HeaderColumnPerc(0)=0.600000
         HeaderColumnPerc(1)=0.400000
         SelectedStyleName="BrowserListSelection"
         bVisibleWhenEmpty=Wahr
         OnCreateComponent=ComboRulesListbox.InternalOnCreateComponent
         StyleName="ServerBrowserGrid"
         WinTop=0.045905
         WinLeft=0.008213
         WinWidth=0.478167
         WinHeight=0.922516
         bBoundToParent=Wahr
         bScaleToParent=Wahr
     End Object
     lb_Rules=GUIMultiColumnListBox'GUI2K4.UT2K4Tab_MidGameRulesCombo.ComboRulesListbox'

     DefaultRulesText="Receiving game rules from server"
     DefaultMapsText="Receiving maplist from server"
     Begin Object Class=GUIContextMenu Name=ComboContextMenu
         ContextItems(0)="Switch to this map"
         ContextItems(1)="Remove this map from rotation"
         OnSelect=UT2K4Tab_MidGameRulesCombo.ContextClick
     End Object
     ContextMenu=GUIContextMenu'GUI2K4.UT2K4Tab_MidGameRulesCombo.ComboContextMenu'

     OnRightClick=UT2K4Tab_MidGameRulesCombo.RightClick
}

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