ACE3/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf

95 lines
3.6 KiB
Plaintext
Raw Normal View History

2015-04-05 06:57:24 +00:00
/*
* Author: PabstMirror
*
*
* Arguments:
*
* Return Value:
*
* Example:
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_2(_player,_newVehicle);
if (isNull _newVehicle) exitWith {};
if (!(_newVehicle isKindOf "Mortar_01_base_F")) exitWith {};
_chargeText = (findDisplay 46) ctrlCreate ["RscStructuredText", 80085];
_xPos = (profilenamespace getvariable ["IGUI_GRID_WEAPON_X", ((safezoneX + safezoneW) - (12.4 * (((safezoneW / safezoneH) min 1.2) / 40)) - 0.5 * (((safezoneW / safezoneH) min 1.2) / 40))]);
_yPos = 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))]);
_wPos = 10 * (((safezoneW / safezoneH) min 1.2) / 40);
_hPos = 1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25);
_chargeText ctrlSetPosition [_xPos, _yPos, _wPos, _hPos];
_chargeText ctrlCommit 0;
2015-04-05 19:34:39 +00:00
_tubeWeaponName = (weapons _newVehicle) select 0;
_fireModes = getArray (configFile >> "CfgWeapons" >> _tubeWeaponName >> "modes");
2015-04-05 06:57:24 +00:00
[{
PARAMS_2(_args,_pfID);
2015-04-05 19:34:39 +00:00
EXPLODE_3_PVT(_args,_mortarVeh,_chargeText,_fireModes);
2015-04-05 06:57:24 +00:00
2015-04-05 19:34:39 +00:00
if ((vehicle ACE_player) != _mortarVeh) then {
2015-04-05 06:57:24 +00:00
[_pfID] call CBA_fnc_removePerFrameHandler;
ctrlDelete _chargeText;
2015-04-05 06:57:24 +00:00
} else {
2015-04-05 19:34:39 +00:00
//Compute: 'charge' from weaponstate
_currentFireMode = (weaponState [_mortarVeh, [0]]) select 2;
_currentChargeMode = _fireModes find _currentFireMode;
_text = format ["<t size='0.8'>%1: %2 <img image='%3'/></t>", "Charge", _currentChargeMode, QUOTE(PATHTOF(UI\ui_charges.paa))];
_chargeText ctrlSetStructuredText parseText _text;
2015-04-05 19:34:39 +00:00
if (shownArtilleryComputer && {!GVAR(allowComputerRangefinder)}) then {
//Don't like this solution, but it works
2015-04-05 07:27:13 +00:00
closeDialog 0;
[parseText "Computer Disabled"] call EFUNC(common,displayTextStructured);
};
2015-04-05 19:34:39 +00:00
2015-04-05 06:57:24 +00:00
_display = uiNamespace getVariable ["ACE_Mk6_RscWeaponRangeArtillery", displayNull];
if (isNull _display) exitWith {systemChat "null";};
2015-04-05 19:34:39 +00:00
//Update CurrentElevation Display:
2015-04-05 06:57:24 +00:00
_elevDeg = parseNumber ctrlText (_display displayCtrl 175);
2015-04-05 07:18:51 +00:00
if (GVAR(useMils)) then {
2015-04-05 06:57:24 +00:00
(_display displayCtrl 80175) ctrlSetText str round (_elevDeg * 6400 / 360);
} else {
(_display displayCtrl 80175) ctrlSetText str _elevDeg;
};
2015-04-05 19:34:39 +00:00
//Update ElevationNeeded Display:
if (!GVAR(allowComputerRangefinder)) then {
2015-04-05 06:57:24 +00:00
(_display displayCtrl 80176) ctrlSetText "";
} else {
_elevDeg = parseNumber ctrlText (_display displayCtrl 176);
if (_elevDeg <= 0) then {
(_display displayCtrl 80176) ctrlSetText (ctrlText (_display displayCtrl 176));
} else {
2015-04-05 07:18:51 +00:00
if (GVAR(useMils)) then {
2015-04-05 06:57:24 +00:00
(_display displayCtrl 80176) ctrlSetText str round (_elevDeg * 6400 / 360);
} else {
(_display displayCtrl 80176) ctrlSetText str _elevDeg;
};
};
};
2015-04-05 19:34:39 +00:00
//Update Heading Display:
if (!GVAR(allowCompass)) then {
(_display displayCtrl 80156) ctrlSetText "";
} else {
2015-04-05 19:48:26 +00:00
_rotationDegrees = ((getDir _mortarVeh) + (((-180 / PI) * (_mortarVeh animationPhase "mainTurret")) + 360)) % 360;
2015-04-05 19:34:39 +00:00
if (GVAR(useMils)) then {
2015-04-05 19:48:26 +00:00
(_display displayCtrl 80156) ctrlSetText str round (_rotationDegrees * 6400 / 360);
2015-04-05 19:34:39 +00:00
} else {
2015-04-05 19:48:26 +00:00
(_display displayCtrl 80156) ctrlSetText str _rotationDegrees;
2015-04-05 19:34:39 +00:00
};
};
2015-04-05 06:57:24 +00:00
};
2015-04-05 19:34:39 +00:00
}, 0, [_newVehicle, _chargeText,_fireModes]] call CBA_fnc_addPerFrameHandler;