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

Notification height adjustment #3

Open
Bankinghelp opened this issue Mar 29, 2019 · 15 comments
Open

Notification height adjustment #3

Bankinghelp opened this issue Mar 29, 2019 · 15 comments

Comments

@Bankinghelp
Copy link

Bankinghelp commented Mar 29, 2019

Hi, i have a problem, the notification frame is very tall when there is a line, and if i add like 5 or 6 lines the text frame ocupates the whole screen

@Gummibeer
Copy link
Contributor

Hey, I'm sorry but I don't develop SQF anymore.

I can only hint you to the line which adjusts the height depending on the text height

_adjustedHeight = (ctrlTextHeight _TextCtrl);

@Bankinghelp
Copy link
Author

Yeah i know thanks, i have asked in a cuple of forums but thanks ;) if they solve it i sed it to u ;)

@Bankinghelp
Copy link
Author

Hey, I'm sorry but I don't develop SQF anymore.

I can only hint you to the line which adjusts the height depending on the text height

a3_notifications/fn_notification_system.sqf

Line 143 in 6cf8b2a

_adjustedHeight = (ctrlTextHeight _TextCtrl);

and i think u can help me with this, when it appears a notification ferst, the first one puts below the 2nd, and when the 3 appear all at the same time, the one that was below the other notifications, comes down and the second puts below the 3rd, may u see it a sec? thanks.

@Gummibeer
Copy link
Contributor

Hey,
I'm sorry but I don't get what's your question/issue?
To be honest I don't even know which order it was!? 😅

From top to bottom is it 1, 2, 3 or 3, 2, 1? And which one do you want?
Both are useful orders - so it's really a subjective decision.

@Bankinghelp
Copy link
Author

Bankinghelp commented Mar 30, 2019

Hey,
I'm sorry but I don't get what's your question/issue?
To be honest I don't even know which order it was!? 😅

From top to bottom is it 1, 2, 3 or 3, 2, 1? And which one do you want?
Both are useful orders - so it's really a subjective decision.

No i mean, imagine this, you are clicking a button that makes a notification appear. when u press 1st time, appear a notification, when u paress it again (with the notification still in the screen) it apears over the first one. and when u press it agfain, the first one, that should have gone down when the second appear, goes down when the third appear, and the 3nd one gets over the 2nd.

@Bankinghelp
Copy link
Author

And abucle, maybe is something in open_notifications > 0 or something like but cant get how to fix, maybe you can understand it better.

@Gummibeer
Copy link
Contributor

Okay, so you want multiple notification to appear from top to bottom in descending order (3, 2, 1).

If I check what happens in the last if (count open_notifications > 0) it is exactly what you want!? All existing notifications are moved down.

@Bankinghelp
Copy link
Author

Okay, so you want multiple notification to appear from top to bottom in descending order (3, 2, 1).

If I check what happens in the last if (count open_notifications > 0) it is exactly what you want!? All existing notifications are moved down.

Nono, I mean, I don’t want anything, the script is great! Is a bug. Shudnt the notification go down when another one appears? Becaus when the sencond appear, the 1 stays where he is, and when the 3rd appear, the 1st moves but the second stays. And is quite annoying XD. If u can take a look.

@Gummibeer
Copy link
Contributor

Ok, it seems that the script ignores the added notification.
It could help to move the last line before the if and change the condition from count > 0 to count > 1.
This should fix it - but I haven't tested it.

@Bankinghelp
Copy link
Author

Alright, will test Monday and tell u, thanks ;)

@Bankinghelp
Copy link
Author

Alright, will test Monday and tell u, thanks ;)

didnt work... any idea?

@Bankinghelp
Copy link
Author

ok everything is fixed, but thx!

@Gummibeer
Copy link
Contributor

Cool. Would you mind to send a PR with the fix?

@Bankinghelp
Copy link
Author

Bankinghelp commented Apr 3, 2019

/*
 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 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];
            _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;
};
open_notifications = ([[_BorderCtrl,_TextCtrl]] + open_notifications) select {!isNull (_x select 0) && !isNull (_x select 1)};

@Bankinghelp
Copy link
Author

There y go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants