Jump to content
JGames Family

Help with custom notification

Recommended Posts

Hi, i have tried some things but there is no way, i could adjust the strip height to the text but the frame still goes crazy tall and i dont know how to make as tall as the text, here is the script: 

Spoiler

/*

File: fn_notification_system.sqf

Author: TanKode

Author-URI: https://github.com/TanKode

License: MIT

Version: v1.1-dev

Parameter:

0: Text <STRING> text to display in the notification

1: Type <STRING> type of this notification or the colorname or the color as array/object

2: Speed <INTEGER> time in seconds to show this notification

*/

params [

["_text","",[""]],

["_type","default",["",[],{}]],

["_speed",10,[10]]

];

if (isDedicated || !hasInterface) exitWith {};

if(isNil "open_notifications") then {

open_notifications = [];

};

disableSerialization;

_display = findDisplay 46;

 

_alpha = 1;

_colorName = "";

_color = [];

if(typeName _type == "ARRAY" || typeName _type == "OBJECT") then {

_color = _type;

} else {

switch (_type) do {

case "error": {

_colorName = "red";

};

case "aviso": {

_colorName = "amber";

};

case "exito": {

_colorName = "green";

};

case "info": {

_colorName = "blue";

};

default {

_colorName = _type;

};

};

// https://material.io/guidelines/style/color.html

switch (_colorName) do {

case "red": {

_color = [0.957,0.263,0.212,_alpha];

};

case "pink": {

_color = [0.914,0.118,0.388,_alpha];

};

case "purple": {

_color = [0.612,0.153,0.69,_alpha];

};

case "deep-purple": {

_color = [0.404,0.227,0.718,_alpha];

};

case "indigo": {

_color = [0.247,0.318,0.71,_alpha];

};

case "blue": {

_color = [0.129,0.588,0.953,_alpha];

};

case "light-blue": {

_color = [0.012,0.663,0.957,_alpha];

};

case "cyan": {

_color = [0,0.737,0.831,_alpha];

};

case "teal": {

_color = [0,0.588,0.533,_alpha];

};

case "green": {

_color = [0.298,0.686,0.314,_alpha];

};

case "light-green": {

_color = [0.545,0.765,0.29,_alpha];

};

case "lime": {

_color = [0.804,0.863,0.224,_alpha];

};

case "yellow": {

_color = [1,0.922,0.231,_alpha];

};

case "amber": {

_color = [1,0.757,0.027,_alpha];

};

case "orange": {

_color = [1,0.596,0,_alpha];

};

case "deep-orange": {

_color = [1,0.341,0.133,_alpha];

};

case "brown": {

_color = [0.475,0.333,0.282,_alpha];

};

case "grey": {

_color = [0.62,0.62,0.62,_alpha];

};

case "blue-grey": {

_color = [0.376,0.49,0.545,_alpha];

};

default {

_color = [(profileNamespace getvariable ['GUI_BCG_RGB_R',0.3843]),(profileNamespace getvariable ['GUI_BCG_RGB_G',0.7019]),(profileNamespace getvariable ['GUI_BCG_RGB_B',0.8862]),_alpha];

};

};

};

 

if (_text isEqualType "") then {

_text = parseText _text;

};

playSound "HintExpand";

 

_margin = 0.01;

_width = 300 * pixelW;

_borderWidth = 10 * pixelW;

_textWidth = _width - _borderWidth;

_height = 0.01;

_posX = 0;

_posY = 0;

 

_displaySide = "left"; // left or right

if(_displaySide == "left") then {

_posX = _margin + safeZoneX;

} else {

_posX = safeZoneW + safeZoneX - _margin - _width;

};

 

private _BorderCtrl = _display ctrlCreate ["RscText", -1];

_BorderCtrl ctrlSetPosition [_posX, _posY, _borderWidth, _height];

_BorderCtrl ctrlSetBackgroundColor _color;

_BorderCtrl ctrlSetFade 1;

_BorderCtrl ctrlCommit 0;

_BorderCtrl ctrlSetFade 0;

_BorderCtrl ctrlCommit 0.4;

 

private _TextCtrl = _display ctrlCreate ["RscStructuredText", -1];

_TextCtrl ctrlSetStructuredText _text;

_TextCtrl ctrlSetPosition [(_posX + _borderWidth), _posY, _textWidth, _height];

_adjustedHeight = (ctrlTextHeight _TextCtrl);

_TextCtrl ctrlSetPosition [(_posX + _borderWidth), _posY, _textWidth, _adjustedHeight];

_TextCtrl ctrlCommit 0;

_BorderCtrl ctrlSetPosition [_posX, _posY, _borderWidth, _adjustedHeight];

_BorderCtrl ctrlCommit 0;

_TextCtrl ctrlSetBackgroundColor [0.129,0.129,0.129,_alpha];

_TextCtrl ctrlSetFade 1;

_TextCtrl ctrlCommit 0;

_TextCtrl ctrlSetFade 0;

_TextCtrl ctrlCommit 0.4;

 

[_TextCtrl,_BorderCtrl,_speed] spawn {

disableSerialization;

uiSleep (_this select 2);

private _TextCtrl = _this select 0;

private _BorderCtrl = _this select 1;

_TextCtrl ctrlSetFade 1;

_TextCtrl ctrlCommit 0.3;

_BorderCtrl ctrlSetFade 1;

_BorderCtrl ctrlCommit 0.3;

uiSleep 0.3;

ctrlDelete _BorderCtrl;

ctrlDelete _TextCtrl;

};

 

_offsetY = 0;

if (count open_notifications > 0) then {

private _activeNotifications = 0;

{

private _ctrlBorder = _x select 0;

private _ctrlText = _x select 1;

if (!isNull _ctrlBorder && !isNull _ctrlText) then {

_ctrlBorder ctrlSetPosition [_posX, (_posY + _offsetY)];

_ctrlText ctrlSetPosition [(_posX + _borderWidth), (_posY + _offsetY)];

_ctrlBorder ctrlCommit 0.25;

_ctrlText ctrlCommit 0.25;

_offsetY = _offsetY + _margin + ((ctrlPosition _ctrlText) select 3);

if (_activeNotifications > 3) then {

_ctrlText ctrlSetFade 1;

_ctrlText ctrlCommit 0.2;

_ctrlBorder ctrlSetFade 1;

_ctrlBorder ctrlCommit 0.2;

};

};

_activeNotifications = _activeNotifications + 1;

} forEach open_notifications;

};

open_notifications = ([[_BorderCtrl,_TextCtrl]] + open_notifications) select {!isNull (_x select 0) && !isNull (_x select 1)};

 

i wonder if someone can help me... how the prolem looks: 

?imw=1024&imh=576&ima=fit&impolicy=Lette

Share this post


Link to post
Share on other sites

 

Have a look at this. You could either use it as it is or try and learn from it. 

Share this post


Link to post
Share on other sites
On 3/30/2019 at 6:14 PM, beno_83au said:

 

Have a look at this. You could either use it as it is or try and learn from it. 

will try, thanks

Share this post


Link to post
Share on other sites
On 3/30/2019 at 6:14 PM, beno_83au said:

 

Have a look at this. You could either use it as it is or try and learn from it. 

that doesnt has a text legnth system XD, but i will leavi it as irt is... if there is no solution

Share this post


Link to post
Share on other sites
On 3/29/2019 at 2:58 PM, JGames Family said:

_TextCtrl ctrlSetPosition [(_posX + _borderWidth), _posY, _textWidth, _height];
_adjustedHeight = (ctrlTextHeight _TextCtrl);
_TextCtrl ctrlSetPosition [(_posX + _borderWidth), _posY, _textWidth, _adjustedHeight];
_TextCtrl ctrlCommit 0;

 

Before calling the ctrlTextHeight command you have to adjust the width of the control to what you want afterwards. Just add another ctrlCommit before declaring _adjustedHeigth.

Share this post


Link to post
Share on other sites
2 minutes ago, 7erra said:

_TextCtrl ctrlSetPosition [(_posX + _borderWidth), _posY, _textWidth, _height]; 
_TextCtrl ctrlCommit 0; //<-- only this
_adjustedHeight = (ctrlTextHeight _TextCtrl); 
_TextCtrl ctrlSetPosition [(_posX + _borderWidth), _posY, _textWidth, _adjustedHeight];
_TextCtrl ctrlCommit 0;

 

Just this one line should do the trick.

Share this post


Link to post
Share on other sites

_TextCtrl ctrlCommit 0;  just before _adjustedHeight = (ctrlTextHeight _TextCtrl); ?????

4 minutes ago, 7erra said:

Before calling the ctrlTextHeight command you have to adjust the width of the control to what you want afterwards. Just add another ctrlCommit before declaring _adjustedHeigth.

 

Share this post


Link to post
Share on other sites
Just now, 7erra said:

Just this one line should do the trick.

great thanks 😉 will try tomorrow

Share this post


Link to post
Share on other sites
On 3/31/2019 at 11:47 PM, 7erra said:

Just this one line should do the trick.

men u are god, it worked really thanks, i want to ask u another thing, i have now this pronblem: 

 

 

As u can see in the video, when the sencond appear, the 1 stays where he is, and when the 3rd appear, the 1st moves but the second stays. i have tied to put "if (count open_notifications > 1) then {" but didnt work, any solution? Thanks @7erra

Share this post


Link to post
Share on other sites

here is the modified part:

if (count open_notifications > 0) then {
    {
        private _ctrlBorder = _x select 0;
        private _ctrlText = _x select 1;
        if (!isNull _ctrlBorder && !isNull _ctrlText) then {
        	_offsetY = (_foreachindex + 1) * (_margin + ((ctrlPosition _ctrlText) select 3));
            _ctrlBorder ctrlSetPosition [_posX, _posY + _offsetY];
            _ctrlText ctrlSetPosition [_posX + _borderWidth, _posY + _offsetY];
            _ctrlBorder ctrlCommit 0.25;
            _ctrlText ctrlCommit 0.25;
            if (_foreachindex > 3) then {
                _ctrlText ctrlSetFade 1;
                _ctrlText ctrlCommit 0.2;
                _ctrlBorder ctrlSetFade 1;
                _ctrlBorder ctrlCommit 0.2;
            };
        };
    } forEach open_notifications;
};

The magic variable _foreachindex is the current index of the array which is cycled through: https://community.bistudio.com/wiki/Magic_Variables. This saves you the declaring and maintaining of a new variable (_activeNotifications). It has to be incremented by one bc it starts at 0.

Edited by 7erra
code

Share this post


Link to post
Share on other sites
12 minutes ago, 7erra said:

here is the modified part:


if (count open_notifications > 0) then {
    {
        private _ctrlBorder = _x select 0;
        private _ctrlText = _x select 1;
        _offsetY = (_foreachindex + 1) * (_margin + ((ctrlPosition _ctrlText) select 3));
        if (!isNull _ctrlBorder && !isNull _ctrlText) then {
            _ctrlBorder ctrlSetPosition [_posX, _posY + _offsetY];
            _ctrlText ctrlSetPosition [_posX + _borderWidth, _posY + _offsetY];
            _ctrlBorder ctrlCommit 0.25;
            _ctrlText ctrlCommit 0.25;
            if (_foreachindex > 3) then {
                _ctrlText ctrlSetFade 1;
                _ctrlText ctrlCommit 0.2;
                _ctrlBorder ctrlSetFade 1;
                _ctrlBorder ctrlCommit 0.2;
            };
        };
    } forEach open_notifications;
};

The magic variable _foreachindex is the current index of the array which is cycled through: https://community.bistudio.com/wiki/Magic_Variables. This saves you the declaring and maintaining of a new variable (_activeNotifications). It has to be incremented by one bc it starts at 0.

so i just delete the variable line or what can i do? thx. or delete the +1, or put +0... XD 

Share this post


Link to post
Share on other sites

replace the whole if statement with what i posted. btw updated the other post.

Share this post


Link to post
Share on other sites
1 minute ago, 7erra said:

replace the whole if statement with what i posted. btw updated the other post.

oh ok, i see the code is way differnt hahhah, thanks.

Share this post


Link to post
Share on other sites
24 minutes ago, 7erra said:

replace the whole if statement with what i posted. btw updated the other post.

completely fixed men thank ur the best!!!

Share this post


Link to post
Share on other sites

New problems @7erra:

 

 

As u can see there are 2 problems. first:

When there is a little notification on the screen and a tall one appears, it puts over the small one (i think because it dowesnt coun the different height of the norification.

The other one is, as u can see, when i am opening and closing the car, bertween the first and 2nd one there is always a little difference of space.

This is my new code as i have dited de adjusted height and added + 0.035 and that stuff, hoping u can help me, thanks

Spoiler

/*

File: fn_notification_system.sqf

Author: TanKode

Author-URI: https://github.com/TanKode

License: MIT

Version: v1.1-dev

Parameter:

0: Text <STRING> text to display in the notification

1: Type <STRING> type of this notification or the colorname or the color as array/object

2: Speed <INTEGER> time in seconds to show this notification

*/

params [

["_text","",[""]],

["_type","default",["",[],{}]],

["_speed",10,[10]]

];

if (isDedicated || !hasInterface) exitWith {};

if(isNil "open_notifications") then {

open_notifications = [];

};

disableSerialization;

_display = findDisplay 46;

 

_alpha = 1;

_colorName = "";

_color = [];

if(typeName _type == "ARRAY" || typeName _type == "OBJECT") then {

_color = _type;

} else {

switch (_type) do {

case "error": {

_colorName = "red";

};

case "aviso": {

_colorName = "amber";

};

case "exito": {

_colorName = "green";

};

case "info": {

_colorName = "blue";

};

default {

_colorName = _type;

};

};

// https://material.io/guidelines/style/color.html

switch (_colorName) do {

case "red": {

_color = [0.957,0.263,0.212,_alpha];

};

case "pink": {

_color = [0.914,0.118,0.388,_alpha];

};

case "purple": {

_color = [0.612,0.153,0.69,_alpha];

};

case "deep-purple": {

_color = [0.404,0.227,0.718,_alpha];

};

case "indigo": {

_color = [0.247,0.318,0.71,_alpha];

};

case "blue": {

_color = [0.129,0.588,0.953,_alpha];

};

case "light-blue": {

_color = [0.012,0.663,0.957,_alpha];

};

case "cyan": {

_color = [0,0.737,0.831,_alpha];

};

case "teal": {

_color = [0,0.588,0.533,_alpha];

};

case "green": {

_color = [0.298,0.686,0.314,_alpha];

};

case "light-green": {

_color = [0.545,0.765,0.29,_alpha];

};

case "lime": {

_color = [0.804,0.863,0.224,_alpha];

};

case "yellow": {

_color = [1,0.922,0.231,_alpha];

};

case "amber": {

_color = [1,0.757,0.027,_alpha];

};

case "orange": {

_color = [1,0.596,0,_alpha];

};

case "deep-orange": {

_color = [1,0.341,0.133,_alpha];

};

case "brown": {

_color = [0.475,0.333,0.282,_alpha];

};

case "grey": {

_color = [0.62,0.62,0.62,_alpha];

};

case "blue-grey": {

_color = [0.376,0.49,0.545,_alpha];

};

default {

_color = [(profileNamespace getvariable ['GUI_BCG_RGB_R',0.3843]),(profileNamespace getvariable ['GUI_BCG_RGB_G',0.7019]),(profileNamespace getvariable ['GUI_BCG_RGB_B',0.8862]),_alpha];

};

};

};

 

if (_text isEqualType "") then {

_text = parseText _text;

};

playSound "HintExpand";

 

_margin = 0.01;

_width = 300 * pixelW;

_borderWidth = 10 * pixelW;

_textWidth = _width - _borderWidth;

_height = 0.01;

_posX = 0;

_posY = 0;

 

_displaySide = "left"; // left or right

if(_displaySide == "left") then {

_posX = _margin + safeZoneX;

} else {

_posX = safeZoneW + safeZoneX - _margin - _width;

};

 

private _BorderCtrl = _display ctrlCreate ["RscText", -1];

_BorderCtrl ctrlSetBackgroundColor _color;

_BorderCtrl ctrlSetFade 1;

_BorderCtrl ctrlCommit 0;

_BorderCtrl ctrlSetFade 0;

_BorderCtrl ctrlCommit 0.4;

 

private _TextCtrl = _display ctrlCreate ["RscStructuredText", -1];

_TextCtrl ctrlSetStructuredText _text;

_TextCtrl ctrlSetPosition [(_posX + _borderWidth), _posY, _textWidth, _height];

_TextCtrl ctrlCommit 0;

_adjustedHeight = (ctrlTextHeight _TextCtrl) + 0.035;

_TextCtrl ctrlSetPosition [(_posX + _borderWidth), _posY, _textWidth, _adjustedHeight];

_TextCtrl ctrlCommit 0;

_BorderCtrl ctrlSetPosition [_posX, _posY, _borderWidth, _adjustedHeight];

_BorderCtrl ctrlCommit 0;

_TextCtrl ctrlSetBackgroundColor [0.129,0.129,0.129,_alpha];

_TextCtrl ctrlSetFade 1;

_TextCtrl ctrlCommit 0;

_TextCtrl ctrlSetFade 0;

_TextCtrl ctrlCommit 0.4;

 

[_TextCtrl,_BorderCtrl,_speed] spawn {

disableSerialization;

uiSleep (_this select 2);

private _TextCtrl = _this select 0;

private _BorderCtrl = _this select 1;

_TextCtrl ctrlSetFade 1;

_TextCtrl ctrlCommit 0.3;

_BorderCtrl ctrlSetFade 1;

_BorderCtrl ctrlCommit 0.3;

uiSleep 0.3;

ctrlDelete _BorderCtrl;

ctrlDelete _TextCtrl;

};

 

_offsetY = 0;

if (count open_notifications > 0) then {

{

private _ctrlBorder = _x select 0;

private _ctrlText = _x select 1;

_offsetY = (_foreachindex + 1) * (_margin + ((ctrlPosition _ctrlText) select 3));

if (!isNull _ctrlBorder && !isNull _ctrlText) then {

_ctrlBorder ctrlSetPosition [_posX, _posY + _offsetY + 0.035];

_ctrlText ctrlSetPosition [_posX + _borderWidth, _posY + _offsetY + 0.035];

_ctrlBorder ctrlCommit 0.25;

_ctrlText ctrlCommit 0.25;

if (_foreachindex > 3) then {

_ctrlText ctrlSetFade 1;

_ctrlText ctrlCommit 0.2;

_ctrlBorder ctrlSetFade 1;

_ctrlBorder ctrlCommit 0.2;

};

};

} forEach open_notifications;

};

open_notifications = ([[_BorderCtrl,_TextCtrl]] + open_notifications) select {!isNull (_x select 0) && !isNull (_x select 1)};

 

PD: the small space happens with the big ones too.

Thanks.

Share this post


Link to post
Share on other sites

Yeah if you are going to have controls with different heights it's not gonna work anymore. Going back to using a variable which adds the control's height and margin between notifications should work.

Share this post


Link to post
Share on other sites

no idea of how to do it XDD im sorry. if u can at least give me a clue. im sorry.

19 hours ago, 7erra said:

Yeah if you are going to have controls with different heights it's not gonna work anymore. Going back to using a variable which adds the control's height and margin between notifications should work.

 

Share this post


Link to post
Share on other sites
On 4/7/2019 at 11:00 PM, 7erra said:

Yeah if you are going to have controls with different heights it's not gonna work anymore. Going back to using a variable which adds the control's height and margin between notifications should work.

still there?

 

Share this post


Link to post
Share on other sites

There is a new command which will set only one paramter of ctrlSetPosition (ctrlSetPositionX, Y, W, H). Also, changed the initial control creation because after setting the width of the control for the first time it has to be validated with ctrlCommit to give the correct height. Lastly, I've reintroduced the counter which updates with each iteration through the already existing controls array. Just copying it as is should work.

Spoiler

/*
 File: fn_notification_system.sqf
 Author: TanKode
 Author-URI: https://github.com/TanKode
 License: MIT
 Version: v1.1-dev
 Parameter:
 0: Text <STRING> text to display in the notification
 1: Type <STRING> type of this notification or the colorname or the color as array/object
 2: Speed <INTEGER> time in seconds to show this notification
*/
params [
    ["_text","",[""]],
    ["_type","default",["",[],{}]],
    ["_speed",10,[10]]
];
if (isDedicated || !hasInterface) exitWith {};
if(isNil "open_notifications") then {
    open_notifications = [];
};
disableSerialization;
_display = findDisplay 46;

_alpha = 1;
_colorName = "";
_color = [];
if(typeName _type == "ARRAY" || typeName _type == "OBJECT") then {
    _color = _type;
} else {
    switch (_type) do {
        case "error": {
            _colorName = "red";
        };
        case "warning": {
            _colorName = "amber";
        };
        case "success": {
            _colorName = "green";
        };
        case "info": {
            _colorName = "blue";
        };
        default {
            _colorName = _type;
        };
    };
    // https://material.io/guidelines/style/color.html
    switch (_colorName) do {
        case "red": {
            _color = [0.957,0.263,0.212,_alpha];
        };
        case "pink": {
            _color = [0.914,0.118,0.388,_alpha];
        };
        case "purple": {
            _color = [0.612,0.153,0.69,_alpha];
        };
        case "deep-purple": {
            _color = [0.404,0.227,0.718,_alpha];
        };
        case "indigo": {
            _color = [0.247,0.318,0.71,_alpha];
        };
        case "blue": {
            _color = [0.129,0.588,0.953,_alpha];
        };
        case "light-blue": {
            _color = [0.012,0.663,0.957,_alpha];
        };
        case "cyan": {
            _color = [0,0.737,0.831,_alpha];
        };
        case "teal": {
            _color = [0,0.588,0.533,_alpha];
        };
        case "green": {
            _color = [0.298,0.686,0.314,_alpha];
        };
        case "light-green": {
            _color = [0.545,0.765,0.29,_alpha];
        };
        case "lime": {
            _color = [0.804,0.863,0.224,_alpha];
        };
        case "yellow": {
            _color = [1,0.922,0.231,_alpha];
        };
        case "amber": {
            _color = [1,0.757,0.027,_alpha];
        };
        case "orange": {
            _color = [1,0.596,0,_alpha];
        };
        case "deep-orange": {
            _color = [1,0.341,0.133,_alpha];
        };
        case "brown": {
            _color = [0.475,0.333,0.282,_alpha];
        };
        case "grey": {
            _color = [0.62,0.62,0.62,_alpha];
        };
        case "blue-grey": {
            _color = [0.376,0.49,0.545,_alpha];
        };
        default {
            _color = [(profileNamespace getvariable ['GUI_BCG_RGB_R',0.3843]),(profileNamespace getvariable ['GUI_BCG_RGB_G',0.7019]),(profileNamespace getvariable ['GUI_BCG_RGB_B',0.8862]),_alpha];
        };
    };
};

if (_text isEqualType "") then {
    _text = parseText _text;
};
playSound "HintExpand";

_margin = 0.01;
_width = 300 * pixelW;
_borderWidth = 10 * pixelW;
_textWidth = _width - _borderWidth;
_height = 0.01;
_posX = 0;
_posY = 0;

_displaySide = "left"; // left or right
if(_displaySide == "left") then {
    _posX = _margin + safeZoneX;
} else {
    _posX = safeZoneW + safeZoneX - _margin - _width;
};

private _BorderCtrl = _display ctrlCreate ["RscText", -1];
_BorderCtrl ctrlSetPosition [_posX, _posY, _borderWidth, _height];
_BorderCtrl ctrlSetBackgroundColor _color;
_BorderCtrl ctrlSetFade 1;
_BorderCtrl ctrlCommit 0;
_BorderCtrl ctrlSetFade 0;
_BorderCtrl ctrlCommit 0.4;

private _TextCtrl = _display ctrlCreate ["RscStructuredText", -1];
_TextCtrl ctrlSetStructuredText _text;
_TextCtrl ctrlSetPosition [(_posX + _borderWidth), _posY, _textWidth, 10];
_TextCtrl ctrlCommit 0;
_adjustedHeight = (ctrlTextHeight _TextCtrl);
_TextCtrl ctrlSetPositionH _adjustedHeight;
_BorderCtrl ctrlSetPositionH _adjustedHeight;
systemChat str _adjustedHeight;
_BorderCtrl ctrlCommit 0;
_TextCtrl ctrlSetBackgroundColor [0.129,0.129,0.129,_alpha];
_TextCtrl ctrlSetFade 1;
_TextCtrl ctrlCommit 0;
_TextCtrl ctrlSetFade 0;
_TextCtrl ctrlCommit 0.4;

[_TextCtrl,_BorderCtrl,_speed] spawn {
    disableSerialization;
    uiSleep (_this select 2);
    private _TextCtrl = _this select 0;
    private _BorderCtrl = _this select 1;
    _TextCtrl ctrlSetFade 1;
    _TextCtrl ctrlCommit 0.3;
    _BorderCtrl ctrlSetFade 1;
    _BorderCtrl ctrlCommit 0.3;
    uiSleep 0.3;
    ctrlDelete _BorderCtrl;
    ctrlDelete _TextCtrl;
};

_nextY = ctrlTextHeight _TextCtrl + _margin;
if (count open_notifications > 0) then {
    {
        private _ctrlBorder = _x select 0;
        private _ctrlText = _x select 1;
        _offsetY = (_foreachindex + 1) * (_margin + ((ctrlPosition _ctrlText) select 3));
        if (!isNull _ctrlBorder && !isNull _ctrlText) then {
            {_x ctrlSetPositionY _nextY; _x ctrlCommit 0.25;} forEach _x;
            if (_foreachindex > 3) then {
                _ctrlText ctrlSetFade 1;
                _ctrlText ctrlCommit 0.2;
                _ctrlBorder ctrlSetFade 1;
                _ctrlBorder ctrlCommit 0.2;
            };
            _nextY = _nextY + ctrlTextHeight _ctrlText + _margin;
        };
    } forEach open_notifications;
};
open_notifications = ([[_BorderCtrl,_TextCtrl]] + open_notifications) select {!isNull (_x select 0) && !isNull (_x select 1)};

 

 

Tested with the following function from debug console:

[]spawn {
  for "_i" from 0 to 5 do {
    sleep 0.5;
    _msg = [];
    _msg resize _i*5;
    _msg = _msg apply {" test"};
    _msg = _msg joinString "";
    [_msg] execVM "note.sqf";
  };
};

This will print 6 messages with increasing length.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×