*Fixed a minor bug in the dual inclination calculation

*Added a profile namespace format version
*The profileNamespace data is now automatically reset on version mismatch
This commit is contained in:
ulteq 2015-04-18 17:45:32 +02:00
parent 5e45734cf4
commit fc39b81c95
9 changed files with 59 additions and 9 deletions

View File

@ -2,7 +2,7 @@
#include "initKeybinds.sqf"
if (count (profileNamespace getVariable ["ACE_ATragMX_gunList", []]) > 0) then {
if ((profileNamespace getVariable ["ACE_ATragMX_profileNamespaceVersion", 0]) == ATRAGMX_PROFILE_NAMESPACE_VERSION && count (profileNamespace getVariable ["ACE_ATragMX_gunList", []]) > 0) then {
GVAR(gunList) = profileNamespace getVariable "ACE_ATragMX_gunList";
} else {
// Profile Name, Muzzle Velocity, Zero Range, Scope Base Angle, AirFriction, Bore Height, Scope Unit, Elevation Scope Step, Windage Scope Step, Maximum Elevation, Dialed Elevation, Dialed Windage, Mass, Bullet Diameter, Rifle Twist, BC, Drag Model, Atmosphere Model
@ -39,6 +39,7 @@ if (count (profileNamespace getVariable ["ACE_ATragMX_gunList", []]) > 0) then {
["5.56x45mm Mk262" , 820, 100, 0.0671, -0.0011250, 3.81, 0, 0.338, 0.338, 120, 0, 0, 4.990, 5.70, 17.78, 0.361, 1, "ASM" ],
["5.56x45mm Mk318" , 880, 100, 0.0616, -0.0011200, 3.81, 0, 0.338, 0.338, 120, 0, 0, 4.018, 5.70, 17.78, 0.307, 1, "ASM" ]];
[] call FUNC(clear_user_data);
profileNamespace setVariable ["ACE_ATragMX_gunList", GVAR(gunList)];
};

View File

@ -12,6 +12,7 @@ PREP(calculate_target_speed_assist);
PREP(can_show);
PREP(change_gun);
PREP(change_target_slot);
PREP(clear_user_data);
PREP(create_dialog);
PREP(cycle_gun_list);
PREP(cycle_image_size_units);

View File

@ -0,0 +1,39 @@
/*
* Author: Ruthberg
* Removes all user data from the profileNamespace
*
* Arguments:
* Nothing
*
* Return Value:
* Nothing
*
* Example:
* call ace_atragmx_fnc_clear_user_data
*
* Public: No
*/
#include "script_component.hpp"
profileNamespace setVariable ["ACE_ATragMX_gunList", nil];
profileNamespace setVariable ["ACE_ATragMX_currentUnit", nil];
profileNamespace setVariable ["ACE_ATragMX_currentGun", nil];
profileNamespace setVariable ["ACE_ATragMX_currentTarget", nil];
profileNamespace setVariable ["ACE_ATragMX_currentScopeUnit", nil];
profileNamespace setVariable ["ACE_ATragMX_atmosphereModeTBH", nil];
profileNamespace setVariable ["ACE_ATragMX_altitude", nil];
profileNamespace setVariable ["ACE_ATragMX_temperature", nil];
profileNamespace setVariable ["ACE_ATragMX_barometricPressure", nil];
profileNamespace setVariable ["ACE_ATragMX_relativeHumidity", nil];
profileNamespace setVariable ["ACE_ATragMX_showWind2", nil];
profileNamespace setVariable ["latitude", nil];
profileNamespace setVariable ["directionOfFire", nil];
profileNamespace setVariable ["ACE_ATragMX_windSpeed1", nil];
profileNamespace setVariable ["ACE_ATragMX_windSpeed2", nil];
profileNamespace setVariable ["ACE_ATragMX_windDirection", nil];
profileNamespace setVariable ["ACE_ATragMX_inclinationAngle", nil];
profileNamespace setVariable ["ACE_ATragMX_targetSpeed", nil];
profileNamespace setVariable ["ACE_ATragMX_targetRange", nil];

View File

@ -31,12 +31,12 @@ GVAR(directionOfFire) set [GVAR(currentTarget), 0 max abs(Round(parseNumber(ctrl
GVAR(windSpeed1) set [GVAR(currentTarget), 0 max abs(parseNumber(ctrlText 140020)) min 50];
GVAR(windSpeed2) set [GVAR(currentTarget), 0 max abs(parseNumber(ctrlText 140021)) min 50];
GVAR(windDirection) set [GVAR(currentTarget), 1 max Round(parseNumber(ctrlText 140030)) min 12];
_inclinationAngleCosine = 0.5 max parseNumber(ctrlText 140041) max 1;
_inclinationAngleCosine = 0.5 max parseNumber(ctrlText 140041) min 1;
_inclinationAngleDegree = -60 max parseNumber(ctrlText 140040) min 60;
if (_inclinationAngleDegree != GVAR(inclinationAngle) select GVAR(currentTarget)) then {
GVAR(inclinationAngle) set [GVAR(currentTarget), _inclinationAngleDegree];
} else {
if (_inclinationAngleCosine != cos(GVAR(inclinationAngle) select GVAR(currentTarget))) then {
if (_inclinationAngleCosine != Round(cos(GVAR(inclinationAngle) select GVAR(currentTarget)) * 100) / 100) then {
GVAR(inclinationAngle) set [GVAR(currentTarget), acos(_inclinationAngleCosine)];
};
};
@ -120,5 +120,6 @@ GVAR(workingMemory) set [11, _windageCur];
[] call FUNC(update_atmosphere);
[] call FUNC(update_atmo_env_data);
[] call FUNC(update_target);
[] call FUNC(update_target_data);
[] call FUNC(store_user_data);

View File

@ -15,6 +15,8 @@
*/
#include "script_component.hpp"
profileNamespace setVariable ["ACE_ATragMX_profileNamespaceVersion", ATRAGMX_PROFILE_NAMESPACE_VERSION];
profileNamespace setVariable ["ACE_ATragMX_currentUnit", GVAR(currentUnit)];
profileNamespace setVariable ["ACE_ATragMX_currentGun", GVAR(currentGun)];
profileNamespace setVariable ["ACE_ATragMX_currentTarget", GVAR(currentTarget)];

View File

@ -21,9 +21,13 @@ if (ctrlVisible 8000) then {
if (_this == 1) then {
[] call FUNC(calculate_target_speed_assist);
ctrlSetText [330, Str(parseNumber(ctrlText 8007))];
ctrlSetText [140050, Str(parseNumber(ctrlText 8007))];
[] call FUNC(calculate_target_solution);
private ["_targetSpeed"];
_targetSpeed = parseNumber(ctrlText 8007);
if (_targetSpeed != 0) then {
ctrlSetText [330, Str(_targetSpeed)];
ctrlSetText [140050, Str(_targetSpeed)];
[] call FUNC(calculate_target_solution);
};
};
} else {
false call FUNC(show_main_page);

View File

@ -16,11 +16,11 @@
#include "script_component.hpp"
private ["_inclinationAngleCosine", "_inclinationAngleDegree"];
_inclinationAngleCosine = 0.5 max parseNumber(ctrlText 140041) max 1;
_inclinationAngleCosine = 0.5 max parseNumber(ctrlText 140041) min 1;
_inclinationAngleDegree = -60 max parseNumber(ctrlText 140040) min 60;
if (_this == 0) then {
ctrlSetText [140040, Str(round(acos(_inclinationAngleCosine)))];
} else {
ctrlSetText [140041, Str(floor(cos(_inclinationAngleDegree) * 100) / 100)];
ctrlSetText [140041, Str(round(cos(_inclinationAngleDegree) * 100) / 100)];
};

View File

@ -26,7 +26,7 @@ if (GVAR(currentUnit) != 2) then {
};
ctrlSetText [140030, Str(Round((GVAR(windDirection) select GVAR(currentTarget))))];
ctrlSetText [140040, Str(Round((GVAR(inclinationAngle) select GVAR(currentTarget))))];
ctrlSetText [140041, Str(floor(cos(GVAR(inclinationAngle) select GVAR(currentTarget)) * 100) / 100)];
ctrlSetText [140041, Str(Round(cos(GVAR(inclinationAngle) select GVAR(currentTarget)) * 100) / 100)];
if (GVAR(currentUnit) != 2) then {
ctrlSetText [140050, Str(Round((GVAR(targetSpeed) select GVAR(currentTarget)) * 2.23693629 * 100) / 100)];
} else {

View File

@ -10,3 +10,5 @@
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#define ATRAGMX_PROFILE_NAMESPACE_VERSION 1.0