PDA

View Full Version : UE2 - UT2kX GUIMultiColumnList


ottoISI
16th Sep 2004, 01:27 PM
Has anyone any experience with the GUIMultiColumnList class, or any of it's subclasses like Browser_PlayersList or Browser_ServersList? I can't seem to get the control to display, even after initializing the member variables and executing it's functions...

Or, does anyone know about using Tab stops, specifically in GUIScrollTextBox?

Thanks in advance, we are trying to make a student progress report for some trainng software.

-Ross

Evolution
17th Sep 2004, 02:46 AM
I wrote alot of those classes, but I don't know why your list isn't appearing (in fact, I don't even really know what your question is). The only things I know are:


you're using a GUIMultiColumnList
it isn't appearing
you're possibly using a GUIScrollTextBox
you have a question about tab stops, but you don't indicate what you want to know about them


Check out this thread: http://forums.beyondunreal.com/showthread.php?t=109192

psamty10
20th Sep 2004, 03:04 PM
Basically, we're looking for documentation on how to use the AdminPlayerList class.

What I've tried to do thus far is to Hardcode certain elements into the list, to figure out what we need to do later. There is a test script posted below for your reference. The list appears as long as at least one item is in the list, but the items themselves do not show up - just wondering if you see something that strikes you as obviously wrong.

Thanks,
Prasan


class TestGUIMultiColumnList extends GUIPage;

function InitComponent(GUIController MyController, GUIComponent MyOwner)
{
local AdminPlayerList myList;
super.InitComponent(MyController, MyOwner);

myList = AdminPlayerList(Controls[0]);

myList.MyPlayers[0].PlayerID = "Pras";
myList.MyPlayers[0].PlayerIP = "Pras";
myList.MyPlayers[0].PlayerName = "Pras";
myList.MyPlayers[1].PlayerID = "Pras";
myList.MyPlayers[1].PlayerIP = "Pras";
myList.MyPlayers[1].PlayerName = "Pras";
myList.ItemCount += 2;
myList.AddedItem();

}

defaultproperties
{
Begin object class=AdminPlayerList name=Test
WinWidth=0.8
WinLeft=0.1
WinHeight=0.8
WinTop=0.1
End object

Controls(0) = GUIMultiColumnList'Test'

bAllowedAsLast=True
bDisconnectOnOpen=True
WinHeight=1.000000
}

Bonehed316
22nd Sep 2004, 03:07 PM
I'm about to begin work on one of these lists myself, and if I were you I'd consider the default properties of these classes. Namely the column names. From what I recall, it uses this to determine how many columns there are, and how big to make each. My guess is that your list shows up, but no colums, or headings. You really didnt say.

ColumnHeadings(0)="Player Name"
ColumnHeadings(1)="Unique ID"
ColumnHeadings(2)="IP"
InitColumnPerc(0)=0.3
InitColumnPerc(1)=0.4
InitColumnPerc(2)=0.3

Evolution
3rd Oct 2004, 02:42 PM
Basically, we're looking for documentation on how to use the AdminPlayerList class.

What I've tried to do thus far is to Hardcode certain elements into the list, to figure out what we need to do later. There is a test script posted below for your reference. The list appears as long as at least one item is in the list, but the items themselves do not show up - just wondering if you see something that strikes you as obviously wrong.

Thanks,
Prasan

I see now (and sorry about the late response - I don't think I ever received an email notification). The AdminPlayerList is broken in UT2004, so I wouldn't recommend using that as an example.

Anyway, there are a few more steps necessary to get a GUIMultiColumnList to work correctly. From the native standpoint, a GUIMultiColumnList is essentialy a list of indexes, and its only purpose is to sort this list of indexes based on the criteria you specify. What these indexes represent is entirely up to you. Generally, they would correspond to an index into some array that you have already filled with data.

As bonehead said, the number of columns your MC list will have is determined by the number of elements in its ColumnHeadings/InitColumnPerc arrays. Actually, that's a little inaccurate - the MC list has no concept of multiple columns - ColumnHeadings/InitColumnPerc determines how many column *headers* the list will have (but in all fairness, it amounts to essentially the same thing). It's still up to you to draw the actual column data, which brings me to..

GetSortData - whenever you call AddedItem(), UpdatedItem(), RemovedItem(), etc., the list will call the GetSortData delegate. It uses the result to how to sort its list of indexes - when the user clicks on a different column header, the list will once again call GetSortData for each of the items in its SortData array - this allows you to give the list different sort criteria depending on which column is currently the "SortColumn" of the list, by branching inside your GetSortData handler.

OnDrawItem - Since the list itself doesn't know anything about the data its keeping track of, it's up to you to draw those items. Each tick, the list will call its OnDrawItem with the index into the its SortData array. The correct index into your own array would be located at List.SortData[Index].SortItem.

You can try using the UT2K4Tab_MidGameRulesCombo class as a reference, as that is probably the simplest example of using a MC list correctly. The only problem with that class is that it doesn't want its MC list to allow sorting (by setting the list's SortColumn to -1), so you'll notice that in the DrawServerRule function, I uses i as the direct index into the ServerRules array. I did this because I knew that I wasn't sorting the list, but the correct way to write that would have been more like:

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[li_Rules.SortData[i].SortIndex].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[li_Rules.SortData[i].SortIndex].RuleValue, li_Rules.FontScale );
}

Also, since there is no sorting, I didn't implement a handler for GetSortItem. For a complete (albeit a little more complex) example, I'd recommend looking over the KeyBindMenu class. This class has alot of stuff going on, but most of it is irrelevant in terms of learning about MC lists. The important functions there are:
ListGetSortString() - this is the handler for the list's GetSortString. If the SortColum is 0, we return the keybind's label, since we want to draw the keybind labels in the first column, etc.

InternalOnCreateComponent - this allows you to initialize any list properties before InitComponent has been called on the list

DrawBinding - this is where the actual drawing takes place...notice that right off the bat, I convert the Item index by doing
Item = li_Binds.SortData[Item].SortItem;

By doing that, Item is now the index into the Bindings array, rather than the index into the list's SortData array.

Hope this helps!

UT04 Killa
25th May 2011, 04:50 AM
Does anyone have a working solution to this? I want to create a mod and want to create a list/menu with the following being listed for all the players in the server.


Player Name
Player Unique ID
Player IP


I seen something like this.

function f(PlayerReplicationInfo Who)
{
local string address;
local string playerip;
local string playerport;
local PlayerController controller;
controller=PlayerController(Who.Owner);
address=controller.GetPlayerNetworkAddress();
if (address!="") {
playerip=left(address,instr(address,":"));
playerport=right(address,len(address)-instr(address,":")-1);
} else {
playerip="0.0.0.0";
playerport="0";
}
// here you have the ip and port into vars playerip, playerport.
}

&


// ====================================================================
// (C) 2002, Epic Games
// ====================================================================

class AdminPlayerList extends GUIMultiColumnList;

struct PlayerInfo
{
var string PlayerName;
var string PlayerID;
var string PlayerIP;
};

var array<PlayerInfo> MyPlayers;
var GUIStyles SelStyle;

function Clear()
{
MyPlayers.Remove(0,MyPlayers.Length);
Super.Clear();
}

function Add(string PlayerInfo)
{
local string s;
local int i,idx;

idx = MyPlayers.Length;
MyPlayers.Length = MyPlayers.Length+1;

i = instr(PlayerInfo,chr(27));
s = left(PlayerInfo,i);
MyPlayers[idx].PlayerName=s;
PlayerInfo = right(PlayerInfo,Len(PlayerInfo)-i-1);

i = instr(PlayerInfo,chr(27));
s = left(PlayerInfo,i);
MyPlayers[idx].PlayerID=s;
PlayerInfo = right(PlayerInfo,Len(PlayerInfo)-i-1);

MyPlayers[idx].PlayerIP = PlayerInfo;
ItemCount++;
AddedItem();

}

function InitComponent(GUIController MyController, GUIComponent MyOwner)
{
OnDrawItem = MyOnDrawItem;
OnKeyEvent = InternalOnKeyEvent;
Super.Initcomponent(MyController, MyOwner);

SelStyle = Controller.GetStyle("SquareButton",FontScale);

}

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

if( bSelected )
{
Canvas.SetDrawColor(128,8,8,255);
Canvas.SetPos(x,y-2);
Canvas.DrawTile(Controller.DefaultPens[0],w,h+2,0,0,1,1);
Canvas.SetDrawColor(255,255,255,255);
}

GetCellLeftWidth( 0, CellLeft, CellWidth );
Style.DrawText( Canvas, MenuState, X+CellLeft, Y, CellWidth, H, TXTA_Left, MyPlayers[i].PlayerName, FontScale);

GetCellLeftWidth( 1, CellLeft, CellWidth );
Style.DrawText( Canvas, MenuState, X+CellLeft, Y, CellWidth, H, TXTA_Left, MyPlayers[i].PlayerID, FontScale);

GetCellLeftWidth( 2, CellLeft, CellWidth );
Style.DrawText( Canvas, MenuState, X+CellLeft, Y, CellWidth, H, TXTA_Left, MyPlayers[i].PlayerIP, FontScale);
}

defaultproperties
{
ColumnHeadings(0)="Player Name"
ColumnHeadings(1)="Unique ID"
ColumnHeadings(2)="IP"
InitColumnPerc(0)=0.3
InitColumnPerc(1)=0.4
InitColumnPerc(2)=0.3
SortColumn=-1
WinHeight=1
}


Not sure how to display in/on a menu for each player. I remember a couple years ago, I had an admin panel like this, but lost it. :(

Can anyone help me out, please? Give me some examples. Not just tell me to read/download UnrealScript source code or download UnCodeX. I have all that. Just kind of frustrating. Thank you in advance.