replace mainDisplayLoaded event with DisplayLoad XEH and add ACE version to main menu (CBA help)

This commit is contained in:
commy2 2016-02-21 20:26:30 +01:00
parent f5ef7b6b2d
commit 5e486869c0
13 changed files with 143 additions and 79 deletions

View File

@ -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 Extended_InitPost_EventHandlers {
class All { class All {
class GVAR(executePersistent) { class GVAR(executePersistent) {

View File

@ -0,0 +1,6 @@
#include "script_component.hpp"
GVAR(ScrollWheelFrame) = diag_frameno;
call COMPILE_FILE(init_handleScrollWheel);
call COMPILE_FILE(init_handleModifierKey);

View File

@ -290,31 +290,6 @@ if (!hasInterface) exitWith {};
call FUNC(assignedItemFix); 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? // @todo remove?
enableCamShake true; enableCamShake true;

View File

@ -94,9 +94,7 @@ PREP(goKneeling);
PREP(hadamardProduct); PREP(hadamardProduct);
PREP(handleModifierKey); PREP(handleModifierKey);
PREP(handleModifierKeyUp); PREP(handleModifierKeyUp);
PREP(handleModifierKeyInit);
PREP(handleScrollWheel); PREP(handleScrollWheel);
PREP(handleScrollWheelInit);
PREP(hasItem); PREP(hasItem);
PREP(hasMagazine); PREP(hasMagazine);
PREP(headBugFix); PREP(headBugFix);

View File

@ -8,7 +8,7 @@ class CfgPatches {
requiredAddons[] = {"ace_main","ace_modules"}; requiredAddons[] = {"ace_main","ace_modules"};
author[] = {"KoffeinFlummi"}; author[] = {"KoffeinFlummi"};
authorUrl = "https://github.com/KoffeinFlummi/"; authorUrl = "https://github.com/KoffeinFlummi/";
VERSION_CONFIG; VERSION_CONFIG_COMMON;
}; };
}; };

View File

@ -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)];

View 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)];

View File

@ -12,4 +12,8 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
(findDisplay 46) displayAddEventHandler ["MouseZChanged", QUOTE(_this call FUNC(handleScrollWheel))]; disableSerialization;
params ["_display"];
_display displayAddEventHandler ["MouseZChanged", QUOTE(_this call FUNC(handleScrollWheel))];

View 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;
};
}];

View File

@ -14,4 +14,8 @@
#define DEBUG_SETTINGS DEBUG_SETTINGS_COMMON #define DEBUG_SETTINGS DEBUG_SETTINGS_COMMON
#endif #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))

View File

@ -9,3 +9,9 @@ class Extended_PostInit_EventHandlers {
init = QUOTE(call COMPILE_FILE(XEH_postInit)); init = QUOTE(call COMPILE_FILE(XEH_postInit));
}; };
}; };
class Extended_DisplayLoad_EventHandlers {
class RscDisplayMission {
ADDON = QUOTE(_this call COMPILE_FILE(XEH_mainDislayLoad));
};
};

View 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
}];

View File

@ -3,36 +3,3 @@
if (!hasInterface) exitWith {}; if (!hasInterface) exitWith {};
#include "key.sqf" #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);