From 6207e8d91275efe91631a371fbf38afd6b8c764c Mon Sep 17 00:00:00 2001 From: Kex Date: Mon, 16 Aug 2021 18:22:17 +0200 Subject: [PATCH] Add Scale Object module (#627) * Add scale object module * Reorder stringtable entry * Improve tooltip * Change default value and move setObjectScale to common * Limit scale range * Add missing bracket * Move parseNumber * Proper localize string * Move setObjectScale to proper block * Clean-up * Clean-up * Update addons/modules/functions/fnc_moduleScaleObject.sqf Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com> * Update addons/modules/functions/fnc_moduleScaleObject.sqf Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com> Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com> --- addons/common/XEH_postInit.sqf | 5 +++ addons/common/stringtable.xml | 5 +++ addons/modules/CfgVehicles.hpp | 6 +++ addons/modules/XEH_PREP.hpp | 1 + addons/modules/config.cpp | 1 + .../functions/fnc_moduleScaleObject.sqf | 44 +++++++++++++++++++ addons/modules/script_component.hpp | 3 ++ addons/modules/stringtable.xml | 20 +++++++++ 8 files changed, 85 insertions(+) create mode 100644 addons/modules/functions/fnc_moduleScaleObject.sqf diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 7ceb451f0..606652ca2 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -263,6 +263,11 @@ _unit doArtilleryFire [_position, _magazine, _rounds]; }] call CBA_fnc_addEventHandler; +[QGVAR(setObjectScale), { + params ["_object", "_scale"]; + _object setObjectScale _scale; +}] call CBA_fnc_addEventHandler; + [QGVAR(setVehicleRadar), { params ["_vehicle", "_mode"]; _vehicle setVehicleRadar _mode; diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index 424328270..aaef50e81 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -536,6 +536,11 @@ ヨー + + Scale + Redimensionnement + Skalierung + Uncheck All Décocher toutes diff --git a/addons/modules/CfgVehicles.hpp b/addons/modules/CfgVehicles.hpp index fe8d44c7f..1f8f97f2d 100644 --- a/addons/modules/CfgVehicles.hpp +++ b/addons/modules/CfgVehicles.hpp @@ -347,6 +347,12 @@ class CfgVehicles { function = QFUNC(moduleRotateObject); icon = QPATHTOF(ui\rotate_ca.paa); }; + class GVAR(moduleScaleObject): GVAR(moduleBase) { + curatorCanAttach = 1; + category = QGVAR(Objects); + displayName = CSTRING(ScaleObject); + function = QFUNC(moduleScaleObject); + }; class GVAR(moduleSearchBuilding): GVAR(moduleBase) { curatorCanAttach = 1; category = QGVAR(AI); diff --git a/addons/modules/XEH_PREP.hpp b/addons/modules/XEH_PREP.hpp index b79eb2e06..d6176612c 100644 --- a/addons/modules/XEH_PREP.hpp +++ b/addons/modules/XEH_PREP.hpp @@ -70,6 +70,7 @@ PREP(moduleNukeLocal); PREP(modulePatrolArea); PREP(moduleRemoveArsenal); PREP(moduleRotateObject); +PREP(moduleScaleObject); PREP(moduleSearchBuilding); PREP(moduleShowInConfig); PREP(moduleSideRelations); diff --git a/addons/modules/config.cpp b/addons/modules/config.cpp index 09afceb4c..8d680567e 100644 --- a/addons/modules/config.cpp +++ b/addons/modules/config.cpp @@ -52,6 +52,7 @@ class CfgPatches { QGVAR(modulePatrolArea), QGVAR(moduleRemoveArsenal), QGVAR(moduleRotateObject), + QGVAR(moduleScaleObject), QGVAR(moduleSearchBuilding), QGVAR(moduleSetDate), QGVAR(moduleShowInConfig), diff --git a/addons/modules/functions/fnc_moduleScaleObject.sqf b/addons/modules/functions/fnc_moduleScaleObject.sqf new file mode 100644 index 000000000..e9d902d10 --- /dev/null +++ b/addons/modules/functions/fnc_moduleScaleObject.sqf @@ -0,0 +1,44 @@ +#include "script_component.hpp" +/* + * Author: Kex + * Zeus module function to scale an object. + * + * Arguments: + * 0: Logic + * + * Return Value: + * None + * + * Example: + * [LOGIC] call zen_modules_fnc_moduleScaleObject + * + * Public: No + */ + +params ["_logic"]; + +private _object = attachedTo _logic; +deleteVehicle _logic; + +if (isNull _object) exitWith { + [LSTRING(NoObjectSelected)] call EFUNC(common,showMessage); +}; + +if (isNull attachedTo _object) exitWith { + [LSTRING(NotAttachedTo)] call EFUNC(common,showMessage); +}; + +[LSTRING(ScaleObject), [ + ["EDIT", [ELSTRING(common,Scale), LSTRING(ScaleObject_Tooltip)], str getObjectScale _object, true] +], { + params ["_values", "_object"]; + _values params ["_scale"]; + + _scale = parseNumber _scale; + + if (_scale < OBJECT_SCALE_MIN || {_scale > OBJECT_SCALE_MAX}) exitWith { + [format [LLSTRING(ValueOutOfRange), OBJECT_SCALE_MIN, OBJECT_SCALE_MAX]] call EFUNC(common,showMessage); + }; + + [QEGVAR(common,setObjectScale), [_object, _scale], _object] call CBA_fnc_targetEvent; +}, {}, _object] call EFUNC(dialog,create); diff --git a/addons/modules/script_component.hpp b/addons/modules/script_component.hpp index 31e87de1c..00d086a0c 100644 --- a/addons/modules/script_component.hpp +++ b/addons/modules/script_component.hpp @@ -174,3 +174,6 @@ #define MS_TO_KMH(value) ((value) * 3.6) #define KMH_TO_MS(value) ((value) / 3.6) + +#define OBJECT_SCALE_MIN 0.0001 +#define OBJECT_SCALE_MAX 65504 diff --git a/addons/modules/stringtable.xml b/addons/modules/stringtable.xml index 588e3e810..60da67f37 100644 --- a/addons/modules/stringtable.xml +++ b/addons/modules/stringtable.xml @@ -870,6 +870,16 @@ オブジェクトの高さをこの値で変更します (負の値も可能). 이 값에 따라 물체의 고도를 변경합니다. (음수도 가능) + + Scale Object + Redimensionner Objet + Objekt skalieren + + + Scale the object by this factor relative to the original model. + Redimensionner l'objet par ce facteur en relation du modèle original. + Skaliere das Objekt um diesen Faktor relativ zum originalen Modell. + Chatter Разговор @@ -2367,6 +2377,16 @@ 물체에 배치하기 Postaw na obiekcie + + Only for attached objects + Seulement pour des objets attachés + Nur für angehängte Objekte + + + Only values between %1 and %2 are valid + Seulement des valeurs entre %1 et %2 sont permises + Nur Werte zwischen %1 und %2 sind erlaubt + Unit must be alive Utiliser uniquement sur une unité vivante