Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missile_hud - Move HUD feature from laser to new component #10306

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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: 0 additions & 1 deletion addons/laser/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ PREP(seekerFindLaserSpot);
PREP(setLaserCode);
PREP(shootCone);
PREP(shootRay);
PREP(showVehicleHud);
PREP(toggleLST);
17 changes: 0 additions & 17 deletions addons/laser/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,12 @@
if (hasInterface) then {
#include "initKeybinds.inc.sqf"

GVAR(pfID) = -1;

["CBA_settingsInitialized", {
// Handle Map Drawing
GVAR(mapLaserSource) = objNull;
["ACE_controlledUAV", LINKFUNC(addMapHandler)] call CBA_fnc_addEventHandler;
["turret", LINKFUNC(addMapHandler), false] call CBA_fnc_addPlayerEventHandler;
["unit", LINKFUNC(addMapHandler), true] call CBA_fnc_addPlayerEventHandler;

// Laser code display
["turret", LINKFUNC(showVehicleHud), false] call CBA_fnc_addPlayerEventHandler;
["vehicle", LINKFUNC(showVehicleHud), true] call CBA_fnc_addPlayerEventHandler; // only one of these needs the retro flag

// Add UAV Control Compatibility
["ACE_controlledUAV", {
params ["_UAV", "_seatAI", "_turret", "_position"];
TRACE_4("ACE_controlledUAV EH",_UAV,_seatAI,_turret,_position);
if (!isNull _seatAI) then {
[_seatAI] call FUNC(showVehicleHud);
} else {
[ace_player] call FUNC(showVehicleHud);
};
}] call CBA_fnc_addEventHandler;
}] call CBA_fnc_addEventHandler;
};

Expand Down
114 changes: 0 additions & 114 deletions addons/laser/functions/fnc_showVehicleHud.sqf

This file was deleted.

1 change: 1 addition & 0 deletions addons/missile_hud/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z\ace\addons\missile_hud
5 changes: 5 additions & 0 deletions addons/missile_hud/ACE_GuidanceConfig.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class EGVAR(missileguidance,SeekerTypes) {
class SALH {
hudInfo = QFUNC(info_salh);
};
};
17 changes: 17 additions & 0 deletions addons/missile_hud/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_SCRIPT(XEH_preStart));
};
};

class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_preInit));
};
};

class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_postInit));
};
};
4 changes: 4 additions & 0 deletions addons/missile_hud/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ace_missile_hud
===================

Displays information about missile to player through their in-game HUD
40 changes: 40 additions & 0 deletions addons/missile_hud/RscTitles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class RscTitles {
class GVAR(infoDisplay) {
idd = -1;
onLoad = QUOTE(with uiNameSpace do { GVAR(display) = _this select 0 };);
movingEnable = 0;
duration = 60;
fadeIn = "false";
fadeOut = "false";
class controls {};
class controlPrefabs {
class line: RscControlsGroupNoScrollbars {
idc = -1;
x = "3.8 * (((safeZoneW / safeZoneH) min 1.2) / 40) + (profilenamespace getvariable ['IGUI_GRID_WEAPON_X',((safeZoneX + safeZoneW) - (10 * (((safeZoneW / safeZoneH) min 1.2) / 40)) - 4.3 * (((safeZoneW / safeZoneH) min 1.2) / 40))])";
y = "2.5 * ((((safeZoneW / safeZoneH) min 1.2) / 1.2) / 25) + (profilenamespace getVariable ['IGUI_GRID_WEAPON_Y', (safeZoneY + 0.5 * ((((safeZoneW / safeZoneH) min 1.2) / 1.2) / 25))])";
w = "10 * (((safeZoneW / safeZoneH) min 1.2) / 40)";
h = "1 * ((((safeZoneW / safeZoneH) min 1.2) / 1.2) / 25)";
};
class text: RscText {
idc = -1;
colorText[] = {1, 1, 1, 1};
colorBackground[] = {0, 0, 0, 0};
x = "0";
y = "0";
w = "1 * ((((safeZoneW / safeZoneH) min 1.2) / 1.2) / 25)";
h = "1 * ((((safeZoneW / safeZoneH) min 1.2) / 1.2) / 25)";
sizeEx = "0.8 * ((((safeZoneW / safeZoneH) min 1.2) / 1.2) / 25)";
};
class icon: RscPictureKeepAspect {
idc = -1;
colorText[] = {1, 1, 1, 1};
colorBackground[] = {0, 0, 0, 0};
text = "\a3\Ui_F_Curator\Data\CfgCurator\laser_ca.paa";
x = "0";
y = "0";
w = "(1) * ((((safeZoneW / safeZoneH) min 1.2) / 1.2) / 25)";
h = "(1) * ((((safeZoneW / safeZoneH) min 1.2) / 1.2) / 25)";
};
};
};
};
8 changes: 8 additions & 0 deletions addons/missile_hud/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREP(createCtrlFromElement);
PREP(getCurrentWeapon);
PREP(info_salh);
PREP(isElementValid);
PREP(registerDefaultHud);
PREP(registerElement);
PREP(shouldAdjustHud);
PREP(showVehicleHud);
31 changes: 31 additions & 0 deletions addons/missile_hud/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "script_component.hpp"

if (hasInterface) then {
GVAR(pfID) = -1;
GVAR(generators) = [];

GVAR(config) = configFile >> "RscTitles" >> QGVAR(infoDisplay) >> "controlPrefabs";
GVAR(config_line) = GVAR(config) >> "line";
GVAR(lineHeight) = getNumber (GVAR(config_line) >> "h");
GVAR(lineWidth) = getNumber (GVAR(config_line) >> "w");
GVAR(itemWidth) = getNumber (GVAR(config) >> "icon" >> "w") / 1.25;

["CBA_settingsInitialized", {
["turret", LINKFUNC(showVehicleHud), false] call CBA_fnc_addPlayerEventHandler;
["vehicle", LINKFUNC(showVehicleHud), true] call CBA_fnc_addPlayerEventHandler; // only one of these needs the retro flag

// Add UAV Control Compatibility
["ACE_controlledUAV", {
params ["_UAV", "_seatAI", "_turret", "_position"];
TRACE_4("ACE_controlledUAV EH",_UAV,_seatAI,_turret,_position);
if (!isNull _seatAI) then {
[_seatAI] call FUNC(showVehicleHud);
} else {
[ace_player] call FUNC(showVehicleHud);
};
}] call CBA_fnc_addEventHandler;

[] call FUNC(registerDefaultHud);
}] call CBA_fnc_addEventHandler;
};

9 changes: 9 additions & 0 deletions addons/missile_hud/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "script_component.hpp"

ADDON = false;

PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

ADDON = true;
3 changes: 3 additions & 0 deletions addons/missile_hud/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "script_component.hpp"

#include "XEH_PREP.hpp"
24 changes: 24 additions & 0 deletions addons/missile_hud/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "script_component.hpp"

class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common", "ace_missileguidance"};
author = ECSTRING(common,ACETeam);
authors[] = {"tcvm"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
};

#include "CfgEventHandlers.hpp"
#include "ACE_GuidanceConfig.hpp"

class RscText;
class RscControlsGroupNoScrollbars;
class RscPictureKeepAspect;

#include "RscTitles.hpp"
49 changes: 49 additions & 0 deletions addons/missile_hud/functions/fnc_createCtrlFromElement.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "..\script_component.hpp"
/*
* Author: tcvm
* Create a UI control to be added to the display.
*
* Arguments:
* 0: Display <DISPLAY>
* 1: Line <CONTROL>
* 2: Element <ARRAY>
*
* Return Value:
* Control <CONTROL>
*
* Example:
* [findDisplay 46, ["TEXT", "Hello, world!", [1, 1, 0]]] call ace_missile_hud_fnc_createCtrlFromElement
*
* Public: No
*/

params ["_display", "_line", "_element"];
TRACE_1("createCtrlFromElement",_this);

private _ctrl = controlNull;
switch (_element select 0) do {
case "TEXT": {
_element params ["", "_text", "_color"];
private _controlConfig = GVAR(config) >> "text";
_ctrl = _display ctrlCreate [_controlConfig, -1, _line];
_ctrl ctrlSetText _text;
if (3 == count _color) then { _color pushBack 1; };
_ctrl ctrlSetTextColor _color;
};
case "ICON": {
_element params ["", "_path", "_color"];
private _controlConfig = GVAR(config) >> "icon";
_ctrl = _display ctrlCreate [_controlConfig, -1, _line];
_ctrl ctrlSetText _path;
if (3 == count _color) then { _color pushBack 1; };
_ctrl ctrlSetTextColor _color;
};
case "SPACER": {
private _controlConfig = GVAR(config) >> "icon";
_ctrl = _display ctrlCreate [_controlConfig, -1, _line];
_ctrl ctrlSetText "\A3\ui_f\data\map\markers\system\empty_ca.paa";
_ctrl ctrlSetTextColor [0, 0, 0, 0];
};
};

_ctrl
29 changes: 29 additions & 0 deletions addons/missile_hud/functions/fnc_getCurrentWeapon.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "..\script_component.hpp"
/*
* Author: tcvm
* Get the current weapon of the unit.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Vehicle <OBJECT>
* 2: Turret path <ARRAY>
*
* Return Value:
* Current weapon <STRING>
*
* Example:
* [player, vehicle player, [0]] call ace_missile_hud_fnc_getCurrentWeapon
*
* Public: No
*/

params ["_unit", "_vehicle", "_turretPath"];
TRACE_2("registerElement",_condition,_generator);

private _currentWeapon = if (_unit isEqualTo _vehicle) then {
currentWeapon _unit
} else {
_vehicle currentWeaponTurret _turretPath
};

_currentWeapon
Loading