Skip to content

Commit

Permalink
Fixed issue with notification system upon marker creation
Browse files Browse the repository at this point in the history
Added variable message decay to notification system
  • Loading branch information
nsgundy committed May 31, 2015
1 parent 917319e commit 4bca25e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
10 changes: 6 additions & 4 deletions @cTab/addons/cTab/functions/fn_addNotification.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,37 @@
* Arguments:
* 0: App ID <STRING>
* 1: Notification <STRING>
* 2: Decay time in seconds <INTEGER>
*
* Return Value:
* TRUE <BOOL>
*
* Example:
* [_appID,"This is a notification"] call cTab_fnc_addNotification;
* [_appID,"This is a notification",5] call cTab_fnc_addNotification;
*
* Public: No
*/

private ["_appID","_notification","_time","_done"];
private ["_appID","_notification","_time","_done","_decayTime"];

_appID = _this select 0;
_notification = _this select 1;
_decayTime = _this select 2;
_time = [] call cTab_fnc_currentTime;
_done = false;

// search for other _appID notifications
{
// if we find one, override it and increase the counter
if ((_x select 0) isEqualTo _appID) exitWith {
cTabNotificationCache set [_forEachIndex,[_appID,_time,_notification,(_x select 3) + 1]];
cTabNotificationCache set [_forEachIndex,[_appID,_time,_notification,_decayTime,(_x select 4) + 1]];
_done = true;
};
} forEach cTabNotificationCache;

// if we haven't added the notification to the cache above, do it now
if !(_done) then {
cTabNotificationCache pushBack [_appID,_time,_notification,1];
cTabNotificationCache pushBack [_appID,_time,_notification,_decayTime,1];
};

[] call cTab_fnc_processNotifications;
Expand Down
12 changes: 8 additions & 4 deletions @cTab/addons/cTab/functions/fn_addUserMarker.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ call {
// If this was run on a client-server (i.e. in single player or locally hosted), update the marker list
if (hasInterface && {_encryptionKey == call cTab_fnc_getPlayerEncryptionKey}) then {
call cTab_fnc_updateUserMarkerList;
["BFT","Marker added succesfully"] call cTab_fnc_addNotification;
if ((_markerData select 5) != cTab_player) then {
["BFT",format ["New marker at #%1",mapGridPosition (_markerData select 0)],20] call cTab_fnc_addNotification;
} else {
["BFT","Marker added succesfully",3] call cTab_fnc_addNotification;
};
};
};
};
Expand All @@ -68,10 +72,10 @@ call {
call cTab_fnc_updateUserMarkerList;

// add notification if marker was issued by someone else
if ((_markerData select 5) != cTab_player) then {
["BFT",format ["New marker at #%1",mapGridPosition _markerData select 0]] call cTab_fnc_addNotification;
if ((_markerData select 1 select 5) != cTab_player) then {
["BFT",format ["New marker at #%1",mapGridPosition (_markerData select 1 select 0)],20] call cTab_fnc_addNotification;
} else {
["BFT","Marker added succesfully"] call cTab_fnc_addNotification;
["BFT","Marker added succesfully",3] call cTab_fnc_addNotification;
};
};
};
Expand Down
16 changes: 8 additions & 8 deletions @cTab/addons/cTab/functions/fn_processNotifications.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "\cTab\shared\cTab_gui_macros.hpp"

private ["_displayName","_display","_ctrl","_currentTime","_text","_notification"];
private ["_displayName","_display","_ctrl","_currentTime","_text","_notification","_decayTime"];

// make sure there is no PFH already, the interface is open and notifications are available
if (isNil "cTabProcessNotificationsPFH" && !(isNil "cTabIfOpen") && count cTabNotificationCache != 0) then {
Expand All @@ -36,17 +36,17 @@ if (isNil "cTabProcessNotificationsPFH" && !(isNil "cTabIfOpen") && count cTabNo
if (count cTabNotificationCache != 0) then {
// grab and delete the oldest notification
_notification = cTabNotificationCache deleteAt 0;

_decayTime = _notification select 3;
_currentTime = [] call cTab_fnc_currentTime;
// see if notification was issued in the same minute, if so, omit showing the time
if (_currentTime isEqualTo (_notification select 1)) then {
_text = format ["%1",_notification select 2];
_text = if (_currentTime isEqualTo (_notification select 1)) then {
format ["%1",_notification select 2];
} else {
_text = format ["%1: %2",_notification select 1,_notification select 2];
format ["%1: %2",_notification select 1,_notification select 2];
};
// if the counter on the notification is greater than 1, append the counter to the notification text
if ((_notification select 3) > 1) then {
_text = format ["%1 (x%2)",_text,_notification select 3];
if ((_notification select 4) > 1) then {
_text = format ["%1 (x%2)",_text,_notification select 4];
};

// show the notification
Expand All @@ -64,7 +64,7 @@ if (isNil "cTabProcessNotificationsPFH" && !(isNil "cTabIfOpen") && count cTabNo

// make the control fade out
_ctrl ctrlSetFade 1;
_ctrl ctrlCommit 5;
_ctrl ctrlCommit _decayTime;
} else {
[_this select 1] call CBA_fnc_removePerFrameHandler;
_ctrl ctrlShow false;
Expand Down
4 changes: 2 additions & 2 deletions @cTab/addons/cTab/functions/fn_remoteControlUav.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ if (UAVControl cTabActUav select 1 != "GUNNER") then {
};
} else {
// show notification
["UAV","No gunner optics available"] call cTab_fnc_addNotification;
["UAV","No gunner optics available",5] call cTab_fnc_addNotification;
};
} else {
// show notification
["UAV","Another user has control"]call cTab_fnc_addNotification;
["UAV","Another user has control",5] call cTab_fnc_addNotification;
};

true
4 changes: 2 additions & 2 deletions @cTab/addons/cTab/player_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ cTab_msg_Send = {
};

// add a notification
["MSG","Message sent successfully"] call cTab_fnc_addNotification;
["MSG","Message sent successfully",3] call cTab_fnc_addNotification;
playSound "cTab_mailSent";
// remove message body
_msgBodyctrl ctrlSetText "";
Expand Down Expand Up @@ -1132,7 +1132,7 @@ cTab_msg_Send = {
_nop = [] call cTab_msg_gui_load;

// add a notification
["MSG",format ["New message from %1",name _sender]] call cTab_fnc_addNotification;
["MSG",format ["New message from %1",name _sender],6] call cTab_fnc_addNotification;
} else {
cTabRscLayerMailNotification cutRsc ["cTab_Mail_ico_disp", "PLAIN"]; //show
};
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ this setVariable ["cTab_groupId","Fox",true];
Changelog
---------
### 2.2.1 ###
* Added variable message decay to notification system (new-marker notifications are now shown for longer)
* Fixed error regarding the helmet cam icon when looking at a cTab-box placed with Zeus
* Fixed issue with notification system upon marker creation
* Marker menu will now stay inside the device screen boundaries
* Moved marker menu above brightness layer to allow it to show tool-tips properly
* Tweaked marker menu size on Android
Expand Down

0 comments on commit 4bca25e

Please sign in to comment.