From 7d5555a2e01245ffebca6aaea74c02257a161b89 Mon Sep 17 00:00:00 2001 From: Garth L-H de Wet Date: Wed, 1 Apr 2015 19:09:19 +0200 Subject: [PATCH] Renamed functions to be more inline with their purpose. Removed legacy code. --- addons/explosives/CfgVehicles.hpp | 10 +++++----- addons/explosives/XEH_preInit.sqf | 6 +++--- addons/explosives/config.cpp | 2 +- ...etonateUI.sqf => fnc_addDetonateActions.sqf} | 8 +------- .../functions/fnc_addExplosiveActions.sqf | 5 ++++- ...tterUI.sqf => fnc_addTransmitterActions.sqf} | 12 +++--------- ...electionUI.sqf => fnc_addTriggerActions.sqf} | 17 ++++++----------- 7 files changed, 23 insertions(+), 37 deletions(-) rename addons/explosives/functions/{fnc_openDetonateUI.sqf => fnc_addDetonateActions.sqf} (80%) rename addons/explosives/functions/{fnc_openTransmitterUI.sqf => fnc_addTransmitterActions.sqf} (60%) rename addons/explosives/functions/{fnc_openTriggerSelectionUI.sqf => fnc_addTriggerActions.sqf} (69%) diff --git a/addons/explosives/CfgVehicles.hpp b/addons/explosives/CfgVehicles.hpp index 1e039b0770..2ef6dd77c0 100644 --- a/addons/explosives/CfgVehicles.hpp +++ b/addons/explosives/CfgVehicles.hpp @@ -6,7 +6,7 @@ class CfgVehicles { displayName = $STR_ACE_Explosives_Menu; condition = QUOTE(!(_player getVariable [ARR_2('ace_explosives_PlantingExplosive',false)])); statement = ""; - exceptions[] = {"isNotSwimming"}; + exceptions[] = {"isNotSwimming", "isNotInside"}; showDisabled = 1; priority = 4; icon = PATHTOF(UI\Explosives_Menu_ca.paa); @@ -16,8 +16,8 @@ class CfgVehicles { displayName = $STR_ACE_Explosives_Detonate; condition = QUOTE([_player] call FUNC(canDetonate)); statement = ""; - insertChildren = QUOTE([_player] call FUNC(openTransmitterUI);); - exceptions[] = {"isNotSwimming"}; + insertChildren = QUOTE([_player] call FUNC(addTransmitterActions);); + exceptions[] = {"isNotSwimming", "isNotInside"}; showDisabled = 1; icon = PATHTOF(UI\Explosives_Menu_ca.paa); priority = 2; @@ -38,7 +38,7 @@ class CfgVehicles { displayName = $STR_ACE_Explosives_cellphone_displayName; condition = "('ACE_Cellphone' in (items ace_player))"; statement = "closeDialog 0;createDialog 'Rsc_ACE_PhoneInterface';"; - exceptions[] = {"isNotSwimming"}; + exceptions[] = {"isNotSwimming", "isNotInside"}; showDisabled = 0; icon = PATHTOF(Data\UI\Cellphone_UI.paa); priority = 0.8; @@ -101,7 +101,7 @@ class CfgVehicles { distance = 4; condition = "true"; statement = ""; - insertChildren = QUOTE([ARR_3(_target getVariable QUOTE(QGVAR(class)),_target,_player)] call FUNC(openTriggerSelectionUI);); + insertChildren = QUOTE([ARR_3(_target getVariable QUOTE(QGVAR(class)),_target,_player)] call FUNC(addTriggerActions);); showDisabled = 0; exceptions[] = {}; priority = 5; diff --git a/addons/explosives/XEH_preInit.sqf b/addons/explosives/XEH_preInit.sqf index b905c6e736..435624d2a5 100644 --- a/addons/explosives/XEH_preInit.sqf +++ b/addons/explosives/XEH_preInit.sqf @@ -19,8 +19,11 @@ ADDON = false; PREP(addCellphoneIED); PREP(addClacker); +PREP(addDetonateActions); PREP(addExplosiveActions); PREP(addToSpeedDial); +PREP(addTransmitterActions); +PREP(addTriggerActions); PREP(canDefuse); PREP(canDetonate); PREP(defuseExplosive); @@ -39,10 +42,7 @@ PREP(getSpeedDialExplosive); PREP(onLanded); -PREP(openDetonateUI); -PREP(openTransmitterUI); PREP(openTimerSetUI); -PREP(openTriggerSelectionUI); PREP(place_Approve); PREP(place_Cancel); diff --git a/addons/explosives/config.cpp b/addons/explosives/config.cpp index 428d0352b1..f11ff2b358 100644 --- a/addons/explosives/config.cpp +++ b/addons/explosives/config.cpp @@ -5,7 +5,7 @@ class CfgPatches { units[] = {}; weapons[] = {"ACE_Clacker", "ACE_DefusalKit", "ACE_M26_Clacker", "ACE_DeadManSwitch", "ACE_Cellphone"}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_interaction", "ace_interact_menu"}; + requiredAddons[] = {"ace_interaction"}; author[] = {"Garth 'L-H' de Wet"}; authorUrl = "http://garth.snakebiteink.co.za/"; VERSION_CONFIG; diff --git a/addons/explosives/functions/fnc_openDetonateUI.sqf b/addons/explosives/functions/fnc_addDetonateActions.sqf similarity index 80% rename from addons/explosives/functions/fnc_openDetonateUI.sqf rename to addons/explosives/functions/fnc_addDetonateActions.sqf index e00a620143..65077323e5 100644 --- a/addons/explosives/functions/fnc_openDetonateUI.sqf +++ b/addons/explosives/functions/fnc_addDetonateActions.sqf @@ -10,7 +10,7 @@ * None * * Example: - * [player, "ACE_M26_Clacker"] call ACE_Explosives_fnc_openDetonateUI; + * [player, "ACE_M26_Clacker"] call ACE_Explosives_fnc_addDetonateActions; * * Public: No */ @@ -23,7 +23,6 @@ _range = GetNumber (ConfigFile >> "CfgWeapons" >> _detonator >> "ACE_Range"); _result = [_unit] call FUNC(getPlacedExplosives); _children = []; -_count = 0; { if (!isNull(_x select 0)) then { _required = getArray (ConfigFile >> "CfgACE_Triggers" >> (_x select 4) >> "requires"); @@ -44,13 +43,8 @@ _count = 0; [], ACE_Player ]; - _count = _count + 1; }; }; } foreach _result; -if (_count == 0) then { - call EFUNC(interaction,hideMenu); - [localize "STR_ACE_Explosives_NoExplosivesAvailable"] call EFUNC(common,displayTextStructured); -}; _children diff --git a/addons/explosives/functions/fnc_addExplosiveActions.sqf b/addons/explosives/functions/fnc_addExplosiveActions.sqf index b57549114c..29a2eed608 100644 --- a/addons/explosives/functions/fnc_addExplosiveActions.sqf +++ b/addons/explosives/functions/fnc_addExplosiveActions.sqf @@ -34,11 +34,14 @@ _itemCount = []; _children = []; { + private "_name"; + _name = if(isText(_x >> "displayNameShort") && {getText(_x >> "displayNameShort") != ""}) then + {getText (_x >> "displayNameShort")}else{getText(_x >> "displayName")}; _children pushBack [ [ format ["Explosive_%1", _forEachIndex], - format [getText(_x >> "displayName") + " (%1)", _itemCount select _foreachIndex], + format [_name + " (%1)", _itemCount select _foreachIndex], getText(_x >> "picture"), {(_this select 2) call FUNC(setupExplosive);}, {true}, diff --git a/addons/explosives/functions/fnc_openTransmitterUI.sqf b/addons/explosives/functions/fnc_addTransmitterActions.sqf similarity index 60% rename from addons/explosives/functions/fnc_openTransmitterUI.sqf rename to addons/explosives/functions/fnc_addTransmitterActions.sqf index dcd0436f5b..0313b8824e 100644 --- a/addons/explosives/functions/fnc_openTransmitterUI.sqf +++ b/addons/explosives/functions/fnc_addTransmitterActions.sqf @@ -9,12 +9,12 @@ * Nothing * * Example: - * [player] call ACE_Explosives_fnc_openTransmitterUI; + * [player] call ACE_Explosives_fnc_addTransmitterActions; * * Public: No */ #include "script_component.hpp" -private ["_items", "_unit", "_count", "_children", "_config"]; +private ["_items", "_unit", "_children", "_config"]; _unit = _this select 0; _detonators = [_unit] call FUNC(getDetonators); _children = []; @@ -28,7 +28,7 @@ _children = []; getText(_config >> "picture"), {}, {true}, - {(_this select 2) call FUNC(openDetonateUI);}, + {(_this select 2) call FUNC(addDetonateActions);}, [ACE_player,_x] ] call EFUNC(interact_menu,createAction), [], @@ -36,10 +36,4 @@ _children = []; ]; } foreach _detonators; -if (count _detonators == 0) then { - call EFUNC(interaction,hideMenu); - "ACE_Explosives" call EFUNC(interaction,openMenuSelf); - [format[localize "STR_ACE_Explosives_NoTriggersAvailable", "player"]] call EFUNC(Common,displayTextStructured); -}; - _children diff --git a/addons/explosives/functions/fnc_openTriggerSelectionUI.sqf b/addons/explosives/functions/fnc_addTriggerActions.sqf similarity index 69% rename from addons/explosives/functions/fnc_openTriggerSelectionUI.sqf rename to addons/explosives/functions/fnc_addTriggerActions.sqf index acf9eeffdb..b95ae88134 100644 --- a/addons/explosives/functions/fnc_openTriggerSelectionUI.sqf +++ b/addons/explosives/functions/fnc_addTriggerActions.sqf @@ -10,7 +10,7 @@ * None * * Example: - * [lbData [8866, lbCurSel 8866], _explosive] call ACE_Explosives_fnc_openTriggerSelectionUI; + * [lbData [8866, lbCurSel 8866], _explosive] call ACE_Explosives_fnc_addTriggerActions; * * Public: No */ @@ -22,7 +22,6 @@ _detonators = [ACE_player] call FUNC(getDetonators); _triggerTypes = [_magazine] call FUNC(triggerType); _magTriggers = ConfigFile >> "CfgMagazines" >> _magazine >> "ACE_Triggers"; -_count = 0; _children = []; { _required = getArray (_x >> "requires"); @@ -37,8 +36,10 @@ _children = []; [ [ format ["Trigger_%1", _forEachIndex], - if(isText(_magTriggers >> configName _x >> "displayName"))then{getText(_magTriggers >> configName _x >> "displayName")}else{getText(_x >> "displayName")}, - if(isText(_magTriggers >> configName _x >> "picture"))then{getText(_magTriggers >> configName _x >> "picture")}else{getText(_x >> "picture")}, + if(isText(_magTriggers >> configName _x >> "displayName"))then + {getText(_magTriggers >> configName _x >> "displayName")}else{getText(_x >> "displayName")}, + if(isText(_magTriggers >> configName _x >> "picture"))then + {getText(_magTriggers >> configName _x >> "picture")}else{getText(_x >> "picture")}, {(_this select 2) call FUNC(selectTrigger);}, {true}, {}, @@ -47,13 +48,7 @@ _children = []; [], ACE_Player ]; - _count = _count + 1; }; -} count _triggerTypes; - -if (_count == 0) then { - [format[localize "STR_ACE_Explosives_NoTriggersAvailable", - getText(configFile >> "CfgMagazines" >> _magazine >> "DisplayName")]] call EFUNC(Common,displayTextStructured); -}; +} foreach _triggerTypes; _children