mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
replace mainDisplayLoaded event with DisplayLoad XEH and add ACE version to main menu (CBA help)
This commit is contained in:
parent
f5ef7b6b2d
commit
5e486869c0
@ -13,6 +13,12 @@ class Extended_PostInit_EventHandlers {
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_DisplayLoad_EventHandlers {
|
||||
class RscDisplayMission {
|
||||
ADDON = QUOTE(_this call COMPILE_FILE(XEH_mainDislayLoad));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_InitPost_EventHandlers {
|
||||
class All {
|
||||
class GVAR(executePersistent) {
|
||||
|
6
addons/common/XEH_mainDislayLoad.sqf
Normal file
6
addons/common/XEH_mainDislayLoad.sqf
Normal file
@ -0,0 +1,6 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
GVAR(ScrollWheelFrame) = diag_frameno;
|
||||
|
||||
call COMPILE_FILE(init_handleScrollWheel);
|
||||
call COMPILE_FILE(init_handleModifierKey);
|
@ -290,31 +290,6 @@ if (!hasInterface) exitWith {};
|
||||
|
||||
call FUNC(assignedItemFix);
|
||||
|
||||
GVAR(ScrollWheelFrame) = diag_frameno;
|
||||
|
||||
["mainDisplayLoaded", {
|
||||
[{
|
||||
call FUNC(handleScrollWheelInit);
|
||||
call FUNC(handleModifierKeyInit);
|
||||
}, [], 0.1] call FUNC(waitAndExecute); // needs delay, otherwise doesn't work without pressing "RESTART" in editor once. Tested in 1.52RC
|
||||
}] call FUNC(addEventHandler);
|
||||
|
||||
// add PFH to execute event that fires when the main display (46) is created
|
||||
private _fnc_initMainDisplayCheck = {
|
||||
[{
|
||||
if !(isNull findDisplay 46) then {
|
||||
// Raise ACE event locally
|
||||
["mainDisplayLoaded", [findDisplay 46]] call FUNC(localEvent);
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
||||
|
||||
call _fnc_initMainDisplayCheck;
|
||||
|
||||
// repeat this every time a savegame is loaded
|
||||
addMissionEventHandler ["Loaded", _fnc_initMainDisplayCheck];
|
||||
|
||||
// @todo remove?
|
||||
enableCamShake true;
|
||||
|
||||
|
@ -94,9 +94,7 @@ PREP(goKneeling);
|
||||
PREP(hadamardProduct);
|
||||
PREP(handleModifierKey);
|
||||
PREP(handleModifierKeyUp);
|
||||
PREP(handleModifierKeyInit);
|
||||
PREP(handleScrollWheel);
|
||||
PREP(handleScrollWheelInit);
|
||||
PREP(hasItem);
|
||||
PREP(hasMagazine);
|
||||
PREP(headBugFix);
|
||||
|
@ -8,7 +8,7 @@ class CfgPatches {
|
||||
requiredAddons[] = {"ace_main","ace_modules"};
|
||||
author[] = {"KoffeinFlummi"};
|
||||
authorUrl = "https://github.com/KoffeinFlummi/";
|
||||
VERSION_CONFIG;
|
||||
VERSION_CONFIG_COMMON;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Initializes the modifier key handler.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public : No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
(findDisplay 46) displayAddEventHandler ["KeyDown", FUNC(handleModifierKey)];
|
||||
(findDisplay 46) displayAddEventHandler ["KeyUp", FUNC(handleModifierKeyUp)];
|
20
addons/common/init_handleModifierKey.sqf
Normal file
20
addons/common/init_handleModifierKey.sqf
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Initializes the modifier key handler.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public : No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
disableSerialization;
|
||||
|
||||
params ["_display"];
|
||||
|
||||
_display displayAddEventHandler ["KeyDown", FUNC(handleModifierKey)];
|
||||
_display displayAddEventHandler ["KeyUp", FUNC(handleModifierKeyUp)];
|
@ -12,4 +12,8 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
(findDisplay 46) displayAddEventHandler ["MouseZChanged", QUOTE(_this call FUNC(handleScrollWheel))];
|
||||
disableSerialization;
|
||||
|
||||
params ["_display"];
|
||||
|
||||
_display displayAddEventHandler ["MouseZChanged", QUOTE(_this call FUNC(handleScrollWheel))];
|
59
addons/common/init_versionTooltip.sqf
Normal file
59
addons/common/init_versionTooltip.sqf
Normal file
@ -0,0 +1,59 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
#define MAX_COUNT 30
|
||||
#define ANIM_TIME 10
|
||||
|
||||
private _display = findDisplay 0;
|
||||
|
||||
if (!scriptDone (_display getVariable [QGVAR(versionTooltip), scriptNull])) exitWith {};
|
||||
|
||||
_display setVariable [QGVAR(versionTooltip), [_display] spawn {
|
||||
disableSerialization;
|
||||
|
||||
params ["_display"];
|
||||
|
||||
private _allControls = [];
|
||||
|
||||
private _fnc_create = {
|
||||
private _ctrl = _display ctrlCreate ["RscPicture", -1];
|
||||
|
||||
// randomize size
|
||||
private _size = selectRandom [safezoneW / 30, safezoneW / 20, safezoneW / 15];
|
||||
private _position = [
|
||||
random safezoneW + safezoneX - _size / 2,
|
||||
- random (safezoneH / 5) + safezoneY - _size,
|
||||
_size,
|
||||
_size
|
||||
];
|
||||
|
||||
_ctrl ctrlSetPosition _position;
|
||||
_ctrl ctrlCommit 0;
|
||||
|
||||
// pls ignore
|
||||
_ctrl ctrlSetText QUOTE(PATHTOF(data\icon_banana_ca.paa));
|
||||
|
||||
// animate with random speed
|
||||
_position set [1, 1 - safezoneY];
|
||||
_ctrl ctrlSetPosition _position;
|
||||
_ctrl ctrlCommit (ANIM_TIME * random [0.5, 1, 1.5]);
|
||||
|
||||
_allControls pushBack _ctrl;
|
||||
};
|
||||
|
||||
while {!isNull _display} do {
|
||||
_allControls = _allControls select {
|
||||
if (ctrlCommitted _x) then {
|
||||
ctrlDelete _x;
|
||||
false
|
||||
} else {
|
||||
true
|
||||
};
|
||||
};
|
||||
|
||||
while {count _allControls < MAX_COUNT} do {
|
||||
call _fnc_create;
|
||||
};
|
||||
|
||||
uiSleep 3;
|
||||
};
|
||||
}];
|
@ -14,4 +14,8 @@
|
||||
#define DEBUG_SETTINGS DEBUG_SETTINGS_COMMON
|
||||
#endif
|
||||
|
||||
#include "\z\ace\addons\main\script_macros.hpp"
|
||||
#include "\z\ace\addons\main\script_macros.hpp"
|
||||
|
||||
#define VERSION_CONFIG_COMMON VERSION_CONFIG;\
|
||||
versionDesc = "ACE 3";\
|
||||
versionAct = QUOTE(call COMPILE_FILE(init_versionTooltip))
|
||||
|
@ -9,3 +9,9 @@ class Extended_PostInit_EventHandlers {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_postInit));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_DisplayLoad_EventHandlers {
|
||||
class RscDisplayMission {
|
||||
ADDON = QUOTE(_this call COMPILE_FILE(XEH_mainDislayLoad));
|
||||
};
|
||||
};
|
||||
|
35
addons/gestures/XEH_mainDislayLoad.sqf
Normal file
35
addons/gestures/XEH_mainDislayLoad.sqf
Normal file
@ -0,0 +1,35 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
disableSerialization;
|
||||
|
||||
params ["_display"];
|
||||
|
||||
// reload mutex, you can't play signal while reloading
|
||||
GVAR(ReloadMutex) = true;
|
||||
|
||||
_display displayAddEventHandler ["KeyDown", {
|
||||
if ((_this select 1) in actionKeys "ReloadMagazine") then {
|
||||
if (isNull ACE_player || {!alive ACE_player}) exitWith {false};
|
||||
|
||||
private _weapon = currentWeapon ACE_player;
|
||||
|
||||
if (_weapon != "") then {
|
||||
GVAR(ReloadMutex) = false;
|
||||
|
||||
private _gesture = getText (configfile >> "CfgWeapons" >> _weapon >> "reloadAction");
|
||||
private _isLauncher = _weapon isKindOf ["Launcher", configFile >> "CfgWeapons"];
|
||||
private _config = ["CfgGesturesMale", "CfgMovesMaleSdr"] select _isLauncher;
|
||||
private _duration = getNumber (configfile >> _config >> "States" >> _gesture >> "speed");
|
||||
|
||||
if (_duration != 0) then {
|
||||
_duration = if (_duration < 0) then { abs _duration } else { 1 / _duration };
|
||||
} else {
|
||||
_duration = 3;
|
||||
};
|
||||
|
||||
TRACE_2("Reloading, blocking gestures",_weapon,_duration);
|
||||
[{GVAR(ReloadMutex) = true;}, [], _duration] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
};
|
||||
false
|
||||
}];
|
@ -3,36 +3,3 @@
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
#include "key.sqf"
|
||||
|
||||
// reload mutex, you can't play signal while reloading
|
||||
GVAR(ReloadMutex) = true;
|
||||
|
||||
// Event for main display to be loaded:
|
||||
["mainDisplayLoaded", {
|
||||
// handle reloading
|
||||
(findDisplay 46) displayAddEventHandler ["KeyDown", {
|
||||
if ((_this select 1) in actionKeys "ReloadMagazine") then {
|
||||
if ((isNull ACE_player) || {!alive ACE_player}) exitWith {false};
|
||||
private _weapon = currentWeapon ACE_player;
|
||||
|
||||
if (_weapon != "") then {
|
||||
GVAR(ReloadMutex) = false;
|
||||
|
||||
private _gesture = getText (configfile >> "CfgWeapons" >> _weapon >> "reloadAction");
|
||||
private _isLauncher = _weapon isKindOf ["Launcher", (configFile >> "CfgWeapons")];
|
||||
private _config = ["CfgGesturesMale", "CfgMovesMaleSdr"] select _isLauncher;
|
||||
private _duration = getNumber (configfile >> _config >> "States" >> _gesture >> "speed");
|
||||
|
||||
if (_duration != 0) then {
|
||||
_duration = if (_duration < 0) then { abs _duration } else { 1 / _duration };
|
||||
} else {
|
||||
_duration = 3;
|
||||
};
|
||||
|
||||
TRACE_2("Reloading, blocking gestures",_weapon,_duration);
|
||||
[{GVAR(ReloadMutex) = true;}, [], _duration] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
};
|
||||
false
|
||||
}];
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
|
Loading…
Reference in New Issue
Block a user