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

XInterface.Browser_ServerListPageBuddy


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
class Browser_ServerListPageBuddy extends Browser_ServerListPageMS;

// Actual list of buddies
var() config array<String> Buddies;

var GUISplitter       MainSplit;
var GUISplitter       BudSplit;
var Browser_BuddyList MyBuddyList;
var localized string AddBuddyCaption;
var localized string RemoveBuddyCaption;

var bool BuddyInitialized;

function InitComponent(GUIController C, GUIComponent O)
{
    Super.InitComponent(C, O);

    if( !BuddyInitialized )
    {
        MainSplit = GUISplitter(Controls[0]);

        // Set one half of the buddy splitter to be the servers panel
        BudSplit.Controls[1] = MainSplit.Controls[0];

        // Set the buddy splitter as one half of the main splitter
        MainSplit.Controls[0] = BudSplit;

        // Init the budsplit
        BudSplit.InitComponent(C, MainSplit);
    }

    MyBuddyList = Browser_BuddyList( GUIMultiColumnListBox(GUIPanel(BudSplit.Controls[0]).Controls[0]).Controls[0] );
    MyBuddyList.MyBuddyPage = self;
    MyBuddyList.ItemCount = Buddies.Length;

    // Change server list spacing a bit
    MyServersList.InitColumnPerc[0]=0.1;
    MyServersList.InitColumnPerc[1]=0.25;
    MyServersList.InitColumnPerc[2]=0.15;
    MyServersList.InitColumnPerc[3]=0.125;
    MyServersList.InitColumnPerc[4]=0.125;

    // This page has a REFRESH LIST button
    GUIButton(GUIPanel(Controls[1]).Controls[6]).OnClick=MyRefreshClick;
    GUIButton(GUIPanel(Controls[1]).Controls[6]).Caption=RefreshCaption;
    GUIButton(GUIPanel(Controls[1]).Controls[6]).bVisible=true;

    // take over the "Add Favorite" button for "Add Buddy".
    GUIButton(GUIPanel(Controls[1]).Controls[7]).OnClick=AddBuddyClick;
    GUIButton(GUIPanel(Controls[1]).Controls[7]).Caption=AddBuddyCaption;

    // add "Remove Buddy" button
    GUIButton(GUIPanel(Controls[1]).Controls[4]).OnClick=RemoveBuddyClick;
    GUIButton(GUIPanel(Controls[1]).Controls[4]).Caption=RemoveBuddyCaption;

    StatusBar.WinWidth=0.6;

    BuddyInitialized = True;
}

function bool MyRefreshClick(GUIComponent Sender)
{
    Super.MyRefreshClick(Sender);
    return true;
}

function RefreshList()
{
    local int i;
    local MasterServerClient.QueryData QD;

    MyServersList.Clear();

    // Construct query containing all buddy names
    i = Buddies.Length;
    MSC.Query.Length = i;

    for(i=0; i<Buddies.Length; i++)
    {
        QD.Key          = "buddy";
        QD.Value        = Buddies[i];
        QD.QueryType    = QT_Equals;
        MSC.Query[i] = QD;
    }

    // Run query
    MSC.StartQuery(CTM_Query);

    StatusBar.SetCaption(StartQueryString);
    SetTimer(0, false); // Stop it going back to ready from a previous timer!
}

// Add a new buddy to your list
function bool AddBuddyClick(GUIComponent Sender)
{
    if ( Controller.OpenMenu("xinterface.Browser_AddBuddy") )
        Browser_AddBuddy(Controller.TopPage()).MyBuddyPage = self;

    return true;
}

// Remove current buddy from your list
function bool RemoveBuddyClick(GUIComponent Sender)
{
    if(MyBuddyList.Index < 0 || MyBuddyList.Index >= Buddies.Length)
        return true;

    Buddies.Remove(MyBuddyList.Index, 1);

    MyBuddyList.ItemCount = Buddies.Length;

    SaveConfig();
    return true;
}

defaultproperties
{
     Begin Object Class=GUISplitter Name=BuddySplitter
         SplitOrientation=SPLIT_Horizontal
         SplitPosition=0.250000
         Background=Texture'Engine.DefaultTexture'
         Begin Object Class=GUIPanel Name=BuddyPanel
             Begin Object Class=GUIMultiColumnListBox Name=BuddyListBox
                 bVisibleWhenEmpty=True
                 Begin Object Class=Browser_BuddyList Name=TheBuddyList
                     OnPreDraw=TheBuddyList.InternalOnPreDraw
                     OnClick=TheBuddyList.InternalOnClick
                     OnRightClick=TheBuddyList.InternalOnRightClick
                     OnMousePressed=TheBuddyList.InternalOnMousePressed
                     OnMouseRelease=TheBuddyList.InternalOnMouseRelease
                     OnKeyEvent=TheBuddyList.InternalOnKeyEvent
                     OnBeginDrag=TheBuddyList.InternalOnBeginDrag
                     OnEndDrag=TheBuddyList.InternalOnEndDrag
                     OnDragDrop=TheBuddyList.InternalOnDragDrop
                     OnDragEnter=TheBuddyList.InternalOnDragEnter
                     OnDragLeave=TheBuddyList.InternalOnDragLeave
                     OnDragOver=TheBuddyList.InternalOnDragOver
                 End Object
                 Controls(0)=Browser_BuddyList'XInterface.Browser_ServerListPageBuddy.TheBuddyList'

                 OnCreateComponent=BuddyListBox.InternalOnCreateComponent
                 StyleName="ServerBrowserGrid"
                 WinHeight=1.000000
             End Object
             Controls(0)=GUIMultiColumnListBox'XInterface.Browser_ServerListPageBuddy.BuddyListBox'

         End Object
         Controls(0)=GUIPanel'XInterface.Browser_ServerListPageBuddy.BuddyPanel'

         WinHeight=1.000000
         bBoundToParent=True
         bScaleToParent=True
     End Object
     BudSplit=GUISplitter'XInterface.Browser_ServerListPageBuddy.BuddySplitter'

     AddBuddyCaption="ADD BUDDY"
     RemoveBuddyCaption="REMOVE BUDDY"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mon 23/10/2006 20:30:38.000 - Creation time: Wed 7/2/2007 19:16:35.343 - Created with UnCodeX