Jump to content
Sign in to follow this  
Bnae

RscListBox & scrollBar

Recommended Posts

Hello!

 

I'm having a lot of issues with this RscListBox and the https://community.bistudio.com/wiki/DialogControls-ListBoxesis not helping at all.

I'm trying to create a listBox with scrollBar on the side. However half of the commands from the biki ain't working for me.

 

I had ScrollBar class on the RscListBox but i removed it since it didn't do anything. I know i should.

 

 

Exec dialog with addAction

 

decription.ext

class RscListBox 
{
	idc = -1;
	access = 0;
	type = 5;
	style = 0 + 0x10;
	font = "PuristaLight";
	sizeEx = 0.05221;
        rowHeight = 0.05;
	colorText[] = {1, 1, 1, 0.75};
	period = 0;
	colorBackground[] = {0, 0, 0, 0.3};
	maxHistoryDelay = 1.0;
	autoScrollSpeed = -1;
	autoScrollDelay = 5;
	autoScrollRewind = 0;
	shadow = 0;
};

class Sample {

	movingEnable = false;
	idd = 10001;
	onLoad = "ExecVM 'test.sqf'";
	
	class controls 
	{
		class listboxtest : RscListBox 
		{
			idc = 10002;
 			x = 0.043;
			y = 0.167676;
			w = 0.45;
			h = 0.144;
		};
	};
};

test.sqf

{lbAdd[10002,_x]} forEach ["Listbox 1","Listbox 2","Listbox 3","Listbox 4","Listbox 5","Listbox 6","Listbox 7","Listbox 8"];

I don't know what this test.sqf does, except it shows the text..

 

 

 

This is all i can get working and i cannot modify it all. Well except font/ font color, and background color.

 

And this pops up every time i exec the dialog.

No entry 'blaa/blaa/blaa/blaa/blaa/mission.Altis/description.ext/Sample/controls/listboxtest.colorDisabled'.

I cannot find any tutorials about RscListBox so this is kinda hard to figure out.

If you know there is tutorial somewhere, please link it here.

(I'm aware how to make dialogs in common, example: buttons with actions/ frames/ boxes etc)

Share this post


Link to post
Share on other sites

You need to have colorDisabled member in your class. It is an array with 4 elements. You are missing a lot of color-based members. You also need the scrollbar class.

 

I recommend looking at BIS's RscListBox in the config viewer to see what you are missing.

Share this post


Link to post
Share on other sites

You need to have colorDisabled member in your class. It is an array with 4 elements. You are missing a lot of color-based members. You also need the scrollbar class.

 

I recommend looking at BIS's RscListBox in the config viewer to see what you are missing.

 

 

This fixed my errors, and now i were able to add those other commands.

colorDisabled[] = {};

Now i have to figure out how to make actions with this listBox.

Share this post


Link to post
Share on other sites

Okay, now that i got my menu created i'm still facing this one problem.

 

 

description.ext

class BNAE_vehicleDialog {

	movingEnable = false;
	idd = 10001;
	onLoad = "ExecVM 'test.sqf'";
	
	class controls 
	{
		class BNAE_listbox : RscListBox 
		{
			idc = 10002;
			onLBSelChanged = hint "1"; // for testing
			onLBDblClick = execVM "core\vehicle\fn_vehicleType.sqf";
 			x = 0.043;
 			y = 0.167676;
 			w = 0.45;
 			h = 0.124;
 		};
 	};
};

Dialog is called from object with

this addAction ["Dialog","createDialog 'BNAE_vehicleDialog'"];

I don't know how to create a "line" in the listBox, so that onLBDblClick will effect on that line. By "line" i mean the option in the listBox, example "Search".

Now those lines are called with that onLoad = execVM "test.sqf" and thats not the correct way.

 

The action from execVM "core\vehicle\fn_vehicleType.sqf" is done and working. Just not sure if it's the correct way to exec that function of mine.

Share this post


Link to post
Share on other sites

It looks correct to me, although you may want to pass some information to your script

class BNAE_vehicleDialog {

	movingEnable = false;
	idd = 10001;
	onLoad = "ExecVM 'test.sqf'";
	
	class controls 
	{
		class BNAE_listbox : RscListBox 
		{
			idc = 10002;
			onLBSelChanged = systemChat str [_this select 0, (_this select 0) lbText (_this select 1), (_this select 0) lbData (_this select 1)]; // system chat an array [current_control, current control text of selected element, data of selected]
			onLBDblClick = [(_this select 0) lbText (_this select 1)]execVM "core\vehicle\fn_vehicleType.sqf"; //pass text of double clicked element to the script
 			x = 0.043;
 			y = 0.167676;
 			w = 0.45;
 			h = 0.124;
 		};
 	};
};

Options should be added to the script using the scripting command lbAdd. I don't know if you changed/added more color members to your lb definition, so if the options are not showing up in the listbox, it is possible that the text color is the same as the background color. Try clicking around in the listbox in a few places, if anything gets selected then you need to change the color of the text.

  • Like 1

Share this post


Link to post
Share on other sites

It looks correct to me, although you may want to pass some information to your script

class BNAE_vehicleDialog {

	movingEnable = false;
	idd = 10001;
	onLoad = "ExecVM 'test.sqf'";
	
	class controls 
	{
		class BNAE_listbox : RscListBox 
		{
			idc = 10002;
			onLBSelChanged = systemChat str [_this select 0, (_this select 0) lbText (_this select 1), (_this select 0) lbData (_this select 1)]; // system chat an array [current_control, current control text of selected element, data of selected]
			onLBDblClick = [(_this select 0) lbText (_this select 1)]execVM "core\vehicle\fn_vehicleType.sqf"; //pass text of double clicked element to the script
 			x = 0.043;
 			y = 0.167676;
 			w = 0.45;
 			h = 0.124;
 		};
 	};
};

Options should be added to the script using the scripting command lbAdd. I don't know if you changed/added more color members to your lb definition, so if the options are not showing up in the listbox, it is possible that the text color is the same as the background color. Try clicking around in the listbox in a few places, if anything gets selected then you need to change the color of the text.

 

Those will help finding the problems, thanks.

 

Now the issue is that, i don't know how to make multiple different functions in same RscListBox.

So double clicking Listbox 1 will exec fn_vehicleType.sqf and Listbox 2 will exec fn_secondscript.sqf etc.?

 

The actual listbox is working fine now and the first function aswell.

Share this post


Link to post
Share on other sites

Now the issue is that, i don't know how to make multiple different functions in same RscListBox.

So double clicking Listbox 1 will exec fn_vehicleType.sqf and Listbox 2 will exec fn_secondscript.sqf etc.?

There are probably a couple of ways to do this, however, I would just use one script with a switch.

 

Change your on double click to this:

onLBDblClick = ((_this select 0) lbText (_this select 1)) execVM "core\vehicle\fn_dialog_switch.sqf";

 

The name could be whatever you want, honestly. Then the code would be:

fn_dialog_switch.sqf

switch (_this) do
{
	case "Buy Vehicle":
	{
		execVM "core\vehicle\fn_buyVeh.sqf";
	}
	case "Sell Vehicle":
	{
		execVM "core\vehicle\fn_sellVeh.sqf";
	}
	case "Quit":
	{
		execVM "core\vehicle\fn_quit.sqf";
	}
	default
	{
		systemChat "Selected option was not found, closing dialog";
		closeDialog 0;
	}
};

Note that you could just pass (_this select 1) to the script in the double click event, then use an integer switch, as well. Probably not as helpful though because if you decide to change the order of the menu, you'll have to modify the switch too

Share this post


Link to post
Share on other sites

This might be me being stupid but i think thats not the thing i'm looking for.

That would be useful if the first step was finished.

 

At the moment, if i have that

{lbAdd[10002,_x]} forEach ["Listbox 1","Listbox 2","Listbox 3","Listbox 4","Listbox 5","Listbox 6","Listbox 7","Listbox 8"];

So when i execute that dialog in game it will show up with nice looking listBox with scollBar, with 8 different lines called Linebox 1, Linebox 2 etc.

But no matter which one i double click, it'll run the same function.

 

To make examples easier we can use 2 lines

{lbAdd[10002,_x]} forEach ["Listbox 1","Listbox 2"];

I'm trying to make this work on my own, but i'm getting no results without help. So i'm grateful that you're willing to help me.

Share this post


Link to post
Share on other sites

Instead of execVM "core\vehicle\fn_vehicleType.sqf", if you execVM a different script that contains a switch, you will be able to run different code depending on which element you have selected

  • Like 1

Share this post


Link to post
Share on other sites

Instead of execVM "core\vehicle\fn_vehicleType.sqf", if you execVM a different script that contains a switch, you will be able to run different code depending on which element you have selected

 

Ahh, i don't know what i messed up yesterday but i got it working now. Maybe i thought it work differently and that's why modified in wrongly. apparently it was me being stupid..

I hope this topic helps others aswell.

 

Thank you for your help dreadedentity!

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
Sign in to follow this  

×