From d66b78bdd500703bce33ee9cdac78a9d4cff9fa9 Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 16 Jan 2015 23:13:51 +0100 Subject: [PATCH] infoDisplayChanged via addEventHandler --- TO_MERGE/agm/Parachute/clientInit.sqf | 4 +-- TO_MERGE/agm/SafeMode/clientInit.sqf | 1 + TO_MERGE/agm/WeaponSelect/clientInit.sqf | 2 +- addons/common/RscInfoType.hpp | 13 ++++--- addons/common/XEH_preInit.sqf | 2 -- .../fnc_addInfoDisplayEventHandler.sqf | 35 ------------------- .../fnc_removeInfoDisplayEventHandler.sqf | 33 ----------------- 7 files changed, 12 insertions(+), 78 deletions(-) delete mode 100644 addons/common/functions/fnc_addInfoDisplayEventHandler.sqf delete mode 100644 addons/common/functions/fnc_removeInfoDisplayEventHandler.sqf diff --git a/TO_MERGE/agm/Parachute/clientInit.sqf b/TO_MERGE/agm/Parachute/clientInit.sqf index 8c2c4274b5..5cd18c3ea8 100644 --- a/TO_MERGE/agm/Parachute/clientInit.sqf +++ b/TO_MERGE/agm/Parachute/clientInit.sqf @@ -29,5 +29,5 @@ }; // don't show speed and height when in expert mode -["Parachute", {if (!cadetMode) then {_dlg = _this select 0; {(_dlg displayCtrl _x) ctrlShow false} forEach [121, 122, 1004, 1005, 1006, 1014];};}] call AGM_Core_fnc_addInfoDisplayEventHandler; -["Soldier", {if (!cadetMode) then {_dlg = _this select 0; {_ctrl = (_dlg displayCtrl _x); _ctrl ctrlSetPosition [0,0,0,0]; _ctrl ctrlCommit 0;} forEach [380, 382]};}] call AGM_Core_fnc_addInfoDisplayEventHandler; +["Parachute", {if (!cadetMode) then {_dlg = _this select 0; {(_dlg displayCtrl _x) ctrlShow false} forEach [121, 122, 1004, 1005, 1006, 1014];};}] call AGM_Core_fnc_addInfoDisplayEventHandler; //@todo addEventHandler infoDisplayChanged with select 1 == "Parachute" +["Soldier", {if (!cadetMode) then {_dlg = _this select 0; {_ctrl = (_dlg displayCtrl _x); _ctrl ctrlSetPosition [0,0,0,0]; _ctrl ctrlCommit 0;} forEach [380, 382]};}] call AGM_Core_fnc_addInfoDisplayEventHandler; //@todo addEventHandler infoDisplayChanged with select 1 == "Soldier" diff --git a/TO_MERGE/agm/SafeMode/clientInit.sqf b/TO_MERGE/agm/SafeMode/clientInit.sqf index 2e0bad4a39..22440928b8 100644 --- a/TO_MERGE/agm/SafeMode/clientInit.sqf +++ b/TO_MERGE/agm/SafeMode/clientInit.sqf @@ -2,3 +2,4 @@ // by commy2 //["Soldier", {_player = AGM_player; if (currentWeapon _player in (_player getVariable ["AGM_SafeMode_safedWeapons", []])) then {[false] call AGM_SafeMode_setSafeModeVisual}] call AGM_Core_fnc_addInfoDisplayEventHandler; + //@todo addEventHandler infoDisplayChanged with select 1 == "Soldier" \ No newline at end of file diff --git a/TO_MERGE/agm/WeaponSelect/clientInit.sqf b/TO_MERGE/agm/WeaponSelect/clientInit.sqf index c3becf5495..42a1e347d6 100644 --- a/TO_MERGE/agm/WeaponSelect/clientInit.sqf +++ b/TO_MERGE/agm/WeaponSelect/clientInit.sqf @@ -46,4 +46,4 @@ AGM_WeaponSelect_AllMagazines = uiNamespace getVariable "AGM_WeaponSelect_Al // hide grenade count if none is selected [uiNamespace getVariable "AGM_dlgSoldier", false] call AGM_WeaponSelect_fnc_toggleGrenadeCount; -["Soldier", {[_this select 0, call AGM_WeaponSelect_fnc_getSelectedGrenade != ""] call AGM_WeaponSelect_fnc_toggleGrenadeCount}] call AGM_Core_fnc_addInfoDisplayEventHandler; +["Soldier", {[_this select 0, call AGM_WeaponSelect_fnc_getSelectedGrenade != ""] call AGM_WeaponSelect_fnc_toggleGrenadeCount}] call AGM_Core_fnc_addInfoDisplayEventHandler; //@todo addEventHandler infoDisplayChanged with select 1 == "Soldier" diff --git a/addons/common/RscInfoType.hpp b/addons/common/RscInfoType.hpp index 1a4950b022..0b499bc9ac 100644 --- a/addons/common/RscInfoType.hpp +++ b/addons/common/RscInfoType.hpp @@ -2,19 +2,22 @@ class RscInGameUI { class RscUnitInfo; class RscUnitInfoSoldier: RscUnitInfo { - onLoad = "uiNamespace setVariable ['ACE_dlgSoldier', _this select 0]; {_this call _x} forEach ((missionNamespace getVariable ['ACE_onLoadInfoSoldier', [-1, [], []]]) select 2); {_this call _x} forEach ((missionNamespace getVariable ['ACE_onLoadInfoAny', [-1, [], []]]) select 2); [""onLoad"",_this,""RscUnitInfo"",'IGUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf"""; + onLoad = QUOTE([ARR_4(""onLoad"",_this,""RscUnitInfo"",'IGUI')] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf""; uiNamespace setVariable [ARR_2('ACE_dlgSoldier', _this select 0)]; [ARR_2('infoDisplayChanged', [ARR_2(_this select 0, 'Soldier')])] call FUNC(localEvent);); }; class RscUnitInfoTank: RscUnitInfo { - onLoad = "uiNamespace setVariable ['ACE_dlgVehicle', _this select 0]; {_this call _x} forEach ((missionNamespace getVariable ['ACE_onLoadInfoVehicle', [-1, [], []]]) select 2); {_this call _x} forEach ((missionNamespace getVariable ['ACE_onLoadInfoAny', [-1, [], []]]) select 2); [""onLoad"",_this,""RscUnitInfo"",'IGUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf"""; + onLoad = QUOTE([ARR_4(""onLoad"",_this,""RscUnitInfo"",'IGUI')] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf""; uiNamespace setVariable [ARR_2('ACE_dlgVehicle', _this select 0)]; [ARR_2('infoDisplayChanged', [ARR_2(_this select 0, 'Vehicle')])] call FUNC(localEvent);); }; class RscUnitInfoAir: RscUnitInfo { - onLoad = "uiNamespace setVariable ['ACE_dlgAircraft', _this select 0]; {_this call _x} forEach ((missionNamespace getVariable ['ACE_onLoadInfoAircraft', [-1, [], []]]) select 2); {_this call _x} forEach ((missionNamespace getVariable ['ACE_onLoadInfoAny', [-1, [], []]]) select 2); [""onLoad"",_this,""RscUnitInfo"",'IGUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf"""; + onLoad = QUOTE([ARR_4(""onLoad"",_this,""RscUnitInfo"",'IGUI')] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf""; uiNamespace setVariable [ARR_2('ACE_dlgAircraft', _this select 0)]; [ARR_2('infoDisplayChanged', [ARR_2(_this select 0, 'Aircraft')])] call FUNC(localEvent);); + }; + class RscUnitInfoSubmarine: RscUnitInfo { + onLoad = QUOTE([ARR_4(""onLoad"",_this,""RscUnitInfo"",'IGUI')] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf""; uiNamespace setVariable [ARR_2('ACE_dlgSubmarine', _this select 0)]; [ARR_2('infoDisplayChanged', [ARR_2(_this select 0, 'Submarine')])] call FUNC(localEvent);); }; class RscUnitInfoShip: RscUnitInfo { - onLoad = "uiNamespace setVariable ['ACE_dlgShip', _this select 0]; {_this call _x} forEach ((missionNamespace getVariable ['ACE_onLoadInfoShip', [-1, [], []]]) select 2); {_this call _x} forEach ((missionNamespace getVariable ['ACE_onLoadInfoAny', [-1, [], []]]) select 2); [""onLoad"",_this,""RscUnitInfo"",'IGUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf"""; + onLoad = QUOTE([ARR_4(""onLoad"",_this,""RscUnitInfo"",'IGUI')] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf""; uiNamespace setVariable [ARR_2('ACE_dlgShip', _this select 0)]; [ARR_2('infoDisplayChanged', [ARR_2(_this select 0, 'Ship')])] call FUNC(localEvent);); }; class RscUnitInfoParachute: RscUnitInfo { - onLoad = "uiNamespace setVariable ['ACE_dlgParachute', _this select 0]; {_this call _x} forEach ((missionNamespace getVariable ['ACE_onLoadInfoParachute', [-1, [], []]]) select 2); {_this call _x} forEach ((missionNamespace getVariable ['ACE_onLoadInfoAny', [-1, [], []]]) select 2); [""onLoad"",_this,""RscUnitInfo"",'IGUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf"""; + onLoad = QUOTE([ARR_4(""onLoad"",_this,""RscUnitInfo"",'IGUI')] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf""; uiNamespace setVariable [ARR_2('ACE_dlgParachute', _this select 0)]; [ARR_2('infoDisplayChanged', [ARR_2(_this select 0, 'Parachute')])] call FUNC(localEvent);); }; }; diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 70aab8ca6a..27ff8915b7 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -6,7 +6,6 @@ PREP(addActionEventHandler); PREP(addActionMenuEventHandler); PREP(addCameraEventHandler); PREP(addCustomEventHandler); -PREP(addInfoDisplayEventHandler); PREP(addMapMarkerCreatedEventHandler); PREP(addInventoryDisplayLoadedEventHandler); PREP(addScrollWheelEventHandler); @@ -101,7 +100,6 @@ PREP(removeActionEventHandler); PREP(removeActionMenuEventHandler); PREP(removeCameraEventHandler); PREP(removeCustomEventHandler); -PREP(removeInfoDisplayEventHandler); PREP(removeInventoryDisplayLoadedEventHandler); PREP(removeMapMarkerCreatedEventHandler); PREP(removeScrollWheelEventHandler); diff --git a/addons/common/functions/fnc_addInfoDisplayEventHandler.sqf b/addons/common/functions/fnc_addInfoDisplayEventHandler.sqf deleted file mode 100644 index d80c8b7fec..0000000000 --- a/addons/common/functions/fnc_addInfoDisplayEventHandler.sqf +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Author: commy2 - * - * Add a unit info type handler. - * - * Argument: - * 0: Type. Can be "Soldier", "Vehicle", "Aircraft", "Ship", "Parachute" or "Any". "Any" will execute for any compatible display (String) - * 1: Code to execute (Code or String) - * - * Return value: - * ID of the event script (used to remove it later). - */ -#include "script_component.hpp" - -private ["_type", "_statement", "_actionsVar", "_id", "_actionIDs", "_actions"]; - -_type = format ["ACE_onLoadInfo%1", _this select 0]; -_statement = _this select 1; - -if (typeName _statement == "STRING") then { - _statement = compile _statement; -}; - -_actionsVar = missionNamespace getVariable [_type, [-1, [], []]]; - -_id = (_actionsVar select 0) + 1; -_actionIDs = _actionsVar select 1; -_actions = _actionsVar select 2; - -_actionIDs pushBack _id; -_actions pushBack _statement; - -missionNamespace setVariable [_type, [_id, _actionIDs, _actions]]; - -_id diff --git a/addons/common/functions/fnc_removeInfoDisplayEventHandler.sqf b/addons/common/functions/fnc_removeInfoDisplayEventHandler.sqf deleted file mode 100644 index 160002990c..0000000000 --- a/addons/common/functions/fnc_removeInfoDisplayEventHandler.sqf +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Author: commy2 - * - * Remove a unit info type event handler. - * - * Argument: - * 0: Type. Can be "Soldier", "Vehicle", "Aircraft" or "Parachute" (String) - * 1: ID of the event handler (Number) - * - * Return value: - * None. - */ -#include "script_component.hpp" - -private ["_type", "_id", "_actionsVar", "_currentId", "_actionIDs", "_actions"]; - -_type = format ["ACE_onLoadInfo%1", _this select 0]; -_id = _this select 1; - -_actionsVar = missionNamespace getVariable [_type, [-1, [], []]]; - -_currentId = _actionsVar select 0; -_actionIDs = _actionsVar select 1; -_actions = _actionsVar select 2; - -_id = _actionIDs find _id; - -if (_id == -1) exitWith {}; - -_actionIDs deleteAt _id; -_actions deleteAt _id; - -missionNamespace setVariable [_type, [_currentId, _actionIDs, _actions]];