mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
more common code cleanup
This commit is contained in:
parent
f8ecf1b8ab
commit
c7d636a533
@ -144,7 +144,6 @@ PREP(player);
|
||||
PREP(playerSide);
|
||||
PREP(positionToASL);
|
||||
PREP(progressBar);
|
||||
PREP(queueAnimation);
|
||||
PREP(readSettingFromModule);
|
||||
PREP(receiveRequest);
|
||||
PREP(removeCanInteractWithCondition);
|
||||
|
@ -10,6 +10,8 @@
|
||||
*
|
||||
* Return Value:
|
||||
* ID of the action (used to remove it later) <NUMBER>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* Return Value:
|
||||
* ID of the action (used to remove it later) <NUMBER>
|
||||
*
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
@ -1,10 +1,9 @@
|
||||
/*
|
||||
* Author: commy2, Glowbal, PabstMirror
|
||||
*
|
||||
* Draw progress bar and execute given function if succesful.
|
||||
* Finish/Failure/Conditional are all passed [_args, _elapsedTime, _totalTime, _errorCode]
|
||||
*
|
||||
* Argument:
|
||||
* Arguments:
|
||||
* 0: NUMBER - Total Time (in game "ACE_time" seconds)
|
||||
* 1: ARRAY - Arguments, passed to condition, fail and finish
|
||||
* 2: CODE or STRING - On Finish: Code called or STRING raised as event.
|
||||
@ -13,26 +12,26 @@
|
||||
* 5: CODE - (Optional) Code to check each frame
|
||||
* 6: ARRAY - (Optional) Exceptions for checking EFUNC(common,canInteractWith)
|
||||
*
|
||||
* Return value:
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [5, [], {Hint "Finished!"}, {hint "Failure!"}, "My Title"] call ace_common_fnc_progressBar
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_4(_totalTime,_args,_onFinish,_onFail);
|
||||
DEFAULT_PARAM(4,_localizedTitle,"");
|
||||
DEFAULT_PARAM(5,_condition,{true});
|
||||
DEFAULT_PARAM(6,_exceptions,[]);
|
||||
private ["_player", "_perFrameFunction", "_ctrlPos"];
|
||||
params ["_totalTime", "_args", "_onFinish", "_onFail", ["_localizedTitle", ""], ["_condition", {true}], ["_exceptions", []]];
|
||||
|
||||
private ["_player", "_ctrlPos", "_fnc_perFrameFunction"];
|
||||
|
||||
_player = ACE_player;
|
||||
|
||||
//Open Dialog and set the title
|
||||
closeDialog 0;
|
||||
createDialog QGVAR(ProgressBar_Dialog);
|
||||
|
||||
(uiNamespace getVariable QGVAR(ctrlProgressBarTitle)) ctrlSetText _localizedTitle;
|
||||
|
||||
//Adjust position based on user setting:
|
||||
@ -46,11 +45,9 @@ _ctrlPos set [1, ((0 + 29 * GVAR(SettingProgressBarLocation)) * ((((safezoneW /
|
||||
(uiNamespace getVariable QGVAR(ctrlProgressBarTitle)) ctrlSetPosition _ctrlPos;
|
||||
(uiNamespace getVariable QGVAR(ctrlProgressBarTitle)) ctrlCommit 0;
|
||||
|
||||
_fnc_perFrameFunction = {
|
||||
(_this select 0) params ["_args", "_onFinish", "_onFail", "_condition", "_player", "_startTime", "_totalTime", "_exceptions"];
|
||||
|
||||
|
||||
_perFrameFunction = {
|
||||
PARAMS_2(_parameters,_pfhID);
|
||||
EXPLODE_8_PVT(_parameters,_args,_onFinish,_onFail,_condition,_player,_startTime,_totalTime,_exceptions);
|
||||
private ["_elapsedTime", "_errorCode"];
|
||||
|
||||
_elapsedTime = ACE_time - _startTime;
|
||||
@ -63,10 +60,10 @@ _perFrameFunction = {
|
||||
if (ACE_player != _player || !alive _player) then {
|
||||
_errorCode = 2;
|
||||
} else {
|
||||
if (!([_args, _elapsedTime, _totalTime, _errorCode] call _condition)) then {
|
||||
if !([_args, _elapsedTime, _totalTime, _errorCode] call _condition) then {
|
||||
_errorCode = 3;
|
||||
} else {
|
||||
if (!([_player, objNull, _exceptions] call EFUNC(common,canInteractWith))) then {
|
||||
if !([_player, objNull, _exceptions] call EFUNC(common,canInteractWith)) then {
|
||||
_errorCode = 4;
|
||||
} else {
|
||||
if (_elapsedTime >= _totalTime) then {
|
||||
@ -84,16 +81,17 @@ _perFrameFunction = {
|
||||
if (!isNull (uiNamespace getVariable [QGVAR(ctrlProgressBar), controlNull])) then {
|
||||
closeDialog 0;
|
||||
};
|
||||
[_pfhID] call CBA_fnc_removePerFrameHandler;
|
||||
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
|
||||
if (_errorCode == 0) then {
|
||||
if ((typeName _onFinish) == (typeName "")) then {
|
||||
if (typeName _onFinish == "STRING") then {
|
||||
[_onFinish, [_args, _elapsedTime, _totalTime, _errorCode]] call FUNC(localEvent);
|
||||
} else {
|
||||
[_args, _elapsedTime, _totalTime, _errorCode] call _onFinish;
|
||||
};
|
||||
} else {
|
||||
if ((typeName _onFail) == (typeName "")) then {
|
||||
if (typeName _onFail == "STRING") then {
|
||||
[_onFail, [_args, _elapsedTime, _totalTime, _errorCode]] call FUNC(localEvent);
|
||||
} else {
|
||||
[_args, _elapsedTime, _totalTime, _errorCode] call _onFail;
|
||||
@ -105,4 +103,4 @@ _perFrameFunction = {
|
||||
};
|
||||
};
|
||||
|
||||
[_perFrameFunction, 0, [_args, _onFinish, _onFail, _condition, _player, ACE_time, _totalTime, _exceptions]] call CBA_fnc_addPerFrameHandler;
|
||||
[_fnc_perFrameFunction, 0, [_args, _onFinish, _onFail, _condition, _player, ACE_time, _totalTime, _exceptions]] call CBA_fnc_addPerFrameHandler;
|
||||
|
@ -1,10 +0,0 @@
|
||||
// by commy2
|
||||
#include "script_component.hpp"
|
||||
|
||||
terminate (missionNamespace getVariable [QGVAR(waitForAnimationHandle), scriptNull]);
|
||||
|
||||
GVAR(waitForAnimationHandle) = _this spawn {
|
||||
waitUntil {!([_this select 0] call FUNC(inTransitionAnim))};
|
||||
|
||||
_this call FUNC(doAnimation);
|
||||
};
|
@ -5,18 +5,20 @@
|
||||
* Must be called on the server, effect is global.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Module (Object)
|
||||
* 1: ACE_Parameter name (string)
|
||||
* 2: Module parameter name (string)
|
||||
* 0: Module <OBJECT>
|
||||
* 1: ACE_Parameter name <STRING>
|
||||
* 2: Module parameter name <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
if !(isServer) exitWith {};
|
||||
|
||||
PARAMS_3(_logic,_settingName,_moduleVariable);
|
||||
params ["_logic", "_settingName", "_moduleVariable"];
|
||||
|
||||
// Check if the parameter is defined in the module
|
||||
if (isNil {_logic getVariable _moduleVariable}) exitWith {
|
||||
|
@ -1,37 +1,41 @@
|
||||
/**
|
||||
* fn_recieveRequest.sqf
|
||||
* @Descr: N/A
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* N/A
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: false
|
||||
* Arguments:
|
||||
* ?
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_5(_caller,_target,_requestID,_requestMessage,_callBack);
|
||||
params ["_caller", "_target", "_requestID", "_requestMessage", "_callBack"];
|
||||
|
||||
_requestID = ("ace_recieveRequest_f_id_"+_requestID);
|
||||
|
||||
_target setvariable [_requestID, _this];
|
||||
_target setVariable [_requestID, _this];
|
||||
|
||||
if (isLocalized _requestMessage) then {
|
||||
_requestMessage = format[localize _requestMessage,[_caller] call FUNC(getName)];
|
||||
_requestMessage = format [localize _requestMessage, [_caller] call FUNC(getName)];
|
||||
} else {
|
||||
_requestMessage = format[_requestMessage,[_caller] call FUNC(getName)];
|
||||
_requestMessage = format [_requestMessage, [_caller] call FUNC(getName)];
|
||||
};
|
||||
|
||||
hint format["%1",_requestMessage];
|
||||
if !(isnil QGVAR(RECIEVE_REQUEST_TIME_OUT_SCRIPT)) then {
|
||||
hint format ["%1", _requestMessage]; // @todo ?
|
||||
|
||||
if !(isNil QGVAR(RECIEVE_REQUEST_TIME_OUT_SCRIPT)) then {
|
||||
terminate GVAR(RECIEVE_REQUEST_TIME_OUT_SCRIPT);
|
||||
};
|
||||
|
||||
if (!isnil QGVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT)) then {
|
||||
if (!isNil QGVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT)) then {
|
||||
_target removeAction GVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT);
|
||||
GVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT) = nil;
|
||||
};
|
||||
if (!isnil QGVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE)) then {
|
||||
|
||||
if (!isNil QGVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE)) then {
|
||||
_target removeAction GVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE);
|
||||
GVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE) = nil;
|
||||
};
|
||||
@ -41,24 +45,31 @@ GVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE) = _target addAction ["Decline", compile
|
||||
|
||||
GVAR(RECIEVE_REQUEST_ID_KEY_BINDING) = _requestID;
|
||||
|
||||
GVAR(RECIEVE_REQUEST_TIME_OUT_SCRIPT) = [ACE_time, _target, _requestID] spawn {
|
||||
private["_id", "_t", "_requestID", "_target"];
|
||||
_t = (_this select 0) + 40;
|
||||
_target = _this select 1;
|
||||
_requestID = _this select 2;
|
||||
_id = _target getvariable _requestID;
|
||||
waituntil {
|
||||
_id = _target getvariable _requestID;
|
||||
GVAR(RECIEVE_REQUEST_TIME_OUT_SCRIPT) = [ACE_time, _target, _requestID] spawn { // @todo
|
||||
params ["_time", "_target", "_requestID"];
|
||||
|
||||
_time = _time + 40;
|
||||
|
||||
private "_id";
|
||||
_id = _target getVariable _requestID;
|
||||
|
||||
waituntil {
|
||||
_id = _target getVariable _requestID;
|
||||
|
||||
(ACE_time > _time || isNil "_id")
|
||||
};
|
||||
|
||||
_target setVariable [_requestID, nil];
|
||||
|
||||
(ACE_time > _t || isnil "_id")};
|
||||
_target setvariable [_requestID, nil];
|
||||
GVAR(RECIEVE_REQUEST_ID_KEY_BINDING) = nil;
|
||||
if (!isnil QGVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT)) then {
|
||||
|
||||
if (!isNil QGVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT)) then {
|
||||
_target removeAction GVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT);
|
||||
GVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT) = nil;
|
||||
};
|
||||
if (!isnil QGVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE)) then {
|
||||
|
||||
if (!isNil QGVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE)) then {
|
||||
_target removeAction GVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE);
|
||||
GVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE) = nil;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -1,34 +1,30 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Remove an addAction event from a unit.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit the action is assigned to (Object)
|
||||
* 1: Name of the action, e.g. "DefaultAction" (String)
|
||||
* 2: ID of the action (Number)
|
||||
* Arguments:
|
||||
* 0: Unit the action is assigned to <OBJECT>
|
||||
* 1: Name of the action, e.g. "DefaultAction" <STRING>
|
||||
* 2: ID of the action <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None.
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_name", "_actionsVar", "_actionID", "_actions", "_currentID", "_actionIDs"];
|
||||
|
||||
PARAMS_3(_unit,_action,_id);
|
||||
params ["_unit", "_action", "_id"];
|
||||
|
||||
if (_id == -1) exitWith {};
|
||||
|
||||
_name = format ["ACE_Action_%1", _action];
|
||||
private ["_name", "_actionsVar"];
|
||||
|
||||
_name = format ["ACE_Action_%1", _action];
|
||||
_actionsVar = _unit getVariable [_name, [-1, [-1, [], []], objNull]];
|
||||
|
||||
_actionID = _actionsVar select 0;
|
||||
_actions = _actionsVar select 1;
|
||||
|
||||
_currentID = _actions select 0;
|
||||
_actionIDs = _actions select 1;
|
||||
_actions = _actions select 2;
|
||||
_actionsVar params ["_actionID", "_actionsArray"];
|
||||
_actionsArray params ["_currentID", "_actionIDs", "_actions"];
|
||||
|
||||
if (_unit != _actionsVar select 2) exitWith {};
|
||||
|
||||
|
@ -1,39 +1,37 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Remove an addAction menu event from a unit.
|
||||
*
|
||||
* Remove an addAction event from a unit.
|
||||
* Arguments:
|
||||
* 0: Unit the action is assigned to <OBJECT>
|
||||
* 1: Name of the action, e.g. "DefaultAction" <STRING>
|
||||
* 2: ID of the action <NUMBER>
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit the action is assigned to (Object)
|
||||
* 1: Name of the action, e.g. "DefaultAction" (String)
|
||||
* 2: ID of the action (Number)
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Return value:
|
||||
* None.
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_name", "_actionsVar", "_currentID", "_actionIDs", "_actions", "_actionID", "_nameVar"];
|
||||
|
||||
PARAMS_3(_unit,_action,_id);
|
||||
params ["_unit", "_action", "_id"];
|
||||
|
||||
if (_id == -1) exitWith {};
|
||||
|
||||
_name = format ["ACE_ActionMenu_%1", _action];
|
||||
private ["_name", "_actionsVar"];
|
||||
|
||||
_name = format ["ACE_ActionMenu_%1", _action];
|
||||
_actionsVar = _unit getVariable [_name, [-1, [-1, [], []]]];
|
||||
|
||||
_currentID = _actionsVar select 0;
|
||||
_actionIDs = _actionsVar select 1;
|
||||
_actions = _actionsVar select 2;
|
||||
_actionsVar params ["_currentID", "_actionIDs", "_actions"];
|
||||
|
||||
_id = _actionIDs find _id;
|
||||
|
||||
if (_id == -1) exitWith {};
|
||||
|
||||
_action = _actions select _id;
|
||||
_actionID = _action select 0;
|
||||
_nameVar = _action select 1;
|
||||
|
||||
_action params ["_actionID", "_nameVar"];
|
||||
|
||||
missionNamespace setVariable [_nameVar, nil];
|
||||
|
||||
|
@ -1,21 +1,26 @@
|
||||
/*
|
||||
* Author: Nou
|
||||
*
|
||||
* Remove all events of a certain event type.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Event name (string)
|
||||
* 0: Event name <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
private ["_eventNames", "_eventFunctions", "_eventIndex"];
|
||||
PARAMS_1(_eventName);
|
||||
|
||||
_eventNames = GVAR(events) select 0;
|
||||
params ["_eventName"];
|
||||
|
||||
GVAR(events) params ["_eventNames", "_events"];
|
||||
|
||||
private ["_eventFunctions", "_eventIndex"];
|
||||
|
||||
_eventFunctions = [];
|
||||
_eventIndex = _eventNames find _eventName;
|
||||
|
||||
if (_eventIndex != -1) then {
|
||||
(GVAR(events) select 1) set [_eventIndex, []];
|
||||
};
|
||||
_events set [_eventIndex, []];
|
||||
};
|
||||
|
@ -4,24 +4,23 @@
|
||||
* Remove a condition that gets checked by ace_common_fnc_canInteractWith.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The conditions id. (String)
|
||||
* 0: The conditions id. <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Unit can interact?
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_conditionName";
|
||||
params ["_conditionName"];
|
||||
|
||||
_conditionName = toLower (_this select 0);
|
||||
|
||||
private ["_conditions", "_conditionNames", "_conditionFuncs"];
|
||||
_conditionName = toLower _conditionName;
|
||||
|
||||
private "_conditions";
|
||||
_conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]];
|
||||
|
||||
_conditionNames = _conditions select 0;
|
||||
_conditionFuncs = _conditions select 1;
|
||||
_conditions params ["_conditionNames", "_conditionFuncs"];
|
||||
|
||||
private "_index";
|
||||
_index = _conditionNames find _conditionName;
|
||||
@ -31,4 +30,4 @@ if (_index == -1) exitWith {};
|
||||
_conditionNames deleteAt _index;
|
||||
_conditionFuncs deleteAt _index;
|
||||
|
||||
GVAR(InteractionConditions) = [_conditionNames, _conditionFuncs];
|
||||
GVAR(InteractionConditions) = _conditions;
|
||||
|
@ -1,25 +1,28 @@
|
||||
/*
|
||||
* Author: Nou
|
||||
*
|
||||
* Remove an event handler.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Event name (string)
|
||||
* 1: Event code (number)
|
||||
* 0: Event name <STRING>
|
||||
* 1: Event code <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
private ["_eventNames", "_eventFunctions", "_eventIndex"];
|
||||
|
||||
PARAMS_2(_eventName,_eventCodeIndex);
|
||||
params ["_eventName", "_eventCodeIndex"];
|
||||
|
||||
GVAR(events) params ["_eventNames", "_events"];
|
||||
|
||||
private ["_eventFunctions", "_eventIndex"];
|
||||
|
||||
_eventNames = GVAR(events) select 0;
|
||||
_eventFunctions = [];
|
||||
_eventIndex = _eventNames find _eventName;
|
||||
|
||||
if (_eventIndex != -1) then {
|
||||
_eventFunctions = (GVAR(events) select 1) select _eventIndex;
|
||||
_eventFunctions set[_eventCodeIndex, nil];
|
||||
};
|
||||
_eventFunctions = _events select _eventIndex;
|
||||
_eventFunctions set [_eventCodeIndex, nil];
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user