Skip to content

Commit

Permalink
Add Scale Object module (#627)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Kexanone and mharis001 authored Aug 16, 2021
1 parent ef8efdc commit 6207e8d
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 0 deletions.
5 changes: 5 additions & 0 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions addons/common/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,11 @@
<Korean>요</Korean>
<Japanese>ヨー</Japanese>
</Key>
<Key ID="STR_ZEN_Common_Scale">
<English>Scale</English>
<French>Redimensionnement</French>
<German>Skalierung</German>
</Key>
<Key ID="STR_ZEN_Common_UncheckAll">
<English>Uncheck All</English>
<French>Décocher toutes</French>
Expand Down
6 changes: 6 additions & 0 deletions addons/modules/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions addons/modules/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ PREP(moduleNukeLocal);
PREP(modulePatrolArea);
PREP(moduleRemoveArsenal);
PREP(moduleRotateObject);
PREP(moduleScaleObject);
PREP(moduleSearchBuilding);
PREP(moduleShowInConfig);
PREP(moduleSideRelations);
Expand Down
1 change: 1 addition & 0 deletions addons/modules/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class CfgPatches {
QGVAR(modulePatrolArea),
QGVAR(moduleRemoveArsenal),
QGVAR(moduleRotateObject),
QGVAR(moduleScaleObject),
QGVAR(moduleSearchBuilding),
QGVAR(moduleSetDate),
QGVAR(moduleShowInConfig),
Expand Down
44 changes: 44 additions & 0 deletions addons/modules/functions/fnc_moduleScaleObject.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "script_component.hpp"
/*
* Author: Kex
* Zeus module function to scale an object.
*
* Arguments:
* 0: Logic <OBJECT>
*
* 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);
3 changes: 3 additions & 0 deletions addons/modules/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 20 additions & 0 deletions addons/modules/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,16 @@
<Japanese>オブジェクトの高さをこの値で変更します (負の値も可能).</Japanese>
<Korean>이 값에 따라 물체의 고도를 변경합니다. (음수도 가능)</Korean>
</Key>
<Key ID="STR_ZEN_Modules_ScaleObject">
<English>Scale Object</English>
<French>Redimensionner Objet</French>
<German>Objekt skalieren</German>
</Key>
<Key ID="STR_ZEN_Modules_ScaleObject_Tooltip">
<English>Scale the object by this factor relative to the original model.</English>
<French>Redimensionner l'objet par ce facteur en relation du modèle original.</French>
<German>Skaliere das Objekt um diesen Faktor relativ zum originalen Modell.</German>
</Key>
<Key ID="STR_ZEN_Modules_ModuleChatter">
<English>Chatter</English>
<Russian>Разговор</Russian>
Expand Down Expand Up @@ -2367,6 +2377,16 @@
<Korean>물체에 배치하기</Korean>
<Polish>Postaw na obiekcie</Polish>
</Key>
<Key ID="STR_ZEN_Modules_NotAttachedTo">
<English>Only for attached objects</English>
<French>Seulement pour des objets attachés</French>
<German>Nur für angehängte Objekte</German>
</Key>
<Key ID="STR_ZEN_Modules_ValueOutOfRange">
<English>Only values between %1 and %2 are valid</English>
<French>Seulement des valeurs entre %1 et %2 sont permises</French>
<German>Nur Werte zwischen %1 und %2 sind erlaubt</German>
</Key>
<Key ID="STR_ZEN_Modules_OnlyAlive">
<English>Unit must be alive</English>
<French>Utiliser uniquement sur une unité vivante</French>
Expand Down

0 comments on commit 6207e8d

Please sign in to comment.