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

Issues 305 #319

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions addons/main/GUI/ESE.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ class ENH_ESE
"SortbyClass",
"SortbyCount",
"SortbyMod",
"SortbyType"
"SortbyType",
"ImportFromClipboard"
};
};
class FolderFilter
Expand Down Expand Up @@ -269,6 +270,12 @@ class ENH_ESE
action = "'type' call ENH_fnc_ESE_sort";
shortcuts[] = {DIK_5};
};
class ImportFromClipboard
{
text = "$STR_ENH_MAIN_ESE_IMPORTFROMCLIPBOARD";
action = "[false, [], true] call ENH_fnc_ESE_loadAttributeValue";
shortcuts[] = {DIK_6};
};
//Filter
class ARs
{
Expand Down Expand Up @@ -479,4 +486,4 @@ class ENH_ESE
onButtonClick = "0 spawn ENH_fnc_ESE_close";
};
};
};
};
4 changes: 3 additions & 1 deletion addons/main/cfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ class CfgFunctions
class ESE_close;
class ESE_export;
class ESE_fullArsenal;
class ESE_getConfigValues;
class ESE_handleTemplates;
class ESE_lbAdd;
class ESE_lnbAdd;
class ESE_loadAttributeValue;
class ESE_onModFilterChanged;
class ESE_open;
class ESE_parseClipboardValues;
class ESE_removeItem;
class ESE_resetSearch;
class ESE_resetStorage;
Expand Down Expand Up @@ -249,4 +251,4 @@ class CfgFunctions
// class testDisplays;
// };
};
};
};
177 changes: 95 additions & 82 deletions addons/main/functions/GUI/ESE/fn_ESE_applyAttribute.sqf
Original file line number Diff line number Diff line change
@@ -1,82 +1,95 @@
/*
Author: R3vo

Date: 2020-06-14

Description:
Used by the ENH_ESE GUI. Takes items from inventory list and applies the attribute. Can also only return the attribute value.

Parameter(s):
0: BOOLEAN - True to not set the attribute and only return the attribute value. Default: false

Returns:
ARRAY, NOTHING: See Parameters
*/

#include "\x\enh\addons\main\script_component.hpp"

disableSerialization;
params [["_return", false]];
private _display = uiNamespace getVariable "ENH_Display_ESE";
private _itemsHashMap = uiNamespace getVariable "ENH_ESE_itemsHashMap";
private _ctrlInventory = CTRL(IDC_ESE_INVENTORYLIST);
private _rows = lnbSize _ctrlInventory select 0;

private _weapons = [];
private _magazines = [];
private _items = [];
private _backpacks = [];

private _weaponsAmount = [];
private _magazinesAmount = [];
private _itemsAmount = [];
private _backpacksAmount = [];

for "_i" from 0 to _rows - 1 do
{
private _configName = _ctrlInventory lnbData [_i, 0];
private _amount = _ctrlInventory lnbValue [_i, 1];
(_itemsHashMap getOrDefault [toLower _configName, []]) params ["", "", "", "", ["_category", ""], ["_specificType", ""]];
switch (true) do
{
case (_category isEqualTo "Weapon"):
{
_weapons pushBack _configName;
_weaponsAmount pushBack _amount;
};
case (_category in ["Mine", "Magazine"]):
{
_magazines pushBack _configName;
_magazinesAmount pushBack _amount;
};
case (_category in ["Item", "Equipment"]):
{
if (_specificType isEqualTo "Backpack") then
{
_backpacks pushBack _configName;
_backpacksAmount pushBack _amount;
}
else
{
_items pushBack _configName;
_itemsAmount pushBack _amount;
};
};
};
};

private _value = str
[
[
[_weapons, _weaponsAmount],
[_magazines, _magazinesAmount],
[_items, _itemsAmount],
[_backpacks, _backpacksAmount]
],
_display getVariable ["ENH_ESE_IsVirtual", false]
];

if (_return) exitWith {_value};
ENH_ESE_target set3DENAttribute ["ammoBox", _value];

["ENH_actionPerformed"] call BIS_fnc_3DENNotification;
/*
Author: R3vo

Date: 2020-06-14

Description:
Used by the ENH_ESE GUI. Takes items from inventory list and applies the attribute. Can also only return the attribute value.

Parameter(s):
0: BOOLEAN - True to not set the attribute and only return the attribute value. Default: false
1: ARRAY - Items details. Same data structure as _itemsHashMap.

Returns:
ARRAY, NOTHING: See Parameters
*/

#include "\x\enh\addons\main\script_component.hpp"
disableSerialization;
params [["_return", false], ["_itemsDetails", []]];
private _display = uiNamespace getVariable "ENH_Display_ESE";
private _ctrlInventory = CTRL(IDC_ESE_INVENTORYLIST);
private _rows = lnbSize _ctrlInventory select 0;

private _weapons = [];
private _magazines = [];
private _items = [];
private _backpacks = [];

private _weaponsAmount = [];
private _magazinesAmount = [];
private _itemsAmount = [];
private _backpacksAmount = [];

private _itemsHashMap = uiNamespace getVariable "ENH_ESE_itemsHashMap";

private _rowCount = count _itemsDetails;
if (_rowCount > 0) then {
_itemsHashMap = _itemsDetails;
_rows = _rowCount
};

for "_i" from 0 to _rows - 1 do
{
private "_configName";
private _amount = 1;
if (_rowCount == 0) then {
_configName = _ctrlInventory lnbData [_i, 0];
_amount = _ctrlInventory lnbValue [_i, 1]
} else {
_configName = (keys _itemsHashMap) select _i
};
(_itemsHashMap getOrDefault [toLower _configName, []]) params ["", "", "", "", ["_category", ""], ["_specificType", ""]];
switch (true) do
{
case (_category isEqualTo "Weapon"):
{
_weapons pushBack _configName;
_weaponsAmount pushBack _amount;
};
case (_category in ["Mine", "Magazine"]):
{
_magazines pushBack _configName;
_magazinesAmount pushBack _amount;
};
case (_category in ["Item", "Equipment"]):
{
if (_specificType isEqualTo "Backpack") then
{
_backpacks pushBack _configName;
_backpacksAmount pushBack _amount;
}
else
{
_items pushBack _configName;
_itemsAmount pushBack _amount;
};
};
};
};

private _value = str
[
[
[_weapons, _weaponsAmount],
[_magazines, _magazinesAmount],
[_items, _itemsAmount],
[_backpacks, _backpacksAmount]
],
_display getVariable ["ENH_ESE_IsVirtual", false]
];

if (_return) exitWith {_value};
ENH_ESE_target set3DENAttribute ["ammoBox", _value];

["ENH_actionPerformed"] call BIS_fnc_3DENNotification;
126 changes: 63 additions & 63 deletions addons/main/functions/GUI/ESE/fn_ESE_getConfigValues.sqf
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
/*
Author: Pixelated_Grunt

Date: 2024-08-20

Description:
Return all items configuration details.

Parameter(s):
ARRAY - An array of class names or configs to get details for.

Returns:
ARRAY - ARRAY of whitelisted items, HASHMAP of items with details, ARRAY of available addons
*/


#include "\x\enh\addons\main\script_component.hpp"
#define TYPES_WHITELIST ["AssaultRifle", "MachineGun", "SniperRifle", "Shotgun", "SubmachineGun", "RocketLauncher", "Handgun", "Grenade", "Magazine",\
"Mine", "AccessoryBipod", "AccessoryMuzzle", "AccessoryPointer", "AccessorySights", "Uniform", "Vest", "Backpack", "Headgear", "Glasses", "NVGoggles", "Item", "MissileLauncher"]

params [["_input", [], []]];

private _addons = [["", localize "$STR_3DEN_ATTRIBUTES_DEFAULT_UNCHANGED_TEXT", ""]];//Everything
private _itemsHashMap = createHashMap;

if (count _input > 0) then {
diag_log format["_input: (%1)", _input];
_input apply
{
private _class = configName _x;
(_class call BIS_fnc_itemType) params ["_category", "_specificType"];
if ((_category in TYPES_WHITELIST || _specificType in TYPES_WHITELIST && _specificType != "UnknownEquipment") && {if (isArray (_x >> "muzzles")) then {_class call BIS_fnc_baseWeapon == _class} else {true}}) then
{
//Modify some _specificTypes
if (_specificType == "MissileLauncher") then {_specificType = "RocketLauncher"};//Same type for all launchers
if (_specificType in ["Throw", "SmokeShell", "Flare"]) then {_specificType = "Grenade"};//Same type for all grenades, flares, chemlights, smoke
if (_specificType == "AccessoryBipod" && {_class isKindOf ["CBA_MiscItem", configFile >> "CfgWeapons"]}) then {_specificType = "Item"};

//Get the DLC, make sure it's a DLC and was not modified by a mod (CBA, ACE)
(_x call ENH_fnc_getConfigSourceAddon) params [["_addonClass", ""], ["_addonName", ""], ["_addonIcon", ""]];
_addons pushBackUnique [_addonClass, _addonName, _addonIcon];

_itemsHashMap insert
[
[
toLower _class, //Make the key lowercase. Some configs don't use the proper casing (Thanks BI ;P)
[
getText (_x >> "DisplayName"),
getText (_x >> "Picture"),
_addonClass,
_addonIcon,
_category,
_specificType,
getText (_x >> "descriptionShort") regexReplace ["<br[\W ]*\/>", "\n"],
_class //Properly cased configname for displaying
]
]
]
}
}
};

[TYPES_WHITELIST, _itemsHashMap, _addons]
/*
Author: Pixelated_Grunt
Date: 2024-08-20
Description:
Return all items configuration details.
Parameter(s):
ARRAY - An array of class names or configs to get details for.
Returns:
ARRAY - ARRAY of whitelisted items, HASHMAP of items with details, ARRAY of available addons
*/
#include "\x\enh\addons\main\script_component.hpp"
#define TYPES_WHITELIST ["AssaultRifle", "MachineGun", "SniperRifle", "Shotgun", "SubmachineGun", "RocketLauncher", "Handgun", "Grenade", "Magazine",\
"Mine", "AccessoryBipod", "AccessoryMuzzle", "AccessoryPointer", "AccessorySights", "Uniform", "Vest", "Backpack", "Headgear", "Glasses", "NVGoggles", "Item", "MissileLauncher"]
params [["_input", [], []]];
private _addons = [["", localize "$STR_3DEN_ATTRIBUTES_DEFAULT_UNCHANGED_TEXT", ""]];//Everything
private _itemsHashMap = createHashMap;
if (count _input > 0) then {
diag_log format["_input: (%1)", _input];
_input apply
{
private _class = configName _x;
(_class call BIS_fnc_itemType) params ["_category", "_specificType"];
if ((_category in TYPES_WHITELIST || _specificType in TYPES_WHITELIST && _specificType != "UnknownEquipment") && {if (isArray (_x >> "muzzles")) then {_class call BIS_fnc_baseWeapon == _class} else {true}}) then
{
//Modify some _specificTypes
if (_specificType == "MissileLauncher") then {_specificType = "RocketLauncher"};//Same type for all launchers
if (_specificType in ["Throw", "SmokeShell", "Flare"]) then {_specificType = "Grenade"};//Same type for all grenades, flares, chemlights, smoke
if (_specificType == "AccessoryBipod" && {_class isKindOf ["CBA_MiscItem", configFile >> "CfgWeapons"]}) then {_specificType = "Item"};
//Get the DLC, make sure it's a DLC and was not modified by a mod (CBA, ACE)
(_x call ENH_fnc_getConfigSourceAddon) params [["_addonClass", ""], ["_addonName", ""], ["_addonIcon", ""]];
_addons pushBackUnique [_addonClass, _addonName, _addonIcon];
_itemsHashMap insert
[
[
toLower _class, //Make the key lowercase. Some configs don't use the proper casing (Thanks BI ;P)
[
getText (_x >> "DisplayName"),
getText (_x >> "Picture"),
_addonClass,
_addonIcon,
_category,
_specificType,
getText (_x >> "descriptionShort") regexReplace ["<br[\W ]*\/>", "\n"],
_class //Properly cased configname for displaying
]
]
]
}
}
};
[TYPES_WHITELIST, _itemsHashMap, _addons]
Loading
Loading