Skip to content
Merged
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
4 changes: 0 additions & 4 deletions addons/missileguidance/GPSDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
#include "\a3\ui_f\hpp\defineCommonColors.inc"
#include "idc_defines.hpp"

class RscText;
class RscEdit;
class RscButton;

class GVAR(gpsAttackOptionsUI) {
idd = -1;
movingEnable = 1;
Expand Down
23 changes: 23 additions & 0 deletions addons/missileguidance/MCLOSDialog.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class GVAR(mouseInputDialog) {
idd = -1;
movingEnable = 0;
enableSimulation = 1;
onLoad = QUOTE(with uiNameSpace do { GVAR(mouseInputDialog) = _this select 0 };);
class controlsBackground {
class Background: RscText {
idc = 1000;
x = 0;
y = 0;
w = 1;
h = 1;
colorBackground[] = {0, 0, 0, 0.2};
};
};
class controls {
class MousePositionMarker: RscPicture {
idc = 2000;
text = "\A3\ui_f\data\map\markers\military\circle_CA.paa";
colorText[] = {1, 0, 0, 1};
};
};
};
1 change: 1 addition & 0 deletions addons/missileguidance/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ PREP(handleHandoff);
PREP(shouldFilterRadarHit);

PREP(MCLOS_buttonPressed);
PREP(MCLOS_mouseInput);

// Attack Profiles
PREP(attackProfile_AIR);
Expand Down
9 changes: 9 additions & 0 deletions addons/missileguidance/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,12 @@ if (!hasInterface) exitWith {};
};
}] call CBA_fnc_addEventHandler;
}] call CBA_fnc_addEventHandler;

// MCLOS - Mouse Input
["lock", {
if (GVAR(MCLOS_mouseInput)) exitWith { GVAR(MCLOS_mouseInput) = false; };
GVAR(MCLOS_mouseInput) = true;
call FUNC(MCLOS_mouseInput);
}, {
GVAR(MCLOS_mouseInput) = false;
}] call EFUNC(missileguidance,keybind_add);
6 changes: 6 additions & 0 deletions addons/missileguidance/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class CfgPatches {
};
};

class RscText;
class RscEdit;
class RscButton;
class RscPicture;

#include "ACE_GuidanceConfig.hpp"

#include "CfgMissileTypesNato.hpp"
Expand All @@ -22,6 +27,7 @@ class CfgPatches {
#include "CfgMagazines.hpp"
#include "CfgWeapons.hpp"
#include "GPSDialog.hpp"
#include "MCLOSDialog.hpp"
#ifdef CREATE_MOCK_PLATFORMS
#include "dev\mock_vehicles.hpp"
#endif
20 changes: 14 additions & 6 deletions addons/missileguidance/dev/mock_ammo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ class GVAR(mock_a_Malyutka): M_Titan_AA_static {
manualControl = 0;
thrust = 80;
maxSpeed = 100;
airFriction = 0.5;
sideairfriction = 0.14;
airFriction = 0.01;
sideairfriction = 0.5;
maneuvrability = 0;
class ADDON: GVAR(type_Malyutka) {
pitchRate = 5; // Minium flap deflection for guidance
yawRate = 5; // Maximum flap deflection for guidance
enabled = 1;
};
};
Expand All @@ -20,11 +23,16 @@ class GVAR(mock_a_blowpipe): M_Titan_AA_static {
airLock = 0;
lockType = 0;
manualControl = 0;
thrust = 80;
maxSpeed = 100;
airFriction = 0.5;
sideairfriction = 0.14;
thrust = 120;
maxSpeed = 500;
timeToLive = 15;
thrustTime = 15;
airFriction = 0.01;
sideairfriction = 0.5;
maneuvrability = 0;
class ADDON: GVAR(type_Blowpipe) {
pitchRate = 5; // Minium flap deflection for guidance
yawRate = 5; // Maximum flap deflection for guidance
enabled = 1;
};
};
107 changes: 107 additions & 0 deletions addons/missileguidance/functions/fnc_MCLOS_mouseInput.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#include "..\script_component.hpp"
/*
* Author: PabstMirror
* MCLOS mouse input handler
*
* Arguments:
* None
*
* Return Value:
* Handled
*
* Example:
* [] call ace_missileguidance_fnc_MCOLS_mouseInput
*
* Public: No
*/

private _player = ACE_player;

if (!alive _player) exitWith { false };
if !([_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith { false };

private _shooter = objNull;
private _weapons = [];
if ((isNull objectParent _player) || {_player call CBA_fnc_canUseWeapon}) then {
_shooter = _player;
private _currentWeapon = currentWeapon _shooter;
if (_currentWeapon != "") then { _weapons pushBack _currentWeapon };
} else {
_shooter = vehicle _player;
private _turretPath = if (_player == (driver _shooter)) then {[-1]} else {_player call CBA_fnc_turretPath};
_weapons = _shooter weaponsTurret _turretPath;
};

if ((_weapons findIf {
private _weapon = _x;
GVAR(mclos_weapons) getOrDefaultCall [_weapon, {
((compatibleMagazines _weapon) findIf {
private _mag = _x;
private _ammo = getText (configFile >> "CfgMagazines" >> _mag >> "ammo");
("MCLOS" in getArray (configFile >> "CfgAmmo" >> _ammo >> QUOTE(ADDON) >> "seekerTypes"))
}) != -1}, true]
}) == -1) exitWith { false };

playSound "ACE_Sound_Click";
createDialog QGVAR(mouseInputDialog);

private _halfX = safeZoneW / 16;
private _halfY = (4/3) * _halfX; // Maintain aspect ratio;
private _centerX = 0.5;
private _centerY = 1 min (safeZoneH - 2 * _halfY);

private _display = uiNamespace getVariable [QGVAR(mouseInputDialog), displayNull];
private _background = _display displayCtrl 1000;
_background ctrlSetBackgroundColor [0, 0, 0, 0.25]; // Semi-transparent background
_background ctrlSetPosition [_centerX - _halfX, _centerY - _halfY, _halfX * 2, _halfY * 2];
_background ctrlCommit 0;

// Set initial mouse position to the center
setMousePosition [_centerX, _centerY];
TRACE_1("start mouse input",typeOf _shooter);
[{
params ["_args", "_pfID"];
_args params ["_shooter", "_halfX", "_halfY", "_centerX", "_centerY"];
private _display = uiNamespace getVariable [QGVAR(mouseInputDialog), displayNull];
if ((!alive ACE_player) ||
{!alive _shooter} ||
{!([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith))} ||
{!GVAR(MCLOS_mouseInput)} ||
{isNull _display}
) exitWith {
TRACE_1("stop mouse input",typeOf _shooter);
if (!isNull _display) then {
closeDialog 1;
};
[_pfID] call CBA_fnc_removePerFrameHandler;
_shooter setVariable [QGVAR(MCLOS_direction), nil, true];
playSound "ACE_Sound_Click";
GVAR(MCLOS_mouseInput) = false;
};

getMousePosition params ["_mouseX", "_mouseY"];
private _minX = _centerX - _halfX;
private _maxX = _centerX + _halfX;
private _minY = _centerY - _halfY;
private _maxY = _centerY + _halfY;
private _clampX = (_mouseX min _maxX) max _minX;
private _clampY = (_mouseY min _maxY) max _minY;
private _realX = linearConversion [_minX, _maxX, _clampX, -1, 1, true];
private _realY = linearConversion [_minY, _maxY, _clampY, 1, -1, true]; // Inverted Y axis for the mouse
setMousePosition [_clampX, _clampY];


private _joystickIcon = _display displayCtrl 2000;
private _iconWidth = _halfX * 0.2;
private _iconHeight = _halfY * 0.2;
_joystickIcon ctrlSetPosition [_clampX - _iconWidth * 0.5, _clampY - _iconHeight * 0.5, _iconWidth, _iconHeight];
_joystickIcon ctrlCommit 0;

#ifdef DEBUG_MODE_FULL
systemChat format ["Mouse Position: %1, %2", _realX, _realY];
#endif

_shooter setVariable [QGVAR(MCLOS_direction), [_realX, 0, _realY]];
}, 0, [_shooter, _halfX, _halfY, _centerX, _centerY]] call CBA_fnc_addPerFrameHandler;

true
Loading