Arsenal - Compile stats on first use (#6159)

* Arsenal - Compile stats on first use

* fix )
This commit is contained in:
PabstMirror 2018-02-23 23:30:15 -06:00 committed by GitHub
parent 123c19c1c0
commit f70dfaf160
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 23 deletions

View File

@ -3,4 +3,3 @@
#include "XEH_PREP.hpp"
call FUNC(scanConfig);
call FUNC(compileStats);

View File

@ -53,8 +53,7 @@ _statements params [
["_condition", {true}, [{}]]
];
private _statsListLeftPanel = uiNamespace getVariable QGVAR(statsListLeftPanel);
private _statsListRightPanel = uiNamespace getVariable QGVAR(statsListRightPanel);
call FUNC(compileStats);
private _returnArray = [];
private _fnc_addToTabs = {
@ -89,11 +88,11 @@ private _fnc_addToTabs = {
private _finalArray = ["", _stats, _title, [_showBar, _showText], [_barStatement, _textStatement, _condition], _priority];
if (count _leftTabs > 0) then {
[_statsListLeftPanel, _leftTabs, "L", 0] call _fnc_addToTabs;
[GVAR(statsListLeftPanel), _leftTabs, "L", 0] call _fnc_addToTabs;
};
if (count _rightTabs > 0) then {
[_statsListRightPanel, _rightTabs, "R", 1] call _fnc_addToTabs;
[GVAR(statsListRightPanel), _rightTabs, "R", 1] call _fnc_addToTabs;
};
_returnArray

View File

@ -1,6 +1,6 @@
/*
* Author: Alganthe
* Create the internal stats arrays on preStart
* Create the internal stats arrays when needed for the first time
*
* Arguments:
* None
@ -12,6 +12,8 @@
*/
#include "script_component.hpp"
if (!isNil QGVAR(statsListLeftPanel)) exitWith {};
private _fnc_addToTabs = {
params ["_tabsList", "_tabsToAddTo", "_sideString"];
{
@ -53,7 +55,7 @@ private _fnc_sortLists = {
} foreach _tabsList;
};
private _statsListLeftPanel = uiNamespace getVariable [QGVAR(statsListLeftPanel), [
private _statsListLeftPanel = [
[[]], // Primary 0
[[]], // Handgun 1
[[]], // Launcher 2
@ -68,10 +70,10 @@ private _statsListLeftPanel = uiNamespace getVariable [QGVAR(statsListLeftPanel)
[[]], // GPS 11
[[]], // Radio 12
[[]], // Compass 13
[[]] // Watch 14
]];
[[]] // Watch 14
];
private _statsListRightPanel = uiNamespace getVariable [QGVAR(statsListRightPanel), [
private _statsListRightPanel = [
[[]], // Optics 0
[[]], // Side accs 1
[[]], // Muzzle 2
@ -79,8 +81,8 @@ private _statsListRightPanel = uiNamespace getVariable [QGVAR(statsListRightPane
[[]], // Mag 4
[[]], // Throw 5
[[]], // Put 6
[[]] // Misc 7
]];
[[]] // Misc 7
];
//------------------------- Config handling
private _configEntries = "(getNumber (_x >> 'scope')) == 2" configClasses (configFile >> QGVAR(stats));
@ -129,5 +131,5 @@ private _configEntries = "(getNumber (_x >> 'scope')) == 2" configClasses (confi
//------------------------- Config Handling
uiNamespace setVariable [QGVAR(statsListLeftPanel), _statsListLeftPanel];
uiNamespace setVariable [QGVAR(statsListRightPanel), _statsListRightPanel];
missionNamespace setVariable [QGVAR(statsListLeftPanel), _statsListLeftPanel];
missionNamespace setVariable [QGVAR(statsListRightPanel), _statsListRightPanel];

View File

@ -50,6 +50,7 @@ private _hideUnusedFnc = {
} forEach _numbers;
};
call FUNC(compileStats);
if !(isNil "_itemCfg") then {
private _handleStatsFnc = {
@ -57,9 +58,9 @@ if !(isNil "_itemCfg") then {
// Get the proper list and page
if (_leftPanel) then {
[true, (uiNamespace getVariable QGVAR(statsListLeftPanel)) select _statsIndex, GVAR(statsPagesLeft) select _statsIndex]
[true, (GVAR(statsListLeftPanel)) select _statsIndex, GVAR(statsPagesLeft) select _statsIndex]
} else {
[false, (uiNamespace getVariable QGVAR(statsListRightPanel)) select _statsIndex, GVAR(statsPagesRight) select _statsIndex]
[false, (GVAR(statsListRightPanel)) select _statsIndex, GVAR(statsPagesRight) select _statsIndex]
} params ["_isLeftPanel", "_statsArray", "_currentPage"];
private _statsList = _statsArray select _currentPage;

View File

@ -17,8 +17,7 @@
params ["_IDList"];
private _statsListLeftPanel = uiNamespace getVariable QGVAR(statsListLeftPanel);
private _statsListRightPanel = uiNamespace getVariable QGVAR(statsListRightPanel);
call FUNC(compileStats);
{
private _currentID = _x;
@ -28,9 +27,9 @@ private _statsListRightPanel = uiNamespace getVariable QGVAR(statsListRightPanel
_tab = parseNumber _tab;
private _tabToChange = if (_side == "R") then {
_statsListRightPanel select _tab
GVAR(statsListRightPanel) select _tab
} else {
_statsListLeftPanel select _tab
GVAR(statsListLeftPanel) select _tab
};
{
@ -46,6 +45,7 @@ private _statsListRightPanel = uiNamespace getVariable QGVAR(statsListRightPanel
// Clear empty pages
private _fnc_deleteEmptyPage = {
params ["_list"];
{
private _evaluatedTab = _forEachIndex;
{
@ -55,12 +55,12 @@ private _fnc_deleteEmptyPage = {
} foreach _x;
{
(_statsListLeftPanel select (_x select 0)) deleteAt (_x select 1);
(_list select (_x select 0)) deleteAt (_x select 1);
} foreach _markedForDeletion;
} foreach (_this select 0);
};
private _markedForDeletion = [];
[_statsListLeftPanel] call _fnc_deleteEmptyPage;
[_statsListRightPanel] call _fnc_deleteEmptyPage;
[GVAR(statsListLeftPanel)] call _fnc_deleteEmptyPage;
[GVAR(statsListRightPanel)] call _fnc_deleteEmptyPage;