Add key handling to 3DEN attribute (#6622)

This commit is contained in:
mharis001 2018-10-14 09:54:51 -04:00 committed by PabstMirror
parent 9b6aa4c8c2
commit 50e233c22c
8 changed files with 84 additions and 37 deletions

View File

@ -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]]";
@ -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);

View File

@ -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;";
};
};
};
};
};

View File

@ -6,6 +6,7 @@ PREP(attributeAddItems);
PREP(attributeClear);
PREP(attributeDblClick);
PREP(attributeInit);
PREP(attributeKeyDown);
PREP(attributeLoad);
PREP(attributeMode);
PREP(attributeSelect);

View File

@ -15,6 +15,7 @@ class CfgPatches {
};
#include "ui\RscAttributes.hpp"
#include "Display3DEN.hpp"
#include "Cfg3DEN.hpp"
#include "CfgEventHandlers.hpp"
#include "RscDisplayMain.hpp"

View File

@ -11,7 +11,7 @@
* None
*
* Example:
* [CONTROL, 0] call ace_arsenal_fnc_attributeAddItems
* [CONTROL] call ace_arsenal_fnc_attributeAddItems
*
* Public: No
*/

View File

@ -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};
};

View File

@ -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;

View File

@ -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;";
};
};
};
};
};