From d724d34c3173ccf95dd6dddfdae0ec9e48a28f6b Mon Sep 17 00:00:00 2001 From: Relentless Date: Tue, 19 Sep 2017 04:14:40 +0200 Subject: [PATCH] Fixed a lot of bugs, improved performance, new algorithm --- rlnt/dialogs/RLNT_updatepanel.hpp | 6 +- rlnt/functions/RLNT_up_main.sqf | 186 ++----------------- rlnt/functions/RLNT_up_setup.sqf | 20 +- rlnt/scripts/Update Panel/RLNT_up_config.sqf | 2 +- rlnt/scripts/Update Panel/RLNT_up_init.sqf | 9 +- 5 files changed, 41 insertions(+), 182 deletions(-) diff --git a/rlnt/dialogs/RLNT_updatepanel.hpp b/rlnt/dialogs/RLNT_updatepanel.hpp index 899966e..ec786dd 100644 --- a/rlnt/dialogs/RLNT_updatepanel.hpp +++ b/rlnt/dialogs/RLNT_updatepanel.hpp @@ -80,7 +80,7 @@ class rlnt_updatepanel_style_2 { onLoad = "uiNamespace setVariable ['rlnt_updatepanel_style_2', _this select 0];"; class Controls { - class rlnt_text_header: RscText + class rlnt_text_header: RLNT_RscText { idc = 1028; text = ""; @@ -90,7 +90,7 @@ class rlnt_updatepanel_style_2 { h = 0.0329878 * safezoneH; sizeEx = 0.02076 * SafezoneH; }; - class rlnt_text_line_1: RscText + class rlnt_text_line_1: RLNT_RscText { idc = 1029; text = ""; @@ -100,7 +100,7 @@ class rlnt_updatepanel_style_2 { h = 0.0175934 * safezoneH; sizeEx = 0.0173 * SafezoneH; }; - class rlnt_text_line_2: RscText + class rlnt_text_line_2: RLNT_RscText { idc = 1030; text = ""; diff --git a/rlnt/functions/RLNT_up_main.sqf b/rlnt/functions/RLNT_up_main.sqf index 746cc4d..fcbdc4d 100644 --- a/rlnt/functions/RLNT_up_main.sqf +++ b/rlnt/functions/RLNT_up_main.sqf @@ -4,7 +4,7 @@ Author: Relentless Description: Base function for RLNT-CustomUpdatePanel Call: [Side,Style,Header,Line1,Line2,Img,Duration,FontColor,BgColor] spawn RLNT_updatePanel; */ -private ["_input","_upSide","_upStyle","_upHeader","_upLine1","_upLine2","_upImg","_upDuration","_upFontColor","_upBgColor"]; +private ["_input","_varArray"]; disableSerialization; @@ -14,188 +14,40 @@ if (rlnt_debug) then { }; -/* Count the input for optional arguments */ -_input = count _this; +/* Variables */ +_input = (count _this) - 1; +_varArray = rlnt_up_defaults; -/* Variables, fill with config if optional */ -switch (_input) do { - - case 0: { - _upSide = rlnt_up_Side; - _upStyle = rlnt_up_Style; - _upHeader = rlnt_up_Header; - _upLine1 = rlnt_up_Line1; - _upLine2 = rlnt_up_Line2; - _upImg = rlnt_up_Img; - _upDuration = rlnt_up_Duration; - _upFontColor = rlnt_up_FontColor; - _upBgColor = rlnt_up_BgColor; - }; - - case 1: { - _upSide = _this select 0; - _upStyle = rlnt_up_Style; - _upHeader = rlnt_up_Header; - _upLine1 = rlnt_up_Line1; - _upLine2 = rlnt_up_Line2; - _upImg = rlnt_up_Img; - _upDuration = rlnt_up_Duration; - _upFontColor = rlnt_up_FontColor; - _upBgColor = rlnt_up_BgColor; - }; - - case 2: { - _upSide = _this select 0; - _upStyle = _this select 1; - _upHeader = rlnt_up_Header; - _upLine1 = rlnt_up_Line1; - _upLine2 = rlnt_up_Line2; - _upImg = rlnt_up_Img; - _upDuration = rlnt_up_Duration; - _upFontColor = rlnt_up_FontColor; - _upBgColor = rlnt_up_BgColor; - }; - - case 3: { - _upSide = _this select 0; - _upStyle = _this select 1; - _upHeader = _this select 2; - _upLine1 = rlnt_up_Line1; - _upLine2 = rlnt_up_Line2; - _upImg = rlnt_up_Img; - _upDuration = rlnt_up_Duration; - _upFontColor = rlnt_up_FontColor; - _upBgColor = rlnt_up_BgColor; - }; - - case 4: { - _upSide = _this select 0; - _upStyle = _this select 1; - _upHeader = _this select 2; - _upLine1 = _this select 3; - _upLine2 = rlnt_up_Line2; - _upImg = rlnt_up_Img; - _upDuration = rlnt_up_Duration; - _upFontColor = rlnt_up_FontColor; - _upBgColor = rlnt_up_BgColor; - }; - - case 5: { - _upSide = _this select 0; - _upStyle = _this select 1; - _upHeader = _this select 2; - _upLine1 = _this select 3; - _upLine2 = _this select 4; - _upImg = rlnt_up_Img; - _upDuration = rlnt_up_Duration; - _upFontColor = rlnt_up_FontColor; - _upBgColor = rlnt_up_BgColor; - }; - - case 6: { - _upSide = _this select 0; - _upStyle = _this select 1; - _upHeader = _this select 2; - _upLine1 = _this select 3; - _upLine2 = _this select 4; - _upImg = _this select 5; - _upDuration = rlnt_up_Duration; - _upFontColor = rlnt_up_FontColor; - _upBgColor = rlnt_up_BgColor; - }; - - case 7: { - _upSide = _this select 0; - _upStyle = _this select 1; - _upHeader = _this select 2; - _upLine1 = _this select 3; - _upLine2 = _this select 4; - _upImg = _this select 5; - _upDuration = _this select 6; - _upFontColor = rlnt_up_FontColor; - _upBgColor = rlnt_up_BgColor; +/* Define arguments for setup */ +for "_i" from 0 to _input do { + if (isNil (_this select _i)) then { + if (rlnt_up_debug) then { + diag_log format ["[RLNT][UP] The variable '_this select %1' wasn't overwritten.", str(_i)]; + }; + } else { + _varArray set [_i, (_this select _i)]; + if (rlnt_up_debug) then { + diag_log format ["[RLNT][UP] The variable '_this select %1' was overwritten with ''%2'.", str(_i), _varArray select _i]; + }; }; - - case 8: { - _upSide = _this select 0; - _upStyle = _this select 1; - _upHeader = _this select 2; - _upLine1 = _this select 3; - _upLine2 = _this select 4; - _upImg = _this select 5; - _upDuration = _this select 6; - _upFontColor = _this select 7; - _upBgColor = rlnt_up_BgColor; - }; - - case 9: { - _upSide = _this select 0; - _upStyle = _this select 1; - _upHeader = _this select 2; - _upLine1 = _this select 3; - _upLine2 = _this select 4; - _upImg = _this select 5; - _upDuration = _this select 6; - _upFontColor = _this select 7; - _upBgColor = _this select 8; - }; - -}; - - -/* Use config if not defined */ -if (isNil "_upSide") then { - _upSide = rlnt_up_Side; -}; - -if (isNil "_upStyle") then { - _upStyle = rlnt_up_Style; -}; - -if (isNil "_upHeader") then { - _upHeader = rlnt_up_Header; -}; - -if (isNil "_upLine1") then { - _upLine1 = rlnt_up_Line1; -}; - -if (isNil "_upLine2") then { - _upLine2 = rlnt_up_Line2; -}; - -if (isNil "_upImg") then { - _upImg = rlnt_up_Img; -}; - -if (isNil "_upDuration") then { - _upDuration = rlnt_up_Duration; -}; - -if (isNil "_upFontColor") then { - _upFontColor = rlnt_up_FontColor; -}; - -if (isNil "_upBgColor") then { - _upBgColor = rlnt_up_BgColor; }; /* Check the receiver */ -if (_upSide == "local") then { +if ((_varArray select 1) == "local") then { if (rlnt_up_debug) then { diag_log "[RLNT][UP] The RLNT_up_main.sqf decided a local receiver!"; }; - [_upStyle,_upHeader,_upLine1,_upLine2,_upImg,_upDuration,_upFontColor,_upBgColor] spawn RLNT_up_setup; + _varArray spawn RLNT_up_setup; }; -if (_upSide == "global") then { +if ((_varArray select 1) == "global") then { if (rlnt_up_debug) then { diag_log "[RLNT][UP] The RLNT_up_main.sqf decided a global receiver!"; }; - RLNT_up_global = [_upStyle,_upHeader,_upLine1,_upLine2,_upImg,_upDuration,_upFontColor,_upBgColor]; + RLNT_up_global = _varArray; publicVariableServer "RLNT_up_global"; }; diff --git a/rlnt/functions/RLNT_up_setup.sqf b/rlnt/functions/RLNT_up_setup.sqf index 0bae6d8..37a76c9 100644 --- a/rlnt/functions/RLNT_up_setup.sqf +++ b/rlnt/functions/RLNT_up_setup.sqf @@ -2,7 +2,7 @@ Filename: RLNT_up_setup.sqf Author: Relentless Description: Creation function for RLNT-CustomUpdatePanel -Call: [_upStyle,_upHeader,_upLine1,_upLine2,_upImg,_upDuration,_upFontColor,_upBgColor] spawn RLNT_up_setup; +Call: _varArray spawn RLNT_up_setup; */ private ["_upStyle","_upHeader","_upLine1","_upLine2","_upImg","_upDuration","_upFontColor","_upBgColor","_layer","_display","_cHeader","_cLine1","_cLine2","_cImg","_cFontColor","_cBgColor"]; disableSerialization; @@ -15,14 +15,14 @@ if (rlnt_debug) then { /* Variables */ -_upStyle = _this select 0; -_upHeader = _this select 1; -_upLine1 = _this select 2; -_upLine2 = _this select 3; -_upImg = _this select 4; -_upDuration = _this select 5; -_upFontColor = _this select 6; -_upBgColor = _this select 7; +_upStyle = _this select 1; +_upHeader = _this select 2; +_upLine1 = _this select 3; +_upLine2 = _this select 4; +_upImg = _this select 5; +_upDuration = _this select 6; +_upFontColor = _this select 7; +_upBgColor = _this select 8; _layer = 1302; @@ -59,7 +59,7 @@ switch (_upStyle) do { //Left upper corner without image (PLAIN) case 2: { - _layer cutRsc ["rlnt_updatepnael_style_2","PLAIN",1]; + _layer cutRsc ["rlnt_updatepanel_style_2","PLAIN",1]; sleep 0.01; if (rlnt_up_debug) then { diff --git a/rlnt/scripts/Update Panel/RLNT_up_config.sqf b/rlnt/scripts/Update Panel/RLNT_up_config.sqf index 280f8cc..0e83cf3 100644 --- a/rlnt/scripts/Update Panel/RLNT_up_config.sqf +++ b/rlnt/scripts/Update Panel/RLNT_up_config.sqf @@ -76,7 +76,7 @@ rlnt_up_Style = 1; /* default: 1 */ //// Default string that defines the text that's used //// //// as the header of the Update Panel. //// //// THE OPTION HAS TO BE A STRING! //// -//// MAXIMUM CHAR AMOUNT IS 13! //// +//// MAXIMUM CHAR AMOUNT IS 16! //// //////////////////////////////////////////////////////////// rlnt_up_Header = "RLNT Panel:"; diff --git a/rlnt/scripts/Update Panel/RLNT_up_init.sqf b/rlnt/scripts/Update Panel/RLNT_up_init.sqf index b3571f1..b4065a0 100644 --- a/rlnt/scripts/Update Panel/RLNT_up_init.sqf +++ b/rlnt/scripts/Update Panel/RLNT_up_init.sqf @@ -11,5 +11,12 @@ if (rlnt_debug) then { }; - execVM "rlnt\scripts\Update Panel\RLNT_up_config.sqf"; +sleep 0.2; +rlnt_up_defaults = [rlnt_up_Side,rlnt_up_Style,rlnt_up_Header,rlnt_up_Line1,rlnt_up_Line2,rlnt_up_Img,rlnt_up_Duration,rlnt_up_FontColor,rlnt_up_BgColor]; + + +/* UP RLNT Debug */ +if (rlnt_up_debug) then { + diag_log format ["[RLNT][UP] The default variable array is %1.", rlnt_up_defaults]; +};