mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #191 from KoffeinFlummi/interact-improvements
Interact improvements
This commit is contained in:
commit
72543e343c
@ -19,6 +19,7 @@ PREP(ASLToPosition);
|
||||
PREP(beingCarried);
|
||||
PREP(binarizeNumber);
|
||||
PREP(blurScreen);
|
||||
PREP(cachedCall);
|
||||
PREP(callCustomEventHandlers);
|
||||
PREP(callCustomEventHandlersGlobal);
|
||||
PREP(canGetInPosition);
|
||||
@ -47,6 +48,7 @@ PREP(displayTextPicture);
|
||||
PREP(displayTextStructured);
|
||||
PREP(doAnimation);
|
||||
PREP(endRadioTransmission);
|
||||
PREP(eraseCache);
|
||||
PREP(execNextFrame);
|
||||
PREP(execPersistentFnc);
|
||||
PREP(execRemoteFnc);
|
||||
|
30
addons/common/functions/fnc_cachedCall.sqf
Normal file
30
addons/common/functions/fnc_cachedCall.sqf
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Author: CAA-Picard and Jaynus
|
||||
* Returns the result of the function and caches it up to a given time
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Parameters <ARRAY>
|
||||
* 1: Function <CODE>
|
||||
* 2: Namespace to store the cache on <NAMESPACE>
|
||||
* 3: Cache uid <STRING>
|
||||
* 4: Max duration of the cache <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* Result of the function <ANY>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_5_PVT(_this,_params,_function,_namespace,_uid,_duration);
|
||||
|
||||
if (((_namespace getVariable [_uid, [-99999]]) select 0) < diag_tickTime) then {
|
||||
_namespace setVariable [_uid, [diag_tickTime + _duration, _params call _function]];
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
diag_log format ["Calculated result: %1 %2", _namespace, _uid];
|
||||
} else {
|
||||
diag_log format ["Cached result : %1 %2", _namespace, _uid];
|
||||
#endif
|
||||
};
|
||||
|
||||
(_namespace getVariable _uid) select 1
|
18
addons/common/functions/fnc_eraseCache.sqf
Normal file
18
addons/common/functions/fnc_eraseCache.sqf
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Deletes a cached result
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Namespace to store the cache on <NAMESPACE>
|
||||
* 1: Cache uid <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_2_PVT(_this,_namespace,_uid);
|
||||
|
||||
_namespace setVariable [_uid, nil];
|
@ -3,6 +3,7 @@
|
||||
ADDON = false;
|
||||
|
||||
PREP(addAction);
|
||||
PREP(addClassAction);
|
||||
PREP(compileMenu);
|
||||
PREP(compileMenuSelfAction);
|
||||
PREP(collectActiveActionTree);
|
||||
@ -11,6 +12,7 @@ PREP(keyDownSelfAction);
|
||||
PREP(keyUp);
|
||||
PREP(keyUpSelfAction);
|
||||
PREP(removeAction);
|
||||
PREP(removeClassAction);
|
||||
PREP(render);
|
||||
PREP(renderIcon);
|
||||
PREP(renderBaseMenu);
|
||||
@ -23,7 +25,8 @@ GVAR(keyDownTime) = 0;
|
||||
GVAR(lastTime) = diag_tickTime;
|
||||
GVAR(rotationAngle) = 0;
|
||||
|
||||
GVAR(selectedAction) = {};
|
||||
GVAR(selectedAction) = [[],[]];
|
||||
GVAR(selectedStatement) = {};
|
||||
GVAR(actionSelected) = false;
|
||||
GVAR(selectedTarget) = objNull;
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
* 6: Statement <CODE>
|
||||
* 7: Condition <CODE>
|
||||
* 8: Distance <NUMBER>
|
||||
* 9: Other parameters <ARRAY> (Optional)
|
||||
*
|
||||
* Return value:
|
||||
* The entry full path, which can be used to remove the entry, or add children entries <ARRAY>.
|
||||
@ -26,7 +27,7 @@
|
||||
|
||||
EXPLODE_9_PVT(_this,_object,_typeNum,_fullPath,_displayName,_icon,_position,_statement,_condition,_distance);
|
||||
|
||||
private ["_varName","_actions"];
|
||||
private ["_varName","_actions","_params","_entry"];
|
||||
|
||||
_varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum;
|
||||
_actions = _object getVariable [_varName, []];
|
||||
@ -34,7 +35,11 @@ if((count _actions) == 0) then {
|
||||
_object setVariable [_varName, _actions];
|
||||
};
|
||||
|
||||
private "_entry";
|
||||
_params = [false,false,false,false];
|
||||
if (count _this > 9) then {
|
||||
_params = _this select 9;
|
||||
};
|
||||
|
||||
_entry = [
|
||||
[
|
||||
_displayName,
|
||||
@ -43,7 +48,7 @@ _entry = [
|
||||
_statement,
|
||||
_condition,
|
||||
_distance,
|
||||
[false,false,false],
|
||||
_params,
|
||||
+ _fullPath
|
||||
],
|
||||
[]
|
||||
|
87
addons/interact_menu/functions/fnc_addClassAction.sqf
Normal file
87
addons/interact_menu/functions/fnc_addClassAction.sqf
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Add an ACE action to a class, under a certain path
|
||||
* Note: This function is NOT global.
|
||||
*
|
||||
* Argument:
|
||||
* 0: TypeOf of the class <STRING>
|
||||
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
|
||||
* 2: Full path of the new action <ARRAY>
|
||||
* 3: Name of the action shown in the menu <STRING>
|
||||
* 4: Icon <STRING>
|
||||
* 5: Position (Position or Selection Name) <POSITION> or <STRING>
|
||||
* 6: Statement <CODE>
|
||||
* 7: Condition <CODE>
|
||||
* 8: Distance <NUMBER>
|
||||
* 9: Other parameters <ARRAY> (Optional)
|
||||
*
|
||||
* Return value:
|
||||
* The entry full path, which can be used to remove the entry, or add children entries <ARRAY>.
|
||||
*
|
||||
* Example:
|
||||
* [typeOf cursorTarget, 0,["ACE_TapShoulderRight","VulcanPinch"],"Vulcan Pinch","",[0,0,0],{_target setDamage 1;},{true},100] call ace_interact_menu_fnc_addClassAction;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_9_PVT(_this,_objectType,_typeNum,_fullPath,_displayName,_icon,_position,_statement,_condition,_distance);
|
||||
|
||||
private ["_varName","_actions","_params","_entry", "_parentLevel", "_foundParentLevel", "_fnc_findFolder"];
|
||||
|
||||
_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
|
||||
_actions = missionNamespace getVariable [_varName, []];
|
||||
if((count _actions) == 0) then {
|
||||
missionNamespace setVariable [_varName, _actions];
|
||||
};
|
||||
|
||||
_params = [false,false,false,false];
|
||||
if (count _this > 9) then {
|
||||
_params = _this select 9;
|
||||
};
|
||||
|
||||
// Search the class action trees and find where to insert the entry
|
||||
_parentLevel = _actions;
|
||||
_foundParentLevel = false;
|
||||
|
||||
_fnc_findFolder = {
|
||||
EXPLODE_3_PVT(_this,_fullPath,_level,_classActions);
|
||||
|
||||
if (count _fullPath == _level + 1) then {
|
||||
_parentLevel = _classActions;
|
||||
_foundParentLevel = true;
|
||||
};
|
||||
|
||||
if (_foundParentLevel) exitWith {};
|
||||
|
||||
{
|
||||
EXPLODE_2_PVT(_x,_actionData,_actionChildren);
|
||||
if (((_actionData select 7) select _level) isEqualTo (_fullPath select _level)) exitWith {
|
||||
// The action should go somewhere in here
|
||||
[_fullPath, _level + 1, _actionChildren] call _fnc_findFolder;
|
||||
};
|
||||
} forEach _classActions;
|
||||
};
|
||||
|
||||
[_fullPath, 0, _actions] call _fnc_findFolder;
|
||||
|
||||
// Exit if there's no entry point to insert this action
|
||||
if (!_foundParentLevel) exitWith {};
|
||||
|
||||
_entry = [
|
||||
[
|
||||
_displayName,
|
||||
_icon,
|
||||
_position,
|
||||
_statement,
|
||||
_condition,
|
||||
_distance,
|
||||
_params,
|
||||
+ _fullPath
|
||||
],
|
||||
[]
|
||||
];
|
||||
|
||||
_parentLevel pushBack _entry;
|
||||
|
||||
_fullPath
|
@ -24,7 +24,7 @@ if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {};
|
||||
private "_recurseFnc";
|
||||
_recurseFnc = {
|
||||
private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_selection", "_condition", "_showDisabled",
|
||||
"_enableInside", "_children", "_entry", "_entryCfg", "_fullPath"];
|
||||
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_fullPath"];
|
||||
EXPLODE_2_PVT(_this,_actionsCfg,_parentPath);
|
||||
_actions = [];
|
||||
|
||||
@ -48,6 +48,7 @@ _recurseFnc = {
|
||||
_showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
|
||||
_enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
|
||||
_canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
|
||||
_runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0;
|
||||
|
||||
_fullPath = (+ _parentPath);
|
||||
_fullPath pushBack (configName _entryCfg);
|
||||
@ -63,7 +64,7 @@ _recurseFnc = {
|
||||
_statement,
|
||||
_condition,
|
||||
_distance,
|
||||
[_showDisabled,_enableInside,_canCollapse],
|
||||
[_showDisabled,_enableInside,_canCollapse,_runOnHover],
|
||||
_fullPath
|
||||
],
|
||||
_children
|
||||
|
@ -24,7 +24,7 @@ if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {};
|
||||
private "_recurseFnc";
|
||||
_recurseFnc = {
|
||||
private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_selection", "_condition", "_showDisabled",
|
||||
"_enableInside", "_children", "_entry", "_entryCfg", "_fullPath"];
|
||||
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_fullPath"];
|
||||
EXPLODE_2_PVT(_this,_actionsCfg,_parentPath);
|
||||
_actions = [];
|
||||
|
||||
@ -45,6 +45,7 @@ _recurseFnc = {
|
||||
_showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
|
||||
_enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
|
||||
_canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
|
||||
_runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0;
|
||||
|
||||
_fullPath = (+ _parentPath);
|
||||
_fullPath pushBack (configName _entryCfg);
|
||||
@ -60,7 +61,7 @@ _recurseFnc = {
|
||||
_statement,
|
||||
_condition,
|
||||
10, //distace
|
||||
[_showDisabled,_enableInside,_canCollapse],
|
||||
[_showDisabled,_enableInside,_canCollapse,_runOnHover],
|
||||
_fullPath
|
||||
],
|
||||
_children
|
||||
|
@ -12,13 +12,18 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
GVAR(keyDown) = false;
|
||||
if(GVAR(actionSelected)) then {
|
||||
this = GVAR(selectedTarget);
|
||||
_player = ACE_Player;
|
||||
_target = GVAR(selectedTarget);
|
||||
[GVAR(selectedTarget), ACE_player] call GVAR(selectedAction);
|
||||
[GVAR(selectedTarget), ACE_player] call GVAR(selectedStatement);
|
||||
};
|
||||
|
||||
if (GVAR(keyDown)) then {
|
||||
GVAR(keyDown) = false;
|
||||
["interactMenuClosed", [0]] call FUNC(localEvent);
|
||||
};
|
||||
|
||||
GVAR(expanded) = false;
|
||||
GVAR(lastPath) = [];
|
||||
GVAR(menuDepthPath) = [];
|
||||
|
@ -16,13 +16,18 @@ if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then {
|
||||
closeDialog 0;
|
||||
};
|
||||
|
||||
GVAR(keyDownSelfAction) = false;
|
||||
if(GVAR(actionSelected)) then {
|
||||
this = GVAR(selectedTarget);
|
||||
_player = ACE_Player;
|
||||
_target = GVAR(selectedTarget);
|
||||
[GVAR(selectedTarget), ACE_player] call GVAR(selectedAction);
|
||||
[GVAR(selectedTarget), ACE_player] call GVAR(selectedStatement);
|
||||
};
|
||||
|
||||
if (GVAR(keyDownSelfAction)) then {
|
||||
GVAR(keyDownSelfAction) = false;
|
||||
["interactMenuClosed", [1]] call FUNC(localEvent);
|
||||
};
|
||||
|
||||
GVAR(expanded) = false;
|
||||
GVAR(lastPath) = [];
|
||||
GVAR(menuDepthPath) = [];
|
||||
|
72
addons/interact_menu/functions/fnc_removeClassAction.sqf
Normal file
72
addons/interact_menu/functions/fnc_removeClassAction.sqf
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Removes a class action from a class
|
||||
* Note: This function is NOT global.
|
||||
*
|
||||
* Argument:
|
||||
* 0: TypeOf of the class <STRING>
|
||||
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
|
||||
* 2: Full path of the new action <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [typeOf cursorTarget, 0,["ACE_TapShoulderRight","VulcanPinch"]] call ace_interact_menu_fnc_removeClassAction;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_3_PVT(_this,_objectType,_typeNum,_fullPath);
|
||||
|
||||
private ["_varName","_actions","_parentLevel", "_actionIndex", "_foundAction", "_fnc_findFolder"];
|
||||
|
||||
_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
|
||||
_actions = missionNamespace getVariable [_varName, []];
|
||||
|
||||
// Search the class action trees and find where to insert the entry
|
||||
_parentLevel = _actions;
|
||||
_actionIndex = -1;
|
||||
_foundAction = false;
|
||||
|
||||
_fnc_findFolder = {
|
||||
EXPLODE_3_PVT(_this,_fullPath,_level,_classActions);
|
||||
|
||||
if (count _fullPath == _level + 1) then {
|
||||
_parentLevel = _classActions;
|
||||
};
|
||||
|
||||
{
|
||||
EXPLODE_2_PVT(_x,_actionData,_actionChildren);
|
||||
if (((_actionData select 7) select _level) isEqualTo (_fullPath select _level)) exitWith {
|
||||
if (_level + 1 == count _fullPath) exitWith {
|
||||
_actionIndex = _forEachIndex;
|
||||
_foundAction = true;
|
||||
};
|
||||
[_fullPath, _level + 1, _actionChildren] call _fnc_findFolder;
|
||||
};
|
||||
if (_foundAction) exitWith {};
|
||||
} forEach _classActions;
|
||||
};
|
||||
|
||||
[_fullPath, 0, _actions] call _fnc_findFolder;
|
||||
|
||||
// Exit if the action was not found
|
||||
if (!_foundAction) exitWith {};
|
||||
|
||||
_entry = [
|
||||
[
|
||||
_displayName,
|
||||
_icon,
|
||||
_position,
|
||||
_statement,
|
||||
_condition,
|
||||
_distance,
|
||||
_params,
|
||||
+ _fullPath
|
||||
],
|
||||
[]
|
||||
];
|
||||
|
||||
_parentLevel deleteAt _actionIndex;
|
@ -143,7 +143,9 @@ if(GVAR(keyDown) || GVAR(keyDownSelfAction)) then {
|
||||
_foundTarget = true;
|
||||
GVAR(actionSelected) = true;
|
||||
GVAR(selectedTarget) = (_closest select 0) select 0;
|
||||
GVAR(selectedAction) = (((_closest select 0) select 1) select 0) select 3;
|
||||
GVAR(selectedAction) = (_closest select 0) select 1;
|
||||
GVAR(selectedStatement) = ((GVAR(selectedAction)) select 0) select 3;
|
||||
|
||||
_misMatch = false;
|
||||
_hoverPath = (_closest select 2);
|
||||
|
||||
@ -165,6 +167,16 @@ if(GVAR(keyDown) || GVAR(keyDownSelfAction)) then {
|
||||
if(!GVAR(expanded) && diag_tickTime-GVAR(startHoverTime) > 0.25) then {
|
||||
GVAR(expanded) = true;
|
||||
GVAR(menuDepthPath) = +GVAR(lastPath);
|
||||
|
||||
// Execute the current action if it's run on hover
|
||||
private "_runOnHover";
|
||||
_runOnHover = ((GVAR(selectedAction) select 0) select 6) select 3;
|
||||
if (_runOnHover) then {
|
||||
this = GVAR(selectedTarget);
|
||||
_player = ACE_Player;
|
||||
_target = GVAR(selectedTarget);
|
||||
[GVAR(selectedTarget), ACE_player] call GVAR(selectedStatement);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -58,8 +58,14 @@ if ((_sPos select 1) < safeZoneY || (_sPos select 1) > safeZoneY + safeZon
|
||||
|
||||
|
||||
// Collect active tree
|
||||
// @todo: cache activeActionTree?
|
||||
_activeActionTree = ([_object, _baseAction] call FUNC(collectActiveActionTree));
|
||||
private "_uid";
|
||||
_uid = format [QGVAR(ATCache_%1), (_actionData select 7) select 0];
|
||||
_activeActionTree = [
|
||||
[_object, _baseAction],
|
||||
DFUNC(collectActiveActionTree),
|
||||
_object, _uid, 0.2
|
||||
] call EFUNC(common,cachedCall);
|
||||
|
||||
|
||||
// Check if there's something left for rendering
|
||||
if (count _activeActionTree == 0) exitWith {false};
|
||||
|
@ -347,6 +347,7 @@ class CfgVehicles {
|
||||
|
||||
class ACE_Actions {
|
||||
class ACE_Head {
|
||||
runOnHover = 1;
|
||||
statement = QUOTE([ARR_3(_target, true, 0)] call DFUNC(displayPatientInformation));
|
||||
|
||||
class Bandage_Head {
|
||||
@ -406,6 +407,7 @@ class CfgVehicles {
|
||||
displayName = "Medical";
|
||||
distance = 5.0;
|
||||
condition = "true";
|
||||
runOnHover = 1;
|
||||
statement = QUOTE([ARR_3(_target, true, 1)] call DFUNC(displayPatientInformation));
|
||||
showDisabled = 1;
|
||||
priority = 2;
|
||||
@ -481,6 +483,7 @@ class CfgVehicles {
|
||||
};
|
||||
};
|
||||
class ACE_ArmLeft {
|
||||
runOnHover = 1;
|
||||
statement = QUOTE([ARR_3(_target, true, 2)] call DFUNC(displayPatientInformation));
|
||||
|
||||
class Bandage_LeftArm {
|
||||
@ -602,6 +605,7 @@ class CfgVehicles {
|
||||
};
|
||||
};
|
||||
class ACE_ArmRight {
|
||||
runOnHover = 1;
|
||||
statement = QUOTE([ARR_3(_target, true, 3)] call DFUNC(displayPatientInformation));
|
||||
class Bandage_RightArm {
|
||||
displayName = "Bandage Right Arm";
|
||||
@ -723,6 +727,7 @@ class CfgVehicles {
|
||||
|
||||
};
|
||||
class ACE_LegLeft {
|
||||
runOnHover = 1;
|
||||
statement = QUOTE([ARR_3(_target, true, 4)] call DFUNC(displayPatientInformation));
|
||||
class Bandage_LeftLeg {
|
||||
displayName = "Bandage Left Leg";
|
||||
@ -834,6 +839,7 @@ class CfgVehicles {
|
||||
};
|
||||
};
|
||||
class ACE_LegRight {
|
||||
runOnHover = 1;
|
||||
statement = QUOTE([ARR_3(_target, true, 5)] call DFUNC(displayPatientInformation));
|
||||
class Bandage_RightLeg {
|
||||
displayName = "Bandage Right Leg";
|
||||
|
Loading…
Reference in New Issue
Block a user