mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
c8404f496e
* Arsenal update * Fixes * Update fnc_onSelChangedLeft.sqf * Update fnc_updateUniqueItemsList.sqf * Header fixes * Fix for defines.hpp Co-authored-by: Dystopian <sddex@ya.ru> * Moved fnc_baseWeapon, filtered invalid items * Update addons/arsenal/functions/fnc_scanConfig.sqf Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> * Fixes and tweaks - Sorting is guaranteed to give a fixed order - Dog tags no longer throw errors when reloading the ACE arsenal mission when you had some saved in your loadout before quitting the last time you played. * Cleanup, bug fixes and additions - Added the ability to add items from "CfgMagazines" into the "Misc. items" or custom tabs. - Added "baseWeapon" class support for weapon attachments. If a weapon attachment has the config property "baseWeapon" defined, it will take that item and show that in the arsenal. - Added stronger filtering on item scopes (scope > 0 at least for every item) - Added "descending" (default, as it is now) and "ascending" sort order as a drop down menu, - Unique backpacks in containers can now be removed with either the "-" or "clear all items" button. - When sorting by a number, 2 decimal points have been added, so that when you sort by weight it returns the correct order. * More fixes and tweaks - Converted the arsenal to partially work with hashmaps instead of arrays (for configItems and virtualItems, currentItems is still an array). - Because of the above, performance of FUNC(addVirtualItems) and FUNC(removeVirtualItems) has improved immensely. - Sorting now caches results, reducing repeated sorting times drastically. - CBA disposable launchers are handled differently now: Within the arsenal, you can change weapon attachments on disposable launchers, but you can't change their magazines (primary or secondary). Item info on the right and the stats show correct information. - FUNC(addSort) now checks if the new sorting method already exists and doesn't add it if it does. - FUNC(removeSort) now exists. You can't remove the default sort type (alphabetically) to avoid problems with the arsenal. - Both FUNC(addStat) and FUNC(compileStats) actually taken priority into account now. Because of that priority on several stats needed to be tweaked. - FUNC(removeStat) ensures that there are no gaps within the stat array (so if there is an empty spot in the stats page, it's because there is a stat, but the condition for it being shown hasn't been met). * Update fnc_replaceUniqueItemsLoadout.sqf * Update fnc_onSelChangedLeft.sqf * Update fnc_scanConfig.sqf * Update docs/wiki/framework/arsenal-framework.md Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> * Minor cleanup * Baseweapon filtering * Improvements + better unique items support * Update fnc_fillRightPanel.sqf * Update fnc_onSelChangedLeft.sqf Fixed: Switching between weapons with incompatible primary magazines while a compatible secondary magazine is loaded doesn't equip the new weapon's primary magazine. * Update addons/common/functions/fnc_uniqueUnitItems.sqf Co-authored-by: PabstMirror <pabstmirror@gmail.com> * undefined variable Co-authored-by: PabstMirror <pabstmirror@gmail.com> * fix undefined loadout var * Update fnc_fillLoadoutsList.sqf --------- Co-authored-by: Dystopian <sddex@ya.ru> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
266 lines
9.1 KiB
Plaintext
266 lines
9.1 KiB
Plaintext
#include "script_component.hpp"
|
|
#include "..\defines.hpp"
|
|
/*
|
|
* Author: Alganthe, johnb43
|
|
* Fills left panel.
|
|
*
|
|
* Arguments:
|
|
* 0: Arsenal display <DISPLAY>
|
|
* 1: Tab control <CONTROL>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_display", "_control"];
|
|
|
|
// Fade old control background
|
|
if (!isNil QGVAR(currentLeftPanel)) then {
|
|
private _previousCtrlBackground = _display displayCtrl (GVAR(currentLeftPanel) - 1);
|
|
_previousCtrlBackground ctrlSetFade 1;
|
|
_previousCtrlBackground ctrlCommit FADE_DELAY;
|
|
};
|
|
|
|
// Show new control background
|
|
private _ctrlIDC = ctrlIDC _control;
|
|
private _ctrlBackground = _display displayCtrl (_ctrlIDC - 1);
|
|
_ctrlBackground ctrlSetFade 0;
|
|
_ctrlBackground ctrlCommit FADE_DELAY;
|
|
|
|
private _ctrlPanel = _display displayCtrl IDC_leftTabContent;
|
|
|
|
// Force a "refresh" animation of the panel
|
|
_ctrlPanel ctrlSetFade 1;
|
|
_ctrlPanel ctrlCommit 0;
|
|
_ctrlPanel ctrlSetFade 0;
|
|
_ctrlPanel ctrlCommit FADE_DELAY;
|
|
|
|
_ctrlPanel lbSetCurSel -1;
|
|
|
|
// Handle icons and filling
|
|
private _selectedItem = switch (true) do {
|
|
// Primary weapons, secondary weapons, handgun weapons
|
|
case (_ctrlIDC in [IDC_buttonPrimaryWeapon, IDC_buttonHandgun, IDC_buttonSecondaryWeapon]): {
|
|
// Purge old data
|
|
lbClear _ctrlPanel;
|
|
|
|
// Add "Empty" entry
|
|
private _addEmpty = _ctrlPanel lbAdd format [" <%1>", localize "str_empty"];
|
|
_ctrlPanel lbSetValue [_addEmpty, -1];
|
|
|
|
// Add selected tab's weapons
|
|
private _index = [IDC_buttonPrimaryWeapon, IDC_buttonSecondaryWeapon, IDC_buttonHandgun] find _ctrlIDC;
|
|
|
|
{
|
|
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
|
|
} forEach (keys ((GVAR(virtualItems) get IDX_VIRT_WEAPONS) get _index));
|
|
|
|
GVAR(currentItems) select _index
|
|
};
|
|
// Uniforms, vests, backpacks
|
|
case (_ctrlIDC in [IDC_buttonUniform, IDC_buttonVest, IDC_buttonBackpack]): {
|
|
// Purge old data
|
|
lbClear _ctrlPanel;
|
|
|
|
// Add "Empty" entry
|
|
private _addEmpty = _ctrlPanel lbAdd format [" <%1>", localize "str_empty"];
|
|
_ctrlPanel lbSetValue [_addEmpty, -1];
|
|
|
|
switch (_ctrlIDC) do {
|
|
// Add uniforms
|
|
case IDC_buttonUniform: {
|
|
{
|
|
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
|
|
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_UNIFORM));
|
|
|
|
GVAR(currentItems) select IDX_CURR_UNIFORM
|
|
};
|
|
// Add vests
|
|
case IDC_buttonVest: {
|
|
{
|
|
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
|
|
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_VEST));
|
|
|
|
GVAR(currentItems) select IDX_CURR_VEST
|
|
};
|
|
// Add backpacks
|
|
case IDC_buttonBackpack: {
|
|
{
|
|
["CfgVehicles", _x, _ctrlPanel] call FUNC(addListBoxItem);
|
|
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_BACKPACK));
|
|
|
|
GVAR(currentItems) select IDX_CURR_BACKPACK
|
|
};
|
|
};
|
|
};
|
|
// Other
|
|
default {
|
|
// Don't reset right panel selection if left tab is binos
|
|
if (_ctrlIDC != IDC_buttonBinoculars) then {
|
|
GVAR(currentRightPanel) = nil;
|
|
};
|
|
|
|
lbClear _ctrlPanel;
|
|
|
|
// For every left tab except faces and voices, add "Empty" entry
|
|
if !(_ctrlIDC in [IDC_buttonFace, IDC_buttonVoice]) then {
|
|
private _addEmpty = _ctrlPanel lbAdd format [" <%1>", localize "str_empty"];
|
|
_ctrlPanel lbSetValue [_addEmpty, -1];
|
|
};
|
|
|
|
switch (_ctrlIDC) do {
|
|
// Headgear
|
|
case IDC_buttonHeadgear: {
|
|
{
|
|
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
|
|
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_HEADGEAR));
|
|
|
|
GVAR(currentItems) select IDX_CURR_HEADGEAR
|
|
};
|
|
// Facewear
|
|
case IDC_buttonGoggles: {
|
|
{
|
|
["CfgGlasses", _x, _ctrlPanel] call FUNC(addListBoxItem);
|
|
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_GOGGLES));
|
|
|
|
GVAR(currentItems) select IDX_CURR_GOGGLES
|
|
};
|
|
// NVGs
|
|
case IDC_buttonNVG: {
|
|
{
|
|
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
|
|
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_NVG));
|
|
|
|
GVAR(currentItems) select IDX_CURR_NVG
|
|
};
|
|
// Binoculars
|
|
case IDC_buttonBinoculars: {
|
|
{
|
|
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
|
|
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_BINO));
|
|
|
|
GVAR(currentItems) select IDX_CURR_BINO
|
|
};
|
|
// Maps
|
|
case IDC_buttonMap: {
|
|
{
|
|
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
|
|
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_MAP));
|
|
|
|
GVAR(currentItems) select IDX_CURR_MAP
|
|
};
|
|
// Compasses
|
|
case IDC_buttonCompass: {
|
|
{
|
|
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
|
|
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_COMPASS));
|
|
|
|
GVAR(currentItems) select IDX_CURR_COMPASS
|
|
};
|
|
// Radios
|
|
case IDC_buttonRadio: {
|
|
{
|
|
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
|
|
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_RADIO));
|
|
|
|
GVAR(currentItems) select IDX_CURR_RADIO
|
|
};
|
|
// Watches
|
|
case IDC_buttonWatch: {
|
|
{
|
|
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
|
|
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_WATCH));
|
|
|
|
GVAR(currentItems) select IDX_CURR_WATCH
|
|
};
|
|
// GPS and UAV Terminals
|
|
case IDC_buttonGPS: {
|
|
{
|
|
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
|
|
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_COMMS));
|
|
|
|
GVAR(currentItems) select IDX_CURR_COMMS
|
|
};
|
|
// Faces
|
|
case IDC_buttonFace: {
|
|
private _lbAdd = -1;
|
|
|
|
{
|
|
_y params ["_displayName", "_modPicture"];
|
|
|
|
_lbAdd = _ctrlPanel lbAdd _displayName;
|
|
_ctrlPanel lbSetData [_lbAdd, _x];
|
|
_ctrlPanel lbSetTooltip [_lbAdd, format ["%1\n%2", _displayName, _x]];
|
|
_ctrlPanel lbSetPictureRight [_lbAdd, _modPicture];
|
|
} forEach (uiNamespace getVariable QGVAR(faceCache));
|
|
|
|
GVAR(currentFace)
|
|
};
|
|
// Voices
|
|
case IDC_buttonVoice: {
|
|
{
|
|
["CfgVoice", _x, _ctrlPanel, "icon"] call FUNC(addListBoxItem);
|
|
} forEach (uiNamespace getVariable QGVAR(voiceCache));
|
|
|
|
GVAR(currentVoice)
|
|
};
|
|
// Insignia
|
|
case IDC_buttonInsignia: {
|
|
// Insignia from config
|
|
{
|
|
["CfgUnitInsignia", _x, _ctrlPanel, "texture"] call FUNC(addListBoxItem);
|
|
} forEach (uiNamespace getVariable QGVAR(insigniaCache));
|
|
|
|
private _displayName = "";
|
|
private _className = "";
|
|
private _lbAdd = -1;
|
|
|
|
// Insignia from mission file
|
|
{
|
|
_className = configName _x;
|
|
_displayName = getText (_x >> "displayName");
|
|
_lbAdd = _ctrlPanel lbAdd _displayName;
|
|
|
|
_ctrlPanel lbSetData [_lbAdd, _className];
|
|
_ctrlPanel lbSetPicture [_lbAdd, getText (_x >> "texture")];
|
|
_ctrlPanel lbSetTooltip [_lbAdd, format ["%1\n%2", _displayName, _className]];
|
|
} forEach ("(if (isNumber (_x >> 'scope')) then {getNumber (_x >> 'scope')} else {2}) == 2" configClasses (missionConfigFile >> "CfgUnitInsignia"));
|
|
|
|
GVAR(currentInsignia)
|
|
};
|
|
// Unknown
|
|
default {""};
|
|
};
|
|
};
|
|
};
|
|
|
|
// When switching tabs, clear searchbox
|
|
if (GVAR(currentLeftPanel) != _ctrlIDC) then {
|
|
(_display displayCtrl IDC_leftSearchbar) ctrlSetText "";
|
|
(_display displayCtrl IDC_rightSearchbar) ctrlSetText "";
|
|
};
|
|
|
|
// Trigger event
|
|
GVAR(currentLeftPanel) = _ctrlIDC;
|
|
[QGVAR(leftPanelFilled), [_display, _ctrlIDC, GVAR(currentRightPanel)]] call CBA_fnc_localEvent;
|
|
|
|
// Sort
|
|
[_display, _control, _display displayCtrl IDC_sortLeftTab, _display displayCtrl IDC_sortLeftTabDirection] call FUNC(fillSort);
|
|
|
|
// Try to select previously selected item again, otherwise select first item ("Empty")
|
|
if (_selectedItem != "") then {
|
|
private _index = 0;
|
|
|
|
for "_lbIndex" from 0 to (lbSize _ctrlPanel) - 1 do {
|
|
if ((_ctrlPanel lbData _lbIndex) == _selectedItem) exitWith {
|
|
_index = _lbIndex;
|
|
};
|
|
};
|
|
|
|
_ctrlPanel lbSetCurSel _index;
|
|
} else {
|
|
_ctrlPanel lbSetCurSel 0;
|
|
};
|