Skip to content

Commit

Permalink
Add key handling to 3DEN attribute (#6622)
Browse files Browse the repository at this point in the history
  • Loading branch information
mharis001 authored and PabstMirror committed Oct 14, 2018
1 parent 720bb3f commit 6604868
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 37 deletions.
4 changes: 3 additions & 1 deletion addons/arsenal/Cfg3DEN.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Cfg3DEN {
class GVAR(DefaultLoadoutsListAttribute) {
property = QGVAR(DefaultLoadoutsListAttribute);
value = 0;
expression = QUOTE(if (!is3DEN) then {GVAR(defaultLoadoutsList) = _value};);
expression = QUOTE(if (!is3DEN) then {GVAR(defaultLoadoutsList) = _value});
defaultValue = "[]";
validate = "none";
wikiType = "[[Array]]";
Expand Down Expand Up @@ -102,6 +102,8 @@ class Cfg3DEN {
idcLeft = IDC_ATTRIBUTE_LIST_LEFT;
idcRight = IDC_ATTRIBUTE_LIST_RIGHT;
onLBDblClick = QUOTE(_this call FUNC(attributeDblClick));
onSetFocus = QUOTE(SETUVAR(QGVAR(attributeFocus),ctrlParentControlsGroup (_this select 0)));
onKillFocus = QUOTE(SETUVAR(QGVAR(attributeFocus),nil));
x = QUOTE(5 * ATTRIBUTE_W);
y = QUOTE(35.83 * ATTRIBUTE_H);
w = QUOTE(125 * ATTRIBUTE_W);
Expand Down
34 changes: 34 additions & 0 deletions addons/arsenal/Display3DEN.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Display3DEN {
class ContextMenu: ctrlMenu {
class Items {
class Arsenal {
items[]= {"aceArsenal", "virtualArsenal"};
};
class virtualArsenal {
text = "BI Virtual Arsenal";
action = QUOTE(['arsenal'] call bis_fnc_3DENEntityMenu);
value = 0;
data = "Arsenal";
opensNewWindow = 1;
};
class aceArsenal: virtualArsenal {
text = "ACE Arsenal";
action = QUOTE(call FUNC(open3DEN));
};
};
};
class Controls {
class MenuStrip: ctrlMenuStrip {
class Items {
class Tools {
items[] += {"ACE_arsenal_portVALoadouts"};
};
class ACE_arsenal_portVALoadouts {
text = CSTRING(portLoadoutsText);
picture = QPATHTOEF(common,data\logo_ace3_ca.paa);
action = "call ace_arsenal_fnc_portVALoadouts;";
};
};
};
};
};
1 change: 1 addition & 0 deletions addons/arsenal/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PREP(attributeAddItems);
PREP(attributeClear);
PREP(attributeDblClick);
PREP(attributeInit);
PREP(attributeKeyDown);
PREP(attributeLoad);
PREP(attributeMode);
PREP(attributeSelect);
Expand Down
1 change: 1 addition & 0 deletions addons/arsenal/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class CfgPatches {
};

#include "ui\RscAttributes.hpp"
#include "Display3DEN.hpp"
#include "Cfg3DEN.hpp"
#include "CfgEventHandlers.hpp"
#include "RscDisplayMain.hpp"
Expand Down
2 changes: 1 addition & 1 deletion addons/arsenal/functions/fnc_attributeAddItems.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* None
*
* Example:
* [CONTROL, 0] call ace_arsenal_fnc_attributeAddItems
* [CONTROL] call ace_arsenal_fnc_attributeAddItems
*
* Public: No
*/
Expand Down
39 changes: 39 additions & 0 deletions addons/arsenal/functions/fnc_attributeKeyDown.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "script_component.hpp"
#include "\a3\ui_f\hpp\defineDIKCodes.inc"
/*
* Author: mharis001
* Handles keyboard input for the 3DEN attribute.
*
* Arguments:
* 0: Display <DISPLAY>
* 1: Key code <NUMBER>
*
* Return Value:
* Handled <BOOL>
*
* Example:
* [DISPLAY, 0] call ace_arsenal_fnc_attributeKeyDown
*
* Public: No
*/

params ["_display", "_keyCode"];
TRACE_2("Attribute key down",_display,_keyCode);

// Exit if attribute is not in focus
private _controlsGroup = uiNamespace getVariable QGVAR(attributeFocus);
if (isNil "_controlsGroup") exitWith {false};

switch (_keyCode) do {
case DIK_LEFT;
case DIK_NUMPADMINUS: {
[_controlsGroup, false] call FUNC(attributeSelect);
true
};
case DIK_RIGHT;
case DIK_NUMPADPLUS: {
[_controlsGroup, true] call FUNC(attributeSelect);
true
};
default {false};
};
5 changes: 5 additions & 0 deletions addons/arsenal/functions/fnc_attributeLoad.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ TRACE_1("Initializing 3DEN attribute",_value);
// Store working attribute value
uiNamespace setVariable [QGVAR(attributeValue), _value];

// Add keyDown EH to display
// Does not work properly when added to controls group
private _display = ctrlParent _controlsGroup;
_display displayAddEventHandler ["KeyDown", {call FUNC(attributeKeyDown)}];

// Handle selected mode
if (_value select 1 > 0) then {
(_controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_MODE) lbSetCurSel 1;
Expand Down
35 changes: 0 additions & 35 deletions addons/arsenal/ui/RscCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,38 +266,3 @@ class ctrlMapEmpty;
class ctrlMapMain;
class ctrlListNBox;
class ctrlCheckboxToolbar;

class Display3DEN {
class ContextMenu :ctrlMenu {
class Items {
class Arsenal {
items[]= {"aceArsenal", "virtualArsenal"};
};
class virtualArsenal {
text = "BI Virtual Arsenal";
action= QUOTE(['arsenal'] call bis_fnc_3DENEntityMenu);
value=0;
data="Arsenal";
opensNewWindow=1;
};
class aceArsenal: virtualArsenal {
text = "ACE Arsenal";
action= QUOTE(call FUNC(open3DEN));
};
};
};
class Controls {
class MenuStrip: ctrlMenuStrip {
class Items {
class Tools {
items[] += {"ACE_arsenal_portVALoadouts"};
};
class ACE_arsenal_portVALoadouts {
text = CSTRING(portLoadoutsText);
picture = QPATHTOEF(common,data\logo_ace3_ca.paa);
action = "call ace_arsenal_fnc_portVALoadouts;";
};
};
};
};
};

0 comments on commit 6604868

Please sign in to comment.