Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/ui_units/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z\ace\addons\ui_units
17 changes: 17 additions & 0 deletions addons/ui_units/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -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));
};
};
6 changes: 6 additions & 0 deletions addons/ui_units/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PREP(altInfo);
PREP(altUnits);
PREP(onAltLoad);
PREP(onSpeedLoad);
PREP(speedInfo);
PREP(speedUnits);
3 changes: 3 additions & 0 deletions addons/ui_units/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "script_component.hpp"

#include "XEH_PREP.hpp"
11 changes: 11 additions & 0 deletions addons/ui_units/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions addons/ui_units/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "script_component.hpp"
#include "XEH_PREP.hpp"
62 changes: 62 additions & 0 deletions addons/ui_units/config.cpp
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 7 additions & 0 deletions addons/ui_units/functions/fnc_altInfo.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "script_component.hpp"

params ["_unit"];

if (_unit isEqualTo ALT_F) exitWith {["f", METERS_TO_FEET]};

["m", 1]
9 changes: 9 additions & 0 deletions addons/ui_units/functions/fnc_altUnits.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "script_component.hpp"

params ["_vehicle"];

if (_vehicle isKindOf "Helicopter") exitWith {
[GVAR(heliAlt), QGVAR(heliAlt)]
};

[GVAR(planeAlt), QGVAR(planeAlt)]
40 changes: 40 additions & 0 deletions addons/ui_units/functions/fnc_onAltLoad.sqf
Original file line number Diff line number Diff line change
@@ -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;
32 changes: 32 additions & 0 deletions addons/ui_units/functions/fnc_onSpeedLoad.sqf
Original file line number Diff line number Diff line change
@@ -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;
9 changes: 9 additions & 0 deletions addons/ui_units/functions/fnc_speedInfo.sqf
Original file line number Diff line number Diff line change
@@ -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]
17 changes: 17 additions & 0 deletions addons/ui_units/functions/fnc_speedUnits.sqf
Original file line number Diff line number Diff line change
@@ -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)]
1 change: 1 addition & 0 deletions addons/ui_units/functions/script_component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "\z\ace\addons\ui_units\script_component.hpp"
47 changes: 47 additions & 0 deletions addons/ui_units/initSettings.sqf
Original file line number Diff line number Diff line change
@@ -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;
31 changes: 31 additions & 0 deletions addons/ui_units/script_component.hpp
Original file line number Diff line number Diff line change
@@ -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"
53 changes: 53 additions & 0 deletions addons/ui_units/stringtable.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="UI_Units">
<Key ID="STR_ACE_UI_Units_Module_DisplayName">
<English>Units</English>
<German>Maßeinheiten</German>
</Key>
<Key ID="STR_ACE_UI_Units_Speed_DisplayName">
<English>Speed</English>
<German>Geschwindigkeit</German>
</Key>
<Key ID="STR_ACE_UI_Units_Speed_Description">
<English>Units used to display Speed.</English>
<German>Maßeinheit, um Geschwindigkeit darzustellen.</German>
</Key>
<Key ID="STR_ACE_UI_Units_Alt_DisplayName">
<English>Altitude</English>
<German>Flughöhe</German>
</Key>
<Key ID="STR_ACE_UI_Units_Alt_Description">
<English>Units used to display Altitude.</English>
<German>Maßeinheit, um Flughöhe darzustellen.</German>
</Key>
<Key ID="STR_ACE_UI_Units_Land_DisplayName">
<English>Land Vehicles</English>
<German>Bodenfahrzeuge</German>
</Key>
<Key ID="STR_ACE_UI_Units_Speed_KMH">
<English>km/h</English>
<German>km/h</German>
</Key>
<Key ID="STR_ACE_UI_Units_Speed_MPH">
<English>mph</English>
<German>mph</German>
</Key>
<Key ID="STR_ACE_UI_Units_Speed_KNOT">
<English>kn</English>
<German>kn</German>
</Key>
<Key ID="STR_ACE_UI_Units_Speed_MS">
<English>m/s</English>
<German>m/s</German>
</Key>
<Key ID="STR_ACE_UI_Units_Alt_M">
<English>Meters</English>
<German>Meter</German>
</Key>
<Key ID="STR_ACE_UI_Units_Alt_F">
<English>Feet</English>
<German>Fuß</German>
</Key>
</Package>
</Project>