Initial implementation of static zeus menu

This commit is contained in:
SilentSpike 2015-06-04 23:11:35 +01:00
parent ddc6688d03
commit 25f613b712
8 changed files with 187 additions and 11 deletions

View File

@ -0,0 +1,43 @@
class ACE_ZeusActions {
class ZeusUnits {
displayName = "Units";
icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modeunits_ca.paa";
};
class ZeusGroups {
displayName = "Groups";
icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modegroups_ca.paa";
class behaviour {
displayName = "Behaviour";
class aware {
displayName = "Aware";
icon = "\A3\UI_F_Curator\Data\RscCommon\RscAttributeBehaviour\aware_ca.paa";
statement = "{ _x setBehaviour 'AWARE'; } forEach (curatorSelected select 1);";
};
class combat {
displayName = "Combat";
icon = "\A3\UI_F_Curator\Data\RscCommon\RscAttributeBehaviour\combat_ca.paa";
statement = "{ _x setBehaviour 'COMBAT'; } forEach (curatorSelected select 1);";
};
class safe {
displayName = "Safe";
icon = "\A3\UI_F_Curator\Data\RscCommon\RscAttributeBehaviour\safe_ca.paa";
statement = "{ _x setBehaviour 'SAFE'; } forEach (curatorSelected select 1);";
};
class stealth {
displayName = "Stealth";
icon = "\A3\UI_F_Curator\Data\RscCommon\RscAttributeBehaviour\stealth_ca.paa";
statement = "{ _x setBehaviour 'STEALTH'; } forEach (curatorSelected select 1);";
};
};
};
class ZeusWaypoints {
displayName = "Waypoints";
icon = "\A3\UI_F_Curator\Data\CfgCurator\waypoint_ca.paa";
};
class ZeusMarkers {
displayName = "Markers";
icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modemarkers_ca.paa";
};
};

View File

@ -72,3 +72,11 @@ addMissionEventHandler ["Draw3D", DFUNC(render)];
if (GVAR(menuBackground)==1) then {[QGVAR(menuBackground), false] call EFUNC(common,blurScreen);};
if (GVAR(menuBackground)==2) then {(uiNamespace getVariable [QGVAR(menuBackground), displayNull]) closeDisplay 0;};
}] call EFUNC(common,addEventHandler);
// Let key work with zeus open (not perfect, enables all added hotkeys in zeus interface rather than only menu)
["zeusDisplayChanged",{
if (_this select 1) then {
(finddisplay 312) displayAddEventHandler ["KeyUp", {[_this,'keyup'] call CBA_events_fnc_keyHandler}];
(finddisplay 312) displayAddEventHandler ["KeyDown", {[_this,'keydown'] call CBA_events_fnc_keyHandler}];
};
}] call EFUNC(common,addEventHandler);

View File

@ -6,6 +6,7 @@ PREP(addActionToClass);
PREP(addActionToObject);
PREP(compileMenu);
PREP(compileMenuSelfAction);
PREP(compileMenuZeus);
PREP(collectActiveActionTree);
PREP(createAction);
PREP(ctrlSetParsedTextCached);
@ -75,4 +76,7 @@ GVAR(lastTimeSearchedActions) = -1000;
["CAManBase"] call FUNC(compileMenu);
["CAManBase"] call FUNC(compileMenuSelfAction);
// Init zeus menu
[] call FUNC(compileMenuZeus);
ADDON = true;

View File

@ -23,3 +23,5 @@ class CfgPatches {
class ACE_Extensions {
extensions[] += {"ace_break_line"};
};
#include "ACE_ZeusActions.hpp"

View File

@ -0,0 +1,94 @@
/*
* Author: SilentSpike
* Compile the zeus action menu (only to be done once)
*
* Argument:
* nil
*
* Return value:
* None
*
* Public: No
*/
#include "script_component.hpp";
// Exit if the action menu is already compiled for zeus
if !(isNil {missionNamespace getVariable [QGVAR(ZeusActions), nil]}) exitWith {};
private "_recurseFnc";
_recurseFnc = {
private ["_actions", "_displayName", "_icon", "_statement", "_condition", "_showDisabled",
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren", "_modifierFunction"];
EXPLODE_1_PVT(_this,_actionsCfg);
_actions = [];
{
_entryCfg = _x;
if(isClass _entryCfg) then {
_displayName = getText (_entryCfg >> "displayName");
_icon = getText (_entryCfg >> "icon");
_statement = compile (getText (_entryCfg >> "statement"));
_condition = getText (_entryCfg >> "condition");
if (_condition == "") then {_condition = "true"};
_insertChildren = compile (getText (_entryCfg >> "insertChildren"));
_modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
_showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
_enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
_canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
_runOnHover = true;
if (isText (_entryCfg >> "runOnHover")) then {
_runOnHover = compile getText (_entryCfg >> "runOnHover");
} else {
_runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0;
};
_condition = compile _condition;
_children = [_entryCfg] call _recurseFnc;
_entry = [
[
configName _entryCfg,
_displayName,
_icon,
_statement,
_condition,
_insertChildren,
{},
[0,0,0],
10, //distace
[_showDisabled,_enableInside,_canCollapse,_runOnHover],
_modifierFunction
],
_children
];
_actions pushBack _entry;
};
} forEach (configProperties [_actionsCfg, "isClass _x", true]);
_actions
};
private ["_actionsCfg"];
_actionsCfg = configFile >> "ACE_ZeusActions";
// Create a master action to base zeus actions on
GVAR(ZeusActions) = [
[
[
"ACE_ZeusActions",
localize LSTRING(ZeusActionsRoot),
"\A3\Ui_F_Curator\Data\Logos\arma3_zeus_icon_ca.paa",
{true},
{true},
{},
{},
{[0,0,0]},
10,
[false,true,false]
],
[_actionsCfg] call _recurseFnc
]
];

View File

@ -34,6 +34,7 @@ GVAR(ParsedTextCached) = [];
GVAR(useCursorMenu) = (vehicle ACE_player != ACE_player) ||
visibleMap ||
(!isNull curatorCamera) ||
{(_menuType == 1) && {(isWeaponDeployed ACE_player) || GVAR(AlwaysUseCursorSelfInteraction) || {cameraView == "GUNNER"}}} ||
{(_menuType == 0) && GVAR(AlwaysUseCursorInteraction)};
@ -46,7 +47,7 @@ for "_i" from 0 to (count GVAR(iconCtrls))-1 do {
GVAR(iconCtrls) resize GVAR(iconCount);
if (GVAR(useCursorMenu)) then {
(findDisplay 46) createDisplay QGVAR(cursorMenu); //"RscCinemaBorder";//
(findDisplay ([312,46] select (isNull curatorCamera))) createDisplay QGVAR(cursorMenu); //"RscCinemaBorder";//
(finddisplay 91919) displayAddEventHandler ["KeyUp", {[_this,'keyup'] call CBA_events_fnc_keyHandler}];
(finddisplay 91919) displayAddEventHandler ["KeyDown", {[_this,'keydown'] call CBA_events_fnc_keyHandler}];
// The dialog sets:

View File

@ -118,24 +118,48 @@ _fnc_renderSelfActions = {
} forEach _classActions;
};
_fnc_renderZeusActions = {
_target = _this;
// Iterate through zeus actions, find base level actions and render them if appropiate
_pos = if !(GVAR(useCursorMenu)) then {
_virtualPoint = (((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)) vectorAdd GVAR(selfMenuOffset)) call EFUNC(common,ASLToPosition);
_wavesAtOrigin = [(positionCameraToWorld [0, 0, 0])] call EFUNC(common,waveHeightAt);
_wavesAtVirtualPoint = [_virtualPoint] call EFUNC(common,waveHeightAt);
_virtualPoint set [2, ((_virtualPoint select 2) - _wavesAtOrigin + _wavesAtVirtualPoint)];
_virtualPoint
} else {
[0.5, 0.5]
};
{
_action = _x;
[_target, _action, _pos] call FUNC(renderBaseMenu);
} forEach GVAR(ZeusActions);
};
GVAR(collectedActionPoints) resize 0;
// Render nearby actions, unit self actions or vehicle self actions as appropiate
if (GVAR(openedMenuType) == 0) then {
if (vehicle ACE_player == ACE_player) then {
if (ACE_diagTime > GVAR(lastTimeSearchedActions) + 0.20) then {
// Once every 0.2 secs, collect nearby objects active and visible action points and render them
call _fnc_renderNearbyActions;
if (isNull curatorCamera) then {
if (vehicle ACE_player == ACE_player) then {
if (ACE_diagTime > GVAR(lastTimeSearchedActions) + 0.20) then {
// Once every 0.2 secs, collect nearby objects active and visible action points and render them
call _fnc_renderNearbyActions;
} else {
// The rest of the frames just draw the same action points rendered the last frame
call _fnc_renderLastFrameActions;
};
} else {
// The rest of the frames just draw the same action points rendered the last frame
call _fnc_renderLastFrameActions;
// Render vehicle self actions when in vehicle
(vehicle ACE_player) call _fnc_renderSelfActions;
};
} else {
(vehicle ACE_player) call _fnc_renderSelfActions;
// Render zeus actions when zeus open
(getAssignedCuratorLogic player) call _fnc_renderZeusActions;
};
} else {
ACE_player call _fnc_renderSelfActions;
};

View File

@ -36,7 +36,7 @@ _pos = if((count _this) > 2) then {
};
// For non-self actions, exit if the action is too far away or ocluded
if (GVAR(openedMenuType) == 0 && vehicle ACE_player == ACE_player &&
if (GVAR(openedMenuType) == 0 && (vehicle ACE_player == ACE_player) && (isNull curatorCamera) &&
{
private ["_headPos","_actualDistance"];
_headPos = ACE_player modelToWorldVisual (ACE_player selectionPosition "pilot");