diff --git a/addons/kestrel4500/CfgEventHandlers.hpp b/addons/kestrel4500/CfgEventHandlers.hpp new file mode 100644 index 0000000000..2a05b72298 --- /dev/null +++ b/addons/kestrel4500/CfgEventHandlers.hpp @@ -0,0 +1,11 @@ +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) ); + }; +}; \ No newline at end of file diff --git a/addons/kestrel4500/CfgSound.hpp b/addons/kestrel4500/CfgSound.hpp new file mode 100644 index 0000000000..d63d2a6c1e --- /dev/null +++ b/addons/kestrel4500/CfgSound.hpp @@ -0,0 +1,39 @@ +class CfgSounds +{ + class kestrel4500_center_button_click + { + name="kestrel4500_center_button_click"; + sound[]={PATHTOF(sound\kestrel_center_button_click.wav),1,1}; + titles[]={}; + }; + class kestrel4500_top_button_click + { + name="kestrel4500_top_button_click"; + sound[]={PATHTOF(sound\kestrel_top_button_click.wav),1,1}; + titles[]={}; + }; + class kestrel4500_right_button_click + { + name="kestrel4500_right_button_click"; + sound[]={PATHTOF(sound\kestrel_right_button_click.wav),1,1}; + titles[]={}; + }; + class kestrel4500_bottom_button_click + { + name="kestrel4500_bottom_button_click"; + sound[]={PATHTOF(sound\kestrel_bottom_button_click.wav),1,1}; + titles[]={}; + }; + class kestrel4500_left_button_click + { + name="kestrel4500_left_button_click"; + sound[]={PATHTOF(sound\kestrel_left_button_click.wav),1,1}; + titles[]={}; + }; + class kestrel4500_exit_button_click + { + name="kestrel4500_exit_button_click"; + sound[]={PATHTOF(sound\kestrel_exit_button_click.wav),1,1}; + titles[]={}; + }; +}; \ No newline at end of file diff --git a/addons/kestrel4500/CfgVehicles.hpp b/addons/kestrel4500/CfgVehicles.hpp new file mode 100644 index 0000000000..15642b2da6 --- /dev/null +++ b/addons/kestrel4500/CfgVehicles.hpp @@ -0,0 +1,38 @@ +class CfgVehicles { + class Man; + class CAManBase: Man { + class ACE_SelfActions { + class ACE_OpenKestrel4500 { + displayName = "$STR_ACE_Kestrel4500_OpenKestrelDialog"; + condition = QUOTE('ACE_Kestrel4500' in items _player && {!GVAR(Kestrel4500)}); + statement = QUOTE(call FUNC(createKestrelDialog)); + showDisabled = 0; + priority = 2; + icon = PATHTOF(data\4500NV1.paa); + hotkey = "K"; + }; + }; + }; + + class Item_Base_F; + class ACE_Item_Kestrel4500: Item_Base_F { + author = "Ruthberg"; + scope = 2; + scopeCurator = 2; + displayName = "Kestrel 4500"; + vehicleClass = "Items"; + class TransportItems { + class ACE_Kestrel4500 { + name = "ACE_Kestrel4500"; + count = 1; + }; + }; + }; + + class Box_NATO_Support_F; + class ACE_Box_Misc: Box_NATO_Support_F { + class TransportItems { + MACRO_ADDITEM(ACE_Kestrel4500,6); + }; + }; +}; diff --git a/addons/kestrel4500/CfgWeapons.hpp b/addons/kestrel4500/CfgWeapons.hpp new file mode 100644 index 0000000000..8b0ff401f0 --- /dev/null +++ b/addons/kestrel4500/CfgWeapons.hpp @@ -0,0 +1,19 @@ + +class CfgWeapons { + class ACE_ItemCore; + class InventoryItem_Base_F; + + class ACE_Kestrel4500: ACE_ItemCore { + author[] = {$STR_ACE_Common_ACETeam, "Ruthberg"}; + scope = 2; + displayName = "$STR_ACE_Kestrel_Name"; + descriptionShort = "$STR_ACE_Kestrel_Description"; + picture = PATHTOF(UI\Kestrel4500.paa); + icon = "iconObject_circle"; + mapSize = 0.034; + + class ItemInfo: InventoryItem_Base_F { + mass = 2; + }; + }; +}; diff --git a/addons/kestrel4500/README.md b/addons/kestrel4500/README.md new file mode 100644 index 0000000000..c2908a6f85 --- /dev/null +++ b/addons/kestrel4500/README.md @@ -0,0 +1,11 @@ +ace_winddeflection +=============== + +Wind deflection for projectiles/bullets. + +## Maintainers + +The people responsible for merging changes to this component or answering potential questions. + +- [Glowbal](https://github.com/Glowbal) +- [Ruthberg] (http://github.com/Ulteq) \ No newline at end of file diff --git a/addons/kestrel4500/RscTitles.hpp b/addons/kestrel4500/RscTitles.hpp new file mode 100644 index 0000000000..b9a65cb1e4 --- /dev/null +++ b/addons/kestrel4500/RscTitles.hpp @@ -0,0 +1,310 @@ +#define ST_LEFT 0 +#define ST_RIGHT 1 +#define ST_CENTER 2 + +class Kestrel4500_RscText +{ + idc=-1; + type=0; + style=ST_CENTER; + colorDisabled[]={0,0,0,0}; + colorBackground[]={0,0,0,0}; + colorText[]={0,0,0,1}; + text=""; + x=0; + y=0; + w=0.1; + h=0.03; + font="TahomaB"; + sizeEx=0.04; + shadow=0; +}; +class Kestrel4500_RscButton +{ + text=""; + colorText[]={0,0,0,1}; + colorDisabled[]={0,0,0,0}; + colorBackground[]={0,0,0,0}; + colorBackgroundDisabled[]={0,0,0,0}; + colorBackgroundActive[]={0,0,0,0}; + colorFocused[]={0,0,0,0}; + colorShadow[]={0,0,0,0}; + colorBorder[]={0,0,0,1}; + soundEnter[]={"",0,1}; + soundPush[]={"",0,1}; + soundClick[]={"",0,1}; + soundEscape[]={"",0,1}; + type=1; + style="0x02+0x100"; + x=0; + y=0; + w=0.10; + h=0.03; + font="TahomaB"; + SizeEx=0.025; + offsetX=0.003; + offsetY=0.003; + offsetPressedX=0.0020; + offsetPressedY=0.0020; + borderSize=0; + shadow=0; +}; +class Kestrel4500_Display +{ + name="Kestrel4500_Display"; + idd=-1; + onLoad="uiNamespace setVariable ['Kestrel4500_Display', (_this select 0)]"; + movingEnable=1; + controlsBackground[]={}; + objects[]={}; + class controls + { + class BACKGROUND + { + moving=1; + type=0; + font="TahomaB"; + SizeEX=0.025; + idc=-1; + style=48; + x=safezoneX; + y=safezoneY; + w=1.024; + h=1.024*4/3; + colorBackground[]={1,1,1,1}; + colorText[]={1,1,1,1}; + text=PATHTOF(UI\kestrel4500.paa); + }; + class POWER: Kestrel4500_RscButton + { + idc=-1; + x=safezoneX+0.385; + y=safezoneY+1.125; + w=0.042; + h=0.042*4/3; + action="closeDialog 0"; + onMouseButtonDown = "playSound 'kestrel4500_exit_button_click'"; + }; + class ENTER: POWER + { + idc=-1; + x=safezoneX+0.46; + y=safezoneY+1.0; + w=0.1; + action=QUOTE(0 call FUNC(buttonPressed)); + onMouseButtonDown = "playSound 'kestrel4500_center_button_click'"; + }; + class TOP: Kestrel4500_RscButton + { + idc=-1; + x=safezoneX+0.46; + y=safezoneY+0.93; + w=0.1; + h=0.03; + action=QUOTE(1 call FUNC(buttonPressed)); + onMouseButtonDown = "playSound 'kestrel4500_top_button_click'"; + }; + class BOTTOM: TOP + { + idc=-1; + y=safezoneY+1.1; + action=QUOTE(2 call FUNC(buttonPressed)); + onMouseButtonDown = "playSound 'kestrel4500_bottom_button_click'"; + }; + class LEFT: Kestrel4500_RscButton + { + idc=-1; + x=safezoneX+0.4; + y=safezoneY+0.97; + w=0.046; + h=0.11; + action=QUOTE(3 call FUNC(buttonPressed)); + onMouseButtonDown = "playSound 'kestrel4500_left_button_click'"; + }; + class RIGHT: LEFT + { + idc=-1; + x=safezoneX+0.58; + action=QUOTE(4 call FUNC(buttonPressed)); + onMouseButtonDown = "playSound 'kestrel4500_right_button_click'"; + }; + class MEMORY: Kestrel4500_RscButton + { + idc=-1; + x=safezoneX+0.395; + y=safezoneY+0.87; + w=0.05; + h=0.045*4/3; + action=QUOTE(5 call FUNC(buttonPressed)); + }; + class BACKLIGHT: MEMORY + { + idc=-1; + x=safezoneX+0.585; + action=QUOTE(6 call FUNC(buttonPressed)); + }; + + class TEXT_TOP: Kestrel4500_RscText + { + idc=74100; + x=safezoneX+0.40; + y=safezoneY+0.58; + w=0.22; + h=0.04; + text=""; + }; + class TEXT_CENTER_BIG: TEXT_TOP + { + idc=74200; + y=safezoneY+0.61; + h=0.10; + SizeEx=0.06; + text=""; + }; + class TEXT_CENTER_LINE_1_LEFT: TEXT_TOP + { + idc=74300; + y=safezoneY+0.60; + style=ST_LEFT; + h=0.10; + SizeEx=0.05; + text=""; + }; + class TEXT_CENTER_LINE2_LEFT: TEXT_CENTER_LINE_1_LEFT + { + idc=74301; + y=safezoneY+0.64; + text=""; + }; + class TEXT_CENTER_LINE_3_LEFT: TEXT_CENTER_LINE2_LEFT + { + idc=74302; + y=safezoneY+0.68; + text=""; + }; + class TEXT_CENTER_LINE_1_RIGHT: TEXT_CENTER_LINE_1_LEFT + { + idc=74303; + style=ST_RIGHT; + }; + class TEXT_CENTER_LINE2_RIGHT: TEXT_CENTER_LINE2_LEFT + { + idc=74304; + style=ST_RIGHT; + }; + class TEXT_CENTER_LINE_3_RIGHT: TEXT_CENTER_LINE_3_LEFT + { + idc=74305; + style=ST_RIGHT; + }; + class TEXT_INFO_LINE_1: TEXT_TOP + { + idc=74400; + y=safezoneY+0.69; + text=""; + }; + class TEXT_INFO_LINE_2: TEXT_TOP + { + idc=74401; + y=safezoneY+0.72; + text=""; + }; + }; +}; +class RscTitles +{ + class RscKestrel4500 + { + idd=-1; + onLoad="with uiNameSpace do { RscKestrel4500 = _this select 0 };"; + movingEnable=0; + duration=60; + fadeIn="false"; + fadeOut="false"; + class controls + { + class RscKestrel4500 + { + idc=75000; + moving=0; + type=0; + font="TahomaB"; + SizeEX=0.025*0.75; + style=48; + x=safezoneX-0.05; + y=safezoneY+0.7; + w=1.024*0.75; + h=1.024*4/3*0.75; + colorBackground[]={1,1,1,1}; + colorText[]={1,1,1,1}; + text=PATHTOF(UI\kestrel4500.paa); + }; + class RscTextTop: Kestrel4500_RscText + { + idc=75100; + x=safezoneX-0.05+0.40*0.75; + y=safezoneY+0.7+0.58*0.75; + w=0.22*0.75; + h=0.04*0.75; + SizeEx=0.04*0.75; + text=""; + }; + class RscTextCenterBig: RscTextTop + { + idc=75200; + y=safezoneY+0.7+0.61*0.75; + h=0.10*0.75; + SizeEx=0.06*0.75; + text=""; + }; + class RscTextCenterLine1Left: RscTextTop + { + idc=75300; + y=safezoneY+0.7+0.60*0.75; + style=ST_LEFT; + h=0.10*0.75; + SizeEx=0.05*0.75; + text=""; + }; + class RscTextCenterLine2Left: RscTextCenterLine1Left + { + idc=75301; + y=safezoneY+0.7+0.64*0.75; + text=""; + }; + class RscTextCenterLine3Left: RscTextCenterLine2Left + { + idc=75302; + y=safezoneY+0.7+0.68*0.75; + text=""; + }; + class RscTextCenterLine1Right: RscTextCenterLine1Left + { + idc=75303; + style=ST_RIGHT; + }; + class RscTextCenterLine2Right: RscTextCenterLine2Left + { + idc=75304; + style=ST_RIGHT; + }; + class RscTextCenterLine3Right: RscTextCenterLine3Left + { + idc=75305; + style=ST_RIGHT; + }; + class RscTextInfoLine1: RscTextTop + { + idc=75400; + y=safezoneY+0.7+0.69*0.75; + text=""; + }; + class RscTextInfoLine2: RscTextTop + { + idc=75401; + y=safezoneY+0.7+0.72*0.75; + text=""; + }; + }; + }; +}; \ No newline at end of file diff --git a/addons/kestrel4500/UI/Kestrel4500.paa b/addons/kestrel4500/UI/Kestrel4500.paa new file mode 100644 index 0000000000..4fafe55cb2 Binary files /dev/null and b/addons/kestrel4500/UI/Kestrel4500.paa differ diff --git a/addons/kestrel4500/UI/Kestrel4500_Icon.paa b/addons/kestrel4500/UI/Kestrel4500_Icon.paa new file mode 100644 index 0000000000..062282115a Binary files /dev/null and b/addons/kestrel4500/UI/Kestrel4500_Icon.paa differ diff --git a/addons/kestrel4500/XEH_postInit.sqf b/addons/kestrel4500/XEH_postInit.sqf new file mode 100644 index 0000000000..a80521a572 --- /dev/null +++ b/addons/kestrel4500/XEH_postInit.sqf @@ -0,0 +1,21 @@ +#include "script_component.hpp" + +#include "initKeybinds.sqf" + +GVAR(Kestrel4500_Menus) = ["Direction", "Wind SPD m/s", "CROSSWIND m/s", "HEADWIND m/s", "TEMP °C", "HUMIDITY %", "BARO hPA", "ALTITUDE m", "User Screen 1", "User Screen 2"]; + +GVAR(Kestrel4500_TOTAL) = [0, 0, 0, 0, 0, 0, 0, 0]; +GVAR(Kestrel4500_ENTRIES) = [0, 0, 0, 0, 0, 0, 0, 0]; + +GVAR(Kestrel4500_MinAvgMax) = false; +GVAR(Kestrel4500_MinAvgMaxMode) = 0; + +GVAR(Kestrel4500_Menu) = 1; +GVAR(Kestrel4500_Directions) = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"]; +GVAR(Kestrel4500_Direction) = 0; + +GVAR(Kestrel4500_RefHeading) = 0; + +GVAR(Kestrel4500) = false; +GVAR(Kestrel4500_Overlay) = false; +GVAR(Kestrel4500_OverlayStart) = diag_tickTime; diff --git a/addons/kestrel4500/XEH_preInit.sqf b/addons/kestrel4500/XEH_preInit.sqf new file mode 100644 index 0000000000..16365e9020 --- /dev/null +++ b/addons/kestrel4500/XEH_preInit.sqf @@ -0,0 +1,12 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(buttonPressed); +PREP(collectData); +PREP(createKestrelDialog); +PREP(displayKestrel); +PREP(generateOutputData); +PREP(updateDisplay); + +ADDON = true; diff --git a/addons/kestrel4500/config.cpp b/addons/kestrel4500/config.cpp new file mode 100644 index 0000000000..8e558af44f --- /dev/null +++ b/addons/kestrel4500/config.cpp @@ -0,0 +1,18 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {"ACE_Item_Kestrel4500"}; + weapons[] = {"ACE_Kestrel4500"}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ACE_common", "ACE_weather"}; + author[] = {$STR_ACE_Common_ACETeam, "Ruthberg"}; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgSound.hpp" +#include "CfgVehicles.hpp" +#include "CfgWeapons.hpp" +#include "RscTitles.hpp" \ No newline at end of file diff --git a/addons/kestrel4500/functions/defines.h b/addons/kestrel4500/functions/defines.h new file mode 100644 index 0000000000..bd59c23bd4 --- /dev/null +++ b/addons/kestrel4500/functions/defines.h @@ -0,0 +1 @@ +#define GET_TEMPERATURE_AT_HEIGHT(h) (EGVAR(weather,currentTemperature) - 0.0065 * (h)) \ No newline at end of file diff --git a/addons/kestrel4500/functions/fnc_buttonPressed.sqf b/addons/kestrel4500/functions/fnc_buttonPressed.sqf new file mode 100644 index 0000000000..776c836abb --- /dev/null +++ b/addons/kestrel4500/functions/fnc_buttonPressed.sqf @@ -0,0 +1,38 @@ +#include "script_component.hpp" + +switch (_this) do { + case 0: { // Enter + if (!GVAR(Kestrel4500_MinAvgMAx) && (GVAR(Kestrel4500_Menu) == 2 || GVAR(Kestrel4500_Menu) == 3)) then { + Kestrel4500_RefHeading = getDir ACE_player; + }; + if (GVAR(Kestrel4500_MinAvgMAx) && GVAR(Kestrel4500_Menu) > 0 && GVAR(Kestrel4500_Menu) < 4) then { + if (GVAR(Kestrel4500_MinAvgMAxMode) != 1) then { + { + GVAR(Kestrel4500_MIN) set [_x, 0]; + GVAR(Kestrel4500_MAX) set [_x, 0]; + GVAR(Kestrel4500_TOTAL) set [_x, 0]; + GVAR(Kestrel4500_ENTRIES) set [_x, 0]; + } forEach [1, 2, 3]; + }; + GVAR(Kestrel4500_MinAvgMaxMode = (GVAR(Kestrel4500_MinAvgMaxMode + 1) % 3; + }; + }; + case 1: { // Top + GVAR(Kestrel4500_Menu) = (GVAR(Kestrel4500_Menu) - 1 + (count GVAR(Kestrel4500_Menu)s)) % (count GVAR(Kestrel4500_Menu)s); + }; + case 2: { // Bottom + GVAR(Kestrel4500_Menu) = (GVAR(Kestrel4500_Menu) + 1 + (count GVAR(Kestrel4500_Menu)s)) % (count GVAR(Kestrel4500_Menu)s); + }; + case 3: { // Left + GVAR(Kestrel4500_MinAvgMaxMode) = !GVAR(Kestrel4500_MinAvgMaxMode); + }; + case 4: { // Right + GVAR(Kestrel4500_MinAvgMaxMode) = !GVAR(Kestrel4500_MinAvgMaxMode); + }; + case 5: { // Memory + }; + case 6: { // Backlight + }; +}; + +[] call FUNC(updateDisplay); diff --git a/addons/kestrel4500/functions/fnc_collectData.sqf b/addons/kestrel4500/functions/fnc_collectData.sqf new file mode 100644 index 0000000000..cc0debb6c9 --- /dev/null +++ b/addons/kestrel4500/functions/fnc_collectData.sqf @@ -0,0 +1,80 @@ +#include "script_component.hpp" +#include "defines.h" + +private ["_playerDir", "_windSpeed", "_windDir", "_crosswind", "_headwind", "_humidity", "_temperature", "_humidity", "_barometricPressure", "_altitude"]; + +if (isNil QUOTE(EGVAR(advanced_ballistics,Altitude))) then {EGVAR(advanced_ballistics,Altitude) = 0}; + +if (isNil QUOTE(GVAR(Kestrel4500_MIN)) || isNil QUOTE(GVAR(Kestrel4500_MAX))) then { + _temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2); + _humidity = EGVAR(weather,currentHumidity); + _barometricPressure = 1013.25 * exp(-(EGVAR(advanced_ballistics,Altitude) + ((getPosASL ACE_player) select 2)) / 7990) - 10 * overcast; + _altitude = EGVAR(advanced_ballistics,Altitude) + ((getPosASL ACE_player) select 2); + GVAR(Kestrel4500_MIN) = [0, 0, 0, 0, _temperature, _humidity, _barometricPressure, _altitude]; + GVAR(Kestrel4500_MAX) = [0, 0, 0, 0, _temperature, _humidity, _barometricPressure, _altitude]; +}; + +{ + GVAR(Kestrel4500_ENTRIES) set [_x, (GVAR(Kestrel4500_ENTRIES) select _x) + 1]; +} forEach [0, 4, 5, 6 ,7]; + +// Direction +_playerDir = getDir ACE_player; +GVAR(Kestrel4500_MIN) set [0, (GVAR(Kestrel4500_MIN) select 0) min _playerDir]; +GVAR(Kestrel4500_MAX) set [0, _playerDir max (GVAR(Kestrel4500_MAX) select 0)]; +GVAR(Kestrel4500_TOTAL) set [0, (GVAR(Kestrel4500_TOTAL) select 0) + _playerDir]; + +if (GVAR(Kestrel4500_MinAvgMaxMode) == 1) then { + { + GVAR(Kestrel4500_ENTRIES) set [_x, (GVAR(Kestrel4500_ENTRIES) select _x) + 1]; + } forEach [1, 2, 3]; + + // Wind SPD + _windSpeed = vectorMagnitude ACE_wind; + _windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); + + if (isClass (configFile >> "CfgPatches" >> "ACE_Advanced_Ballistics")) then { + _windSpeed = (eyePos ACE_player) call EFUNC(advanced_ballistics,calculateWindSpeed); + }; + + _windSpeed = cos(_playerDir - _windDir) * _windSpeed; + GVAR(Kestrel4500_MIN) set [1, (GVAR(Kestrel4500_MIN) select 1) min abs(_windSpeed)]; + GVAR(Kestrel4500_MAX) set [1, abs(_windSpeed) max (GVAR(Kestrel4500_MAX) select 1)]; + GVAR(Kestrel4500_TOTAL) set [1, (GVAR(Kestrel4500_TOTAL) select 1) + abs(_windSpeed)]; + + // CROSSWIND + _crosswind = abs(sin(Kestrel4500_RefHeading - _playerDir) * _windSpeed); + GVAR(Kestrel4500_MIN) set [2, (GVAR(Kestrel4500_MIN) select 2) min _crosswind]; + GVAR(Kestrel4500_MAX) set [2, _crosswind max (GVAR(Kestrel4500_MAX) select 2)]; + GVAR(Kestrel4500_TOTAL) set [2, (GVAR(Kestrel4500_TOTAL) select 2) + _crosswind]; + + // HEADWIND + _headwind = abs(cos(Kestrel4500_RefHeading - _playerDir) * _windSpeed); + GVAR(Kestrel4500_MIN) set [3, (GVAR(Kestrel4500_MIN) select 3) min _headwind]; + GVAR(Kestrel4500_MAX) set [3, _headwind max (GVAR(Kestrel4500_MAX) select 3)]; + GVAR(Kestrel4500_TOTAL) set [3, (GVAR(Kestrel4500_TOTAL) select 3) + _headwind]; +}; + +// TEMP +_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2); +GVAR(Kestrel4500_MIN) set [4, (GVAR(Kestrel4500_MIN) select 4) min _temperature]; +GVAR(Kestrel4500_MAX) set [4, _temperature max (GVAR(Kestrel4500_MAX) select 4)]; +GVAR(Kestrel4500_TOTAL) set [4, (GVAR(Kestrel4500_TOTAL) select 4) + _temperature]; + +// HUMIDITY +_humidity = EGVAR(weather,currentHumidity); +GVAR(Kestrel4500_MIN) set [5, (GVAR(Kestrel4500_MIN) select 5) min _humidity]; +GVAR(Kestrel4500_MAX) set [5, _humidity max (GVAR(Kestrel4500_MAX) select 5)]; +GVAR(Kestrel4500_TOTAL) set [5, (GVAR(Kestrel4500_TOTAL) select 5) + _humidity]; + +// BARO +_barometricPressure = 1013.25 * exp(-(EGVAR(advanced_ballistics,Altitude) + ((getPosASL ACE_player) select 2)) / 7990) - 10 * overcast; +GVAR(Kestrel4500_MIN) set [6, (GVAR(Kestrel4500_MIN) select 6) min _barometricPressure]; +GVAR(Kestrel4500_MAX) set [6, _barometricPressure max (GVAR(Kestrel4500_MAX) select 6)]; +GVAR(Kestrel4500_TOTAL) set [6, (GVAR(Kestrel4500_TOTAL) select 6) + _barometricPressure]; + +// ALTITUDE +_altitude = EGVAR(advanced_ballistics,Altitude) + ((getPosASL ACE_player) select 2); +GVAR(Kestrel4500_MIN) set [7, (GVAR(Kestrel4500_MIN) select 7) min _altitude]; +GVAR(Kestrel4500_MAX) set [7, _altitude max (GVAR(Kestrel4500_MAX) select 7)]; +GVAR(Kestrel4500_TOTAL) set [7, (GVAR(Kestrel4500_TOTAL) select 7) + _altitude]; \ No newline at end of file diff --git a/addons/kestrel4500/functions/fnc_createKestrelDialog.sqf b/addons/kestrel4500/functions/fnc_createKestrelDialog.sqf new file mode 100644 index 0000000000..6439566b16 --- /dev/null +++ b/addons/kestrel4500/functions/fnc_createKestrelDialog.sqf @@ -0,0 +1,21 @@ +#include "script_component.hpp" + +if (dialog) exitWith { false }; +if (underwater ACE_player) exitWith { false }; +if (!("ACE_Kestrel4500" in (uniformItems ACE_player)) && !("ACE_Kestrel4500" in (vestItems ACE_player))) exitWith { false }; + +GVAR(Kestrel4500_Overlay) = false; +3 cutText ["", "PLAIN"]; + +GVAR(Kestrel4500) = true; +createDialog 'Kestrel4500_Display'; + +[{ + if (!dialog || !GVAR(Kestrel4500)) exitWith { + [_this select 1] call CBA_fnc_removePerFrameHandler; + }; + + [] call FUNC(updateDisplay); +}, 1, _this select 0] call CBA_fnc_addPerFrameHandler; + +true diff --git a/addons/kestrel4500/functions/fnc_displayKestrel.sqf b/addons/kestrel4500/functions/fnc_displayKestrel.sqf new file mode 100644 index 0000000000..cd9d7f02a4 --- /dev/null +++ b/addons/kestrel4500/functions/fnc_displayKestrel.sqf @@ -0,0 +1,63 @@ +#include "script_component.hpp" + +#define __dsp (uiNamespace getVariable "RscKestrel4500") +#define __ctrlKestrel4500 (__dsp displayCtrl 75000) +#define __ctrlTop (__dsp displayCtrl 75100) +#define __ctrlCenterBig (__dsp displayCtrl 75200) +#define __ctrlCenterLine1Left (__dsp displayCtrl 75300) +#define __ctrlCenterLine2Left (__dsp displayCtrl 75301) +#define __ctrlCenterLine3Left (__dsp displayCtrl 75302) +#define __ctrlCenterLine1Right (__dsp displayCtrl 75303) +#define __ctrlCenterLine2Right (__dsp displayCtrl 75304) +#define __ctrlCenterLine3Right (__dsp displayCtrl 75305) +#define __ctrlInfoLine1 (__dsp displayCtrl 75400) +#define __ctrlInfoLine2 (__dsp displayCtrl 75401) + +private ["_outputData"]; + +if (GVAR(Kestrel4500_Overlay)) exitWith { + GVAR(Kestrel4500_Overlay) = false; + 3 cutText ["", "PLAIN"]; + true +}; +if (underwater ACE_player) exitWith { true }; +if (!("ACE_Kestrel4500" in (uniformItems ACE_player)) && !("ACE_Kestrel4500" in (vestItems ACE_player))) exitWith { true }; + +if (GVAR(Kestrel4500) && dialog) then { + GVAR(Kestrel4500) = false; + closeDialog 0; +}; + +GVAR(Kestrel4500_Overlay) = true; + +[{ + // abort condition + if (!GVAR(Kestrel4500_Overlay) || {!(("ACE_Kestrel4500" in (uniformItems ACE_player)) || ("ACE_Kestrel4500" in (vestItems ACE_player)))}) exitWith { + GVAR(Kestrel4500_Overlay) = false; + 3 cutText ["", "PLAIN"]; + [_this select 1] call CBA_fnc_removePerFrameHandler; + }; + + _outputData = [] call FUNC(generateOutputData); + + 3 cutRsc ["RscKestrel4500", "PLAIN", 1, false]; + + __ctrlTop ctrlSetText (_outputData select 0); + __ctrlCenterBig ctrlSetText (_outputData select 1); + + __ctrlTop ctrlSetText (_outputData select 0); + __ctrlCenterBig ctrlSetText (_outputData select 1); + + __ctrlCenterLine1Left ctrlSetText (_outputData select 2); + __ctrlCenterLine2Left ctrlSetText (_outputData select 3); + __ctrlCenterLine3Left ctrlSetText (_outputData select 4); + + __ctrlCenterLine1Right ctrlSetText (_outputData select 5); + __ctrlCenterLine2Right ctrlSetText (_outputData select 6); + __ctrlCenterLine3Right ctrlSetText (_outputData select 7); + + __ctrlInfoLine1 ctrlSetText (_outputData select 8); + __ctrlInfoLine2 ctrlSetText (_outputData select 9); +}, 1, _this select 0] call CBA_fnc_addPerFrameHandler; + +true diff --git a/addons/kestrel4500/functions/fnc_generateOutputData.sqf b/addons/kestrel4500/functions/fnc_generateOutputData.sqf new file mode 100644 index 0000000000..451f1c5282 --- /dev/null +++ b/addons/kestrel4500/functions/fnc_generateOutputData.sqf @@ -0,0 +1,201 @@ +#include "script_component.hpp" +#include "defines.h" + +private ["_playerDir", "_textTop", "_textCenterBig", "_textCenterLine1Left", "_textCenterLine2Left", "_textCenterLine3Left", "_textCenterLine1Right", "_textCenterLine2Right", "_textCenterLine3Right", "_textInfoLine1", "_textInfoLine2", "_temperature", "_humidity", "_windSpeed", "_windDir", "_newWindSpeed", "_windSource", "_height"]; + +if (isNil QUOTE(EGVAR(advanced_ballistics,Altitude))) then {EGVAR(advanced_ballistics,Altitude) = 0}; + +[] call FUNC(collectData); + +_textTop = GVAR(Kestrel4500_Menus) select GVAR(Kestrel4500_Menu); +_textCenterBig = ""; + +_textCenterLine1Left = ""; +_textCenterLine2Left = ""; +_textCenterLine3Left = ""; +_textCenterLine1Right = ""; +_textCenterLine2Right = ""; +_textCenterLine3Right = ""; + +_textInfoLine1 = ""; +_textInfoLine2 = ""; + +_windSpeed = vectorMagnitude ACE_wind; +_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); + +_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2); +_humidity = EGVAR(weather,currentHumidity); + +if (isClass (configFile >> "CfgPatches" >> "ACE_Advanced_Ballistics")) then { + _windSpeed = (eyePos ACE_player) call EFUNC(advanced_ballistics,calculateWindSpeed); +}; + +_playerDir = getDir ACE_player; +_windSpeed = cos(_playerDir - _windDir) * _windSpeed; + +GVAR(Kestrel4500_Direction) = 4 * floor(_playerDir / 90); +if (_playerDir % 90 > 10) then { GVAR(Kestrel4500_Direction) = GVAR(Kestrel4500_Direction) + 1}; +if (_playerDir % 90 > 35) then { GVAR(Kestrel4500_Direction) = GVAR(Kestrel4500_Direction) + 1}; +if (_playerDir % 90 > 55) then { GVAR(Kestrel4500_Direction) = GVAR(Kestrel4500_Direction) + 1}; +if (_playerDir % 90 > 80) then { GVAR(Kestrel4500_Direction) = GVAR(Kestrel4500_Direction) + 1}; +GVAR(Kestrel4500_Direction) = GVAR(Kestrel4500_Direction) % 16; + +switch (GVAR(Kestrel4500_Menu)) do { + case 0: { // Direction + if (!GVAR(Kestrel4500_MinAvgMax)) then { + _textCenterBig = format["%1", format["%1 %2", GVAR(Kestrel4500_Direction)s select GVAR(Kestrel4500_Direction), round(_playerDir)]]; + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = "N/A"; + _textCenterLine2Right = "N/A"; + _textCenterLine3Right = "N/A"; + }; + }; + case 1: { // Wind SPD + if (!GVAR(Kestrel4500_MinAvgMax)) then { + _textCenterBig = Str(round(abs(_windSpeed) * 10) / 10); + } else { + _textCenterLine1Left = "Max"; + _textCenterLine2Left = "Avg"; + switch (GVAR(Kestrel4500_MinAvgMaxMode)) do { + case 0: { + _textCenterLine1Right = "--. -"; + _textCenterLine2Right = "--. -"; + _textInfoLine2 = "- average"; + }; + case 1: { + _textCenterLine1Right = Str(round((Kestrel4500_MAX select 1) * 10) / 10); + _textCenterLine2Right = Str(round((Kestrel4500_TOTAL select 1) / (Kestrel4500_ENTRIES select 1) * 10) / 10); + _textInfoLine2 = "- stop"; + }; + case 2: { + _textCenterLine1Right = Str(round((Kestrel4500_MAX select 1) * 10) / 10); + _textCenterLine2Right = Str(round((Kestrel4500_TOTAL select 1) / (Kestrel4500_ENTRIES select 1) * 10) / 10); + _textInfoLine2 = "- clear"; + }; + }; + }; + }; + case 2: { // CROSSWIND + if (!GVAR(Kestrel4500_MinAvgMax)) then { + _textCenterBig = Str(round(abs(sin(Kestrel4500_RefHeading - _playerDir) * _windSpeed) * 10) / 10); + _textInfoLine1 = format["%1 m/s @ %2", round((cos(_playerDir - _windDir) * _windSpeed) * 10) / 10, round(_playerDir)]; + _textInfoLine2 = "- set heading"; + } else { + _textCenterLine1Left = "Max"; + _textCenterLine2Left = "Avg"; + switch (GVAR(Kestrel4500_MinAvgMax)Mode) do { + case 0: { + _textCenterLine1Right = "--. -"; + _textCenterLine2Right = "--. -"; + _textInfoLine2 = "- average"; + }; + case 1: { + _textCenterLine1Right = Str(round((Kestrel4500_MAX select 2) * 10) / 10); + _textCenterLine2Right = Str(round((Kestrel4500_TOTAL select 2) / (Kestrel4500_ENTRIES select 2) * 10) / 10); + _textInfoLine2 = "- stop"; + }; + case 2: { + _textCenterLine1Right = Str(round((Kestrel4500_MAX select 2) * 10) / 10); + _textCenterLine2Right = Str(round((Kestrel4500_TOTAL select 2) / (Kestrel4500_ENTRIES select 2) * 10) / 10); + _textInfoLine2 = "- clear"; + }; + }; + }; + }; + case 3: { // HEADWIND + if (!GVAR(Kestrel4500_MinAvgMax)) then { + _textCenterBig = Str(round(abs(cos(Kestrel4500_RefHeading - _playerDir) * _windSpeed) * 10) / 10); + _textInfoLine1 = format["%1 m/s @ %2", round((cos(_playerDir - _windDir) * _windSpeed) * 10) / 10, round(_playerDir)]; + _textInfoLine2 = "- set heading"; + } else { + _textCenterLine1Left = "Max"; + _textCenterLine2Left = "Avg"; + switch (GVAR(Kestrel4500_MinAvgMax)Mode) do { + case 0: { + _textCenterLine1Right = "--. -"; + _textCenterLine2Right = "--. -"; + _textInfoLine2 = "- average"; + }; + case 1: { + _textCenterLine1Right = Str(round((Kestrel4500_MAX select 3) * 10) / 10); + _textCenterLine2Right = Str(round((Kestrel4500_TOTAL select 3) / (Kestrel4500_ENTRIES select 3) * 10) / 10); + _textInfoLine2 = "- stop"; + }; + case 2: { + _textCenterLine1Right = Str(round((Kestrel4500_MAX select 3) * 10) / 10); + _textCenterLine2Right = Str(round((Kestrel4500_TOTAL select 3) / (Kestrel4500_ENTRIES select 3) * 10) / 10); + _textInfoLine2 = "- clear"; + }; + }; + }; + }; + case 4: { // TEMP + if (!GVAR(Kestrel4500_MinAvgMax)) then { + _textCenterBig = Str(round(_temperature * 10) / 10); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round((Kestrel4500_MIN select 4) * 10) / 10); + _textCenterLine2Right = Str(round((Kestrel4500_TOTAL select 4) / (Kestrel4500_ENTRIES select 4) * 10) / 10); + _textCenterLine3Right = Str(round((Kestrel4500_MAX select 4) * 10) / 10); + }; + }; + case 5: { // HUMIDITY + if (!GVAR(Kestrel4500_MinAvgMax)) then { + _textCenterBig = Str(round(_humidity * 100 * 10) / 10); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round((Kestrel4500_MIN select 5) * 10) / 10); + _textCenterLine2Right = Str(round((Kestrel4500_TOTAL select 5) / (Kestrel4500_ENTRIES select 5) * 10) / 10); + _textCenterLine3Right = Str(round((Kestrel4500_MAX select 5) * 10) / 10); + }; + }; + case 6: { // BARO + if (!GVAR(Kestrel4500_MinAvgMax)) then { + _textCenterBig = Str(round((1013.25 * exp(-(EGVAR(advanced_ballistics,Altitude) + ((getPosASL ACE_player) select 2)) / 7990) - 10 * overcast) * 10) / 10); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round((Kestrel4500_MIN select 6) * 10) / 10); + _textCenterLine2Right = Str(round((Kestrel4500_TOTAL select 6) / (Kestrel4500_ENTRIES select 6) * 10) / 10); + _textCenterLine3Right = Str(round((Kestrel4500_MAX select 6) * 10) / 10); + }; + }; + case 7: { // ALTITUDE + if (!GVAR(Kestrel4500_MinAvgMax)) then { + _textCenterBig = Str(round(EGVAR(advanced_ballistics,Altitude) + ((getPosASL ACE_player) select 2))); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round(Kestrel4500_MIN select 7)); + _textCenterLine2Right = Str(round((Kestrel4500_TOTAL select 7) / (Kestrel4500_ENTRIES select 7))); + _textCenterLine3Right = Str(round(Kestrel4500_MAX select 7)); + }; + }; + case 8: { // User Screen 1 + _textCenterLine1Left = Str(round(_playerDir)); + _textCenterLine2Left = Str(round(EGVAR(advanced_ballistics,Altitude) + ((getPosASL ACE_player) select 2))); + _textCenterLine3Left = Str(round(abs(_windSpeed) * 10) / 10); + _textCenterLine1Right = GVAR(Kestrel4500_Direction)s select GVAR(Kestrel4500_Direction); + _textCenterLine2Right = "m"; + _textCenterLine3Right = "m/s"; + }; + case 9: { // User Screen 2 + _textCenterLine1Left = Str(round(_temperature * 10) / 10); + _textCenterLine2Left = Str(round(_humidity * 100 * 10) / 10); + _textCenterLine3Left = Str(round((1013.25 * exp(-(EGVAR(advanced_ballistics,Altitude) + ((getPosASL ACE_player) select 2)) / 7990) - 10 * overcast) * 10) / 10); + _textCenterLine1Right = "C"; + _textCenterLine2Right = "%"; + _textCenterLine3Right = "hPA"; + }; +}; + +[_textTop, _textCenterBig, _textCenterLine1Left, _textCenterLine2Left, _textCenterLine3Left, _textCenterLine1Right, _textCenterLine2Right, _textCenterLine3Right, _textInfoLine1, _textInfoLine2] diff --git a/addons/kestrel4500/functions/fnc_updateDisplay.sqf b/addons/kestrel4500/functions/fnc_updateDisplay.sqf new file mode 100644 index 0000000000..a28a7071d6 --- /dev/null +++ b/addons/kestrel4500/functions/fnc_updateDisplay.sqf @@ -0,0 +1,19 @@ +#include "script_component.hpp" + +private ["_outputData"]; + +_outputData = [] call FUNC(generateOutputData); + +ctrlSetText [74100, _outputData select 0]; +ctrlSetText [74200, _outputData select 1]; + +ctrlSetText [74300, _outputData select 2]; +ctrlSetText [74301, _outputData select 3]; +ctrlSetText [74302, _outputData select 4]; + +ctrlSetText [74303, _outputData select 5]; +ctrlSetText [74304, _outputData select 6]; +ctrlSetText [74305, _outputData select 7]; + +ctrlSetText [74400, _outputData select 8]; +ctrlSetText [74401, _outputData select 9]; diff --git a/addons/kestrel4500/functions/script_component.hpp b/addons/kestrel4500/functions/script_component.hpp new file mode 100644 index 0000000000..32c774cd89 --- /dev/null +++ b/addons/kestrel4500/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\kestrel4500\script_component.hpp" \ No newline at end of file diff --git a/addons/kestrel4500/initKeybinds.sqf b/addons/kestrel4500/initKeybinds.sqf new file mode 100644 index 0000000000..657e10d907 --- /dev/null +++ b/addons/kestrel4500/initKeybinds.sqf @@ -0,0 +1,23 @@ +["ACE3", QGVAR(KestrelDialogKey), localize "STR_ACE_Kestrel4500_KestrelDialogKey", +{ + // Conditions: canInteract + if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + + // Statement + [] call FUNC(createKestrelDialog); + false +}, +{false}, +[70, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // (SCROLL) + +["ACE3", QGVAR(DisplayKestrelKey), localize "STR_ACE_Kestrel4500_DisplayKestrelKey", +{ + // Conditions: canInteract + if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + + // Statement + [] call FUNC(displayKestrel); + false +}, +{false}, +[70, [true, false, false]], false, 0] call CBA_fnc_addKeybind; // (SHIFT + SCROLL) diff --git a/addons/kestrel4500/script_component.hpp b/addons/kestrel4500/script_component.hpp new file mode 100644 index 0000000000..aa09280ff6 --- /dev/null +++ b/addons/kestrel4500/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT kestrel4500 +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_KESTREL4500 + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_KESTREL4500 + #define DEBUG_SETTINGS DEBUG_SETTINGS_KESTREL4500 +#endif + +#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file diff --git a/addons/kestrel4500/sound/kestrel_bottom_button_click.wav b/addons/kestrel4500/sound/kestrel_bottom_button_click.wav new file mode 100644 index 0000000000..1f5a2ddeb1 Binary files /dev/null and b/addons/kestrel4500/sound/kestrel_bottom_button_click.wav differ diff --git a/addons/kestrel4500/sound/kestrel_center_button_click.wav b/addons/kestrel4500/sound/kestrel_center_button_click.wav new file mode 100644 index 0000000000..ce34a645c3 Binary files /dev/null and b/addons/kestrel4500/sound/kestrel_center_button_click.wav differ diff --git a/addons/kestrel4500/sound/kestrel_exit_button_click.wav b/addons/kestrel4500/sound/kestrel_exit_button_click.wav new file mode 100644 index 0000000000..1f5a2ddeb1 Binary files /dev/null and b/addons/kestrel4500/sound/kestrel_exit_button_click.wav differ diff --git a/addons/kestrel4500/sound/kestrel_left_button_click.wav b/addons/kestrel4500/sound/kestrel_left_button_click.wav new file mode 100644 index 0000000000..a880e76dc1 Binary files /dev/null and b/addons/kestrel4500/sound/kestrel_left_button_click.wav differ diff --git a/addons/kestrel4500/sound/kestrel_right_button_click.wav b/addons/kestrel4500/sound/kestrel_right_button_click.wav new file mode 100644 index 0000000000..14ff2e0689 Binary files /dev/null and b/addons/kestrel4500/sound/kestrel_right_button_click.wav differ diff --git a/addons/kestrel4500/sound/kestrel_top_button_click.wav b/addons/kestrel4500/sound/kestrel_top_button_click.wav new file mode 100644 index 0000000000..e4ef1df50d Binary files /dev/null and b/addons/kestrel4500/sound/kestrel_top_button_click.wav differ diff --git a/addons/kestrel4500/stringtable.xml b/addons/kestrel4500/stringtable.xml new file mode 100644 index 0000000000..65625fdf9b --- /dev/null +++ b/addons/kestrel4500/stringtable.xml @@ -0,0 +1,29 @@ + + + + + Kestrel 4500NV + Kestrel 4500NV + Kestrel 4500NV + Kestrel 4500NV + Kestrel 4500NV + Kestrel 4500NV + Kestrel 4500NV + Kestrel 4500NV + Kestrel 4500NV + Kestrel 4500NV + + + Kestrel 4500 Pocket Weather Tracker + + + Open Kestrel 4500 + + + Open Kestrel 4500 + + + Show Kestrel 4500 + + +