Add initial context menu test

This commit is contained in:
SilentSpike 2017-12-21 16:07:21 +00:00
parent 06db96663f
commit 57c0596238
5 changed files with 92 additions and 2 deletions

View File

@ -14,6 +14,7 @@ PREP(ui_draw3D);
PREP(ui_fadeList);
PREP(ui_getTreeDataIndex);
PREP(ui_handleChildDestroyed);
PREP(ui_handleContextMenu);
PREP(ui_handleKeyDown);
PREP(ui_handleKeyUp);
PREP(ui_handleListClick);

View File

@ -0,0 +1,42 @@
/*
* Author: SilentSpike
* Function used to handle creating the context menu upon right clicking the units list
*
* Expected behaviour:
* Right clicking the list creates a context menu with relevant toggles and entries at the cursor position
*
* Arguments:
* 0: List <CONTROL>
* 1: Mouse button <NUMBER>
* 1: X Coordinate <NUMBER>
* 1: Y Coordinate <NUMBER>
* 1: Shift <BOOL>
* 1: Ctrl <BOOL>
* 1: Alt <BOOL>
*
* Return Value:
* None
*
* Example:
* [false, _this] call ace_spectator_fnc_ui_handleListClick
*
* Public: No
*/
#include "script_component.hpp"
params ["_list", "_button", "_x", "_y"];
// Don't create more than one context menu
if !(isNull (GETUVAR(GVAR(context),controlNull))) exitWith {};
// Right clicked
if (_button == 1) then {
private _menu = (ctrlParent _list) ctrlCreate [QGVAR(contextMenu), -1];
_menu ctrlSetPosition [_x,_y];
_menu ctrlCommit 0;
ctrlSetFocus _menu;
SETUVAR(GVAR(context),_menu);
};

View File

@ -20,7 +20,7 @@
*/
#include "script_component.hpp"
params ["_dblClick","_params"];
params ["_dblClick", "_params"];
_params params ["_list","_index"];
private _handled = false;

View File

@ -138,3 +138,5 @@
#define CTRL_WIDGET_WEAPON (SPEC_DISPLAY displayCtrl IDC_WIDGET_WEAPON)
#define IDC_WIDGET_THROWABLE 60042
#define CTRL_WIDGET_THROWABLE (SPEC_DISPLAY displayCtrl IDC_WIDGET_THROWABLE)
#define IDC_CONTEXT 60050

View File

@ -1,3 +1,6 @@
#include "\A3\ui_f\hpp\defineDIKCodes.inc"
class CtrlMenu;
class RscButton;
class RscControlsGroup;
class RscControlsGroupNoScrollbars;
@ -12,6 +15,48 @@ class RscToolbox;
class RscTree;
class EGVAR(common,CompassControl);
class GVAR(contextMenu): CtrlMenu {
idc = IDC_CONTEXT;
colorBackground[] = {0.1,0.1,0.1,1};
class Items {
items[] = {"Toggles"};
class Toggles {
text = "Toggles";
items[] = {
"ToggleLight",
"ToggleInfo",
"ToggleTags",
"ToggleProjectiles"
};
};
class ToggleLight {
text = "Toggle Lights";
action = QUOTE([ARR_2(displayNull, DIK_L)] call FUNC(ui_handleKeyDown));
shortcuts[] = { DIK_L };
picture="\a3\3DEN\Data\Displays\Display3DEN\ToolBar\flashlight_off_ca.paa";
};
class ToggleInfo {
text = "Toggle Widget";
action = QUOTE([ARR_2(displayNull, DIK_I)] call FUNC(ui_handleKeyDown));
shortcuts[] = { DIK_I };
};
class ToggleTags {
text = "Toggle Icons";
action = QUOTE([ARR_2(displayNull, DIK_O)] call FUNC(ui_handleKeyDown));
shortcuts[] = { DIK_O };
};
class ToggleProjectiles {
text = "Toggle Projectiles";
action = QUOTE([ARR_2(displayNull, DIK_P)] call FUNC(ui_handleKeyDown));
shortcuts[] = { DIK_P };
};
class Default {
enable = 0;
};
};
};
// Based on RscDisplayEGSpectator (sadly Arma doesn't like display inheritance)
class GVAR(display) {
idd = IDD_SPEC_DISPLAY;
@ -48,6 +93,7 @@ class GVAR(display) {
class List: RscTree {
idc = IDC_LIST;
onMouseButtonDown = QUOTE(_this call FUNC(ui_handleContextMenu));
onMouseEnter = QUOTE([false] call FUNC(ui_fadeList));
onMouseExit = QUOTE([true] call FUNC(ui_fadeList));
onTreeSelChanged = QUOTE([ARR_2(false,_this)] call FUNC(ui_handleListClick));
@ -76,7 +122,6 @@ class GVAR(display) {
class Tabs: RscToolbox {
idc = IDC_TABS;
//onToolBoxSelChanged = QUOTE(_this call FUNC(ui_handleTabSelected));
onMouseEnter = QUOTE([false] call FUNC(ui_fadeList));
onMouseExit = QUOTE([true] call FUNC(ui_fadeList));