Code cleanup of Dagr module

This commit is contained in:
jokoho48 2015-08-09 02:33:00 +02:00
parent 2b3c936e99
commit bd1a6d14a8
6 changed files with 38 additions and 36 deletions

View File

@ -30,4 +30,4 @@ GVAR(vectorConnected) = false;
GVAR(noVectorData) = true; GVAR(noVectorData) = true;
GVAR(vectorGrid) = "00000000"; GVAR(vectorGrid) = "00000000";
["RangerfinderData", {_this call FUNC(handleRangeFinderData)}] call EFUNC(common,addEventHandler); ["RangerfinderData", FUNC(handleRangeFinderData)] call EFUNC(common,addEventHandler);

View File

@ -74,13 +74,13 @@ GVAR(menuRun) = true;
GVAR(menuRun) = false; GVAR(menuRun) = false;
[_this select 1] call CBA_fnc_removePerFrameHandler; [_this select 1] call CBA_fnc_removePerFrameHandler;
}; };
if (GVAR(MENU_B)) then { if (GVAR(MENU_B)) then {
GVAR(menu) = "main"; GVAR(menu) = "main";
GVAR(selection) = 0; GVAR(selection) = 0;
GVAR(numSelections) = 5; GVAR(numSelections) = 5;
}; };
if (!GVAR(add) && !GVAR(edit)) then { if (!GVAR(add) && !GVAR(edit)) then {
if (GVAR(DOWN)) then { if (GVAR(DOWN)) then {
GVAR(selection) = (GVAR(numSelections) + GVAR(selection) + 1); GVAR(selection) = (GVAR(numSelections) + GVAR(selection) + 1);
@ -90,7 +90,7 @@ GVAR(menuRun) = true;
}; };
GVAR(selection) = if (GVAR(numSelections) > 0) then { GVAR(selection) % GVAR(numSelections) } else { 0 }; GVAR(selection) = if (GVAR(numSelections) > 0) then { GVAR(selection) % GVAR(numSelections) } else { 0 };
}; };
if (GVAR(LEFT)) then { if (GVAR(LEFT)) then {
GVAR(pointer) = (8 + GVAR(pointer) - 1); GVAR(pointer) = (8 + GVAR(pointer) - 1);
}; };
@ -98,7 +98,7 @@ GVAR(menuRun) = true;
GVAR(pointer) = (8 + GVAR(pointer) + 1); GVAR(pointer) = (8 + GVAR(pointer) + 1);
}; };
GVAR(pointer) = GVAR(pointer) % 8; GVAR(pointer) = GVAR(pointer) % 8;
(__dsp displayCtrl __PSelection1) ctrlSetText ""; (__dsp displayCtrl __PSelection1) ctrlSetText "";
(__dsp displayCtrl __PSelection2) ctrlSetText ""; (__dsp displayCtrl __PSelection2) ctrlSetText "";
(__dsp displayCtrl __PSelection3) ctrlSetText ""; (__dsp displayCtrl __PSelection3) ctrlSetText "";
@ -113,7 +113,7 @@ GVAR(menuRun) = true;
(__dsp displayCtrl __Selection2) ctrlSetText ""; (__dsp displayCtrl __Selection2) ctrlSetText "";
(__dsp displayCtrl __Selection3) ctrlSetText ""; (__dsp displayCtrl __Selection3) ctrlSetText "";
(__dsp displayCtrl __Selection4) ctrlSetText ""; (__dsp displayCtrl __Selection4) ctrlSetText "";
(__dsp displayCtrl __F1) ctrlSetText ""; (__dsp displayCtrl __F1) ctrlSetText "";
(__dsp displayCtrl __F2) ctrlSetText ""; (__dsp displayCtrl __F2) ctrlSetText "";
(__dsp displayCtrl __F3) ctrlSetText ""; (__dsp displayCtrl __F3) ctrlSetText "";
@ -124,7 +124,7 @@ GVAR(menuRun) = true;
(__dsp displayCtrl __Option2) ctrlSetText ""; (__dsp displayCtrl __Option2) ctrlSetText "";
(__dsp displayCtrl __Option3) ctrlSetText ""; (__dsp displayCtrl __Option3) ctrlSetText "";
(__dsp displayCtrl __Option4) ctrlSetText ""; (__dsp displayCtrl __Option4) ctrlSetText "";
switch (GVAR(menu)) do { switch (GVAR(menu)) do {
case "main": { case "main": {
if (GVAR(SEL)) then { if (GVAR(SEL)) then {
@ -500,7 +500,7 @@ GVAR(menuRun) = true;
case 6: { GVAR(digit6) = (10 + GVAR(digit6) - 1) % 10 }; case 6: { GVAR(digit6) = (10 + GVAR(digit6) - 1) % 10 };
case 7: { GVAR(digit7) = (10 + GVAR(digit7) - 1) % 10 }; case 7: { GVAR(digit7) = (10 + GVAR(digit7) - 1) % 10 };
case 8: { GVAR(digit8) = (10 + GVAR(digit8) - 1) % 10 }; case 8: { GVAR(digit8) = (10 + GVAR(digit8) - 1) % 10 };
}; };
}; };
}; };
}; };
@ -590,7 +590,7 @@ GVAR(menuRun) = true;
}; };
}; };
}; };
if (!GVAR(busy)) then { if (!GVAR(busy)) then {
GVAR(F3) = false; GVAR(F3) = false;
GVAR(F2) = false; GVAR(F2) = false;

View File

@ -31,18 +31,19 @@ if (GVAR(outputPFH) != -1) exitWith {};
GVAR(outputPFH) = [{ GVAR(outputPFH) = [{
private["_dagrElevation", "_dagrGrid", "_dagrHeading", "_dagrSpeed", "_dagrTime", "_elevation", "_gridArray", "_speed"]; private["_dagrElevation", "_dagrGrid", "_dagrHeading", "_dagrSpeed", "_dagrTime", "_elevation", "_gridArray", "_speed"];
// Abort Condition // Abort Condition
if !(GVAR(run) && [ACE_player, "ACE_DAGR"] call EFUNC(common,hasItem)) exitWith { if !(GVAR(run) && [ACE_player, "ACE_DAGR"] call EFUNC(common,hasItem)) exitWith {
GVAR(outputPFH) = -1; GVAR(outputPFH) = -1;
135471 cutText ["", "PLAIN"]; 135471 cutText ["", "PLAIN"];
[_this select 1] call CBA_fnc_removePerFrameHandler; [_this select 1] call CBA_fnc_removePerFrameHandler;
}; };
// GRID // GRID
_gridArray = [(getPos ACE_player), false] call EFUNC(common,getMapGridFromPos); _gridArray = [(getPos ACE_player), false] call EFUNC(common,getMapGridFromPos);
_dagrGrid = format ["%1 %2", ((_gridArray select 0) select [0,4]), ((_gridArray select 1) select [0,4])]; _gridArray params ["_gridArrayX","_gridArrayY"];
_dagrGrid = format ["%1 %2", ((_gridArrayX) select [0,4]), ((_gridArrayY) select [0,4])];
// SPEED // SPEED
_speed = speed (vehicle ACE_player); _speed = speed (vehicle ACE_player);
_speed = floor (_speed * 10) / 10; _speed = floor (_speed * 10) / 10;
@ -68,7 +69,7 @@ GVAR(outputPFH) = [{
__gridControl ctrlSetText format ["%1", _dagrGrid]; __gridControl ctrlSetText format ["%1", _dagrGrid];
__speedControl ctrlSetText format ["%1", _dagrSpeed]; __speedControl ctrlSetText format ["%1", _dagrSpeed];
__elevationControl ctrlSetText format ["%1", _dagrElevation]; __elevationControl ctrlSetText format ["%1", _dagrElevation];
__headingControl ctrlSetText (if (!GVAR(useDegrees)) then { format ["%1", _dagrHeading] } else { format ["%1 °", _dagrHeading] }); __headingControl ctrlSetText (if (!GVAR(useDegrees)) then { format ["%1", _dagrHeading] } else { format ["%1 <EFBFBD>", _dagrHeading] });
__timeControl ctrlSetText format ["%1", _dagrTime]; __timeControl ctrlSetText format ["%1", _dagrTime];
}, GVAR(updateInterval), []] call CBA_fnc_addPerFrameHandler; }, GVAR(updateInterval), []] call CBA_fnc_addPerFrameHandler;

View File

@ -14,7 +14,7 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_pos", "_xGrid", "_yGrid", "_dagrGrid", "_bearing", "_dagrDist", "_dagrElevation", "_dagrTime", "_elevation", "_xCoord", "_yCoord"]; private ["_xGrid", "_yGrid", "_dagrGrid", "_bearing", "_dagrDist", "_dagrElevation", "_dagrTime", "_elevation", "_xCoord", "_yCoord"];
135471 cutRsc ["DAGR_DISPLAY", "plain down"]; 135471 cutRsc ["DAGR_DISPLAY", "plain down"];
@ -30,15 +30,14 @@ private ["_pos", "_xGrid", "_yGrid", "_dagrGrid", "_bearing", "_dagrDist", "_dag
__background ctrlSetText QUOTE(PATHTOF(UI\dagr_vector.paa)); __background ctrlSetText QUOTE(PATHTOF(UI\dagr_vector.paa));
if (GVAR(noVectorData)) exitwith {}; if (GVAR(noVectorData)) exitwith {};
GVAR(LAZPOS) params ["_lazPosX", "_lazPosY", "_lazPosZ"];
_pos = [GVAR(LAZPOS) select 0, GVAR(LAZPOS) select 1];
// Incase grids go neg due to 99-00 boundry // Incase grids go neg due to 99-00 boundry
if (_pos select 0 < 0) then {_pos set [0, (_pos select 0) + 99999];}; if (_lazPosX < 0) then { _lazPosX = _lazPosX + 99999;};
if (_pos select 1 < 0) then {_pos set [1, (_pos select 1) + 99999];}; if (_lazPosY < 0) then {_lazPosY = _lazPosY + 99999;};
// Find laser position // Find laser position
_xGrid = toArray Str(round(_pos select 0)); _xGrid = toArray Str(round _lazPosX);
while {count _xGrid < 5} do { while {count _xGrid < 5} do {
_xGrid = [48] + _xGrid; _xGrid = [48] + _xGrid;
@ -47,7 +46,7 @@ _xGrid resize 4;
_xGrid = toString _xGrid; _xGrid = toString _xGrid;
_xGrid = parseNumber _xGrid; _xGrid = parseNumber _xGrid;
_yGrid = toArray Str(round(_pos select 1)); _yGrid = toArray Str(round _lazPosY);
while {count _yGrid < 5} do { while {count _yGrid < 5} do {
_yGrid = [48] + _yGrid; _yGrid = [48] + _yGrid;
}; };
@ -72,7 +71,7 @@ _yCoord = switch true do {
_dagrGrid = _xCoord + " " + _yCoord; _dagrGrid = _xCoord + " " + _yCoord;
// Find target elevation // Find target elevation
_elevation = floor ((GVAR(LAZPOS) select 2) + EGVAR(common,mapAltitude)); _elevation = floor (_lazPosZ) + EGVAR(common,mapAltitude));
_dagrElevation = str _elevation + "m"; _dagrElevation = str _elevation + "m";
// Time // Time
@ -94,5 +93,5 @@ GVAR(vectorGrid) = _dagrGrid;
__gridControl ctrlSetText format ["%1", _dagrGrid]; __gridControl ctrlSetText format ["%1", _dagrGrid];
__speedControl ctrlSetText format ["%1", _dagrDist]; __speedControl ctrlSetText format ["%1", _dagrDist];
__elevationControl ctrlSetText format ["%1", _dagrElevation]; __elevationControl ctrlSetText format ["%1", _dagrElevation];
__headingControl ctrlSetText (if (!GVAR(useDegrees)) then { format ["%1", _bearing] } else { format ["%1°", _bearing] }); __headingControl ctrlSetText (if (!GVAR(useDegrees)) then { format ["%1", _bearing] } else { format ["%1<EFBFBD>", _bearing] });
__timeControl ctrlSetText format ["%1", _dagrTime]; __timeControl ctrlSetText format ["%1", _dagrTime];

View File

@ -31,22 +31,23 @@ if (GVAR(outputPFH) != -1) exitWith {};
GVAR(outputPFH) = [{ GVAR(outputPFH) = [{
private["_MYpos", "_WPpos", "_bearing", "_dagrDistance", "_dagrGrid", "_dagrHeading", "_distance", "_gridArray"]; private["_MYpos", "_WPpos", "_bearing", "_dagrDistance", "_dagrGrid", "_dagrHeading", "_distance", "_gridArray"];
// Abort Condition // Abort Condition
if !(GVAR(run) && [ACE_player, "ACE_DAGR"] call EFUNC(common,hasItem)) exitWith { if !(GVAR(run) && [ACE_player, "ACE_DAGR"] call EFUNC(common,hasItem)) exitWith {
GVAR(outputPFH) = -1; GVAR(outputPFH) = -1;
135471 cutText ["", "PLAIN"]; 135471 cutText ["", "PLAIN"];
[_this select 1] call CBA_fnc_removePerFrameHandler; [_this select 1] call CBA_fnc_removePerFrameHandler;
}; };
// GRID // GRID
_gridArray = [(getPos ACE_player), false] call EFUNC(common,getMapGridFromPos); _gridArray = [(getPos ACE_player), false] call EFUNC(common,getMapGridFromPos);
_dagrGrid = format ["%1 %2", ((_gridArray select 0) select [0,4]), ((_gridArray select 1) select [0,4])]; _gridArray params ["_gridArrayX","_gridArrayY"];
_dagrGrid = format ["%1 %2", (_gridArrayX select [0,4]), (_gridArrayY select [0,4])];
// WP Grid // WP Grid
_xGrid2 = floor (DAGR_WP_INFO / 10000); _xGrid2 = floor (DAGR_WP_INFO / 10000);
_yGrid2 = DAGR_WP_INFO - _xGrid2 * 10000; _yGrid2 = DAGR_WP_INFO - _xGrid2 * 10000;
_xCoord2 = switch true do { _xCoord2 = switch true do {
case (_xGrid2 >= 1000): { "" + Str(_xGrid2) }; case (_xGrid2 >= 1000): { "" + Str(_xGrid2) };
case (_xGrid2 >= 100): { "0" + Str(_xGrid2) }; case (_xGrid2 >= 100): { "0" + Str(_xGrid2) };
@ -60,7 +61,7 @@ GVAR(outputPFH) = [{
case (_yGrid2 >= 10): { "00" + Str(_yGrid2) }; case (_yGrid2 >= 10): { "00" + Str(_yGrid2) };
default { "000" + Str(_yGrid2) }; default { "000" + Str(_yGrid2) };
}; };
_dagrGrid2 = _xCoord2 + " " + _yCoord2; _dagrGrid2 = _xCoord2 + " " + _yCoord2;
// Distance // Distance
@ -69,7 +70,7 @@ GVAR(outputPFH) = [{
_distance = _MYpos distance _WPpos; _distance = _MYpos distance _WPpos;
_distance = floor (_distance * 10) / 10; _distance = floor (_distance * 10) / 10;
_dagrDistance = str _distance + "m"; _dagrDistance = str _distance + "m";
// Heading // Heading
_dagrHeading = floor (if (GVAR(useDegrees)) then { _dagrHeading = floor (if (GVAR(useDegrees)) then {
direction (vehicle ACE_player) direction (vehicle ACE_player)
@ -79,12 +80,12 @@ GVAR(outputPFH) = [{
// WP Heading // WP Heading
_bearing = floor ((_WPpos vectorDiff _MYpos) call CBA_fnc_vectDir); _bearing = floor ((_WPpos vectorDiff _MYpos) call CBA_fnc_vectDir);
// Output // Output
__gridControl ctrlSetText format ["%1", _dagrGrid]; __gridControl ctrlSetText format ["%1", _dagrGrid];
__speedControl ctrlSetText format ["%1", _bearing]; __speedControl ctrlSetText format ["%1", _bearing];
__elevationControl ctrlSetText format ["%1", _dagrGrid2]; __elevationControl ctrlSetText format ["%1", _dagrGrid2];
__headingControl ctrlSetText (if (!GVAR(useDegrees)) then { format ["%1", _dagrHeading] } else { format ["%1°", _dagrHeading] }); __headingControl ctrlSetText (if (!GVAR(useDegrees)) then { format ["%1", _dagrHeading] } else { format ["%1<EFBFBD>", _dagrHeading] });
__timeControl ctrlSetText format ["%1", _dagrDistance]; __timeControl ctrlSetText format ["%1", _dagrDistance];
}, GVAR(updateInterval), []] call CBA_fnc_addPerFrameHandler; }, GVAR(updateInterval), []] call CBA_fnc_addPerFrameHandler;

View File

@ -23,11 +23,12 @@ if (GVAR(run)) then {
}; };
GVAR(hidden) = true; GVAR(hidden) = true;
[{ [{
EXPLODE_1_PVT(_this select 0,_vehicle); params ["_args", "_idPFH"];
_args params ["_vehicle"];
if (!GVAR(run) || (!alive ACE_player) || (vehicle ACE_player != _vehicle)) exitWith { if (!GVAR(run) || (!alive ACE_player) || (vehicle ACE_player != _vehicle)) exitWith {
GVAR(run) = false; GVAR(run) = false;
135471 cutText ["", "PLAIN"]; 135471 cutText ["", "PLAIN"];
[_this select 1] call CBA_fnc_removePerFrameHandler; [_idPFH] call CBA_fnc_removePerFrameHandler;
}; };
if (cameraView == "GUNNER") then { if (cameraView == "GUNNER") then {
if (!GVAR(hidden)) then { if (!GVAR(hidden)) then {