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
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
{
	// Buddy list box
	Begin Object Class=Browser_BuddyList Name=TheBuddyList
	End Object

	Begin Object Class=GUIMultiColumnListBox Name=BuddyListBox
		WinLeft=0
		WinTop=0
		WinWidth=1
		WinHeight=1
		bVisibleWhenEmpty=True
		Controls(0)=TheBuddyList
		StyleName="ServerBrowserGrid"
	End Object

	// Buddy panel
	Begin Object Class=GUIPanel Name=BuddyPanel
		Controls(0)=BuddyListBox;
	End Object

	// Splitter to divide buddies and rules horizontally
	Begin Object Class=GUISplitter Name=BuddySplitter
		WinWidth=1.0
		WinHeight=1.0
		WinTop=0
		WinLeft=0
		Controls(0)=BuddyPanel
		SplitOrientation=SPLIT_Horizontal
		SplitPosition=0.25
		Background=DefaultTexture
		bBoundToParent=true
		bScaleToParent=true
	End Object
	BudSplit=BuddySplitter

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

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Di 5.9.2006 22:36:28.000 - Creation time: Do 14.8.2014 09:58:35.585 - Created with UnCodeX