From 6b5d95906d357f4432f94c75736d9aed3e501a90 Mon Sep 17 00:00:00 2001 From: jaynus Date: Sat, 9 May 2015 12:41:01 -0700 Subject: [PATCH] Disables multiple openings of the kestrel & atrag. Allows the overlay toggle, but disables the opening of multiple ones. Used onUnload handlers. Supports both limiting interact and keybinds. Fixes #1086 --- addons/atragmx/RscTitles.hpp | 1 + addons/atragmx/XEH_preInit.sqf | 1 + addons/atragmx/functions/fnc_create_dialog.sqf | 3 +++ addons/atragmx/functions/fnc_init.sqf | 2 ++ addons/atragmx/functions/fnc_on_close_dialog.sqf | 4 ++++ addons/atragmx/initKeybinds.sqf | 2 +- addons/kestrel4500/RscTitles.hpp | 2 ++ addons/kestrel4500/XEH_postInit.sqf | 2 +- addons/kestrel4500/XEH_preInit.sqf | 3 +++ addons/kestrel4500/functions/fnc_createKestrelDialog.sqf | 1 + addons/kestrel4500/functions/fnc_onCloseDialog.sqf | 4 ++++ addons/kestrel4500/functions/fnc_onCloseDisplay.sqf | 4 ++++ addons/kestrel4500/initKeybinds.sqf | 5 +++-- 13 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 addons/atragmx/functions/fnc_on_close_dialog.sqf create mode 100644 addons/kestrel4500/functions/fnc_onCloseDialog.sqf create mode 100644 addons/kestrel4500/functions/fnc_onCloseDisplay.sqf diff --git a/addons/atragmx/RscTitles.hpp b/addons/atragmx/RscTitles.hpp index 4ae08c20aa..cefc7a26eb 100644 --- a/addons/atragmx/RscTitles.hpp +++ b/addons/atragmx/RscTitles.hpp @@ -142,6 +142,7 @@ class ATragMX_Display { name="ATragMX_Display"; idd=-1; onLoad="uiNamespace setVariable ['ATragMX_Display', (_this select 0)]"; + onUnload=QUOTE(_this call FUNC(on_close_dialog)); movingEnable=1; controlsBackground[]={}; objects[]={}; diff --git a/addons/atragmx/XEH_preInit.sqf b/addons/atragmx/XEH_preInit.sqf index 6ec288b9c7..62bf2181c7 100644 --- a/addons/atragmx/XEH_preInit.sqf +++ b/addons/atragmx/XEH_preInit.sqf @@ -68,5 +68,6 @@ PREP(update_target_data); PREP(update_target_selection); PREP(update_unit_selection); PREP(update_zero_range); +PREP(on_close_dialog); ADDON = true; diff --git a/addons/atragmx/functions/fnc_create_dialog.sqf b/addons/atragmx/functions/fnc_create_dialog.sqf index 09e413d535..e0be3c6941 100644 --- a/addons/atragmx/functions/fnc_create_dialog.sqf +++ b/addons/atragmx/functions/fnc_create_dialog.sqf @@ -16,6 +16,7 @@ #include "script_component.hpp" //if (dialog) exitWith { false }; +if(GVAR(active)) exitWith { false }; if (underwater ACE_player) exitWith { false }; if (!("ACE_ATragMX" in (uniformItems ACE_player)) && !("ACE_ATragMX" in (vestItems ACE_player))) exitWith { false }; @@ -47,4 +48,6 @@ GVAR(showTargetSpeedAssistTimer) call FUNC(show_target_speed_assist_timer); lbAdd [6000, _x select 0]; } forEach GVAR(gunList); +GVAR(active) = true; + true diff --git a/addons/atragmx/functions/fnc_init.sqf b/addons/atragmx/functions/fnc_init.sqf index e4fe1b67a4..30b17ebf90 100644 --- a/addons/atragmx/functions/fnc_init.sqf +++ b/addons/atragmx/functions/fnc_init.sqf @@ -15,6 +15,8 @@ */ #include "script_component.hpp" +GVAR(active) = false; + GVAR(workingMemory) = +(GVAR(gunList) select 0); GVAR(scopeUnits) = ["MILs", "TMOA", "SMOA", "Clicks"]; diff --git a/addons/atragmx/functions/fnc_on_close_dialog.sqf b/addons/atragmx/functions/fnc_on_close_dialog.sqf new file mode 100644 index 0000000000..32ba4e4c43 --- /dev/null +++ b/addons/atragmx/functions/fnc_on_close_dialog.sqf @@ -0,0 +1,4 @@ +#include "script_component.hpp" + +uiNamespace setVariable ['ATragMX_Display', nil]; +GVAR(active) = false; \ No newline at end of file diff --git a/addons/atragmx/initKeybinds.sqf b/addons/atragmx/initKeybinds.sqf index 796d7f9d97..98bddf04e4 100644 --- a/addons/atragmx/initKeybinds.sqf +++ b/addons/atragmx/initKeybinds.sqf @@ -2,7 +2,7 @@ { // Conditions: canInteract if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; - + if(GVAR(active)) exitWith {}; // Statement [] call FUNC(create_dialog); false diff --git a/addons/kestrel4500/RscTitles.hpp b/addons/kestrel4500/RscTitles.hpp index defb954292..b091a07561 100644 --- a/addons/kestrel4500/RscTitles.hpp +++ b/addons/kestrel4500/RscTitles.hpp @@ -54,6 +54,7 @@ class Kestrel4500_Display name="Kestrel4500_Display"; idd=-1; onLoad="uiNamespace setVariable ['Kestrel4500_Display', (_this select 0)]"; + onUnload=QUOTE(_this call FUNC(onCloseDialog)); movingEnable=1; controlsBackground[]={}; objects[]={}; @@ -217,6 +218,7 @@ class RscTitles { idd=-1; onLoad="with uiNameSpace do { RscKestrel4500 = _this select 0 };"; + onUnload=(_this call FUNC(onCloseDisplay)); movingEnable=0; duration=60; fadeIn="false"; diff --git a/addons/kestrel4500/XEH_postInit.sqf b/addons/kestrel4500/XEH_postInit.sqf index 461ed533db..24a972c326 100644 --- a/addons/kestrel4500/XEH_postInit.sqf +++ b/addons/kestrel4500/XEH_postInit.sqf @@ -22,4 +22,4 @@ GVAR(MeasuredWindSpeed) = 0; GVAR(ImpellerState) = 0; GVAR(Kestrel4500) = false; -GVAR(Overlay) = false; +GVAR(Overlay) = false; \ No newline at end of file diff --git a/addons/kestrel4500/XEH_preInit.sqf b/addons/kestrel4500/XEH_preInit.sqf index d081f485ec..2d5e211a54 100644 --- a/addons/kestrel4500/XEH_preInit.sqf +++ b/addons/kestrel4500/XEH_preInit.sqf @@ -13,4 +13,7 @@ PREP(measureWindSpeed); PREP(updateDisplay); PREP(updateImpellerState); +PREP(onCloseDialog); +PREP(onCloseDisplay); + ADDON = true; diff --git a/addons/kestrel4500/functions/fnc_createKestrelDialog.sqf b/addons/kestrel4500/functions/fnc_createKestrelDialog.sqf index f9cd6cf04a..77e36679de 100644 --- a/addons/kestrel4500/functions/fnc_createKestrelDialog.sqf +++ b/addons/kestrel4500/functions/fnc_createKestrelDialog.sqf @@ -16,6 +16,7 @@ //if (dialog) exitWith { false }; if (underwater ACE_player) exitWith { false }; +if(GVAR(Kestrel4500)) exitWith { false }; if (!("ACE_Kestrel4500" in (uniformItems ACE_player)) && !("ACE_Kestrel4500" in (vestItems ACE_player))) exitWith { false }; GVAR(Overlay) = false; diff --git a/addons/kestrel4500/functions/fnc_onCloseDialog.sqf b/addons/kestrel4500/functions/fnc_onCloseDialog.sqf new file mode 100644 index 0000000000..a45a9decc3 --- /dev/null +++ b/addons/kestrel4500/functions/fnc_onCloseDialog.sqf @@ -0,0 +1,4 @@ +#include "script_component.hpp" + +uiNamespace setVariable ['Kestrel4500_Display', nil]; +GVAR(Kestrel4500) = false; diff --git a/addons/kestrel4500/functions/fnc_onCloseDisplay.sqf b/addons/kestrel4500/functions/fnc_onCloseDisplay.sqf new file mode 100644 index 0000000000..efb60b322a --- /dev/null +++ b/addons/kestrel4500/functions/fnc_onCloseDisplay.sqf @@ -0,0 +1,4 @@ +#include "script_component.hpp" + +uiNamespace setVariable ['RscKestrel4500', nil]; +GVAR(Overlay) = false; diff --git a/addons/kestrel4500/initKeybinds.sqf b/addons/kestrel4500/initKeybinds.sqf index f6b4fec3ce..f910bdf552 100644 --- a/addons/kestrel4500/initKeybinds.sqf +++ b/addons/kestrel4500/initKeybinds.sqf @@ -2,7 +2,8 @@ { // Conditions: canInteract if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; - + if(GVAR(Kestrel4500)) exitWith { false }; + // Statement [] call FUNC(createKestrelDialog); false @@ -14,7 +15,7 @@ { // Conditions: canInteract if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; - + // Statement [] call FUNC(displayKestrel); false