diff --git a/README.md b/README.md index 046fc46..38958c9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # GRAD GPS Tracker GPS Tracker dialog with a basic API. +![](http://i.imgur.com/aWKas0x.png) ![](http://i.imgur.com/Rn2xKBa.png) + ## Dependencies * [CBA_A3](https://github.com/CBATeam/CBA_A3) @@ -30,15 +32,12 @@ class CfgFunctions { }; ``` -## Pictures - -![](http://i.imgur.com/aWKas0x.png) ![](http://i.imgur.com/Rn2xKBa.png) ## Usage -There are two functions to open the tracker. `grad_gpsTracker_fnc_openTitle` creates a `cutRsc` (this is the function that you want). `grad_gpsTracker_fnc_openDialog` creates and returns a dialog - I don't know why you would want this, but hey it's here. Their parameters are the same. +There are two functions to open the tracker. `grad_gpsTracker_fnc_openTitle` creates a `cutRsc` (this is the function that you want). `grad_gpsTracker_fnc_openDialog` creates and returns a dialog - I don't know why you would want this, but hey it's here. To close the title, use `grad_gpsTracker_fnc_closeTitle`. To close the dialog, use the escape button. Most of their parameters are the same. -`[target,update interval,size,offset X,offset Y,reception code] call grad_gpsTracker_fnc_openTitle` +`[target,update interval,size,offset X,offset Y,reception code,duration] call grad_gpsTracker_fnc_openTitle` Parameter | Explanation ----------------|-------------------------------------------------------------------------------------------------------------------- @@ -48,6 +47,7 @@ size | number (optional) - Size factor for title. Default: 1 offset X | number (optional) - Horizontal offset factor for title. Default: 1 offset Y | number (optional) - Vertical offset factor for title. Default: 1 reception code | code (optional) - Code that returns the reception value. See below. +duration | number (optional) - ONLY `_fnc_openTitle`! Time in seconds after which tracker will automatically be closed. -1 to disable. Default: -1 Example: `[_vehicle2,0.1,1,1.2,1,{_target getVariable ['signalStrength',0]}] call grad_gpsTracker_fnc_openTitle;` diff --git a/functions/fn_closeTitle.sqf b/functions/fn_closeTitle.sqf index 766d855..691e5ef 100644 --- a/functions/fn_closeTitle.sqf +++ b/functions/fn_closeTitle.sqf @@ -1,3 +1,3 @@ #include "..\component.hpp" -"grad_gpsTracker_layer" cutRsc ["RscTitleDisplayEmpty","PLAIN",0,false]; +"grad_gpsTracker_layer" cutFadeout 0.5; diff --git a/functions/fn_createGPS.sqf b/functions/fn_createGPS.sqf index a164b4e..760685c 100644 --- a/functions/fn_createGPS.sqf +++ b/functions/fn_createGPS.sqf @@ -7,8 +7,14 @@ private _totalH = _size * SZH(40); private _ctrlGroup = _display ctrlCreate ["RscControlsGroupNoScrollbars",-1]; _ctrlGroup ctrlSetPosition [_offsetX * SZW(120) - _totalW,_offsetY * SZH(80) - _totalH,_totalW,_totalH]; +_ctrlGroup ctrlSetFade 1; _ctrlGroup ctrlCommit 0; +[{ctrlCommitted _this}, { + _this ctrlSetFade 0; + _this ctrlCommit 0.5; +}, _ctrlGroup] call CBA_fnc_waitUntilAndExecute; + private _background = _display ctrlCreate ["RscPicture",-1,_ctrlGroup]; _background ctrlSetText (grad_gpsTracker_moduleRoot + "\data\tracker_bg.paa"); _background ctrlSetPosition [0,0,_totalW,_totalH]; @@ -24,4 +30,4 @@ _arrowCtrl ctrlSetText (grad_gpsTracker_moduleRoot + "\data\tracker_arrow.paa"); _arrowCtrl ctrlSetPosition [_size * SZW(14.5),_size * SZH(15),_size * SZW(11),_size * SZH(11)]; _arrowCtrl ctrlCommit 0; -[_arrowCtrl,_receptionCtrl] +[_ctrlGroup,_arrowCtrl,_receptionCtrl] diff --git a/functions/fn_openDialog.sqf b/functions/fn_openDialog.sqf index b6008cb..60171c1 100644 --- a/functions/fn_openDialog.sqf +++ b/functions/fn_openDialog.sqf @@ -1,17 +1,13 @@ #include "..\component.hpp" -diag_log "ASDASDASDASD"; - params ["_target",["_updateInterval",0.5],["_size",1],["_offsetX",1],["_offsetY",1],["_receptionCode",{params ["_unit","_target","_updateInterval"]; private _reception = 1 - (_unit distance2D _target)/100; _reception}]]; if (!isNil "_target") then {[_target] call grad_gpsTracker_fnc_setTarget}; _display = (findDisplay 46) createDisplay "RscDisplayEmpty"; -diag_log ["asd",_display]; - _components = [_display,_size,_offsetX,_offsetY] call grad_gpsTracker_fnc_createGPS; -_components params ["_arrowCtrl","_receptionCtrl"]; +_components params ["_ctrlGroup","_arrowCtrl","_receptionCtrl"]; [_updateInterval,_display,_arrowCtrl,_receptionCtrl,_receptionCode] call grad_gpsTracker_fnc_addPFH; diff --git a/functions/fn_openTitle.sqf b/functions/fn_openTitle.sqf index 82718c1..6aac607 100644 --- a/functions/fn_openTitle.sqf +++ b/functions/fn_openTitle.sqf @@ -3,15 +3,18 @@ "grad_gpsTracker_layer" cutRsc ["RscTitleDisplayEmpty","PLAIN",0,false]; [{!isNull (uiNamespace getVariable ["RscTitleDisplayEmpty",displayNull])}, { - params ["_target",["_updateInterval",0.5],["_size",1],["_offsetX",1],["_offsetY",1],["_receptionCode",{params ["_unit","_target","_updateInterval"]; private _reception = 1 - (_unit distance2D _target)/100; _reception}]]; + params ["_target",["_updateInterval",0.5],["_size",1],["_offsetX",1],["_offsetY",1],["_receptionCode",{params ["_unit","_target","_updateInterval"]; private _reception = 1 - (_unit distance2D _target)/100; _reception}],["_duration",-1]]; if (!isNil "_target") then {[_target] call grad_gpsTracker_fnc_setTarget}; _display = uiNamespace getVariable ["RscTitleDisplayEmpty",displayNull]; _components = [_display,_size,_offsetX,_offsetY] call grad_gpsTracker_fnc_createGPS; - _components params ["_arrowCtrl","_receptionCtrl"]; + _components params ["_ctrlGroup","_arrowCtrl","_receptionCtrl"]; [_updateInterval,_display,_arrowCtrl,_receptionCtrl,_receptionCode] call grad_gpsTracker_fnc_addPFH; + if (_duration > 0) then { + [grad_gpsTracker_fnc_closeTitle,[],_duration] call CBA_fnc_waitAndExecute; + }; }, _this] call CBA_fnc_waitUntilAndExecute;