From f7ff4a2f36de32b107d7a0a1ce9b7d1d07f107c8 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 10 May 2015 14:59:53 -0500 Subject: [PATCH 1/7] Base Device Handler Framework Multiple devices share Home/Ctrl-home keys --- addons/common/XEH_postInit.sqf | 36 +++++++++++++++++++ addons/common/XEH_preInit.sqf | 2 ++ .../functions/fnc_deviceKeyFindValidIndex.sqf | 13 +++++++ .../functions/fnc_deviceKeyRegisterNew.sqf | 6 ++++ addons/microdagr/XEH_clientInit.sqf | 21 +++++++++-- 5 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 addons/common/functions/fnc_deviceKeyFindValidIndex.sqf create mode 100644 addons/common/functions/fnc_deviceKeyRegisterNew.sqf diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 696aa16f9b..d19958bd57 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -249,3 +249,39 @@ if(isMultiplayer && { time > 0 || isNull player } ) then { }; }, 0, []] call cba_fnc_addPerFrameHandler; }; + +//Device Handler: +GVAR(deviceKeyHandlingArray) = []; +GVAR(deviceKeyCurrentIndex) = -1; + +["ACE3 Equipment", QGVAR(openDevice), "Open Device", //(localize "STR_ACE_microdagr_toggleUnit"), +{ + [] call FUNC(deviceKeyFindValidIndex); + if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false}; + [] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 3); + true; +}, +{false}, +[0xC7, [false, false, false]], false] call cba_fnc_addKeybind; //Home Key + +["ACE3 Equipment", QGVAR(closeDevice), "Close Device", //(localize "STR_ACE_microdagr_toggleUnit"), +{ + [] call FUNC(deviceKeyFindValidIndex); + if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false}; + [] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 4); +}, +{false}, +[0xC7, [false, true, false]], false] call cba_fnc_addKeybind; //CTRL + Home Key + +["ACE3 Equipment", QGVAR(cycleDevice), "Cycle Devices", //(localize "STR_ACE_microdagr_toggleUnit"), +{ + systemChat "here"; + [1] call FUNC(deviceKeyFindValidIndex); + if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false}; + _displayName = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 0); + _iconImage = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 1); + systemChat str [_displayName, _iconImage]; + [_displayName, _iconImage] call FUNC(displayTextPicture); +}, +{false}, +[0xC7, [true, false, false]], false] call cba_fnc_addKeybind; //SHIFT + Home Key diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 5c2ad1e592..4bedd36513 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -33,6 +33,8 @@ PREP(currentChannel); PREP(debug); PREP(debugModule); PREP(defineVariable); +PREP(deviceKeyFindValidIndex); +PREP(deviceKeyRegisterNew); PREP(disableAI); PREP(disableUserInput); PREP(displayIcon); diff --git a/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf b/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf new file mode 100644 index 0000000000..19069b1821 --- /dev/null +++ b/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf @@ -0,0 +1,13 @@ + +#include "script_component.hpp" + +DEFAULT_PARAM(0,_offsetBy,0); + +_validIndex = -1; +for "_offset" from _offsetBy to ((count GVAR(deviceKeyHandlingArray)) - 1 + _offsetBy) do { + _realIndex = (GVAR(deviceKeyCurrentIndex) + _offset) % (count GVAR(deviceKeyHandlingArray)); + if ([] call ((GVAR(deviceKeyHandlingArray) select _realIndex) select 2)) exitWith { + _validIndex = _realIndex; + }; +}; +GVAR(deviceKeyCurrentIndex) = _validIndex; diff --git a/addons/common/functions/fnc_deviceKeyRegisterNew.sqf b/addons/common/functions/fnc_deviceKeyRegisterNew.sqf new file mode 100644 index 0000000000..0b8ab0761c --- /dev/null +++ b/addons/common/functions/fnc_deviceKeyRegisterNew.sqf @@ -0,0 +1,6 @@ + +#include "script_component.hpp" +PARAMS_5(_displayName,_iconImage,_conditionCode,_toggleCode,_closeCode); + +GVAR(deviceKeyHandlingArray) pushBack [_displayName,_iconImage,_conditionCode,_toggleCode,_closeCode]; +[] call FUNC(deviceKeyFindValidIndex); diff --git a/addons/microdagr/XEH_clientInit.sqf b/addons/microdagr/XEH_clientInit.sqf index 587bf85ef5..339e0bf112 100644 --- a/addons/microdagr/XEH_clientInit.sqf +++ b/addons/microdagr/XEH_clientInit.sqf @@ -3,7 +3,24 @@ if (!hasInterface) exitWith {}; -//Add Keybinds: +_conditonCode = { +("ACE_microDAGR" in (items ace_player)) +}; +_toggleCode = { + if !([ACE_player, objNull, ["notOnMap", "isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; + [] call FUNC(openDisplay); //toggle display mode + true +}; +_closeCode = { + if (GVAR(currentShowMode) == DISPLAY_MODE_CLOSED) exitWith {false}; + [DISPLAY_MODE_CLOSED] call FUNC(openDisplay); + true +}; + +["Mdagr", "", _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew); + + +/* //Add Keybinds: ["ACE3 Equipment", QGVAR(openGPS), (localize "STR_ACE_microdagr_toggleUnit"), { // canInteractWith (can use on map) @@ -29,7 +46,7 @@ if (!hasInterface) exitWith {}; true; }, {false}, -[0xC7, [false, true, false]], false] call cba_fnc_addKeybind; //CTRL + Home Key +[0xC7, [false, true, false]], false] call cba_fnc_addKeybind; //CTRL + Home Key */ //Add Eventhandler: ["RangerfinderData", {_this call FUNC(recieveRangefinderData)}] call EFUNC(common,addEventHandler); From 05f1b884fac792df117947ab6fce4c238d5099e9 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 10 May 2015 15:17:50 -0500 Subject: [PATCH 2/7] Localization/ headers --- addons/common/XEH_postInit.sqf | 8 ++--- .../functions/fnc_deviceKeyFindValidIndex.sqf | 16 ++++++++- .../functions/fnc_deviceKeyRegisterNew.sqf | 21 ++++++++++- addons/common/stringtable.xml | 11 +++++- addons/microdagr/XEH_clientInit.sqf | 36 +++---------------- 5 files changed, 52 insertions(+), 40 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index d19958bd57..ade35855ea 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -254,7 +254,7 @@ if(isMultiplayer && { time > 0 || isNull player } ) then { GVAR(deviceKeyHandlingArray) = []; GVAR(deviceKeyCurrentIndex) = -1; -["ACE3 Equipment", QGVAR(openDevice), "Open Device", //(localize "STR_ACE_microdagr_toggleUnit"), +["ACE3 Equipment", QGVAR(openDevice), (localize "STR_ACE_Common_toggleHandheldDevice"), { [] call FUNC(deviceKeyFindValidIndex); if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false}; @@ -264,7 +264,7 @@ GVAR(deviceKeyCurrentIndex) = -1; {false}, [0xC7, [false, false, false]], false] call cba_fnc_addKeybind; //Home Key -["ACE3 Equipment", QGVAR(closeDevice), "Close Device", //(localize "STR_ACE_microdagr_toggleUnit"), +["ACE3 Equipment", QGVAR(closeDevice), (localize "STR_ACE_Common_closeHandheldDevice"), { [] call FUNC(deviceKeyFindValidIndex); if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false}; @@ -273,14 +273,12 @@ GVAR(deviceKeyCurrentIndex) = -1; {false}, [0xC7, [false, true, false]], false] call cba_fnc_addKeybind; //CTRL + Home Key -["ACE3 Equipment", QGVAR(cycleDevice), "Cycle Devices", //(localize "STR_ACE_microdagr_toggleUnit"), +["ACE3 Equipment", QGVAR(cycleDevice), (localize "STR_ACE_Common_cycleHandheldDevices"), { - systemChat "here"; [1] call FUNC(deviceKeyFindValidIndex); if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false}; _displayName = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 0); _iconImage = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 1); - systemChat str [_displayName, _iconImage]; [_displayName, _iconImage] call FUNC(displayTextPicture); }, {false}, diff --git a/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf b/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf index 19069b1821..431761bae1 100644 --- a/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf +++ b/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf @@ -1,4 +1,18 @@ - +/* + * Author: PabstMirror + * Finds next valid index for the device array. + * + * Arguments: + * 0: Offset from currentIndex (use 1 to find next valid) + * + * Return Value: + * Nothing + * + * Example: + * [] call ace_common_fnc_deviceKeyFindValidIndex + * + * Public: No + */ #include "script_component.hpp" DEFAULT_PARAM(0,_offsetBy,0); diff --git a/addons/common/functions/fnc_deviceKeyRegisterNew.sqf b/addons/common/functions/fnc_deviceKeyRegisterNew.sqf index 0b8ab0761c..6a15c3c340 100644 --- a/addons/common/functions/fnc_deviceKeyRegisterNew.sqf +++ b/addons/common/functions/fnc_deviceKeyRegisterNew.sqf @@ -1,5 +1,24 @@ - +/* + * Author: PabstMirror + * Finds next valid index for the device array. + * + * Arguments: + * 0: Localized Device Display Name + * 1: Image + * 2: Condtion Code (do they have the device) + * 3: Toggle Code (on home press) + * 4: Close Code (on ctrl-home press) + * + * Return Value: + * Nothing + * + * Example: + * [(localize "STR_ACE_microdagr_itemName"), QUOTE(PATHTOF(images\microDAGR_item.paa)), _conditonCode, _toggleCode, _closeCode] call ace_common_fnc_deviceKeyRegisterNew + * + * Public: No + */ #include "script_component.hpp" + PARAMS_5(_displayName,_iconImage,_conditionCode,_toggleCode,_closeCode); GVAR(deviceKeyHandlingArray) pushBack [_displayName,_iconImage,_conditionCode,_toggleCode,_closeCode]; diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index 8d28704362..3b1e5dbc76 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -470,5 +470,14 @@ Une banane est un fruit qui, d'un point de vue botanique, fait partie du groupe des baies. Produite par plusieurs sortes de grandes plantes à fleurs herbacées du type Musa. A banana é uma fruta comestível, botanicamente uma baga, produzida por vários tipos de plantas herbáceas grandes do genero Musa. + + Toggle Device + + + Close Device + + + Cycle Devices + - + \ No newline at end of file diff --git a/addons/microdagr/XEH_clientInit.sqf b/addons/microdagr/XEH_clientInit.sqf index 339e0bf112..0569256df3 100644 --- a/addons/microdagr/XEH_clientInit.sqf +++ b/addons/microdagr/XEH_clientInit.sqf @@ -3,8 +3,10 @@ if (!hasInterface) exitWith {}; +//Add deviceKey entry: +private ["_conditonCode", "_toggleCode", "_closeCode"]; _conditonCode = { -("ACE_microDAGR" in (items ace_player)) + ("ACE_microDAGR" in (items ace_player)) }; _toggleCode = { if !([ACE_player, objNull, ["notOnMap", "isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; @@ -16,37 +18,7 @@ _closeCode = { [DISPLAY_MODE_CLOSED] call FUNC(openDisplay); true }; - -["Mdagr", "", _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew); - - -/* //Add Keybinds: -["ACE3 Equipment", QGVAR(openGPS), (localize "STR_ACE_microdagr_toggleUnit"), -{ - // canInteractWith (can use on map) - if !([ACE_player, objNull, ["notOnMap", "isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; - // Conditions: specific - if (!("ACE_microDAGR" in (items ace_player))) exitWith {false}; - - [] call FUNC(openDisplay); //toggle display mode - true; -}, -{false}, -[0xC7, [false, false, false]], false] call cba_fnc_addKeybind; //Home Key - -["ACE3 Equipment", QGVAR(closeGPS), (localize "STR_ACE_microdagr_closeUnit"), -{ - // canInteractWith (can use on map) - if !([ACE_player, objNull, ["notOnMap", "isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; - // Conditions: specific - if (!("ACE_microDAGR" in (items ace_player))) exitWith {false}; - if (GVAR(currentShowMode) == DISPLAY_MODE_CLOSED) exitWith {false}; - - [DISPLAY_MODE_CLOSED] call FUNC(openDisplay); //close unit - true; -}, -{false}, -[0xC7, [false, true, false]], false] call cba_fnc_addKeybind; //CTRL + Home Key */ +[(localize "STR_ACE_microdagr_itemName"), QUOTE(PATHTOF(images\microDAGR_item.paa)), _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew); //Add Eventhandler: ["RangerfinderData", {_this call FUNC(recieveRangefinderData)}] call EFUNC(common,addEventHandler); From 57d6ad988b1c85846c4dffbb853fd116cdd14227 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 10 May 2015 16:54:24 -0500 Subject: [PATCH 3/7] Kestral WIP --- .../functions/fnc_deviceKeyFindValidIndex.sqf | 15 ++++++++----- addons/kestrel4500/initKeybinds.sqf | 21 +++++++++---------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf b/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf index 431761bae1..f9ac89a30b 100644 --- a/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf +++ b/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf @@ -6,7 +6,7 @@ * 0: Offset from currentIndex (use 1 to find next valid) * * Return Value: - * Nothing + * The new index (-1 if no valid) * * Example: * [] call ace_common_fnc_deviceKeyFindValidIndex @@ -18,10 +18,15 @@ DEFAULT_PARAM(0,_offsetBy,0); _validIndex = -1; -for "_offset" from _offsetBy to ((count GVAR(deviceKeyHandlingArray)) - 1 + _offsetBy) do { - _realIndex = (GVAR(deviceKeyCurrentIndex) + _offset) % (count GVAR(deviceKeyHandlingArray)); - if ([] call ((GVAR(deviceKeyHandlingArray) select _realIndex) select 2)) exitWith { - _validIndex = _realIndex; +if ((count GVAR(deviceKeyHandlingArray)) > 0) then { + if (GVAR(deviceKeyCurrentIndex) == -1) then {GVAR(deviceKeyCurrentIndex) = 0;}; + for "_offset" from _offsetBy to ((count GVAR(deviceKeyHandlingArray)) - 1 + _offsetBy) do { + _realIndex = (GVAR(deviceKeyCurrentIndex) + _offset) % (count GVAR(deviceKeyHandlingArray)); + if ([] call ((GVAR(deviceKeyHandlingArray) select _realIndex) select 2)) exitWith { + _validIndex = _realIndex; + }; }; }; + GVAR(deviceKeyCurrentIndex) = _validIndex; +_validIndex diff --git a/addons/kestrel4500/initKeybinds.sqf b/addons/kestrel4500/initKeybinds.sqf index f910bdf552..9096b7c897 100644 --- a/addons/kestrel4500/initKeybinds.sqf +++ b/addons/kestrel4500/initKeybinds.sqf @@ -1,5 +1,9 @@ -["ACE3 Equipment", QGVAR(KestrelDialogKey), localize "STR_ACE_Kestrel4500_KestrelDialogKey", -{ +//Add deviceKey entry: +private ["_conditonCode", "_toggleCode", "_closeCode"]; +_conditonCode = { + [] call FUNC(canShow); +}; +_toggleCode = { // Conditions: canInteract if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; if(GVAR(Kestrel4500)) exitWith { false }; @@ -7,18 +11,13 @@ // Statement [] call FUNC(createKestrelDialog); false -}, -{false}, -[0, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // (empty default key) - -["ACE3 Equipment", QGVAR(DisplayKestrelKey), localize "STR_ACE_Kestrel4500_DisplayKestrelKey", -{ +}; +_closeCode = { // Conditions: canInteract if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; // Statement [] call FUNC(displayKestrel); false -}, -{false}, -[0, [true, false, false]], false, 0] call CBA_fnc_addKeybind; // (empty default key) +}; +[(localize "STR_ACE_Kestrel_Name"), QUOTE(PATHTOF(UI\Kestrel4500.paa)), _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew); \ No newline at end of file From ffce1f6386b0f23cd89845d3843b7cd72fab0572 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 11 May 2015 21:49:13 -0500 Subject: [PATCH 4/7] Condense mDagr interactions - intergrate kestral --- .../functions/fnc_deviceKeyFindValidIndex.sqf | 31 +++++++++---- .../functions/fnc_deviceKeyRegisterNew.sqf | 2 +- addons/kestrel4500/initKeybinds.sqf | 25 +++++++--- addons/microdagr/CfgVehicles.hpp | 46 ++++++++++--------- 4 files changed, 66 insertions(+), 38 deletions(-) diff --git a/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf b/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf index f9ac89a30b..a8418cd4cd 100644 --- a/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf +++ b/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf @@ -3,30 +3,43 @@ * Finds next valid index for the device array. * * Arguments: - * 0: Offset from currentIndex (use 1 to find next valid) + * 0: Offset from currentIndex (use 1 to find next valid after current) or a displayName string or * * Return Value: * The new index (-1 if no valid) * * Example: * [] call ace_common_fnc_deviceKeyFindValidIndex + * ["kestral4500"] call ace_common_fnc_deviceKeyFindValidIndex * * Public: No */ #include "script_component.hpp" -DEFAULT_PARAM(0,_offsetBy,0); +DEFAULT_PARAM(0,_searchOffsetOrName,0); + +private ["_validIndex", "_offsetBy", "_realIndex", "_offset"]; _validIndex = -1; -if ((count GVAR(deviceKeyHandlingArray)) > 0) then { - if (GVAR(deviceKeyCurrentIndex) == -1) then {GVAR(deviceKeyCurrentIndex) = 0;}; - for "_offset" from _offsetBy to ((count GVAR(deviceKeyHandlingArray)) - 1 + _offsetBy) do { - _realIndex = (GVAR(deviceKeyCurrentIndex) + _offset) % (count GVAR(deviceKeyHandlingArray)); - if ([] call ((GVAR(deviceKeyHandlingArray) select _realIndex) select 2)) exitWith { - _validIndex = _realIndex; + +if ((typeName _searchOffsetOrName) == "STRING") then { + { + if ((_x select 0) == _searchOffsetOrName) exitWith { + _validIndex = _forEachIndex; + }; + } forEach GVAR(deviceKeyHandlingArray); +} else { + if ((count GVAR(deviceKeyHandlingArray)) > 0) then { + _baseIndex = if (GVAR(deviceKeyCurrentIndex) == -1) then {0} else {GVAR(deviceKeyCurrentIndex) + _searchOffsetOrName}; + for "_offset" from _baseIndex to ((count GVAR(deviceKeyHandlingArray)) - 1 + _baseIndex) do { + _realIndex = _offset % (count GVAR(deviceKeyHandlingArray)); + if ([] call ((GVAR(deviceKeyHandlingArray) select _realIndex) select 2)) exitWith { + _validIndex = _realIndex; + }; }; }; }; GVAR(deviceKeyCurrentIndex) = _validIndex; -_validIndex + +GVAR(deviceKeyCurrentIndex) diff --git a/addons/common/functions/fnc_deviceKeyRegisterNew.sqf b/addons/common/functions/fnc_deviceKeyRegisterNew.sqf index 6a15c3c340..88ffa84af7 100644 --- a/addons/common/functions/fnc_deviceKeyRegisterNew.sqf +++ b/addons/common/functions/fnc_deviceKeyRegisterNew.sqf @@ -13,7 +13,7 @@ * Nothing * * Example: - * [(localize "STR_ACE_microdagr_itemName"), QUOTE(PATHTOF(images\microDAGR_item.paa)), _conditonCode, _toggleCode, _closeCode] call ace_common_fnc_deviceKeyRegisterNew + * [(localize "STR_ACE_microdagr_itemName"), QUOTE(PATHTOF(images\microDAGR_item.paa)), _conditionCode, _toggleCode, _closeCode] call ace_common_fnc_deviceKeyRegisterNew * * Public: No */ diff --git a/addons/kestrel4500/initKeybinds.sqf b/addons/kestrel4500/initKeybinds.sqf index 9096b7c897..c9c8d1b69b 100644 --- a/addons/kestrel4500/initKeybinds.sqf +++ b/addons/kestrel4500/initKeybinds.sqf @@ -6,18 +6,31 @@ _conditonCode = { _toggleCode = { // Conditions: canInteract if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; - if(GVAR(Kestrel4500)) exitWith { false }; // Statement - [] call FUNC(createKestrelDialog); - false + if (!GVAR(Overlay)) then { + //If no overlay, show it: + [] call FUNC(displayKestrel); + } else { + //If overlay is up, switch to dialog: + [] call FUNC(createKestrelDialog); + }; }; _closeCode = { // Conditions: canInteract if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; - + // Statement - [] call FUNC(displayKestrel); + if (GVAR(Overlay)) then { + //If dispaly is open, close it: + GVAR(Overlay) = false; + }; + if (dialog && {!isNull (uiNamespace getVariable ["Kestrel4500_Display", displayNull])}) then { + //If dialog is open, close it: + GVAR(Kestrel4500) = false; + closeDialog 0; + }; false }; -[(localize "STR_ACE_Kestrel_Name"), QUOTE(PATHTOF(UI\Kestrel4500.paa)), _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew); \ No newline at end of file + +[(localize "STR_ACE_Kestrel_Name"), QUOTE(PATHTOF(UI\Kestrel4500.paa)), _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew); diff --git a/addons/microdagr/CfgVehicles.hpp b/addons/microdagr/CfgVehicles.hpp index 833f7bd2f6..fe803a2ae4 100644 --- a/addons/microdagr/CfgVehicles.hpp +++ b/addons/microdagr/CfgVehicles.hpp @@ -3,34 +3,36 @@ class CfgVehicles { class CAManBase: Man { class ACE_SelfActions { class ACE_Equipment { - class GVAR(show) { - //Opens the mini map - displayName = "$STR_ACE_microdagr_show"; - condition = QUOTE(([DISPLAY_MODE_DISPLAY] call FUNC(canShow)) && {GVAR(currentShowMode) != DISPLAY_MODE_DISPLAY}); - statement = QUOTE([DISPLAY_MODE_DISPLAY] call FUNC(openDisplay)); - showDisabled = 0; - priority = 0.2; - icon = QUOTE(PATHTOF(UI\icon_microDAGR.paa)); - exceptions[] = {"notOnMap", "isNotInside"}; - }; class GVAR(configure) { - //Opens the dialog + //Opens the interactive dialog displayName = "$STR_ACE_microdagr_configure"; - condition = QUOTE(([DISPLAY_MODE_DIALOG] call FUNC(canShow)) && {GVAR(currentShowMode) != DISPLAY_MODE_DIALOG}); + condition = QUOTE([DISPLAY_MODE_DIALOG] call FUNC(canShow)); statement = QUOTE([DISPLAY_MODE_DIALOG] call FUNC(openDisplay)); showDisabled = 0; priority = 0.1; icon = QUOTE(PATHTOF(UI\icon_microDAGR.paa)); exceptions[] = {"notOnMap", "isNotInside"}; - }; - class GVAR(close) { - displayName = "$STR_ACE_microdagr_closeUnit"; - condition = QUOTE(GVAR(currentShowMode) != DISPLAY_MODE_CLOSED); - statement = QUOTE([DISPLAY_MODE_CLOSED] call FUNC(openDisplay)); - showDisabled = 0; - priority = 0.3; - icon = QUOTE(PATHTOF(UI\icon_microDAGR.paa)); - exceptions[] = {"notOnMap", "isNotInside"}; + + //Sub Actions: + class GVAR(show) { + //Opens the background display (minimap) + displayName = "$STR_ACE_microdagr_show"; + condition = QUOTE(([DISPLAY_MODE_DISPLAY] call FUNC(canShow)) && {GVAR(currentShowMode) != DISPLAY_MODE_DISPLAY}); + statement = QUOTE([DISPLAY_MODE_DISPLAY] call FUNC(openDisplay)); + showDisabled = 0; + priority = 0.2; + icon = QUOTE(PATHTOF(UI\icon_microDAGR.paa)); + exceptions[] = {"notOnMap", "isNotInside"}; + }; + class GVAR(close) { + displayName = "$STR_ACE_microdagr_closeUnit"; + condition = QUOTE(GVAR(currentShowMode) != DISPLAY_MODE_CLOSED); + statement = QUOTE([DISPLAY_MODE_CLOSED] call FUNC(openDisplay)); + showDisabled = 0; + priority = 0.3; + icon = QUOTE(PATHTOF(UI\icon_microDAGR.paa)); + exceptions[] = {"notOnMap", "isNotInside"}; + }; }; }; }; @@ -66,7 +68,7 @@ class CfgVehicles { description = "Controls how much data is filled on the microDAGR items. Less data restricts the map view to show less on the minimap.
Source: microDAGR.pbo"; }; }; - + class Box_NATO_Support_F; class ACE_Box_Misc: Box_NATO_Support_F { class TransportItems { From de2a89613ce69ce9ff160943ac47a1d1776f31a4 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 11 May 2015 22:22:24 -0500 Subject: [PATCH 5/7] ATragMX --- addons/atragmx/initKeybinds.sqf | 19 +++++++++++----- addons/common/stringtable.xml | 6 ++--- addons/kestrel4500/CfgVehicles.hpp | 36 +++++++++++++++--------------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/addons/atragmx/initKeybinds.sqf b/addons/atragmx/initKeybinds.sqf index 8bc37752f3..64802997d9 100644 --- a/addons/atragmx/initKeybinds.sqf +++ b/addons/atragmx/initKeybinds.sqf @@ -1,11 +1,20 @@ -["ACE3 Equipment", QGVAR(ATragMXDialogKey), localize "STR_ACE_ATragMX_ATragMXDialogKey", -{ +//Add deviceKey entry: +private ["_conditonCode", "_toggleCode", "_closeCode"]; +_conditonCode = { + ("ACE_ATragMX" in (uniformItems ACE_player)) || {"ACE_ATragMX" in (vestItems ACE_player)} +}; +_toggleCode = { // Conditions: canInteract if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; if (GVAR(active)) exitWith {false}; // Statement [] call FUNC(create_dialog); false -}, -{false}, -[0, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // (empty default key) \ No newline at end of file +}; +_closeCode = { + if (dialog && {!isNull (uiNamespace getVariable ["ATragMX_Display", displayNull])}) then { + closeDialog 0; + }; +}; + +[(localize "STR_ACE_ATragMX_Name"), QUOTE(PATHTOF(UI\ATRAG_Icon.paa)), _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew); diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index 3b1e5dbc76..0f05274109 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -471,13 +471,13 @@ A banana é uma fruta comestível, botanicamente uma baga, produzida por vários tipos de plantas herbáceas grandes do genero Musa. - Toggle Device + Toggle Handheld Device - Close Device + Close Handheld Device - Cycle Devices + Cycle Handheld Devices \ No newline at end of file diff --git a/addons/kestrel4500/CfgVehicles.hpp b/addons/kestrel4500/CfgVehicles.hpp index 20d8bf5b62..ab7fefa3a5 100644 --- a/addons/kestrel4500/CfgVehicles.hpp +++ b/addons/kestrel4500/CfgVehicles.hpp @@ -10,25 +10,25 @@ class CfgVehicles { showDisabled = 0; priority = 0.1; icon = QUOTE(PATHTOF(UI\Kestrel4500_Icon.paa)); - exceptions[] = {"notOnMap"}; - }; - class GVAR(show) { - displayName = "$STR_ACE_Kestrel4500_ShowKestrel"; - condition = QUOTE(call FUNC(canShow) && !GVAR(Overlay)); - statement = QUOTE(call FUNC(displayKestrel)); - showDisabled = 0; - priority = 0.2; - icon = QUOTE(PATHTOF(UI\Kestrel4500_Icon.paa)); - exceptions[] = {"notOnMap", "isNotInside"}; - }; - class GVAR(hide) { - displayName = "$STR_ACE_Kestrel4500_HideKestrel"; - condition = QUOTE(GVAR(Overlay)); - statement = QUOTE(call FUNC(displayKestrel)); - showDisabled = 0; - priority = 0.3; - icon = QUOTE(PATHTOF(UI\Kestrel4500_Icon.paa)); exceptions[] = {"notOnMap", "isNotInside"}; + class GVAR(show) { + displayName = "$STR_ACE_Kestrel4500_ShowKestrel"; + condition = QUOTE(call FUNC(canShow) && !GVAR(Overlay)); + statement = QUOTE(call FUNC(displayKestrel)); + showDisabled = 0; + priority = 0.2; + icon = QUOTE(PATHTOF(UI\Kestrel4500_Icon.paa)); + exceptions[] = {"notOnMap", "isNotInside"}; + }; + class GVAR(hide) { + displayName = "$STR_ACE_Kestrel4500_HideKestrel"; + condition = QUOTE(GVAR(Overlay)); + statement = QUOTE(call FUNC(displayKestrel)); + showDisabled = 0; + priority = 0.3; + icon = QUOTE(PATHTOF(UI\Kestrel4500_Icon.paa)); + exceptions[] = {"notOnMap", "isNotInside"}; + }; }; }; }; From 043fee03bdf7d7a3227bf9fa6e247a246636becb Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 11 May 2015 22:48:03 -0500 Subject: [PATCH 6/7] Return Valid bool for keybind --- addons/common/XEH_postInit.sqf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index ade35855ea..aa5e6ba5d8 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -259,7 +259,7 @@ GVAR(deviceKeyCurrentIndex) = -1; [] call FUNC(deviceKeyFindValidIndex); if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false}; [] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 3); - true; + true }, {false}, [0xC7, [false, false, false]], false] call cba_fnc_addKeybind; //Home Key @@ -269,6 +269,7 @@ GVAR(deviceKeyCurrentIndex) = -1; [] call FUNC(deviceKeyFindValidIndex); if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false}; [] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 4); + true }, {false}, [0xC7, [false, true, false]], false] call cba_fnc_addKeybind; //CTRL + Home Key @@ -280,6 +281,7 @@ GVAR(deviceKeyCurrentIndex) = -1; _displayName = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 0); _iconImage = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 1); [_displayName, _iconImage] call FUNC(displayTextPicture); + true }, {false}, [0xC7, [true, false, false]], false] call cba_fnc_addKeybind; //SHIFT + Home Key From 560609fbed31597af709f8c44582ee9cde66f879 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 5 Jun 2015 19:46:19 -0500 Subject: [PATCH 7/7] Cleanup --- addons/atragmx/initKeybinds.sqf | 11 ++++------- addons/kestrel4500/initKeybinds.sqf | 10 +++------- addons/microdagr/CfgVehicles.hpp | 26 ++++++++++---------------- addons/microdagr/XEH_clientInit.sqf | 11 +++++------ 4 files changed, 22 insertions(+), 36 deletions(-) diff --git a/addons/atragmx/initKeybinds.sqf b/addons/atragmx/initKeybinds.sqf index 17e7ff0fcb..ddba0f12ea 100644 --- a/addons/atragmx/initKeybinds.sqf +++ b/addons/atragmx/initKeybinds.sqf @@ -17,23 +17,20 @@ //Add deviceKey entry: private ["_conditonCode", "_toggleCode", "_closeCode"]; _conditonCode = { - ("ACE_ATragMX" in (uniformItems ACE_player)) || {"ACE_ATragMX" in (vestItems ACE_player)} + [] call FUNC(can_show); }; _toggleCode = { // Conditions: canInteract - if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, objNull, ["notOnMap", "isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {}; if (GVAR(active)) exitWith { closeDialog 0; - false }; // Statement [] call FUNC(create_dialog); - false }; _closeCode = { - if (dialog && {!isNull (uiNamespace getVariable ["ATragMX_Display", displayNull])}) then { + if (GVAR(active)) exitWith { closeDialog 0; }; }; - -[(localize "STR_ACE_ATragMX_Name"), QUOTE(PATHTOF(UI\ATRAG_Icon.paa)), _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew); +[(localize LSTRING(Name)), QUOTE(PATHTOF(UI\ATRAG_Icon.paa)), _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew); diff --git a/addons/kestrel4500/initKeybinds.sqf b/addons/kestrel4500/initKeybinds.sqf index 0877196013..b4f1ce3998 100644 --- a/addons/kestrel4500/initKeybinds.sqf +++ b/addons/kestrel4500/initKeybinds.sqf @@ -25,6 +25,7 @@ {false}, [0, [true, false, false]], false, 0] call CBA_fnc_addKeybind; // (empty default key) + //Add deviceKey entry: private ["_conditonCode", "_toggleCode", "_closeCode"]; _conditonCode = { @@ -32,7 +33,7 @@ _conditonCode = { }; _toggleCode = { // Conditions: canInteract - if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {}; // Statement if (!GVAR(Overlay)) then { @@ -44,9 +45,6 @@ _toggleCode = { }; }; _closeCode = { - // Conditions: canInteract - if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; - // Statement if (GVAR(Overlay)) then { //If dispaly is open, close it: @@ -57,7 +55,5 @@ _closeCode = { GVAR(Kestrel4500) = false; closeDialog 0; }; - false }; - -[(localize "STR_ACE_Kestrel_Name"), QUOTE(PATHTOF(UI\Kestrel4500.paa)), _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew); +[(localize LSTRING(Name)), QUOTE(PATHTOF(UI\Kestrel4500.paa)), _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew); diff --git a/addons/microdagr/CfgVehicles.hpp b/addons/microdagr/CfgVehicles.hpp index 69c5aac317..d70dcc8c6f 100644 --- a/addons/microdagr/CfgVehicles.hpp +++ b/addons/microdagr/CfgVehicles.hpp @@ -3,22 +3,18 @@ class CfgVehicles { class CAManBase: Man { class ACE_SelfActions { class ACE_Equipment { - class GVAR(show) { - //Opens the mini map - displayName = CSTRING(show); - condition = QUOTE([DISPLAY_MODE_DIALOG] call FUNC(canShow)); - statement = QUOTE([DISPLAY_MODE_DISPLAY] call FUNC(openDisplay)); - showDisabled = 0; - priority = 0.2; + class GVAR(configure) { + //Opens the dialog + displayName = CSTRING(configure); + condition = QUOTE(([DISPLAY_MODE_DIALOG] call FUNC(canShow)) && {GVAR(currentShowMode) != DISPLAY_MODE_DIALOG}); + statement = QUOTE([DISPLAY_MODE_DIALOG] call FUNC(openDisplay)); icon = QUOTE(PATHTOF(UI\icon_microDAGR.paa)); exceptions[] = {"notOnMap", "isNotInside"}; - class GVAR(configure) { - //Opens the dialog - displayName = CSTRING(configure); - condition = QUOTE(([DISPLAY_MODE_DIALOG] call FUNC(canShow)) && {GVAR(currentShowMode) != DISPLAY_MODE_DIALOG}); - statement = QUOTE([DISPLAY_MODE_DIALOG] call FUNC(openDisplay)); - showDisabled = 0; - priority = 0.1; + class GVAR(show) { + //Opens the mini map + displayName = CSTRING(show); + condition = QUOTE(([DISPLAY_MODE_DISPLAY] call FUNC(canShow)) && {GVAR(currentShowMode) != DISPLAY_MODE_DISPLAY}); + statement = QUOTE([DISPLAY_MODE_DISPLAY] call FUNC(openDisplay)); icon = QUOTE(PATHTOF(UI\icon_microDAGR.paa)); exceptions[] = {"notOnMap", "isNotInside"}; }; @@ -26,8 +22,6 @@ class CfgVehicles { displayName = CSTRING(closeUnit); condition = QUOTE(GVAR(currentShowMode) != DISPLAY_MODE_CLOSED); statement = QUOTE([DISPLAY_MODE_CLOSED] call FUNC(openDisplay)); - showDisabled = 0; - priority = 0.3; icon = QUOTE(PATHTOF(UI\icon_microDAGR.paa)); exceptions[] = {"notOnMap", "isNotInside"}; }; diff --git a/addons/microdagr/XEH_clientInit.sqf b/addons/microdagr/XEH_clientInit.sqf index 0569256df3..736403cb5f 100644 --- a/addons/microdagr/XEH_clientInit.sqf +++ b/addons/microdagr/XEH_clientInit.sqf @@ -6,19 +6,18 @@ if (!hasInterface) exitWith {}; //Add deviceKey entry: private ["_conditonCode", "_toggleCode", "_closeCode"]; _conditonCode = { - ("ACE_microDAGR" in (items ace_player)) + ("ACE_microDAGR" in (items ACE_player)) }; _toggleCode = { - if !([ACE_player, objNull, ["notOnMap", "isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, objNull, ["notOnMap", "isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {}; [] call FUNC(openDisplay); //toggle display mode - true }; _closeCode = { - if (GVAR(currentShowMode) == DISPLAY_MODE_CLOSED) exitWith {false}; + if (GVAR(currentShowMode) == DISPLAY_MODE_CLOSED) exitWith {}; [DISPLAY_MODE_CLOSED] call FUNC(openDisplay); - true }; -[(localize "STR_ACE_microdagr_itemName"), QUOTE(PATHTOF(images\microDAGR_item.paa)), _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew); +[(localize LSTRING(itemName)), QUOTE(PATHTOF(images\microDAGR_item.paa)), _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew); + //Add Eventhandler: ["RangerfinderData", {_this call FUNC(recieveRangefinderData)}] call EFUNC(common,addEventHandler);