Skip to content

Commit

Permalink
implement day/night backgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
McDiod committed May 10, 2017
1 parent 027cb8f commit bff8828
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 17 deletions.
1 change: 1 addition & 0 deletions cfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class grad_gpsTracker {
class openTitle {};
class setTarget {};
class updateArrow {};
class updateBackground {};
class updateReception {};
};
};
Binary file renamed data/tracker_bg.paa → data/tracker_bg_day.paa
Binary file not shown.
Binary file added data/tracker_bg_night.paa
Binary file not shown.
7 changes: 6 additions & 1 deletion functions/fn_addPFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ params ["_updateInterval"];

[{
params ["_args","_handle"];
_args params ["_updateInterval","_display","_arrowCtrl","_receptionCtrl","_receptionCode"];
_args params ["_updateInterval","_display","_arrowCtrl","_receptionCtrl","_bgDayCtrl","_receptionCode"];

if (isNull _display) exitWith {[_handle] call CBA_fnc_removePerFrameHandler};

_reception = [player,grad_gpsTracker_currentTarget,_updateInterval,_receptionCtrl,_receptionCode] call grad_gpsTracker_fnc_updateReception;
[player,grad_gpsTracker_currentTarget,_arrowCtrl,_reception] call grad_gpsTracker_fnc_updateArrow;


if (CBA_missionTime - grad_gpsTracker_lastBgUpdateTime > 10) then {
[_bgDayCtrl] call grad_gpsTracker_fnc_updateBackground;
grad_gpsTracker_lastBgUpdateTime = CBA_missionTime;
};
} , _updateInterval, _this] call CBA_fnc_addPerFrameHandler;
27 changes: 17 additions & 10 deletions functions/fn_createGPS.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,31 @@ _ctrlGroup ctrlSetPosition [_offsetX * SZW(120) - _totalW,_offsetY * SZH(80) - _
_ctrlGroup ctrlSetFade 1;
_ctrlGroup ctrlCommit 0;

[{ctrlCommitted _this}, {
_this ctrlSetFade 0;
_this ctrlCommit 0.5;
}, _ctrlGroup] call CBA_fnc_waitUntilAndExecute;
private _backgroundNight = _display ctrlCreate ["RscPicture",-1,_ctrlGroup];
_backgroundNight ctrlSetText (grad_gpsTracker_moduleRoot + "\data\tracker_bg_night.paa");
_backgroundNight ctrlSetPosition [0,0,_totalW,_totalH];
_backgroundNight ctrlCommit 0;

private _background = _display ctrlCreate ["RscPicture",-1,_ctrlGroup];
_background ctrlSetText (grad_gpsTracker_moduleRoot + "\data\tracker_bg.paa");
_background ctrlSetPosition [0,0,_totalW,_totalH];
_background ctrlCommit 0;
private _backgroundDay = _display ctrlCreate ["RscPicture",-1,_ctrlGroup];
_backgroundDay ctrlSetTextColor [1,1,1,1];
_backgroundDay ctrlSetText (grad_gpsTracker_moduleRoot + "\data\tracker_bg_day.paa");
_backgroundDay ctrlSetPosition [0,0,_totalW,_totalH];
_backgroundDay ctrlCommit 0;

private _receptionCtrl = _display ctrlCreate ["RscPicture",-1,_ctrlGroup];
_receptionCtrl ctrlSetText (grad_gpsTracker_moduleRoot + "\data\tracker_0.paa");
_receptionCtrl ctrlSetPosition [_size * SZW(14),_size * SZH(10.4),_size * SZW(4),_size * SZH(4)];
_receptionCtrl ctrlSetPosition [_size * SZW(12.6),_size * SZH(10.4),_size * SZW(4),_size * SZH(4)];
_receptionCtrl ctrlCommit 0;

private _arrowCtrl = _display ctrlCreate ["RscPicture",-1,_ctrlGroup];
_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;

[_ctrlGroup,_arrowCtrl,_receptionCtrl]
[{ctrlCommitted (_this select 0)}, {
params ["_arrowCtrl","_ctrlGroup"];
_ctrlGroup ctrlSetFade 0;
_ctrlGroup ctrlCommit 0.5;
}, [_arrowCtrl,_ctrlGroup]] call CBA_fnc_waitUntilAndExecute;

[_ctrlGroup,_arrowCtrl,_receptionCtrl,_backgroundDay]
2 changes: 2 additions & 0 deletions functions/fn_initModule.sqf
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "..\component.hpp"

grad_gpsTracker_lastBgUpdateTime = 0;

grad_gpsTracker_moduleRoot = [] call grad_gpsTracker_fnc_getModuleRoot;
[] call grad_gpsTracker_fnc_setTarget;
4 changes: 2 additions & 2 deletions functions/fn_openDialog.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ if (!isNil "_target") then {[_target] call grad_gpsTracker_fnc_setTarget};
_display = (findDisplay 46) createDisplay "RscDisplayEmpty";

_components = [_display,_size,_offsetX,_offsetY] call grad_gpsTracker_fnc_createGPS;
_components params ["_ctrlGroup","_arrowCtrl","_receptionCtrl"];
_components params ["_ctrlGroup","_arrowCtrl","_receptionCtrl","_bgDayCtrl"];

[_updateInterval,_display,_arrowCtrl,_receptionCtrl,_receptionCode] call grad_gpsTracker_fnc_addPFH;
[_updateInterval,_display,_arrowCtrl,_receptionCtrl,_bgDayCtrl,_receptionCode] call grad_gpsTracker_fnc_addPFH;

_display
4 changes: 2 additions & 2 deletions functions/fn_openTitle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
_display = uiNamespace getVariable ["RscTitleDisplayEmpty",displayNull];

_components = [_display,_size,_offsetX,_offsetY] call grad_gpsTracker_fnc_createGPS;
_components params ["_ctrlGroup","_arrowCtrl","_receptionCtrl"];
_components params ["_ctrlGroup","_arrowCtrl","_receptionCtrl","_bgDayCtrl"];

[_updateInterval,_display,_arrowCtrl,_receptionCtrl,_receptionCode] call grad_gpsTracker_fnc_addPFH;
[_updateInterval,_display,_arrowCtrl,_receptionCtrl,_bgDayCtrl,_receptionCode] call grad_gpsTracker_fnc_addPFH;

if (_duration > 0) then {
[grad_gpsTracker_fnc_closeTitle,[],_duration] call CBA_fnc_waitAndExecute;
Expand Down
5 changes: 5 additions & 0 deletions functions/fn_updateBackground.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "..\component.hpp"

params ["_bg"];

_bg ctrlSetTextColor [1,1,1,-0.8 + 1.8 * sunOrMoon];
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"name": "grad-gpstracker",
"description": "GPS Tracker dialog with a basic API.",
"version": "0.0.4",
"author": "McDiod"
"version": "0.1.0",
"contributors": [
{
"name": "nomisum"
},
{
"name": "McDiod"
}
]
}

0 comments on commit bff8828

Please sign in to comment.