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

ESE - Add import from clipboard into Available Items #331

Merged
merged 6 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
19 changes: 18 additions & 1 deletion addons/main/GUI/ESE.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ class ENH_ESE
"Backpacks",
"Headgear",
"Goggles",
"NVGs"
"NVGs",
"Separator",
"ImportToFilter",
"Separator",
"ResetToAllItems"
};
};
class FolderHelp
Expand Down Expand Up @@ -275,6 +279,7 @@ class ENH_ESE
{
text = "$STR_ENH_MAIN_ESE_IMPORTFROMCLIPBOARD";
action = "[false, [], true] call ENH_fnc_ESE_loadAttributeValue";
picture = "\a3\ui_f\data\igui\cfg\actions\loadvehicle_ca.paa";
shortcuts[] = {DIK_6};
};
//Filter
Expand Down Expand Up @@ -399,6 +404,18 @@ class ENH_ESE
picture = "\a3\ui_f\data\gui\rsc\rscdisplayarsenal\nvgs_ca.paa";
data = "NVGoggles";
};
class ImportToFilter
{
text = "$STR_ENH_MAIN_ESE_IMPORTFROMCLIPBOARD";
picture = "\a3\ui_f\data\igui\cfg\actions\loadvehicle_ca.paa";
action = "[] call ENH_fnc_ESE_importToFilter";
};
class ResetToAllItems
{
text = "$STR_A3_RSCDISPLAYARSENAL_RESET";
picture = "\A3\ui_f\data\igui\rsctitles\mpprogress\respawn_ca.paa";
action = "[] call ENH_fnc_ESE_resetToAllItems";
};
class InventoryItems: ARs
{
text = "$STR_A3_CFGVEHICLECLASSES_ITEMS0";
Expand Down
2 changes: 2 additions & 0 deletions addons/main/cfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class CfgFunctions
class ESE_fullArsenal;
class ESE_getConfigValues;
class ESE_handleTemplates;
class ESE_importToFilter;
class ESE_lbAdd;
class ESE_lnbAdd;
class ESE_loadAttributeValue;
Expand All @@ -108,6 +109,7 @@ class CfgFunctions
class ESE_removeItem;
class ESE_resetSearch;
class ESE_resetStorage;
class ESE_resetToAllItems;
class ESE_search;
class ESE_sort;
class ESE_toggleVirtual;
Expand Down
27 changes: 27 additions & 0 deletions addons/main/functions/GUI/ESE/fn_ESE_importToFilter.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Author: Pixelated_Grunt

Date: 2024-08-29

Description:
Used by the ENH_ESE GUI. Import a list from clipboard to the available list (left panel).
The import list is same as ACE arsenal export format i.e. ["item1", "item2"].

Parameter(s):
-

Returns:
-
*/


#include "\x\enh\addons\main\script_component.hpp"
private _allAttributes = [true] call ENH_fnc_ESE_parseClipboardValues;
private _display = uiNamespace getVariable ["ENH_Display_ESE", displayNull];

// Backup the existing ENH_ESE_itemsHashMap
uiNamespace setVariable ["ENH_ESE_itemsHashMapClone", uiNamespace getVariable ["ENH_ESE_itemsHashMap", createHashMap]];
// Replace the hashmap
uiNamespace setVariable ["ENH_ESE_itemsHashMap", _allAttributes];
// Call change filter to trigger the list update
[CTRL(IDC_ESE_MENU), [2, 0]] call ENH_fnc_ESE_changeFilter
14 changes: 8 additions & 6 deletions addons/main/functions/GUI/ESE/fn_ESE_lbAdd.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ params
["_textRight", ""]
];

private _index = _ctrlLb lbAdd _lbText;
_ctrlLb lbSetData [_index, _lbData];
_ctrlLb lbSetPicture [_index, _pictureLeft];
_ctrlLb lbSetPictureRight [_index, _pictureRight];
_ctrlLb lbSetTooltip [_index, _tooltip];
_ctrlLb lbSetTextRight [_index, _textRight];
if (_lbText != "") then {
private _index = _ctrlLb lbAdd _lbText;
_ctrlLb lbSetData [_index, _lbData];
_ctrlLb lbSetPicture [_index, _pictureLeft];
_ctrlLb lbSetPictureRight [_index, _pictureRight];
_ctrlLb lbSetTooltip [_index, _tooltip];
_ctrlLb lbSetTextRight [_index, _textRight]
}
37 changes: 20 additions & 17 deletions addons/main/functions/GUI/ESE/fn_ESE_lnbAdd.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,23 @@
disableSerialization;
params ["_ctrlLnb", "_data", "_text", "_image", "_addonIcon", "_value", "_tooltip", "_specificType"];

private _row = _ctrlLnb lnbAddRow ["", _text, str _value, ""];

//Column #0
_ctrlLnb lnbSetData [[_row, 0], _data];
_ctrlLnb lnbSetPicture [[_row, 0], _image];
_ctrlLnb lnbSetTooltip [[_row, 0], _tooltip];

//Column #1
_ctrlLnb lnbSetValue [[_row, 1], _value];
_ctrlLnb lnbSetData [[_row, 1], _specificType];

//Column #2 - Count
_ctrlLnb lnbSetText [[_row, 2], str _value];

//Column #3 - Addon Icon
_ctrlLnb lnbSetPicture [[_row, 3], _addonIcon];
_ctrlLnb lnbSetData [[_row, 3], _addonIcon];
if (_text != "") then
{
private _row = _ctrlLnb lnbAddRow ["", _text, str _value, ""];

//Column #0
_ctrlLnb lnbSetData [[_row, 0], _data];
_ctrlLnb lnbSetPicture [[_row, 0], _image];
_ctrlLnb lnbSetTooltip [[_row, 0], _tooltip];

//Column #1
_ctrlLnb lnbSetValue [[_row, 1], _value];
_ctrlLnb lnbSetData [[_row, 1], _specificType];

//Column #2 - Count
_ctrlLnb lnbSetText [[_row, 2], str _value];

//Column #3 - Addon Icon
_ctrlLnb lnbSetPicture [[_row, 3], _addonIcon];
_ctrlLnb lnbSetData [[_row, 3], _addonIcon]
};
6 changes: 5 additions & 1 deletion addons/main/functions/GUI/ESE/fn_ESE_open.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ CTRL(IDC_ESE_AVAILABLEITEMSLIST) ctrlAddEventHandler ["LBSelChanged",
private _itemsHashMap = uiNamespace getVariable ["ENH_ESE_itemsHashMap", createHashMap];
private _lbCompItems = ctrlParent _lbAvailableItems displayCtrl IDC_ESE_COMPATIBLEITEMSLIST;

// Use the clone if exist
private _clone = uiNamespace getVariable ["ENH_ESE_itemsHashMapClone", nil];
if (!isNil("_clone")) then {_itemsHashMap = _clone};

lbClear _lbCompItems;

{
Expand All @@ -71,4 +75,4 @@ CTRL(IDC_ESE_AVAILABLEITEMSLIST) ctrlAddEventHandler ["LBSelChanged",
} forEach (compatibleItems _className + compatibleMagazines _className);
}];

["update"] call ENH_fnc_ESE_handleTemplates;
["update"] call ENH_fnc_ESE_handleTemplates;
10 changes: 4 additions & 6 deletions addons/main/functions/GUI/ESE/fn_ESE_parseClipboardValues.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
Used by the ENH_ESE GUI. Read and convert array from clipboard to inventory attributes.

Parameter(s):
-
BOOL - true to return variable only. Default is false.

Returns:
ARRAY - Result attributes that can be loaded into the inventory screen. Return all if failed.
ARRAY - Result attributes that can be loaded into the filter and inventory screens. Return all items if failed.
*/


#include "\x\enh\addons\main\script_component.hpp"
params [["_return", false, [false]]];
private _importList = call compile copyFromClipboard;

// Verify import list is in correct format
Expand All @@ -41,9 +42,6 @@ private _configs = _importList apply {
}
};

//private _configValues = ([_configs] call ENH_fnc_ESE_getConfigValues) select 1;
//private _attributeValue = [true, _configValues] call ENH_fnc_ESE_applyAttribute;
//
//_attributeValue
private _attributeValue = ([_configs] call ENH_fnc_ESE_getConfigValues) select 1;
if _return exitWith {_attributeValue};
[true, _attributeValue] call ENH_fnc_ESE_applyAttribute
25 changes: 25 additions & 0 deletions addons/main/functions/GUI/ESE/fn_ESE_resetToAllItems.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Author: Pixelated_Grunt

Date: 2024-08-29

Description:
Used by the ENH_ESE GUI. Reset the filter list (left panel) back to all available items.

Parameter(s):
-

Returns:
-
*/


#include "\x\enh\addons\main\script_component.hpp"
private _display = uiNamespace getVariable ["ENH_Display_ESE", displayNull];

// Restore the ENH_ESE_itemsHashMap variable
uiNamespace setVariable ["ENH_ESE_itemsHashMap", uiNamespace getVariable "ENH_ESE_itemsHashMapClone"];
// Release the memory
uiNamespace setVariable ["ENH_ESE_itemsHashMapClone", nil];
// Call change filter to trigger the list update
[CTRL(IDC_ESE_MENU), [2, 0]] call ENH_fnc_ESE_changeFilter
13 changes: 12 additions & 1 deletion addons/main/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6873,6 +6873,17 @@
<Chinese>可用物品</Chinese>
<Italian>Oggetti Disponibili</Italian>
</Key>
<Key ID="STR_A3_RSCDISPLAYARSENAL_RESET">
<English>Reset</English>
<Russian>Перезагрузить</Russian>
<German>Zurücksetzen</German>
<Polish>Nastawić</Polish>
<French>Réinitialiser</French>
<Spanish>Reiniciar</Spanish>
<Chinesesimp>重置</Chinesesimp>
<Chinese>重置</Chinese>
<Italian>Reset</Italian>
</Key>
<Key ID="STR_ENH_MAIN_ESE_FULLARSENAL_TOOLTIP">
<English>Adds all items of selected addon to the inventory and sets it to be virtual (Arsenal).</English>
<Russian>Добавляет все предметы выбранного аддона в инвентарь и делает его виртуальным (Арсенал).</Russian>
Expand Down Expand Up @@ -10341,4 +10352,4 @@
<Italian>Condizione calcolata ripetutamente, deve restituire un'espressione booleana. Quando è vera, l'indicatore viene visualizzato.</Italian>
</Key>
</Package>
</Project>
</Project>