From 1faf52831895feea250aa23d70e2ee2d7c6aa529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20E=C4=9Fitmen?= Date: Fri, 20 Jan 2017 14:36:27 +0300 Subject: [PATCH 1/5] Add showMessage fnc that shows BIS curator messages --- addons/zeus/XEH_PREP.hpp | 1 + .../functions/fnc_moduleAddOrRemoveFRIES.sqf | 10 +++---- .../functions/fnc_moduleAddSpareTrack.sqf | 8 ++--- .../functions/fnc_moduleAddSpareWheel.sqf | 8 ++--- addons/zeus/functions/fnc_moduleCaptive.sqf | 8 ++--- .../zeus/functions/fnc_moduleSearchNearby.sqf | 2 +- addons/zeus/functions/fnc_moduleSetMedic.sqf | 10 +++---- .../fnc_moduleSetMedicalFacility.sqf | 10 +++---- .../functions/fnc_moduleSetMedicalVehicle.sqf | 10 +++---- .../zeus/functions/fnc_moduleSimulation.sqf | 2 +- addons/zeus/functions/fnc_moduleSurrender.sqf | 10 +++---- .../zeus/functions/fnc_moduleUnconscious.sqf | 8 ++--- addons/zeus/functions/fnc_showMessage.sqf | 30 +++++++++++++++++++ addons/zeus/functions/fnc_ui_defendArea.sqf | 2 +- addons/zeus/functions/fnc_ui_groupSide.sqf | 2 +- addons/zeus/functions/fnc_ui_patrolArea.sqf | 2 +- addons/zeus/functions/fnc_ui_searchArea.sqf | 2 +- 17 files changed, 78 insertions(+), 47 deletions(-) create mode 100644 addons/zeus/functions/fnc_showMessage.sqf diff --git a/addons/zeus/XEH_PREP.hpp b/addons/zeus/XEH_PREP.hpp index a04b0a6d2c6..f52c300355f 100644 --- a/addons/zeus/XEH_PREP.hpp +++ b/addons/zeus/XEH_PREP.hpp @@ -20,6 +20,7 @@ PREP(moduleSurrender); PREP(moduleTeleportPlayers); PREP(moduleUnconscious); PREP(moduleZeusSettings); +PREP(showMessage); PREP(ui_attributeCargo); //PREP(ui_attributePosition); PREP(ui_attributeRadius); diff --git a/addons/zeus/functions/fnc_moduleAddOrRemoveFRIES.sqf b/addons/zeus/functions/fnc_moduleAddOrRemoveFRIES.sqf index 5c8998b767d..5ebae1844a4 100644 --- a/addons/zeus/functions/fnc_moduleAddOrRemoveFRIES.sqf +++ b/addons/zeus/functions/fnc_moduleAddOrRemoveFRIES.sqf @@ -19,27 +19,27 @@ params ["_logic", "_units", "_activated"]; if !(_activated && {local _logic}) exitWith {}; if !(["ace_fastroping"] call EFUNC(common,isModLoaded)) then { - [LSTRING(RequiresAddon)] call EFUNC(common,displayTextStructured); + [LSTRING(RequiresAddon)] call FUNC(showMessage); } else { (GETMVAR(BIS_fnc_curatorObjectPlaced_mouseOver,[""])) params ["_mouseOverType", "_mouseOverUnit"]; if (_mouseOverType != "OBJECT") then { - [LSTRING(NothingSelected)] call EFUNC(common,displayTextStructured); + [LSTRING(NothingSelected)] call FUNC(showMessage); } else { if !(alive _mouseOverUnit) then { - [LSTRING(OnlyAlive)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyAlive)] call FUNC(showMessage); } else { private _config = configFile >> "CfgVehicles" >> typeOf _mouseOverUnit; private _displayName = getText (_config >> "displayName"); if !(isNumber (_config >> QEGVAR(fastroping,enabled))) then { - [[LSTRING(NotFastRopeCompatible), _displayName]] call EFUNC(common,displayTextStructured); + [[LSTRING(NotFastRopeCompatible), _displayName]] call FUNC(showMessage); } else { private _fries = GETVAR(_mouseOverUnit,EGVAR(fastroping,FRIES),objNull); if (isNull _fries) then { [QGVAR(equipFries), [_mouseOverUnit]] call CBA_fnc_serverEvent; } else { if ([_mouseOverUnit] call EFUNC(fastroping,canCutRopes)) then { - [[LSTRING(CantRemoveFRIES), _displayName]] call EFUNC(common,displayTextStructured); + [[LSTRING(CantRemoveFRIES), _displayName]] call FUNC(showMessage); } else { [_mouseOverUnit] call EFUNC(fastroping,cutRopes); deleteVehicle _fries; diff --git a/addons/zeus/functions/fnc_moduleAddSpareTrack.sqf b/addons/zeus/functions/fnc_moduleAddSpareTrack.sqf index 2926fafcf92..3a291ac5b39 100644 --- a/addons/zeus/functions/fnc_moduleAddSpareTrack.sqf +++ b/addons/zeus/functions/fnc_moduleAddSpareTrack.sqf @@ -19,18 +19,18 @@ params ["_logic", "_units", "_activated"]; if !(_activated && local _logic) exitWith {}; if !(["ace_cargo"] call EFUNC(common,isModLoaded) && ["ace_repair"] call EFUNC(common,isModLoaded)) then { - [LSTRING(RequiresAddon)] call EFUNC(common,displayTextStructured); + [LSTRING(RequiresAddon)] call FUNC(showMessage); } else { (GETMVAR(bis_fnc_curatorObjectPlaced_mouseOver,[""])) params ["_mouseOverType", "_mouseOverUnit"]; if (_mouseOverType != "OBJECT") then { - [LSTRING(NothingSelected)] call EFUNC(common,displayTextStructured); + [LSTRING(NothingSelected)] call FUNC(showMessage); } else { if !(alive _mouseOverUnit) then { - [LSTRING(OnlyAlive)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyAlive)] call FUNC(showMessage); } else { if (getNumber (configFile >> "CfgVehicles" >> "ACE_Track" >> QEGVAR(cargo,size)) > [_mouseOverUnit] call EFUNC(cargo,getCargoSpaceLeft)) then { - [LSTRING(OnlyEnoughCargoSpace)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyEnoughCargoSpace)] call FUNC(showMessage); } else { ["ace_addCargo", ["ACE_Track", _mouseOverUnit, 1, true]] call CBA_fnc_localEvent; }; diff --git a/addons/zeus/functions/fnc_moduleAddSpareWheel.sqf b/addons/zeus/functions/fnc_moduleAddSpareWheel.sqf index 2c051c94b67..50dc25d62c0 100644 --- a/addons/zeus/functions/fnc_moduleAddSpareWheel.sqf +++ b/addons/zeus/functions/fnc_moduleAddSpareWheel.sqf @@ -19,18 +19,18 @@ params ["_logic", "_units", "_activated"]; if !(_activated && local _logic) exitWith {}; if !(["ace_cargo"] call EFUNC(common,isModLoaded) && ["ace_repair"] call EFUNC(common,isModLoaded)) then { - [LSTRING(RequiresAddon)] call EFUNC(common,displayTextStructured); + [LSTRING(RequiresAddon)] call FUNC(showMessage); } else { (GETMVAR(bis_fnc_curatorObjectPlaced_mouseOver,[""])) params ["_mouseOverType", "_mouseOverUnit"]; if (_mouseOverType != "OBJECT") then { - [LSTRING(NothingSelected)] call EFUNC(common,displayTextStructured); + [LSTRING(NothingSelected)] call FUNC(showMessage); } else { if !(alive _mouseOverUnit) then { - [LSTRING(OnlyAlive)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyAlive)] call FUNC(showMessage); } else { if (getNumber (configFile >> "CfgVehicles" >> "ACE_Wheel" >> QEGVAR(cargo,size)) > [_mouseOverUnit] call EFUNC(cargo,getCargoSpaceLeft)) then { - [LSTRING(OnlyEnoughCargoSpace)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyEnoughCargoSpace)] call FUNC(showMessage); } else { ["ace_addCargo", ["ACE_Wheel", _mouseOverUnit, 1, true]] call CBA_fnc_localEvent; }; diff --git a/addons/zeus/functions/fnc_moduleCaptive.sqf b/addons/zeus/functions/fnc_moduleCaptive.sqf index 732c165fa43..4db34231c07 100644 --- a/addons/zeus/functions/fnc_moduleCaptive.sqf +++ b/addons/zeus/functions/fnc_moduleCaptive.sqf @@ -21,20 +21,20 @@ private ["_mouseOver", "_unit", "_captive"]; if !(_activated && local _logic) exitWith {}; if (isNil QEFUNC(captives,setHandcuffed)) then { - [LSTRING(RequiresAddon)] call EFUNC(common,displayTextStructured); + [LSTRING(RequiresAddon)] call FUNC(showMessage); } else { _mouseOver = GETMVAR(bis_fnc_curatorObjectPlaced_mouseOver,[""]); if ((_mouseOver select 0) != "OBJECT") then { - [LSTRING(NothingSelected)] call EFUNC(common,displayTextStructured); + [LSTRING(NothingSelected)] call FUNC(showMessage); } else { _unit = effectivecommander (_mouseOver select 1); if !(_unit isKindOf "CAManBase") then { - [LSTRING(OnlyInfantry)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyInfantry)] call FUNC(showMessage); } else { if !(alive _unit) then { - [LSTRING(OnlyAlive)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyAlive)] call FUNC(showMessage); } else { _captive = GETVAR(_unit,EGVAR(captives,isHandcuffed),false); // Event initalized by ACE_Captives diff --git a/addons/zeus/functions/fnc_moduleSearchNearby.sqf b/addons/zeus/functions/fnc_moduleSearchNearby.sqf index 76f77c489e6..47b423faddc 100644 --- a/addons/zeus/functions/fnc_moduleSearchNearby.sqf +++ b/addons/zeus/functions/fnc_moduleSearchNearby.sqf @@ -27,7 +27,7 @@ scopeName "Main"; private _fnc_errorAndClose = { params ["_msg"]; deleteVehicle _logic; - [_msg] call EFUNC(common,displayTextStructured); + [_msg] call FUNC(showMessage); breakOut "Main"; }; diff --git a/addons/zeus/functions/fnc_moduleSetMedic.sqf b/addons/zeus/functions/fnc_moduleSetMedic.sqf index 14dfca4f6f6..55b1f2687b2 100644 --- a/addons/zeus/functions/fnc_moduleSetMedic.sqf +++ b/addons/zeus/functions/fnc_moduleSetMedic.sqf @@ -21,23 +21,23 @@ private ["_mouseOver", "_unit", "_medicN"]; if !(_activated && local _logic) exitWith {}; if !(["ACE_Medical"] call EFUNC(common,isModLoaded)) then { - [LSTRING(RequiresAddon)] call EFUNC(common,displayTextStructured); + [LSTRING(RequiresAddon)] call FUNC(showMessage); } else { _mouseOver = GETMVAR(bis_fnc_curatorObjectPlaced_mouseOver,[""]); if ((_mouseOver select 0) != "OBJECT") then { - [LSTRING(NothingSelected)] call EFUNC(common,displayTextStructured); + [LSTRING(NothingSelected)] call FUNC(showMessage); } else { _unit = effectivecommander (_mouseOver select 1); if !(_unit isKindOf "CAManBase") then { - [LSTRING(OnlyInfantry)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyInfantry)] call FUNC(showMessage); } else { if !(alive _unit) then { - [LSTRING(OnlyAlive)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyAlive)] call FUNC(showMessage); } else { if (GETVAR(_unit,EGVAR(captives,isHandcuffed),false)) then { - [LSTRING(OnlyNonCaptive)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyNonCaptive)] call FUNC(showMessage); } else { _medicN = GETVAR(_unit,EGVAR(medical,medicClass),0); if (_medicN < 1) then { diff --git a/addons/zeus/functions/fnc_moduleSetMedicalFacility.sqf b/addons/zeus/functions/fnc_moduleSetMedicalFacility.sqf index 4c26ccdd712..e0a3131f444 100644 --- a/addons/zeus/functions/fnc_moduleSetMedicalFacility.sqf +++ b/addons/zeus/functions/fnc_moduleSetMedicalFacility.sqf @@ -21,23 +21,23 @@ private ["_mouseOver", "_unit"]; if !(_activated && local _logic) exitWith {}; if !(["ACE_Medical"] call EFUNC(common,isModLoaded)) then { - [LSTRING(RequiresAddon)] call EFUNC(common,displayTextStructured); + [LSTRING(RequiresAddon)] call FUNC(showMessage); } else { _mouseOver = GETMVAR(bis_fnc_curatorObjectPlaced_mouseOver,[""]); if ((_mouseOver select 0) != "OBJECT") then { - [LSTRING(NothingSelected)] call EFUNC(common,displayTextStructured); + [LSTRING(NothingSelected)] call FUNC(showMessage); } else { _unit = (_mouseOver select 1); if (_unit isKindOf "Man" || {!(_unit isKindOf "Building")}) then { - [LSTRING(OnlyStructures)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyStructures)] call FUNC(showMessage); } else { if !(alive _unit) then { - [LSTRING(OnlyAlive)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyAlive)] call FUNC(showMessage); } else { if (GETVAR(_unit,EGVAR(captives,isHandcuffed),false)) then { - [LSTRING(OnlyNonCaptive)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyNonCaptive)] call FUNC(showMessage); } else { if (!(GETVAR(_unit,EGVAR(medical,isMedicalFacility),false))) then { _unit setVariable [QEGVAR(medical,isMedicalFacility), true, true]; diff --git a/addons/zeus/functions/fnc_moduleSetMedicalVehicle.sqf b/addons/zeus/functions/fnc_moduleSetMedicalVehicle.sqf index abbc26b1ed7..49070dbfb9e 100644 --- a/addons/zeus/functions/fnc_moduleSetMedicalVehicle.sqf +++ b/addons/zeus/functions/fnc_moduleSetMedicalVehicle.sqf @@ -21,23 +21,23 @@ private ["_mouseOver", "_unit", "_medicN"]; if !(_activated && local _logic) exitWith {}; if !(["ACE_Medical"] call EFUNC(common,isModLoaded)) then { - [LSTRING(RequiresAddon)] call EFUNC(common,displayTextStructured); + [LSTRING(RequiresAddon)] call FUNC(showMessage); } else { _mouseOver = GETMVAR(bis_fnc_curatorObjectPlaced_mouseOver,[""]); if ((_mouseOver select 0) != "OBJECT") then { - [LSTRING(NothingSelected)] call EFUNC(common,displayTextStructured); + [LSTRING(NothingSelected)] call FUNC(showMessage); } else { _unit = (_mouseOver select 1); if (_unit isKindOf "Man" || {_unit isKindOf "Building"}) then { - [LSTRING(OnlyVehicles)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyVehicles)] call FUNC(showMessage); } else { if !(alive _unit) then { - [LSTRING(OnlyAlive)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyAlive)] call FUNC(showMessage); } else { if (GETVAR(_unit,EGVAR(captives,isHandcuffed),false)) then { - [LSTRING(OnlyNonCaptive)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyNonCaptive)] call FUNC(showMessage); } else { _medicN = GETVAR(_unit,EGVAR(medical,medicClass),0); if (_medicN < 1) then { diff --git a/addons/zeus/functions/fnc_moduleSimulation.sqf b/addons/zeus/functions/fnc_moduleSimulation.sqf index fab59e48eb3..fe7f3564e0f 100644 --- a/addons/zeus/functions/fnc_moduleSimulation.sqf +++ b/addons/zeus/functions/fnc_moduleSimulation.sqf @@ -19,7 +19,7 @@ if !(local _logic) exitWith {}; private _object = attachedTo _logic; if (isNull _object) then { - [LSTRING(NothingSelected)] call EFUNC(common,displayTextStructured); + [LSTRING(NothingSelected)] call FUNC(showMessage); } else { [QEGVAR(common,enableSimulationGlobal), [_object, !(simulationEnabled _object)]] call CBA_fnc_serverEvent; }; diff --git a/addons/zeus/functions/fnc_moduleSurrender.sqf b/addons/zeus/functions/fnc_moduleSurrender.sqf index d6d030a4c58..5e4890ae75f 100644 --- a/addons/zeus/functions/fnc_moduleSurrender.sqf +++ b/addons/zeus/functions/fnc_moduleSurrender.sqf @@ -21,23 +21,23 @@ private ["_mouseOver", "_unit", "_surrendering"]; if !(_activated && local _logic) exitWith {}; if (isNil QEFUNC(captives,setSurrendered)) then { - [LSTRING(RequiresAddon)] call EFUNC(common,displayTextStructured); + [LSTRING(RequiresAddon)] call FUNC(showMessage); } else { _mouseOver = GETMVAR(bis_fnc_curatorObjectPlaced_mouseOver,[""]); if ((_mouseOver select 0) != "OBJECT") then { - [LSTRING(NothingSelected)] call EFUNC(common,displayTextStructured); + [LSTRING(NothingSelected)] call FUNC(showMessage); } else { _unit = effectivecommander (_mouseOver select 1); if !(_unit isKindOf "CAManBase") then { - [LSTRING(OnlyInfantry)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyInfantry)] call FUNC(showMessage); } else { if !(alive _unit) then { - [LSTRING(OnlyAlive)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyAlive)] call FUNC(showMessage); } else { if (GETVAR(_unit,EGVAR(captives,isHandcuffed),false)) then { - [LSTRING(OnlyNonCaptive)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyNonCaptive)] call FUNC(showMessage); } else { _surrendering = GETVAR(_unit,EGVAR(captives,isSurrendering),false); // Event initalized by ACE_Captives diff --git a/addons/zeus/functions/fnc_moduleUnconscious.sqf b/addons/zeus/functions/fnc_moduleUnconscious.sqf index 502847feda3..0cf0fffda6d 100644 --- a/addons/zeus/functions/fnc_moduleUnconscious.sqf +++ b/addons/zeus/functions/fnc_moduleUnconscious.sqf @@ -21,20 +21,20 @@ private ["_mouseOver", "_unit", "_conscious"]; if !(_activated && local _logic) exitWith {}; if (isNil QEFUNC(medical,setUnconscious)) then { - [LSTRING(RequiresAddon)] call EFUNC(common,displayTextStructured); + [LSTRING(RequiresAddon)] call FUNC(showMessage); } else { _mouseOver = GETMVAR(bis_fnc_curatorObjectPlaced_mouseOver,[""]); if ((_mouseOver select 0) != "OBJECT") then { - [LSTRING(NothingSelected)] call EFUNC(common,displayTextStructured); + [LSTRING(NothingSelected)] call FUNC(showMessage); } else { _unit = effectivecommander (_mouseOver select 1); if !(_unit isKindOf "CAManBase") then { - [LSTRING(OnlyInfantry)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyInfantry)] call FUNC(showMessage); } else { if !(alive _unit) then { - [LSTRING(OnlyAlive)] call EFUNC(common,displayTextStructured); + [LSTRING(OnlyAlive)] call FUNC(showMessage); } else { _conscious = GETVAR(_unit,ACE_isUnconscious,false); // Function handles locality for me diff --git a/addons/zeus/functions/fnc_showMessage.sqf b/addons/zeus/functions/fnc_showMessage.sqf new file mode 100644 index 00000000000..d46bdbb40be --- /dev/null +++ b/addons/zeus/functions/fnc_showMessage.sqf @@ -0,0 +1,30 @@ +/* + * Author: 654wak654 + * Shows a zeus message through the BIS function, handles localization + * + * Arguments: + * 0: The message + * + * Return Value: + * Nothing + * + * Example: + * ["something"] call ace_zeus_fnc_showMessage + * + * Public: Yes + */ + +#include "script_component.hpp" + +params ["_message"]; + +if (_message isEqualType "" && {isLocalized _message}) then { + _message = localize _message; +} else { + if (_message isEqualType []) then { + MAP(_message,if (isLocalized _x) then {localize _x} else {_x}); + _message = format _message; + }; +}; + +[objNull, _message] call BIS_fnc_showCuratorFeedbackMessage; diff --git a/addons/zeus/functions/fnc_ui_defendArea.sqf b/addons/zeus/functions/fnc_ui_defendArea.sqf index 492f74cf481..5d4f6529507 100644 --- a/addons/zeus/functions/fnc_ui_defendArea.sqf +++ b/addons/zeus/functions/fnc_ui_defendArea.sqf @@ -28,7 +28,7 @@ private _fnc_errorAndClose = { params ["_msg"]; _display closeDisplay 0; deleteVehicle _logic; - [_msg] call EFUNC(common,displayTextStructured); + [_msg] call FUNC(showMessage); breakOut "Main"; }; diff --git a/addons/zeus/functions/fnc_ui_groupSide.sqf b/addons/zeus/functions/fnc_ui_groupSide.sqf index 46418a71fc4..e983d49ea1e 100644 --- a/addons/zeus/functions/fnc_ui_groupSide.sqf +++ b/addons/zeus/functions/fnc_ui_groupSide.sqf @@ -33,7 +33,7 @@ private _fnc_errorAndClose = { params ["_msg"]; _display closeDisplay 0; deleteVehicle _logic; - [_msg] call EFUNC(common,displayTextStructured); + [_msg] call FUNC(showMessage); breakOut "Main"; }; diff --git a/addons/zeus/functions/fnc_ui_patrolArea.sqf b/addons/zeus/functions/fnc_ui_patrolArea.sqf index 9db2df9773c..c94e2b3dd23 100644 --- a/addons/zeus/functions/fnc_ui_patrolArea.sqf +++ b/addons/zeus/functions/fnc_ui_patrolArea.sqf @@ -28,7 +28,7 @@ private _fnc_errorAndClose = { params ["_msg"]; _display closeDisplay 0; deleteVehicle _logic; - [_msg] call EFUNC(common,displayTextStructured); + [_msg] call FUNC(showMessage); breakOut "Main"; }; diff --git a/addons/zeus/functions/fnc_ui_searchArea.sqf b/addons/zeus/functions/fnc_ui_searchArea.sqf index d30af4e234d..30e012e29b3 100644 --- a/addons/zeus/functions/fnc_ui_searchArea.sqf +++ b/addons/zeus/functions/fnc_ui_searchArea.sqf @@ -28,7 +28,7 @@ private _fnc_errorAndClose = { params ["_msg"]; _display closeDisplay 0; deleteVehicle _logic; - [_msg] call EFUNC(common,displayTextStructured); + [_msg] call FUNC(showMessage); breakOut "Main"; }; From cd1268f92ca92b046581ce72a2903773ecdde408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20E=C4=9Fitmen?= Date: Fri, 20 Jan 2017 15:37:48 +0200 Subject: [PATCH 2/5] Add documentation --- addons/zeus/functions/fnc_showMessage.sqf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/zeus/functions/fnc_showMessage.sqf b/addons/zeus/functions/fnc_showMessage.sqf index d46bdbb40be..f71109a5b41 100644 --- a/addons/zeus/functions/fnc_showMessage.sqf +++ b/addons/zeus/functions/fnc_showMessage.sqf @@ -1,15 +1,17 @@ /* * Author: 654wak654 - * Shows a zeus message through the BIS function, handles localization + * Shows a zeus message through the BIS function, handles localization. + * If the _message param is an array, it gets formatted. * * Arguments: - * 0: The message + * 0: The message or * * Return Value: * Nothing * * Example: * ["something"] call ace_zeus_fnc_showMessage + * [["something %1", "strange"]] call ace_zeus_fnc_showMessage * * Public: Yes */ From 66ab40b144372205fef8018ca8e66c281028465b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20E=C4=9Fitmen?= Date: Fri, 20 Jan 2017 18:19:30 +0200 Subject: [PATCH 3/5] Make function simpler --- addons/zeus/functions/fnc_showMessage.sqf | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/addons/zeus/functions/fnc_showMessage.sqf b/addons/zeus/functions/fnc_showMessage.sqf index f71109a5b41..448977f604f 100644 --- a/addons/zeus/functions/fnc_showMessage.sqf +++ b/addons/zeus/functions/fnc_showMessage.sqf @@ -1,32 +1,22 @@ /* * Author: 654wak654 * Shows a zeus message through the BIS function, handles localization. - * If the _message param is an array, it gets formatted. + * If multiple args are given, they get formatted. * * Arguments: - * 0: The message or + * The message ... * * Return Value: * Nothing * * Example: * ["something"] call ace_zeus_fnc_showMessage - * [["something %1", "strange"]] call ace_zeus_fnc_showMessage + * ["something %1", "strange"] call ace_zeus_fnc_showMessage * * Public: Yes */ #include "script_component.hpp" -params ["_message"]; - -if (_message isEqualType "" && {isLocalized _message}) then { - _message = localize _message; -} else { - if (_message isEqualType []) then { - MAP(_message,if (isLocalized _x) then {localize _x} else {_x}); - _message = format _message; - }; -}; - -[objNull, _message] call BIS_fnc_showCuratorFeedbackMessage; +private _message = _this apply {if (isLocalized _x) then {localize _x} else {_x}}; +[objNull, format _message] call BIS_fnc_showCuratorFeedbackMessage; From 22f18c4abff8f1eb0b1f958a16120e2197cfdb04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20E=C4=9Fitmen?= Date: Fri, 20 Jan 2017 18:20:02 +0200 Subject: [PATCH 4/5] Modify to fir new syntax --- addons/zeus/functions/fnc_moduleAddOrRemoveFRIES.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/zeus/functions/fnc_moduleAddOrRemoveFRIES.sqf b/addons/zeus/functions/fnc_moduleAddOrRemoveFRIES.sqf index 5ebae1844a4..d75c0173fe6 100644 --- a/addons/zeus/functions/fnc_moduleAddOrRemoveFRIES.sqf +++ b/addons/zeus/functions/fnc_moduleAddOrRemoveFRIES.sqf @@ -32,14 +32,14 @@ if !(["ace_fastroping"] call EFUNC(common,isModLoaded)) then { private _config = configFile >> "CfgVehicles" >> typeOf _mouseOverUnit; private _displayName = getText (_config >> "displayName"); if !(isNumber (_config >> QEGVAR(fastroping,enabled))) then { - [[LSTRING(NotFastRopeCompatible), _displayName]] call FUNC(showMessage); + [LSTRING(NotFastRopeCompatible), _displayName] call FUNC(showMessage); } else { private _fries = GETVAR(_mouseOverUnit,EGVAR(fastroping,FRIES),objNull); if (isNull _fries) then { [QGVAR(equipFries), [_mouseOverUnit]] call CBA_fnc_serverEvent; } else { if ([_mouseOverUnit] call EFUNC(fastroping,canCutRopes)) then { - [[LSTRING(CantRemoveFRIES), _displayName]] call FUNC(showMessage); + [LSTRING(CantRemoveFRIES), _displayName] call FUNC(showMessage); } else { [_mouseOverUnit] call EFUNC(fastroping,cutRopes); deleteVehicle _fries; From 1431456cc51f38a225379642a987b2c2ac0031a2 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 2 Mar 2017 17:45:53 -0600 Subject: [PATCH 5/5] Handle non-string args --- addons/zeus/functions/fnc_showMessage.sqf | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/zeus/functions/fnc_showMessage.sqf b/addons/zeus/functions/fnc_showMessage.sqf index 448977f604f..9ce8ced9c3e 100644 --- a/addons/zeus/functions/fnc_showMessage.sqf +++ b/addons/zeus/functions/fnc_showMessage.sqf @@ -4,19 +4,21 @@ * If multiple args are given, they get formatted. * * Arguments: - * The message ... + * 0: The message + * N: Anything * * Return Value: * Nothing * * Example: * ["something"] call ace_zeus_fnc_showMessage - * ["something %1", "strange"] call ace_zeus_fnc_showMessage + * ["something %1 in %2", "strange", getPos neighborhood] call ace_zeus_fnc_showMessage * * Public: Yes */ - #include "script_component.hpp" -private _message = _this apply {if (isLocalized _x) then {localize _x} else {_x}}; +if (!(_this isEqualTypeParams [""])) exitWith {ERROR_1("First arg must be string [%1]",_this);}; + +private _message = _this apply {if ((_x isEqualType "") && {isLocalized _x}) then {localize _x} else {_x}}; [objNull, format _message] call BIS_fnc_showCuratorFeedbackMessage;