Jump to content
Sign in to follow this  
falconx1

view distance and terrain grid dialog help

Recommended Posts

i made a test dialog box that i been messing with to try to get it to work. I haven't figured it out. the sliders i can't get to adjust the view distance or terrain grid settings. Can anyone point me in the right direction?

Here is the test dialog box.

http://postimg.org/image/7t53ept8v/

Share this post


Link to post
Share on other sites

You need to calculate the slider position to a value for viewdistance and terraingrid - sorry I can't phrase that better.

Since you posted a picture of the dialog I assume that you already declared all the classes etc in your description.ext. You might have a trigger with something like

nul = createdialog "MyDialogName";

or whatever your classname is for the dialog. This creates the dialog but it doesn't know what to do and hence does nothing :butbut:

Gotta admit I'm also no veteran when it comes to dialogs, put here is a solution that works for me:

Make a script called "Dialog.sqf" in your mission directory and paste the following inside:

Dialog.sqf:

_handle = CreateDialog "MyDialogName";
_viewdistance = 0;
_terraingrid = 50;

[color="#008000"]//The next line puts the viewdistance slider in the position of the current viewdistance. 1900 is the idc value of the viewdistance slider, change value to the idc you use. [/color]
sliderSetPosition [1900, (viewdistance / 500)]; 

while {dialog} do {
_SV =     sliderposition 1900; [color="#008000"]// 1900 is the idc value of the viewdistance slider again, you need to change the value[/color]
_ST =     sliderposition 1901; [color="#008000"]// 1901 is the idc value of the terraingrid slider, you also need to change this off course[/color]
_viewdistance = (_SV * 500);
_terraingrid = (50 - (_ST * 5));

setviewdistance _viewdistance;
setterraingrid _terraingrid;
sleep 0.1;
};

hintsilent format [" Viewdistance: %1                               Terraingrid: %2",_viewdistance,_terraingrid];

Change the idc values and the dialog's classname in the script to whatever you have declared in the description.ext.

Now, in the trigger you used to call your dialog just put:

nul = execVM "Dialog.sqf"

and you should be set.

This example is for a maximum viewdistance of 5000. The terraingrid btw is calculated 'in reverse' because a lower setting means a higher resolution.

Hope that helps! To be honest I think a dialog or maybe even action menu with fixed choices would suit your needs better in this particular case but that's just my opinion.

Share this post


Link to post
Share on other sites

how can i find out which slider images to use?

is there a list i can view somewhere?

i made my own arrows for the left and right arrow boxes too, and set them in the mission main DIR and put: arrowFull = "leftarrow.jpg"; but that didnt work either.

example


thumb = "\A3\ui_f\data\gui\cfg\scrollbar\thumb_ca.paa";
	arrowFull = "\A3\ui_f\data\gui\cfg\scrollbar\arrowFull_ca.paa";
	arrowEmpty = "\A3\ui_f\data\gui\cfg\scrollbar\arrowEmpty_ca.paa";
	border = "\A3\ui_f\data\gui\cfg\scrollbar\border_ca.paa";

Share this post


Link to post
Share on other sites

If the sliders don't move when opening it you need to set the sliderspeed & range.

https://community.bistudio.com/wiki/sliderSetRange

https://community.bistudio.com/wiki/sliderSetSpeed

Additionally if you need an actual example of using sliders you can look at my signature "TAW View Distance Script" it should provide useful reading information.

*Edit* Whoops I skimmed over the entire thing and missed it but regardless my view distance script should provide useful reading information for you.

Share this post


Link to post
Share on other sites

I got the sliders working well the code posted above is rubbish. thanks for putting me in the direction though

here is mine if anyone comes here looking for the same: it's not gold but it works lol

:EDIT Code updated and both sliders now work

_handle = CreateDialog "visualoptions";
                                                     //--- view distance control ID = 1900
                                                     //--- Terrain grid  control ID = 1901
_NewVD = viewDistance;
if (isNil "CurTerrainGrid") then {CurTerrainGrid = 50};
_NewTG = CurTerrainGrid;

SliderSetRange     [1900,500,5000];
SliderSetRange     [1901,1,5];  //--- Set terrain grid slider range to only use numbers 1-5
SliderSetPosition  [1900,_NewVD]; 

//--- Convert numbers to valid ranges.   http://community.bistudio.com/wiki/setTerrainGrid
if (_NewTG == 50)    then {SliderSetPosition[1901,1];};
if (_NewTG == 25)    then {SliderSetPosition[1901,2];};
if (_NewTG == 12.5)  then {SliderSetPosition[1901,3];};
if (_NewTG == 6.25)  then {SliderSetPosition[1901,4];};
if (_NewTG == 3.125) then {SliderSetPosition[1901,5];};

     _OldVD = _NewVD;
  _OldTG = _NewTG;

 while {alive player && dialog} do {

if (!dialog) exitWith {};
_NewVD = sliderposition 1900; 
   _NewTG = Floor (SliderPosition 1901);  //--- Floor to the next lowest integer to make sure every slide is a hit


if (_NewVD != _OldVD) then {setviewdistance _NewVD;

      hintsilent format ["View Distance: %1" , _NewVD];
      _OldVD = _NewVD;
 };


switch (_NewTG) do
{

case 1:
{
	_NewTG = 50;
	setTerrainGrid _NewTG;
};

case 2:
{
	_NewTG = 25;
	setTerrainGrid _NewTG;
};

case 3:
{
	_NewTG = 12.5;
	setTerrainGrid _NewTG;
};

case 4:
{
	_NewTG = 6.25;
	setTerrainGrid _NewTG;
};

case 5:
{
	_NewTG = 3.125;
	setTerrainGrid _NewTG;
  };

 };

   if (_NewTG != _OldTG) then {

            hintsilent format ["Terrain Grid : %1" , _NewTG];

           _OldTG = _NewTG;
       };

      sleep 0.5;

   };

Edited by falconx1

Share this post


Link to post
Share on other sites

:P cheese :butbut: it's true lol. _viewdistance = (_SV * 500); ??

Code updated in my last post above, it works almost perfectly if your looking to make your own feel free to mod the code how ever you want to. or if you want the dialogs and full code to get this added to your missions the download link is below.

Screenshot:

Download Link:

Edited by falconx1

Share this post


Link to post
Share on other sites
:P cheese :butbut: it's true lol. _viewdistance = (_SV * 500); ??

Yes. Given that the normal sliderrange is 10 that seems like somewhat of a legit approach (which works btw). Congratulations on implementing SliderSetRange though.

It's all good, I'm not crying. However a questionable approach to answer somebody who spend 15 minutes trying to help with a thread that had no replies at that time. But you are right, your new code is indeed much better :)

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  

×