Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more params to notify function #1146

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 25 additions & 21 deletions addons/ui/fnc_notify.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ Description:
Display a text message. Multiple incoming messages are queued.

Parameters:
_content - ARRAY
_line1 - ARRAY
_line2 - ARRAY
_content - ARRAY
_line1 - ARRAY
_line2 - ARRAY
...
_lineN - ARRAY
_text - STRING, NUMBER: Text to display or path to .paa or .jpg image.
_size - NUMBER: Text or image size multiplier, optional, default: 1
_color - ARRAY: RGB or RGBA color (range 0-1), optional, default: [1,1,1,1]
_lineN - ARRAY
_text - STRING, NUMBER: Text to display or path to .paa or .jpg image.
_size - NUMBER: Text or image size multiplier, optional, default: 1
_color - ARRAY: RGB or RGBA color (range 0-1), optional, default: [1,1,1,1]
_queue - BOOL: Defines if the notify will be queued or force shown, optional, default: true (queued)
_lifetime - NUMBER: Defines the lifetime of the notify, optional, default: 4

Examples:
(begin example)
["Banana", 1.5, [1, 1, 0, 1]] call CBA_fnc_notify;
[["Banana", 1.5, [1, 1, 0, 1]], false] call CBA_fnc_notify;
(end)

Returns:
Expand All @@ -27,7 +29,12 @@ Authors:
commy2
---------------------------------------------------------------------------- */

#define LIFE_TIME 4
params [
["_content", [], [[]]],
["_queue", true, [false]],
["_lifetime", 4, [0]]
];

#define FADE_IN_TIME 0.2
#define FADE_OUT_TIME 1

Expand All @@ -37,15 +44,6 @@ if (canSuspend) exitWith {

if (!hasInterface) exitWith {};

// compose structured text
if !(_this isEqualType []) then {
_this = [_this];
};

if !(_this select 0 isEqualType []) then {
_this = [_this];
};

private _composition = [];

{
Expand Down Expand Up @@ -73,7 +71,7 @@ private _composition = [];
} else {
_composition pushBack parseText format ["<t align='center' size='%2' color='%3'>%1</t>", _text, _size, _color];
};
} forEach _this;
} forEach _content;

_composition deleteAt 0;

Expand All @@ -82,7 +80,13 @@ if (isNil QGVAR(notifyQueue)) then {
GVAR(notifyQueue) = [];
};

GVAR(notifyQueue) pushBack _composition;
if (_queue) then {
// if queue param is true add the notify to the queue
GVAR(notifyQueue) pushBack _composition;
} else {
// otherwise reset the queue to force show the notify
GVAR(notifyQueue) = [];
};

private _fnc_processQueue = {
private _composition = _this;
Expand Down Expand Up @@ -172,7 +176,7 @@ private _fnc_processQueue = {
_x ctrlCommit (FADE_OUT_TIME);
} forEach _controls;
};
}, [_controls, _fnc_processQueue], LIFE_TIME] call CBA_fnc_waitAndExecute;
}, [_controls, _fnc_processQueue], _lifetime] call CBA_fnc_waitAndExecute;
};

if (count GVAR(notifyQueue) isEqualTo 1) then {
Expand Down