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:
@ -215,25 +215,12 @@ if (!hasInterface) exitWith {};
|
|||||||
// Set up mouse wheel eventhandler
|
// Set up mouse wheel eventhandler
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
call COMPILE_FILE(scripts\assignedItemFix);/////////////
|
|
||||||
call COMPILE_FILE(scripts\initScrollWheel);/////////////
|
|
||||||
|
|
||||||
DFUNC(mouseZHandler) = {
|
|
||||||
waitUntil {!isNull (findDisplay 46)}; sleep 0.1;
|
|
||||||
findDisplay 46 displayAddEventHandler ["MouseZChanged", QUOTE( _this call GVAR(onScrollWheel) )];
|
|
||||||
[false] call FUNC(disableUserInput);
|
|
||||||
};
|
|
||||||
|
|
||||||
addMissionEventHandler ["Loaded", {[] spawn FUNC(mouseZHandler)}];
|
|
||||||
[] spawn FUNC(mouseZHandler);
|
|
||||||
|
|
||||||
/*
|
|
||||||
call FUNC(assignedItemFix);
|
call FUNC(assignedItemFix);
|
||||||
|
|
||||||
GVAR(ScrollWheelFrame) = diag_frameno;
|
GVAR(ScrollWheelFrame) = diag_frameno;
|
||||||
|
|
||||||
addMissionEventHandler ["Loaded", {call FUNC(mouseZHandler)}];
|
addMissionEventHandler ["Loaded", {call FUNC(handleScrollWheelInit)}];
|
||||||
call FUNC(mouseZHandler);
|
call FUNC(handleScrollWheelInit);
|
||||||
*/
|
|
||||||
|
|
||||||
// @todo remove?
|
// @todo remove?
|
||||||
enableCamShake true;
|
enableCamShake true;
|
||||||
@ -417,14 +404,20 @@ if (!isNil QGVAR(PreInit_playerChanged_PFHID)) then {
|
|||||||
{_unit != _target && {vehicle _unit == vehicle _target}}
|
{_unit != _target && {vehicle _unit == vehicle _target}}
|
||||||
}] call FUNC(addCanInteractWithCondition);
|
}] call FUNC(addCanInteractWithCondition);
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
// Set up PlayerJIP eventhandler
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
// Lastly, do JIP events
|
// Lastly, do JIP events
|
||||||
// JIP Detection and event trigger. Run this at the very end, just in case anything uses it
|
// JIP Detection and event trigger. Run this at the very end, just in case anything uses it
|
||||||
|
// Note: usage of player is most likely on purpose
|
||||||
if (didJip) then {
|
if (didJip) then {
|
||||||
// We are jipping! Get ready and wait, and throw the event
|
// We are jipping! Get ready and wait, and throw the event
|
||||||
[{
|
[{
|
||||||
if((!(isNull player)) && GVAR(settingsInitFinished)) then {
|
if(!isNull player && GVAR(settingsInitFinished)) then {
|
||||||
["PlayerJip", [player] ] call FUNC(localEvent);
|
["PlayerJip", [player]] call FUNC(localEvent);
|
||||||
[(_this select 1)] call CBA_fnc_removePerFrameHandler;
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
||||||
};
|
};
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
// by commy2
|
// by commy2
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
//IGNORE_PRIVATE_WARNING("_handleNetEvent", "_handleRequestAllSyncedEvents", "_handleRequestSyncedEvent", "_handleSyncedEvent");
|
|
||||||
|
|
||||||
ADDON = false;
|
ADDON = false;
|
||||||
|
|
||||||
// ACE Common Function
|
|
||||||
|
|
||||||
PREP(addCanInteractWithCondition);
|
PREP(addCanInteractWithCondition);
|
||||||
PREP(addLineToDebugDraw);
|
PREP(addLineToDebugDraw);
|
||||||
PREP(addSetting);
|
PREP(addSetting);
|
||||||
PREP(addToInventory);
|
PREP(addToInventory);
|
||||||
|
PREP(assignedItemFix);
|
||||||
PREP(assignObjectsInList);
|
PREP(assignObjectsInList);
|
||||||
PREP(ambientBrightness);
|
PREP(ambientBrightness);
|
||||||
PREP(applyForceWalkStatus);
|
PREP(applyForceWalkStatus);
|
||||||
@ -82,14 +79,6 @@ PREP(getTargetAzimuthAndInclination);
|
|||||||
PREP(getTargetDistance);
|
PREP(getTargetDistance);
|
||||||
PREP(getTargetObject);
|
PREP(getTargetObject);
|
||||||
PREP(getTurnedOnLights);
|
PREP(getTurnedOnLights);
|
||||||
PREP(getTurretCommander);
|
|
||||||
PREP(getTurretConfigPath);
|
|
||||||
PREP(getTurretCopilot);
|
|
||||||
PREP(getTurretGunner);
|
|
||||||
PREP(getTurretIndex);
|
|
||||||
PREP(getTurrets);
|
|
||||||
PREP(getTurretsFFV);
|
|
||||||
PREP(getTurretsOther);
|
|
||||||
PREP(getTurretDirection);
|
PREP(getTurretDirection);
|
||||||
PREP(getUavControlPosition);
|
PREP(getUavControlPosition);
|
||||||
PREP(getVehicleCargo);
|
PREP(getVehicleCargo);
|
||||||
@ -102,6 +91,8 @@ PREP(getWindDirection);
|
|||||||
PREP(getZoom);
|
PREP(getZoom);
|
||||||
PREP(goKneeling);
|
PREP(goKneeling);
|
||||||
PREP(hadamardProduct);
|
PREP(hadamardProduct);
|
||||||
|
PREP(handleScrollWheel);
|
||||||
|
PREP(handleScrollWheelInit);
|
||||||
PREP(hasItem);
|
PREP(hasItem);
|
||||||
PREP(hasMagazine);
|
PREP(hasMagazine);
|
||||||
PREP(headBugFix);
|
PREP(headBugFix);
|
||||||
@ -251,6 +242,17 @@ PREP(localEvent);
|
|||||||
PREP(removeEventHandler);
|
PREP(removeEventHandler);
|
||||||
PREP(removeAlLEventHandlers);
|
PREP(removeAlLEventHandlers);
|
||||||
|
|
||||||
|
// Synchronized Events
|
||||||
|
PREP(syncedEventPFH);
|
||||||
|
PREP(addSyncedEventHandler);
|
||||||
|
PREP(removeSyncedEventHandler);
|
||||||
|
PREP(requestSyncedEvent);
|
||||||
|
PREP(syncedEvent);
|
||||||
|
|
||||||
|
PREP(_handleSyncedEvent);
|
||||||
|
PREP(_handleRequestSyncedEvent);
|
||||||
|
PREP(_handleRequestAllSyncedEvents);
|
||||||
|
|
||||||
// other eventhandlers
|
// other eventhandlers
|
||||||
PREP(addActionEventHandler);
|
PREP(addActionEventHandler);
|
||||||
PREP(addActionMenuEventHandler);
|
PREP(addActionMenuEventHandler);
|
||||||
@ -274,17 +276,6 @@ PREP(hashListSelect);
|
|||||||
PREP(hashListSet);
|
PREP(hashListSet);
|
||||||
PREP(hashListPush);
|
PREP(hashListPush);
|
||||||
|
|
||||||
// Synchronized Events
|
|
||||||
PREP(syncedEventPFH);
|
|
||||||
PREP(addSyncedEventHandler);
|
|
||||||
PREP(removeSyncedEventHandler);
|
|
||||||
PREP(requestSyncedEvent);
|
|
||||||
PREP(syncedEvent);
|
|
||||||
|
|
||||||
PREP(_handleSyncedEvent);
|
|
||||||
PREP(_handleRequestSyncedEvent);
|
|
||||||
PREP(_handleRequestAllSyncedEvents);
|
|
||||||
|
|
||||||
GVAR(syncedEvents) = HASH_CREATE;
|
GVAR(syncedEvents) = HASH_CREATE;
|
||||||
|
|
||||||
//GVARS for execNextFrame and waitAndExec
|
//GVARS for execNextFrame and waitAndExec
|
||||||
@ -296,7 +287,7 @@ GVAR(nextFrameBufferB) = [];
|
|||||||
GVAR(settingsInitFinished) = false;
|
GVAR(settingsInitFinished) = false;
|
||||||
GVAR(runAtSettingsInitialized) = [];
|
GVAR(runAtSettingsInitialized) = [];
|
||||||
|
|
||||||
// @TODO: Generic local-managed global-synced objects (createVehicleLocal)
|
// @todo: Generic local-managed global-synced objects (createVehicleLocal)
|
||||||
|
|
||||||
//Debug
|
//Debug
|
||||||
ACE_COUNTERS = [];
|
ACE_COUNTERS = [];
|
||||||
@ -306,8 +297,15 @@ if (isServer) then {
|
|||||||
call FUNC(loadSettingsOnServer);
|
call FUNC(loadSettingsOnServer);
|
||||||
};
|
};
|
||||||
|
|
||||||
ACE_player = objNull;
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
// Set up PlayerChanged eventhandler for pre init
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ACE_player = objNull;
|
||||||
|
uiNamespace setVariable ["ACE_player", objNull];
|
||||||
|
|
||||||
|
// @todo check if this can be removed
|
||||||
if (hasInterface) then {
|
if (hasInterface) then {
|
||||||
// PFH to update the ACE_player variable
|
// PFH to update the ACE_player variable
|
||||||
GVAR(PreInit_playerChanged_PFHID) = [{
|
GVAR(PreInit_playerChanged_PFHID) = [{
|
||||||
@ -324,7 +322,11 @@ if (hasInterface) then {
|
|||||||
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
// Time handling
|
// Time handling
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
ACE_time = diag_tickTime;
|
ACE_time = diag_tickTime;
|
||||||
ACE_realTime = diag_tickTime;
|
ACE_realTime = diag_tickTime;
|
||||||
ACE_virtualTime = diag_tickTime;
|
ACE_virtualTime = diag_tickTime;
|
||||||
@ -339,6 +341,8 @@ PREP(timePFH);
|
|||||||
// Init toHex
|
// Init toHex
|
||||||
[0] call FUNC(toHex);
|
[0] call FUNC(toHex);
|
||||||
|
|
||||||
ADDON = true;
|
isHC = !hasInterface && !isDedicated; // deprecated because no tag
|
||||||
|
missionNamespace setVariable ["ACE_isHC", ACE_isHC];
|
||||||
|
uiNamespace setVariable ["ACE_isHC", ACE_isHC];
|
||||||
|
|
||||||
isHC = !(hasInterface || isDedicated);
|
ADDON = true;
|
||||||
|
73
addons/common/functions/fnc_assignedItemFix.sqf
Normal file
73
addons/common/functions/fnc_assignedItemFix.sqf
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Author: commy2
|
||||||
|
* Initialized the assigned item fix.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Public : No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
private "_config";
|
||||||
|
|
||||||
|
ACE_isMapEnabled = call {_config = missionConfigFile >> "showMap"; !isNumber _config || {getNumber _config == 1}}; // default value is 1, so do isNumber check first
|
||||||
|
ACE_isCompassEnabled = call {_config = missionConfigFile >> "showCompass"; !isNumber _config || {getNumber _config == 1}};
|
||||||
|
ACE_isWatchEnabled = call {_config = missionConfigFile >> "showWatch"; !isNumber _config || {getNumber _config == 1}};
|
||||||
|
ACE_isRadioEnabled = call {_config = missionConfigFile >> "showRadio"; !isNumber _config || {getNumber _config == 1}};
|
||||||
|
ACE_isGPSEnabled = call {_config = missionConfigFile >> "showGPS"; !isNumber _config || {getNumber _config == 1}};
|
||||||
|
|
||||||
|
GVAR(AssignedItems) = [];
|
||||||
|
GVAR(AssignedItemsInfo) = [];
|
||||||
|
GVAR(AssignedItemsShownItems) = [
|
||||||
|
ACE_isMapEnabled,
|
||||||
|
ACE_isCompassEnabled,
|
||||||
|
ACE_isWatchEnabled,
|
||||||
|
ACE_isRadioEnabled,
|
||||||
|
ACE_isGPSEnabled
|
||||||
|
];
|
||||||
|
|
||||||
|
["playerInventoryChanged", {
|
||||||
|
params ["_unit", "_assignedItems"];
|
||||||
|
|
||||||
|
_assignedItems = _assignedItems select 17;
|
||||||
|
|
||||||
|
{
|
||||||
|
if !(_x in GVAR(AssignedItems)) then {
|
||||||
|
GVAR(AssignedItems) pushBack _x;
|
||||||
|
GVAR(AssignedItemsInfo) pushBack toLower getText (configFile >> "CfgWeapons" >> _x >> "ACE_hideItemType");
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (GVAR(AssignedItemsInfo) select (GVAR(AssignedItems) find _x)) do {
|
||||||
|
case ("map"): {
|
||||||
|
GVAR(AssignedItemsShownItems) set [0, false];
|
||||||
|
};
|
||||||
|
case ("compass"): {
|
||||||
|
GVAR(AssignedItemsShownItems) set [1, false];
|
||||||
|
};
|
||||||
|
case ("watch"): {
|
||||||
|
GVAR(AssignedItemsShownItems) set [2, false];
|
||||||
|
};
|
||||||
|
case ("radio"): {
|
||||||
|
GVAR(AssignedItemsShownItems) set [3, false];
|
||||||
|
};
|
||||||
|
case ("gps"): {
|
||||||
|
GVAR(AssignedItemsShownItems) set [4, false];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
false
|
||||||
|
} count _assignedItems;
|
||||||
|
|
||||||
|
//systemChat str GVAR(AssignedItemsShownItems);
|
||||||
|
|
||||||
|
GVAR(AssignedItemsShownItems) params ["_showMap", "_showCompass", "_showWatch", "_showRadio", "_showGPS"];
|
||||||
|
|
||||||
|
showMap _showMap;
|
||||||
|
showCompass _showCompass;
|
||||||
|
showWatch _showWatch;
|
||||||
|
showRadio _showRadio;
|
||||||
|
showGPS (_showGPS || {cameraOn == getConnectedUAV _unit}); //If player is activly controling a UAV, showGPS controls showing the map (m key)
|
||||||
|
}] call FUNC(addEventHandler);
|
25
addons/common/functions/fnc_handleScrollWheel.sqf
Normal file
25
addons/common/functions/fnc_handleScrollWheel.sqf
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Author: commy2
|
||||||
|
* Handles MouseZChanged event.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Public : No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
// prevents a bug that causes the MouseZChanged to trigger N-times, where N is the number of times you consecutively pressed "Restart" instead of "Preview" in the editor
|
||||||
|
if (GVAR(ScrollWheelFrame) == diag_frameno) exitWith {};
|
||||||
|
|
||||||
|
GVAR(ScrollWheelFrame) = diag_frameno;
|
||||||
|
|
||||||
|
{
|
||||||
|
[_this select 1] call _x;
|
||||||
|
false
|
||||||
|
} count ((missionNamespace getVariable ["ACE_EventHandler_ScrollWheel", [-1, [], []]]) select 2);
|
||||||
|
|
||||||
|
nil
|
15
addons/common/functions/fnc_handleScrollWheelInit.sqf
Normal file
15
addons/common/functions/fnc_handleScrollWheelInit.sqf
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Author: commy2
|
||||||
|
* Initializes the MouseZChanged eventhandler.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Public : No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
(findDisplay 46) displayAddEventHandler ["MouseZChanged", QUOTE(_this call FUNC(handleScrollWheel))];
|
@ -1,64 +0,0 @@
|
|||||||
// by commy2
|
|
||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
private ["_config"];
|
|
||||||
|
|
||||||
ACE_isMapEnabled = call {_config = missionConfigFile >> "showMap"; !isNumber _config || {getNumber _config == 1}}; // default value is 1, so do isNumber check first
|
|
||||||
ACE_isCompassEnabled = call {_config = missionConfigFile >> "showCompass"; !isNumber _config || {getNumber _config == 1}};
|
|
||||||
ACE_isWatchEnabled = call {_config = missionConfigFile >> "showWatch"; !isNumber _config || {getNumber _config == 1}};
|
|
||||||
ACE_isRadioEnabled = call {_config = missionConfigFile >> "showRadio"; !isNumber _config || {getNumber _config == 1}};
|
|
||||||
ACE_isGPSEnabled = call {_config = missionConfigFile >> "showGPS"; !isNumber _config || {getNumber _config == 1}};
|
|
||||||
|
|
||||||
GVAR(AssignedItems) = [];
|
|
||||||
GVAR(AssignedItemsInfo) = [];
|
|
||||||
|
|
||||||
["playerInventoryChanged", {
|
|
||||||
private ["_unit", "_assignedItems", "_shownItems"];
|
|
||||||
|
|
||||||
_unit = _this select 0;
|
|
||||||
_assignedItems = _this select 1 select 17;
|
|
||||||
|
|
||||||
_shownItems = [
|
|
||||||
ACE_isMapEnabled,
|
|
||||||
ACE_isCompassEnabled,
|
|
||||||
ACE_isWatchEnabled,
|
|
||||||
ACE_isRadioEnabled,
|
|
||||||
ACE_isGPSEnabled
|
|
||||||
];
|
|
||||||
|
|
||||||
{
|
|
||||||
if !(_x in GVAR(AssignedItems)) then {
|
|
||||||
GVAR(AssignedItems) pushBack _x;
|
|
||||||
GVAR(AssignedItemsInfo) pushBack toLower getText (configFile >> "CfgWeapons" >> _x >> "ACE_hideItemType")
|
|
||||||
};
|
|
||||||
|
|
||||||
private "_hideItemType";
|
|
||||||
_hideItemType = GVAR(AssignedItemsInfo) select (GVAR(AssignedItems) find _x);
|
|
||||||
|
|
||||||
switch (_hideItemType) do {
|
|
||||||
case ("map"): {
|
|
||||||
_shownItems set [0, false];
|
|
||||||
};
|
|
||||||
case ("compass"): {
|
|
||||||
_shownItems set [1, false];
|
|
||||||
};
|
|
||||||
case ("watch"): {
|
|
||||||
_shownItems set [2, false];
|
|
||||||
};
|
|
||||||
case ("radio"): {
|
|
||||||
_shownItems set [3, false];
|
|
||||||
};
|
|
||||||
case ("gps"): {
|
|
||||||
_shownItems set [4, false];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
} forEach _assignedItems;
|
|
||||||
|
|
||||||
//systemChat str _shownItems;
|
|
||||||
|
|
||||||
showMap (_shownItems select 0);
|
|
||||||
showCompass (_shownItems select 1);
|
|
||||||
showWatch (_shownItems select 2);
|
|
||||||
showRadio (_shownItems select 3);
|
|
||||||
showGPS (_shownItems select 4 || {cameraOn == getConnectedUAV _unit}); //If player is activly controling a UAV, showGPS controls showing the map (m key)
|
|
||||||
}] call FUNC(addEventHandler);
|
|
@ -1,16 +0,0 @@
|
|||||||
// by commy2
|
|
||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
GVAR(ScrollWheelFrame) = diag_frameno;
|
|
||||||
|
|
||||||
GVAR(onScrollWheel) = {
|
|
||||||
private ["_scroll"];
|
|
||||||
_scroll = _this select 1;
|
|
||||||
|
|
||||||
if (GVAR(ScrollWheelFrame) == diag_frameno) exitWith {};
|
|
||||||
GVAR(ScrollWheelFrame) = diag_frameno;
|
|
||||||
|
|
||||||
{
|
|
||||||
[_scroll] call _x;
|
|
||||||
} count ((missionNamespace getVariable ["ACE_EventHandler_ScrollWheel", [-1, [], []]]) select 2);
|
|
||||||
};
|
|
@ -97,6 +97,8 @@
|
|||||||
// Time functions for accuracy per frame
|
// Time functions for accuracy per frame
|
||||||
#define ACE_tickTime (ACE_time + (diag_tickTime - ACE_diagTime))
|
#define ACE_tickTime (ACE_time + (diag_tickTime - ACE_diagTime))
|
||||||
|
|
||||||
|
#define ACE_isHC (!hasInterface && !isDedicated)
|
||||||
|
|
||||||
#define ACE_LOG(module,level,message) diag_log text ACE_LOGFORMAT(module,level,message)
|
#define ACE_LOG(module,level,message) diag_log text ACE_LOGFORMAT(module,level,message)
|
||||||
#define ACE_LOGFORMAT(module,level,message) FORMAT_2(QUOTE([ACE] (module) %1: %2),level,message)
|
#define ACE_LOGFORMAT(module,level,message) FORMAT_2(QUOTE([ACE] (module) %1: %2),level,message)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user