diff --git a/addons/ui_units/$PBOPREFIX$ b/addons/ui_units/$PBOPREFIX$ new file mode 100644 index 00000000000..b93deea9f45 --- /dev/null +++ b/addons/ui_units/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\ui_units diff --git a/addons/ui_units/CfgEventHandlers.hpp b/addons/ui_units/CfgEventHandlers.hpp new file mode 100644 index 00000000000..0d3301d6e0a --- /dev/null +++ b/addons/ui_units/CfgEventHandlers.hpp @@ -0,0 +1,17 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; diff --git a/addons/ui_units/XEH_PREP.hpp b/addons/ui_units/XEH_PREP.hpp new file mode 100644 index 00000000000..607ccdb1192 --- /dev/null +++ b/addons/ui_units/XEH_PREP.hpp @@ -0,0 +1,6 @@ +PREP(altInfo); +PREP(altUnits); +PREP(onAltLoad); +PREP(onSpeedLoad); +PREP(speedInfo); +PREP(speedUnits); diff --git a/addons/ui_units/XEH_postInit.sqf b/addons/ui_units/XEH_postInit.sqf new file mode 100644 index 00000000000..022888575ed --- /dev/null +++ b/addons/ui_units/XEH_postInit.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +#include "XEH_PREP.hpp" diff --git a/addons/ui_units/XEH_preInit.sqf b/addons/ui_units/XEH_preInit.sqf new file mode 100644 index 00000000000..9361d05015e --- /dev/null +++ b/addons/ui_units/XEH_preInit.sqf @@ -0,0 +1,11 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +#include "initSettings.sqf" + +ADDON = true; diff --git a/addons/ui_units/XEH_preStart.sqf b/addons/ui_units/XEH_preStart.sqf new file mode 100644 index 00000000000..a51262a37b9 --- /dev/null +++ b/addons/ui_units/XEH_preStart.sqf @@ -0,0 +1,2 @@ +#include "script_component.hpp" +#include "XEH_PREP.hpp" diff --git a/addons/ui_units/config.cpp b/addons/ui_units/config.cpp new file mode 100644 index 00000000000..ae52cc8fa01 --- /dev/null +++ b/addons/ui_units/config.cpp @@ -0,0 +1,62 @@ +#include "script_component.hpp" +#include "\a3\ui_f\hpp\defineCommonGrids.inc" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author = ECSTRING(common,ACETeam); + authors[] = {"SynixeBrett"}; + url = ECSTRING(main,URL); + VERSION_CONFIG; + }; +}; + +class RscText; +class RscInGameUI { + class RscUnitInfo { + class CA_Alt: RscText { + onLoad = QUOTE(call FUNC(onAltLoad)); + }; + class CA_Speed: RscText { + onLoad = QUOTE(call FUNC(onSpeedLoad)); + }; + }; +}; + +class GVAR(alt): RscText { + style = 1; + colorText[] = { + "(profileNamespace getVariable ['IGUI_TEXT_RGB_R',0])", + "(profileNamespace getVariable ['IGUI_TEXT_RGB_G',1])", + "(profileNamespace getVariable ['IGUI_TEXT_RGB_B',1])", + "(profileNamespace getVariable ['IGUI_TEXT_RGB_A',0.8])" + }; + text = "9999"; + x = 6.3 * GUI_GRID_W + (profileNamespace getVariable ["IGUI_GRID_VEHICLE_X", (safezoneX + 0.5 * GUI_GRID_W)]); + y = 2.3 * GUI_GRID_H + (profileNamespace getVariable ["IGUI_GRID_VEHICLE_Y", (safezoneY + 0.5 * GUI_GRID_H)]); + w = 2 * GUI_GRID_W; + h = 1 * GUI_GRID_H; + sizeEx = 0.8 * GUI_GRID_H; +}; + +class GVAR(speed): RscText { + style = 1; + colorText[] = { + "(profileNamespace getVariable ['IGUI_TEXT_RGB_R',0])", + "(profileNamespace getVariable ['IGUI_TEXT_RGB_G',1])", + "(profileNamespace getVariable ['IGUI_TEXT_RGB_B',1])", + "(profileNamespace getVariable ['IGUI_TEXT_RGB_A',0.8])" + }; + text = "9999"; + x = 6.3 * GUI_GRID_W + (profileNamespace getVariable ["IGUI_GRID_VEHICLE_X", (safezoneX + 0.5 * GUI_GRID_W)]); + y = 1.3 * GUI_GRID_H + (profileNamespace getVariable ["IGUI_GRID_VEHICLE_Y", (safezoneY + 0.5 * GUI_GRID_H)]); + w = 2 * GUI_GRID_W; + h = 1 * GUI_GRID_H; + sizeEx = 0.8 * GUI_GRID_H; +}; + +#include "CfgEventHandlers.hpp" diff --git a/addons/ui_units/functions/fnc_altInfo.sqf b/addons/ui_units/functions/fnc_altInfo.sqf new file mode 100644 index 00000000000..2a5aa54b3d6 --- /dev/null +++ b/addons/ui_units/functions/fnc_altInfo.sqf @@ -0,0 +1,7 @@ +#include "script_component.hpp" + +params ["_unit"]; + +if (_unit isEqualTo ALT_F) exitWith {["f", METERS_TO_FEET]}; + +["m", 1] diff --git a/addons/ui_units/functions/fnc_altUnits.sqf b/addons/ui_units/functions/fnc_altUnits.sqf new file mode 100644 index 00000000000..710b2b86572 --- /dev/null +++ b/addons/ui_units/functions/fnc_altUnits.sqf @@ -0,0 +1,9 @@ +#include "script_component.hpp" + +params ["_vehicle"]; + +if (_vehicle isKindOf "Helicopter") exitWith { + [GVAR(heliAlt), QGVAR(heliAlt)] +}; + +[GVAR(planeAlt), QGVAR(planeAlt)] diff --git a/addons/ui_units/functions/fnc_onAltLoad.sqf b/addons/ui_units/functions/fnc_onAltLoad.sqf new file mode 100644 index 00000000000..5b691d7c538 --- /dev/null +++ b/addons/ui_units/functions/fnc_onAltLoad.sqf @@ -0,0 +1,40 @@ +#include "script_component.hpp" + +params ["_ctrl"]; + +private _alt = (ctrlParent _ctrl) ctrlCreate [QGVAR(alt), -1]; + +private _units = cameraOn call FUNC(altUnits); +_units call FUNC(altInfo) params ["_unitText", "_ratio"]; + +((ctrlParent _alt) displayCtrl 1005) ctrlSetText _unitText; +GVAR(altRatio) = _ratio; + +private _settingEH = ["CBA_SettingChanged", { + params ["_setting", "_value"]; + _thisArgs params ["_settingName", "_alt"]; + if (_setting isEqualTo _settingName) then { + [_value] call FUNC(altInfo) params ["_unitText", "_ratio"]; + ((ctrlParent _alt) displayCtrl 1005) ctrlSetText _unitText; + GVAR(altRatio) = _ratio; + }; +}, [_units select 1, _alt]] call CBA_fnc_addEventHandlerArgs; + +[{ + (_this select 0) params ["_ctrl", "_alt", "_settingEH"]; + if (isNull _ctrl) exitWith { + [_this select 1] call CBA_fnc_removePerFrameHandler; + ["CBA_SettingChanged", _settingEH] call CBA_fnc_removeEventHandler; + }; + _ctrl ctrlSetFade 1; + _ctrl ctrlCommit 0; + private _vehicle = cameraOn; + private _rawAlt = ((getPosATL _vehicle) select 2) + (0 min (getTerrainHeightASL getPos _vehicle)); + private _altValue = _rawAlt / GVAR(altRatio); + if (_altValue < 10) then { + _altValue = _altValue toFixed 1; + } else { + _altValue = _altValue toFixed 0; + }; + _alt ctrlSetText _altValue; +}, 0, [_ctrl, _alt, _settingEH]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/ui_units/functions/fnc_onSpeedLoad.sqf b/addons/ui_units/functions/fnc_onSpeedLoad.sqf new file mode 100644 index 00000000000..f70592e8c03 --- /dev/null +++ b/addons/ui_units/functions/fnc_onSpeedLoad.sqf @@ -0,0 +1,32 @@ +#include "script_component.hpp" + +params ["_ctrl"]; + +private _speed = (ctrlParent _ctrl) ctrlCreate [QGVAR(speed), -1]; + +private _units = cameraOn call FUNC(speedUnits); +_units call FUNC(speedInfo) params ["_unitText", "_ratio"]; + +((ctrlParent _speed) displayCtrl 1004) ctrlSetText _unitText; +GVAR(speedRatio) = _ratio; + +private _settingEH = ["CBA_SettingChanged", { + params ["_setting", "_value"]; + _thisArgs params ["_settingName", "_speed"]; + if (_setting isEqualTo _settingName) then { + [_value] call FUNC(speedInfo) params ["_unitText", "_ratio"]; + ((ctrlParent _speed) displayCtrl 1004) ctrlSetText _unitText; + GVAR(speedRatio) = _ratio; + }; +}, [_units select 1, _speed]] call CBA_fnc_addEventHandlerArgs; + +[{ + (_this select 0) params ["_ctrl", "_speed", "_settingEH"]; + if (isNull _ctrl) exitWith { + [_this select 1] call CBA_fnc_removePerFrameHandler; + ["CBA_SettingChanged", _settingEH] call CBA_fnc_removeEventHandler; + }; + _ctrl ctrlSetFade 1; + _ctrl ctrlCommit 0; + _speed ctrlSetText ((abs (speed cameraOn / GVAR(speedRatio))) toFixed 0); +}, 0, [_ctrl, _speed, _settingEH]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/ui_units/functions/fnc_speedInfo.sqf b/addons/ui_units/functions/fnc_speedInfo.sqf new file mode 100644 index 00000000000..91744043f32 --- /dev/null +++ b/addons/ui_units/functions/fnc_speedInfo.sqf @@ -0,0 +1,9 @@ +#include "script_component.hpp" + +params ["_unit"]; + +if (_unit isEqualTo SPEED_MPH) exitWith {[LLSTRING(Speed_MPH), KMH_TO_MPH]}; +if (_unit isEqualTo SPEED_KNOT) exitWith {[LLSTRING(Speed_KNOT), KMH_TO_KNOT]}; +if (_unit isEqualTo SPEED_MS) exitWith {[LLSTRING(Speed_MS), KMH_TO_MS]}; + +[LLSTRING(Speed_KMH), 1] diff --git a/addons/ui_units/functions/fnc_speedUnits.sqf b/addons/ui_units/functions/fnc_speedUnits.sqf new file mode 100644 index 00000000000..cc063e47512 --- /dev/null +++ b/addons/ui_units/functions/fnc_speedUnits.sqf @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +params ["_vehicle"]; + +if (_vehicle isKindOf "Helicopter") exitWith { + [GVAR(heliSpeed), QGVAR(heliSpeed)] +}; + +if (_vehicle isKindOf "Plane") exitWith { + [GVAR(planeSpeed), QGVAR(planeSpeed)] +}; + +if (_vehicle isKindOf "Ship") exitWith { + [GVAR(seaSpeed), QGVAR(seaSpeed)] +}; + +[GVAR(landSpeed), QGVAR(landSpeed)] diff --git a/addons/ui_units/functions/script_component.hpp b/addons/ui_units/functions/script_component.hpp new file mode 100644 index 00000000000..b9c73dea0fe --- /dev/null +++ b/addons/ui_units/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\ui_units\script_component.hpp" diff --git a/addons/ui_units/initSettings.sqf b/addons/ui_units/initSettings.sqf new file mode 100644 index 00000000000..1649e183e7f --- /dev/null +++ b/addons/ui_units/initSettings.sqf @@ -0,0 +1,47 @@ +[ + QGVAR(landSpeed), + "LIST", + [localize LSTRING(Speed_DisplayName), localize LSTRING(Speed_Description)], + [format["ACE %1", localize LSTRING(Module_DisplayName)], localize LSTRING(Land_DisplayName)], + [[SPEED_KMH, SPEED_MPH, SPEED_KNOT, SPEED_MS], [LSTRING(Speed_KMH), LSTRING(Speed_MPH), LSTRING(Speed_KNOT), LSTRING(Speed_MS)], 0] +] call CBA_settings_fnc_init; + +[ + QGVAR(seaSpeed), + "LIST", + [localize LSTRING(Speed_DisplayName), localize LSTRING(Speed_Description)], + [format["ACE %1", localize LSTRING(Module_DisplayName)], localize "str_a3_rscdisplaygarage_tab_naval"], + [[SPEED_KMH, SPEED_MPH, SPEED_KNOT, SPEED_MS], [LSTRING(Speed_KMH), LSTRING(Speed_MPH), LSTRING(Speed_KNOT), LSTRING(Speed_MS)], 0] +] call CBA_settings_fnc_init; + +[ + QGVAR(heliSpeed), + "LIST", + [localize LSTRING(Speed_DisplayName), localize LSTRING(Speed_Description)], + [format["ACE %1", localize LSTRING(Module_DisplayName)], localize "STR_A3_TIME_TRIALS_HELI_NAME"], + [[SPEED_KMH, SPEED_MPH, SPEED_KNOT, SPEED_MS], [LSTRING(Speed_KMH), LSTRING(Speed_MPH), LSTRING(Speed_KNOT), LSTRING(Speed_MS)], 0] +] call CBA_settings_fnc_init; + +[ + QGVAR(heliAlt), + "LIST", + [localize LSTRING(Alt_DisplayName), localize LSTRING(Alt_Description)], + [format["ACE %1", localize LSTRING(Module_DisplayName)], localize "STR_A3_TIME_TRIALS_HELI_NAME"], + [[ALT_M, ALT_F], [LSTRING(Alt_M), LSTRING(Alt_F)], 0] +] call CBA_settings_fnc_init; + +[ + QGVAR(planeSpeed), + "LIST", + [localize LSTRING(Speed_DisplayName), localize LSTRING(Speed_Description)], + [format["ACE %1", localize LSTRING(Module_DisplayName)], localize "STR_A3_Showcase_FixedWings_Mission_Name"], + [[SPEED_KMH, SPEED_MPH, SPEED_KNOT, SPEED_MS], [LSTRING(Speed_KMH), LSTRING(Speed_MPH), LSTRING(Speed_KNOT), LSTRING(Speed_MS)], 0] +] call CBA_settings_fnc_init; + +[ + QGVAR(planeAlt), + "LIST", + [localize LSTRING(Alt_DisplayName), localize LSTRING(Alt_Description)], + [format["ACE %1", localize LSTRING(Module_DisplayName)], localize "STR_A3_Showcase_FixedWings_Mission_Name"], + [[ALT_M, ALT_F], [LSTRING(Alt_M), LSTRING(Alt_F)], 0] +] call CBA_settings_fnc_init; diff --git a/addons/ui_units/script_component.hpp b/addons/ui_units/script_component.hpp new file mode 100644 index 00000000000..ae1f4abf06a --- /dev/null +++ b/addons/ui_units/script_component.hpp @@ -0,0 +1,31 @@ +#define COMPONENT ui_units +#include "\z\ace\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_UI_UNITS + #define DEBUG_MODE_FULL +#endif + #ifdef DEBUG_SETTINGS_UI_UNITS + #define DEBUG_SETTINGS DEBUG_SETTINGS_UI_UNITS +#endif + +#define SPEED_KMH 0 +#define SPEED_MPH 1 +#define SPEED_KNOT 2 +#define SPEED_MS 3 + +#define KMH_TO_MPH 1.609 +#define KMH_TO_KNOT 1.852 +#define KMH_TO_MS 3.6 + +#define ALT_M 0 +#define ALT_F 1 + +#define METERS_TO_FEET 0.3047999902464003 + +#define MODE_ATL 0 +#define MODE_ASL 1 + +#include "\z\ace\addons\main\script_macros.hpp" diff --git a/addons/ui_units/stringtable.xml b/addons/ui_units/stringtable.xml new file mode 100644 index 00000000000..0c429a4be14 --- /dev/null +++ b/addons/ui_units/stringtable.xml @@ -0,0 +1,53 @@ + + + + + Units + Maßeinheiten + + + Speed + Geschwindigkeit + + + Units used to display Speed. + Maßeinheit, um Geschwindigkeit darzustellen. + + + Altitude + Flughöhe + + + Units used to display Altitude. + Maßeinheit, um Flughöhe darzustellen. + + + Land Vehicles + Bodenfahrzeuge + + + km/h + km/h + + + mph + mph + + + kn + kn + + + m/s + m/s + + + Meters + Meter + + + Feet + Fuß + + +