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
5907bccc77
commit
493ce1b092
@ -5,23 +5,20 @@
|
||||
* Arguments:
|
||||
* 0: True to disable key inputs, false to re-enable them <BOOL>
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_dlg"];
|
||||
|
||||
PARAMS_1(_state);
|
||||
params ["_state"];
|
||||
|
||||
if (_state) then {
|
||||
disableSerialization;
|
||||
|
||||
if (!isNull (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull])) exitWith {};
|
||||
if ("ACE_DisableUserInput" in ([BIS_stackedEventHandlers_onEachFrame, {_this select 0}] call FUNC(map))) exitWith {};
|
||||
if (!isNil QGVAR(disableInputPFH)) exitWith {};
|
||||
|
||||
// end TFAR and ACRE2 radio transmissions
|
||||
call FUNC(endRadioTransmission);
|
||||
@ -34,19 +31,22 @@ if (_state) then {
|
||||
closeDialog 0;
|
||||
createDialog QGVAR(DisableMouse_Dialog);
|
||||
|
||||
private "_dlg";
|
||||
_dlg = uiNamespace getVariable QGVAR(dlgDisableMouse);
|
||||
|
||||
_dlg displayAddEventHandler ["KeyDown", {
|
||||
private ["_key", "_dlg", "_ctrl", "_config", "_acc", "_index"];
|
||||
_key = _this select 1;
|
||||
params ["", "_key"];
|
||||
|
||||
if (_key == 1 && {alive player}) then {
|
||||
createDialog (["RscDisplayInterrupt", "RscDisplayMPInterrupt"] select isMultiplayer);
|
||||
|
||||
disableSerialization;
|
||||
|
||||
private ["_dlg", "_ctrl"];
|
||||
|
||||
_dlg = finddisplay 49;
|
||||
_dlg displayAddEventHandler ["KeyDown", {
|
||||
_key = _this select 1;
|
||||
params ["", "_key"];
|
||||
!(_key == 1)
|
||||
}];
|
||||
|
||||
@ -62,13 +62,15 @@ if (_state) then {
|
||||
|
||||
_ctrl = _dlg displayctrl ([104, 1010] select isMultiplayer);
|
||||
_ctrl ctrlSetEventHandler ["buttonClick", QUOTE(closeDialog 0; player setDamage 1; [false] call DFUNC(disableUserInput);)];
|
||||
_ctrl ctrlEnable (call {_config = missionConfigFile >> "respawnButton"; !isNumber _config || {getNumber _config == 1}});
|
||||
_ctrl ctrlEnable (call {private "_config"; _config = missionConfigFile >> "respawnButton"; !isNumber _config || {getNumber _config == 1}});
|
||||
_ctrl ctrlSetText "RESPAWN";
|
||||
_ctrl ctrlSetTooltip "Respawn.";
|
||||
};
|
||||
|
||||
if (_key in actionKeys "TeamSwitch" && {teamSwitchEnabled}) then {
|
||||
(uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0;
|
||||
|
||||
private "_acc";
|
||||
_acc = accTime;
|
||||
teamSwitch;
|
||||
setAccTime _acc;
|
||||
|
@ -1,25 +1,21 @@
|
||||
/*
|
||||
* Author: commy2, Glowbal
|
||||
*
|
||||
* Display a structured text with image.
|
||||
*
|
||||
* Argument:
|
||||
* Arguments:
|
||||
* 0: Text <ANY>
|
||||
* 1: Image <STRING>
|
||||
* 2: Image color <ARRAY> <OPTIONAL>
|
||||
* 3: Target Unit. Will only display if target is the player controlled object <OBJECT> <OPTIONAL>
|
||||
* 2: Image color (default: [0, 0, 0, 0]) <ARRAY>
|
||||
* 3: Target Unit. Will only display if target is the player controlled object (default: ACE_player) <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_imageColor", "_target"];
|
||||
PARAMS_2(_text,_image);
|
||||
_imageColor = if (count _this > 2) then {_this select 2} else {[1,1,1]};
|
||||
_imageColor resize 3;
|
||||
_target = if (count _this > 3) then {_this select 3} else {ACE_player};
|
||||
params ["_text", "_image", ["_imageColor", [1,1,1]], ["_target", ACE_player]];
|
||||
|
||||
if (_target != ACE_player) exitWith {};
|
||||
|
||||
@ -28,16 +24,21 @@ if (typeName _text != "TEXT") then {
|
||||
if (count _text > 0) then {
|
||||
{
|
||||
if (typeName _x == "STRING" && {isLocalized _x}) then {
|
||||
_text set [_foreachIndex, localize _x];
|
||||
_text set [_forEachIndex, localize _x];
|
||||
};
|
||||
}foreach _text;
|
||||
} forEach _text;
|
||||
|
||||
_text = format _text;
|
||||
};
|
||||
};
|
||||
|
||||
if (typeName _text == "STRING" && {isLocalized _text}) then {
|
||||
_text = localize _text;
|
||||
};
|
||||
|
||||
_text = parseText format ["<t align='center'>%1</t>", _text];
|
||||
};
|
||||
|
||||
_text = composeText [parseText format ["<img size='2' align='center' color='%2' image='%1'/>", _image, _imageColor call BIS_fnc_colorRGBtoHTML], lineBreak, _text];
|
||||
|
||||
[_text, 2] call FUNC(displayTextStructured);
|
||||
|
@ -1,23 +1,20 @@
|
||||
/*
|
||||
* Author: commy2, Glowbal
|
||||
*
|
||||
* Display a structured text.
|
||||
*
|
||||
* Argument:
|
||||
* Arguments:
|
||||
* 0: Text <ANY>
|
||||
* 1: Size of the textbox <NUMBER> <OPTIONAL>
|
||||
* 2: Target Unit. Will only display if target is the player controlled object <OBJECT> <OPTIONAL>
|
||||
* 1: Size of the textbox (default: 1.5) <NUMBER>
|
||||
* 2: Target Unit. Will only display if target is the player controlled object (default: ACE_player) <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_text", "_size", "_isShown", "_ctrlHint", "_yPos", "_xPos", "_wPos", "_hPos", "_position", "_target"];
|
||||
_text = _this select 0;
|
||||
_size = if (count _this > 1) then {_this select 1} else {1.5;};
|
||||
_target = if (count _this > 2) then {_this select 2} else {ACE_player};
|
||||
params ["_text", ["_size", 1.5], ["_target", ACE_player]];
|
||||
|
||||
if (_target != ACE_player) exitWith {};
|
||||
|
||||
@ -38,6 +35,8 @@ if (typeName _text != "TEXT") then {
|
||||
_text = composeText [lineBreak, parseText format ["<t align='center'>%1</t>", _text]];
|
||||
};
|
||||
|
||||
private ["_isShown", "_ctrlHint", "_xPos", "_yPos", "_wPos", "_hPos", "_position"];
|
||||
|
||||
_isShown = ctrlShown (uiNamespace getVariable ["ACE_ctrlHint", controlNull]);
|
||||
|
||||
("ACE_RscHint" call BIS_fnc_rscLayer) cutRsc ["ACE_RscHint", "PLAIN", 0, true];
|
||||
@ -60,8 +59,8 @@ _yPos = safeZoneY + 0.175 * safezoneH;
|
||||
_wPos = (10 *(((safezoneW / safezoneH) min 1.2) / 40));
|
||||
_hPos = (2 *((((safezoneW / safezoneH) min 1.2) / 1.2) / 25));
|
||||
|
||||
//Zeus Interface Open and Display would be under the "CREATE" list
|
||||
if (!isnull curatorCamera) then {
|
||||
// Zeus Interface Open and Display would be under the "CREATE" list
|
||||
if (!isNull curatorCamera) then {
|
||||
_xPos = _xPos min ((safezoneX + safezoneW - 12.5 * (((safezoneW / safezoneH) min 1.2) / 40)) - _wPos);
|
||||
};
|
||||
|
||||
|
@ -3,35 +3,22 @@
|
||||
*
|
||||
* Execute an animation. This is used to not break things like the unconsciousness animation.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit (Object)
|
||||
* 1: Animation (String)
|
||||
* 2: Priority of the animation. (Number, optional default: 0)
|
||||
* 0: PlayMove
|
||||
* 1: PlayMoveNow
|
||||
* 2: SwitchMove (no transitional animation, doesn't overwrite priority 1)
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Animation <STRING>
|
||||
* 2: Priority of the animation. (default: 0) <NUMBER>
|
||||
* 0 = PlayMove
|
||||
* 1 = PlayMoveNow
|
||||
* 2 = SwitchMove (no transitional animation, doesn't overwrite priority 1)
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_force"];
|
||||
|
||||
PARAMS_3(_unit,_animation,_priority);
|
||||
_force = False;
|
||||
|
||||
// no animation given
|
||||
if (isNil "_animation") exitWith {
|
||||
ACE_LOGERROR_1("No animation specified in %1.",_fnc_scriptNameParent);
|
||||
};
|
||||
|
||||
if (isNil "_priority") then {
|
||||
_priority = 0;
|
||||
};
|
||||
if (count _this > 3) then {
|
||||
_force = _this select 3;
|
||||
};
|
||||
params ["_unit", "_animation", ["_priority", 0], ["_force", false]];
|
||||
|
||||
// don't overwrite more important animations
|
||||
if (_unit getVariable ["ACE_isUnconscious", false] && {(_animation != "Unconscious")} && {!_force}) exitWith {};
|
||||
@ -47,7 +34,7 @@ if (_animation == "") then {
|
||||
//if (_animation == animationState _unit) exitWith {};
|
||||
|
||||
switch (_priority) do {
|
||||
case 0 : {
|
||||
case 0: {
|
||||
if (_unit == vehicle _unit) then {
|
||||
[_unit, format ["{_this playMove '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
|
||||
} else {
|
||||
@ -55,7 +42,7 @@ switch (_priority) do {
|
||||
[_unit, format ["{_this playMove '%1'}", _animation]] call FUNC(execRemoteFnc);
|
||||
};
|
||||
};
|
||||
case 1 : {
|
||||
case 1: {
|
||||
if (_unit == vehicle _unit) then {
|
||||
[_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
|
||||
} else {
|
||||
@ -63,7 +50,7 @@ switch (_priority) do {
|
||||
[_unit, format ["{_this playMoveNow '%1'}", _animation]] call FUNC(execRemoteFnc);
|
||||
};
|
||||
};
|
||||
case 2 : {
|
||||
case 2: {
|
||||
// try playMoveNow first
|
||||
if (_unit == vehicle _unit) then {
|
||||
[_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
|
||||
@ -80,5 +67,3 @@ switch (_priority) do {
|
||||
};
|
||||
default {};
|
||||
};
|
||||
|
||||
["Anim", [_priority, _animation]] call FUNC(log);
|
||||
|
@ -1,30 +1,24 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Drops a backback. Also returns the ground wepaon holder object of the dropped backpack.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit that has a backpack (Object)
|
||||
* Arguments:
|
||||
* 0: Unit that has a backpack <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Ground wepaon holder with backpack (Object)
|
||||
* Ground wepaon holder with backpack <OBJECT>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_unit);
|
||||
params ["_unit"];
|
||||
|
||||
private ["_backpackObject","_holder"];
|
||||
private ["_backpackObject", "_holder"];
|
||||
|
||||
_backpackObject = backpackContainer _unit;
|
||||
|
||||
_unit addBackpack "Bag_Base";
|
||||
removeBackpack _unit;
|
||||
_holder = objNull;
|
||||
|
||||
{
|
||||
if (_backpackObject in everyBackpack _x) exitWith {
|
||||
_holder = _x;
|
||||
};
|
||||
} forEach (position _unit nearObjects ["WeaponHolder", 5]);
|
||||
|
||||
_holder
|
||||
objectParent _backpackObject // return
|
||||
|
@ -1,10 +1,21 @@
|
||||
//fnc_dumpArray.sqf
|
||||
/*
|
||||
* Author: ?
|
||||
* ?
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Array to be dumped <ARRAY>
|
||||
* 1: Depth <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_pad", "_i", "_x"];
|
||||
|
||||
PARAMS_2(_var,_depth);
|
||||
params ["_var", "_depth"];
|
||||
|
||||
private "_pad";
|
||||
_pad = "";
|
||||
|
||||
for "_i" from 0 to _depth do {
|
||||
@ -14,11 +25,14 @@ for "_i" from 0 to _depth do {
|
||||
_depth = _depth + 1;
|
||||
|
||||
if (IS_ARRAY(_var)) then {
|
||||
if ((count _var) > 0) then {
|
||||
if (count _var > 0) then {
|
||||
diag_log text format["%1[", _pad];
|
||||
|
||||
{
|
||||
[_x, _depth] call FUNC(dumpArray);
|
||||
} forEach _var;
|
||||
false
|
||||
} count _var;
|
||||
|
||||
diag_log text format["%1],", _pad];
|
||||
} else {
|
||||
diag_log text format["%1[],", _pad];
|
||||
|
@ -1,49 +1,68 @@
|
||||
//fnc_dumpPerformanceCounters.sqf
|
||||
#define DEBUG_MODE_FULL
|
||||
/*
|
||||
* Author: ?
|
||||
* Dumps performance counter statistics into Logs.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
|
||||
diag_log text format["REGISTERED ACE PFH HANDLERS"];
|
||||
diag_log text format["-------------------------------------------"];
|
||||
|
||||
if (!isNil "ACE_PFH_COUNTER") then {
|
||||
{
|
||||
private ["_isActive"];
|
||||
_x params ["_pfh", "_parameters"];
|
||||
_isActive = if (!isNil {cba_common_PFHhandles select (_pfh select 0)}) then {"ACTIVE"} else {"REMOVED"};
|
||||
diag_log text format["Registered PFH: id=%1 [%2, delay %3], %4:%5", (_pfh select 0), (_isActive), (_parameters select 1), (_pfh select 1), (_pfh select 2) ];
|
||||
} forEach ACE_PFH_COUNTER;
|
||||
|
||||
private "_isActive";
|
||||
_isActive = ["ACTIVE", "REMOVED"] select isNil {CBA_common_PFHhandles select (_pfh select 0)}
|
||||
|
||||
diag_log text format ["Registered PFH: id=%1 [%2, delay %3], %4:%5", _pfh select 0, _isActive, _parameters select 1, _pfh select 1, _pfh select 2];
|
||||
false
|
||||
} count ACE_PFH_COUNTER;
|
||||
};
|
||||
|
||||
diag_log text format["ACE COUNTER RESULTS"];
|
||||
diag_log text format["-------------------------------------------"];
|
||||
diag_log text format ["ACE COUNTER RESULTS"];
|
||||
diag_log text format ["-------------------------------------------"];
|
||||
|
||||
{
|
||||
private ["_counterEntry", "_iter", "_total", "_count", "_delta", "_averageResult"];
|
||||
private ["_counterEntry", "_iter", "_total", "_count", "_averageResult", "_delta"];
|
||||
|
||||
_counterEntry = _x;
|
||||
_iter = 0;
|
||||
_total = 0;
|
||||
_count = 0;
|
||||
_averageResult = 0;
|
||||
if( (count _counterEntry) > 3) then {
|
||||
|
||||
if (count _counterEntry > 3) then {
|
||||
// calc
|
||||
{
|
||||
if(_iter > 2) then {
|
||||
if (_iter > 2) then {
|
||||
_count = _count + 1;
|
||||
_delta = (_x select 1) - (_x select 0);
|
||||
|
||||
_total = _total + _delta;
|
||||
};
|
||||
|
||||
_iter = _iter + 1;
|
||||
} forEach _counterEntry;
|
||||
false
|
||||
} count _counterEntry;
|
||||
|
||||
// results
|
||||
_averageResult = (_total / _count) * 1000;
|
||||
|
||||
// dump results
|
||||
diag_log text format["%1: Average: %2s / %3 = %4ms", (_counterEntry select 0), _total, _count, _averageResult];
|
||||
diag_log text format ["%1: Average: %2s / %3 = %4ms", _counterEntry select 0, _total, _count, _averageResult];
|
||||
} else {
|
||||
diag_log text format["%1: No results", (_counterEntry select 0) ];
|
||||
diag_log text format ["%1: No results", _counterEntry select 0];
|
||||
};
|
||||
} forEach ACE_COUNTERS;
|
||||
false
|
||||
} count ACE_COUNTERS;
|
||||
|
||||
/*
|
||||
// Dump PFH Trackers
|
||||
|
Loading…
Reference in New Issue
Block a user