Jump to content

Recommended Posts

I am trying to create a type of leaderboard on a dialog menu, where it will display stats such as their overall ranking in the list, name, kills, deaths, ect. 

 

The best example of the result i am trying to recreate would be the server browser:

h6v96Ot.png

 

I have tried to use the Table Dialog Control but have failed, looking for some help with trying to get this type of dialog to work as it seems to be the best option available.

The example they provide seems to only have the base defines from what I saw and when I try to create a row or header row with the commands, I get no result and no error:

 

Add Row - https://community.bistudio.com/wiki/ctAddRow

Add Header Row - https://community.bistudio.com/wiki/ctAddHeader

 

With from my "extensive research", literally no online existing help, I've come here ...

If you know how to actually use this type of dialog control, please help. Thank You!

Share this post


Link to post
Share on other sites

I don't have any experience with the ControlsTable either and it seems to be a rather unused asset as the CT_CONTROLS_TABLE isn't even included in the export function BIS_fnc_exportGUIBaseClasses with the "all" parameter. I have looked through the config for the server browser and BIS doesn't use it either. Instead they are going for a RscListBox:

Spoiler

class CA_ValueSessions: RscListBox
{
  idc=102;
  style=16;
  colorPingUnknown[]={0.40000001,0.40000001,0.40000001,1};
  colorSelect[]={0,0,0,1};
  colorPingGood[]={0,1,0,1};
  colorPingPoor[]={1,0.60000002,0,1};
  colorPingBad[]={1,0,0,1};
  password="a3\ui_f\data\gui\rsc\rscdisplaymultiplayer\sessions_password_ca.paa";
  locked="a3\ui_f\data\gui\rsc\rscdisplaymultiplayer\sessions_locked_ca.paa";
  allowedFilePatching="a3\ui_f\data\gui\rsc\rscdisplaymultiplayer\sessions_version_ca.paa";
  version="a3\ui_f\data\gui\rsc\rscdisplaymultiplayer\sessions_version_ca.paa";
  none="a3\ui_f\data\gui\rsc\rscdisplaymultiplayer\sessions_none_ca.paa";
  star="a3\ui_f\data\gui\rsc\rscdisplaymultiplayer\sessions_star_ca.paa";
  addons="a3\ui_f\data\gui\rsc\rscdisplaymultiplayer\sessions_addons_ca.paa";
  mods="a3\ui_f\data\gui\rsc\rscdisplaymultiplayer\sessions_mods_ca.paa";
  serverLike="a3\ui_f\data\gui\rsc\rscdisplaymultiplayer\mp_serverlike_ca.paa";
  serverDislike="a3\ui_f\data\gui\rsc\rscdisplaymultiplayer\mp_serverdislike_ca.paa";
  serverEmpty="a3\ui_f\data\gui\rsc\rscdisplaymultiplayer\mp_serverempty_ca.paa";
  sizeEx="(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 0.8)";
  x="1.2 *(((safezoneW / safezoneH) min 1.2) / 40) + 		(SafezoneX)";
  y="safezoneY + (5.9 *((((safezoneW / safezoneH) min 1.2) / 1.2) / 25))";
  w="SafezoneW - (2.4 *(((safezoneW / safezoneH) min 1.2) / 40))";
  h="SafezoneH - (17.3 *((((safezoneW / safezoneH) min 1.2) / 1.2) / 25))";
  class Columns
  {
    class ColumnFavorite
    {
      x="1.2 *(((safezoneW / safezoneH) min 1.2) / 40) +(SafezoneX)";
      w="(2 *(((safezoneW / safezoneH) min 1.2) / 40))";
    };
    class ColumnServer
    {
      x="2.7 *(((safezoneW / safezoneH) min 1.2) / 40) +(SafezoneX)";
      w="(11 *(((safezoneW / safezoneH) min 1.2) / 40)) + 0.45*(safezoneW -((safezoneW / safezoneH) min 1.2))";
    };
    class ColumnType
    {
      x="safezoneX + (15 *(((safezoneW / safezoneH) min 1.2) / 40)) + 0.45*(safezoneW -((safezoneW / safezoneH) min 1.2))";
      w="3 *(((safezoneW / safezoneH) min 1.2) / 40)";
    };
    class ColumnMission
    {
      x="safezoneX + (18.3 *(((safezoneW / safezoneH) min 1.2) / 40)) + 0.45*(safezoneW -((safezoneW / safezoneH) min 1.2))";
      w="(10.5 *(((safezoneW / safezoneH) min 1.2) / 40)) + 0.45*(safezoneW -((safezoneW / safezoneH) min 1.2))";
    };
    class ColumnState
    {
      x="safezoneX + (29.1 *(((safezoneW / safezoneH) min 1.2) / 40)) + 0.9*(safezoneW -((safezoneW / safezoneH) min 1.2))";
      w="3 *(((safezoneW / safezoneH) min 1.2) / 40)";
    };
    class ColumnPlayers
    {
      x="safezoneX + (32.4 *(((safezoneW / safezoneH) min 1.2) / 40)) + 0.9*(safezoneW -((safezoneW / safezoneH) min 1.2))";
      w="3 *(((safezoneW / safezoneH) min 1.2) / 40)";
    };
    class ColumnPing
    {
      x="safezoneX + (35.7 *(((safezoneW / safezoneH) min 1.2) / 40)) + 0.9*(safezoneW -((safezoneW / safezoneH) min 1.2))";
      w="3 *(((safezoneW / safezoneH) min 1.2) / 40)";
    };
  };
};

 

 

I will try to replicate something like this but if someone is faster then here you go :)

  • Like 1

Share this post


Link to post
Share on other sites

Okay after all the solution is simpler than I thought. Try to use the RscListNBox. If you are doing a stat board then this one should be enough. The advantage of the TableControl is the possiblity to add controls other than text to it, like a button or a picture and then assign an idc to it so you can access it later.

  • Like 2

Share this post


Link to post
Share on other sites

Unfortunately RscListNBox only got me so far in finding something that replicates the server browser. From the looks of it they lined up buttons to match the columns in the list but I am still unsure how the server browser is made because I cannot find any "column" functionality with RscListBox as they use it for the server browser so my guess is that its using the table dialog type but all the defines in config.bin point to using RscListBox.

 

I am aware that RscListNBox can create columns, but with the server browser they are able to add tool tips to certain column items and can click on column cell items such as the favorites icon without selecting the entire row which both RscListBox and RscListNBox cannot do.

Share this post


Link to post
Share on other sites

Gonna split this post in two because different topics.

 

So about the Server Browser and ListNBox.

It consists of one top line of buttons which, when clicked on, sort the ListNBox below. This also means that they are not part of the listbox and can be handled (tooltip, selected) seperatly. Aligning them is not that intuitive though. I made a mission to show how I would do it:

 

GitHub mission

 

description.ext

Spoiler

#include "defines.hpp"
#include "dialog.hpp"

 

 

defines.hpp is way too long to post here. The basic defines should do.

 

dialog.hpp

Spoiler

class TER_lnbSort
{
	idd = 7300;
	onLoad = "[""onLoad"",_this] execVM ""loadTest.sqf"";";
	class controlsBackground
	{
		class back: RscText
		{
			colorBackground[] = {0,0,0,0.8};
			x = -16.5 * GUI_GRID_W + 0.5;
			y = -6.5 * GUI_GRID_H + 0.5;
			w = 33 * GUI_GRID_W;
			h = 15.5 * GUI_GRID_H;
		};
		class title: RscStructuredText
		{
			text = "Column Sort"; //--- ToDo: Localize;
			colorBackground[]={0.8,0.5,0,1};
			x = -16.5 * GUI_GRID_W + 0.5;
			y = -7.6 * GUI_GRID_H + 0.5;
			w = 33 * GUI_GRID_W;
			h = 1 * GUI_GRID_H;
		};
	};
	class controls
	{
		#define W_LNB (32 * GUI_GRID_W)
		class lnbEntries: RscListNBox
		{
			idc = 1500;
			columns[] = {0, 2.5/6, 5/6};
			x = -16 * GUI_GRID_W + 0.5;
			y = -5 * GUI_GRID_H + 0.5;
			w = W_LNB;
			h = 12 * GUI_GRID_H;
		};
		class grpSortBtns: RscControlsGroup
		{
			idc = 2300;
			x = -16 * GUI_GRID_W + 0.5;
			y = -6 * GUI_GRID_H + 0.5;
			w = W_LNB;
			h = 1 * GUI_GRID_H;
			class Controls
			{
				class btnSortCol1: RscButtonTextOnly
				{
					idc = 2400;
					text = "Sort Column 1";
					style=ST_LEFT;
					colorFocused[]={1,1,1,0.5};
					colorFocused2[]={1,1,1,0.1};
					period=1.2;
					x = 0;
					y = 0;
					w = 2.5/6 * W_LNB;
					h = GUI_GRID_H;
				};
				class btnSortCol2: btnSortCol1
				{
					idc = 2401;
					text = "Sort Column 2";
					x = 2.5/6 * W_LNB;
				};
				class btnSortCol3: btnSortCol1
				{
					idc = 2402;
					text = "Sort Column 3";
					x = 5/6 * W_LNB;
					w = 1/6 * W_LNB;
				};
			};
		};
		class btnCancel: RscButtonMenuCancel
		{
			x = 8 * GUI_GRID_W + 0.5;
			y = 7.5 * GUI_GRID_H + 0.5;
			w = 8 * GUI_GRID_W;
			h = 1 * GUI_GRID_H;
		};
		class btnOK: RscButtonMenuOK
		{
			x = -16 * GUI_GRID_W + 0.5;
			y = 7.5 * GUI_GRID_H + 0.5;
			w = 8 * GUI_GRID_W;
			h = 1 * GUI_GRID_H;
		};
	};
};

 

 

loadTest.sqf

Spoiler

_mode = _this#0;
_this = _this#1;

switch (_mode) do
{
case "onLoad":
{
	_this params ["_display"];
	_lnbEntries = _display displayCtrl 1500;
	_cfgs = "true" configClasses (configFile >> "CfgVehicles");
	_names = _cfgs apply {[_x] call BIS_fnc_displayname};
	_cfgNames = _cfgs apply {configName _x};
	for "_i" from 0 to 30 do {
		_rInd = floor random (count _cfgs);
		_ind = _lnbEntries lnbAddRow [_cfgNames#_rInd, _names#_rInd, str _rInd];
		_lnbEntries lnbSetValue [[_ind,2],_rInd];
	};

	for "_idc" from 2400 to 2402 do {
		_btn = _display displayCtrl _idc;
		_btn setVariable ["reverseSort",false];
		_btn ctrlAddEventHandler ["ButtonClick",{
			["sortCol",[ctrlParent (_this#0)] +_this] execVM "loadTest.sqf";
		}];
	};
};
case "sortCol":{
	params ["_display","_ctrl"];
	_lnbEntries = _display displayCtrl 1500;
	_column = [2400,2401,2402] find ctrlIDC _ctrl;
	_reverse = _ctrl getVariable "reverseSort";
	if (_column == 2) then {
		_lnbEntries lnbSortByValue [_column,_reverse];
	} else {
		_lnbEntries lnbSort [_column,_reverse];
	};
	_ctrl setVariable ["reverseSort",!_reverse];
};
};

 

 

As you will see I am keeping the buttons together inside of a controlsGroup and use the relative width of the listbox to get the horizontal position. The magic of sorting happens in the loadTest.sqf script where I fille the listNbox with random vehicle configs, assign an EH to the buttons and then find the correct column to sort by the idc of the button. The command lnbSort(ByValue) does the rest. Because the third column contains numbers they have to be set as values on the column. Otherwise they will be sorted by their string which would put "100" before "2". To keep track of if the order should be ascending or descending I set a boolean variable which gets inverted after each click.

 

8 hours ago, NumbNutsJunior said:

I cannot find any "column" functionality with RscListBox as they use it for the server browser

Yeah sometimes BIS is hiding things from us. Might be handled by the engine. But I don't know ¯\_(ツ)_/¯.

 

Next post: RscControlsTable

Share this post


Link to post
Share on other sites

Kinda made it working here:

 

 

(first post contains link to the files, see GUI.hpp, RscInhabitants)

 

roster-1.jpg

 

Found no way to fill it with custom controls, thus all customization done via scripting, using "ct" commands. Most fields are in fact buttons. 

 

 

 

Share this post


Link to post
Share on other sites

I've figured out how the CT_CONTROLS_TABLE is used.

 

First of all you have to add a new line to the defines you already got (where all the control types (CT_) are defined).

#define CT_CONTROLS_TABLE 0x13 //19

There is no base class for this control type so create either a new one by copying the example from the BIKI page or copy the BIKI entry to your dialog's controls and adjust the position. All important attributes are explained well on the BIKI by a BI dev. When the control is created it doesn't show as long as there are no entries. Here is a piece of code that shows the basic functionality of (kind of reproduces the BIKI example, but in bad):

params ["_display"];
_table = _display displayCtrl 107;
_header = ctAddHeader _table;
_header#1 params ["_txtBack","_picCol1","_txtCol2"];
_picCol1 ctrlSetText "\a3\ui_f\data\igui\cfg\revive\overlayiconsgroup\u100_ca.paa";
_txtCol2 ctrlSetText "Test Table";
_txtBack ctrlSetBackgroundColor [0,0,1,1];
for "_i" from 0 to 2 do {
	_newRow = ctAddRow _table;
	_newRow#1 params ["_txtBack","_picCol1","_txtCol2","_btnCol3"];
	_picCol1 ctrlSetText "\a3\ui_f\data\igui\cfg\revive\overlayicons\d100_ca.paa";
	_txtCol2 ctrlSetText "Some long text";
	_btnCol3 ctrlSetText "CLICK ME!";
};

 

It seems that this control type hasn't (yet) been used in A3 but in Argo. Sorting the colums is probably not such a great idea as there are no commands for it.

Share this post


Link to post
Share on other sites
13 hours ago, 7erra said:

There is no base class for this control type

There is, it is RscControlsTable. Although there are no example/default header/row templates as far as I know.

 

As for sorting a controls table, headers are not selectable and you would want rows as you data. As there can only be one header and one row template per controlsTable you would need to add external buttons to re-order the rows, mush like @7erra did above for listNBox.

Or create a secondary controls table that only has a row template with buttons as your headers/sort selection which refreshes a secondary tables data.

TEST_MISSION

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×