From 22dc7d124546c377f5120f5f701729bdea9e7193 Mon Sep 17 00:00:00 2001 From: NeilZar Date: Wed, 13 Feb 2019 16:42:10 +0100 Subject: [PATCH 1/3] Bunch of performance improvements --- .../ui_f/scripts/RscAttributeInventory.sqf | 334 +++++++++--------- 1 file changed, 168 insertions(+), 166 deletions(-) diff --git a/@AresModAchillesExpansion/addons/ui_f/scripts/RscAttributeInventory.sqf b/@AresModAchillesExpansion/addons/ui_f/scripts/RscAttributeInventory.sqf index 304911c2..d7135b40 100644 --- a/@AresModAchillesExpansion/addons/ui_f/scripts/RscAttributeInventory.sqf +++ b/@AresModAchillesExpansion/addons/ui_f/scripts/RscAttributeInventory.sqf @@ -1,7 +1,7 @@ #include "\A3\ui_f_curator\ui\defineResinclDesign.inc" #include "\a3\editor_f\Data\Scripts\dikCodes.h" -#define VALUE_NUMBER "#(argb,1,1,1)color(0,0,0,0)" +#define VALUE_NUMBER "#(argb, 1, 1, 1)color(0, 0, 0, 0)" #define IDC_RSCATTRIBUTEINVENTORY_FILTER13 24081 #define IDC_RSCATTRIBUTEINVENTORY_BUTTON_VA 24470 @@ -30,78 +30,78 @@ switch _mode do { { //--- Get weapons and magazines from curator addons private _curator = getassignedcuratorlogic player; - private _weaponAddons = missionnamespace getvariable ["RscAttrbuteInventory_weaponAddons",[]]; + private _weaponAddons = missionnamespace getvariable ["RscAttrbuteInventory_weaponAddons", []]; private _types = [ - ["AssaultRifle","Shotgun","Rifle","SubmachineGun"], + ["AssaultRifle", "Shotgun", "Rifle", "SubmachineGun"], ["MachineGun"], ["SniperRifle"], - ["Launcher","MissileLauncher","RocketLauncher"], + ["Launcher", "MissileLauncher", "RocketLauncher"], ["Handgun"], ["UnknownWeapon"], - ["AccessoryMuzzle","AccessoryPointer","AccessorySights","AccessoryBipod"], + ["AccessoryMuzzle", "AccessoryPointer", "AccessorySights", "AccessoryBipod"], ["Uniform"], ["Vest"], ["Backpack"], - ["Headgear","Glasses"], - ["Binocular","Compass","FirstAidKit","GPS","LaserDesignator","Map","Medikit","MineDetector","NVGoggles","Radio","Toolkit","Watch","UAVTerminal"] + ["Headgear", "Glasses"], + ["Binocular", "Compass", "FirstAidKit", "GPS", "LaserDesignator", "Map", "Medikit", "MineDetector", "NVGoggles", "Radio", "Toolkit", "Watch", "UAVTerminal"] ]; - private _typeMagazine = _types find "Magazine"; - private _list = [[],[],[],[],[],[],[],[],[],[],[],[]]; + //private _typeMagazine = _types find "Magazine"; + private _list = [[], [], [], [], [], [], [], [], [], [], [], []]; private _magazines = []; //--- Store magazines in an array and mark duplicates, so nthey don't appear in the list of all items { private _addon = tolower _x; - private _addonList = [[],[],[],[],[],[],[],[],[],[],[],[]]; + private _addonList = [[], [], [], [], [], [], [], [], [], [], [], []]; private _addonID = _weaponAddons find _addon; - if (_addonID < 0) then { + if (_addonID < 0) then + { { private _weapon = tolower _x; - private _weaponType = (_weapon call bis_fnc_itemType); - private _weaponTypeCategory = _weaponType select 0; - private _weaponTypeSpecific = _weaponType select 1; - private _weaponTypeID = -1; - { - if (_weaponTypeSpecific in _x) exitwith {_weaponTypeID = _foreachindex;}; - } foreach _types; + private _weaponType = _weapon call bis_fnc_itemType; + _weaponType params ["_weaponTypeCategory", "_weaponTypeSpecific"]; + private _weaponTypeID = _types findIf { _weaponTypeSpecific in _x }; + //_weaponTypeID = _types find (_weaponType select 0); - if (_weaponTypeCategory != "VehicleWeapon" and _weaponTypeID >= 0 and (_weapon == [_weapon] call bis_fnc_baseWeapon)) then { + if (_weaponTypeCategory != "VehicleWeapon" && _weaponTypeID >= 0 && (_weapon == [_weapon] call bis_fnc_baseWeapon)) then + { private _weaponCfg = configfile >> "cfgweapons" >> _weapon; private _weaponPublic = getnumber (_weaponCfg >> "scope") == 2; private _addonListType = _addonList select _weaponTypeID; - if (_weaponPublic) then { + if (_weaponPublic) then + { private _displayName = gettext (_weaponCfg >> "displayName"); private _picture = gettext (_weaponCfg >> "picture"); { private _item = gettext (_x >> "item"); private _itemName = gettext (configfile >> "cfgweapons" >> _item >> "displayName"); _displayName = _displayName + " + " + _itemName; - } foreach ((_weaponCfg >> "linkeditems") call Achilles_fnc_returnChildren); + } foreach configProperties [_weaponCfg >> "linkeditems", "isClass _x"]; private _displayNameShort = _displayName; - private _displayNameShortArray = toarray _displayNameShort; - if (count _displayNameShortArray > 41) then { //--- Cut when the name is too long (41 chars is approximate) - _displayNameShortArray resize 41; - _displayNameShort = tostring _displayNameShortArray + "..."; + if (count _displayNameShort > 41) then + { // Cut when the name is too long (41 chars is approximate) + _displayNameShort = (_displayNameShort select [0, 41]) + "..."; }; - private _type = [0, 1] select (getnumber (configfile >> "cfgweapons" >> _weapon >> "type") in [4096,131072]); - _addonListType pushback [_weapon,_displayName,_displayNameShort,_picture,_type,false]; + private _type = [0, 1] select (getnumber (configfile >> "cfgweapons" >> _weapon >> "type") in [4096, 131072]); + _addonListType pushback [_weapon, _displayName, _displayNameShort, _picture, _type, false]; }; - //--- Add magazines compatible with the weapon - if (_weaponPublic || _weapon in ["throw","put"]) then { - //_addonListType = _addonList select _typeMagazine; + // Add magazines compatible with the weapon + if (_weaponPublic || _weapon in ["throw", "put"]) then + { { private _muzzle = if (_x == "this") then {_weaponCfg} else {_weaponCfg >> _x}; { private _mag = tolower _x; - if ({(_x select 0) == _mag} count _addonListType == 0) then { + if (_addonListType findIf {(_x select 0) isEqualTo _mag} == -1) then + { private _magCfg = configfile >> "cfgmagazines" >> _mag; - if (getnumber (_magCfg >> "scope") == 2) then { + if (getnumber (_magCfg >> "scope") == 2) then + { private _displayName = gettext (_magCfg >> "displayName"); - private _displayNameArray = toarray _displayName; - if (count _displayNameArray > 41) then { //--- Cut when the name is too long (41 chars is approximate) - _displayNameArray resize 41; - _displayName = tostring _displayNameArray + "..."; + if (count _displayName > 41) then + { //--- Cut when the name is too long (41 chars is approximate) + _displayName = (_displayName select [0, 41]) + "..."; }; private _picture = gettext (_magCfg >> "picture"); - _addonListType pushback [_mag,_displayName,_displayName,_picture,2,_mag in _magazines]; + _addonListType pushback [_mag, _displayName, _displayName, _picture, 2, _mag in _magazines]; _magazines pushback _mag; }; }; @@ -113,47 +113,43 @@ switch _mode do { { private _weapon = tolower _x; private _weaponType = _weapon call bis_fnc_itemType; - private _weaponTypeSpecific = _weaponType select 1; - private _weaponTypeID = -1; - { - if (_weaponTypeSpecific in _x) exitwith {_weaponTypeID = _foreachindex;}; - } foreach _types; - //_weaponTypeID = _types find (_weaponType select 0); - if (_weaponTypeID >= 0) then { + _weaponType params ["", "_weaponTypeSpecific"]; + private _weaponTypeID = _types findIf { _weaponTypeSpecific in _x }; + if (_weaponTypeID >= 0) then + { private _weaponCfg = configfile >> "cfgvehicles" >> _weapon; - if (getnumber (_weaponCfg >> "scope") == 2) then { + if (getnumber (_weaponCfg >> "scope") == 2) then + { private _displayName = gettext (_weaponCfg >> "displayName"); private _picture = gettext (_weaponCfg >> "picture"); private _addonListType = _addonList select _weaponTypeID; - _addonListType pushback [_weapon,_displayName,_displayName,_picture,3,false]; + _addonListType pushback [_weapon, _displayName, _displayName, _picture, 3, false]; }; }; } foreach getarray (configfile >> "cfgpatches" >> _x >> "units"); - private _weaponTypeID = -1; + private _weaponTypeID = _types findIf {"Glasses" in _x}; { - if ("Glasses" in _x) exitwith {_weaponTypeID = _foreachindex;}; - } foreach _types; - { - private _glassesCfg = _x; - private _glasses = configName _glassesCfg; - private _displayName = gettext (_glassesCfg >> "displayName"); - private _picture = gettext (_glassesCfg >> "picture"); + private _glasses = configName _x; + private _displayName = gettext (_x >> "displayName"); + private _picture = gettext (_x >> "picture"); private _addonListType = _addonList select _weaponTypeID; - _addonListType pushback [_glasses,_displayName,_displayName,_picture,1,false]; - } forEach ((configfile >> "CfgGlasses") call Achilles_fnc_returnChildren); - _weaponAddons set [count _weaponAddons,_addon]; - _weaponAddons set [count _weaponAddons,_addonList]; - } else { + _addonListType pushback [_glasses, _displayName, _displayName, _picture, 1, false]; + } forEach configProperties [configfile >> "CfgGlasses", "isClass _x"]; + _weaponAddons pushBack _addon; + _weaponAddons pushBack _addonList; + } + else + { _addonList = _weaponAddons select (_addonID + 1); }; { private _current = _list select _foreachindex; - _list set [_foreachindex,_current + (_x - _current)]; + _list set [_foreachindex, _current + (_x - _current)]; } foreach _addonList; - } foreach (curatoraddons _curator); - missionnamespace setvariable ["RscAttrbuteInventory_weaponAddons",_weaponAddons]; - _list = _list apply {[_x,[],{_x select 1}] call BIS_fnc_sortBy}; + } foreach curatoraddons _curator; + missionnamespace setvariable ["RscAttrbuteInventory_weaponAddons", _weaponAddons]; + _list = _list apply {[_x, [], {_x select 1}] call BIS_fnc_sortBy}; RscAttributeInventory_list = _list; }; @@ -165,13 +161,14 @@ switch _mode do { getbackpackcargo _entity ]; private _virtualCargo = [_entity] call Achilles_fnc_getVirtualArsenal; - + RscAttributeInventory_cargoVirtual = []; { private _xCargo = _cargo select _foreachindex; { private _index = (_xCargo select 0) find _x; - if (_index < 0) then { + if (_index < 0) then + { (_xCargo select 0) pushBack (tolower _x); (_xCargo select 1) pushBack 0; }; @@ -179,18 +176,20 @@ switch _mode do { } foreach _x; } foreach _virtualCargo; - RscAttributeInventory_cargo = [[],[]]; + RscAttributeInventory_cargo = [[], []]; { - RscAttributeInventory_cargo set [0,(RscAttributeInventory_cargo select 0) + (_x select 0)]; - RscAttributeInventory_cargo set [1,(RscAttributeInventory_cargo select 1) + (_x select 1)]; + RscAttributeInventory_cargo set [0, (RscAttributeInventory_cargo select 0) + (_x select 0)]; + RscAttributeInventory_cargo set [1, (RscAttributeInventory_cargo select 1) + (_x select 1)]; } foreach _cargo; private _classes = RscAttributeInventory_cargo select 0; - {_classes set [_foreachindex,tolower _x];} foreach _classes; + _classes = _classes apply {toLower _x}; //--- Get limits - private _cfgEntity = configfile >> "cfgvehicles" >> typeof _entity; - RscAttributeInventory_Capacity = [_cfgEntity,"maximumLoad",1e10] call BIS_fnc_returnConfigEntry; + private _cfgEntity = configfile >> "cfgvehicles" >> typeof _entity >> "maximumLoad"; + private _maxLoad = 1e10; + if (isNumber _cfgEntity) then { _maxLoad = getNumber _cfgEntity }; + RscAttributeInventory_Capacity = _maxLoad; //--- Init UI private _display = _params select 0; @@ -199,28 +198,28 @@ switch _mode do { private _ctrl = _display displayctrl _x; _ctrl ctrladdeventhandler [ "buttonclick", - format ["with uinamespace do {['filterChanged',[ctrlparent (_this select 0),%1],objnull] call RscAttributeInventory;};",_foreachindex] + format ["with uinamespace do {['filterChanged', [ctrlparent (_this select 0), %1], objnull] call RscAttributeInventory;};", _foreachindex] ]; } foreach _filterIDCs; RscAttributeInventory_selected = 0; - ["filterChanged",[_display],objnull] call RscAttributeInventory; + ["filterChanged", [_display], objnull] call RscAttributeInventory; private _ctrlList = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_LIST; - _ctrlList ctrladdeventhandler ["lbselchanged",{with uinamespace do {["listSelect",[ctrlparent (_this select 0)],objnull] call RscAttributeInventory}}]; - _ctrlList ctrladdeventhandler ["lbdblclick",{with uinamespace do {["toggleWeaponSpecific",[ctrlparent (_this select 0), _this select 0],objnull] call RscAttributeInventory}}]; - _ctrlList ctrladdeventhandler ["keyDown",{with uinamespace do {["keyDown",_this,objnull] call RscAttributeInventory}; true}]; + _ctrlList ctrladdeventhandler ["lbselchanged", {with uinamespace do {["listSelect", [ctrlparent (_this select 0)], objnull] call RscAttributeInventory}}]; + _ctrlList ctrladdeventhandler ["lbdblclick", {with uinamespace do {["toggleWeaponSpecific", [ctrlparent (_this select 0), _this select 0], objnull] call RscAttributeInventory}}]; + _ctrlList ctrladdeventhandler ["keyDown", {with uinamespace do {["keyDown", _this, objnull] call RscAttributeInventory}; true}]; private _ctrlButtonVA = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_BUTTON_VA; - _ctrlButtonVA ctrladdeventhandler ["buttonclick",{with uinamespace do {["virutalArsenal",[ctrlparent (_this select 0)],objnull] call RscAttributeInventory}}]; + _ctrlButtonVA ctrladdeventhandler ["buttonclick", {with uinamespace do {["virtualArsenal", [ctrlparent (_this select 0)], objnull] call RscAttributeInventory}}]; private _ctrlArrowLeft = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_ARROWLEFT; - _ctrlArrowLeft ctrladdeventhandler ["buttonclick",{with uinamespace do {["listModify",[ctrlparent (_this select 0),-1],objnull] call RscAttributeInventory}}]; + _ctrlArrowLeft ctrladdeventhandler ["buttonclick", {with uinamespace do {["listModify", [ctrlparent (_this select 0), -1], objnull] call RscAttributeInventory}}]; private _ctrlArrowRight = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_ARROWRIGHT; - _ctrlArrowRight ctrladdeventhandler ["buttonclick",{with uinamespace do {["listModify",[ctrlparent (_this select 0),+1],objnull] call RscAttributeInventory}}]; + _ctrlArrowRight ctrladdeventhandler ["buttonclick", {with uinamespace do {["listModify", [ctrlparent (_this select 0), +1], objnull] call RscAttributeInventory}}]; private _ctrlButtonCustom = _Display displayctrl IDC_RSCDISPLAYATTRIBUTES_BUTTONCUSTOM; _ctrlButtonCustom ctrlsettext localize "STR_disp_arcmap_clear"; - _ctrlButtonCustom ctrladdeventhandler ["buttonclick",{with uinamespace do {["clear",[ctrlparent (_this select 0)],objnull] call RscAttributeInventory}}]; + _ctrlButtonCustom ctrladdeventhandler ["buttonclick", {with uinamespace do {["clear", [ctrlparent (_this select 0)], objnull] call RscAttributeInventory}}]; }; case "filterChanged": { private _display = _params select 0; @@ -231,10 +230,10 @@ switch _mode do { private _cursel = if (count _params > 1) then {_params select 1} else {RscAttributeInventory_selected}; RscAttributeInventory_selected = _cursel; private _ctrlList = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_LIST; - _ctrlList setVariable ["WeaponSpecific",nil]; + _ctrlList setVariable ["WeaponSpecific", nil]; private _ctrlLoad = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_LOAD; private _ctrlFilterBackground = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_FILTERBACKGROUND; - private _list = uinamespace getvariable ["RscAttributeInventory_list",[[],[],[],[],[],[],[],[],[],[],[],[]]]; + private _list = uinamespace getvariable ["RscAttributeInventory_list", [[], [], [], [], [], [], [], [], [], [], [], []]]; private _items = []; if (_cursel > 0) then { @@ -257,39 +256,42 @@ switch _mode do { private _classes = RscAttributeInventory_cargo select 0; private _values = RscAttributeInventory_cargo select 1; private _index = _classes find _classLowered; - private _value = if (_index < 0) then { + private _value = if (_index < 0) then + { _index = count _classes; - _classes set [_index,_classLowered]; - _values set [_index,0]; + _classes set [_index, _classLowered]; + _values set [_index, 0]; 0 - } else { + } + else + { _values select _index }; private _arsenal = _class in RscAttributeInventory_cargoVirtual; if ((_cursel == 0 and (_value != 0 or _arsenal)) or (_cursel > 0)) then { - private _lnbAdd = _ctrlList lnbaddrow ["",_displayNameShort,str _value,""]; - _ctrlList lnbsetdata [[_lnbAdd,0],_class]; - _ctrlList lnbsetvalue [[_lnbAdd,0],_value]; - _ctrlList lnbsetvalue [[_lnbAdd,1],_type]; - _ctrlList lnbsetpicture [[_lnbAdd,0],_picture]; + private _lnbAdd = _ctrlList lnbaddrow ["", _displayNameShort, str _value, ""]; + _ctrlList lnbsetdata [[_lnbAdd, 0], _class]; + _ctrlList lnbsetvalue [[_lnbAdd, 0], _value]; + _ctrlList lnbsetvalue [[_lnbAdd, 1], _type]; + _ctrlList lnbsetpicture [[_lnbAdd, 0], _picture]; private _alpha = [0.5, 1] select (_value != 0 or _arsenal); - _ctrlList lnbsetcolor [[_lnbAdd,1],[1,1,1,_alpha]]; - _ctrlList lnbsetcolor [[_lnbAdd,2],[1,1,1,_alpha]]; - _ctrlList lnbsetcolor [[_lnbAdd,3],[1,1,1,_alpha]]; + _ctrlList lnbsetcolor [[_lnbAdd, 1], [1, 1, 1, _alpha]]; + _ctrlList lnbsetcolor [[_lnbAdd, 2], [1, 1, 1, _alpha]]; + _ctrlList lnbsetcolor [[_lnbAdd, 3], [1, 1, 1, _alpha]]; if (_arsenal) then { - _ctrlList lnbsettext [[_lnbAdd,3],"VA"]; - _ctrlList lnbsetvalue [[_lnbAdd,3],1]; + _ctrlList lnbsettext [[_lnbAdd, 3], "VA"]; + _ctrlList lnbsetvalue [[_lnbAdd, 3], 1]; }; - _ctrlList lbsettooltip [_lnbAdd,_displayName]; + _ctrlList lbsettooltip [_lnbAdd, _displayName]; if (_cursel == 0 && _value != 0) then { private _coef = switch _type do { - case 0: {[configfile >> "cfgweapons" >> _class >> "WeaponSlotsInfo","mass",0] call BIS_fnc_returnConfigEntry}; - case 1: {[configfile >> "cfgweapons" >> _class >> "ItemInfo","mass",0] call BIS_fnc_returnConfigEntry}; - case 2: {[configfile >> "cfgmagazines" >> _class,"mass",0] call BIS_fnc_returnConfigEntry}; - case 3: {[configfile >> "cfgvehicles" >> _class,"mass",0] call BIS_fnc_returnConfigEntry}; + case 0: {[configfile >> "cfgweapons" >> _class >> "WeaponSlotsInfo", "mass", 0] call BIS_fnc_returnConfigEntry}; + case 1: {[configfile >> "cfgweapons" >> _class >> "ItemInfo", "mass", 0] call BIS_fnc_returnConfigEntry}; + case 2: {[configfile >> "cfgmagazines" >> _class, "mass", 0] call BIS_fnc_returnConfigEntry}; + case 3: {[configfile >> "cfgvehicles" >> _class, "mass", 0] call BIS_fnc_returnConfigEntry}; default {0}; }; _ctrlLoad progresssetposition (progressposition _ctrlLoad + (_value max 0) * _coef / RscAttributeInventory_Capacity); @@ -297,23 +299,23 @@ switch _mode do { }; }; } foreach _items; - } foreach [[0,1,3],[2]]; - private _prevSelRow = _params param [2,0,[0]]; + } foreach [[0, 1, 3], [2]]; + private _prevSelRow = _params param [2, 0, [0]]; _ctrlList lnbsetcurselrow _prevSelRow; - ["listSelect",[_display],objnull] call RscAttributeInventory; + ["listSelect", [_display], objnull] call RscAttributeInventory; //--- Update UI private _delay = [0, 0.1] select (isnil "_curator"); { private _ctrl = _display displayctrl _x; - private _color = [1,1,1,0.5]; + private _color = [1, 1, 1, 0.5]; private _scale = 0.75; if (_foreachindex == _cursel) then { - _color = [1,1,1,1]; + _color = [1, 1, 1, 1]; _scale = 1; }; _ctrl ctrlsettextcolor _color; - private _pos = [_ctrl,_scale,_delay] call bis_fnc_ctrlsetscale; + private _pos = [_ctrl, _scale, _delay] call bis_fnc_ctrlsetscale; if (_foreachindex == _cursel) then { _ctrlFilterBackground ctrlsetposition _pos; @@ -326,20 +328,20 @@ switch _mode do { private _ctrlList = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_LIST; private _ctrlLoad = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_LOAD; private _cursel = lnbcurselrow _ctrlList; - private _class = _ctrlList lnbdata [_cursel,0]; + private _class = _ctrlList lnbdata [_cursel, 0]; private _classLowered = tolower _class; - private _value = _ctrlList lnbvalue [_cursel,0]; - private _type = _ctrlList lnbvalue [_cursel,1]; + private _value = _ctrlList lnbvalue [_cursel, 0]; + private _type = _ctrlList lnbvalue [_cursel, 1]; private _classes = RscAttributeInventory_cargo select 0; private _values = RscAttributeInventory_cargo select 1; private _index = _classes find _classLowered; if (_index >= 0) then { private _coef = switch _type do { - case 0: {[configfile >> "cfgweapons" >> _class >> "WeaponSlotsInfo","mass",0] call BIS_fnc_returnConfigEntry}; - case 1: {[configfile >> "cfgweapons" >> _class >> "ItemInfo","mass",0] call BIS_fnc_returnConfigEntry}; - case 2: {[configfile >> "cfgmagazines" >> _class,"mass",0] call BIS_fnc_returnConfigEntry}; - case 3: {[configfile >> "cfgvehicles" >> _class,"mass",0] call BIS_fnc_returnConfigEntry}; + case 0: {[configfile >> "cfgweapons" >> _class >> "WeaponSlotsInfo", "mass", 0] call BIS_fnc_returnConfigEntry}; + case 1: {[configfile >> "cfgweapons" >> _class >> "ItemInfo", "mass", 0] call BIS_fnc_returnConfigEntry}; + case 2: {[configfile >> "cfgmagazines" >> _class, "mass", 0] call BIS_fnc_returnConfigEntry}; + case 3: {[configfile >> "cfgvehicles" >> _class, "mass", 0] call BIS_fnc_returnConfigEntry}; default {0}; }; @@ -348,43 +350,43 @@ switch _mode do { private _load = progressposition _ctrlLoad + _add * _coef / RscAttributeInventory_Capacity; if ((_load <= 1 and _value > 0) || _value == 0) then { if (_value > 0 || (_value == 0 && _add < 0)) then {_ctrlLoad progresssetposition _load}; - _values set [_index,_value]; - _ctrlList lnbsetvalue [[_cursel,0],_value]; - _ctrlList lnbsettext [[_cursel,2], [str _value, ""] select (_value < 0)]; + _values set [_index, _value]; + _ctrlList lnbsetvalue [[_cursel, 0], _value]; + _ctrlList lnbsettext [[_cursel, 2], [str _value, ""] select (_value < 0)]; private _arsenal = _class in RscAttributeInventory_cargoVirtual; private _alpha = [0.5, 1] select (_value != 0 or _arsenal); - _ctrlList lnbsetcolor [[_cursel,1],[1,1,1,_alpha]]; - _ctrlList lnbsetcolor [[_cursel,2],[1,1,1,_alpha]]; - _ctrlList lnbsetcolor [[_cursel,3],[1,1,1,_alpha]]; - ["listSelect",[_display],objnull] call RscAttributeInventory; + _ctrlList lnbsetcolor [[_cursel, 1], [1, 1, 1, _alpha]]; + _ctrlList lnbsetcolor [[_cursel, 2], [1, 1, 1, _alpha]]; + _ctrlList lnbsetcolor [[_cursel, 3], [1, 1, 1, _alpha]]; + ["listSelect", [_display], objnull] call RscAttributeInventory; }; }; }; case "listSelect": { - private ["_display","_ctrlList","_cursel","_value","_ctrlArrowLeft"]; + private ["_display", "_ctrlList", "_cursel", "_value", "_ctrlArrowLeft"]; _display = _params select 0; _ctrlList = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_LIST; _cursel = lnbcurselrow _ctrlList; - _value = _ctrlList lnbvalue [_cursel,0]; + _value = _ctrlList lnbvalue [_cursel, 0]; _ctrlArrowLeft = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_ARROWLEFT; _ctrlArrowLeft ctrlenable (_value > 0); }; - case "virutalArsenal": { + case "virtualArsenal": { private _display = _params select 0; private _ctrlList = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_LIST; private _cursel = lnbcurselrow _ctrlList; - private _arsenal = _ctrlList lnbvalue [_cursel,3]; - private _value = _ctrlList lnbvalue [_cursel,0]; + private _arsenal = _ctrlList lnbvalue [_cursel, 3]; + private _value = _ctrlList lnbvalue [_cursel, 0]; _arsenal = 1 - _arsenal; - _ctrlList lnbsetvalue [[_cursel,3], _arsenal]; + _ctrlList lnbsetvalue [[_cursel, 3], _arsenal]; private _alpha = [0.5, 1] select (_arsenal == 1 or _value > 0); - _ctrlList lnbsetcolor [[_cursel,1],[1,1,1,_alpha]]; - _ctrlList lnbsetcolor [[_cursel,2],[1,1,1,_alpha]]; - _ctrlList lnbsetcolor [[_cursel,3],[1,1,1,_alpha]]; - private _class = _ctrlList lnbdata [_cursel,0]; + _ctrlList lnbsetcolor [[_cursel, 1], [1, 1, 1, _alpha]]; + _ctrlList lnbsetcolor [[_cursel, 2], [1, 1, 1, _alpha]]; + _ctrlList lnbsetcolor [[_cursel, 3], [1, 1, 1, _alpha]]; + private _class = _ctrlList lnbdata [_cursel, 0]; private _text = if (_arsenal == 1) then { RscAttributeInventory_cargoVirtual pushBack _class; @@ -394,7 +396,7 @@ switch _mode do { RscAttributeInventory_cargoVirtual = RscAttributeInventory_cargoVirtual - [_class]; "" }; - _ctrlList lnbsettext [[_cursel,3], _text]; + _ctrlList lnbsettext [[_cursel, 3], _text]; }; case "keyDown": { @@ -403,19 +405,19 @@ switch _mode do { { case (_key == DIK_MULTIPLY): { - ["virutalArsenal",[ctrlparent _ctrlList],objnull] call RscAttributeInventory; + ["virtualArsenal", [ctrlparent _ctrlList], objnull] call RscAttributeInventory; }; case (_key == DIK_DIVIDE): { - ["toggleWeaponSpecific",[ctrlparent _ctrlList, _ctrlList],objnull] call RscAttributeInventory; + ["toggleWeaponSpecific", [ctrlparent _ctrlList, _ctrlList], objnull] call RscAttributeInventory; }; case (_key == DIK_ADD): { - ["listModify",[ctrlparent _ctrlList,+1],objnull] call RscAttributeInventory; + ["listModify", [ctrlparent _ctrlList, +1], objnull] call RscAttributeInventory; }; case (_key == DIK_SUBTRACT): { - ["listModify",[ctrlparent _ctrlList,-1],objnull] call RscAttributeInventory; + ["listModify", [ctrlparent _ctrlList, -1], objnull] call RscAttributeInventory; }; default { @@ -424,8 +426,8 @@ switch _mode do { { for "_i" from 0 to ((lnbSize _ctrlList select 0) - 1) do { - private _displayName = _ctrlList lnbText [_i,1]; - if (toupper (_displayName select [0,1]) == _letter) exitWith + private _displayName = _ctrlList lnbText [_i, 1]; + if (toupper (_displayName select [0, 1]) == _letter) exitWith { _ctrlList lnbSetCurSelRow _i; }; @@ -440,19 +442,19 @@ switch _mode do { private _classes = RscAttributeInventory_cargo select 0; private _values = RscAttributeInventory_cargo select 1; - private _cursel = _ctrlList getVariable ["WeaponSpecific",nil]; + private _cursel = _ctrlList getVariable ["WeaponSpecific", nil]; if (!isNil "_cursel") exitWith { - ["filterChanged",[_display,RscAttributeInventory_selected,_cursel],objnull] call RscAttributeInventory; + ["filterChanged", [_display, RscAttributeInventory_selected, _cursel], objnull] call RscAttributeInventory; }; _cursel = lnbCurSelRow _ctrlList; - private _weapon = _ctrlList lnbdata [_cursel,0]; + private _weapon = _ctrlList lnbdata [_cursel, 0]; if (!isclass (configfile >> "cfgweapons" >> _weapon)) exitWith {}; - if (getnumber (configfile >> "cfgweapons" >> _weapon >> "type") in [4096,131072]) exitWith {}; + if (getnumber (configfile >> "cfgweapons" >> _weapon >> "type") in [4096, 131072]) exitWith {}; - _ctrlList setVariable ["WeaponSpecific",_cursel]; + _ctrlList setVariable ["WeaponSpecific", _cursel]; private _ctrlLable = _display displayCtrl IDC_RSCATTRIBUTEINVENTORY_FILTER13; _ctrlLable ctrlSetText (localize "STR_AMAE_WEAPON_SPECIFIC"); @@ -477,7 +479,7 @@ switch _mode do { } foreach getarray (_muzzle >> "magazines"); } foreach getarray (_weaponCfg >> "muzzles"); - private _list = uinamespace getvariable ["RscAttributeInventory_list",[[],[],[],[],[],[],[],[],[],[],[],[]]]; + private _list = uinamespace getvariable ["RscAttributeInventory_list", [[], [], [], [], [], [], [], [], [], [], [], []]]; private _items = []; {_items append _x} foreach _list; @@ -495,36 +497,36 @@ switch _mode do { private _value = _reducedValues select _index; private _arsenal = _class in RscAttributeInventory_cargoVirtual; - private _lnbAdd = _ctrlList lnbaddrow ["",_displayNameShort,str _value,""]; - _ctrlList lnbsetdata [[_lnbAdd,0],_class]; - _ctrlList lnbsetvalue [[_lnbAdd,0],_value]; - _ctrlList lnbsetvalue [[_lnbAdd,1],_type]; - _ctrlList lnbsetpicture [[_lnbAdd,0],_picture]; + private _lnbAdd = _ctrlList lnbaddrow ["", _displayNameShort, str _value, ""]; + _ctrlList lnbsetdata [[_lnbAdd, 0], _class]; + _ctrlList lnbsetvalue [[_lnbAdd, 0], _value]; + _ctrlList lnbsetvalue [[_lnbAdd, 1], _type]; + _ctrlList lnbsetpicture [[_lnbAdd, 0], _picture]; private _alpha = [0.5, 1] select (_value != 0 or _arsenal); - _ctrlList lnbsetcolor [[_lnbAdd,1],[1,1,1,_alpha]]; - _ctrlList lnbsetcolor [[_lnbAdd,2],[1,1,1,_alpha]]; - _ctrlList lnbsetcolor [[_lnbAdd,3],[1,1,1,_alpha]]; + _ctrlList lnbsetcolor [[_lnbAdd, 1], [1, 1, 1, _alpha]]; + _ctrlList lnbsetcolor [[_lnbAdd, 2], [1, 1, 1, _alpha]]; + _ctrlList lnbsetcolor [[_lnbAdd, 3], [1, 1, 1, _alpha]]; if (_arsenal) then { - _ctrlList lnbsettext [[_lnbAdd,3],"VA"]; - _ctrlList lnbsetvalue [[_lnbAdd,3],1]; + _ctrlList lnbsettext [[_lnbAdd, 3], "VA"]; + _ctrlList lnbsetvalue [[_lnbAdd, 3], 1]; }; - _ctrlList lbsettooltip [_lnbAdd,_displayName]; + _ctrlList lbsettooltip [_lnbAdd, _displayName]; }; } foreach _items; - } foreach [[0,1,3],[2]]; + } foreach [[0, 1, 3], [2]]; _ctrlList lnbsetcurselrow 0; - ["listSelect",[_display],objnull] call RscAttributeInventory; + ["listSelect", [_display], objnull] call RscAttributeInventory; }; case "clear": { private _values = RscAttributeInventory_cargo select 1; { - _values set [_foreachindex,0]; + _values set [_foreachindex, 0]; } foreach _values; RscAttributeInventory_cargoVirtual = []; - ["filterChanged",_params,objnull] call RscAttributeInventory; + ["filterChanged", _params, objnull] call RscAttributeInventory; private _display = _params select 0; private _ctrlLoad = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_LOAD; @@ -546,17 +548,17 @@ switch _mode do { if (_x != 0) then { private _class = _classes select _foreachindex; switch true do { - case (getnumber (configfile >> "cfgweapons" >> _class >> "type") in [4096,131072] or isClass (configfile >> "CfgGlasses" >> _class)): { - _items pushBack [_class,abs _x]; + case (getnumber (configfile >> "cfgweapons" >> _class >> "type") in [4096, 131072] or isClass (configfile >> "CfgGlasses" >> _class)): { + _items pushBack [_class, abs _x]; }; case (isclass (configfile >> "cfgweapons" >> _class)): { - _weapons pushBack [_class,abs _x]; + _weapons pushBack [_class, abs _x]; }; case (isclass (configfile >> "cfgmagazines" >> _class)): { - _magazines pushBack [_class,abs _x]; + _magazines pushBack [_class, abs _x]; }; case (isclass (configfile >> "cfgvehicles" >> _class)): { - _backpacks pushBack [_class,abs _x]; + _backpacks pushBack [_class, abs _x]; }; }; }; @@ -572,12 +574,12 @@ switch _mode do { clearweaponcargoglobal _box; clearmagazinecargoglobal _box; clearbackpackcargoglobal _box; - + {_box additemcargoglobal _x} forEach _items; {_box addweaponcargoglobal _x} forEach _weapons; {_box addmagazinecargoglobal _x} forEach _magazines; {_box addbackpackcargoglobal _x} forEach _backpacks; - + with missionNamespace do {[_box, uiNamespace getVariable ["RscAttributeInventory_cargoVirtual", []], true] call Achilles_fnc_updateVirtualArsenal}; } forEach _curatorSelected; }; From 55cdb809cd04bad93605b097bc344be80e1046ab Mon Sep 17 00:00:00 2001 From: NeilZar Date: Thu, 14 Feb 2019 01:01:21 +0100 Subject: [PATCH 2/3] Couple more improvements --- .../ui_f/scripts/RscAttributeInventory.sqf | 113 +++++++++--------- 1 file changed, 58 insertions(+), 55 deletions(-) diff --git a/@AresModAchillesExpansion/addons/ui_f/scripts/RscAttributeInventory.sqf b/@AresModAchillesExpansion/addons/ui_f/scripts/RscAttributeInventory.sqf index d7135b40..6c4a6ec4 100644 --- a/@AresModAchillesExpansion/addons/ui_f/scripts/RscAttributeInventory.sqf +++ b/@AresModAchillesExpansion/addons/ui_f/scripts/RscAttributeInventory.sqf @@ -53,21 +53,20 @@ switch _mode do { private _addonList = [[], [], [], [], [], [], [], [], [], [], [], []]; private _addonID = _weaponAddons find _addon; if (_addonID < 0) then - { + { { private _weapon = tolower _x; private _weaponType = _weapon call bis_fnc_itemType; - _weaponType params ["_weaponTypeCategory", "_weaponTypeSpecific"]; + _weaponType params ["_weaponTypeCategory", "_weaponTypeSpecific"]; private _weaponTypeID = _types findIf { _weaponTypeSpecific in _x }; - //_weaponTypeID = _types find (_weaponType select 0); - if (_weaponTypeCategory != "VehicleWeapon" && _weaponTypeID >= 0 && (_weapon == [_weapon] call bis_fnc_baseWeapon)) then - { + if (_weaponTypeCategory != "VehicleWeapon" && {_weaponTypeID >= 0 && (_weapon == [_weapon] call bis_fnc_baseWeapon)}) then + { private _weaponCfg = configfile >> "cfgweapons" >> _weapon; private _weaponPublic = getnumber (_weaponCfg >> "scope") == 2; private _addonListType = _addonList select _weaponTypeID; if (_weaponPublic) then - { + { private _displayName = gettext (_weaponCfg >> "displayName"); private _picture = gettext (_weaponCfg >> "picture"); { @@ -77,27 +76,27 @@ switch _mode do { } foreach configProperties [_weaponCfg >> "linkeditems", "isClass _x"]; private _displayNameShort = _displayName; if (count _displayNameShort > 41) then - { // Cut when the name is too long (41 chars is approximate) + { // Cut when the name is too long (41 chars is approximate) _displayNameShort = (_displayNameShort select [0, 41]) + "..."; }; private _type = [0, 1] select (getnumber (configfile >> "cfgweapons" >> _weapon >> "type") in [4096, 131072]); _addonListType pushback [_weapon, _displayName, _displayNameShort, _picture, _type, false]; }; // Add magazines compatible with the weapon - if (_weaponPublic || _weapon in ["throw", "put"]) then - { + if (_weaponPublic || {_weapon in ["throw", "put"]}) then + { { private _muzzle = if (_x == "this") then {_weaponCfg} else {_weaponCfg >> _x}; { private _mag = tolower _x; if (_addonListType findIf {(_x select 0) isEqualTo _mag} == -1) then - { + { private _magCfg = configfile >> "cfgmagazines" >> _mag; - if (getnumber (_magCfg >> "scope") == 2) then - { + if (getNumber (_magCfg >> "scope") == 2) then + { private _displayName = gettext (_magCfg >> "displayName"); if (count _displayName > 41) then - { //--- Cut when the name is too long (41 chars is approximate) + { //--- Cut when the name is too long (41 chars is approximate) _displayName = (_displayName select [0, 41]) + "..."; }; private _picture = gettext (_magCfg >> "picture"); @@ -116,10 +115,10 @@ switch _mode do { _weaponType params ["", "_weaponTypeSpecific"]; private _weaponTypeID = _types findIf { _weaponTypeSpecific in _x }; if (_weaponTypeID >= 0) then - { + { private _weaponCfg = configfile >> "cfgvehicles" >> _weapon; if (getnumber (_weaponCfg >> "scope") == 2) then - { + { private _displayName = gettext (_weaponCfg >> "displayName"); private _picture = gettext (_weaponCfg >> "picture"); private _addonListType = _addonList select _weaponTypeID; @@ -139,8 +138,8 @@ switch _mode do { _weaponAddons pushBack _addon; _weaponAddons pushBack _addonList; } - else - { + else + { _addonList = _weaponAddons select (_addonID + 1); }; { @@ -168,7 +167,7 @@ switch _mode do { { private _index = (_xCargo select 0) find _x; if (_index < 0) then - { + { (_xCargo select 0) pushBack (tolower _x); (_xCargo select 1) pushBack 0; }; @@ -183,12 +182,12 @@ switch _mode do { } foreach _cargo; private _classes = RscAttributeInventory_cargo select 0; - _classes = _classes apply {toLower _x}; + _classes = _classes apply {toLower _x}; //--- Get limits private _cfgEntity = configfile >> "cfgvehicles" >> typeof _entity >> "maximumLoad"; - private _maxLoad = 1e10; - if (isNumber _cfgEntity) then { _maxLoad = getNumber _cfgEntity }; + private _maxLoad = 1e10; + if (isNumber _cfgEntity) then { _maxLoad = getNumber _cfgEntity }; RscAttributeInventory_Capacity = _maxLoad; //--- Init UI @@ -257,25 +256,25 @@ switch _mode do { private _values = RscAttributeInventory_cargo select 1; private _index = _classes find _classLowered; private _value = if (_index < 0) then - { + { _index = count _classes; _classes set [_index, _classLowered]; _values set [_index, 0]; 0 } - else - { + else + { _values select _index }; private _arsenal = _class in RscAttributeInventory_cargoVirtual; - if ((_cursel == 0 and (_value != 0 or _arsenal)) or (_cursel > 0)) then { + if ((_cursel == 0 && {_value != 0 || _arsenal}) || (_cursel > 0)) then { private _lnbAdd = _ctrlList lnbaddrow ["", _displayNameShort, str _value, ""]; _ctrlList lnbsetdata [[_lnbAdd, 0], _class]; _ctrlList lnbsetvalue [[_lnbAdd, 0], _value]; _ctrlList lnbsetvalue [[_lnbAdd, 1], _type]; _ctrlList lnbsetpicture [[_lnbAdd, 0], _picture]; - private _alpha = [0.5, 1] select (_value != 0 or _arsenal); + private _alpha = [0.5, 1] select (_value != 0 || _arsenal); _ctrlList lnbsetcolor [[_lnbAdd, 1], [1, 1, 1, _alpha]]; _ctrlList lnbsetcolor [[_lnbAdd, 2], [1, 1, 1, _alpha]]; _ctrlList lnbsetcolor [[_lnbAdd, 3], [1, 1, 1, _alpha]]; @@ -286,12 +285,14 @@ switch _mode do { }; _ctrlList lbsettooltip [_lnbAdd, _displayName]; - if (_cursel == 0 && _value != 0) then { - private _coef = switch _type do { - case 0: {[configfile >> "cfgweapons" >> _class >> "WeaponSlotsInfo", "mass", 0] call BIS_fnc_returnConfigEntry}; - case 1: {[configfile >> "cfgweapons" >> _class >> "ItemInfo", "mass", 0] call BIS_fnc_returnConfigEntry}; - case 2: {[configfile >> "cfgmagazines" >> _class, "mass", 0] call BIS_fnc_returnConfigEntry}; - case 3: {[configfile >> "cfgvehicles" >> _class, "mass", 0] call BIS_fnc_returnConfigEntry}; + if (_cursel == 0 && _value != 0) then + { + private _coef = switch _type do + { + case 0: {getNumber (configfile >> "cfgweapons" >> _class >> "WeaponSlotsInfo" >> "mass")}; + case 1: {getNumber (configfile >> "cfgweapons" >> _class >> "ItemInfo" >> "mass")}; + case 2: {getNumber (configfile >> "cfgmagazines" >> _class >> "mass")}; + case 3: {getNumber (configfile >> "cfgvehicles" >> _class >> "mass")}; default {0}; }; _ctrlLoad progresssetposition (progressposition _ctrlLoad + (_value max 0) * _coef / RscAttributeInventory_Capacity); @@ -310,14 +311,16 @@ switch _mode do { private _ctrl = _display displayctrl _x; private _color = [1, 1, 1, 0.5]; private _scale = 0.75; - if (_foreachindex == _cursel) then { + if (_foreachindex == _cursel) then + { _color = [1, 1, 1, 1]; _scale = 1; }; _ctrl ctrlsettextcolor _color; private _pos = [_ctrl, _scale, _delay] call bis_fnc_ctrlsetscale; - if (_foreachindex == _cursel) then { + if (_foreachindex == _cursel) then + { _ctrlFilterBackground ctrlsetposition _pos; _ctrlFilterBackground ctrlcommit 0; }; @@ -336,25 +339,27 @@ switch _mode do { private _classes = RscAttributeInventory_cargo select 0; private _values = RscAttributeInventory_cargo select 1; private _index = _classes find _classLowered; - if (_index >= 0) then { - private _coef = switch _type do { - case 0: {[configfile >> "cfgweapons" >> _class >> "WeaponSlotsInfo", "mass", 0] call BIS_fnc_returnConfigEntry}; - case 1: {[configfile >> "cfgweapons" >> _class >> "ItemInfo", "mass", 0] call BIS_fnc_returnConfigEntry}; - case 2: {[configfile >> "cfgmagazines" >> _class, "mass", 0] call BIS_fnc_returnConfigEntry}; - case 3: {[configfile >> "cfgvehicles" >> _class, "mass", 0] call BIS_fnc_returnConfigEntry}; + if (_index >= 0) then + { + private _coef = switch _type do + { + case 0: {getNumber (configfile >> "cfgweapons" >> _class >> "WeaponSlotsInfo" >> "mass")}; + case 1: {getNumber (configfile >> "cfgweapons" >> _class >> "ItemInfo" >> "mass")}; + case 2: {getNumber (configfile >> "cfgmagazines" >> _class >> "mass")}; + case 3: {getNumber (configfile >> "cfgvehicles" >> _class >> "mass")}; default {0}; }; _value = _value + _add; - //if (_value < 0 || (_value == 0 && _add > 0)) then {_add = -_add;}; private _load = progressposition _ctrlLoad + _add * _coef / RscAttributeInventory_Capacity; - if ((_load <= 1 and _value > 0) || _value == 0) then { - if (_value > 0 || (_value == 0 && _add < 0)) then {_ctrlLoad progresssetposition _load}; + if (_value == 0 || {_load <= 1 && _value > 0}) then + { + if (_value > 0 || {_value == 0 && _add < 0}) then {_ctrlLoad progresssetposition _load}; _values set [_index, _value]; _ctrlList lnbsetvalue [[_cursel, 0], _value]; _ctrlList lnbsettext [[_cursel, 2], [str _value, ""] select (_value < 0)]; private _arsenal = _class in RscAttributeInventory_cargoVirtual; - private _alpha = [0.5, 1] select (_value != 0 or _arsenal); + private _alpha = [0.5, 1] select (_value != 0 || _arsenal); _ctrlList lnbsetcolor [[_cursel, 1], [1, 1, 1, _alpha]]; _ctrlList lnbsetcolor [[_cursel, 2], [1, 1, 1, _alpha]]; _ctrlList lnbsetcolor [[_cursel, 3], [1, 1, 1, _alpha]]; @@ -363,13 +368,12 @@ switch _mode do { }; }; case "listSelect": { - private ["_display", "_ctrlList", "_cursel", "_value", "_ctrlArrowLeft"]; - _display = _params select 0; - _ctrlList = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_LIST; - _cursel = lnbcurselrow _ctrlList; - _value = _ctrlList lnbvalue [_cursel, 0]; + private _display = _params select 0; + private _ctrlList = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_LIST; + private _cursel = lnbcurselrow _ctrlList; + private _value = _ctrlList lnbvalue [_cursel, 0]; - _ctrlArrowLeft = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_ARROWLEFT; + private _ctrlArrowLeft = _display displayctrl IDC_RSCATTRIBUTEINVENTORY_ARROWLEFT; _ctrlArrowLeft ctrlenable (_value > 0); }; @@ -382,7 +386,7 @@ switch _mode do { private _value = _ctrlList lnbvalue [_cursel, 0]; _arsenal = 1 - _arsenal; _ctrlList lnbsetvalue [[_cursel, 3], _arsenal]; - private _alpha = [0.5, 1] select (_arsenal == 1 or _value > 0); + private _alpha = [0.5, 1] select (_arsenal == 1 || _value > 0); _ctrlList lnbsetcolor [[_cursel, 1], [1, 1, 1, _alpha]]; _ctrlList lnbsetcolor [[_cursel, 2], [1, 1, 1, _alpha]]; _ctrlList lnbsetcolor [[_cursel, 3], [1, 1, 1, _alpha]]; @@ -462,7 +466,6 @@ switch _mode do { private _index = _classes find _weapon; private _reducedValues = [_values select _index]; private _weaponCfg = configfile >> "cfgweapons" >> _weapon; - private _magazines = []; { private _muzzle = if (_x == "this") then {_weaponCfg} else {_weaponCfg >> _x};; @@ -489,7 +492,7 @@ switch _mode do { { _x params ["_class", "_displayName", "_displayNameShort", "_picture", "_type", "_isDuplicate"]; - if (_type in _types && (!_isDuplicate or (RscAttributeInventory_selected > 0))) then { + if ((!_isDuplicate || RscAttributeInventory_selected > 0) && {_type in _types}) then { _index = _reducedClasses find _class; if (_index == -1) exitWith {}; @@ -502,7 +505,7 @@ switch _mode do { _ctrlList lnbsetvalue [[_lnbAdd, 0], _value]; _ctrlList lnbsetvalue [[_lnbAdd, 1], _type]; _ctrlList lnbsetpicture [[_lnbAdd, 0], _picture]; - private _alpha = [0.5, 1] select (_value != 0 or _arsenal); + private _alpha = [0.5, 1] select (_value != 0 || _arsenal); _ctrlList lnbsetcolor [[_lnbAdd, 1], [1, 1, 1, _alpha]]; _ctrlList lnbsetcolor [[_lnbAdd, 2], [1, 1, 1, _alpha]]; _ctrlList lnbsetcolor [[_lnbAdd, 3], [1, 1, 1, _alpha]]; @@ -548,7 +551,7 @@ switch _mode do { if (_x != 0) then { private _class = _classes select _foreachindex; switch true do { - case (getnumber (configfile >> "cfgweapons" >> _class >> "type") in [4096, 131072] or isClass (configfile >> "CfgGlasses" >> _class)): { + case (getnumber (configfile >> "cfgweapons" >> _class >> "type") in [4096, 131072] || {isClass (configfile >> "CfgGlasses" >> _class)}): { _items pushBack [_class, abs _x]; }; case (isclass (configfile >> "cfgweapons" >> _class)): { From 0670e04a334693ab51d3efac1cf6116767cf5f58 Mon Sep 17 00:00:00 2001 From: NeilZar Date: Sun, 17 Feb 2019 21:19:25 +0100 Subject: [PATCH 3/3] Update RscAttributeInventory.sqf --- .../addons/ui_f/scripts/RscAttributeInventory.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/@AresModAchillesExpansion/addons/ui_f/scripts/RscAttributeInventory.sqf b/@AresModAchillesExpansion/addons/ui_f/scripts/RscAttributeInventory.sqf index 6c4a6ec4..97d4eb82 100644 --- a/@AresModAchillesExpansion/addons/ui_f/scripts/RscAttributeInventory.sqf +++ b/@AresModAchillesExpansion/addons/ui_f/scripts/RscAttributeInventory.sqf @@ -76,7 +76,8 @@ switch _mode do { } foreach configProperties [_weaponCfg >> "linkeditems", "isClass _x"]; private _displayNameShort = _displayName; if (count _displayNameShort > 41) then - { // Cut when the name is too long (41 chars is approximate) + { + // Cut when the name is too long (41 chars is approximate) _displayNameShort = (_displayNameShort select [0, 41]) + "..."; }; private _type = [0, 1] select (getnumber (configfile >> "cfgweapons" >> _weapon >> "type") in [4096, 131072]);