diff --git a/addons/common/CfgEventHandlers.hpp b/addons/common/CfgEventHandlers.hpp index 1afbe16512..0320b32709 100644 --- a/addons/common/CfgEventHandlers.hpp +++ b/addons/common/CfgEventHandlers.hpp @@ -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) { diff --git a/addons/common/XEH_mainDislayLoad.sqf b/addons/common/XEH_mainDislayLoad.sqf new file mode 100644 index 0000000000..57ace32f94 --- /dev/null +++ b/addons/common/XEH_mainDislayLoad.sqf @@ -0,0 +1,6 @@ +#include "script_component.hpp" + +GVAR(ScrollWheelFrame) = diag_frameno; + +call COMPILE_FILE(init_handleScrollWheel); +call COMPILE_FILE(init_handleModifierKey); diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index a265600d28..3034e73188 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -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; diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index f96028c352..dd541c2126 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -94,9 +94,7 @@ PREP(goKneeling); PREP(hadamardProduct); PREP(handleModifierKey); PREP(handleModifierKeyUp); -PREP(handleModifierKeyInit); PREP(handleScrollWheel); -PREP(handleScrollWheelInit); PREP(hasItem); PREP(hasMagazine); PREP(headBugFix); diff --git a/addons/common/config.cpp b/addons/common/config.cpp index 8050943803..6ec74cb746 100644 --- a/addons/common/config.cpp +++ b/addons/common/config.cpp @@ -8,7 +8,7 @@ class CfgPatches { requiredAddons[] = {"ace_main","ace_modules"}; author[] = {"KoffeinFlummi"}; authorUrl = "https://github.com/KoffeinFlummi/"; - VERSION_CONFIG; + VERSION_CONFIG_COMMON; }; }; diff --git a/addons/common/functions/fnc_handleModifierKeyInit.sqf b/addons/common/functions/fnc_handleModifierKeyInit.sqf deleted file mode 100644 index a945f5eba1..0000000000 --- a/addons/common/functions/fnc_handleModifierKeyInit.sqf +++ /dev/null @@ -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)]; diff --git a/addons/common/init_handleModifierKey.sqf b/addons/common/init_handleModifierKey.sqf new file mode 100644 index 0000000000..dd07db621c --- /dev/null +++ b/addons/common/init_handleModifierKey.sqf @@ -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)]; diff --git a/addons/common/functions/fnc_handleScrollWheelInit.sqf b/addons/common/init_handleScrollWheel.sqf similarity index 55% rename from addons/common/functions/fnc_handleScrollWheelInit.sqf rename to addons/common/init_handleScrollWheel.sqf index 12f8b5f337..0acb84a5f2 100644 --- a/addons/common/functions/fnc_handleScrollWheelInit.sqf +++ b/addons/common/init_handleScrollWheel.sqf @@ -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))]; diff --git a/addons/common/init_versionTooltip.sqf b/addons/common/init_versionTooltip.sqf new file mode 100644 index 0000000000..7aef3f4786 --- /dev/null +++ b/addons/common/init_versionTooltip.sqf @@ -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; + }; +}]; diff --git a/addons/common/script_component.hpp b/addons/common/script_component.hpp index aa023e7c9f..4e941943fa 100644 --- a/addons/common/script_component.hpp +++ b/addons/common/script_component.hpp @@ -14,4 +14,8 @@ #define DEBUG_SETTINGS DEBUG_SETTINGS_COMMON #endif -#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file +#include "\z\ace\addons\main\script_macros.hpp" + +#define VERSION_CONFIG_COMMON VERSION_CONFIG;\ + versionDesc = "ACE 3";\ + versionAct = QUOTE(call COMPILE_FILE(init_versionTooltip)) diff --git a/addons/gestures/CfgEventHandlers.hpp b/addons/gestures/CfgEventHandlers.hpp index 7b003bbe8c..b426a3a580 100644 --- a/addons/gestures/CfgEventHandlers.hpp +++ b/addons/gestures/CfgEventHandlers.hpp @@ -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)); + }; +}; diff --git a/addons/gestures/XEH_mainDislayLoad.sqf b/addons/gestures/XEH_mainDislayLoad.sqf new file mode 100644 index 0000000000..4b5c2ca63b --- /dev/null +++ b/addons/gestures/XEH_mainDislayLoad.sqf @@ -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 +}]; diff --git a/addons/gestures/XEH_postInit.sqf b/addons/gestures/XEH_postInit.sqf index fec57ab111..d9cfc74e04 100644 --- a/addons/gestures/XEH_postInit.sqf +++ b/addons/gestures/XEH_postInit.sqf @@ -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);