Jump to content
Atom_Monky

Esc key toggle rsc

Recommended Posts

Hi,

i want a rsc dialog showing up while you are in the main menue and it should close alter pressing esc again.

 

this is the code im currently testing with but the waitUntil seems to be different in the esc menu.

createEndInfoDialog = {
		
	hint "t1";
	disableSerialization;
	15 cutRsc ["endroundinfo","PLAIN"];

	waituntil {!(IsNull (findDisplay 46))};
	
	15 cutFadeOut 2;
	hint "t2";
};

waituntil {!(IsNull (findDisplay 46))};  
keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 0x01) then {_this call createEndInfoDialog }"];

im starting the test mssion in MP mode because SP pauses the game.

Share this post


Link to post
Share on other sites
4 hours ago, Atom_Monky said:

while you are in the main menue

4 hours ago, Atom_Monky said:

waitUntil seems to be different in the esc menu

I presume you actually mean the escape menu when you say main menu?

There is an event script for when the pause menu is shown (pauseOnLoad.sqf).

Creating you ctrls in the pause menu display (RscDisplayInterrupt) will automatically hide them when the pause menu is closed.

Maybe this thread will help?

  • Like 1

Share this post


Link to post
Share on other sites
8 hours ago, Larrow said:

Maybe this thread will help?


thanks a lot. 
exactly what i needed  :don11:

description.ext
onPauseScript = "script.sqf";

script.sqf
disableSerialization;

params[ "_pauseMenu" ];

createDialog "onPauseUI"; //Your UI

_pauseMenu displayAddEventHandler [ "Unload", {
	//When pause menu exits, close dialog
	closeDialog 1;
}];

 

Share this post


Link to post
Share on other sites

Sorry to reopen the question but i cant get onPauseScript to work in mp mission.
i use        _db_id = player getVariable ["db_id",0];         in my script but read somthing about                missionNamespace getVariable "myVar"     ?

 

and even a simple test 

description.ext
onPauseScript = "test.sqf";

test.sqf
diag_log format["####################################### test.sqf +++++++++++++++++++++++++++++"];

dose not work, what am i doing wrong ?

Share this post


Link to post
Share on other sites
6 hours ago, Atom_Monky said:

i use        _db_id = player getVariable ["db_id",0];         in my script but read somthing about                missionNamespace getVariable "myVar"     ?

No need to worry about that, that is for global variables. You are accessing a variable stored in an objects(player) namespace directly.

I just took the test mission from the linked thread, placed...

this setVariable["db_id",[0,"LARs"]];

in the playable units init.

Then...

hint str ( player getVariable[ "db_id", [] ] );

in the myOnPauseScript.sqf.

Worked fine, tested MP both hosted and dedicated.

  • Like 1

Share this post


Link to post
Share on other sites

Interesting post,  onPauseScript = "script.sqf"; doesn't seem to work from an addon's config.cpp any idea how to make this addon based? (besides adding EH keydown to display 46)

Share this post


Link to post
Share on other sites
15 hours ago, Atom_Monky said:

But in the Pause menu there is a blur effect, can i somehow disable the squares ?.

Dont use createDialog, this will add your dialog as a child of the mission display, of which the pause menu is shown above this and has the blurred squares background.

Turn your dialog into a controlsGroup then ctrlCreate this inside the pause menu display instead.

 

e.g A dialog that shows a red square 1/4 the size of the screen, centred.

Spoiler

class GUI_myPauseMenu
{
	idd = 10000;

	onLoad = "_this spawn LARs_fnc_someFunction";

	class Controls
	{

		class Background: ctrlStatic
		{
			idc = 10001;

			x = ( safeZoneX + ( safeZoneW / 2 )) - ( safeZoneW / 4 );
			y = ( safeZoneY + ( safeZoneH / 2 )) - ( safeZoneH / 4 );
			w = ( safeZoneW / 2 );
			h = ( safeZoneH / 2 );

			colorBackground[] = {1,0,0,1};
		};
	};
};

 

Turned into a controlsGroup

Spoiler

class GUI_myPauseMenu : ctrlControlsGroupNoScrollbars //inhert from controls group
{
	//idd = 10000; //remove idd reference

	//New position data large enough to encompass all child controls
	x = ( safeZoneX + ( safeZoneW / 2 )) - ( safeZoneW / 4 );
	y = ( safeZoneY + ( safeZoneH / 2 )) - ( safeZoneH / 4 );
	w = ( safeZoneW / 2 );
	h = ( safeZoneH / 2 );

	//Make sure any code called from what was the display now references it as a control instead
	onLoad = "_this spawn LARs_fnc_someFunction";

	class Controls
	{

		class Background: ctrlStatic
		{
			idc = 10001;

			//controls are now positioned relative to the controls group
			x = 0;
			y = 0;
			w = ( safeZoneW / 2 );
			h = ( safeZoneH / 2 );

			colorBackground[] = {1,0,0,1};
		};
	};
};

 

Then when you want to show the controls instead of...

createDialog "GUI_myPauseMenu";

do...

( uiNamespace getVariable "RscDisplayInterrupt" ) ctrlCreate [ "GUI_myPauseMenu", 10000 ];

or "RscDisplayMPInterrupt" for MP pause screen.

Then all you need to remember to do, is that any script called from your dialog (for instance LARs_fnc_someFunction in the above example ) the passed argument is a control and no longer a display.

  • Like 2

Share this post


Link to post
Share on other sites
10 hours ago, Mr H. said:

doesn't seem to work from an addon's config.cpp any idea how to make this addon based?

As an addon you have access to either overwrite the pause menus(RscDisplayInterrupt) onLoad event OR incorporate your controls straight into the display.

Same example as above as an addon.

Spoiler

class CfgPatches {
	class RscDisplayInterruptOverride {
		units[] = {};
		weapons[] = {};
		requiredVersion = 1.84;
		requiredAddons[] = {};
	};
};

class ctrlStatic;

class RscDisplayInterrupt { //OR RscDisplayMPInterrupt for MP pause
	class controls {
		class myRedRectangle: ctrlStatic
		{
			idc = 10001;

			x = ( safeZoneX + ( safeZoneW / 2 )) - ( safeZoneW / 4 );
			y = ( safeZoneY + ( safeZoneH / 2 )) - ( safeZoneH / 4 );
			w = ( safeZoneW / 2 );
			h = ( safeZoneH / 2 );

			colorBackground[] = {1,0,0,1};
		};
	};
};

 

 

  • Like 2

Share this post


Link to post
Share on other sites

I did try to override the onload but it didn't seem to work. Maybe I did it wrong. Could you give an example for that?

Share this post


Link to post
Share on other sites
2 hours ago, Mr H. said:

I did try to override the onload but it didn't seem to work.

I see what you mean. No matter just create a ctrl in the display instead with no width/height and use an onLoad event in that instead.

Spoiler

class CfgPatches {
	class RscDisplayInterruptOverride {
		units[] = {};
		weapons[] = {};
		requiredVersion = 1.84;
		requiredAddons[] = {};
	};
};

class ctrlStatic;

class RscDisplayInterrupt { //OR RscDisplayMPInterrupt for MP pause
	class controls {
		class myOnLoadControl: ctrlStatic
		{
			idc = 10001;

			x = safeZoneX;
			y = safeZoneY;
			w = 0;
			h = 0;

			onLoad = "_this call TAG_fnc_someFunction";
		};
	};
};

TAG_fnc_someFunction


disableSerialization

params[ "_myOnLoadCtrl" ];

_interruptDisplay = ctrlParent _myOnLoadCtrl;

 

 

  • Like 1

Share this post


Link to post
Share on other sites

perfect thanks! (all that to have my unit's logo rotating on the escape screen ;-) )

Share this post


Link to post
Share on other sites
On 26.11.2018 at 4:55 AM, Larrow said:

Turn your dialog into a controlsGroup then ctrlCreate this inside the pause menu display instead.


it seems that the new controls are overlapping the pause menu, can i move them behind the pause menu?
ViEdg3w.jpg
 

On 26.11.2018 at 4:55 AM, Larrow said:

//controls are now positioned relative to the controls group


And what is the best way to get the relativ postion to the controls group ? DONE ---> found an efficent way to transform dialog to RscControlsGroup:
1. Open the arma GUI editor -> STR+I Imort your dialog  -> "" missionConfigFIle >> "nameofyourdialog" "" 
2. add an RscControlsGroup and move it to your dialogs outer boundaries
3. STR+L and edit every control to  -> PositionType "ControlGroup:2300"
3. STR+Shift+S Saves to your dialog to clipboard (you see a short flash on the screen)

Share this post


Link to post
Share on other sites

I think you can't put your controls behind, they are placed in the order in which they are defined in your config file, and Arma's default are placed first.To the best of my knowledge there is no command to change the layering order (which is a crying shame). It might be possible from an addon but you'd have to have the entirety of the RscDisplayInterrupt (not just the thing you add). Why not just put your menu to the right of the console?

Share this post


Link to post
Share on other sites

Sorry I missed the bottom border you had in your original picture and thought it was just the centre controls.

As @Mr H. says its due to ordering and your created control is the top most.

The debugConsole will always rise above the others when you click anywhere on the screen due to an event placed on the display in BI's code. Due to the debugConsole being a controls group itself setting focus to one of its elements brings the whole thing to the top. Unfortunately we are not so lucky with the other controls of the pause menu and they are all separate controls.

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

×