Skip to content

Commit

Permalink
Merge pull request #1519 from SilentSpike/gm_revamp
Browse files Browse the repository at this point in the history
Introducing zeus interaction menu
  • Loading branch information
nicolasbadano committed Jun 27, 2015
2 parents 0432cd0 + f2e5f72 commit f52babe
Show file tree
Hide file tree
Showing 11 changed files with 428 additions and 20 deletions.
12 changes: 8 additions & 4 deletions addons/interact_menu/XEH_clientInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,13 @@ addMissionEventHandler ["Draw3D", DFUNC(render)];

["ACE3 Common", QGVAR(InteractKey), (localize LSTRING(InteractKey)),
{
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering", "isNotSitting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Statement
[0] call FUNC(keyDown)
},{[0,false] call FUNC(keyUp)},
[219, [false, false, false]], false] call cba_fnc_addKeybind; //Left Windows Key

["ACE3 Common", QGVAR(SelfInteractKey), (localize LSTRING(SelfInteractKey)),
{
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering", "isNotSitting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Statement
[1] call FUNC(keyDown)
},{[1,false] call FUNC(keyUp)},
Expand Down Expand Up @@ -72,3 +68,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);
4 changes: 4 additions & 0 deletions addons/interact_menu/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PREP(addActionToClass);
PREP(addActionToObject);
PREP(compileMenu);
PREP(compileMenuSelfAction);
PREP(compileMenuZeus);
PREP(collectActiveActionTree);
PREP(createAction);
PREP(ctrlSetParsedTextCached);
Expand Down Expand Up @@ -75,4 +76,7 @@ GVAR(lastTimeSearchedActions) = -1000;
["CAManBase"] call FUNC(compileMenu);
["CAManBase"] call FUNC(compileMenuSelfAction);

// Init zeus menu
[] call FUNC(compileMenuZeus);

ADDON = true;
94 changes: 94 additions & 0 deletions addons/interact_menu/functions/fnc_compileMenuZeus.sqf
Original file line number Diff line number Diff line change
@@ -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
]
];
13 changes: 12 additions & 1 deletion addons/interact_menu/functions/fnc_keyDown.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ EXPLODE_1_PVT(_this,_menuType);

if (GVAR(openedMenuType) == _menuType) exitWith {true};

// Conditions: canInteract (these don't apply to zeus)
if ((isNull curatorCamera) && {
!([ACE_player, objNull, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering", "isNotSitting"]] call EFUNC(common,canInteractWith))
}) exitWith {false};

while {dialog} do {
closeDialog 0;
};
Expand All @@ -34,6 +39,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)};

Expand All @@ -46,7 +52,12 @@ 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";//
// Don't close zeus interface if open
if (isNull curatorCamera) then {
(findDisplay 46) createDisplay QGVAR(cursorMenu); //"RscCinemaBorder";//
} else {
createDialog QGVAR(cursorMenu);
};
(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:
Expand Down
4 changes: 2 additions & 2 deletions addons/interact_menu/functions/fnc_keyUp.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ if(GVAR(actionSelected)) then {
};
};

["interactMenuClosed", [GVAR(openedMenuType)]] call EFUNC(common,localEvent);

GVAR(keyDown) = false;
GVAR(keyDownSelfAction) = false;
GVAR(openedMenuType) = -1;
Expand All @@ -54,6 +56,4 @@ GVAR(expanded) = false;
GVAR(lastPath) = [];
GVAR(menuDepthPath) = [];

["interactMenuClosed", [GVAR(openedMenuType)]] call EFUNC(common,localEvent);

true
29 changes: 20 additions & 9 deletions addons/interact_menu/functions/fnc_renderActionPoints.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,35 @@ _fnc_renderSelfActions = {
} forEach _classActions;
};

_fnc_renderZeusActions = {
{
_action = _x;
[_this, _action, [0.5, 0.5]] 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;
};
Expand Down
2 changes: 1 addition & 1 deletion addons/interact_menu/functions/fnc_renderBaseMenu.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
5 changes: 4 additions & 1 deletion addons/interact_menu/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
<Italian>Interazioni con veicoli</Italian>
<Portuguese>Ações de Veículos</Portuguese>
</Key>
<Key ID="STR_ACE_Interact_Menu_ZeusActionsRoot">
<English>Zeus Actions</English>
</Key>
<Key ID="STR_ACE_Interact_Menu_ColorTextMax">
<English>Interaction - Text Max</English>
<Polish>Interakcja - Tekst max</Polish>
Expand Down Expand Up @@ -242,4 +245,4 @@
<Czech>Černý obraz</Czech>
</Key>
</Package>
</Project>
</Project>
Loading

0 comments on commit f52babe

Please sign in to comment.