Jump to content
Sign in to follow this  
lawman_actual

Fine tuning Support Request GUI

Recommended Posts

Greetings

 

Nearly finished building a UI for requesting various fire missions and so fourth.

 

I still haven't figured out the following:

 

 

 

1) How can I close the radio channel menu after the dialog is called?

 

Pretty simple; the dialog is called via radio alpha. Trouble is, while it is being displayed you can still see the menu for selecting different radio channels.

I'd rather this wasn't the case.

 

 

 

 

2) How can I limit user input within an rscEdit control?

 

Ideally I want the user to only ever be able to enter (for example) a maximum of 4 digits (5 characters):           e.g. 123.4

 

But those 5 characters can't be 1234 or 1.234 or 12.34 etc.

 

Only ever 1 character after the decimal point, but anything up to 3 before

 

I could achieve this more easily by splitting up the whole and half digits, but I really don't want to. It would look ghastly.

 

 

 

Thanks in advance.

Lawman

Share this post


Link to post
Share on other sites

Solution for #2:

_string = ctrlText 1500;
_number = parseNumber _string; //parse into number
_string = str _number; //turn back into string, but a leading zero should be added in the event that the player did not have one. eg. ".1" should now be "0.1"
_output = "Something went wrong.";

if ((count _string) > 5) then
{
	hint "Input is too long.";
} else
{
	_split = [_string, "."] call BIS_fnc_splitString;
	
	_integer = _split select 0;
	_decimal = _split select 1; //should always be correct since we parsed and re-stringed
	
	if ((count _integer) > 3) then
	{
		hint "Integer piece too long.";
	} else
	{
		if ((count _decimal) > 1) then
		{
			hint "Decimal piece too long.";
		} else
		{
			_output = _number;
		};
	};
};
hint str _output;
  • Like 1

Share this post


Link to post
Share on other sites

Thanks very much Entity.

 

I've made some modifications to suit my application a little better:


if (thisIdc == 1400) then {		//only run if the correct control is edited



_string = ctrlText 1400;
_number = parseNumber _string; //parse into number
_string = str _number; //turn back into string, but a leading zero should be added in the event that the player did not have one. eg. ".1" should now be "0.1"
_output = "Invalid coordinate.";


	
	
if ([".", _string, false] call BIS_fnc_inString) then {} else {textDecimal = 0; textInteger = _string; _string = (format ["%1.%2",textInteger,textDecimal]);};		//correction if no decimal is entered
	
	_split = [_string, "."] call BIS_fnc_splitString;			
	textInteger = +_split select 0;							//re-obtain integer
	textDecimal = +_split select 1;							//re-obtain decimal
	
	

	
	if ((count (format["%1",textInteger])) > 3) then
	{
		//hint "Integer piece too long.";
		ctrlSetText [1400, (format["%1",lastGoodEntry])];
		
		
		
		
	} else
	{
		player sideChat (format ["%1",textDecimal]);
		
			if ((count (format ["%1",textDecimal])) > 1) then
			{
			

			ctrlSetText [1400, (format["%1",lastGoodEntry])];
			
			} else
			{
			
			
			lastGoodEntry = _string;
			
			
			};
	};
};

///END OF TEXT CHECKER

Now it stores your 'last good entry' as a variable and auto-corrects if you exceed the integer or decimal limit as you type.

Since this is fired each time a readable character is typed in the Idc, it should correct to the last thing you entered before breaching the limit.

 

Also I have converted some local variables to global because I was encountering "undefined variable" errors and got fed up trying to make it work with locals.

Lazy scripting perhaps, but it works....for now.

 

The only remaining problem (aside from still not knowing how to hide the radio channels) is that 0 isn't being picked up in the length checking.

 

 

For example:

 

If i enter 123.45 it is corrected to 123.4

 

But if I enter 123.04, the 0 isn't picked up and for some reason it allows it.

 

 

I can't spot why this might be at the moment

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  

×