mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Support per mag air friction
This commit is contained in:
parent
c6d7df3770
commit
1d2ecdd3ff
@ -8,43 +8,37 @@ class GVAR(rangeTableDialog) {
|
||||
class TableBackground: RscPicture {
|
||||
idc = -1;
|
||||
text = QPATHTOF(UI\RangeTable_background.paa);
|
||||
x = "18 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH)/2)";
|
||||
y = "1 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2))/2)";
|
||||
x = "18 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH) / 2)";
|
||||
y = "1 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2)) / 2)";
|
||||
w = "16.2634559672906 * (safeZoneH / 40)";
|
||||
h = "23 * ((safeZoneH / 1.2) / 25)";
|
||||
colorBackground[] = {1,1,1,1};
|
||||
};
|
||||
class ChargeBackground: RscText {
|
||||
class LeftSideBackground: RscText {
|
||||
idc = -1;
|
||||
x = "14 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH)/2)";
|
||||
y = "1 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2))/2)";
|
||||
w = "4 * (safeZoneH / 40)";
|
||||
h = "8 * ((safeZoneH / 1.2) / 25)";
|
||||
colorBackground[] = {0,0,0,0.9};
|
||||
x = "13 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH) / 2)";
|
||||
y = "1 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2)) / 2)";
|
||||
w = "5 * (safeZoneH / 40)";
|
||||
h = "23 * ((safeZoneH / 1.2) / 25)";
|
||||
colorBackground[] = {0,0,0,0.8};
|
||||
};
|
||||
};
|
||||
class controls {
|
||||
class TheTable: RscListNBox {
|
||||
idc = IDC_TABLE;
|
||||
// style = ST_CENTER + ST_MULTI + LB_TEXTURES;
|
||||
// style = ST_LEFT + ST_MULTI + LB_TEXTURES;
|
||||
// style = LB_MULTI + ST_LEFT; // Style
|
||||
x = "18 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH)/2)";
|
||||
y = "3.76 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2))/2)";
|
||||
x = "18 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH) / 2)";
|
||||
y = "3.76 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2)) / 2)";
|
||||
w = "16.2634559672906 * (safeZoneH / 40)";
|
||||
h = "20.24 * ((safeZoneH / 1.2) / 25)";
|
||||
columns[] = {(10/867),(86/867),(171/867),(238/867),(320/867),(405/867),
|
||||
(485/867),(546/867),(607/867),(668/867),(729/867),(790/867)};
|
||||
columns[] = {(10/867),(86/867),(171/867),(238/867),(320/867),(405/867),(485/867),(546/867),(607/867),(668/867),(729/867),(790/867)};
|
||||
rowHeight = 0.015 * safeZoneH;
|
||||
sizeEx = "0.014 * safeZoneH";
|
||||
font = "EtelkaMonospacePro";
|
||||
drawSideArrows = 1;
|
||||
idcLeft = 14124;
|
||||
idcRight = 412343243;
|
||||
idcLeft = -1;
|
||||
idcRight = -1;
|
||||
colorText[] = {0, 0, 0, 1};
|
||||
shadow = "0";
|
||||
// colorBorder[] = {1,0,0,1};
|
||||
// colorBackground[] = {1, 0, 0, 1};
|
||||
colorSelectBackground[] = {0, 0, 0, 0.025};
|
||||
colorSelectBackground2[] = {0, 0, 0, 0.025};
|
||||
colorScrollbar[] = {0.95,0,0.95,1};
|
||||
@ -55,31 +49,31 @@ class GVAR(rangeTableDialog) {
|
||||
class ChargeListBox: RscListbox {
|
||||
idc = IDC_CHARGELIST;
|
||||
style = ST_RIGHT;
|
||||
x = "14 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH)/2)";
|
||||
y = "2 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2))/2)";
|
||||
w = "4 * (safeZoneH / 40)";
|
||||
h = "7 * ((safeZoneH / 1.2) / 25)";
|
||||
x = "13 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH) / 2)";
|
||||
y = "2 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2)) / 2)";
|
||||
w = "5 * (safeZoneH / 40)";
|
||||
h = "22 * ((safeZoneH / 1.2) / 25)";
|
||||
onLBSelChanged = QUOTE([] call FUNC(rangeTableUpdate));
|
||||
};
|
||||
class elevationHigh: ctrlButton {
|
||||
idc = IDC_BUTTON_ELEV_HIGH;
|
||||
text = "High";
|
||||
onButtonClick = QUOTE([true] call FUNC(rangeTableUpdate));
|
||||
x = "14.1 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH)/2)";
|
||||
y = "1.1 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2))/2)";
|
||||
w = "1.8 * (safeZoneH / 40)";
|
||||
x = "13.1 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH) / 2)";
|
||||
y = "1.1 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2)) / 2)";
|
||||
w = "2.3 * (safeZoneH / 40)";
|
||||
h = "0.8 * ((safeZoneH / 1.2) / 25)";
|
||||
};
|
||||
class elevationLow: elevationHigh {
|
||||
idc = IDC_BUTTON_ELEV_LOW;
|
||||
text = "Low";
|
||||
onButtonClick = QUOTE([false] call FUNC(rangeTableUpdate));
|
||||
x = "16.1 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH)/2)";
|
||||
x = "15.6 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH) / 2)";
|
||||
};
|
||||
class CloseBackground: RscText {
|
||||
idc = -1;
|
||||
x = "33.7634559672906 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH)/2)";
|
||||
y = "1 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2))/2)";
|
||||
x = "33.7634559672906 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH) / 2)";
|
||||
y = "1 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2)) / 2)";
|
||||
w = "0.5 * (safeZoneH / 40)";
|
||||
h = "0.5 * ((safeZoneH / 1.2) / 25)";
|
||||
colorBackground[] = {0,0,0,0.5};
|
||||
@ -89,8 +83,8 @@ class GVAR(rangeTableDialog) {
|
||||
style = 48;
|
||||
color[] = {1,1,1,0.7};
|
||||
text = "A3\Ui_f\data\GUI\Rsc\RscDisplayArcadeMap\icon_exit_cross_ca.paa";
|
||||
x = "33.7634559672906 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH)/2)";
|
||||
y = "1 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2))/2)";
|
||||
x = "33.7634559672906 *(safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH) / 2)";
|
||||
y = "1 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2)) / 2)";
|
||||
w = "0.5 * (safeZoneH / 40)";
|
||||
h = "0.5 * ((safeZoneH / 1.2) / 25)";
|
||||
colorText[] = {1,1,1,0.7};
|
||||
|
@ -68,7 +68,6 @@ TRACE_2("searching for new vehicles",_vehicleAdded,_rangeTablesShown);
|
||||
private _turretRot = [vectorDir _vehicle, vectorUp _vehicle, (180 / PI) * _currentTraverseRad] call FUNC(rotateVector3d);
|
||||
private _neutralX = (acos (_turretRot vectorCos _weaponDir)) - ((180 / PI) * _currentElevRad);
|
||||
_neutralX = (round (_neutralX * 10)) / 10; // minimize floating point errors
|
||||
|
||||
private _minElev = _neutralX + getNumber (_turretCfg >> "minElev");
|
||||
private _maxElev = _neutralX + getNumber (_turretCfg >> "maxElev");
|
||||
|
||||
@ -79,7 +78,8 @@ TRACE_2("searching for new vehicles",_vehicleAdded,_rangeTablesShown);
|
||||
};
|
||||
private _advCorrection = GVAR(advancedCorrections) && {_applyCorrections == 1};
|
||||
|
||||
private _info = [_weapon, _minElev, _maxElev, _advCorrection]; // in case multiple vehicle types use the same weapon
|
||||
// check weapon and limits in case different vehicles use the same weapon (cammo variants should still produce the same array)
|
||||
private _info = [_weapon, _minElev, _maxElev, _advCorrection];
|
||||
|
||||
_vehicleAdded pushBack _vehicle;
|
||||
ace_player setVariable [QGVAR(vehiclesAdded), _vehicleAdded];
|
||||
@ -90,9 +90,7 @@ TRACE_2("searching for new vehicles",_vehicleAdded,_rangeTablesShown);
|
||||
private _statement = {
|
||||
params ["", "", "_info"];
|
||||
TRACE_1("interaction statement",_info);
|
||||
[{
|
||||
_this call FUNC(rangeTableOpen); // delay a frame because of interaction menu closing dialogs
|
||||
}, _info] call CBA_fnc_execNextFrame;
|
||||
[FUNC(rangeTableOpen), _info] call CBA_fnc_execNextFrame; // delay a frame because of interaction menu closing dialogs
|
||||
};
|
||||
private _condition = {
|
||||
//IGNORE_PRIVATE_WARNING ["_player"];
|
||||
|
@ -4,7 +4,10 @@
|
||||
* Opens the rangetable and fills the charge listbox.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
* 0: Weapon configname <STRING>
|
||||
* 1: Elevation Min (Deg) <NUMBER>
|
||||
* 2: Elevation Max (Deg) <NUMBER>
|
||||
* 3: Advanced Corrections Enabled <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -18,6 +21,8 @@
|
||||
params ["_weaponName", "_elevMin", "_elevMax", "_advCorrection"];
|
||||
TRACE_3("rangeTableOpen",_weaponName,_elevMin,_elevMax);
|
||||
|
||||
BEGIN_COUNTER(rangeTableOpen);
|
||||
|
||||
createDialog QGVAR(rangeTableDialog);
|
||||
private _dialog = uiNamespace getVariable [QGVAR(rangeTableDialog), displayNull];
|
||||
if (isNull _dialog) exitWith{ERROR("Dialog failed to open");};
|
||||
@ -31,48 +36,52 @@ TRACE_2("created dialog",_dialog,_ctrlChargeList);
|
||||
private _mags = [_weaponName] call CBA_fnc_compatibleMagazines;
|
||||
if (_mags isEqualTo []) exitWith {WARNING_1("No Mags",_weaponName);};
|
||||
private _magCfg = configFile >> "CfgMagazines";
|
||||
private _firstSpeed = getNumber (_magCfg >> (_mags select 0) >> "initSpeed");
|
||||
private _allSame = true;
|
||||
private _magParamsArray = [];
|
||||
_mags = _mags apply {
|
||||
private _initSpeed = getNumber (_magCfg >> _x >> "initSpeed");
|
||||
if (_initSpeed != _firstSpeed) then {_allSame = false};
|
||||
[getText (_magCfg >> _x >> "displayNameShort"), _initSpeed]
|
||||
_magParamsArray pushBackUnique _initSpeed;
|
||||
private _airFriction = 0;
|
||||
if (_advCorrection) then {
|
||||
_airFriction = if (isNumber (_magCfg >> _x >> QGVAR(airFriction))) then { getNumber (_magCfg >> _x >> QGVAR(airFriction)) } else { -0.00005 };
|
||||
};
|
||||
_magParamsArray pushBackUnique _airFriction;
|
||||
[getText (_magCfg >> _x >> "displayNameShort"), getText (_magCfg >> _x >> "displayName"), _initSpeed, _airFriction]
|
||||
};
|
||||
TRACE_2("",_magParamsArray,_mags);
|
||||
if ((count _magParamsArray) == 2) then { // test if all magazines share the parameters
|
||||
_mags = [["", "", (_mags select 0) select 2, (_mags select 0) select 3]]; // simplify
|
||||
};
|
||||
if (_allSame) then { _mags = [["-", _firstSpeed]]; };
|
||||
TRACE_2("",_allSame,_mags);
|
||||
|
||||
// Get Firemodes:
|
||||
private _fireModes = getArray (configFile >> "CfgWeapons" >> _weaponName >> "modes");
|
||||
_fireModes = (_fireModes apply {configFile >> "CfgWeapons" >> _weaponName >> _x}) select {1 == getNumber (_x >> "showToPlayer")};
|
||||
_fireModes = _fireModes apply {[getNumber (_x >> "artilleryCharge"), configName _x]};
|
||||
_fireModes sort true;
|
||||
private _allSameCharge = ((count _fireModes) == 1);
|
||||
private _allSameCharge = ((count _fireModes) == 1) && {((_fireModes select 0) select 0) == 1};
|
||||
TRACE_2("",_allSameCharge,_fireModes);
|
||||
|
||||
private _index = 0;
|
||||
GVAR(magModeData) = [];
|
||||
{
|
||||
_x params ["_xMagName", "_xMagInitSpeed"];
|
||||
_x params ["_xDisplayNameShort", "_xDisplayName", "_xInitSpeed", "_xAirFriction"];
|
||||
if (_allSameCharge) then {
|
||||
_ctrlChargeList lbAdd format ["%1", _xMagName];
|
||||
_ctrlChargeList lbSetTooltip [_index, format ["%1 m/s",_xMagInitSpeed toFixed 1]];
|
||||
_ctrlChargeList lbSetData [_index, str (_xMagInitSpeed)];
|
||||
_index = _index + 1;
|
||||
_ctrlChargeList lbAdd format ["%1", _xDisplayNameShort];
|
||||
_ctrlChargeList lbSetTooltip [count GVAR(magModeData), format ["%1 m/s\n%2",_xInitSpeed toFixed 1, _xDisplayName]];
|
||||
GVAR(magModeData) pushBack [_xInitSpeed, _xAirFriction];
|
||||
} else {
|
||||
{
|
||||
_x params ["_xArtilleryCharge"];
|
||||
_ctrlChargeList lbAdd format ["%1 Charge: %2", _xMagName, _forEachIndex]; // forEachIndex is for firemodes
|
||||
_ctrlChargeList lbSetTooltip [_index, format ["%1 m/s", (_xMagInitSpeed * _xArtilleryCharge) toFixed 1]];
|
||||
_ctrlChargeList lbSetData [_index, str (_xMagInitSpeed * _xArtilleryCharge)];
|
||||
_index = _index + 1;
|
||||
_x params ["_xModeCharge"];
|
||||
_ctrlChargeList lbAdd format ["[Charge %1] %2", _forEachIndex, _xDisplayNameShort]; // forEachIndex is from firemodes
|
||||
_ctrlChargeList lbSetTooltip [count GVAR(magModeData), format ["%1 m/s\n%2", (_xInitSpeed * _xModeCharge) toFixed 1, _xDisplayName]];
|
||||
GVAR(magModeData) pushBack [_xInitSpeed * _xModeCharge, _xAirFriction];
|
||||
} forEach _fireModes;
|
||||
};
|
||||
} forEach _mags;
|
||||
|
||||
if (_index == 0) exitWith {ERROR_1("no modes %1",_weaponName);};
|
||||
|
||||
if (isNil QGVAR(lastElevationMode)) then {GVAR(lastElevationMode) = true;};
|
||||
if (isNil QGVAR(lastCharge)) then {GVAR(lastCharge) = 0;};
|
||||
if ((GVAR(lastCharge) >= _index) || {GVAR(lastCharge) < 0}) then { GVAR(lastCharge) = 0; };
|
||||
if (isNil QGVAR(lastTablePage)) then {GVAR(lastTablePage) = 0;};
|
||||
if ((GVAR(lastTablePage) >= (count GVAR(magModeData))) || {GVAR(lastTablePage) < 0}) then { GVAR(lastTablePage) = 0; };
|
||||
|
||||
TRACE_2("",GVAR(lastElevationMode),GVAR(lastCharge));
|
||||
_ctrlChargeList lbSetCurSel GVAR(lastCharge); // triggers call to FUNC(rangeTableUpdate)
|
||||
END_COUNTER(rangeTableOpen);
|
||||
TRACE_2("trigger update",GVAR(lastElevationMode),GVAR(lastTablePage));
|
||||
_ctrlChargeList lbSetCurSel GVAR(lastTablePage); // triggers call to FUNC(rangeTableUpdate)
|
||||
|
@ -15,32 +15,25 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
|
||||
private _dialog = uiNamespace getVariable [QGVAR(rangeTableDialog), displayNull];
|
||||
private _ctrlRangeTable = _dialog displayCtrl IDC_TABLE;
|
||||
private _ctrlChargeList = _dialog displayCtrl IDC_CHARGELIST;
|
||||
private _ctrlElevationHigh = _dialog displayCtrl IDC_BUTTON_ELEV_HIGH;
|
||||
private _ctrlElevationLow = _dialog displayCtrl IDC_BUTTON_ELEV_LOW;
|
||||
|
||||
GVAR(lastElevationMode) = param [0, GVAR(lastElevationMode)];
|
||||
GVAR(lastElevationMode) = param [0, GVAR(lastElevationMode)]; // update if passed a new value
|
||||
GVAR(lastCharge) = lbCurSel _ctrlChargeList;
|
||||
|
||||
private _listBoxData = _ctrlChargeList lbData GVAR(lastCharge);
|
||||
if (isNil "_listBoxData" || {_listBoxData == ""}) exitWith {ERROR("lbCurSel out of bounds or no data");};
|
||||
private _muzzleVelocity = parseNumber _listBoxData;
|
||||
|
||||
// get data for currently selected mag/mode combo:
|
||||
(GVAR(magModeData) select GVAR(lastCharge)) params [["_muzzleVelocity", -1], ["_airFriction", 0]];
|
||||
private _elevMin = _dialog getVariable [QGVAR(elevMin), 0];
|
||||
private _elevMax = _dialog getVariable [QGVAR(elevMax), 0];
|
||||
_ctrlElevationHigh ctrlSetTextColor ([[0.25,0.25,0.25,1],[1,1,1,1]] select GVAR(lastElevationMode));
|
||||
_ctrlElevationLow ctrlSetTextColor ([[1,1,1,1],[0.25,0.25,0.25,1]] select GVAR(lastElevationMode));
|
||||
|
||||
private _advCorrection = _dialog getVariable [QGVAR(advCorrection), false];
|
||||
private _airFriction = if (_advCorrection) then {-0.00005} else {0};
|
||||
|
||||
TRACE_4("",_muzzleVelocity,_elevMin,_elevMax,_airFriction);
|
||||
|
||||
|
||||
lnbClear _ctrlRangeTable;
|
||||
// Call extension with current data and start workers
|
||||
TRACE_5("callExtension:start",_muzzleVelocity,_airFriction,_elevMin,_elevMax,GVAR(lastElevationMode));
|
||||
private _ret = "ace_artillerytables" callExtension ["start", [_muzzleVelocity,_airFriction,_elevMin,_elevMax,GVAR(lastElevationMode)]];
|
||||
TRACE_1("",_ret);
|
||||
|
Loading…
Reference in New Issue
Block a user