diff --git a/addons/arsenal/defines.hpp b/addons/arsenal/defines.hpp index 6967c3f0401..ecd50f7a479 100644 --- a/addons/arsenal/defines.hpp +++ b/addons/arsenal/defines.hpp @@ -154,6 +154,8 @@ #define IDC_statsPreviousPage 52 #define IDC_statsNextPage 53 #define IDC_statsCurrentPage 54 +#define IDC_statsBoxTitleBackground 55 +#define IDC_statsBoxBackground 56 #define IDC_actionsBox 90 #define IDC_actionsBackground1 90010 #define IDC_actionsBackground2 90011 diff --git a/addons/arsenal/functions/fnc_handleStats.sqf b/addons/arsenal/functions/fnc_handleStats.sqf index 3fd92d64f0f..0511c05a25a 100644 --- a/addons/arsenal/functions/fnc_handleStats.sqf +++ b/addons/arsenal/functions/fnc_handleStats.sqf @@ -19,6 +19,8 @@ params ["_display", "_control", "_curSel", ["_itemCfg", configNull]]; private _statsBoxCtrl = _display displayCtrl IDC_statsBox; +private _statsBoxTitleBackgroundCtrl = _display displayCtrl IDC_statsBoxTitleBackground; +private _statsBoxBackgroundCtrl = _display displayCtrl IDC_statsBoxBackground; private _statsPreviousPageCtrl = _display displayCtrl IDC_statsPreviousPage; private _statsNextPageCtrl = _display displayCtrl IDC_statsNextPage; private _statsCurrentPageCtrl = _display displayCtrl IDC_statsCurrentPage; @@ -111,6 +113,7 @@ private _fnc_handleStats = { private _statsBarCtrl = controlNull; private _statsTextCtrl = controlNull; private _textStatementResult = ""; + private _lastCtrl = _statsBoxTitleBackgroundCtrl; { _x params ["", "_configEntry", "_title", "_bools", "_statements"]; @@ -127,6 +130,17 @@ private _fnc_handleStats = { _statsTitleCtrl ctrlSetText _title; _statsTitleCtrl ctrlSetFade 0; + // Vertical Position + ctrlPosition _lastCtrl params ["", "_lastPosY", "", "_lastPosH"]; + _statsTitleCtrl ctrlSetPositionY (_lastPosY + _lastPosH + GRID_H); + { + _x ctrlSetPositionY (_lastPosY + _lastPosH + GRID_H + (5 * GRID_H)); + } forEach [ + _statsBackgroundCtrl, + _statsBarCtrl, + _statsTextCtrl + ]; + // Handle bars if (_showBar) then { _statsBarCtrl progressSetPosition ([_configEntry, _itemCfg] call _barStatement); @@ -140,18 +154,39 @@ private _fnc_handleStats = { // Handle text entries if (_showText) then { _textStatementResult = [_configEntry, _itemCfg] call _textStatement; - - if !(_textStatementResult isEqualType "") then { - _textStatementResult = str _textStatementResult; + if (_textStatementResult isEqualType []) then { + _textStatementResult = _textStatementResult joinString endl; + } else { + if !(_textStatementResult isEqualType "") then { + _textStatementResult = str _textStatementResult; + }; }; _statsTextCtrl ctrlSetText _textStatementResult; _statsTextCtrl ctrlSetTextColor ([[1, 1, 1, 1], [0, 0, 0, 1]] select (_showBar)); + + //Height based on Text lines + { + _x ctrlSetPositionH (ctrlTextHeight _statsTextCtrl); + } forEach [ + _statsBackgroundCtrl, + _statsBarCtrl, + _statsTextCtrl + ]; + _statsTextCtrl ctrlSetFade 0; } else { _statsTextCtrl ctrlSetFade 1; + //Ensure default height + { + _x ctrlSetPositionH (5 * GRID_H); + } forEach [ + _statsBackgroundCtrl, + _statsBarCtrl, + _statsTextCtrl + ]; }; - + { _x ctrlCommit 0; } forEach [ @@ -160,24 +195,29 @@ private _fnc_handleStats = { _statsBarCtrl, _statsTextCtrl ]; + + _lastCtrl = _statsTextCtrl; + } forEach _statsToDisplay; // Resize the window (5 - _statsCount) call _fnc_hideUnused; - private _height = 10 * _statsCount + 5; + ctrlPosition _lastCtrl params ["", "_lastPosY", "", "_lastPosH"]; _statsBoxCtrl ctrlSetPosition [ (0.5 - WIDTH_TOTAL / 2) + WIDTH_GAP, safeZoneY + 1.8 * GRID_H, 47 * GRID_W, - _height * GRID_H + _lastPosY + _lastPosH + GRID_H ]; + _statsBoxBackgroundCtrl ctrlSetPositionH (_lastPosY + _lastPosH + GRID_H); + _statsBoxBackgroundCtrl ctrlCommit 0; _statsBoxCtrl ctrlCommit 0; // Move the actions box private _ctrl = _display displayCtrl IDC_actionsBox; private _pos = ctrlPosition _ctrl; - _pos set [1, safeZoneY + (_height + 3.6) * GRID_H]; + _pos set [1, safeZoneY + (_lastPosY + _lastPosH + GRID_H + (3.6 * GRID_H))]; _ctrl ctrlSetPosition _pos; _ctrl ctrlCommit 0; diff --git a/addons/arsenal/ui/RscAttributes.hpp b/addons/arsenal/ui/RscAttributes.hpp index 6ec69223355..b487cffd617 100644 --- a/addons/arsenal/ui/RscAttributes.hpp +++ b/addons/arsenal/ui/RscAttributes.hpp @@ -283,7 +283,7 @@ class GVAR(display) { h = QUOTE(55 * GRID_H); class controls { class statsStaticBackground1: ctrlStaticBackground { - idc = -1; + idc = IDC_statsBoxBackground; x = QUOTE(0); y = QUOTE(0); w = QUOTE(47 * GRID_W); @@ -291,7 +291,7 @@ class GVAR(display) { colorBackground[] = {0.1,0.1,0.1,0.5}; }; class statsStaticBackground2: ctrlStaticBackground { - idc = -1; + idc = IDC_statsBoxTitleBackground; x = QUOTE(0); y = QUOTE(0); w = QUOTE(47 * GRID_W); @@ -316,7 +316,7 @@ class GVAR(display) { x = QUOTE(1 * GRID_W); y = QUOTE(10 * GRID_H); w = QUOTE(45 * GRID_W); - h = QUOTE(4 * GRID_H); + h = QUOTE(5 * GRID_H); colorBackground[] = {1,1,1,0.15}; }; class statsBar1: ctrlProgress { @@ -329,9 +329,9 @@ class GVAR(display) { x = QUOTE(1 * GRID_W); y = QUOTE(10 * GRID_H); w = QUOTE(45 * GRID_W); - h = QUOTE(4 * GRID_H); + h = QUOTE(5 * GRID_H); }; - class statsText1: RscText { + class statsText1: RscTextMulti { idc = IDC_statsText1; shadow = 0; fade = 1; @@ -340,7 +340,7 @@ class GVAR(display) { x = QUOTE(0 * GRID_W); y = QUOTE(10 * GRID_H); w = QUOTE(45 * GRID_W); - h = QUOTE(4 * GRID_H); + h = QUOTE(5 * GRID_H); sizeEx = QUOTE(5 * GRID_H); text = ""; }; @@ -482,7 +482,7 @@ class GVAR(display) { x = QUOTE(1 * GRID_W); y = QUOTE(6 * GRID_H); w = QUOTE(45 * GRID_W); - h = QUOTE(4 * GRID_H); + h = QUOTE(5 * GRID_H); }; class actionsText2: actionsText1 { idc = IDC_actionsText2; diff --git a/docs/wiki/framework/arsenal-framework.md b/docs/wiki/framework/arsenal-framework.md index a02dcdf646a..330e7fa99b1 100644 --- a/docs/wiki/framework/arsenal-framework.md +++ b/docs/wiki/framework/arsenal-framework.md @@ -214,7 +214,7 @@ class ace_arsenal_stats { showBar = 1; // 0 disabled; 1 enabled; showText = 1; // 0 disabled; 1 enabled; barStatement = "1"; // Statement evaluated to set the bar progress, needs to return a NUMBER. - textStatement = "test entry"; // statement evaluated to set the text entry, can return anything. + textStatement = "test entry"; // statement evaluated to set the text entry, can return anything. Arrays will have a linebreak added after each element. condition = "true"; // Condition for the stats to be displayed, default is true if not defined, needs to return a BOOL. tabs[] = { {0,1,2}, { } }; // Arrays of tabs, left array is left tabs, right array is right tabs. };