Combining GuiMLTextCtrl with GuiTextList?
by Robert Fritzen · in Torque 3D Professional · 07/12/2011 (11:45 am) · 14 replies
Because source code is definitely involved here, I have decided to move my discussion to the private forum.
I'm looking to combine the TorqueML features of text with the TextList so I can have different colors and fonts in my text lists. This is mostly going to be used for news listings, colored names in my lobbies, and a few other situations.
How would I go about adding the TorqueML options to a textList (I'm looking to create a new gui control GuiMLTextList)?
I'm looking to combine the TorqueML features of text with the TextList so I can have different colors and fonts in my text lists. This is mostly going to be used for news listings, colored names in my lobbies, and a few other situations.
How would I go about adding the TorqueML options to a textList (I'm looking to create a new gui control GuiMLTextList)?
About the author
Illinois Grad. Retired T3D Developer / Pack Dev.
#2
You can assign the colors by switching the profiles of the row elements.
No source changes required.
07/22/2011 (2:05 pm)
Consider not using the text list, but a stack of guicontainers created dynamically in script. Each guicontainer would be a 'row'.You can assign the colors by switching the profiles of the row elements.
No source changes required.
#3
What happens when you exceed the size of the list (IE: say I max out the players (18-24). You would the need to have it scrolled.
Any input on that route? I would definitely be interested in trimming out source editing from this if possible.
*edit*
I mentioned earlier that profiles on the elements was not a possible route here
my fields would be as so:
[color:clanTagcolor]ClanTag[/color][img:rankicon]UserName
07/23/2011 (2:25 pm)
That was another one of my options, but here's the issued problem.What happens when you exceed the size of the list (IE: say I max out the players (18-24). You would the need to have it scrolled.
Any input on that route? I would definitely be interested in trimming out source editing from this if possible.
*edit*
I mentioned earlier that profiles on the elements was not a possible route here
my fields would be as so:
[color:clanTagcolor]ClanTag[/color][img:rankicon]UserName
#4
Why can't you use profiles, and when did you mention that? Not sure I understand. Profiles can be dynamically generated also.
I use the technique I describe for all list like elements in my game, have different colors based on status and and whether or not it is selected. Works well and easy to use/modify.
for instance a fcn to return a gui element and assign a profile (shortened for brevity):
The internal gui elements can be addressed using the var names I've assigned them (ie in a loop). So to change the profile for the name element (assuming you assign guielement to the row you are addressing):
For ease of creation, I use the gui editor to create a row visually to get it to look as I want, then copy/paste the relevant bits into my code.
07/24/2011 (7:50 am)
The stack goes within a guiscrollctrl.Why can't you use profiles, and when did you mention that? Not sure I understand. Profiles can be dynamically generated also.
I use the technique I describe for all list like elements in my game, have different colors based on status and and whether or not it is selected. Works well and easy to use/modify.
for instance a fcn to return a gui element and assign a profile (shortened for brevity):
function addPlayerListItem(%clanprofile){
%playerrow = new GuiContainer() {
...
};
%playerrow.datablockselector = new GuiPopUpMenuCtrl() {
profile = "GuiPopUpMenuProfile";
position = "220 5";
extent = "150 20";...
};
%playerrow.deletebutton = new GuiButtonCtrl() {
text = "X";...
};
%playerrow.camerabutton = new GuiButtonCtrl() {
text = "C";...
};
%playerrow.selectbutton = new GuiButtonCtrl() {
text = "select";...
};
%playerrow.name = new GuiTextCtrl() {
text = "Name";
profile = %clanprofile;...
};
%playerrow.add(%playerrow.name);
%playerrow.add(%playerrow.datablockselector);
%playerrow.add(%playerrow.selectbutton);
%playerrow.add(%playerrow.camerabutton);
%playerrow.add(%playerrow.deletebutton);
return %playerrow;
}The internal gui elements can be addressed using the var names I've assigned them (ie in a loop). So to change the profile for the name element (assuming you assign guielement to the row you are addressing):
%guielement.name.setProfile("NewProfile");For ease of creation, I use the gui editor to create a row visually to get it to look as I want, then copy/paste the relevant bits into my code.
#5
I'll give this method a shot and report back.
07/24/2011 (7:53 am)
Wow.... I really need to learn more advanced things with torque's gui System. I didn't even notice you could do it that way before x_x. Sorry about that.I'll give this method a shot and report back.
#6
You can then get/set these vars as you need them. ie:
Super extra handy.
07/24/2011 (8:08 am)
One very useful aspect I didnt mention but I use all the time is adding other vars to the row you may need ie:function addPlayerListItem(%clanprofile, %somevar, %someothervar){
...
%playerrow.add(%playerrow.deletebutton);
%playerrow.ausefulvar = %somevar;
%playerrow.anothervar = %someothervar;
return %playerrow;
}You can then get/set these vars as you need them. ie:
somefcnthatneedsthevar(%guirowelement.ausefulvar);
Super extra handy.
#7

Don't mind ze fake players I made up just to test it :P
Thanks for the help.
07/25/2011 (6:30 pm)
well, after getting the code updated, I'm pleased to say that it's looking great.
Don't mind ze fake players I made up just to test it :P
Thanks for the help.
#8
Can grab the actual video file here. (H264 - 1.33MBytes)
Currently Working:
TODO:
And to put things into perspective is the torquescript that populated the test server list during the test video:
:)
07/27/2011 (1:41 pm)
I figured I would post an update here to show off my progress on the very control I've always wanted in Torque since it was gutted out from Tribes 2 codebase that I've been working on in my spare time which is a reimplementation of ShellFancyTextList control:Can grab the actual video file here. (H264 - 1.33MBytes)
Currently Working:
- Columns with headers.
- Per column text alignment attributes, controlled via text keyword flags when using addColumn().
- Columns are now properly draw clipped and columns that are not visible in scroll client space are skipped during rendering.
TODO:
- Reuse torque markup language in row contents to support multicolor text and bitmap images. Might just go ahead and do the same thing for column headers too.
- Sort order rules which are rules that can be added/edited/removed to control how all the columns are ordered instead of the most typical implementation of only one or two columns can be specified for sorting order.
- others that I might be forgetting.
And to put things into perspective is the torquescript that populated the test server list during the test video:
function GameBrowserGui::onDialogPush(%this)
{
%obj = GServerList;
if(%obj.getColumnCount())
return;
// %obj.clearRows();
// %obj.clearColumns();
// %obj.clearSortOrders();
%key = 0;
%obj.addColumn(%key++, "Server Name", 281, 25, 300, "center");
%obj.addColumn(%key++, "Favorite", 50, 25, 75, "center");
%obj.addColumn(%key++, "Status", 50, 25, 75, "center");
%obj.addColumn(%key++, "Ping", 45, 25, 120, "numeric");
%obj.addColumn(%key++, "Mission Name", 100, 25, 300, "center");
%obj.addColumn(%key++, "# Players (Bots)", 155, 25, 150, "center");
%obj.addColumn(%key++, "CPU", 80, 25, 120, "numeric");
%obj.addColumn(%key++, "Address:Port", 170, 25, 200, "right");
%obj.addColumn(%key++, "Game Type", 80, 25, 200, "center");
%obj.addColumn(%key++, "Version", 80, 52, 200, "numeric");
%key = 0;
for(%i=0; %i<50; %i++)
{
%this.AddServer(%key++, "Test Server" @ %key, "Good", getRandom(42, 168), "Mars - Section" @ getRandom(1, 9),
getRandom(0, 28) @ "/28 (00)", getRandom(900, 3300) @ " MHz", "192.168.100.117" @ ":" @ (28000 + %i),
"Team Deathmatch", "201107b");
}
}
function GameBrowserGui::AddServer(%this, %id, %name, %status, %ping, %mission, %players, %cpu, %addr, %type, %version)
{
%fav = "";
%text = %name TAB %fav TAB %status TAB %ping TAB %mission TAB %players TAB %cpu TAB %addr TAB %type TAB %version;
GServerList.addRow(%id, %text);
}
function GTestSlider::OnMouseDragged(%this)
{
// change column Game Type's width size
GServerList.setColumnWidth(8, GTestSlider.getValue());
}:)
#9
07/28/2011 (9:40 am)
Very cool, keep us posted on this. You should resource it when it's done to make it a community enhancement. I'm sure many (including myself) would find a use for it.
#10
08/03/2011 (2:26 pm)
That would be VERY useful!
#11

I plan on posting this as a resource and a blog post explaining how it works anywhere from this weekend to another week or two depending on how much free time I have available to me to get it finished and documented. Until then enjoy the eye candy. :)
08/04/2011 (12:30 pm)
I've been making good progress for the past week during my spare time, so here's what it currently looks like:
I plan on posting this as a resource and a blog post explaining how it works anywhere from this weekend to another week or two depending on how much free time I have available to me to get it finished and documented. Until then enjoy the eye candy. :)
#12
08/05/2011 (7:42 am)
Looks sweet. I'm working on a data heavy project and have had to fix or modify a number of GUI controls to get them to do what I want. Looking forward to trying this out.
#13
08/06/2011 (8:11 am)
Looking forward to this, looks really good so far.
#14
08/22/2011 (7:26 am)
It took me over two weeks later, but I finally did it. I introduce to you GuiModernTextListCtrl. Have fun :)
Torque Owner Nathan Martin
TRON 2001 Network
dottools.net/~tron/imgs/Tribes2_Browser.png
I've looked into it before but I was kind of discouraged once I looked at the quite messing item array code used in GuiTextList.
Edit: Changed embedded image to a link instead.