Arsenal - Add/Fix/Improve/Change numerous aspects (#9040)

* 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>
This commit is contained in:
johnb432 2023-07-21 20:25:25 +02:00 committed by GitHub
parent 12bb5aced4
commit c8404f496e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
119 changed files with 5126 additions and 3660 deletions

View File

@ -4,7 +4,7 @@ class GVAR(sorts) {
displayName = "";
tabs[] = {{}, {}};
statement = "";
condition = "true";
condition = QUOTE(true);
};
class ACE_alphabetically: sortBase {

View File

@ -8,12 +8,12 @@ class GVAR(stats) {
showText = 0;
barStatement = "";
textStatement = "";
condition = "true";
condition = QUOTE(true);
tabs[] = {{}, {}};
};
class ACE_bananaPotassium: statBase {
scope = 2;
displayName= CSTRING(statPotassium);
displayName = CSTRING(statPotassium);
showBar = 1;
barStatement = "1";
condition = QUOTE((configName (_this select 1)) == 'ACE_Banana');
@ -21,7 +21,8 @@ class GVAR(stats) {
};
class ACE_mass: statBase {
scope = 2;
displayName= "$STR_a3_rscdisplayarsenal_stat_weight";
priority = 1.5;
displayName = "$STR_a3_rscdisplayarsenal_stat_weight";
showText = 1;
textStatement = QUOTE([ARR_2(_this select 0, _this select 1)] call FUNC(statTextStatement_mass));
tabs[] = {{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14}, {0,1,2,3,4,5,6,7}};
@ -30,7 +31,7 @@ class GVAR(stats) {
scope = 2;
priority = 5;
stats[] = {"reloadTime"};
displayName= "$STR_a3_rscdisplayarsenal_stat_rof";
displayName = "$STR_a3_rscdisplayarsenal_stat_rof";
showBar = 1;
showText = 1;
barStatement = QUOTE([ARR_3((_this select 0) select 0, _this select 1, [ARR_2([ARR_2(-1.4, 0.31)], [ARR_2(1, 0.01)])])] call FUNC(statBarStatement_rateOfFIre));
@ -50,7 +51,7 @@ class GVAR(stats) {
};
class ACE_maxZeroing: statBase {
scope = 2;
priority = 3;
priority = 3.2;
stats[] = {"maxZeroing"};
displayName = "$STR_a3_rscdisplayarsenal_stat_range";
showBar = 1;
@ -59,11 +60,11 @@ class GVAR(stats) {
};
class ACE_impact: statBase {
scope = 2;
priority = 2;
priority = 3.1;
stats[] = {"hit", "initSpeed"};
displayName = "$STR_a3_rscdisplayarsenal_stat_impact";
showBar = 1;
barStatement = QUOTE([ARR_3(_this select 0, _this select 1, [ARR_3([ARR_2(0, 3.2)], [ARR_2(-1, 1100)], 2006)])] call FUNC(statBarStatement_impact));
barStatement = QUOTE([ARR_3(_this select 0, _this select 1, [ARR_2([ARR_2(0, 3.2)], [ARR_2(-1, 1100)])])] call FUNC(statBarStatement_impact));
tabs[] = {{0,1,2}, {}};
};
class ACE_scopeMagnification: statBase {
@ -76,7 +77,7 @@ class GVAR(stats) {
};
class ACE_scopeVisionMode: statBase {
scope = 2;
priority = 1;
priority = 1.6;
displayName = CSTRING(statVisionMode);
showText = 1;
textStatement = QUOTE(call FUNC(statTextStatement_scopeVisionMode));
@ -125,7 +126,6 @@ class GVAR(stats) {
displayName = CSTRING(StatExplosionTime);
showText = 1;
textStatement = QUOTE(call FUNC(statTextStatement_explosionTime));
condition = QUOTE(true);
tabs[] = {{}, {5}};
};
};

View File

@ -15,6 +15,7 @@ PREP(attributeKeyDown);
PREP(attributeLoad);
PREP(attributeMode);
PREP(attributeSelect);
PREP(baseWeapon);
PREP(buttonCargo);
PREP(buttonClearAll);
PREP(buttonExport);
@ -34,7 +35,6 @@ PREP(fillLeftPanel);
PREP(fillLoadoutsList);
PREP(fillRightPanel);
PREP(fillSort);
PREP(getLoadout);
PREP(handleLoadoutsSearchbar);
PREP(handleMouse);
PREP(handleScrollWheel);
@ -59,8 +59,10 @@ PREP(open3DEN);
PREP(openBox);
PREP(portVALoadouts);
PREP(removeBox);
PREP(removeSort);
PREP(removeStat);
PREP(removeVirtualItems);
PREP(replaceUniqueItemsLoadout);
PREP(scanConfig);
PREP(showItem);
PREP(sortPanel);
@ -85,5 +87,6 @@ PREP(statTextStatement_scopeVisionMode);
PREP(statTextStatement_smokeChemTTL);
PREP(updateCamPos);
PREP(updateRightPanel);
PREP(updateCurrentItemsList);
PREP(updateUniqueItemsList);
PREP(verifyLoadout);

View File

@ -9,43 +9,40 @@ GVAR(lastSearchTextRight) = "";
GVAR(lastSearchTextLoadouts) = "";
GVAR(lastSortLeft) = "";
GVAR(lastSortRight) = "";
GVAR(lastSortDirectionLeft) = DESCENDING;
GVAR(lastSortDirectionRight) = DESCENDING;
[QGVAR(initBox), {_this call FUNC(initBox)}] call CBA_fnc_addEventHandler;
[QGVAR(removeBox), {_this call FUNC(removeBox)}] call CBA_fnc_addEventHandler;
[QGVAR(initBox), LINKFUNC(initBox)] call CBA_fnc_addEventHandler;
[QGVAR(removeBox), LINKFUNC(removeBox)] call CBA_fnc_addEventHandler;
[QGVAR(broadcastFace), {
params ["_unit", "_face"];
_unit setFace _face;
}] call CBA_fnc_addEventHandler;
[QGVAR(broadcastVoice), {
params ["_unit", "_voice"];
_unit setSpeaker _voice;
}] call CBA_fnc_addEventHandler;
[QGVAR(loadoutUnshared), {
params ["_contentPanelCtrl" , "_playerName", "_loadoutName"];
// If player is in arsenal in the shared tab and a loadout is unshared at the same time
if (!isNil QGVAR(currentLoadoutsTab) && {GVAR(currentLoadoutsTab) == IDC_buttonSharedLoadouts}) then {
private _dataToCheck = _playerName + _loadoutName;
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
if ((_contentPanelCtrl lnbData [_i, 1]) == _dataToCheck) exitwith {_contentPanelCtrl lnbDeleteRow _i};
for "_lbIndex" from 0 to (lnbSize _contentPanelCtrl select 0) - 1 do {
if ((_contentPanelCtrl lnbData [_lbIndex, 1]) == _dataToCheck) exitWith {
_contentPanelCtrl lnbDeleteRow _lbIndex;
};
};
} else {
if (
profileName == _playerName &&
{!(isNil QGVAR(currentLoadoutsTab) && {GVAR(currentLoadoutsTab) == IDC_buttonMyLoadouts})}
) then {
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
if ((_contentPanelCtrl lnbText [_i, 1]) == _loadoutName) exitwith {
_contentPanelCtrl lnbSetPicture [[_i, 0], QPATHTOF(data\iconPublicBlank.paa)];
_contentPanelCtrl lnbSetValue [[_i, 0], 0];
if (profileName == _playerName && {!(isNil QGVAR(currentLoadoutsTab) && {GVAR(currentLoadoutsTab) == IDC_buttonMyLoadouts})}) then {
for "_lbIndex" from 0 to (lnbSize _contentPanelCtrl select 0) - 1 do {
if ((_contentPanelCtrl lnbText [_lbIndex, 1]) == _loadoutName) exitWith {
_contentPanelCtrl lnbSetPicture [[_lbIndex, 0], QPATHTOF(data\iconPublicBlank.paa)];
_contentPanelCtrl lnbSetValue [[_lbIndex, 0], 0];
};
};
};
@ -53,53 +50,99 @@ GVAR(lastSortRight) = "";
}] call CBA_fnc_addEventHandler;
[QGVAR(loadoutShared), {
params ["_contentPanelCtrl" ,"_loadoutArgs"];
params ["_contentPanelCtrl", "_loadoutArgs"];
_loadoutArgs params ["_playerName", "_loadoutName", "_loadoutData"];
// If player is in arsenal in the shared tab and a loadout is shared at the same time
if (!isNil QGVAR(currentLoadoutsTab) && {GVAR(currentLoadoutsTab) == IDC_buttonSharedLoadouts}) then {
private _curSelData = _contentPanelCtrl lnbData [lnbCurSelRow _contentPanelCtrl, 1];
private _curSelData =_contentPanelCtrl lnbData [(lnbCurSelRow _contentPanelCtrl), 1];
([_loadoutData] call FUNC(verifyLoadout)) params ["_extendedLoadout", "_nullItemsAmount", "_unavailableItemsAmount"];
_extendedLoadout params ["_loadout"];
private _newRow = _contentPanelCtrl lnbAddRow [_playerName, _loadoutName];
private _cfgWeapons = configFile >> "CfgWeapons";
_extendedLoadout params ["_loadout"];
ADD_LOADOUTS_LIST_PICTURES
_contentPanelCtrl lnbSetData [[_newRow, 1], _playerName + _loadoutName];
// Set color of row, depending if items are unavailable/missing
if (_nullItemsAmount > 0) then {
_contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 0, 0, 0.8]];
} else {
if (_unavailableItemsAmount > 0) then {
_contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 1, 1, 0.25]];
};
};
// Sort loadouts alphabetically
_contentPanelCtrl lnbSort [1, false];
// Select previously selected loadout
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
if ((_contentPanelCtrl lnbText [_i, 1]) == _curSelData) exitwith {_contentPanelCtrl lnbSetCurSelRow _i};
for "_lbIndex" from 0 to (lnbSize _contentPanelCtrl select 0) - 1 do {
if ((_contentPanelCtrl lnbText [_lbIndex, 1]) == _curSelData) exitWith {
_contentPanelCtrl lnbSetCurSelRow _lbIndex
};
};
};
}] call CBA_fnc_addEventHandler;
["CBA_loadoutSet", {
params ["_unit", "_loadout", "_extendedInfo"];
// Set face
private _face = _extendedInfo getOrDefault [QGVAR(face), ""];
if (_face != "") then {
_unit setFace _face;
if (isMultiplayer) then {
private _id = [QGVAR(broadcastFace), [_unit, _face], QGVAR(centerFace_) + netId _unit] call CBA_fnc_globalEventJIP;
[_id, _unit] call CBA_fnc_removeGlobalEventJIP;
} else {
_unit setFace _face;
};
};
// Set voice
private _voice = _extendedInfo getOrDefault [QGVAR(voice), ""];
if (_voice != "") then {
_unit setSpeaker _voice;
if (isMultiplayer) then {
private _id = [QGVAR(broadcastVoice), [_unit, _voice], QGVAR(centerVoice_) + netId _unit] call CBA_fnc_globalEventJIP;
[_id, _unit] call CBA_fnc_removeGlobalEventJIP;
} else {
_unit setSpeaker _voice;
};
};
// Set insignia
private _insignia = _extendedInfo getOrDefault [QGVAR(insignia), ""];
if (_insignia != "") then {
_unit setVariable ["BIS_fnc_setUnitInsignia_class", nil];
[_unit, _insignia] call bis_fnc_setUnitInsignia;
[_unit, _insignia] call BIS_fnc_setUnitInsignia;
};
}] call CBA_fnc_addEventHandler;
["CBA_loadoutGet", {
params ["_unit", "_loadout", "_extendedInfo"];
// Set face if enabled
if (GVAR(loadoutsSaveFace)) then {
_extendedInfo set [QGVAR(face), face _unit];
};
// Set voice if enabled
if (GVAR(loadoutsSaveVoice)) then {
_extendedInfo set [QGVAR(voice), speaker _unit];
};
// Set insignia if enabled
if (GVAR(loadoutsSaveInsignia)) then {
private _insignia = _unit call BIS_fnc_getUnitInsignia;
if (_insignia != "") then {
_extendedInfo set [QGVAR(insignia), _insignia];
};
};
}] call CBA_fnc_addEventHandler;

View File

@ -8,20 +8,21 @@ PREP_RECOMPILE_START;
PREP_RECOMPILE_END;
// Arsenal
[QGVAR(camInverted), "CHECKBOX", localize LSTRING(invertCameraSetting), localize LSTRING(settingCategory), false] call CBA_fnc_addSetting;
[QGVAR(enableModIcons), "CHECKBOX", [LSTRING(modIconsSetting), LSTRING(modIconsTooltip)], localize LSTRING(settingCategory), true] call CBA_fnc_addSetting;
[QGVAR(fontHeight), "SLIDER", [LSTRING(fontHeightSetting), LSTRING(fontHeightTooltip)], localize LSTRING(settingCategory), [1, 10, 4.5, 1]] call CBA_fnc_addSetting;
[QGVAR(enableIdentityTabs), "CHECKBOX", localize LSTRING(enableIdentityTabsSettings), localize LSTRING(settingCategory), true, true] call CBA_fnc_addSetting;
[QGVAR(camInverted), "CHECKBOX", LLSTRING(invertCameraSetting), LLSTRING(settingCategory), false] call CBA_fnc_addSetting;
[QGVAR(enableModIcons), "CHECKBOX", [LSTRING(modIconsSetting), LSTRING(modIconsTooltip)], LLSTRING(settingCategory), true] call CBA_fnc_addSetting;
[QGVAR(fontHeight), "SLIDER", [LSTRING(fontHeightSetting), LSTRING(fontHeightTooltip)], LLSTRING(settingCategory), [1, 10, 4.5, 1]] call CBA_fnc_addSetting;
[QGVAR(enableIdentityTabs), "CHECKBOX", LLSTRING(enableIdentityTabsSettings), LLSTRING(settingCategory), true, true] call CBA_fnc_addSetting;
// Arsenal loadouts
[QGVAR(allowDefaultLoadouts), "CHECKBOX", [LSTRING(allowDefaultLoadoutsSetting), LSTRING(defaultLoadoutsTooltip)], [localize LSTRING(settingCategory), localize LSTRING(loadoutSubcategory)], true, true] call CBA_fnc_addSetting;
[QGVAR(allowSharedLoadouts), "CHECKBOX", localize LSTRING(allowSharingSetting), [localize LSTRING(settingCategory), localize LSTRING(loadoutSubcategory)], true, true] call CBA_fnc_addSetting;
[QGVAR(EnableRPTLog), "CHECKBOX", [LSTRING(printToRPTSetting), LSTRING(printToRPTTooltip)], [localize LSTRING(settingCategory), localize LSTRING(loadoutSubcategory)], false, false] call CBA_fnc_addSetting;
[QGVAR(allowDefaultLoadouts), "CHECKBOX", [LSTRING(allowDefaultLoadoutsSetting), LSTRING(defaultLoadoutsTooltip)], [LLSTRING(settingCategory), LLSTRING(loadoutSubcategory)], true, true] call CBA_fnc_addSetting;
[QGVAR(allowSharedLoadouts), "CHECKBOX", LLSTRING(allowSharingSetting), [LLSTRING(settingCategory), LLSTRING(loadoutSubcategory)], true, true] call CBA_fnc_addSetting;
[QGVAR(EnableRPTLog), "CHECKBOX", [LSTRING(printToRPTSetting), LSTRING(printToRPTTooltip)], [LLSTRING(settingCategory), LLSTRING(loadoutSubcategory)], false, false] call CBA_fnc_addSetting;
[QGVAR(loadoutsSaveFace), "CHECKBOX", localize LSTRING(loadoutsSaveFaceSetting), [localize LSTRING(settingCategory), localize LSTRING(loadoutSubcategory)], false] call CBA_fnc_addSetting;
[QGVAR(loadoutsSaveVoice), "CHECKBOX", localize LSTRING(loadoutsSaveVoiceSetting), [localize LSTRING(settingCategory), localize LSTRING(loadoutSubcategory)], false] call CBA_fnc_addSetting;
[QGVAR(loadoutsSaveInsignia), "CHECKBOX", localize LSTRING(loadoutsSaveInsigniaSetting), [localize LSTRING(settingCategory), localize LSTRING(loadoutSubcategory)], true] call CBA_fnc_addSetting;
[QGVAR(loadoutsSaveFace), "CHECKBOX", LLSTRING(loadoutsSaveFaceSetting), [LLSTRING(settingCategory), LLSTRING(loadoutSubcategory)], false] call CBA_fnc_addSetting;
[QGVAR(loadoutsSaveVoice), "CHECKBOX", LLSTRING(loadoutsSaveVoiceSetting), [LLSTRING(settingCategory), LLSTRING(loadoutSubcategory)], false] call CBA_fnc_addSetting;
[QGVAR(loadoutsSaveInsignia), "CHECKBOX", LLSTRING(loadoutsSaveInsigniaSetting), [LLSTRING(settingCategory), LLSTRING(loadoutSubcategory)], true] call CBA_fnc_addSetting;
// Arsenal events
[QGVAR(statsToggle), {
params ["_display", "_showStats"];
@ -54,25 +55,25 @@ PREP_RECOMPILE_END;
_this call FUNC(buttonStatsPage);
}] call CBA_fnc_addEventHandler;
[QGVAR(displayStats), {
_this call FUNC(handleStats);
}] call CBA_fnc_addEventHandler;
// Compile sorts and stats
call FUNC(compileStats);
call FUNC(compileSorts);
[QUOTE(ADDON), {!isNil QGVAR(camera)}] call CBA_fnc_registerFeatureCamera;
// Compatibility with CBA scripted optics and dispoable framework
// Compatibility with CBA scripted optics and disposable framework
[QGVAR(displayOpened), {
"cba_optics_arsenalOpened" call CBA_fnc_localEvent;
"cba_disposable_arsenalOpened" call CBA_fnc_localEvent;
"CBA_optics_arsenalOpened" call CBA_fnc_localEvent;
"CBA_disposable_arsenalOpened" call CBA_fnc_localEvent;
}] call CBA_fnc_addEventHandler;
[QGVAR(displayClosed), {
"cba_optics_arsenalClosed" call CBA_fnc_localEvent;
"cba_disposable_arsenalClosed" call CBA_fnc_localEvent;
"CBA_optics_arsenalClosed" call CBA_fnc_localEvent;
"CBA_disposable_arsenalClosed" call CBA_fnc_localEvent;
}] call CBA_fnc_addEventHandler;
ADDON = true;

View File

@ -2,4 +2,12 @@
#include "XEH_PREP.hpp"
// Cache for FUNC(baseWeapon)
uiNamespace setVariable [QGVAR(baseWeaponNameCache), createHashMap];
// Caches for names, pictures, mod icons
uiNamespace setVariable [QGVAR(addListBoxItemCache), createHashMap];
uiNamespace setVariable [QGVAR(rightPanelCache), createHashMap];
uiNamespace setVariable [QGVAR(sortCache), createHashMap];
call FUNC(scanConfig);

View File

@ -8,7 +8,7 @@ class CfgPatches {
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
author = ECSTRING(common,ACETeam);
authors[] = {"alganthe", "mharis001", "Brett Mayson"};
authors[] = {"alganthe", "mharis001", "Brett Mayson", "johnb43"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};

View File

@ -7,6 +7,18 @@
#define WIDTH_GAP (WIDTH_TOTAL / 100)
#define WIDTH_SINGLE ((WIDTH_TOTAL - 6 * WIDTH_GAP) / 5)
// IDDs
#define IDD_MISSION 46
#define IDD_RSCDISPLAYCURATOR 312
#define IDD_DISPLAY3DEN 313
#define IDC_OK 1 // emulate "OK" button
#define IDC_CANCEL 2 // emulate "Cancel" button
// Sorting
#define ASCENDING 0
#define DESCENDING 1
// IDCs
#define IDD_ace_arsenal 1127001
#define IDC_mouseArea 0
@ -38,7 +50,9 @@
#define IDC_rightTabContent 14
#define IDC_rightTabContentListnBox 15
#define IDC_sortLeftTab 16
#define IDC_sortLeftTabDirection 161
#define IDC_sortRightTab 17
#define IDC_sortRightTabDirection 171
#define IDC_leftSearchbar 18
#define IDC_leftSearchbarButton 41
#define IDC_rightSearchbar 19
@ -165,12 +179,45 @@
#define IDC_ATTRIBUTE_IMPORT_BUTTON 8109
#define IDC_ATTRIBUTE_ADD_COMPATIBLE 8110
// Indexes of categories
#define IDX_CAT_ALL 0
#define IDX_CAT_PRIMARY_WEAPON 1
#define IDX_CAT_SECONDARY_WEAPON 2
#define IDX_CAT_HANDGUN_WEAPON 3
#define IDX_CAT_OPTICS_ATTACHMENTS 4
#define IDX_CAT_FLASHLIGHT_ATTACHMENTS 5
#define IDX_CAT_MUZZLE_ATTACHMENTS 6
#define IDX_CAT_BIPOD_ATTACHMENTS 7
#define IDX_CAT_ITEMS_ALL 8
#define IDX_CAT_HEADGEAR 9
#define IDX_CAT_UNIFORM 10
#define IDX_CAT_VEST 11
#define IDX_CAT_BACKPACK 12
#define IDX_CAT_GOGGLES 13
#define IDX_CAT_NVG 14
#define IDX_CAT_BINO 15
#define IDX_CAT_MAP 16
#define IDX_CAT_COMPASS 17
#define IDX_CAT_RADIO 18
#define IDX_CAT_WATCH 19
#define IDX_CAT_COMMS 20
#define IDX_CAT_GRENADES 21
#define IDX_CAT_EXPLOSIVES 22
#define IDX_CAT_MISC_ITEMS 23
// Indexes of virtual items array
#define IDX_VIRT_WEAPONS 0
#define IDX_VIRT_ATTACHEMENTS 1
#define IDX_VIRT_PRIMARY_WEAPONS 0
#define IDX_VIRT_SECONDARY_WEAPONS 1
#define IDX_VIRT_HANDGUN_WEAPONS 2
#define IDX_VIRT_ATTACHMENTS 1
#define IDX_VIRT_OPTICS_ATTACHMENTS 0
#define IDX_VIRT_FLASHLIGHT_ATTACHMENTS 1
#define IDX_VIRT_MUZZLE_ATTACHMENTS 2
#define IDX_VIRT_BIPOD_ATTACHMENTS 3
#define IDX_VIRT_ITEMS_ALL 2
#define IDX_VIRT_HEADGEAR 3
#define IDX_VIRT_UNIFORM 4
#define IDX_VIRT_VEST 5
@ -183,6 +230,54 @@
#define IDX_VIRT_RADIO 12
#define IDX_VIRT_WATCH 13
#define IDX_VIRT_COMMS 14
#define IDX_VIRT_GRENADES 15
#define IDX_VIRT_EXPLOSIVES 16
#define IDX_VIRT_MISC_ITEMS 17
#define IDX_VIRT_UNIQUE_MISC_ITEMS 18
#define IDX_VIRT_UNIQUE_VIRT_ITEMS_ALL 19
#define IDX_VIRT_UNIQUE_GRENADES 20
#define IDX_VIRT_UNIQUE_EXPLOSIVES 21
#define IDX_VIRT_UNIQUE_ATTACHMENTS 22
#define IDX_VIRT_UNIQUE_BACKPACKS 23
#define IDX_VIRT_UNIQUE_GOGGLES 24
#define IDX_VIRT_UNIQUE_UNKNOWN_ITEMS 25
// Indexes of current items array
#define IDX_CURR_PRIMARY_WEAPON 0
#define IDX_CURR_SECONDARY_WEAPON 1
#define IDX_CURR_HANDGUN_WEAPON 2
#define IDX_CURR_HEADGEAR 3
#define IDX_CURR_UNIFORM 4
#define IDX_CURR_VEST 5
#define IDX_CURR_BACKPACK 6
#define IDX_CURR_GOGGLES 7
#define IDX_CURR_NVG 8
#define IDX_CURR_BINO 9
#define IDX_CURR_MAP 10
#define IDX_CURR_COMPASS 11
#define IDX_CURR_RADIO 12
#define IDX_CURR_WATCH 13
#define IDX_CURR_COMMS 14
#define IDX_CURR_UNIFORM_ITEMS 15
#define IDX_CURR_VEST_ITEMS 16
#define IDX_CURR_BACKPACK_ITEMS 17
#define IDX_CURR_PRIMARY_WEAPON_ITEMS 18
#define IDX_CURR_SECONDARY_WEAPON_ITEMS 19
#define IDX_CURR_HANDGUN_WEAPON_ITEMS 20
#define IDX_CURR_BINO_ITEMS 21
// Indexes of loadout items array
#define IDX_LOADOUT_PRIMARY_WEAPON 0
#define IDX_LOADOUT_SECONDARY_WEAPON 1
#define IDX_LOADOUT_HANDGUN_WEAPON 2
#define IDX_LOADOUT_UNIFORM 3
#define IDX_LOADOUT_VEST 4
#define IDX_LOADOUT_BACKPACK 5
#define IDX_LOADOUT_HEADGEAR 6
#define IDX_LOADOUT_GOGGLES 7
#define IDX_LOADOUT_BINO 8
#define IDX_LOADOUT_ASSIGNEDITEMS 9
#define SYMBOL_ITEM_NONE ""
#define SYMBOL_ITEM_REMOVE "×"
@ -199,31 +294,6 @@
#define RIGHT_PANEL_ITEMS_BACKGROUND_IDCS IDC_iconBackgroundMag, IDC_iconBackgroundMagALL, IDC_iconBackgroundThrow, IDC_iconBackgroundPut, IDC_iconBackgroundMisc, RIGHT_PANEL_CUSTOM_BACKGROUND
#define ARROWS_IDCS IDC_arrowMinus, IDC_arrowPlus
#define GETDLC\
{\
private _dlc = "";\
private _addons = configsourceaddonlist _this;\
if (count _addons > 0) then {\
private _mods = configsourcemodlist (configfile >> "CfgPatches" >> _addons select 0);\
if (count _mods > 0) then {\
_dlc = _mods select 0;\
};\
};\
_dlc\
}
#define ADDMODICON\
{\
private _dlcName = _this call GETDLC;\
if (_dlcName != "") then {\
_ctrlPanel lbsetpictureright [_lbAdd,(modParams [_dlcName,["logo"]]) param [0,""]];\
};\
};
#define ADDBINOCULARSMAG\
private _magazines = getarray (configfile >> "cfgweapons" >> _item >> "magazines");\
if (count _magazines > 0) then {GVAR(center) addmagazine (_magazines select 0)};
#define TOGGLE_RIGHT_PANEL_WEAPON\
{\
_x = _display displayCtrl _x;\
@ -231,26 +301,21 @@
_x ctrlShow true;\
_x ctrlEnable true;\
_x ctrlCommit FADE_DELAY;\
} foreach [\
} forEach [\
IDC_blockRightFrame,\
IDC_blockRighttBackground,\
IDC_rightTabContent,\
IDC_sortRightTab,\
IDC_sortRightTabDirection,\
RIGHT_PANEL_ACC_IDCS,\
IDC_rightSearchbar,\
IDC_rightSearchbarButton,\
IDC_buttonCurrentMag\
];\
private _buttonCurrentMag2Ctrl = _display displayCtrl IDC_buttonCurrentMag2;\
if (GVAR(currentLeftPanel) == IDC_buttonPrimaryWeapon) then {\
_buttonCurrentMag2Ctrl ctrlSetFade 0;\
_buttonCurrentMag2Ctrl ctrlShow true;\
_buttonCurrentMag2Ctrl ctrlEnable true;\
} else {\
_buttonCurrentMag2Ctrl ctrlSetFade 1;\
_buttonCurrentMag2Ctrl ctrlShow false;\
_buttonCurrentMag2Ctrl ctrlEnable false;\
};\
_buttonCurrentMag2Ctrl ctrlSetFade 0;\
_buttonCurrentMag2Ctrl ctrlShow true;\
_buttonCurrentMag2Ctrl ctrlEnable true;\
_buttonCurrentMag2Ctrl ctrlCommit FADE_DELAY;\
{\
_x = _display displayCtrl _x;\
@ -258,7 +323,7 @@ _buttonCurrentMag2Ctrl ctrlCommit FADE_DELAY;\
_x ctrlShow false;\
_x ctrlEnable false;\
_x ctrlCommit FADE_DELAY;\
} foreach [\
} forEach [\
IDC_loadIndicator,\
RIGHT_PANEL_ITEMS_IDCS,\
IDC_rightTabContentListnBox,\
@ -274,7 +339,7 @@ _buttonCurrentMag2Ctrl ctrlCommit FADE_DELAY;\
safezoneH - 28 * GRID_H\
];\
_x ctrlCommit 0;\
} foreach [\
} forEach [\
IDC_blockRightFrame,\
IDC_blockRighttBackground\
];
@ -286,12 +351,13 @@ _buttonCurrentMag2Ctrl ctrlCommit FADE_DELAY;\
_x ctrlShow true;\
_x ctrlEnable true;\
_x ctrlCommit FADE_DELAY;\
} foreach [\
} forEach [\
IDC_blockRightFrame, \
IDC_blockRighttBackground,\
IDC_loadIndicator,\
IDC_rightTabContentListnBox,\
IDC_sortRightTab,\
IDC_sortRightTabDirection,\
IDC_tabRight,\
RIGHT_PANEL_ACC_IDCS,\
RIGHT_PANEL_ITEMS_IDCS,\
@ -304,7 +370,7 @@ _buttonCurrentMag2Ctrl ctrlCommit FADE_DELAY;\
_x ctrlShow false;\
_x ctrlEnable false;\
_x ctrlCommit FADE_DELAY;\
} foreach [\
} forEach [\
IDC_buttonCurrentMag,\
IDC_buttonCurrentMag2,\
IDC_iconBackgroundCurrentMag,\
@ -319,7 +385,7 @@ _buttonCurrentMag2Ctrl ctrlCommit FADE_DELAY;\
safezoneH - 34 * GRID_H\
];\
_x ctrlCommit 0;\
} foreach [\
} forEach [\
IDC_blockRightFrame,\
IDC_blockRighttBackground\
];\
@ -367,13 +433,14 @@ if (!isNil QGVAR(customRightPanelButtons)) then {\
_x ctrlShow false;\
_x ctrlEnable false;\
_x ctrlCommit FADE_DELAY;\
} foreach [\
} forEach [\
IDC_blockRightFrame,\
IDC_blockRighttBackground,\
IDC_loadIndicator,\
IDC_rightTabContent,\
IDC_rightTabContentListnBox,\
IDC_sortRightTab,\
IDC_sortRightTabDirection,\
RIGHT_PANEL_ACC_BACKGROUND_IDCS,\
RIGHT_PANEL_ACC_IDCS,\
RIGHT_PANEL_ITEMS_BACKGROUND_IDCS,\
@ -387,83 +454,12 @@ if (!isNil QGVAR(customRightPanelButtons)) then {\
IDC_iconBackgroundCurrentMag2\
];
#define LIST_DEFAULTS\
[\
[\
(primaryweapon GVAR(center) call bis_fnc_baseWeapon),\
(secondaryweapon GVAR(center) call bis_fnc_baseWeapon),\
(handgunweapon GVAR(center) call bis_fnc_baseWeapon)\
],\
[\
[primaryWeaponItems GVAR(center), secondaryWeaponItems GVAR(center), handgunItems GVAR(center)],\
[primaryWeaponMagazine GVAR(center), secondaryWeaponMagazine GVAR(center), handgunMagazine GVAR(center)]\
],\
uniformItems GVAR(center) + vestItems GVAR(center) + backpackItems GVAR(center),\
[headgear GVAR(center)],\
[uniform GVAR(center)],\
[vest GVAR(center)],\
[backpack GVAR(center)],\
[goggles GVAR(center)],\
[hmd GVAR(center)],\
[binocular GVAR(center)]\
]
#define CHECK_WEAPON_OR_ACC\
(_weaponsArray select 0) findIf {_x == _item} > -1 ||\
{(_weaponsArray select 1) findIf {_x == _item} > -1} ||\
{(_weaponsArray select 2) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 9) findIf {_x == _item} > -1} ||\
{(_accsArray select 0) findIf {_x == _item} > -1} ||\
{(_accsArray select 1 findIf {_x == _item} > -1)} ||\
{(_accsArray select 2) findIf {_x == _item} > -1} ||\
{(_accsArray select 3) findIf {_x == _item} > -1}
// PboProject 2.45 has problems with these macros for some reason, adding a single space before the \ fixes
#define CHECK_ASSIGNED_ITEMS \
(GVAR(virtualItems) select 10) findIf {_x == _item} > -1 ||\
{(GVAR(virtualItems) select 11) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 12) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 13) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 14) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 8) findIf {_x == _item} > -1}
#define CHECK_CONTAINER \
(GVAR(virtualItems) select 4) findIf {_x == _item} > -1 ||\
{(GVAR(virtualItems) select 5) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 6) findIf {_x == _item} > -1}
#define CLASS_CHECK_ITEM\
isClass (_weaponCfg >> _item) ||\
{isClass (_vehcCfg >> _item)} ||\
{isClass (_glassesCfg >> _item)} ||\
{isClass (_magCfg >> _item)}
#define CHECK_CONTAINER_ITEMS \
(GVAR(virtualItems) select 3) findIf {_x == _item} > -1 ||\
{(_accsArray select 0) findIf {_x == _item} > -1} ||\
{(_accsArray select 1) findIf {_x == _item} > -1} ||\
{(_accsArray select 2) findIf {_x == _item} > -1} ||\
{(_accsArray select 3) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 4) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 5) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 6) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 7) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 8) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 10) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 11) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 12) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 13) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 14) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 15) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 16) findIf {_x == _item} > -1} ||\
{(GVAR(virtualItems) select 17) findIf {_x == _item} > -1}
#define ADD_LOADOUTS_LIST_PICTURES\
_contentPanelCtrl lnbSetPicture [[_newRow, 2], getText (configFile >> "cfgWeapons" >> ((_loadout select 0) select 0) >> "picture")];\
_contentPanelCtrl lnbSetPicture [[_newRow, 3], getText (configFile >> "cfgWeapons" >> ((_loadout select 1) select 0) >> "picture")];\
_contentPanelCtrl lnbSetPicture [[_newRow, 4], getText (configFile >> "cfgWeapons" >> ((_loadout select 2) select 0) >> "picture")];\
_contentPanelCtrl lnbSetPicture [[_newRow, 5], getText (configFile >> "cfgWeapons" >> ((_loadout select 3) select 0) >> "picture")];\
_contentPanelCtrl lnbSetPicture [[_newRow, 6], getText (configFile >> "cfgWeapons" >> ((_loadout select 4) select 0) >> "picture")];\
_contentPanelCtrl lnbSetPicture [[_newRow, 7], getText (configFile >> "cfgVehicles" >> ((_loadout select 5) select 0) >> "picture")];\
_contentPanelCtrl lnbSetPicture [[_newRow, 8], getText (configFile >> "cfgWeapons" >> (_loadout select 6) >> "picture")];\
_contentPanelCtrl lnbSetPicture [[_newRow, 9], getText (configFile >> "cfgGlasses" >> (_loadout select 7) >> "picture")];
_contentPanelCtrl lnbSetPicture [[_newRow, 2], getText (_cfgWeapons >> (_loadout select IDX_LOADOUT_PRIMARY_WEAPON) select 0 >> "picture")];\
_contentPanelCtrl lnbSetPicture [[_newRow, 3], getText (_cfgWeapons >> (_loadout select IDX_LOADOUT_SECONDARY_WEAPON) select 0 >> "picture")];\
_contentPanelCtrl lnbSetPicture [[_newRow, 4], getText (_cfgWeapons >> (_loadout select IDX_LOADOUT_HANDGUN_WEAPON) select 0 >> "picture")];\
_contentPanelCtrl lnbSetPicture [[_newRow, 5], getText (_cfgWeapons >> (_loadout select IDX_LOADOUT_UNIFORM) select 0 >> "picture")];\
_contentPanelCtrl lnbSetPicture [[_newRow, 6], getText (_cfgWeapons >> (_loadout select IDX_LOADOUT_VEST) select 0 >> "picture")];\
_contentPanelCtrl lnbSetPicture [[_newRow, 7], getText (configFile >> "CfgVehicles" >> (_loadout select IDX_LOADOUT_BACKPACK) select 0 >> "picture")];\
_contentPanelCtrl lnbSetPicture [[_newRow, 8], getText (_cfgWeapons >> _loadout select IDX_LOADOUT_HEADGEAR >> "picture")];\
_contentPanelCtrl lnbSetPicture [[_newRow, 9], getText (configFile >> "CfgGlasses" >> _loadout select IDX_LOADOUT_GOGGLES >> "picture")];

View File

@ -1,8 +1,8 @@
#include "script_component.hpp"
/*
* Author: 654wak654
* Author: 654wak654, johnb43
* Adds a loadout to the "Default Loadouts" list.
* If a loadout with the same name exists, it is overwritten.
* If a loadout with a similar name exists (case insensitve), it is overwritten.
*
* Arguments:
* 0: Name of loadout <STRING>
@ -20,6 +20,8 @@
params [["_name", "", [""]], ["_loadout", [], [[]]]];
private _extendedInfo = createHashMap;
// Check if CBA extended loadout array
if (count _loadout == 2) then {
_extendedInfo = _loadout select 1;
_loadout = _loadout select 0;
@ -31,84 +33,15 @@ if (isNil QGVAR(defaultLoadoutsList)) then {
GVAR(defaultLoadoutsList) = [];
};
for "_dataIndex" from 0 to 10 do {
switch (_dataIndex) do {
// Replace unique items with their bases and replace weapons with their base weapons
_loadout = [_loadout] call FUNC(replaceUniqueItemsLoadout);
case 0;
case 1;
case 2;
case 8: {
if (count (_loadout select _dataIndex) > 0) then {
private _index = GVAR(defaultLoadoutsList) findIf {(_x select 0) == _name};
private _weapon = (_loadout select _dataIndex) select 0;
if (_weapon != "") then {
private _baseWeapon = _weapon call BIS_fnc_baseWeapon;
if (_weapon != _baseWeapon) then {
(_loadout select _dataIndex) set [0, _baseWeapon];
};
};
};
};
case 3;
case 4;
case 5: {
if (count (_loadout select _dataIndex) > 0) then {
private _containerContents = (_loadout select _dataIndex) select 1;
if (count _containerContents > 0) then {
{
if (count _x == 2) then {
if ((_x select 0) isEqualType "") then {
private _item = (_x select 0);
if (_item != "") then {
private _uniqueBaseCfgText = getText (configFile >> "CfgWeapons" >> _item >> "ace_arsenal_uniqueBase");
if (_uniqueBaseCfgText != "") then {
_x set [0, _uniqueBaseCfgText];
};
};
} else {
private _weapon = (_x select 0) select 0;
if (_weapon != "") then {
private _baseWeapon = _weapon call BIS_fnc_baseWeapon;
if (_weapon != _baseWeapon) then {
(_x select 0) set [0, _baseWeapon];
};
};
};
};
} foreach _containerContents;
};
};
};
case 9: {
for "_subIndex" from 0 to 4 do {
private _item = (_loadout select _dataIndex) select _subIndex;
if (_item != "") then {
private _uniqueBaseCfgText = getText (configFile >> "CfgWeapons" >> _item >> "ace_arsenal_uniqueBase");
if (_uniqueBaseCfgText != "") then {
(_loadout select _dataIndex) set [_subIndex, _uniqueBaseCfgText];
};
};
};
};
};
};
private _loadoutIndex = (+(GVAR(defaultLoadoutsList))) findIf {(_x select 0) == _name};
if (_loadoutIndex == -1) then {
GVAR(defaultLoadoutsList) pushBack [_name, [_loadout, _extendedInfo]];
// If there is an already existing loadout with similar name, overwrite it
if (_index != -1) then {
GVAR(defaultLoadoutsList) set [_index, [_name, [_loadout, _extendedInfo]]];
} else {
GVAR(defaultLoadoutsList) set [_loadoutIndex, [_name, [_loadout, _extendedInfo]]];
// Otherwise just add
GVAR(defaultLoadoutsList) pushBack [_name, [_loadout, _extendedInfo]];
};

View File

@ -1,13 +1,13 @@
#include "script_component.hpp"
/*
* Author: Dedmen
* Author: Dedmen, johnb43
* Add a listbox row.
*
* Arguments:
* 0: Config category, must be "CfgWeapons", "CfgVehicles", "CfgMagazines", "CfgVoice" <STRING>
* 0: Config category, must be "CfgWeapons", "CfgVehicles", "CfgMagazines", "CfgVoice" or "CfgUnitInsignia" <STRING>
* 1: Classname <STRING>
* 2: Panel control <CONTROL>
* 3: Name of the picture entry in that Cfg class <STRING>
* 3: Name of the picture entry in that Cfg class <STRING> (default: "picture")
*
* Return Value:
* None
@ -20,43 +20,18 @@
params ["_configCategory", "_className", "_ctrlPanel", ["_pictureEntryName", "picture", [""]]];
private _cacheNamespace = _ctrlPanel; //For better readability.
private _cachedItemInfo = _cacheNamespace getVariable [_configCategory+_className, []];
//_cachedItemInfo == [_displayName, _itemPicture, _modPicture]
if (_cachedItemInfo isEqualTo []) then {//Not in cache. So get info and put into cache.
// Sanitise key, as it's public; If not in cache, find info and cache it for later use
((uiNamespace getVariable QGVAR(addListBoxItemCache)) getOrDefaultCall [_configCategory + _className, {
// Get classname (config case), display name, picture and DLC
private _configPath = configFile >> _configCategory >> _className;
private _dlcName = _configPath call EFUNC(common,getAddon);
_cachedItemInfo set [0, getText (_configPath >> "displayName")];
//if _pictureEntryName is empty then this item has no Icons. (Faces)
_cachedItemInfo set [1, if (_pictureEntryName isEqualTo "") then {""} else {getText (_configPath >> _pictureEntryName)}];
//get name of DLC
private _dlcName = "";
private _addons = configsourceaddonlist _configPath;
if (_addons isNotEqualTo []) then {
private _mods = configsourcemodlist (configfile >> "CfgPatches" >> _addons select 0);
if (_mods isNotEqualTo []) then {
_dlcName = _mods select 0;
};
};
if (_dlcName != "") then {
_cachedItemInfo set [2, (modParams [_dlcName,["logo"]]) param [0,""]];//mod picture
} else {
_cachedItemInfo set [2, ""];//mod picture
_cachedItemInfo set [3, 0];//mod ID
};
_cacheNamespace setVariable [_configCategory+_className, _cachedItemInfo];
};
_cachedItemInfo params ["_displayName", "_itemPicture", "_modPicture"];
private _lbAdd = _ctrlPanel lbAdd _displayName;
// If _pictureEntryName is empty, then this item has no picture (e.g. faces)
[configName _configPath, getText (_configPath >> "displayName"), if (_pictureEntryName == "") then {""} else {getText (_configPath >> _pictureEntryName)}, if (_dlcName != "") then {(modParams [_dlcName, ["logo"]]) param [0, ""]} else {""}]
}, true]) params ["_className", "_displayName", "_itemPicture", "_modPicture"];
private _lbAdd = _ctrlPanel lbAdd _displayName;
_ctrlPanel lbSetData [_lbAdd, _className];
_ctrlPanel lbSetPicture [_lbAdd, _itemPicture];
_ctrlPanel lbSetPictureRight [_lbAdd,["",_modPicture] select (GVAR(enableModIcons))];
_ctrlPanel lbSetPictureRight [_lbAdd, ["", _modPicture] select GVAR(enableModIcons)];
_ctrlPanel lbSetTooltip [_lbAdd, format ["%1\n%2", _displayName, _className]];

View File

@ -1,18 +1,17 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: shukari, Schwaggot
* Adds a right panel button for uniforms, vests and backpacks with
* defined misc items.
* Author: shukari, Schwaggot, johnb43
* Adds a right panel button for uniforms, vests and backpacks with defined misc. items.
*
* Arguments:
* 0: items only misc items <ARRAY of STRING>
* 1: tooltip <STRING> (default: "")
* 2: picture path <STRING> (default: QPATHTOF(data\iconCustom.paa))
* 3: override a specific button (0-9) <NUMBER> (default: -1)
* 0: Items, must be misc items <ARRAY of STRINGS>
* 1: Tooltip <STRING> (default: "")
* 2: Picture path <STRING> (default: QPATHTOF(data\iconCustom.paa))
* 3: Override a specific button (0-9) <NUMBER> (default: -1)
*
* Return Value:
* successful: number of the slot (0-9); error: -1 <NUMBER>
* Successful: Number of the slot (0-9); Error: -1 <NUMBER>
*
* Example:
* [["ACE_bloodIV_500", "ACE_Banana"], "MedicalStuff", "\z\ace\addons\arsenal\data\iconCustom.paa", 5] call ace_arsenal_fnc_addRightPanelButton
@ -23,33 +22,42 @@
params [["_items", [], [[]]], ["_tooltip", "", [""]], ["_picture", QPATHTOF(data\iconCustom.paa), [""]], ["_override", -1, [0]]];
if (isNil QGVAR(customRightPanelButtons)) then {
GVAR(customRightPanelButtons) = [];
GVAR(customRightPanelButtons) = [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil];
};
private _position = count GVAR(customRightPanelButtons);
private _position = -1;
if (_override != -1 && {_override >= 0} && {_override <= 9}) then {
// See if override is valid
if (_override >= 0 && {_override <= 9}) then {
_position = _override;
} else {
// Try to find an empty spot
private _emptyPos = GVAR(customRightPanelButtons) findIf {isNil "_x"};
if (_emptyPos != -1) then {
_position = _emptyPos;
};
};
private _return = -1;
if (_position >= 0 && _position <= 9) then {
private _cfgWeapons = configFile >> "CfgWeapons";
_items = _items select {
private _configItemInfo = _cfgWeapons >> _x >> "ItemInfo";
_x isKindOf ["CBA_MiscItem", _cfgWeapons] && {getNumber (_configItemInfo >> "type") in [TYPE_MUZZLE, TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_BIPOD]} ||
{getNumber (_configItemInfo >> "type") in [TYPE_FIRST_AID_KIT, TYPE_MEDIKIT, TYPE_TOOLKIT]} ||
{getText (_cfgWeapons >> _x >> "simulation") == "ItemMineDetector"}
};
_return = _position;
GVAR(customRightPanelButtons) set [_position, [_items apply {toLower _x}, _picture, _tooltip]];
// If spot not found, return error
if (_position < 0 || {_position > 9}) exitWith {
-1
};
_return
// If spot found, add items and return position
private _cfgWeapons = configFile >> "CfgWeapons";
private _cfgMagazines = configFile >> "CfgMagazines";
private _configItemInfo = "";
_items = _items select {
_configItemInfo = _cfgWeapons >> _x >> "ItemInfo";
_x isKindOf ["CBA_MiscItem", _cfgWeapons] && {getNumber (_configItemInfo >> "type") in [TYPE_MUZZLE, TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_BIPOD]} ||
{getNumber (_configItemInfo >> "type") in [TYPE_FIRST_AID_KIT, TYPE_MEDIKIT, TYPE_TOOLKIT]} ||
{getText (_cfgWeapons >> _x >> "simulation") == "ItemMineDetector"} ||
{getNumber (_cfgMagazines >> _x >> "ACE_isUnique") == 1}
};
GVAR(customRightPanelButtons) set [_position, [_items apply {_x call EFUNC(common,getConfigName)}, _picture, _tooltip]];
_position

View File

@ -1,14 +1,14 @@
#include "script_component.hpp"
/*
* Author: Brett Mayson
* Add a custom sorting method.
* Author: Brett Mayson, johnb43
* Adds a custom sorting method.
*
* Arguments:
* 0: Tabs to add stat to <ARRAY>
* 0.0: Left Tab Indexes <ARRAY>
* 0.1: Right Tab Indexes <ARRAY>
* 0: Tabs to add sort to <ARRAY>
* 0.0: Left Tab Indexes <ARRAY of NUMBERS>
* 0.1: Right Tab Indexes <ARRAY of NUMBERS>
* 1: Sort Class (a unique string for each algorithm) <STRING>
* 2: Display Name <STRING>
* 2: Title <STRING>
* 3: Algorithm <CODE>
* 4: Condition <CODE> (default: true)
*
@ -23,11 +23,11 @@
*
* {
* _fireRate pushBackUnique (getNumber (_itemCfg >> _x >> "reloadTime"));
* } foreach _fireModes;
* } forEach _fireModes;
*
* _fireRate sort true;
* _fireRate param [0, 0]
* }] call ACE_arsenal_fnc_addSort;
* }] call ace_arsenal_fnc_addSort;
*
* Public: Yes
*/
@ -35,9 +35,10 @@
params [
["_tabs", [[], []], [[]], 2],
["_class", "", [""]],
["_displayName", "", [""]],
["_title", "", [""]],
["_statement", {}, [{}]],
["_condition", {true}, [{}]]
["_condition", {true}, [{}]],
["_overwrite", false, [false]]
];
_tabs params [
@ -45,28 +46,46 @@ _tabs params [
["_rightTabs", [], [[]]]
];
// Compile sorts from config (in case this is called before preInit)
call FUNC(compileSorts);
private _returnArray = [];
private _return = [];
private _fnc_addToTabs = {
params ["_tabsList", "_tabsToAddTo", "_sideString"];
params ["_tabsList", "_tabsToAddTo", "_tabSide"];
private _sort = [];
private _sortName = "";
private _currentTab = [];
{
private _arrayToSave = +_finalArray;
_arrayToSave set [0, [_class, _sideString, [str _x, format ["0%1", _x]] select (_x < 10)] joinString ""];
_returnArray pushBack (_arrayToSave select 0);
(_tabsList select _x) pushBack _arrayToSave;
// Copy title, statement and condition
_sort = +_finalArray;
// Make sort name
_sortName = [_class, _tabSide, [str _x, format ["0%1", _x]] select (_x < 10)] joinString "";
_sort set [0, _sortName];
_currentTab = _tabsList select _x;
// Find if there is an entry with same ID
if ((_currentTab findIf {(_x select 0) == _sortName}) == -1) then {
_currentTab pushBack _sort;
_return pushBack _sortName;
} else {
TRACE_1("A sort with this ID already exists", _sortName);
};
} forEach _tabsToAddTo;
};
_finalArray = ["", _displayName, _statement, _condition];
private _finalArray = ["", _title, _statement, _condition];
if (_leftTabs isNotEqualTo []) then {
[GVAR(sortListLeftPanel), _leftTabs, "L", 0] call _fnc_addToTabs;
[GVAR(sortListLeftPanel), _leftTabs, "L"] call _fnc_addToTabs;
};
if (_rightTabs isNotEqualTo []) then {
[GVAR(sortListRightPanel), _rightTabs, "R", 1] call _fnc_addToTabs;
[GVAR(sortListRightPanel), _rightTabs, "R"] call _fnc_addToTabs;
};
_returnArray
_return

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
/*
* Author: Alganthe
* Add a stat to ACE Arsenal.
* Author: Alganthe, johnb43
* Adds a stat to ACE Arsenal.
*
* Arguments:
* 0: Tabs to add the stat to <ARRAY of ARRAYS>
@ -11,22 +11,22 @@
* 2: Config entries to pass <ARRAY of STRINGS>
* 3: Title <STRING>
* 4: Show bar / show text bools <ARRAY of BOOLS>
* 4.0: Show bar <BOOL>
* 4.1: Show text <BOOL>
* 5: Array of statements <ARRAY of ARRAYS>
* 5.0: Bar code <CODE>
* 5.1: Text code <CODE>
* 5.2: Condition code <CODE>
* 4.0: Show bar <BOOL> (default: false)
* 4.1: Show text <BOOL> (default: false)
* 5: Array of statements <ARRAY of CODE>
* 5.0: Bar code <CODE> (default: {})
* 5.1: Text code <CODE> (default: {})
* 5.2: Condition code <CODE> (default: {true})
* 6: Priority <NUMBER> (default: 0)
*
* Return Value:
* 0: Array of IDs <ARRAY of STRINGS>
*
* Example:
* [[[0,1,2], [7]], "scopeStat", ["scope"], "Scope", [false, true], [{}, {
* [[[0, 1, 2], [7]], "scopeStat", ["scope"], "Scope", [false, true], [{}, {
* params ["_statsArray", "_itemCfg"];
* getNumber (_itemCfg >> _statsArray select 0)
* }, {true}]] call ACE_arsenal_fnc_addStat
* }, {true}]] call ace_arsenal_fnc_addStat
*
* Public: Yes
*/
@ -46,7 +46,10 @@ _tabs params [
["_rightTabs", [], [[]]]
];
_bools params [["_showBar", false, [false]], ["_showText", false, [false]]];
_bools params [
["_showBar", false, [false]],
["_showText", false, [false]]
];
_statements params [
["_barStatement", {}, [{}]],
@ -54,47 +57,100 @@ _statements params [
["_condition", {true}, [{}]]
];
// Compile stats from config (in case this is called before preInit)
call FUNC(compileStats);
private _returnArray = [];
private _return = [];
private _changes = [];
private _fnc_addToTabs = {
params ["_tabsList", "_tabsToAddTo", "_sideString", "_returnIndex"];
params ["_tabsList", "_tabsToAddTo", "_tabSide"];
private _statName = "";
private _currentTab = [];
private _stat = [];
{
private _currentTab = _tabsList select _x;
// Make stat name
_statName = [_class, _tabSide, [str _x, format ["0%1", _x]] select (_x < 10)] joinString "";
_currentTab = _tabsList select _x;
private _finalID = [_class, _sideString, [str _x, format ["0%1", _x]] select (_x < 10)] joinString "";
if ({{_x select 0 == _finalID} count _x > 0} count _currentTab > 0) then {
TRACE_1("A stat with this ID already exists", _finalID);
// Find if there is an entry with same ID
if (_currentTab findIf {_x findIf {_x select 0 == _statName} != -1} != -1) then {
TRACE_1("A stat with this ID already exists", _statName);
} else {
_stat = +_finalArray;
_stat set [0, _statName];
private _arrayToSave = +_finalArray;
_arrayToSave set [0, _finalID];
_returnArray pushBack _finalID;
_index = _currentTab findIf {count _x < 5};
// Add to existing page if there's enough space, otherwise create a new page
if ({count _x < 5} count _currentTab > 0) then {
{
if (count _x < 5) exitWith {
(_currentTab select _forEachIndex) append [_arrayToSave];
};
} foreach _currentTab;
if (_index != -1) then {
(_currentTab select _index) pushBack _stat;
} else {
_currentTab pushBack [_arrayToSave];
_currentTab pushBack [_stat];
};
_return pushBack _statName;
// Store information, so that only tabs that were changed can be sorted again
_changes pushBackUnique [_x, _tabSide];
};
} foreach _tabsToAddTo;
} forEach _tabsToAddTo;
};
private _finalArray = ["", _stats, _title, [_showBar, _showText], [_barStatement, _textStatement, _condition], _priority];
if (count _leftTabs > 0) then {
[GVAR(statsListLeftPanel), _leftTabs, "L", 0] call _fnc_addToTabs;
if (_leftTabs isNotEqualTo []) then {
[GVAR(statsListLeftPanel), _leftTabs, "L"] call _fnc_addToTabs;
};
if (count _rightTabs > 0) then {
[GVAR(statsListRightPanel), _rightTabs, "R", 1] call _fnc_addToTabs;
if (_rightTabs isNotEqualTo []) then {
[GVAR(statsListRightPanel), _rightTabs, "R"] call _fnc_addToTabs;
};
_returnArray
private _statsFlat = [];
private _stats = [];
private _tabToChange = [];
// Ensure priority is kept
{
_x params ["_tab", "_tabSide"];
_tabToChange = if (_tabSide == "R") then {
GVAR(statsListRightPanel)
} else {
GVAR(statsListLeftPanel)
};
_statsFlat = [];
// Get all stats of a tab into a single array
{
_statsFlat append _x;
} forEach (_tabToChange select _tab);
// Put priority up front
{
reverse _x;
} forEach _statsFlat;
// Sort numerically
_statsFlat sort false;
// Put it back at the rear
{
reverse _x;
} forEach _statsFlat;
_stats = [];
// Group stats into groups of 5
for "_index" from 0 to count _statsFlat - 1 step 5 do {
_stats pushBack (_statsFlat select [_index, _index + 5]);
};
_tabToChange set [_tab, _stats];
} forEach _changes;
_return

View File

@ -1,13 +1,13 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe, Dedmen
* Author: Alganthe, Dedmen, johnb43
* Add virtual items to the provided target.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Items <ARRAY of strings> <BOOL>
* 2: Add globally <BOOL>
* 1: Items <ARRAY of STRINGS> <BOOL>
* 2: Add globally <BOOL> (default: false)
*
* Return Value:
* None
@ -21,206 +21,105 @@
params [["_object", objNull, [objNull]], ["_items", [], [true, []]], ["_global", false, [false]]];
if (isNull _object) exitWith {};
if (_items isEqualType [] && {count _items == 0}) exitWith {};
if (isNull _object || {_items isEqualTo []}) exitWith {};
private _cargo = _object getVariable [QGVAR(virtualItems), [
[[], [], []], // Weapons 0, primary, secondary, handgun
[[], [], [], []], // WeaponAccessories 1, optic,side,muzzle,bipod
[ ], // Magazines 2
[ ], // Headgear 3
[ ], // Uniform 4
[ ], // Vest 5
[ ], // Backpacks 6
[ ], // Goggles 7
[ ], // NVGs 8
[ ], // Binoculars 9
[ ], // Map 10
[ ], // Compass 11
[ ], // Radio slot 12
[ ], // Watch slot 13
[ ], // Comms slot 14
[ ], // WeaponThrow 15
[ ], // WeaponPut 16
[ ] // InventoryItems 17
]];
private _cargo = _object getVariable QGVAR(virtualItems);
private _configCfgWeapons = configFile >> "CfgWeapons"; //Save this lookup in variable for perf improvement
if (isNil "_cargo") then {
_cargo = [
[IDX_VIRT_WEAPONS, createHashMapFromArray [[IDX_VIRT_PRIMARY_WEAPONS, createHashMap], [IDX_VIRT_SECONDARY_WEAPONS, createHashMap], [IDX_VIRT_HANDGUN_WEAPONS, createHashMap]]],
[IDX_VIRT_ATTACHMENTS, createHashMapFromArray [[IDX_VIRT_OPTICS_ATTACHMENTS, createHashMap], [IDX_VIRT_FLASHLIGHT_ATTACHMENTS, createHashMap], [IDX_VIRT_MUZZLE_ATTACHMENTS, createHashMap], [IDX_VIRT_BIPOD_ATTACHMENTS, createHashMap]]]
];
_cargo = createHashMapFromArray _cargo;
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
_cargo set [_index, createHashMap];
};
};
// If passed arguement is "true", add all items
if (_items isEqualType true) then {
if (_items) then {
private _weapons = _cargo get IDX_VIRT_WEAPONS;
private _weaponAttachments = _cargo get IDX_VIRT_ATTACHMENTS;
private _configItems = uiNamespace getVariable QGVAR(configItems);
// Add onto existing items, in case some items that were already added aren't available by default in the arsenal
{
(_x select 0) append (_x select 1);
(_x select 2) set [(_x select 3), (_x select 0) arrayIntersect (_x select 0)];
(_x select 0) merge [_x select 1, true];
(_x select 2) set [_x select 3, _x select 0];
} forEach [
[(_cargo select 0 select 0),(_configItems select 0 select 0), _cargo select 0, 0],
[(_cargo select 0 select 1),(_configItems select 0 select 1), _cargo select 0, 1],
[(_cargo select 0 select 2),(_configItems select 0 select 2), _cargo select 0, 2],
[(_cargo select 1 select 0),(_configItems select 1 select 0), _cargo select 1, 0],
[(_cargo select 1 select 1),(_configItems select 1 select 1), _cargo select 1, 1],
[(_cargo select 1 select 2),(_configItems select 1 select 2), _cargo select 1, 2],
[(_cargo select 1 select 3),(_configItems select 1 select 3), _cargo select 1, 3]
[_weapons get IDX_VIRT_PRIMARY_WEAPONS, _configItems get IDX_VIRT_WEAPONS get IDX_VIRT_PRIMARY_WEAPONS, _weapons, IDX_VIRT_PRIMARY_WEAPONS],
[_weapons get IDX_VIRT_SECONDARY_WEAPONS, _configItems get IDX_VIRT_WEAPONS get IDX_VIRT_SECONDARY_WEAPONS, _weapons, IDX_VIRT_SECONDARY_WEAPONS],
[_weapons get IDX_VIRT_HANDGUN_WEAPONS, _configItems get IDX_VIRT_WEAPONS get IDX_VIRT_HANDGUN_WEAPONS, _weapons, IDX_VIRT_HANDGUN_WEAPONS],
[_weaponAttachments get IDX_VIRT_OPTICS_ATTACHMENTS, _configItems get IDX_VIRT_ATTACHMENTS get IDX_VIRT_OPTICS_ATTACHMENTS, _weaponAttachments, IDX_VIRT_OPTICS_ATTACHMENTS],
[_weaponAttachments get IDX_VIRT_FLASHLIGHT_ATTACHMENTS, _configItems get IDX_VIRT_ATTACHMENTS get IDX_VIRT_FLASHLIGHT_ATTACHMENTS, _weaponAttachments, IDX_VIRT_FLASHLIGHT_ATTACHMENTS],
[_weaponAttachments get IDX_VIRT_MUZZLE_ATTACHMENTS, _configItems get IDX_VIRT_ATTACHMENTS get IDX_VIRT_MUZZLE_ATTACHMENTS, _weaponAttachments, IDX_VIRT_MUZZLE_ATTACHMENTS],
[_weaponAttachments get IDX_VIRT_BIPOD_ATTACHMENTS, _configItems get IDX_VIRT_ATTACHMENTS get IDX_VIRT_BIPOD_ATTACHMENTS, _weaponAttachments, IDX_VIRT_BIPOD_ATTACHMENTS]
];
for "_index" from 2 to 17 do {
(_cargo select _index) append (_configItems select _index);
_cargo set [_index, (_cargo select _index) arrayIntersect (_cargo select _index)];
// Add onto existing items, in case some items that were already added aren't available by default in the arsenal
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
(_cargo get _index) merge [_configItems get _index, true];
_cargo set [_index, _cargo get _index];
};
};
} else {
// Make sure all items are in string form, then convert to config case (non-existent items return "")
_items = (_items select {_x isEqualType ""}) apply {_x call EFUNC(common,getConfigName)};
// Remove any invalid/non-existing items
_items = _items - [""];
private _configItems = uiNamespace getVariable QGVAR(configItems);
private _configItemsFlat = uiNamespace getVariable QGVAR(configItemsFlat);
// Convert all items to their baseWeapon
_items = _items apply {if (_x in _configItemsFlat) then {_x} else {_x call FUNC(baseWeapon)}};
// Remove any items not found by the arsenal
_items = _items select {_x in _configItemsFlat};
// https://community.bistudio.com/wiki/Arma_3:_Characters_And_Gear_Encoding_Guide#Character_configuration
// https://github.com/acemod/ACE3/pull/9040#issuecomment-1597748331
{
if (_x isEqualType "") then {
private _configItemInfo = _configCfgWeapons >> _x >> "ItemInfo";
private _simulationType = getText (_configCfgWeapons >> _x >> "simulation");
switch true do {
case (isClass (_configCfgWeapons >> _x)): {
switch true do {
/* Weapon acc */
case (
isClass (_configItemInfo) &&
{(getNumber (_configItemInfo >> "type")) in [TYPE_MUZZLE, TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_BIPOD]} &&
{!(_x isKindOf ["CBA_MiscItem", (_configCfgWeapons)])}
): {
switch (getNumber (_configItemInfo >> "type")) do {
case TYPE_OPTICS: {
(_cargo select 1) select 0 pushBackUnique _x;
};
case TYPE_FLASHLIGHT: {
(_cargo select 1) select 1 pushBackUnique _x;
};
case TYPE_MUZZLE: {
(_cargo select 1) select 2 pushBackUnique _x;
};
case TYPE_BIPOD: {
(_cargo select 1) select 3 pushBackUnique _x;
};
};
};
/* Headgear */
case (isClass (_configItemInfo) &&
{getNumber (_configItemInfo >> "type") == TYPE_HEADGEAR}): {
(_cargo select 3) pushBackUnique _x;
};
/* Uniform */
case (isClass (_configItemInfo) &&
{getNumber (_configItemInfo >> "type") == TYPE_UNIFORM}): {
(_cargo select 4) pushBackUnique _x;
};
/* Vest */
case (isClass (_configItemInfo) &&
{getNumber (_configItemInfo >> "type") == TYPE_VEST}): {
(_cargo select 5) pushBackUnique _x;
};
/* NVgs */
case (_simulationType == "NVGoggles"): {
(_cargo select 8) pushBackUnique _x;
};
/* Binos */
case (_simulationType == "Binocular" ||
{(_simulationType == 'Weapon') && {(getNumber (_configCfgWeapons >> _x >> 'type') == TYPE_BINOCULAR_AND_NVG)}}): {
(_cargo select 9) pushBackUnique _x;
};
/* Map */
case (_simulationType == "ItemMap"): {
(_cargo select 10) pushBackUnique _x;
};
/* Compass */
case (_simulationType == "ItemCompass"): {
(_cargo select 11) pushBackUnique _x;
};
/* Radio */
case (_simulationType == "ItemRadio"): {
(_cargo select 12) pushBackUnique _x;
};
/* Watch */
case (_simulationType == "ItemWatch"): {
(_cargo select 13) pushBackUnique _x;
};
/* GPS */
case (_simulationType == "ItemGPS"): {
(_cargo select 14) pushBackUnique _x;
};
/* UAV terminals */
case (isClass (_configItemInfo) &&
{getNumber (_configItemInfo >> "type") == TYPE_UAV_TERMINAL}): {
(_cargo select 14) pushBackUnique _x;
};
/* Weapon, at the bottom to avoid adding binos */
case (isClass (_configCfgWeapons >> _x >> "WeaponSlotsInfo") &&
{getNumber (_configCfgWeapons >> _x >> 'type') != TYPE_BINOCULAR_AND_NVG}): {
switch (getNumber (_configCfgWeapons >> _x >> "type")) do {
case TYPE_WEAPON_PRIMARY: {
(_cargo select 0) select 0 pushBackUnique ([_x] call bis_fnc_baseWeapon);
};
case TYPE_WEAPON_HANDGUN: {
(_cargo select 0) select 2 pushBackUnique ([_x] call bis_fnc_baseWeapon);
};
case TYPE_WEAPON_SECONDARY: {
(_cargo select 0) select 1 pushBackUnique ([_x] call bis_fnc_baseWeapon);
};
};
};
/* Misc items */
case (
isClass (_configItemInfo) &&
((getNumber (_configItemInfo >> "type")) in [TYPE_MUZZLE, TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_BIPOD] &&
{(_x isKindOf ["CBA_MiscItem", (_configCfgWeapons)])}) ||
{(getNumber (_configItemInfo >> "type")) in [TYPE_FIRST_AID_KIT, TYPE_MEDIKIT, TYPE_TOOLKIT]} ||
{(getText (_configCfgWeapons >> _x >> "simulation")) == "ItemMineDetector"}
): {
(_cargo select 17) pushBackUnique _x;
};
};
};
case (isClass (configFile >> "CfgMagazines" >> _x)): {
// Lists to check against
private _grenadeList = [];
{
_grenadeList append getArray (_configCfgWeapons >> "Throw" >> _x >> "magazines");
false
} count getArray (_configCfgWeapons >> "Throw" >> "muzzles");
switch (true) do {
// Weapons
case (_x in ((_configItems get IDX_VIRT_WEAPONS) get IDX_VIRT_PRIMARY_WEAPONS)): {
((_cargo get IDX_VIRT_WEAPONS) get IDX_VIRT_PRIMARY_WEAPONS) set [_x, nil];
};
case (_x in ((_configItems get IDX_VIRT_WEAPONS) get IDX_VIRT_HANDGUN_WEAPONS)): {
((_cargo get IDX_VIRT_WEAPONS) get IDX_VIRT_HANDGUN_WEAPONS) set [_x, nil];
};
case (_x in ((_configItems get IDX_VIRT_WEAPONS) get IDX_VIRT_SECONDARY_WEAPONS)): {
((_cargo get IDX_VIRT_WEAPONS) get IDX_VIRT_SECONDARY_WEAPONS) set [_x, nil];
};
private _putList = [];
{
_putList append getArray (_configCfgWeapons >> "Put" >> _x >> "magazines");
false
} count getArray (_configCfgWeapons >> "Put" >> "muzzles");
// Weapon attachments
case (_x in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_OPTICS_ATTACHMENTS)): {
((_cargo get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_OPTICS_ATTACHMENTS) set [_x, nil];
};
case (_x in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_FLASHLIGHT_ATTACHMENTS)): {
((_cargo get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_FLASHLIGHT_ATTACHMENTS) set [_x, nil];
};
case (_x in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_MUZZLE_ATTACHMENTS)): {
((_cargo get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_MUZZLE_ATTACHMENTS) set [_x, nil];
};
case (_x in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_BIPOD_ATTACHMENTS)): {
((_cargo get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_BIPOD_ATTACHMENTS) set [_x, nil];
};
// Check what the magazine actually is
switch true do {
// Rifle, handgun, secondary weapons mags
case (
((getNumber (configFile >> "CfgMagazines" >> _x >> "type") in [TYPE_MAGAZINE_PRIMARY_AND_THROW,TYPE_MAGAZINE_SECONDARY_AND_PUT,1536,TYPE_MAGAZINE_HANDGUN_AND_GL]) ||
{(getNumber (configFile >> "CfgMagazines" >> _x >> QGVAR(hide))) == -1}) &&
{!(_x in _grenadeList)} &&
{!(_x in _putList)}
): {
(_cargo select 2) pushBackUnique _x;
};
// Grenades
case (_x in _grenadeList): {
(_cargo select 15) pushBackUnique _x;
};
// Put
case (_x in _putList): {
(_cargo select 16) pushBackUnique _x;
};
// Other
default {
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
if (_x in (_configItems get _index)) exitWith {
(_cargo get _index) set [_x, nil];
};
};
case (isClass (configFile >> "CfgVehicles" >> _x)): {
if (getNumber (configFile >> "CfgVehicles" >> _x >> "isBackpack") == 1) then {
(_cargo select 6) pushBackUnique _x;
};
};
case (isClass (configFile >> "CfgGlasses" >> _x)): {
(_cargo select 7) pushBackUnique _x;
};
};
};
} foreach _items;
} forEach _items;
};
_object setVariable [QGVAR(virtualItems), _cargo, _global];

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: mharis001
* Author: mharis001, johnb43
* Adds compatible attachments or magazines for all weapons in 3DEN attribute.
*
* Arguments:
@ -21,55 +21,63 @@ params ["_controlsGroup"];
private _category = lbCurSel (_controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_CATEGORY);
// Exit if selected category is not attachments or magazines
if !(_category in [4, 5, 6, 7, 8]) exitWith {};
if !(_category in [IDX_CAT_OPTICS_ATTACHMENTS, IDX_CAT_FLASHLIGHT_ATTACHMENTS, IDX_CAT_MUZZLE_ATTACHMENTS, IDX_CAT_BIPOD_ATTACHMENTS, IDX_CAT_ITEMS_ALL]) exitWith {};
private _configItems = +(uiNamespace getVariable [QGVAR(configItems), []]);
private _configItems = uiNamespace getVariable QGVAR(configItems);
private _attributeValue = uiNamespace getVariable [QGVAR(attributeValue), [[], 0]];
_attributeValue params ["_attributeItems"];
// Get list of all weapons in attribute items
(_configItems select 0) params ["_primaryWeapons", "_secondaryWeapons", "_handgunWeapons"];
private _attributeWeapons = _attributeItems select {_x in _primaryWeapons || {_x in _secondaryWeapons} || {_x in _handgunWeapons}};
private _attributeWeapons = [];
{
_attributeWeapons append (_attributeItems arrayIntersect (keys _y));
} forEach (_configItems get IDX_VIRT_WEAPONS);
private _itemsToAdd = createHashMap;
// Add compatible attachments or magazines to attribute
private _cfgWeapons = configFile >> "CfgWeapons";
private _itemsToAdd = [];
if (_category == 8) then {
private _magazineGroups = uiNamespace getVariable QGVAR(magazineGroups);
private _cfgMagazines = configFile >> "CfgMagazines";
if (_category == IDX_CAT_ITEMS_ALL) then {
// Add compatible attachments or magazines to attribute
private _compatibleMagazines = createHashMap;
// Get all compatible magazines for weapons
{
private _weaponConfig = _cfgWeapons >> _x;
{
private _muzzleConfig = if (_x == "this") then {_weaponConfig} else {_weaponConfig >> _x};
// Only add existent magazines and ensure correct classname case
private _magazines = getArray (_muzzleConfig >> "magazines") select {isClass (_cfgMagazines >> _x)};
_magazines = _magazines apply {configName (_cfgMagazines >> _x)};
_itemsToAdd append _magazines;
{
_itemsToAdd append (_magazineGroups get (toLower _x));
} forEach getArray (_muzzleConfig >> "magazineWell");
} forEach getArray (_weaponConfig >> "muzzles");
_compatibleMagazines insert [true, compatibleMagazines _x, []];
} forEach _attributeWeapons;
// Check if magazines are in configItems
{
if (_x in (_configItems get IDX_VIRT_ITEMS_ALL)) then {
_itemsToAdd set [_x, nil];
};
} forEach (keys _compatibleMagazines);
} else {
private _attachmentCategory = _category - 4;
private _filter = ["optic", "pointer", "muzzle", "bipod"] select _attachmentCategory;
private _compatibleItems = createHashMap;
// CBA_fnc_compatibleItems returns config case sensitive names
{
_itemsToAdd append ([_x, _filter] call CBA_fnc_compatibleItems);
_compatibleItems insert [true, [_x, _filter] call CBA_fnc_compatibleItems, []];
} forEach _attributeWeapons;
// Only add items with scope of 2 and ensure correct classname case
_itemsToAdd = _itemsToAdd select {getNumber (_cfgWeapons >> _x >> "scope") == 2};
_itemsToAdd = _itemsToAdd apply {configName (_cfgWeapons >> _x)};
// Check if attachments are in configItems
{
if (
_x in (_configItems get IDX_VIRT_ATTACHMENTS get IDX_VIRT_OPTICS_ATTACHMENTS) ||
{_x in (_configItems get IDX_VIRT_ATTACHMENTS get IDX_VIRT_FLASHLIGHT_ATTACHMENTS)} ||
{_x in (_configItems get IDX_VIRT_ATTACHMENTS get IDX_VIRT_MUZZLE_ATTACHMENTS)} ||
{_x in (_configItems get IDX_VIRT_ATTACHMENTS get IDX_VIRT_BIPOD_ATTACHMENTS)}
) then {
_itemsToAdd set [_x, nil];
};
} forEach (keys _compatibleItems);
};
_attributeItems append _itemsToAdd;
_attributeValue set [0, _attributeItems arrayIntersect _attributeItems];
// Only take items that can be found by default in the arsenal
_attributeItems insert [-1, keys _itemsToAdd, true];
_attributeValue set [0, _attributeItems];
// Refresh the list for new items
[_controlsGroup] call FUNC(attributeAddItems);

View File

@ -1,8 +1,8 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: mharis001
* Populates 3DEN attribute listbox with items of given category.
* Author: mharis001, johnb43
* Populates 3DEN's ace arsenal attribute listbox with items of given category.
*
* Arguments:
* 0: Attribute controls group <CONTROL>
@ -18,105 +18,117 @@
params ["_controlsGroup"];
private _category = lbCurSel (_controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_CATEGORY) - 1;
private _category = lbCurSel (_controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_CATEGORY);
private _filter = toLower ctrlText (_controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_SEARCHBAR);
private _configItems = +(uiNamespace getVariable [QGVAR(configItems), []]);
private _configItems = uiNamespace getVariable QGVAR(configItems);
private _magazineMiscItems = uiNamespace getVariable QGVAR(magazineMiscItems);
private _attributeValue = uiNamespace getVariable [QGVAR(attributeValue), [[], 0]];
_attributeValue params ["_attributeItems", "_attributeMode"];
TRACE_3("Populating list",_category,_filter,_attributeValue);
_attributeValue params ["_attributeItems", "_attributeMode"];
private _modeSymbol = [SYMBOL_ITEM_VIRTUAL, SYMBOL_ITEM_REMOVE] select _attributeMode;
// Clear listbox
private _listbox = _controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_LIST;
lnbClear _listbox;
private _cfgWeapons = configFile >> "CfgWeapons";
private _cfgMagazines = configFile >> "CfgMagazines";
private _cfgVehicles = configFile >> "CfgVehicles";
private _cfgGlasses = configFile >> "CfgGlasses";
// Exit with current items (no specific category)
if (_category == -1) exitWith {
if (_category == IDX_CAT_ALL) exitWith {
private _config = configNull;
private _displayName = "";
private _index = -1;
{
// Get appropriate config for each item (different since items can be from any category)
private _config = switch (true) do {
case (_x in (_configItems select 2));
case (_x in (_configItems select 15));
case (_x in (_configItems select 16)): {
configFile >> "CfgMagazines" >> _x;
};
case (_x in (_configItems select 6)): {
configFile >> "CfgVehicles" >> _x;
};
case (_x in (_configItems select 7)): {
configFile >> "CfgGlasses" >> _x;
};
default {
configFile >> "CfgWeapons" >> _x;
};
_config = switch (true) do {
case (_x in _magazineMiscItems);
case (_x in (_configItems get IDX_VIRT_ITEMS_ALL));
case (_x in (_configItems get IDX_VIRT_GRENADES));
case (_x in (_configItems get IDX_VIRT_EXPLOSIVES)): {_cfgMagazines >> _x};
case (_x in (_configItems get IDX_VIRT_BACKPACK)): {_cfgVehicles >> _x};
case (_x in (_configItems get IDX_VIRT_GOGGLES)): {_cfgGlasses >> _x};
default {_cfgWeapons >> _x};
};
_displayName = getText (_config >> "displayName");
// Add item if not filtered
private _displayName = getText (_config >> "displayName");
if (toLower _displayName find _filter > -1) then {
private _picture = getText (_config >> "picture");
private _index = _listbox lnbAddRow ["", _displayName, _modeSymbol];
if (_filter in (toLower _displayName) || {_filter in (toLower _x)}) then {
_index = _listbox lnbAddRow ["", _displayName, _modeSymbol];
_listbox lnbSetData [[_index, 1], _x];
_listbox lnbSetPicture [[_index, 0], _picture];
_listbox lbSetTooltip [_index * (count lnbGetColumnsPosition _listbox), _x];
_listbox lnbSetPicture [[_index, 0], getText (_config >> "picture")];
_listbox lnbSetTooltip [[_index, 0], _x];
};
} forEach _attributeItems;
_listbox lnbSort [1];
// Sort alphabetically
_listbox lnbSort [1, false];
};
// Get list of category items
private _categoryItems = switch (true) do {
case (_category < 3): {
_configItems select 0 select _category;
// Weapons
case (_category < IDX_CAT_OPTICS_ATTACHMENTS): {
(_configItems get IDX_VIRT_WEAPONS) get (_category - 1)
};
case (_category < 7): {
_configItems select 1 select (_category - 3);
// Weapon attachments
case (_category < IDX_CAT_ITEMS_ALL): {
(_configItems get IDX_VIRT_ATTACHMENTS) get (_category - 4)
};
// Other
default {
_configItems select (_category - 5);
_configItems get (_category - 6)
};
};
// Get config for current category
private _config = switch (true) do {
case (_category in [7, 20, 21]): {
configFile >> "CfgMagazines";
};
case (_category == 11): {
configFile >> "CfgVehicles";
};
case (_category == 12): {
configFile >> "CfgGlasses";
};
default {
configFile >> "CfgWeapons";
};
private _cfgClass = switch (true) do {
case (_category in [IDX_CAT_ITEMS_ALL, IDX_CAT_GRENADES, IDX_CAT_EXPLOSIVES]): {_cfgMagazines};
case (_category == IDX_CAT_BACKPACK): {_cfgVehicles};
case (_category == IDX_CAT_GOGGLES): {_cfgGlasses};
default {_cfgWeapons};
};
private _displayName = "";
private _symbol = SYMBOL_ITEM_NONE;
private _alpha = 0;
private _index = -1;
private _config = _cfgClass;
// Populate listbox with category items
{
// Add item if not filtered
private _displayName = getText (_config >> _x >> "displayName");
if (toLower _displayName find _filter > -1) then {
private _picture = getText (_config >> _x >> "picture");
private _symbol = SYMBOL_ITEM_NONE;
private _alpha = 0.5;
// "Misc. items" magazines (e.g. spare barrels, intel, photos)
if (_category == IDX_CAT_MISC_ITEMS) then {
_config = [_cfgClass, _cfgMagazines] select (_x in _magazineMiscItems);
};
_displayName = getText (_config >> _x >> "displayName");
// Add item if not filtered
if (_filter in (toLower _displayName) || {_filter in (toLower _x)}) then {
// Change symbol and alpha if item already selected
if (_x in _attributeItems) then {
_symbol = _modeSymbol;
_alpha = 1;
} else {
_symbol = SYMBOL_ITEM_NONE;
_alpha = 0.5;
};
private _index = _listbox lnbAddRow ["", _displayName, _symbol];
_index = _listbox lnbAddRow ["", _displayName, _symbol];
_listbox lnbSetData [[_index, 1], _x];
_listbox lnbSetPicture [[_index, 0], _picture];
_listbox lbSetTooltip [_index * (count lnbGetColumnsPosition _listbox), _x];
_listbox lnbSetPicture [[_index, 0], getText (_config >> _x >> "picture")];
_listbox lnbSetTooltip [[_index, 0], _x];
_listbox lnbSetColor [[_index, 1], [1, 1, 1, _alpha]];
_listbox lnbSetColor [[_index, 2], [1, 1, 1, _alpha]];
};
} forEach _categoryItems;
} forEach (keys _categoryItems);
_listbox lnbSort [1];
// Sort alphabetically
_listbox lnbSort [1, false];

View File

@ -2,7 +2,7 @@
#include "..\defines.hpp"
/*
* Author: mharis001
* Handles changing the category in 3DEN attribute.
* Handles changing the category in 3DEN's ace arsenal attribute.
*
* Arguments:
* 0: Attribute controls group <CONTROL>
@ -24,7 +24,7 @@ uiNamespace setVariable [QGVAR(attributeCategory), _category];
// Show add compatible items button when category is attachments or magazines
private _compatibleButton = _controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_ADD_COMPATIBLE;
private _enable = _category in [4, 5, 6, 7, 8];
private _enable = _category in [IDX_CAT_OPTICS_ATTACHMENTS, IDX_CAT_FLASHLIGHT_ATTACHMENTS, IDX_CAT_MUZZLE_ATTACHMENTS, IDX_CAT_BIPOD_ATTACHMENTS, IDX_CAT_ITEMS_ALL];
_compatibleButton ctrlEnable _enable;
_compatibleButton ctrlShow _enable;

View File

@ -2,7 +2,7 @@
#include "..\defines.hpp"
/*
* Author: mharis001
* Clears all items from current category in 3DEN attribute.
* Clears all items from current category in 3DEN's ace arsenal attribute.
*
* Arguments:
* 0: Attribute controls group <CONTROL>
@ -18,28 +18,32 @@
params ["_controlsGroup"];
private _category = lbCurSel (_controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_CATEGORY) - 1;
private _category = lbCurSel (_controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_CATEGORY);
private _attributeValue = uiNamespace getVariable [QGVAR(attributeValue), [[], 0]];
TRACE_1("Handling clear button",_category);
// Remove all if no specific category
if (_category == -1) then {
if (_category == IDX_CAT_ALL) then {
_attributeValue set [0, []];
} else {
// Find category items and remove from list
private _configItems = +(uiNamespace getVariable [QGVAR(configItems), []]);
private _configItems = uiNamespace getVariable QGVAR(configItems);
private _categoryItems = switch (true) do {
case (_category < 3): {
_configItems select 0 select _category;
// Weapons
case (_category < IDX_CAT_OPTICS_ATTACHMENTS): {
(_configItems get IDX_VIRT_WEAPONS) get (_category - 1)
};
case (_category < 7): {
_configItems select 1 select (_category - 3);
// Weapon attachments
case (_category < IDX_CAT_ITEMS_ALL): {
(_configItems get IDX_VIRT_ATTACHMENTS) get (_category - 4)
};
// Other
default {
_configItems select (_category - 5);
_configItems get (_category - 6)
};
};
_attributeValue set [0, (_attributeValue select 0) - _categoryItems];
_attributeValue set [0, (_attributeValue select 0) select {!(_x in _categoryItems)}];
};
// Refresh the list after clear

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
/*
* Author: mharis001
* Handles double clicking a row in 3DEN attribute listbox.
* Handles double clicking a row in 3DEN's ace arsenal attribute listbox.
*
* Arguments:
* 0: Listbox <CONTROL>

View File

@ -1,7 +1,8 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: mharis001
* Handles importing items list from clipboard into 3DEN attribute.
* Handles importing items list from clipboard into 3DEN's ace arsenal attribute.
*
* Arguments:
* 0: Attribute controls group <CONTROL>
@ -15,8 +16,6 @@
* Public: No
*/
params ["_controlsGroup"];
private _importList = call compile copyFromClipboard;
// Verify import list is in correct format
@ -24,23 +23,17 @@ if (isNil "_importList" || {!(_importList isEqualType [])} || {!(_importList isE
playSound ["3DEN_notificationWarning", true];
};
// Ensure imported items are in scanned config array and classname case is correct
private _configItems = +(uiNamespace getVariable [QGVAR(configItems), []]);
private _configItemsFlat = _configItems select [2, 16];
_configItemsFlat append (_configItems select 0);
_configItemsFlat append (_configItems select 1);
params ["_controlsGroup"];
private _filteredList = [];
// Convert all items to config case
_importList = _importList apply {_x call EFUNC(common,getConfigName)};
{
private _item = _x;
{
private _index = _x findIf {_x == _item};
if (_index > -1) then {
_filteredList pushBackUnique (_x select _index);
};
} forEach _configItemsFlat;
} forEach _importList;
// Remove any invalid/non-existing items
_importList = _importList - [""];
// Ensure imported items are in scanned config array
private _configItemsFlat = uiNamespace getVariable QGVAR(configItemsFlat);
private _filteredList = _importList select {_x in _configItemsFlat};
private _attributeValue = uiNamespace getVariable [QGVAR(attributeValue), [[], 0]];
_attributeValue set [0, _filteredList];

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
/*
* Author: mharis001
* Initializes the objects 3DEN attribute at scenario start.
* Initializes the objects 3DEN's ace arsenal attribute at scenario start.
*
* Arguments:
* 0: Attribute target <OBJECT>
@ -28,6 +28,7 @@ if (_mode > 0) then {
[{
[{
params ["_object", "_items"];
[_object, _items, true] call FUNC(removeVirtualItems);
}, _this] call CBA_fnc_execNextFrame;
}, [_object, _items]] call CBA_fnc_execNextFrame;

View File

@ -2,7 +2,7 @@
#include "\a3\ui_f\hpp\defineDIKCodes.inc"
/*
* Author: mharis001
* Handles keyboard input for the 3DEN attribute.
* Handles keyboard input for the 3DEN's ace arsenal attribute.
*
* Arguments:
* 0: Display <DISPLAY>
@ -21,18 +21,23 @@ params ["_display", "_keyCode"];
TRACE_2("Attribute key down",_display,_keyCode);
// Exit if attribute is not in focus
private _controlsGroup = uiNamespace getVariable QGVAR(attributeFocus);
if (isNil "_controlsGroup") exitWith {false};
private _controlsGroup = uiNamespace getVariable [QGVAR(attributeFocus), controlNull];
if (isNull _controlsGroup) exitWith {false};
switch (_keyCode) do {
// Unselect item
case DIK_LEFT;
case DIK_NUMPADMINUS: {
[_controlsGroup, false] call FUNC(attributeSelect);
true
};
// Select item
case DIK_RIGHT;
case DIK_NUMPADPLUS: {
[_controlsGroup, true] call FUNC(attributeSelect);
true
};
default {false};

View File

@ -2,7 +2,7 @@
#include "..\defines.hpp"
/*
* Author: mharis001
* Initializes the 3DEN attribute.
* Initializes the 3DEN's ace arsenal attribute.
*
* Arguments:
* 0: Attribute controls group <CONTROL>
@ -23,10 +23,8 @@ TRACE_1("Initializing 3DEN attribute",_value);
// Store working attribute value
uiNamespace setVariable [QGVAR(attributeValue), _value];
// Add keyDown EH to display
// Does not work properly when added to controls group
private _display = ctrlParent _controlsGroup;
_display displayAddEventHandler ["KeyDown", {call FUNC(attributeKeyDown)}];
// Add keyDown EH to display; Does not work properly when added to controls group
(ctrlParent _controlsGroup) displayAddEventHandler ["KeyDown", {call FUNC(attributeKeyDown)}];
// Handle selected mode
if (_value select 1 > 0) then {

View File

@ -2,7 +2,7 @@
#include "..\defines.hpp"
/*
* Author: mharis001
* Handles changing the mode in 3DEN attribute.
* Handles changing the mode in 3DEN's ace arsenal attribute.
*
* Arguments:
* 0: Attribute controls group <CONTROL>

View File

@ -2,7 +2,7 @@
#include "..\defines.hpp"
/*
* Author: mharis001
* Handles adding/removing an item from 3DEN attribute list.
* Handles adding/removing an item from 3DEN's ace arsenal attribute list.
*
* Arguments:
* 0: Attribute controls group <CONTROL>
@ -28,11 +28,12 @@ TRACE_2("Handling item selection",_itemClassname,_addItem);
private _attributeValue = uiNamespace getVariable [QGVAR(attributeValue), [[], 0]];
_attributeValue params ["_attributeItems", "_attributeMode"];
private _findItem = _attributeItems find _itemClassname;
private _itemIndex = _attributeItems find _itemClassname;
// Add item if not already in list
if (_addItem && {_findItem < 0}) exitWith {
if (_addItem && {_itemIndex == -1}) exitWith {
_attributeItems pushBack _itemClassname;
// Change symbol and increase alpha
_listbox lnbSetText [[_currentRow, 2], [SYMBOL_ITEM_VIRTUAL, SYMBOL_ITEM_REMOVE] select _attributeMode];
_listbox lnbSetColor [[_currentRow, 1], [1, 1, 1, 1]];
@ -40,8 +41,9 @@ if (_addItem && {_findItem < 0}) exitWith {
};
// Remove item if in list
if (!_addItem && {_findItem > -1}) exitWith {
_attributeItems deleteAt _findItem;
if (!_addItem && {_itemIndex != -1}) exitWith {
_attributeItems deleteAt _itemIndex;
// Change symbol and reduce alpha
_listbox lnbSetText [[_currentRow, 2], SYMBOL_ITEM_NONE];
_listbox lnbSetColor [[_currentRow, 1], [1, 1, 1, 0.5]];

View File

@ -0,0 +1,52 @@
#include "script_component.hpp"
/*
* Author: Karel Moricky, johnb43
* Returns base weapon (weapon without any attachments), but it returns it in config sensitive case.
* Same as BIS_fnc_baseWeapon, except config case and uses cache.
*
* Arguments:
* 0: Weapon <STRING>
*
* Return Value:
* Base weapon <STRING>
*
* Example:
* ["arifle_AK12_GL_lush_arco_pointer_F"] call ace_arsenal_fnc_baseWeapon
*
* Public: Yes
*/
params [["_weapon", "", [""]]];
// Check if item is cached
(uiNamespace getVariable QGVAR(baseWeaponNameCache)) getOrDefaultCall [toLower _weapon, {
private _cfgWeapons = configfile >> "CfgWeapons";
private _config = _cfgWeapons >> _weapon;
// If class doesn't exist, exit
if (!isClass _config) then {
_weapon
} else {
// Get manual base weapon
private _configBase = _cfgWeapons >> getText (_config >> "baseWeapon");
if (isClass _configBase) then {
configName _configBase
} else {
private _className = _weapon;
// Get first parent without any attachments; Only take weapons available to the arsenal
// https://community.bistudio.com/wiki/Arma_3:_Characters_And_Gear_Encoding_Guide#Character_configuration
// https://github.com/acemod/ACE3/pull/9040#issuecomment-1597748331
while {isClass _config && {getNumber (_config >> "scope") > 0 && {if (isNumber (_config >> "scopeArsenal")) then {getNumber (_config >> "scopeArsenal") == 2} else {true}}} && {getNumber (_config >> QGVAR(hide)) != 1}} do {
if (count (_config >> "LinkedItems") == 0) exitWith {
_className = configName _config;
};
_config = inheritsFrom _config;
};
_className
};
};
}, true]

View File

@ -1,12 +1,12 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Add or remove item(s) when the + or - button is pressed in the right panel.
*
* Arguments:
* 0: Arsenal display <DISPLAY>
* 1: Add or remove <SCALAR> (-1: remove, 1: Add)
* 1: Add (1) or remove (-1) item <NUMBER>
*
* Return Value:
* None
@ -16,77 +16,110 @@
params ["_display", "_addOrRemove"];
private _load = 0;
private _maxLoad = "";
private _items = [];
private _ctrlList = (_display displayCtrl IDC_rightTabContentListnBox);
private _add = _addOrRemove > 0;
private _ctrlList = _display displayCtrl IDC_rightTabContentListnBox;
private _lnbCurSel = lnbCurSelRow _ctrlList;
private _isUnique = (_ctrlList lnbValue [_lnbCurSel, 2]) == 1;
// If item is unique, don't allow adding more
if (_add && {_isUnique}) exitWith {};
private _containerItems = [];
private _item = _ctrlList lnbData [_lnbCurSel, 0];
if ((_ctrlList lnbValue [_lnbCurSel, 2]) == 1 && {_addOrRemove == 1}) exitWith {};
// Update item count and currentItems array
switch GVAR(currentLeftPanel) do {
case IDC_buttonUniform : {
if (_addOrRemove > 0) then {
for "_count" from 1 to ([1, 5] select (GVAR(shiftState))) do {
GVAR(center) addItemToUniform _item;
};
// Update item count and currentItems array & get relevant container
private _container = switch (GVAR(currentLeftPanel)) do {
// Uniform
case IDC_buttonUniform: {
if (_add) then {
for "_i" from 1 to ([1, 5] select GVAR(shiftState)) do {
GVAR(center) addItemToUniform _item;
};
} else {
// Backpacks need special command to be removed
if (_isUnique && {_item in ((uiNamespace getVariable QGVAR(configItems)) get IDX_VIRT_BACKPACK)}) then {
[uniformContainer GVAR(center), _item, [1, 5] select GVAR(shiftState)] call CBA_fnc_removeBackpackCargo;
} else {
for "_count" from 1 to ([1, 5] select (GVAR(shiftState))) do {
for "_i" from 1 to ([1, 5] select GVAR(shiftState)) do {
GVAR(center) removeItemFromUniform _item;
};
};
};
_load = loadUniform GVAR(center);
_maxLoad = gettext (configfile >> "CfgWeapons" >> uniform GVAR(center) >> "ItemInfo" >> "containerClass");
_items = uniformItems GVAR(center);
GVAR(currentItems) set [15 ,_items];
/// Get all items from container (excluding container itself)
_containerItems = [GVAR(center), 0, 3, 0, 0, false] call EFUNC(common,uniqueUnitItems);
// Update currentItems
GVAR(currentItems) set [IDX_CURR_UNIFORM_ITEMS, ((getUnitLoadout GVAR(center)) select IDX_LOADOUT_UNIFORM) param [1, []]];
// Update load bar
(_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadUniform GVAR(center));
uniformContainer GVAR(center)
};
case IDC_buttonVest : {
if (_addOrRemove > 0) then {
for "_count" from 1 to ([1, 5] select (GVAR(shiftState))) do {
GVAR(center) addItemToVest _item;
};
// Vest
case IDC_buttonVest: {
if (_add) then {
for "_i" from 1 to ([1, 5] select GVAR(shiftState)) do {
GVAR(center) addItemToVest _item;
};
} else {
// Backpacks need special command to be removed
if (_isUnique && {_item in ((uiNamespace getVariable QGVAR(configItems)) get IDX_VIRT_BACKPACK)}) then {
[vestContainer GVAR(center), _item, [1, 5] select GVAR(shiftState)] call CBA_fnc_removeBackpackCargo;
} else {
for "_count" from 1 to ([1, 5] select (GVAR(shiftState))) do {
for "_i" from 1 to ([1, 5] select GVAR(shiftState)) do {
GVAR(center) removeItemFromVest _item;
};
};
};
_load = loadVest GVAR(center);
_maxLoad = gettext (configfile >> "CfgWeapons" >> vest GVAR(center) >> "ItemInfo" >> "containerClass");
_items = vestItems GVAR(center);
GVAR(currentItems) set [16,_items];
// Get all items from container (excluding container itself)
_containerItems = [GVAR(center), 0, 0, 3, 0, false] call EFUNC(common,uniqueUnitItems);
// Update currentItems
GVAR(currentItems) set [IDX_CURR_VEST_ITEMS, ((getUnitLoadout GVAR(center)) select IDX_LOADOUT_VEST) param [1, []]];
// Update load bar
(_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadVest GVAR(center));
vestContainer GVAR(center)
};
case IDC_buttonBackpack : {
if (_addOrRemove > 0) then {
for "_count" from 1 to ([1, 5] select (GVAR(shiftState))) do {
GVAR(center) addItemToBackpack _item;
};
// Backpack
case IDC_buttonBackpack: {
if (_add) then {
for "_i" from 1 to ([1, 5] select GVAR(shiftState)) do {
GVAR(center) addItemToBackpack _item;
};
} else {
// Backpacks need special command to be removed
if (_isUnique && {_item in ((uiNamespace getVariable QGVAR(configItems)) get IDX_VIRT_BACKPACK)}) then {
[backpackContainer GVAR(center), _item, [1, 5] select GVAR(shiftState)] call CBA_fnc_removeBackpackCargo;
} else {
for "_count" from 1 to ([1, 5] select (GVAR(shiftState))) do {
for "_i" from 1 to ([1, 5] select GVAR(shiftState)) do {
GVAR(center) removeItemFromBackpack _item;
};
};
};
_load = loadBackpack GVAR(center);
_maxLoad = backpack GVAR(center);
_items = backpackItems GVAR(center);
GVAR(currentItems) set [17,_items];
// Get all items from container (excluding container itself)
_containerItems = [GVAR(center), 0, 0, 0, 3, false] call EFUNC(common,uniqueUnitItems);
// Update currentItems
GVAR(currentItems) set [IDX_CURR_BACKPACK_ITEMS, ((getUnitLoadout GVAR(center)) select IDX_LOADOUT_BACKPACK) param [1, []]];
// Update load bar
(_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadBackpack GVAR(center));
backpackContainer GVAR(center)
};
};
// Update progress bar status, weight info
private _loadIndicatorBarCtrl = _display displayCtrl IDC_loadIndicatorBar;
_loadIndicatorBarCtrl progressSetPosition _load;
private _value = {_x == _item} count _items;
_ctrlList lnbSetText [[_lnbCurSel, 2],str _value];
// Find out how many items of that type there are and update the number displayed
_ctrlList lnbSetText [[_lnbCurSel, 2], str (_containerItems getOrDefault [_item, 0])];
[QGVAR(cargoChanged), [_display, _item, _addOrRemove, GVAR(shiftState)]] call CBA_fnc_localEvent;
[_ctrlList, _maxLoad] call FUNC(updateRightPanel);
// Refresh availibility of items based on space remaining in container
[_ctrlList, _container, _containerItems isNotEqualTo []] call FUNC(updateRightPanel);

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Clear the current container.
*
* Arguments:
@ -15,48 +15,56 @@
params ["_display"];
// Clear container
switch (GVAR(currentLeftPanel)) do {
// Clear chosen container, reset currentItems for that container and get relevant container
private _container = switch (GVAR(currentLeftPanel)) do {
// Uniform
case IDC_buttonUniform: {
{GVAR(center) removeItemFromUniform _x} foreach (uniformItems GVAR(center));
GVAR(currentItems) set [15, []];
private _container = uniformContainer GVAR(center);
// Remove everything (backpacks need special command for this)
clearWeaponCargoGlobal _container;
clearMagazineCargoGlobal _container;
clearItemCargoGlobal _container;
clearBackpackCargoGlobal _container;
GVAR(currentItems) set [IDX_CURR_UNIFORM_ITEMS, []];
_container
};
// Vest
case IDC_buttonVest: {
{GVAR(center) removeItemFromVest _x} foreach (vestItems GVAR(center));
GVAR(currentItems) set [16, []];
private _container = vestContainer GVAR(center);
// Remove everything (backpacks need special command for this)
clearWeaponCargoGlobal _container;
clearMagazineCargoGlobal _container;
clearItemCargoGlobal _container;
clearBackpackCargoGlobal _container;
GVAR(currentItems) set [IDX_CURR_VEST_ITEMS, []];
_container
};
// Backpack
case IDC_buttonBackpack: {
{GVAR(center) removeItemFromBackpack _x} foreach (backpackItems GVAR(center));
GVAR(currentItems) set [17, []];
// Remove everything
clearAllItemsFromBackpack GVAR(center);
GVAR(currentItems) set [IDX_CURR_BACKPACK_ITEMS, []];
backpackContainer GVAR(center)
};
};
// Clear number of owned items
private _ctrlList = _display displayCtrl IDC_rightTabContentListnBox;
for "_l" from 0 to (lbSize _ctrlList - 1) do {
_ctrlList lnbSetText [[_l, 2], str 0];
for "_lbIndex" from 0 to (lbSize _ctrlList) - 1 do {
_ctrlList lnbSetText [[_lbIndex, 2], "0"];
};
private _removeAllCtrl = _display displayCtrl IDC_buttonRemoveAll;
_removeAllCtrl ctrlSetFade 1;
_removeAllCtrl ctrlCommit FADE_DELAY;
// Update load bar
private _loadIndicatorBarCtrl = _display displayCtrl IDC_loadIndicatorBar;
_loadIndicatorBarCtrl progressSetPosition 0;
(_display displayCtrl IDC_loadIndicatorBar) progressSetPosition 0;
private _maxLoad = switch (GVAR(currentLeftPanel)) do {
case IDC_buttonUniform: {
gettext (configfile >> "CfgWeapons" >> uniform GVAR(center) >> "ItemInfo" >> "containerClass")
};
case IDC_buttonVest: {
gettext (configfile >> "CfgWeapons" >> vest GVAR(center) >> "ItemInfo" >> "containerClass")
};
case IDC_buttonBackpack: {
backpack GVAR(center)
};
};
private _control = _display displayCtrl IDC_rightTabContentListnBox;
[_control, _maxLoad] call FUNC(updateRightPanel);
// Refresh availibility of items based on space remaining in container
[_ctrlList, _container, false] call FUNC(updateRightPanel);

View File

@ -15,39 +15,41 @@
params ["_display"];
if (GVAR(shiftState)) then {
if (isNil QGVAR(defaultLoadoutsList) || {GVAR(defaultLoadoutsList) isEqualTo []}) exitWith {
[_display, localize LSTRING(exportDefaultError)] call FUNC(message);
[_display, LLSTRING(exportDefaultError)] call FUNC(message);
};
// Export default loadout list
private _listLength = count GVAR(defaultLoadoutsList);
for "_index" from -1 to _listLength do {
switch true do {
for "_index" from -1 to _listLength do {
switch (true) do {
// Beginning
case (_index == -1): {
"ace_clipboard" callExtension (format ["[%1", endl]);
};
// End
case (_index == _listLength): {
"ace_clipboard" callExtension "];";
};
// Rest
default {
"ace_clipboard" callExtension ([" ",str (GVAR(defaultLoadoutsList) select _index), [",", ""] select (_index == _listLength - 1), endl] joinString "");
"ace_clipboard" callExtension ([" ", str (GVAR(defaultLoadoutsList) select _index), [",", ""] select (_index == _listLength - 1), endl] joinString "");
};
};
};
"ace_clipboard" callExtension "--COMPLETE--";
[_display, localize LSTRING(exportDefault)] call FUNC(message);
[_display, LLSTRING(exportDefault)] call FUNC(message);
} else {
// Export singular loadout
private _export = str (GVAR(center) call CBA_fnc_getLoadout);
private _export = str ([GVAR(center)] call FUNC(getLoadout));
"ace_clipboard" callExtension (_export + ";");
"ace_clipboard" callExtension "--COMPLETE--";
[_display, localize LSTRING(exportCurrent)] call FUNC(message);
[_display, LLSTRING(exportCurrent)] call FUNC(message);
};
[QGVAR(loadoutExported), [_display, GVAR(shiftState)]] call CBA_fnc_localEvent;

View File

@ -16,12 +16,13 @@
params ["_display"];
private _showToggle = !ctrlShown (_display displayCtrl IDC_menuBar);
private _ctrl = controlNull;
{
private _ctrl = _display displayctrl _x;
_ctrl ctrlshow _showToggle;
_ctrl ctrlcommit 0.15;
} foreach [
_ctrl = _display displayCtrl _x;
_ctrl ctrlShow _showToggle;
_ctrl ctrlCommit FADE_DELAY;
} forEach [
IDC_blockLeftFrame,
IDC_blockLeftBackground,
IDC_blockRightFrame,
@ -35,6 +36,8 @@ private _showToggle = !ctrlShown (_display displayCtrl IDC_menuBar);
IDC_rightTabContentListnBox,
IDC_sortLeftTab,
IDC_sortRightTab,
IDC_sortLeftTabDirection,
IDC_sortRightTabDirection,
IDC_leftSearchbarButton,
IDC_rightSearchbarButton,
IDC_leftSearchbar,

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Import loadout / default loadouts list from clipboard.
*
* Arguments:
@ -15,102 +15,72 @@
params ["_display"];
private _data = call (compile copyFromClipboard);
// Can be either a singular loadout or an array of loadouts
private _extendedLoadout = call compile copyFromClipboard;
if (isNil "_data" || {!(_data isEqualType [])}) exitWith {
[_display, localize LSTRING(importFormatError)] call FUNC(message);
// If error, exit
if (isNil "_extendedLoadout" || {!(_extendedLoadout isEqualType [])}) exitWith {
[_display, LLSTRING(importFormatError)] call FUNC(message);
};
if (GVAR(shiftState) && {is3DEN}) then {
// Supports CBA extended loadout or getUnitLoadout arrays
{
if (
count _x == 2 &&
{_x select 0 isEqualType ""} &&
{_x select 0 != ""} &&
{_x select 1 isEqualType []} &&
{count (_x select 1) == 10}
count _x == 2 &&
{(_x select 0) isEqualType ""} &&
{(_x select 0) != ""} &&
{(_x select 1) isEqualType []} &&
{count (_x select 1) in [2, 10]}
) then {
_x call FUNC(addDefaultLoadout);
};
} foreach _data;
} forEach _extendedLoadout;
[_display, LLSTRING(importedDefault)] call FUNC(message);
[_display, localize LSTRING(importedDefault)] call FUNC(message);
set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]];
} else {
private _count = count _data;
if (_count == 10 || { _count == 2 }) then {
[GVAR(center), _data] call CBA_fnc_setLoadout;
// If _extendedLoadout is in getUnitLoadout array, change into CBA extended loadout array
if (count _extendedLoadout == 10) then {
_extendedLoadout = [_extendedLoadout, createHashMap];
};
GVAR(currentItems) = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", [], [], [], [], [], []];
for "_index" from 0 to 15 do {
switch (_index) do {
case 0;
case 1;
case 2:{
GVAR(currentItems) set [_index, ((LIST_DEFAULTS select 0) select _index)];
};
case 3;
case 4;
case 5;
case 6;
case 7;
case 8;
case 9: {
GVAR(currentItems) set [_index, (LIST_DEFAULTS select _index) select 0];
// Check if CBA extended loadout array
if ((count _extendedLoadout) == 2) then {
[GVAR(center), _extendedLoadout] call CBA_fnc_setLoadout;
};
case 10: {
{(GVAR(currentItems) select 15) pushBack _x} forEach (uniformItems GVAR(center));
};
case 11: {
{(GVAR(currentItems) select 16) pushBack _x} forEach (vestItems GVAR(center));
};
case 12: {
{(GVAR(currentItems) select 17) pushBack _x} forEach (backpackItems GVAR(center));
};
case 13: {
GVAR(currentItems) set [18, (primaryWeaponItems GVAR(center)) + (primaryWeaponMagazine GVAR(center))];
};
case 14: {
GVAR(currentItems) set [19, (secondaryWeaponItems GVAR(center)) + (secondaryWeaponMagazine GVAR(center))];
};
case 15: {
GVAR(currentItems) set [20, (handgunItems GVAR(center)) + (handgunMagazine GVAR(center))];
};
};
};
{
private _simulationType = getText (configFile >> "CfgWeapons" >> _x >> "simulation");
private _index = 10 + (["itemmap", "itemcompass", "itemradio", "itemwatch", "itemgps"] find (tolower _simulationType));
GVAR(currentItems) set [_index, _x];
} foreach (assignedItems GVAR(center));
// Update current item list
call FUNC(updateCurrentItemsList);
// This takes care of items that aren't available in the arsenal (either wrong tab or arsenal doesn't have it whitelisted)
call FUNC(updateUniqueItemsList);
_extendedLoadout params ["_loadout", "_extendedInfo"];
// Reapply insignia
if (QGVAR(insignia) in _loadout#1) then {
GVAR(currentInsignia) = _loadout#1 getOrDefault [QGVAR(insignia), ""];
if (QGVAR(insignia) in _extendedInfo) then {
GVAR(currentInsignia) = _extendedInfo getOrDefault [QGVAR(insignia), ""];
} else {
[GVAR(center), ""] call bis_fnc_setUnitInsignia;
[GVAR(center), GVAR(currentInsignia)] call bis_fnc_setUnitInsignia;
[GVAR(center), ""] call BIS_fnc_setUnitInsignia;
[GVAR(center), GVAR(currentInsignia)] call BIS_fnc_setUnitInsignia;
};
if (QGVAR(face) in _loadout#1) then {
GVAR(currentFace) = _loadout#1 getOrDefault [QGVAR(face), GVAR(currentFace)];
};
if (QGVAR(voice) in _loadout#1) then {
GVAR(currentVoice) = _loadout#1 getOrDefault [QGVAR(voice), GVAR(currentVoice)];
// Save face
if (QGVAR(face) in _extendedInfo) then {
GVAR(currentFace) = _extendedInfo getOrDefault [QGVAR(face), GVAR(currentFace)];
};
// Save voice
if (QGVAR(voice) in _extendedInfo) then {
GVAR(currentVoice) = _extendedInfo getOrDefault [QGVAR(voice), GVAR(currentVoice)];
};
// Fill left panel
[_display, _display displayCtrl GVAR(currentLeftPanel)] call FUNC(fillLeftPanel);
[_display, localize LSTRING(importedCurrent)] call FUNC(message);
[_display, LLSTRING(importedCurrent)] call FUNC(message);
};
};
[QGVAR(loadoutImported), [_display, (GVAR(shiftState) && {is3DEN})]] call CBA_fnc_localEvent;
[QGVAR(loadoutImported), [_display, GVAR(shiftState) && {is3DEN}]] call CBA_fnc_localEvent;

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Delete / unshare loadout currently selected.
*
* Arguments:
@ -22,35 +22,39 @@ private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;
private _contentPanelCursSel = lnbCurSelRow _contentPanelCtrl;
private _loadoutName = _contentPanelCtrl lnbText [_contentPanelCursSel, 1];
// If loadout is local or default
if (GVAR(currentLoadoutsTab) != IDC_buttonSharedLoadouts) then {
// Find loadout and delete from list
if (is3DEN && {GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts}) then {
GVAR(defaultLoadoutsList) deleteAt (GVAR(defaultLoadoutsList) find ((GVAR(defaultLoadoutsList) select {_x select 0 == _loadoutName}) select 0));
set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]];
GVAR(defaultLoadoutsList) deleteAt (GVAR(defaultLoadoutsList) findIf {(_x select 0) == _loadoutName});
set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]];
} else {
private _data = profileNamespace getVariable [QGVAR(saved_loadouts), []];
_data deleteAt (_data find ((_data select {_x select 0 == _loadoutName}) select 0));
private _data = profileNamespace getVariable [QGVAR(saved_loadouts), []];
_data deleteAt (_data findIf {(_x select 0) == _loadoutName});
};
_contentPanelCtrl setVariable [_loadoutName + str GVAR(currentLoadoutsTab), nil];
_contentPanelCtrl lnbDeleteRow _contentPanelCursSel;
_contentPanelCtrl lnbSetCurSelRow (_contentPanelCursSel);
_contentPanelCtrl lnbSetCurSelRow _contentPanelCursSel;
[findDisplay IDD_ace_arsenal, [LLSTRING(loadoutDeleted), _loadoutName] joinString " "] call FUNC(message);
[(findDisplay IDD_ace_arsenal), [localize LSTRING(loadoutDeleted), _loadoutName] joinString " "] call FUNC(message);
[QGVAR(onLoadoutDelete), [_loadoutName]] call CBA_fnc_localEvent;
} else {
// If loadout is shared
private _profileName = profileName; // GVAR(center) could be a remote unit
private _loadoutVar = _profileName + _loadoutName;
private _sharedLoadoutsVars = GVAR(sharedLoadoutsNamespace) getVariable QGVAR(sharedLoadoutsVars);
private _sharedLoadoutsVars = GVAR(sharedLoadoutsNamespace) getVariable [QGVAR(sharedLoadoutsVars), []];
GVAR(sharedLoadoutsNamespace) setVariable [_loadoutVar, nil, true];
GVAR(sharedLoadoutsNamespace) setVariable [QGVAR(sharedLoadoutsVars), _sharedLoadoutsVars - [_loadoutVar], true];
_contentPanelCtrl lnbDeleteRow _contentPanelCursSel;
_contentPanelCtrl lnbSetCurSelRow (_contentPanelCursSel);
_contentPanelCtrl lnbSetCurSelRow _contentPanelCursSel;
[QGVAR(loadoutUnshared), [_contentPanelCtrl, profileName, _loadoutName]] call CBA_fnc_remoteEvent;
[findDisplay IDD_ace_arsenal, [LLSTRING(loadoutUnshared), _loadoutName] joinString " "] call FUNC(message);
[(findDisplay IDD_ace_arsenal), [localize LSTRING(loadoutUnshared), _loadoutName] joinString " "] call FUNC(message);
[QGVAR(loadoutUnshared), [_contentPanelCtrl, _profileName, _loadoutName]] call CBA_fnc_remoteEvent;
};

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Load selected loadout.
*
* Arguments:
@ -22,90 +22,48 @@ private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;
private _curSel = lnbCurSelRow _contentPanelCtrl;
private _loadoutName = _contentPanelCtrl lnbText [_curSel, 1];
private _loadout = switch GVAR(currentLoadoutsTab) do {
private _extendedLoadout = switch (GVAR(currentLoadoutsTab)) do {
// Local and default loadouts
case IDC_buttonMyLoadouts;
case IDC_buttonDefaultLoadouts:{
case IDC_buttonDefaultLoadouts: {
(_contentPanelCtrl getVariable _loadoutName + str GVAR(currentLoadoutsTab)) select 0
};
case IDC_buttonSharedLoadouts:{
// Shared loadouts
case IDC_buttonSharedLoadouts: {
(GVAR(sharedLoadoutsNamespace) getVariable ((_contentPanelCtrl lnbText [_curSel, 0]) + (_contentPanelCtrl lnbText [_curSel, 1]))) select 2
};
};
[GVAR(center), _loadout, true] call CBA_fnc_setLoadout;
// Apply loadout to unit
[GVAR(center), _extendedLoadout, true] call CBA_fnc_setLoadout;
GVAR(currentItems) = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", [], [], [], [], [], []];
for "_index" from 0 to 15 do {
switch (_index) do {
case 0;
case 1;
case 2:{
GVAR(currentItems) set [_index, ((LIST_DEFAULTS select 0) select _index)];
};
case 3;
case 4;
case 5;
case 6;
case 7;
case 8;
case 9: {
GVAR(currentItems) set [_index, (LIST_DEFAULTS select _index) select 0];
};
case 10: {
{(GVAR(currentItems) select 15) pushBack _x} forEach (uniformItems GVAR(center));
};
case 11: {
{(GVAR(currentItems) select 16) pushBack _x} forEach (vestItems GVAR(center));
};
case 12: {
{(GVAR(currentItems) select 17) pushBack _x} forEach (backpackItems GVAR(center));
};
case 13: {
GVAR(currentItems) set [18, (primaryWeaponItems GVAR(center)) + (primaryWeaponMagazine GVAR(center))];
};
case 14: {
GVAR(currentItems) set [19, (secondaryWeaponItems GVAR(center)) + (secondaryWeaponMagazine GVAR(center))];
};
case 15: {
GVAR(currentItems) set [20, (handgunItems GVAR(center)) + (handgunMagazine GVAR(center))];
};
};
};
{
private _simulationType = getText (configFile >> "CfgWeapons" >> _x >> "simulation");
if (_simulationType != "NVGoggles") then {
if (_simulationType == "ItemGps" || _simulationType == "Weapon") then {
GVAR(currentItems) set [14, _x];
} else {
private _index = 10 + (["itemmap", "itemcompass", "itemradio", "itemwatch"] find (tolower _simulationType));
GVAR(currentItems) set [_index, _x];
};
};
} forEach (assignedItems GVAR(center));
// Update current item list
call FUNC(updateCurrentItemsList);
// This takes care of items that aren't available in the arsenal (either wrong tab or arsenal doesn't have it whitelisted)
call FUNC(updateUniqueItemsList);
_extendedLoadout params ["_loadout", "_extendedInfo"];
// Reapply insignia
if (QGVAR(insignia) in _loadout#1) then {
GVAR(currentInsignia) = _loadout#1 getOrDefault [QGVAR(insignia), ""];
if (QGVAR(insignia) in _extendedInfo) then {
GVAR(currentInsignia) = _extendedInfo getOrDefault [QGVAR(insignia), ""];
} else {
[GVAR(center), ""] call bis_fnc_setUnitInsignia;
[GVAR(center), GVAR(currentInsignia)] call bis_fnc_setUnitInsignia;
[GVAR(center), ""] call BIS_fnc_setUnitInsignia;
[GVAR(center), GVAR(currentInsignia)] call BIS_fnc_setUnitInsignia;
};
if (QGVAR(face) in _loadout#1) then {
GVAR(currentFace) = _loadout#1 getOrDefault [QGVAR(face), GVAR(currentFace)];
};
if (QGVAR(voice) in _loadout#1) then {
GVAR(currentVoice) = _loadout#1 getOrDefault [QGVAR(voice), GVAR(currentVoice)];
// Update current face if necessary
if (QGVAR(face) in _extendedInfo) then {
GVAR(currentFace) = _extendedInfo getOrDefault [QGVAR(face), GVAR(currentFace)];
};
[(findDisplay IDD_ace_arsenal), [localize LSTRING(loadoutLoaded), _loadoutName] joinString " "] call FUNC(message);
// Update voice face if necessary
if (QGVAR(voice) in _extendedInfo) then {
GVAR(currentVoice) = _extendedInfo getOrDefault [QGVAR(voice), GVAR(currentVoice)];
};
[QGVAR(onLoadoutLoad), [_loadout#0, _loadoutName]] call CBA_fnc_localEvent;
[QGVAR(onLoadoutLoadExtended), [_loadout, _loadoutName]] call CBA_fnc_localEvent;
[findDisplay IDD_ace_arsenal, [LLSTRING(loadoutLoaded), _loadoutName] joinString " "] call FUNC(message);
[QGVAR(onLoadoutLoad), [_loadout, _loadoutName]] call CBA_fnc_localEvent;
[QGVAR(onLoadoutLoadExtended), [_extendedLoadout, _loadoutName]] call CBA_fnc_localEvent;

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Rename selected loadout.
*
* Arguments:
@ -23,49 +23,45 @@ private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;
private _curSelRow = lnbCurSelRow _contentPanelCtrl;
private _loadoutName = _contentPanelCtrl lnbText [_curSelRow, 1];
private _editBoxCtrl = _display displayCtrl IDC_textEditBox;
private _editBoxContent = ctrlText _editBoxCtrl;
// Get text from text edit box
private _editBoxContent = ctrlText (_display displayCtrl IDC_textEditBox);
private _data = [profileNamespace getVariable [QGVAR(saved_loadouts), []], GVAR(defaultLoadoutsList)] select (GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts && {is3DEN});
private _similarLoadouts = _data select {_x select 0 == _editBoxContent};
// If it's the exact same name, don't do anything
if (_editBoxContent isEqualTo _loadoutName) exitWith {};
if (count _similarLoadouts > 0) exitWith {
[(findDisplay IDD_ace_arsenal), localize LSTRING(renameExistError)] call FUNC(message);
private _data = [profileNamespace getVariable [QGVAR(saved_loadouts), []], GVAR(defaultLoadoutsList)] select (is3DEN && {GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts});
// If there is a loadout with a similar name and it's not chosen to be renamed, don't rename and exit
if (_editBoxContent != _loadoutName && {_data findIf {(_x select 0) == _editBoxContent} != -1}) exitWith {
[findDisplay IDD_ace_arsenal, LLSTRING(renameExistError)] call FUNC(message);
};
// Update loadout info in profile / 3DEN and list namespaces
private _loadoutToRename = (_data select {_x select 0 == _loadoutName}) select 0;
(_contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab))) params ["_extendedLoadout", "_nullItemsAmount", "_unavailableItemsAmount", "_nullItemsList", "_unavailableItemsList"];
private _loadoutIndex = _data findIf {(_x select 0) == _loadoutName};
_data set [_data find _loadoutToRename, [_editBoxContent, (_loadoutToRename select 1)]];
_contentPanelCtrl setVariable [_loadoutName + str GVAR(currentLoadoutsTab), nil];
_contentPanelCtrl setVariable [_editBoxContent + str GVAR(currentLoadoutsTab), [_extendedLoadout, _nullItemsAmount, _unavailableItemsAmount, _nullItemsList, _unavailableItemsList]];
// Add new row
_contentPanelCtrl lnbDeleteRow _curSelRow;
private _newRow = _contentPanelCtrl lnbAddRow ["",_editBoxContent];
_extendedLoadout params ["_loadout"];
ADD_LOADOUTS_LIST_PICTURES
if (_nullItemsAmount > 0) then {
_contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 0, 0, 0.8]];
} else {
if (_unavailableItemsAmount > 0) then {
_contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 1, 1, 0.25]];
};
};
// Sort and select the current row
_contentPanelCtrl lnbSort [1, false];
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
if ((_contentPanelCtrl lnbText [_i, 1]) == _editBoxContent) exitwith {_contentPanelCtrl lnbSetCurSelRow _i};
};
// Set new name
(_data select _loadoutIndex) set [0, _editBoxContent];
if (is3DEN && {GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts}) then {
set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]];
};
[(findDisplay IDD_ace_arsenal), [_loadoutName, localize LSTRING(loadoutRenamed) ,_editBoxContent] joinString " "] call FUNC(message);
private _currentLoadoutsTab = str GVAR(currentLoadoutsTab);
_contentPanelCtrl setVariable [_editBoxContent + _currentLoadoutsTab, _contentPanelCtrl getVariable [_loadoutName + _currentLoadoutsTab, []]];
_contentPanelCtrl setVariable [_loadoutName + _currentLoadoutsTab, nil];
// Update the current row's loadout name
_contentPanelCtrl lnbSetText [[_curSelRow, 1], _editBoxContent];
// Sort loadouts alphabetically
_contentPanelCtrl lnbSort [1, false];
// Select the newly renamed loadout
for "_lbIndex" from 0 to (lnbSize _contentPanelCtrl select 0) - 1 do {
if ((_contentPanelCtrl lnbText [_lbIndex, 1]) == _editBoxContent) exitWith {
_contentPanelCtrl lnbSetCurSelRow _lbIndex;
};
};
[findDisplay IDD_ace_arsenal, [_loadoutName, LLSTRING(loadoutRenamed), _editBoxContent] joinString " "] call FUNC(message);

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Save selected loadout.
*
* Arguments:
@ -21,280 +21,167 @@ if !(ctrlEnabled _control) exitWith {};
private _editBoxCtrl = _display displayCtrl IDC_textEditBox;
private _editBoxContent = ctrlText _editBoxCtrl;
// If no name given, throw error
if (_editBoxContent == "") exitWith {
[(findDisplay IDD_ace_arsenal), localize LSTRING(saveEmptyNameBox)] call FUNC(message);
[findDisplay IDD_ace_arsenal, LLSTRING(saveEmptyNameBox)] call FUNC(message);
};
private _data = [+(profileNamespace getVariable [QGVAR(saved_loadouts),[]]), +(GVAR(defaultLoadoutsList))] select (GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts && {is3DEN});
private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;
private _cursSelRow = lnbCurSelRow _contentPanelCtrl;
private _loadoutName = _contentPanelCtrl lnbText [_cursSelRow, 1];
private _curSelLoadout = (_contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab))) select 0;
private _extendedLoadout = GVAR(center) call FUNC(getLoadout);
private _loadout = _extendedLoadout select 0;
private _loadoutIndex = _data findIf {(_x select 0) == _editBoxContent};
private _sharedLoadoutsVars = GVAR(sharedLoadoutsNamespace) getVariable QGVAR(sharedLoadoutsVars);
// Get shared loadouts
private _sharedLoadoutsVars = GVAR(sharedLoadoutsNamespace) getVariable [QGVAR(sharedLoadoutsVars), []];
// Make sure the loadout isn't yours (public tab) or being shared (my loadouts tab)
private _similarSharedLoadout = (profileName + _editBoxContent) in _sharedLoadoutsVars;
if ((_contentPanelCtrl lnbText [_cursSelRow, 0]) == profileName) exitWith {
[(findDisplay IDD_ace_arsenal), localize LSTRING(saveAuthorError)] call FUNC(message);
if ((profileName + _editBoxContent) in _sharedLoadoutsVars) exitWith {
[findDisplay IDD_ace_arsenal, LLSTRING(saveSharedError)] call FUNC(message);
};
if (_similarSharedLoadout) exitWith {
[(findDisplay IDD_ace_arsenal), localize LSTRING(saveSharedError)] call FUNC(message);
private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;
private _curSelRow = lnbCurSelRow _contentPanelCtrl;
if ((_contentPanelCtrl lnbText [_curSelRow, 0]) == profileName) exitWith {
[findDisplay IDD_ace_arsenal, LLSTRING(saveAuthorError)] call FUNC(message);
};
switch (GVAR(currentLoadoutsTab)) do {
case IDC_buttonMyLoadouts:{
// Get currently selected loadout name & loadout
private _loadoutName = _contentPanelCtrl lnbText [_curSelRow, 1];
private _curSelLoadout = (_contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab))) select 0;
for "_dataIndex" from 0 to 10 do {
switch (_dataIndex) do {
// Get unit's current loadout
private _extendedLoadout = GVAR(center) call CBA_fnc_getLoadout;
_extendedLoadout params ["_loadout"];
case 0;
case 1;
case 2;
case 8: {
if (count (_loadout select _dataIndex) > 0) then {
private _loadouts = [profileNamespace getVariable [QGVAR(saved_loadouts), []], GVAR(defaultLoadoutsList)] select (is3DEN && {GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts});
private _loadoutIndex = _loadouts findIf {(_x select 0) == _editBoxContent};
private _weapon = (_loadout select _dataIndex) select 0;
if (_weapon != "") then {
private _baseWeapon = _weapon call BIS_fnc_baseWeapon;
if (_weapon != _baseWeapon) then {
(_loadout select _dataIndex) set [0, _baseWeapon];
};
};
};
};
case 3;
case 4;
case 5: {
if (count (_loadout select _dataIndex) > 0) then {
private _containerContents = (_loadout select _dataIndex) select 1;
if (count _containerContents > 0) then {
{
if (count _x == 2) then {
if ((_x select 0) isEqualType "") then {
private _item = (_x select 0);
if (_item != "") then {
private _uniqueBaseCfgText = getText (configFile >> "CfgWeapons" >> _item >> "ace_arsenal_uniqueBase");
if (_uniqueBaseCfgText != "") then {
_x set [0, _uniqueBaseCfgText];
};
};
} else {
private _weapon = (_x select 0) select 0;
if (_weapon != "") then {
private _baseWeapon = _weapon call BIS_fnc_baseWeapon;
if (_weapon != _baseWeapon) then {
(_x select 0)set [0, _baseWeapon];
};
};
};
};
} foreach _containerContents;
};
};
};
case 9: {
for "_subIndex" from 0 to 4 do {
private _item = (_loadout select _dataIndex) select _subIndex;
if (_item != "") then {
private _uniqueBaseCfgText = getText (configFile >> "CfgWeapons" >> _item >> "ace_arsenal_uniqueBase");
if (_uniqueBaseCfgText != "") then {
(_loadout select _dataIndex) set [_subIndex, _uniqueBaseCfgText];
};
};
};
};
};
};
if (GVAR(shiftState) && {is3DEN} && {_loadoutName isNotEqualTo ""} && {_cursSelRow != -1} && {_loadoutIndex isNotEqualTo -1}) exitwith {
// Return what loadout was saved
private _savedLoadout = switch (GVAR(currentLoadoutsTab)) do {
// Local loadouts tab
case IDC_buttonMyLoadouts: {
// If saved to default loadout
if (GVAR(shiftState) && {is3DEN} && {_loadoutName != ""} && {_curSelRow != -1} && {_loadoutIndex != -1}) then {
private _defaultLoadoutsSearch = GVAR(defaultLoadoutsList) findIf {(_x select 0) == _loadoutName};
if (_defaultLoadoutsSearch isEqualto -1) then {
GVAR(defaultLoadoutsList) pushBack [_loadoutName, _curSelLoadout];
if (_defaultLoadoutsSearch == -1) then {
_loadoutIndex = GVAR(defaultLoadoutsList) pushBack [_loadoutName, _curSelLoadout];
} else {
GVAR(defaultLoadoutsList) set [_defaultLoadoutsSearch , [ _loadoutName, _curSelLoadout]];
GVAR(defaultLoadoutsList) set [_defaultLoadoutsSearch, [_loadoutName, _curSelLoadout]];
};
set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]];
};
if (_loadoutIndex isEqualto -1) then {
_data pushBack [_editBoxContent, _extendedLoadout];
_curSelLoadout
} else {
_data set [_loadoutIndex, [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _extendedLoadout]];
};
// Replace unique items with their bases and replace weapons with their base weapons
_loadout = [_loadout] call FUNC(replaceUniqueItemsLoadout);
// Delete "old" loadout row
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
if ((_contentPanelCtrl lnbText [_i, 1]) == _editBoxContent) exitwith {_contentPanelCtrl lnbDeleteRow _i};
};
private _data = profileNamespace getVariable [QGVAR(saved_loadouts), []];
private _newRow = _contentPanelCtrl lnbAddRow ["",_editBoxContent];
// Add or overwrite loadout in loadout storage
if (_loadoutIndex == -1) then {
_loadoutIndex = _data pushBack [_editBoxContent, _extendedLoadout];
} else {
_data set [_loadoutIndex, [_editBoxContent, _extendedLoadout]];
};
ADD_LOADOUTS_LIST_PICTURES
_contentPanelCtrl setVariable [_editBoxContent + str GVAR(currentLoadoutsTab), [_extendedLoadout] call FUNC(verifyLoadout)];
_contentPanelCtrl lnbSort [1, false];
// Select newly saved loadout
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
if ((_contentPanelCtrl lnbText [_i, 1]) == _editBoxContent) exitwith {_contentPanelCtrl lnbSetCurSelRow _i};
};
profileNamespace setVariable [QGVAR(saved_loadouts), _data];
};
case IDC_buttonDefaultLoadouts:{
if (is3DEN) then {
private _loadoutIndex = _data findIf {(_x select 0) == _editBoxContent};
for "_dataIndex" from 0 to 10 do {
switch (_dataIndex) do {
case 0;
case 1;
case 2;
case 8: {
if (count (_loadout select _dataIndex) > 0) then {
private _weapon = (_loadout select _dataIndex) select 0;
if (_weapon != "") then {
private _baseWeapon = _weapon call BIS_fnc_baseWeapon;
if (_weapon != _baseWeapon) then {
(_loadout select _dataIndex) set [0, _baseWeapon];
};
};
};
};
case 3;
case 4;
case 5: {
if (count (_loadout select _dataIndex) > 0) then {
private _containerContents = (_loadout select _dataIndex) select 1;
if (count _containerContents > 0) then {
{
if (count _x == 2) then {
if ((_x select 0) isEqualType "") then {
private _item = (_x select 0);
if (_item != "") then {
private _uniqueBaseCfgText = getText (configFile >> "CfgWeapons" >> _item >> "ace_arsenal_uniqueBase");
if (_uniqueBaseCfgText != "") then {
_x set [0, _uniqueBaseCfgText];
};
};
} else {
private _weapon = (_x select 0) select 0;
if (_weapon != "") then {
private _baseWeapon = _weapon call BIS_fnc_baseWeapon;
if (_weapon != _baseWeapon) then {
(_x select 0)set [0, _baseWeapon];
};
};
};
};
} foreach _containerContents;
};
};
};
case 9: {
for "_subIndex" from 0 to 4 do {
private _item = (_loadout select _dataIndex) select _subIndex;
if (_item != "") then {
private _uniqueBaseCfgText = getText (configFile >> "CfgWeapons" >> _item >> "ace_arsenal_uniqueBase");
if (_uniqueBaseCfgText != "") then {
(_loadout select _dataIndex) set [_subIndex, _uniqueBaseCfgText];
};
};
};
};
// Refresh loadout list; Delete previous loadout row
for "_lbIndex" from 0 to (lnbSize _contentPanelCtrl select 0) - 1 do {
if ((_contentPanelCtrl lnbText [_lbIndex, 1]) == _editBoxContent) exitWith {
_contentPanelCtrl lnbDeleteRow _lbIndex;
};
};
if (_loadoutIndex == -1) then {
GVAR(defaultLoadoutsList) pushBack [_editBoxContent, _extendedLoadout];
} else {
GVAR(defaultLoadoutsList) set [_loadoutIndex, [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _extendedLoadout]];
};
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
if ((_contentPanelCtrl lnbText [_i, 1]) == _editBoxContent) exitwith {_contentPanelCtrl lnbDeleteRow _i};
};
private _newRow = _contentPanelCtrl lnbAddRow ["",_editBoxContent];
private _newRow = _contentPanelCtrl lnbAddRow ["", _editBoxContent];
private _cfgWeapons = configFile >> "CfgWeapons";
ADD_LOADOUTS_LIST_PICTURES
_contentPanelCtrl setVariable [_editBoxContent + str GVAR(currentLoadoutsTab), [_extendedLoadout] call FUNC(verifyLoadout)];
// Sort loadouts alphabetically
_contentPanelCtrl lnbSort [1, false];
// Select newly saved loadout
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
if ((_contentPanelCtrl lnbText [_i, 1]) == _editBoxContent) exitwith {_contentPanelCtrl lnbSetCurSelRow _i};
for "_lbIndex" from 0 to (lnbSize _contentPanelCtrl select 0) - 1 do {
if ((_contentPanelCtrl lnbText [_lbIndex, 1]) == _editBoxContent) exitWith {
_contentPanelCtrl lnbSetCurSelRow _lbIndex;
};
};
_extendedLoadout
};
};
// Default loadouts tab
case IDC_buttonDefaultLoadouts: {
if (is3DEN) then {
// Replace unique items with their bases and replace weapons with their base weapons
_loadout = [_loadout] call FUNC(replaceUniqueItemsLoadout);
// Add or overwrite loadout in loadout storage
if (_loadoutIndex == -1) then {
_loadoutIndex = GVAR(defaultLoadoutsList) pushBack [_editBoxContent, _extendedLoadout];
} else {
GVAR(defaultLoadoutsList) set [_loadoutIndex, [_editBoxContent, _extendedLoadout]];
};
set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]];
} else {
// Refresh loadout list; Delete previous loadout row
for "_lbIndex" from 0 to (lnbSize _contentPanelCtrl select 0) - 1 do {
if ((_contentPanelCtrl lnbText [_lbIndex, 1]) == _editBoxContent) exitWith {
_contentPanelCtrl lnbDeleteRow _lbIndex;
};
};
private _newRow = _contentPanelCtrl lnbAddRow ["", _editBoxContent];
private _cfgWeapons = configFile >> "CfgWeapons";
ADD_LOADOUTS_LIST_PICTURES
_contentPanelCtrl setVariable [_editBoxContent + str GVAR(currentLoadoutsTab), [_extendedLoadout] call FUNC(verifyLoadout)];
// Sort loadouts alphabetically
_contentPanelCtrl lnbSort [1, false];
// Select newly saved loadout
for "_lbIndex" from 0 to (lnbSize _contentPanelCtrl select 0) - 1 do {
if ((_contentPanelCtrl lnbText [_lbIndex, 1]) == _editBoxContent) exitWith {
_contentPanelCtrl lnbSetCurSelRow _lbIndex;
};
};
_extendedLoadout
} else {
private _data = profileNamespace getVariable [QGVAR(saved_loadouts), []];
// Add or overwrite loadout in loadout storage
if (_loadoutIndex == -1) then {
_data pushBack [_editBoxContent, _curSelLoadout];
_loadoutIndex = _data pushBack [_editBoxContent, _curSelLoadout];
} else {
_data set [_loadoutIndex, [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _curSelLoadout]];
_data set [_loadoutIndex, [_editBoxContent, _curSelLoadout]];
_contentPanelCtrl setVariable [_editBoxContent + str IDC_buttonMyLoadouts, [_curSelLoadout] call FUNC(verifyLoadout)];
};
profileNamespace setVariable [QGVAR(saved_loadouts), _data];
_curSelLoadout
};
};
// Shared loadouts tab
case IDC_buttonSharedLoadouts: {
_loadout = (GVAR(sharedLoadoutsNamespace) getVariable ((_contentPanelCtrl lnbText [_curSelRow, 0]) + (_contentPanelCtrl lnbText [_curSelRow, 1]))) select 2;
case IDC_buttonSharedLoadouts :{
_loadout = (GVAR(sharedLoadoutsNamespace) getVariable ((_contentPanelCtrl lnbText [_cursSelRow, 0]) + (_contentPanelCtrl lnbText [_cursSelRow, 1]))) select 2;
private _data = profileNamespace getVariable [QGVAR(saved_loadouts), []];
// Add or overwrite loadout in loadout storage
if (_loadoutIndex == -1) then {
_data pushBack [_editBoxContent, _loadout];
_loadoutIndex = _data pushBack [_editBoxContent, _loadout];
} else {
_data set [_loadoutIndex, [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _loadout]];
_data set [_loadoutIndex, [_editBoxContent, _loadout]];
_contentPanelCtrl setVariable [_editBoxContent + str IDC_buttonMyLoadouts, [_loadout] call FUNC(verifyLoadout)];
};
profileNamespace setVariable [QGVAR(saved_loadouts), _data];
_loadout
};
};
[(findDisplay IDD_ace_arsenal), [localize LSTRING(loadoutSaved), _editBoxContent] joinString " "] call FUNC(message);
private _savedLoadout = (_data select {_x select 0 == _editBoxContent}) select 0;
[QGVAR(onLoadoutSave), [_data find _savedLoadout, _savedLoadout#0]] call CBA_fnc_localEvent;
[QGVAR(onLoadoutSaveExtended), [_data find _savedLoadout, _savedLoadout]] call CBA_fnc_localEvent;
[findDisplay IDD_ace_arsenal, [LLSTRING(loadoutSaved), _editBoxContent] joinString " "] call FUNC(message);
[QGVAR(onLoadoutSave), [_loadoutIndex, _savedLoadout select 0]] call CBA_fnc_localEvent;
[QGVAR(onLoadoutSaveExtended), [_loadoutIndex, _savedLoadout]] call CBA_fnc_localEvent;

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Share selected loadout.
*
* Arguments:
@ -23,33 +23,33 @@ private _contentPanelCursSel = lnbCurSelRow _contentPanelCtrl;
private _loadoutName = _contentPanelCtrl lnbText [_contentPanelCursSel, 1];
private _profileName = profileName; // GVAR(center) could be a remote unit
private _loadoutVar = _profileName + _loadoutName;
private _sharedLoadoutsVars = +(GVAR(sharedLoadoutsNamespace) getVariable QGVAR(sharedLoadoutsVars));
private _sharedLoadoutsVars = +(GVAR(sharedLoadoutsNamespace) getVariable [QGVAR(sharedLoadoutsVars), []]);
private _loadoutIndex = _sharedLoadoutsVars find _loadoutVar;
private _loadoutData = (_contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab))) select 0;
// Loadout set to private
if (_loadoutIndex > -1) then {
if (_loadoutVar in _sharedLoadoutsVars) then {
// Loadout is shared, set to private
GVAR(sharedLoadoutsNamespace) setVariable [_loadoutVar, nil, true];
GVAR(sharedLoadoutsNamespace) setVariable [QGVAR(sharedLoadoutsVars), _sharedLoadoutsVars - [_loadoutVar], true];
_contentPanelCtrl lnbSetPicture [[_contentPanelCursSel, 0], QPATHTOF(data\iconPublicBlank.paa)];
_contentPanelCtrl lnbSetValue [[_contentPanelCursSel, 0], 0];
[QGVAR(loadoutUnshared), [_contentPanelCtrl, profileName, _loadoutName]] call CBA_fnc_remoteEvent;
// Loadout set to public
[QGVAR(loadoutUnshared), [_contentPanelCtrl, _profileName, _loadoutName]] call CBA_fnc_remoteEvent;
} else {
GVAR(sharedLoadoutsNamespace) setVariable [_loadoutVar, [_profileName ,_loadoutName , _loadoutData], true];
// Loadout is private, set to shared
GVAR(sharedLoadoutsNamespace) setVariable [_loadoutVar, [_profileName, _loadoutName, _loadoutData], true];
_sharedLoadoutsVars pushBackUnique _loadoutVar;
GVAR(sharedLoadoutsNamespace) setVariable [QGVAR(sharedLoadoutsVars), _sharedLoadoutsVars, true];
_contentPanelCtrl lnbSetPicture [[_contentPanelCursSel, 0], QPATHTOF(data\iconPublic.paa)];
_contentPanelCtrl lnbSetValue [[_contentPanelCursSel, 0], 1];
[QGVAR(loadoutShared), [_contentPanelCtrl, [_profileName ,_loadoutName , _loadoutData]]] call CBA_fnc_remoteEvent;
[QGVAR(loadoutShared), [_contentPanelCtrl, [_profileName, _loadoutName, _loadoutData]]] call CBA_fnc_remoteEvent;
};
// Update share button text
_control ctrlSetText ( [
localize LSTRING(buttonSharePrivateText),
localize LSTRING(buttonSharePublicText)
_control ctrlSetText ([
LLSTRING(buttonSharePrivateText),
LLSTRING(buttonSharePublicText)
] select ((_contentPanelCtrl lnbValue [_contentPanelCursSel, 0]) == 1));

View File

@ -2,11 +2,10 @@
#include "..\defines.hpp"
/*
* Author: Alganthe
* Toggle the stats control group
* Toggle the stats control group.
*
* Arguments:
* 0: Arsenal display <DISPLAY>
* 1: Button control <CONTROL>
*
* Return Value:
* None
@ -17,15 +16,15 @@
params ["_display"];
(_display displayCtrl IDC_statsButton) ctrlShow GVAR(showStats);
GVAR(showStats) = !GVAR(showStats);
{
(_display displayCtrl _x) ctrlShow GVAR(showStats);
} foreach [
} forEach [
IDC_statsBox,
IDC_statsPreviousPage,
IDC_statsNextPage,
IDC_statsCurrentPage,
IDC_statsButtonClose
];

View File

@ -2,11 +2,12 @@
#include "..\defines.hpp"
/*
* Author: Alganthe
* Handles the previous / next page buttons for stats
* Handles the previous / next page buttons for stats.
*
* Arguments:
* 0: Arsenal display <DISPLAY>
* 1: Previous or next <BOOL> (false = previous, true = next)
* 1: Stats page <CONTROL>
* 2: Previous (false) or next (true) page <BOOL>
*
* Return Value:
* None
@ -21,7 +22,7 @@ if !(ctrlEnabled _control) exitWith {};
GVAR(statsInfo) params ["_isLeftPanel", "_statsIndex", "_panelControl", "_curSel", "_itemCfg"];
private _pageList = [GVAR(statsPagesRight), GVAR(statsPagesLeft)] select (_isLeftPanel);
private _pageList = [GVAR(statsPagesRight), GVAR(statsPagesLeft)] select _isLeftPanel;
private _newPageNumber = [(_pageList select _statsIndex) - 1, (_pageList select _statsIndex) + 1] select _nextPage;
_pageList set [_statsIndex, _newPageNumber];

View File

@ -7,7 +7,7 @@
* Arguments:
* 0: Arsenal display <DISPLAY>
* 1: Searchbar control <CONTROL>
* 2: Right button state <BOOL>
* 2: Mouse button <NUMBER>
*
* Return Value:
* None
@ -15,11 +15,11 @@
* Public: No
*/
params ["_display", "_control", "_rightButton"];
params ["_display", "_control", "_buttonPressed"];
if (_rightButton != 1) exitWith {};
if (_buttonPressed != 1) exitWith {};
_control ctrlSetText '';
_control ctrlSetText "";
if (ctrlIDC _control == IDC_leftSearchbar) then {
[_display, _display displayCtrl GVAR(currentLeftPanel)] call FUNC(fillLeftPanel);

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
/*
* Author: Brett Mayson
* Create the internal stats arrays when needed for the first time
* Author: Brett Mayson, johnb43
* Create the internal sort arrays when needed for the first time.
*
* Arguments:
* None
@ -15,11 +15,19 @@
if (!isNil QGVAR(sortListLeftPanel)) exitWith {};
private _fnc_addToTabs = {
params ["_tabsList", "_tabsToAddTo", "_sideString"];
params ["_tabsList", "_tabsToAddTo", "_tabSide"];
private _sort = [];
{
private _arrayToSave = +_finalArray;
_arrayToSave set [0, [_class, _sideString, [str _x, format ["0%1", _x]] select (_x < 10)] joinString ""];
(_tabsList select _x) pushBack _arrayToSave;
// Copy title, statement and condition
_sort = +_finalArray;
// Make sort name
_sort set [0, [_class, _tabSide, [str _x, format ["0%1", _x]] select (_x < 10)] joinString ""];
// No duplicates are possible here
(_tabsList select _x) pushBack _sort;
} forEach _tabsToAddTo;
};
@ -56,15 +64,17 @@ private _sortListRightPanel = [
];
//------------------------- Config handling
private _configEntries = "(getNumber (_x >> 'scope')) == 2" configClasses (configFile >> QGVAR(sorts));
private _class = "";
private _displayName = "";
private _statement = "";
private _condition = "";
private _finalArray = [];
{
private _finalArray = [];
private _class = configName _x;
private _displayName = getText (_x >> "displayName");
private _statement = getText (_x >> "statement");
private _condition = getText (_x >> "condition");
_class = configName _x;
_displayName = getText (_x >> "displayName");
_statement = getText (_x >> "statement");
_condition = getText (_x >> "condition");
(getArray (_x >> "tabs")) params ["_leftTabsList", "_rightTabsList"];
if (_statement != "") then {
@ -84,7 +94,7 @@ private _configEntries = "(getNumber (_x >> 'scope')) == 2" configClasses (confi
if (_rightTabsList isNotEqualTo []) then {
[_sortListRightPanel, _rightTabsList, "R"] call _fnc_addToTabs;
};
} foreach _configEntries;
} forEach ("(getNumber (_x >> 'scope')) == 2" configClasses (configFile >> QGVAR(sorts)));
missionNamespace setVariable [QGVAR(sortListLeftPanel), _sortListLeftPanel];
missionNamespace setVariable [QGVAR(sortListRightPanel), _sortListRightPanel];
GVAR(sortListLeftPanel) = _sortListLeftPanel;
GVAR(sortListRightPanel) = _sortListRightPanel;

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
/*
* Author: Alganthe
* Create the internal stats arrays when needed for the first time
* Author: Alganthe, johnb43
* Create the internal stat arrays when needed for the first time.
*
* Arguments:
* None
@ -15,88 +15,104 @@
if (!isNil QGVAR(statsListLeftPanel)) exitWith {};
private _fnc_addToTabs = {
params ["_tabsList", "_tabsToAddTo", "_sideString"];
params ["_tabsList", "_tabsToAddTo", "_tabSide"];
private _stat = [];
// First gather all stats for a tab
{
private _currentTab = _tabsList select _x;
private _availablePagesCount = {count _x < 5} count _currentTab;
// Make stat name
_stat = +_finalArray;
_stat set [0, [_class, _tabSide, [str _x, format ["0%1", _x]] select (_x < 10)] joinString ""];
private _arrayToSave = +_finalArray;
_arrayToSave set [0, ([_class, _sideString, [str _x, format ["0%1", _x]] select (_x < 10)] joinString "")];
if (_availablePagesCount > 0) then {
{
if (count _x < 5) exitWith {
(_currentTab select _forEachIndex) append [_arrayToSave];
};
} foreach _currentTab;
} else {
_currentTab pushBack [_arrayToSave];
};
} foreach _tabsToAddTo;
(_tabsList select _x) pushBack _stat;
} forEach _tabsToAddTo;
};
// Sort by priority
private _fnc_sortLists = {
params ["_tabsList"];
{
private _page = _x;
// Put priority up front
{
{
reverse _x;
} foreach _x;
reverse _x;
} forEach _x;
_x sort false;
// Sort numerically
_x sort false;
{
reverse _x;
} foreach _x;
} foreach _page;
} foreach _tabsList;
// Put it back at the rear
{
reverse _x;
} forEach _x;
} forEach _tabsList;
};
// Group stats into groups of 5
private _fnc_toStatsArray = {
params ["_tabsList", "_tabsListAll"];
private _stats = [];
{
_stats = [];
for "_index" from 0 to count _x - 1 step 5 do {
_stats pushBack (_x select [_index, _index + 5]);
};
_tabsList set [_forEachIndex, _stats];
} forEach _tabsList;
};
private _statsListLeftPanel = [
[[]], // Primary 0
[[]], // Handgun 1
[[]], // Launcher 2
[[]], // Uniform 3
[[]], // Vests 4
[[]], // Backpacks 5
[[]], // Headgear 6
[[]], // Goggles 7
[[]], // NVGs 8
[[]], // Binoculars 9
[[]], // Map 10
[[]], // GPS 11
[[]], // Radio 12
[[]], // Compass 13
[[]] // Watch 14
[], // Primary 0
[], // Handgun 1
[], // Launcher 2
[], // Uniform 3
[], // Vests 4
[], // Backpacks 5
[], // Headgear 6
[], // Goggles 7
[], // NVGs 8
[], // Binoculars 9
[], // Map 10
[], // GPS 11
[], // Radio 12
[], // Compass 13
[] // Watch 14
];
private _statsListRightPanel = [
[[]], // Optics 0
[[]], // Side accs 1
[[]], // Muzzle 2
[[]], // Bipod 3
[[]], // Mag 4
[[]], // Throw 5
[[]], // Put 6
[[]] // Misc 7
[], // Optics 0
[], // Side accs 1
[], // Muzzle 2
[], // Bipod 3
[], // Mag 4
[], // Throw 5
[], // Put 6
[] // Misc 7
];
//------------------------- Config handling
private _configEntries = "(getNumber (_x >> 'scope')) == 2" configClasses (configFile >> QGVAR(stats));
private _finalArray = [];
private _class = "";
private _stats = [];
private _displayName = "";
private _showBar = false;
private _showText = false;
private _condition = "";
private _priority = 0;
{
private _finalArray = [];
private _class = configName _x;
private _stats = getArray (_x >> "stats");
private _displayName = getText (_x >> "displayName");
private _showBar = getNumber (_x >> "showBar") == 1;
private _showText = getNumber (_x >> "showText") == 1;
private _condition = getText (_x >> "condition");
private _priority = getNumber (_x >> "priority");
_class = configName _x;
_stats = getArray (_x >> "stats");
_displayName = getText (_x >> "displayName");
_showBar = getNumber (_x >> "showBar") == 1;
_showText = getNumber (_x >> "showText") == 1;
_condition = getText (_x >> "condition");
_priority = getNumber (_x >> "priority");
(getArray (_x >> "tabs")) params ["_leftTabsList", "_rightTabsList"];
if (_condition != "") then {
@ -106,30 +122,32 @@ private _configEntries = "(getNumber (_x >> 'scope')) == 2" configClasses (confi
_finalArray = ["", _stats, _displayName, [_showBar, _showText], [{}, {}, _condition], _priority];
if (_showBar) then {
private _barStatement = compile (getText (_x >> "barStatement"));
(_finalArray select 4) set [0, _barStatement];
(_finalArray select 4) set [0, compile (getText (_x >> "barStatement"))];
};
if (_showText) then {
private _textStatement = compile (getText (_x >> "textStatement"));
(_finalArray select 4) set [1, _textStatement];
(_finalArray select 4) set [1, compile (getText (_x >> "textStatement"))];
};
TRACE_3("stats array", _finalArray, _leftTabsList, _rightTabsList);
if (count _leftTabsList > 0) then {
if (_leftTabsList isNotEqualTo []) then {
[_statsListLeftPanel, _leftTabsList, "L"] call _fnc_addToTabs;
};
if (count _rightTabsList > 0) then {
if (_rightTabsList isNotEqualTo []) then {
[_statsListRightPanel, _rightTabsList, "R"] call _fnc_addToTabs;
};
} foreach _configEntries;
} forEach ("(getNumber (_x >> 'scope')) == 2" configClasses (configFile >> "ace_arsenal_stats"));
// Sort
[_statsListLeftPanel] call _fnc_sortLists;
[_statsListRightPanel] call _fnc_sortLists;
//------------------------- Config Handling
// Group into 5 stats
[_statsListLeftPanel] call _fnc_toStatsArray;
[_statsListRightPanel] call _fnc_toStatsArray;
missionNamespace setVariable [QGVAR(statsListLeftPanel), _statsListLeftPanel];
missionNamespace setVariable [QGVAR(statsListRightPanel), _statsListRightPanel];
//------------------------- Config Handling
GVAR(statsListLeftPanel) = _statsListLeftPanel;
GVAR(statsListRightPanel) = _statsListRightPanel;

View File

@ -1,8 +1,8 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Fill left panel.
* Author: Alganthe, johnb43
* Fills left panel.
*
* Arguments:
* 0: Arsenal display <DISPLAY>
@ -16,19 +16,21 @@
params ["_display", "_control"];
private _ctrlIDC = ctrlIDC _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);
private _ctrlPanel = _display displayCtrl IDC_leftTabContent;
_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;
@ -38,168 +40,226 @@ _ctrlPanel ctrlCommit FADE_DELAY;
_ctrlPanel lbSetCurSel -1;
// Handle icons and filling
switch true do {
case (_ctrlIDC in [IDC_buttonPrimaryWeapon, IDC_buttonHandgun, IDC_buttonSecondaryWeapon]) : {
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;
private _addEmpty = _ctrlPanel lbadd format [" <%1>",localize "str_empty"];
_ctrlPanel lbsetvalue [_addEmpty, -1];
// 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 ((GVAR(virtualItems) select IDX_VIRT_WEAPONS) select ([IDC_buttonPrimaryWeapon, IDC_buttonSecondaryWeapon, IDC_buttonHandgun] find _ctrlIDC));
} forEach (keys ((GVAR(virtualItems) get IDX_VIRT_WEAPONS) get _index));
GVAR(currentItems) select _index
};
case (_ctrlIDC in [IDC_buttonUniform, IDC_buttonVest, IDC_buttonBackpack]) : {
// Uniforms, vests, backpacks
case (_ctrlIDC in [IDC_buttonUniform, IDC_buttonVest, IDC_buttonBackpack]): {
// Purge old data
lbClear _ctrlPanel;
private _addEmpty = _ctrlPanel lbadd format [" <%1>",localize "str_empty"];
_ctrlPanel lbsetvalue [_addEmpty, -1];
// Filling
// Add "Empty" entry
private _addEmpty = _ctrlPanel lbAdd format [" <%1>", localize "str_empty"];
_ctrlPanel lbSetValue [_addEmpty, -1];
switch (_ctrlIDC) do {
case IDC_buttonUniform : {
// Add uniforms
case IDC_buttonUniform: {
{
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select IDX_VIRT_UNIFORM);
};
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_UNIFORM));
case IDC_buttonVest : {
GVAR(currentItems) select IDX_CURR_UNIFORM
};
// Add vests
case IDC_buttonVest: {
{
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select IDX_VIRT_VEST);
};
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_VEST));
case IDC_buttonBackpack : {
GVAR(currentItems) select IDX_CURR_VEST
};
// Add backpacks
case IDC_buttonBackpack: {
{
["CfgVehicles", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select IDX_VIRT_BACKPACK);
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_BACKPACK));
GVAR(currentItems) select IDX_CURR_BACKPACK
};
};
};
// Other
default {
GVAR(currentRightPanel) = nil;
// 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];
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 (GVAR(virtualItems) select IDX_VIRT_HEADGEAR);
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_HEADGEAR));
GVAR(currentItems) select IDX_CURR_HEADGEAR
};
case IDC_buttonGoggles : {
// Facewear
case IDC_buttonGoggles: {
{
["CfgGlasses", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select IDX_VIRT_GOGGLES);
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_GOGGLES));
GVAR(currentItems) select IDX_CURR_GOGGLES
};
case IDC_buttonNVG : {
// NVGs
case IDC_buttonNVG: {
{
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select 8);
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_NVG));
GVAR(currentItems) select IDX_CURR_NVG
};
case IDC_buttonBinoculars : {
// Binoculars
case IDC_buttonBinoculars: {
{
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select 9);
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_BINO));
GVAR(currentItems) select IDX_CURR_BINO
};
case IDC_buttonMap : {
// Maps
case IDC_buttonMap: {
{
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select 10);
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_MAP));
GVAR(currentItems) select IDX_CURR_MAP
};
case IDC_buttonCompass : {
// Compasses
case IDC_buttonCompass: {
{
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select 11);
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_COMPASS));
GVAR(currentItems) select IDX_CURR_COMPASS
};
case IDC_buttonRadio : {
// Radios
case IDC_buttonRadio: {
{
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select 12);
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_RADIO));
GVAR(currentItems) select IDX_CURR_RADIO
};
case IDC_buttonWatch : {
// Watches
case IDC_buttonWatch: {
{
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select 13);
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_WATCH));
GVAR(currentItems) select IDX_CURR_WATCH
};
case IDC_buttonGPS : {
// GPS and UAV Terminals
case IDC_buttonGPS: {
{
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select 14);
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_COMMS));
GVAR(currentItems) select IDX_CURR_COMMS
};
case IDC_buttonFace : {
{
{
if (
getnumber (_x >> "disabled") == 0 &&
{getText (_x >> "head") != ""} &&
{configName _x != "Default"}
) then {
private _configName = configName _x;
private _displayName = getText (_x >> "displayName");
private _lbAdd = _ctrlPanel lbAdd _displayName;
_ctrlPanel lbSetData [_lbAdd, _configName];
_ctrlPanel lbSetTooltip [_lbAdd,format ["%1\n%2",_displayName, _configName]];
_x call ADDMODICON;
};
} foreach ("true" configClasses _x);
} foreach ("true" configClasses (configfile >> "cfgfaces"));
};
case IDC_buttonVoice : {
private _voices = (configProperties [(configFile >> "CfgVoice"), "isClass _x && {getNumber (_x >> 'scope') == 2}", true]) - [(configfile >> "CfgVoice" >> "NoVoice")];
{
["CfgVoice", configName _x, _ctrlPanel, "icon"] call FUNC(addListBoxItem);
} foreach _voices;
};
case IDC_buttonInsignia : {
{
["CfgUnitInsignia", configName _x, _ctrlPanel, "texture"] call FUNC(addListBoxItem);
} foreach ("true" configClasses (configFile >> "CfgUnitInsignia"));
// Faces
case IDC_buttonFace: {
private _lbAdd = -1;
{
private _displayName = getText (_x >> "displayName");
private _className = configName _x;
private _lbAdd = _ctrlPanel lbAdd _displayName;
_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 ("true" configClasses (missionConfigFile >> "CfgUnitInsignia"));
} forEach ("(if (isNumber (_x >> 'scope')) then {getNumber (_x >> 'scope')} else {2}) == 2" configClasses (missionConfigFile >> "CfgUnitInsignia"));
GVAR(currentInsignia)
};
// Unknown
default {""};
};
};
};
// Done
// 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
private _sortLeftCtrl = _display displayCtrl IDC_sortLeftTab;
[_display, _control, _sortLeftCtrl] call FUNC(fillSort);
[_display, _control, _display displayCtrl IDC_sortLeftTab, _display displayCtrl IDC_sortLeftTabDirection] call FUNC(fillSort);
//Select current item
private _itemsToCheck = ((GVAR(currentItems) select [0,15]) + [GVAR(currentFace), GVAR(currentVoice), GVAR(currentInsignia)]) apply {tolower _x};
// 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 {
private _currentData = _ctrlPanel lbData _lbIndex;
if ((_currentData isNotEqualTo "") && {tolower _currentData in _itemsToCheck}) exitWith {
_ctrlPanel lbSetCurSel _lbIndex;
for "_lbIndex" from 0 to (lbSize _ctrlPanel) - 1 do {
if ((_ctrlPanel lbData _lbIndex) == _selectedItem) exitWith {
_index = _lbIndex;
};
};
};
if (lbCurSel _ctrlPanel < 0) then {
_ctrlPanel lbSetCurSel _index;
} else {
_ctrlPanel lbSetCurSel 0;
};

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Fill loadouts list.
*
* Arguments:
@ -16,11 +16,9 @@
params ["_display", "_control"];
(_display displayCtrl IDC_textEditBox) ctrlSetText "";
private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;
private _textEditBoxCtrl= _display displayCtrl IDC_textEditBox;
_textEditBoxCtrl ctrlSetText "";
private _sharingEnabled = (GVAR(allowSharedLoadouts) && {isMultiplayer});
private _sharedLoadoutsVars = GVAR(sharedLoadoutsNamespace) getVariable QGVAR(sharedLoadoutsVars);
// Force a "refresh" animation of the panel
_contentPanelCtrl ctrlSetFade 1;
@ -31,98 +29,107 @@ _contentPanelCtrl ctrlCommit FADE_DELAY;
_contentPanelCtrl lnbSetCurSelRow -1;
lnbClear _contentPanelCtrl;
private _data = +(profileNamespace getvariable [QGVAR(saved_loadouts),[]]);
private _sharedLoadoutsVars = GVAR(sharedLoadoutsNamespace) getVariable QGVAR(sharedLoadoutsVars);
private _cfgWeapons = configFile >> "CfgWeapons";
private _newRow = -1;
if (GVAR(currentLoadoutsTab) != IDC_buttonSharedLoadouts) then {
private _loadoutNameAndTab = "";
private _loadoutCachedInfo = "";
private _sharingEnabled = GVAR(allowSharedLoadouts) && {isMultiplayer};
// Add all loadouts to loadout list
{
_x params ["_loadoutName", "_loadoutData"];
private _loadoutCachedInfo = _contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab));
_loadoutNameAndTab = _loadoutName + str GVAR(currentLoadoutsTab);
_loadoutCachedInfo = _contentPanelCtrl getVariable _loadoutNameAndTab;
// If not in cache, get info and cache it
if (isNil "_loadoutCachedInfo") then {
[_loadoutData] call FUNC(verifyLoadout)
} else {
_loadoutCachedInfo
} params ["_extendedLoadout", "_nullItemsAmount", "_unavailableItemsAmount", "_nullItemsList", "_unavailableItemsList"];
_loadoutCachedInfo = [_loadoutData] call FUNC(verifyLoadout);
_contentPanelCtrl setVariable [_loadoutNameAndTab, _loadoutCachedInfo];
// Log missing / nil items to RPT
if (GVAR(EnableRPTLog) && {isNil "_loadoutCachedInfo"} && {(_nullItemsAmount > 0) || {_unavailableItemsAmount > 0}}) then {
_loadoutCachedInfo params ["", "_nullItemsAmount", "_unavailableItemsAmount", "_nullItemsList", "_unavailableItemsList"];
private _printComponent = "ACE_Arsenal - Loadout:";
private _printNullItemsList = ["Missing items:", str _nullItemsList] joinString " ";
private _printUnavailableItemsList = ["Unavailable items:", str _unavailableItemsList] joinString " ";
// Log missing / nil items to RPT (only once per arsenal session)
if (GVAR(EnableRPTLog) && {(_nullItemsAmount > 0) || {_unavailableItemsAmount > 0}}) then {
private _printComponent = "ACE_Arsenal - Loadout:";
private _printNullItemsList = ["Missing items:", str _nullItemsList] joinString " ";
private _printUnavailableItemsList = ["Unavailable items:", str _unavailableItemsList] joinString " ";
diag_log text (format ["%1%5 %2%5 %3%5 %4", _printComponent, "Name: " + _loadoutName, _printNullItemsList, _printUnavailableItemsList, endl]);
diag_log text (format ["%1%5 %2%5 %3%5 %4", _printComponent, "Name: " + _loadoutName, _printNullItemsList, _printUnavailableItemsList, endl]);
};
};
// Set position of loadouts different if in default loadout tab or if sharing is disabled
if (GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts || {!_sharingEnabled}) then {
_contentPanelCtrl lnbSetColumnsPos [0, 0, 0.40, 0.50, 0.60, 0.70, 0.75, 0.80, 0.85, 0.90];
} else {
_contentPanelCtrl lnbSetColumnsPos [0, 0.05, 0.40, 0.50, 0.60, 0.70, 0.75, 0.80, 0.85, 0.90];
};
private _newRow = _contentPanelCtrl lnbAddRow ["",_loadoutName];
_loadoutCachedInfo params ["_extendedLoadout", "_nullItemsAmount", "_unavailableItemsAmount"];
_extendedLoadout params ["_loadout"];
_newRow = _contentPanelCtrl lnbAddRow ["", _loadoutName];
ADD_LOADOUTS_LIST_PICTURES
// Change color on loadout lines that have items that aren't available or don't exist
if (_nullItemsAmount > 0) then {
_contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 0, 0, 0.8]];
_contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 0, 0, 0.8]]; // Red
} else {
if (_unavailableItemsAmount > 0) then {
_contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 1, 1, 0.25]];
_contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 1, 1, 0.25]]; // Gray
};
};
_contentPanelCtrl setVariable [_loadoutName + str GVAR(currentLoadoutsTab), [_extendedLoadout, _nullItemsAmount, _unavailableItemsAmount, _nullItemsList, _unavailableItemsList]];
if ((profileName + _loadoutName) in _sharedLoadoutsVars && {GVAR(currentLoadoutsTab) == IDC_buttonMyLoadouts}) then {
// If it's a shared loadout and player is in the private loadouts tab, add icon
if (((profileName + _loadoutName) in _sharedLoadoutsVars) && {GVAR(currentLoadoutsTab) == IDC_buttonMyLoadouts}) then {
_contentPanelCtrl lnbSetPicture [[_newRow, 0], QPATHTOF(data\iconPublic.paa)];
_contentPanelCtrl lnbSetValue [[_newRow, 0], 1];
};
} foreach ([_data, +GVAR(defaultLoadoutsList)] select (ctrlIDC _control == IDC_buttonDefaultLoadouts));
} forEach ([profileNamespace getVariable [QGVAR(saved_loadouts), []], GVAR(defaultLoadoutsList)] select (ctrlIDC _control == IDC_buttonDefaultLoadouts));
} else {
private _allPlayerNames = allPlayers apply {name _x};
private _loadoutVar = "";
{
_x params ["_playerName", "_loadoutName", "_loadoutData"];
if ((allPlayers apply {name _x}) find _playerName == -1) then {
private _loadoutVar = _playerName + _loadoutName;
_loadoutVar = _playerName + _loadoutName;
// If player who shared loadout doesn't exist anymore, unshare loadout
if !(_playerName in _allPlayerNames) then {
GVAR(sharedLoadoutsNamespace) setVariable [_loadoutVar, nil, true];
_sharedLoadoutsVars = _sharedLoadoutsVars - [_loadoutVar];
GVAR(sharedLoadoutsNamespace) setVariable [QGVAR(sharedLoadoutsNamespace), _sharedLoadoutsVars, true];
GVAR(sharedLoadoutsNamespace) setVariable [QGVAR(sharedLoadoutsNamespace), _sharedLoadoutsVars - [_loadoutVar], true];
[QGVAR(loadoutUnshared), [_contentPanelCtrl, profileName, _loadoutName]] call CBA_fnc_remoteEvent;
} else {
([_loadoutData] call FUNC(verifyLoadout)) params ["_extendedLoadout", "_nullItemsAmount", "_unavailableItemsAmount"];
_extendedLoadout params ["_loadout"];
_contentPanelCtrl lnbSetColumnsPos [0, 0.15, 0.40, 0.50, 0.60, 0.70, 0.75, 0.80, 0.85, 0.90];
private _newRow = _contentPanelCtrl lnbAddRow [_playerName, _loadoutName];
_newRow = _contentPanelCtrl lnbAddRow [_playerName, _loadoutName];
_extendedLoadout params ["_loadout"];
ADD_LOADOUTS_LIST_PICTURES
_contentPanelCtrl lnbSetData [[_newRow, 1], _playerName + _loadoutName];
_contentPanelCtrl lnbSetData [[_newRow, 1], _loadoutVar];
// Change color on loadout lines that have items that aren't available or don't exist
if (_nullItemsAmount > 0) then {
_contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 0, 0, 0.8]];
_contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 0, 0, 0.8]]; // Red
} else {
if (_unavailableItemsAmount > 0) then {
_contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 1, 1, 0.25]];
_contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 1, 1, 0.25]]; // Gray
};
};
};
} foreach (_sharedLoadoutsVars apply {GVAR(sharedLoadoutsNamespace) getVariable _x});
} forEach (_sharedLoadoutsVars apply {GVAR(sharedLoadoutsNamespace) getVariable _x});
};
[QGVAR(loadoutsListFilled), [_display, _control]] call CBA_fnc_localEvent;
// Sort loadouts alphabetically
_contentPanelCtrl lnbSort [1, false];

View File

@ -1,8 +1,8 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Fill right panel.
* Author: Alganthe, johnb43
* Fills right panel.
*
* Arguments:
* 0: Arsenal display <DISPLAY>
@ -16,8 +16,6 @@
params ["_display", "_control"];
private _ctrlIDC = ctrlIDC _control;
// Fade old control background
if (!isNil QGVAR(currentRightPanel)) then {
private _previousCtrlBackground = _display displayCtrl (GVAR(currentRightPanel) - 1);
@ -26,6 +24,7 @@ if (!isNil QGVAR(currentRightPanel)) then {
};
// Show new control background
private _ctrlIDC = ctrlIDC _control;
private _ctrlBackground = _display displayCtrl (_ctrlIDC - 1);
_ctrlBackground ctrlShow true;
_ctrlBackground ctrlSetFade 0;
@ -33,110 +32,144 @@ _ctrlBackground ctrlCommit FADE_DELAY;
private _searchbarCtrl = _display displayCtrl IDC_rightSearchbar;
// Show right search bar
if (!(ctrlShown _searchbarCtrl) || {ctrlFade _searchbarCtrl > 0}) then {
_searchbarCtrl ctrlShow true;
_searchbarCtrl ctrlSetFade 0;
_searchbarCtrl ctrlCommit 0;
};
private _fnc_fill_right_Container = {
params ["_configCategory", "_className", "_isMagazine", ["_isUnique", false, [false]]];
private _cfgMagazines = configFile >> "CfgMagazines";
private _cfgWeapons = configFile >> "CfgWeapons";
private _rightPanelCache = uiNamespace getVariable QGVAR(rightPanelCache);
private _cacheNamespace = _ctrlPanel;
private _cachedItemInfo = _cacheNamespace getVariable [_configCategory+_className, []];
private _fnc_fillRightContainer = {
params ["_configCategory", "_className", "_hasItemInfo", ["_isUnique", false, [false]], ["_unknownOrigin", false, [false]]];
if (!(_className in GVAR(virtualItemsFlat))) then {
// If item is not in the arsenal, it must be unique
if (!_isUnique && {!(_className in GVAR(virtualItemsFlat))}) then {
_isUnique = true;
};
// Not in cache. So get info and put into cache
if (_cachedItemInfo isEqualTo []) then {
// If not in cache, find info and cache it for later use
(_rightPanelCache getOrDefaultCall [_configCategory + _className, {
// Get display name, picture and mass
private _configPath = configFile >> _configCategory >> _className;
_cachedItemInfo set [0, getText (_configPath >> "displayName")];
_cachedItemInfo set [1, getText (_configPath >> "picture")];
_cachedItemInfo set [2, [getNumber (_configPath >> "itemInfo" >> "mass"), getNumber (_configPath >> "mass")] select _isMagazine];
// "Misc. items" magazines (e.g. spare barrels, intel, photos)
if (_className in (uiNamespace getVariable QGVAR(magazineMiscItems))) then {
_configPath = _cfgMagazines >> _className;
_hasItemInfo = false;
};
_cacheNamespace setVariable [_configCategory+_className, _cachedItemInfo];
};
// If an item with unknown origin is in the arsenal list, try to find it
if (_unknownOrigin && {isNull _configPath}) then {
_configPath = _className call CBA_fnc_getItemConfig;
_cachedItemInfo params ["_displayName","_picture", "_mass"];
// Check if item is object (this should never happen)
if (isNull _configPath) then {
_configPath = _className call CBA_fnc_getObjectConfig;
};
// Check if item is has item info
_itemInfo = isClass (_cfgWeapons >> configName _configPath);
};
// Get mass
private _mass = if (!_hasItemInfo) then {
getNumber (_configPath >> "mass")
} else {
private _mass = getNumber (_configPath >> "itemInfo" >> "mass");
if (_mass == 0) then {
_mass = getNumber (_configPath >> "WeaponSlotsInfo" >> "mass");
};
_mass
};
_rightPanelCache set [_className, _mass]; // Needed because this provides more accurate weight for FUNC(updateRightPanel)
[getText (_configPath >> "displayName"), getText (_configPath >> "picture"), _mass]
}, true]) params ["_displayName", "_picture", "_mass"];
private _lbAdd = _ctrlPanel lnbAddRow ["", _displayName, "0"];
private _columns = count lnbGetColumnsPosition _ctrlPanel;
_ctrlPanel lnbSetData [[_lbAdd, 0], _className];
_ctrlPanel lnbSetPicture [[_lbAdd, 0], _picture];
_ctrlPanel lnbSetValue [[_lbAdd, 0], _mass];
_ctrlPanel setVariable [_className, _mass];
_ctrlPanel lnbSetValue [[_lbAdd, 2], [0, 1] select (_isUnique)];
_ctrlPanel lbSetTooltip [_lbAdd * _columns, format ["%1\n%2", _displayName, _className]];
_ctrlPanel lnbSetValue [[_lbAdd, 2], [0, 1] select _isUnique];
_ctrlPanel lnbSetTooltip [[_lbAdd, 0], format ["%1\n%2", _displayName, _className]];
};
// Retrieve compatible mags
private _compatibleItems = [];
private _compatibleMagazines = [[[], []], [[], []], [[], []]];
{
if (_x != "") then {
private _weaponConfig = (configFile >> "CfgWeapons" >> _x);
private _index = _forEachIndex;
{
private _subIndex = _forEachIndex min 1;
{
((_compatibleMagazines select _index) select _subIndex) pushBackUnique (configName (configFile >> "CfgMagazines" >> _x))
} foreach ([getArray (_weaponConfig >> _x >> "magazines"), getArray (_weaponConfig >> "magazines")] select (_x == "this"));
// Magazine groups
{
private _magazineGroups = uiNamespace getVariable [QGVAR(magazineGroups), createHashMap];
private _magArray = _magazineGroups get (toLower _x);
{((_compatibleMagazines select _index) select _subIndex) pushBackUnique _x} forEach _magArray;
} foreach ([getArray (_weaponConfig >> _x >> "magazineWell"), getArray (_weaponConfig >> "magazineWell")] select (_x == "this"));
} foreach getArray (_weaponConfig >> "muzzles");
};
} foreach [primaryWeapon GVAR(center), handgunWeapon GVAR(center), secondaryWeapon GVAR(center)];
private _itemsToCheck = [];
private _compatibleMagsPrimaryMuzzle = [];
private _compatibleMagsSecondaryMuzzle = [];
private _allCompatibleMags = [];
{
_allCompatibleMags append (_x select 0);
_allCompatibleMags append (_x select 1);
} foreach _compatibleMagazines;
private _ctrlPanel = _display displayCtrl IDC_rightTabContent;
private _listnBox = _display displayCtrl IDC_rightTabContentListnBox;
// Reset right panel content
lbClear _ctrlPanel;
lbClear _listnBox;
_ctrlPanel lbSetCurSel -1;
_listnBox lbSetCurSel -1;
// Retrieve compatible items
private _itemToCheck = "";
private _compatibleItems = [];
private _compatibleMagsMuzzle = [];
private _compatibleMagsAll = createHashMap;
switch (GVAR(currentLeftPanel)) do {
case IDC_buttonPrimaryWeapon : {
_compatibleMagsPrimaryMuzzle = _compatibleMagazines select 0 select 0;
_compatibleMagsSecondaryMuzzle = _compatibleMagazines select 0 select 1;
_compatibleItems = (primaryWeapon GVAR(center)) call bis_fnc_compatibleItems;
_itemsToCheck = GVAR(currentItems) select 18;
};
// If weapons or binoculars are chosen, get their compatible magazines & items
// Weapons and binoculars
case IDC_buttonPrimaryWeapon;
case IDC_buttonHandgun;
case IDC_buttonSecondaryWeapon;
case IDC_buttonBinoculars: {
(switch (GVAR(currentLeftPanel)) do {
case IDC_buttonPrimaryWeapon: {
[IDX_CURR_PRIMARY_WEAPON, IDX_CURR_PRIMARY_WEAPON_ITEMS]
};
case IDC_buttonHandgun: {
[IDX_CURR_HANDGUN_WEAPON, IDX_CURR_HANDGUN_WEAPON_ITEMS]
};
case IDC_buttonSecondaryWeapon: {
[IDX_CURR_SECONDARY_WEAPON, IDX_CURR_SECONDARY_WEAPON_ITEMS]
};
case IDC_buttonBinoculars: {
[IDX_CURR_BINO, IDX_CURR_BINO_ITEMS]
};
}) params ["_currentWeaponIndex", "_currentWeaponItemsIndex"];
case IDC_buttonHandgun : {
_compatibleMagsPrimaryMuzzle = _compatibleMagazines select 1 select 0;
_compatibleMagsSecondaryMuzzle = _compatibleMagazines select 1 select 1;
_compatibleItems = (handgunWeapon GVAR(center)) call bis_fnc_compatibleItems;
_itemsToCheck = GVAR(currentItems) select 20;
};
private _index = [IDC_buttonMuzzle, IDC_buttonItemAcc, IDC_buttonOptic, IDC_buttonBipod, IDC_buttonCurrentMag, IDC_buttonCurrentMag2] find _ctrlIDC;
private _weapon = GVAR(currentItems) select _currentWeaponIndex;
case IDC_buttonSecondaryWeapon : {
_compatibleMagsPrimaryMuzzle = _compatibleMagazines select 2 select 0;
_compatibleMagsSecondaryMuzzle = _compatibleMagazines select 2 select 1;
_compatibleItems = (secondaryWeapon GVAR(center)) call bis_fnc_compatibleItems;
_itemsToCheck = GVAR(currentItems) select 19;
};
// Check if weapon attachement or magazine
if (_index != -1) then {
_itemToCheck = (GVAR(currentItems) select _currentWeaponItemsIndex) select _index;
// If weapon attachment, get base weapon; Get compatible items
if (_index <= 3) then {
_compatibleItems = compatibleItems _weapon;
_itemToCheck = _itemToCheck call FUNC(baseWeapon);
} else {
// Get compatible magazines for primary & secondary muzzle (secondary muzzle is not guaranteed to exist)
// Assumption: One weapon can have two muzzles maximum
_compatibleMagsMuzzle = compatibleMagazines [_weapon, (_weapon call CBA_fnc_getMuzzles) param [_index - 4, ""]];
};
};
};
// Uniform, vest or backpack
case IDC_buttonUniform;
case IDC_buttonVest;
case IDC_buttonBackpack : {
_ctrlPanel = _display displayCtrl IDC_rightTabContentListnBox;
case IDC_buttonBackpack: {
_ctrlPanel = _listnBox;
// This is for the "compatible magazines" tab when a container is open
if (_ctrlIDC == IDC_buttonMag) then {
// Get all compatibles magazines with unit's weapons (including compatible magazines that aren't in configItems)
{
_compatibleMagsAll insert [true, compatibleMagazines _x, []];
} forEach [GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON, GVAR(currentItems) select IDX_CURR_HANDGUN_WEAPON, GVAR(currentItems) select IDX_CURR_SECONDARY_WEAPON, GVAR(currentItems) select IDX_CURR_BINO];
};
};
};
@ -146,238 +179,241 @@ _ctrlPanel ctrlCommit 0;
_ctrlPanel ctrlSetFade 0;
_ctrlPanel ctrlCommit FADE_DELAY;
_itemsToCheck = _itemsToCheck apply {toLower _x};
_compatibleItems = _compatibleItems apply {toLower _x};
// Check if the left panel is a weapon. If so, right panel will be compatible items with weapon only
private _leftPanelState = GVAR(currentLeftPanel) in [IDC_buttonPrimaryWeapon, IDC_buttonHandgun, IDC_buttonSecondaryWeapon, IDC_buttonBinoculars];
lbClear (_display displayCtrl IDC_rightTabContentListnBox);
lbClear (_display displayCtrl IDC_rightTabContent);
(_display displayCtrl IDC_rightTabContentListnBox) lbSetCurSel -1;
(_display displayCtrl IDC_rightTabContent) lbSetCurSel -1;
private _leftPanelState = GVAR(currentLeftPanel) in [IDC_buttonPrimaryWeapon, IDC_buttonHandgun, IDC_buttonSecondaryWeapon];
if (_ctrlIDC in [RIGHT_PANEL_ACC_IDCS, IDC_buttonCurrentMag, IDC_buttonCurrentMag2] && {_leftPanelState}) then {
private _addEmpty = _ctrlPanel lbadd format [" <%1>",localize "str_empty"];
_ctrlPanel lbsetvalue [_addEmpty, -1];
// Add an empty entry if left panel is a weapon or bino
if (_leftPanelState && {_ctrlIDC in [RIGHT_PANEL_ACC_IDCS, IDC_buttonCurrentMag, IDC_buttonCurrentMag2]}) then {
private _addEmpty = _ctrlPanel lbAdd format [" <%1>", localize "str_empty"];
_ctrlPanel lbSetValue [_addEmpty, -1];
};
// Fill right panel according to category choice
switch (_ctrlIDC) do {
// Optics, flashlights, muzzle attachments, bipods
case IDC_buttonOptic;
case IDC_buttonItemAcc;
case IDC_buttonMuzzle;
case IDC_buttonBipod: {
private _index = [IDX_VIRT_OPTICS_ATTACHMENTS, IDX_VIRT_FLASHLIGHT_ATTACHMENTS, IDX_VIRT_MUZZLE_ATTACHMENTS, IDX_VIRT_BIPOD_ATTACHMENTS] select ([RIGHT_PANEL_ACC_IDCS] find _ctrlIDC);
case IDC_buttonOptic : {
if (_leftPanelState) then {
{
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (_compatibleItems arrayIntersect (((GVAR(virtualItems) select 1) select 0) apply {toLower _x}));
if (_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get _index)) then {
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
};
} forEach _compatibleItems;
} else {
{
["CfgWeapons", _x, false] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 1) select 0);
["CfgWeapons", _x, true] call _fnc_fillRightContainer;
} forEach (keys ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get _index));
{
["CfgWeapons", _x, false, true] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 22) select 0);
["CfgWeapons", _x, true, true] call _fnc_fillRightContainer;
} forEach (keys ((GVAR(virtualItems) get IDX_VIRT_UNIQUE_ATTACHMENTS) get _index));
};
};
case IDC_buttonItemAcc : {
// Current primary & secondary muzzle compatible magazines
case IDC_buttonCurrentMag;
case IDC_buttonCurrentMag2: {
if (_leftPanelState) then {
{
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (_compatibleItems arrayIntersect (((GVAR(virtualItems) select 1) select 1) apply {toLower _x}));
} else {
{
["CfgWeapons", _x, false] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 1) select 1);
{
["CfgWeapons", _x, false, true] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 22) select 1);
if (_x in (GVAR(virtualItems) get IDX_VIRT_ITEMS_ALL)) then {
["CfgMagazines", _x, _ctrlPanel] call FUNC(addListBoxItem);
};
} forEach _compatibleMagsMuzzle;
};
};
case IDC_buttonMuzzle : {
if (_leftPanelState) then {
{
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (_compatibleItems arrayIntersect (((GVAR(virtualItems) select 1) select 2) apply {toLower _x}));
} else {
{
["CfgWeapons", _x, false] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 1) select 2);
{
["CfgWeapons", _x, false, true] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 22) select 2);
};
};
case IDC_buttonBipod : {
if (_leftPanelState) then {
{
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (_compatibleItems arrayIntersect (((GVAR(virtualItems) select 1) select 3) apply {toLower _x}));
} else {
{
["CfgWeapons", _x, false] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 1) select 3);
{
["CfgWeapons", _x, false, true] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 22) select 3);
};
};
case IDC_buttonCurrentMag : {
if (_leftPanelState) then {
{
["CfgMagazines", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach ((GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL) arrayIntersect _compatibleMagsPrimaryMuzzle);
};
};
case IDC_buttonCurrentMag2 : {
if (_leftPanelState) then {
{
["CfgMagazines", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach ((GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL) arrayIntersect _compatibleMagsSecondaryMuzzle);
};
};
case IDC_buttonMag : {
// All compatible magazines
case IDC_buttonMag: {
{
["CfgMagazines", _x, true] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL) arrayIntersect _allCompatibleMags);
{
["CfgMagazines", _x, true, true] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 19) arrayIntersect _allCompatibleMags);
};
if (_x in (GVAR(virtualItems) get IDX_VIRT_ITEMS_ALL)) then {
["CfgMagazines", _x, false] call _fnc_fillRightContainer;
case IDC_buttonMagALL : {
{
["CfgMagazines", _x, true] call _fnc_fill_right_Container;
} foreach (GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL);
{
["CfgMagazines", _x, true, true] call _fnc_fill_right_Container;
} foreach (GVAR(virtualItems) select 19);
};
continue;
};
case IDC_buttonThrow : {
{
["CfgMagazines", _x, true] call _fnc_fill_right_Container;
} foreach (GVAR(virtualItems) select 15);
{
["CfgMagazines", _x, true, true] call _fnc_fill_right_Container;
} foreach (GVAR(virtualItems) select 20);
if (_x in (GVAR(virtualItems) get IDX_VIRT_UNIQUE_VIRT_ITEMS_ALL)) then {
["CfgMagazines", _x, false, true] call _fnc_fillRightContainer;
};
} forEach (keys _compatibleMagsAll);
};
// All magazines
case IDC_buttonMagALL: {
{
["CfgMagazines", _x, false] call _fnc_fillRightContainer;
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_ITEMS_ALL));
case IDC_buttonPut : {
{
["CfgMagazines", _x, true] call _fnc_fill_right_Container;
} foreach (GVAR(virtualItems) select 16);
{
["CfgMagazines", _x, true, true] call _fnc_fill_right_Container;
} foreach (GVAR(virtualItems) select 21);
["CfgMagazines", _x, false, true] call _fnc_fillRightContainer;
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_UNIQUE_VIRT_ITEMS_ALL));
};
// Grenades
case IDC_buttonThrow: {
{
["CfgMagazines", _x, false] call _fnc_fillRightContainer;
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_GRENADES));
{
["CfgMagazines", _x, false, true] call _fnc_fillRightContainer;
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_UNIQUE_GRENADES));
};
// Explosives
case IDC_buttonPut: {
{
["CfgMagazines", _x, false] call _fnc_fillRightContainer;
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_EXPLOSIVES));
{
["CfgMagazines", _x, false, true] call _fnc_fillRightContainer;
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_UNIQUE_EXPLOSIVES));
};
// Misc. items
case IDC_buttonMisc: {
// Don't add items that will be in a custom right panel button
private _items = createHashMap;
case IDC_buttonMisc : {
// hide custom button items
private _blockItems = [];
if (!isNil QGVAR(customRightPanelButtons)) then {
{
if (!isNil "_x") then {
_blockItems append (_x select 0);
_items insert [true, _x select 0, []];
};
} forEach GVAR(customRightPanelButtons);
};
// "Regular" misc. items
{
["CfgWeapons", _x, false] call _fnc_fill_right_Container;
} forEach ((GVAR(virtualItems) select 17) select {!((toLower _x) in _blockItems)});
{
["CfgWeapons", _x, false, true] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 18) select {!((toLower _x) in _blockItems)});
{
["CfgVehicles", _x, false, true] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 23) select {!((toLower _x) in _blockItems)});
{
["CfgGlasses", _x, false, true] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 24) select {!((toLower _x) in _blockItems)});
};
default {
private _index = [RIGHT_PANEL_CUSTOM_BUTTONS] find _ctrlIDC;
if (_index != -1) then {
private _data = GVAR(customRightPanelButtons) param [_index];
if (!isNil "_data") then {
private _items = _data select 0;
{
["CfgWeapons", _x, false] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 17) select {(toLower _x) in _items});
{
["CfgWeapons", _x, false, true] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 18) select {(toLower _x) in _items});
{
["CfgVehicles", _x, false, true] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 23) select {(toLower _x) in _items});
{
["CfgGlasses", _x, false, true] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 24) select {(toLower _x) in _items});
if !(_x in _items) then {
["CfgWeapons", _x, true] call _fnc_fillRightContainer;
};
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_MISC_ITEMS));
// Unique items
{
if !(_x in _items) then {
["CfgWeapons", _x, true, true] call _fnc_fillRightContainer;
};
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_UNIQUE_MISC_ITEMS));
// Unique backpacks
{
if !(_x in _items) then {
["CfgVehicles", _x, false, true] call _fnc_fillRightContainer;
};
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_UNIQUE_BACKPACKS));
// Unique goggles
{
if !(_x in _items) then {
["CfgGlasses", _x, false, true] call _fnc_fillRightContainer;
};
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_UNIQUE_GOGGLES));
// Unknown items
{
if !(_x in _items) then {
["CfgWeapons", _x, true, true, true] call _fnc_fillRightContainer;
};
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS));
};
// Custom buttons
default {
private _items = (GVAR(customRightPanelButtons) param [[RIGHT_PANEL_CUSTOM_BUTTONS] find _ctrlIDC, []]) param [0, []];
if (_items isNotEqualTo []) then {
{
switch (true) do {
// "Regular" misc. items
case (_x in (GVAR(virtualItems) get IDX_VIRT_MISC_ITEMS)): {
["CfgWeapons", _x, true] call _fnc_fillRightContainer;
};
// Unique items
case (_x in (GVAR(virtualItems) get IDX_VIRT_UNIQUE_MISC_ITEMS)): {
["CfgWeapons", _x, true, true] call _fnc_fillRightContainer;
};
// Unique backpacks
case (_x in (GVAR(virtualItems) get IDX_VIRT_UNIQUE_BACKPACKS)): {
["CfgVehicles", _x, false, true] call _fnc_fillRightContainer;
};
// Unique goggles
case (_x in (GVAR(virtualItems) get IDX_VIRT_UNIQUE_GOGGLES)): {
["CfgGlasses", _x, false, true] call _fnc_fillRightContainer;
};
// Unknown items
case (_x in (GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS)): {
["CfgWeapons", _x, true, true, true] call _fnc_fillRightContainer;
};
};
} forEach _items;
};
};
};
(_display displayCtrl IDC_rightSearchbar) ctrlSetText "";
// When switching tabs, clear searchbox
if (GVAR(currentRightPanel) != _ctrlIDC) then {
(_display displayCtrl IDC_rightSearchbar) ctrlSetText "";
};
// Trigger event
GVAR(currentRightPanel) = _ctrlIDC;
[QGVAR(rightPanelFilled), [_display, GVAR(currentLeftPanel), _ctrlIDC]] call CBA_fnc_localEvent;
// Add current items and change progress bar
// Add current items, change progress bar of container load and get relevant container
if (GVAR(currentLeftPanel) in [IDC_buttonUniform, IDC_buttonVest, IDC_buttonBackpack]) then {
private _maxLoad = 0;
private _containerItems = [];
private _container = switch (GVAR(currentLeftPanel)) do {
case IDC_buttonUniform : {
// Uniform
case IDC_buttonUniform: {
// Update load bar
(_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadUniform GVAR(center));
_maxLoad = gettext (configfile >> "CfgWeapons" >> uniform GVAR(center) >> "ItemInfo" >> "containerClass");
uniformItems GVAR(center)
// Get all items from container (excluding container itself)
_containerItems = [GVAR(center), 0, 3, 0, 0, false] call EFUNC(common,uniqueUnitItems);
uniformContainer GVAR(center)
};
case IDC_buttonVest : {
// Vest
case IDC_buttonVest: {
// Update load bar
(_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadVest GVAR(center));
_maxLoad = gettext (configfile >> "CfgWeapons" >> vest GVAR(center) >> "ItemInfo" >> "containerClass");
vestItems GVAR(center)
// Get all items from container (excluding container itself)
_containerItems = [GVAR(center), 0, 0, 3, 0, false] call EFUNC(common,uniqueUnitItems);
vestContainer GVAR(center)
};
case IDC_buttonBackpack : {
// Backpack
case IDC_buttonBackpack: {
// Update load bar
(_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadBackpack GVAR(center));
_maxLoad = backpack GVAR(center);
backpackItems GVAR(center)
// Get all items from container (excluding container itself)
_containerItems = [GVAR(center), 0, 0, 0, 3, false] call EFUNC(common,uniqueUnitItems);
backpackContainer GVAR(center)
};
};
for "_l" from 0 to ((lnbsize _ctrlPanel select 0) - 1) do {
private _class = _ctrlPanel lnbData [_l, 0];
_ctrlPanel lnbSetText [[_l, 2], ["0", str ({_x == _class} count _container)] select (_class in _container)];
// Find out how many items of a type there are and update the number displayed
for "_lbIndex" from 0 to (lnbSize _ctrlPanel select 0) - 1 do {
_ctrlPanel lnbSetText [[_lbIndex, 2], str (_containerItems getOrDefault [_ctrlPanel lnbData [_lbIndex, 0], 0])];
};
[_ctrlPanel, _maxLoad] call FUNC(updateRightPanel);
// Refresh availibility of items based on space remaining in container
[_ctrlPanel, _container, _containerItems isNotEqualTo []] call FUNC(updateRightPanel);
};
// Sorting
private _sortRightCtrl = _display displayCtrl IDC_sortRightTab;
[_display, _control, _sortRightCtrl] call FUNC(fillSort);
[_display, _control, _display displayCtrl IDC_sortRightTab, _display displayCtrl IDC_sortRightTabDirection] call FUNC(fillSort);
// Select current data if not in a container
if (_itemsToCheck isNotEqualTo []) then {
for "_lbIndex" from 0 to (lbSize _ctrlPanel - 1) do {
private _currentData = _ctrlPanel lbData _lbIndex;
// Try to select previously selected item again, otherwise select first item ("Empty")
if (_itemToCheck != "") then {
private _index = 0;
if ((_currentData != "") && {tolower _currentData in _itemsToCheck}) exitWith {
_ctrlPanel lbSetCurSel _lbIndex;
for "_lbIndex" from 0 to (lbSize _ctrlPanel) - 1 do {
if ((_ctrlPanel lbData _lbIndex) == _itemToCheck) exitWith {
_index = _lbIndex;
};
};
if (lbCurSel _ctrlPanel < 0) then {
_ctrlPanel lbSetCurSel 0;
};
_ctrlPanel lbSetCurSel _index;
} else {
_ctrlPanel lbSetCurSel 0;
};

View File

@ -1,8 +1,8 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe, Brett Mayson
* Fill right panel.
* Author: Alganthe, Brett Mayson, johnb43
* Fills the sort menu.
*
* Arguments:
* 0: Arsenal display <DISPLAY>
@ -15,51 +15,78 @@
* Public: No
*/
params ["_display", "_control", "_sortCtrl"];
params ["_display", "_control", "_sortCtrl", "_sortDirectionCtrl"];
lbClear _sortCtrl;
lbClear _sortDirectionCtrl;
private _right = false;
private _rightSort = ctrlIDC _sortCtrl == 17;
private _rightSort = ctrlIDC _sortCtrl == IDC_sortRightTab;
private _sorts = if (_rightSort && {GVAR(currentLeftPanel) in [IDC_buttonUniform ,IDC_buttonVest, IDC_buttonBackpack]}) then {
// Handle sorting direction
private _lastSortDirection = [GVAR(lastSortDirectionLeft), GVAR(lastSortDirectionRight)] select _rightSort;
private _sortIndex = 0;
private _index = -1;
{
_x params ["_sortName", "_displayName", "_direction"];
_index = _sortDirectionCtrl lbAdd _displayName;
_sortDirectionCtrl lbSetData [_index, _sortName];
_sortDirectionCtrl lbSetValue [_index, _direction];
if (_direction == _lastSortDirection) then {
_sortIndex = _index;
};
} forEach [[QGVAR(descending), LLSTRING(sortDescending), DESCENDING], [QGVAR(ascending), LLSTRING(sortAscending), ASCENDING]];
// Prevent FUNC(sortPanel) being called twice in succession
GVAR(ignoreFirstSortPanelCall) = true;
_sortDirectionCtrl lbSetCurSel _sortIndex;
// Handle sorting
private _sorts = if (_rightSort && {GVAR(currentLeftPanel) in [IDC_buttonUniform, IDC_buttonVest, IDC_buttonBackpack]}) then {
_right = true;
// Right panel for uniforms, vest and backpacks
GVAR(sortListRightPanel) select (
switch (GVAR(currentRightPanel)) do {
case IDC_buttonOptic: { 0 };
case IDC_buttonItemAcc: { 1 };
case IDC_buttonMuzzle: { 2 };
case IDC_buttonBipod: { 3 };
case IDC_buttonOptic: {0};
case IDC_buttonItemAcc: {1};
case IDC_buttonMuzzle: {2};
case IDC_buttonBipod: {3};
case IDC_buttonCurrentMag;
case IDC_buttonCurrentMag2;
case IDC_buttonMag;
case IDC_buttonMagALL: { 4 };
case IDC_buttonThrow: { 5 };
case IDC_buttonPut: { 6 };
case IDC_buttonMisc: { 7 };
case IDC_buttonMagALL: {4};
case IDC_buttonThrow: {5};
case IDC_buttonPut: {6};
case IDC_buttonMisc: {7};
}
)
} else {
private _sidc = ctrlIDC _sortCtrl;
private _idc = ctrlIDC _control;
switch true do {
case (_sidc == 17): { // Right panel weapon attachment
switch (true) do {
// Right panel for weapons
case (_rightSort): {
GVAR(sortListRightPanel) select (
switch (_idc) do {
case IDC_buttonOptic: { 0 };
case IDC_buttonItemAcc: { 1 };
case IDC_buttonMuzzle: { 2 };
case IDC_buttonBipod: { 3 };
case IDC_buttonOptic: {0};
case IDC_buttonItemAcc: {1};
case IDC_buttonMuzzle: {2};
case IDC_buttonBipod: {3};
case IDC_buttonCurrentMag;
case IDC_buttonCurrentMag2;
case IDC_buttonMag;
case IDC_buttonMagALL: { 4 };
case IDC_buttonThrow: { 5 };
case IDC_buttonPut: { 6 };
case IDC_buttonMisc: { 7 };
case IDC_buttonMagALL: {4};
case IDC_buttonThrow: {5};
case IDC_buttonPut: {6};
case IDC_buttonMisc: {7};
}
)
};
// Left panel
default {
GVAR(sortListLeftPanel) select ([
IDC_buttonPrimaryWeapon,
@ -86,15 +113,21 @@ private _sorts = if (_rightSort && {GVAR(currentLeftPanel) in [IDC_buttonUniform
};
private _lastSort = [GVAR(lastSortLeft), GVAR(lastSortRight)] select _rightSort;
private _sortIndex = 0;
_sortIndex = 0;
{
if (_x isEqualTo []) exitWith {};
if (_x isEqualTo []) then {
continue;
};
_x params ["_sortName", "_displayName", "", "_condition"];
// Check if sort if available for this panel
if ([_right] call _condition) then {
private _index = _sortCtrl lbAdd _displayName;
_index = _sortCtrl lbAdd _displayName;
_sortCtrl lbSetData [_index, _sortName];
if (_displayName isEqualTo _lastSort) then {
if (_displayName == _lastSort) then {
_sortIndex = _index;
};
};

View File

@ -1,37 +0,0 @@
#include "script_component.hpp"
/*
* Author: Brett Mayson
* Get the extended loadout of a unit, including identity options if enabled
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* CBA Extended Loadout <ARRAY>
*
* Example:
* [_unit] call ace_arsenal_fnc_getLoadout
*
* Public: Yes
*/
params [["_unit", objNull, [objNull]]];
if (isNull _unit) exitWith {};
([_unit] call CBA_fnc_getLoadout) params ["_loadout", "_extendedInfo"];
if (GVAR(loadoutsSaveFace)) then {
_extendedInfo set [QGVAR(face), face _unit];
};
if (GVAR(loadoutsSaveVoice)) then {
_extendedInfo set [QGVAR(voice), speaker _unit];
};
if (GVAR(loadoutsSaveInsignia)) then {
private _insignia = _unit getVariable ["BIS_fnc_setUnitInsignia_class", ""];
if (_insignia != "") then {
_extendedInfo set [QGVAR(insignia), _insignia];
};
};
[_loadout, _extendedInfo]

View File

@ -16,30 +16,56 @@
params ["_display", "_control"];
private _textString = ctrlText _control;
private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;
if !(GVAR(lastSearchTextLoadouts) isEqualTo "" || {(_textString find GVAR(lastSearchTextLoadouts)) == 0}) then {//don't refill if there is no need
// Get the currently selected item in panel
private _selectedLoadoutIndex = lnbCurSelRow _contentPanelCtrl;
private _selectedLoadout = "";
// If something is selected, save it
if (_selectedLoadoutIndex != -1) then {
_selectedLoadout = _contentPanelCtrl lnbText [_selectedLoadoutIndex, 1];
};
private _searchString = ctrlText _control;
// Don't refill if there is no need
if (GVAR(lastSearchTextLoadouts) != "" && {(_searchString find GVAR(lastSearchTextLoadouts)) != 0}) then {
[_display, _display displayCtrl GVAR(currentLoadoutsTab)] call FUNC(fillLoadoutsList);
};
GVAR(lastSearchTextLoadouts) = _textString;
if (count _textString == 0) exitWith {};
GVAR(lastSearchTextLoadouts) = _searchString;
private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;
// If nothing searched, quit here
if (_searchString != "") then {
_searchString = toLower _searchString;
private _itemsToGo = (lnbSize _contentPanelCtrl) select 0;
private _lbIndex = 0;
while {_itemsToGo > 0} do {
private _currentData = _contentPanelCtrl lnbText [_lbIndex, 1];
private _currentClassname = _contentPanelCtrl lnbData [_lbIndex, 0];
private _loadoutName = "";
private _loadout = [];
private _currentTab = str GVAR(currentLoadoutsTab);
if ((_currentData isEqualTo "") || {(((toUpper _currentData) find (toUpper _textString)) == -1) && {((toUpper _currentClassname) find (toUpper _textString)) == -1}}) then {
_contentPanelCtrl lnbDeleteRow _lbIndex;
} else {
_lbIndex = _lbIndex + 1;
// Go through all items in panel and see if they need to be deleted or not
for "_lbIndex" from (lnbSize _contentPanelCtrl select 0) - 1 to 0 step -1 do {
_loadoutName = toLower (_contentPanelCtrl lnbText [_lbIndex, 1]);
// Remove item in panel if it doesn't match search, skip otherwise
if ((_loadoutName == "") || {!(_searchString in _loadoutName)}) then {
_contentPanelCtrl lnbDeleteRow _lbIndex;
};
};
_itemsToGo = _itemsToGo - 1;
};
_contentPanelCtrl lnbSetCurSelRow -1;
// Try to select previously selected item again, otherwise select nothing
if (_selectedLoadoutIndex != -1) then {
private _index = -1;
for "_lbIndex" from 0 to (lnbSize _contentPanelCtrl select 0) - 1 do {
if ((_contentPanelCtrl lnbText [_lbIndex, 1]) == _selectedLoadout) exitWith {
_index = _lbIndex;
};
};
_contentPanelCtrl lnbSetCurSelRow _index;
} else {
_contentPanelCtrl lnbSetCurSelRow -1;
};

View File

@ -1,16 +1,16 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Karel Moricky, modified by Alganthe
* Author: Karel Moricky, modified by Alganthe, johnb43
* Update the camera position and pitch/bank.
* Modernized a bit, modified to fit the rewrite.
*
* Arguments:
* 0: Not used
* 1: Arguments <ARRAY>
* 1.1: Mouse area control <CONTROL>
* 1.2: Mouse X position <SCALAR>
* 1.3: Mouse Y position <SCALAR>
* 1.0: Mouse area control <CONTROL>
* 1.1: Mouse X position <NUMBER>
* 1.2: Mouse Y position <NUMBER>
*
* Return Value:
* None
@ -19,50 +19,53 @@
*/
params ["", "_args"];
_args params ["_control", "_mouseX", "_mouseY"];
GVAR(cameraPosition) params ["_distance", "_dirH", "_dirV", "_helperPos"];
GVAR(cameraPosition) params ["", "_dirH", "_dirV", "_helperPos"];
GVAR(mouseButtonState) params ["_LMB", "_RMB"];
if (count _LMB > 0) then {
_LMB params ["_LMBcursorX", "_LMBcursorY"];
private _dX = [(_mouseX - _LMBcursorX), (_LMBcursorX - _mouseX)] select GVAR(camInverted);
private _dY = [(_mouseY -_LMBcursorY), (_LMBcursorY - _mouseY)] select GVAR(camInverted);
GVAR(mouseButtonState) set [0,[_mouseX,_mouseY]];
private _dX = [_mouseX - _LMBcursorX, _LMBcursorX - _mouseX] select GVAR(camInverted);
private _dY = [_mouseY -_LMBcursorY, _LMBcursorY - _mouseY] select GVAR(camInverted);
private _centerBox = boundingboxreal GVAR(center);
private _centerBox = boundingBoxReal GVAR(center);
private _centerSizeBottom = _centerBox select 0 select 2;
private _centerSizeUp = _centerBox select 1 select 2;
private _centerSize = sqrt ([_centerBox select 0 select 0,_centerBox select 0 select 1] distance [_centerBox select 1 select 0,_centerBox select 1 select 1]);
private _centerSize = sqrt ([_centerBox select 0 select 0, _centerBox select 0 select 1] distance [_centerBox select 1 select 0, _centerBox select 1 select 1]);
_helperPos = [_helperPos, _dX * _centerSize, _dirH - 90] call BIS_fnc_relPos;
_helperPos = [_helperPos, _dX * _centerSize, _dirH - 90] call bis_fnc_relpos;
_helperPos = [
[0,0,((_helperPos select 2) - _dY * _centerSize) max _centerSizeBottom min _centerSizeUp],
([0,0,0] distance2D _helperPos) min _centerSize,
[0,0,0] getDir _helperPos
] call bis_fnc_relpos;
[0, 0, ((_helperPos select 2) - _dY * _centerSize) max _centerSizeBottom min _centerSizeUp],
([0, 0, 0] distance2D _helperPos) min _centerSize,
[0, 0, 0] getDir _helperPos
] call BIS_fnc_relPos;
_helperPos set [2,(_helperPos select 2) max ((boundingboxreal GVAR(center) select 0 select 2) + 0.2)];
_helperPos set [2, (_helperPos select 2) max ((_centerBox select 0 select 2) + 0.2)];
GVAR(cameraPosition) set [3,_helperPos];
GVAR(cameraPosition) set [3, _helperPos];
GVAR(mouseButtonState) set [0, [_mouseX, _mouseY]];
};
if (count _RMB > 0) then {
_RMB params ["_RMBcursorX", "_RMBcursorY"];
private _dX = (_RMBcursorX - _mouseX) * 0.75;
private _dY = (_RMBcursorY - _mouseY) * 0.75;
_helperPos = [
[0,0,_helperPos select 2],
[0,0,0] distance2D _helperPos,
([0,0,0] getDir _helperPos) - _dX * 360
] call bis_fnc_relpos;
[0, 0, _helperPos select 2],
[0, 0, 0] distance2D _helperPos,
([0, 0, 0] getDir _helperPos) - _dX * 360
] call BIS_fnc_relPos;
GVAR(cameraPosition) set [1,(_dirH - _dX * 360)];
GVAR(cameraPosition) set [2,(_dirV - _dY * 100) max -89 min 89];
GVAR(cameraPosition) set [3,_helperPos];
GVAR(mouseButtonState) set [1,[_mouseX,_mouseY]];
GVAR(cameraPosition) set [1, _dirH - _dX * 360];
GVAR(cameraPosition) set [2, (_dirV - _dY * 100) max -89 min 89];
GVAR(cameraPosition) set [3, _helperPos];
GVAR(mouseButtonState) set [1, [_mouseX, _mouseY]];
};
if (!alive (GVAR(center)) || isnull GVAR(center)) then {
(ctrlParent _control) closeDisplay 2;
if (!alive GVAR(center)) then {
(ctrlParent _control) closeDisplay IDC_CANCEL;
};

View File

@ -1,12 +1,13 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Handle the mouse wheel.
*
* Arguments:
* 0: Not used
* 1: Mousewheel Z position <SCALAR>
* 1: onMouseZChanged EH return <ARRAY>
* 1.0: Not used
* 1.1: Mousewheel Z position <NUMBER>
*
* Return Value:
* None
@ -17,7 +18,8 @@
params ["", "_args"];
_args params ["", "_zPos"];
private _distanceMax = ((boundingboxreal GVAR(center) select 0) vectordistance (boundingboxreal GVAR(center) select 1)) * 1.5;
private _boundingBoxReal = boundingBoxReal GVAR(center);
private _distanceMax = ((_boundingBoxReal select 0) vectorDistance (_boundingBoxReal select 1)) * 1.5;
private _distanceMin = _distanceMax * 0.15;
private _distance = GVAR(cameraPosition) select 0;

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Handles keyboard inputs inside the searchbars text boxes.
*
* Arguments:
@ -16,77 +16,162 @@
params ["_display", "_control"];
private _textString = ctrlText _control;
private _searchString = ctrlText _control;
// Right panel search bar
if ((ctrlIDC _control) == IDC_rightSearchbar) then {
if !(GVAR(lastSearchTextRight) isEqualTo "" || {(_textString find GVAR(lastSearchTextRight)) == 0}) then {//don't refill if there is no need
// Don't refill if there is no need
if (GVAR(lastSearchTextRight) != "" && {(_searchString find GVAR(lastSearchTextRight)) != 0}) then {
[_display, _display displayCtrl GVAR(currentRightPanel)] call FUNC(fillRightPanel);
};
GVAR(lastSearchTextRight) = _textString;
if (count _textString == 0) exitWith {};
private _rightPanelState = GVAR(currentLeftPanel) in [IDC_buttonPrimaryWeapon, IDC_buttonHandgun, IDC_buttonSecondaryWeapon];
private _rightPanelCtrl = [_display displayCtrl IDC_rightTabContentListnBox, _display displayCtrl IDC_rightTabContent] select (_rightPanelState);
GVAR(lastSearchTextRight) = _searchString;
// If nothing searched, quit here
if (_searchString == "") exitWith {};
private _rightPanelState = GVAR(currentLeftPanel) in [IDC_buttonPrimaryWeapon, IDC_buttonHandgun, IDC_buttonSecondaryWeapon, IDC_buttonBinoculars];
private _rightPanelCtrl = [_display displayCtrl IDC_rightTabContentListnBox, _display displayCtrl IDC_rightTabContent] select _rightPanelState;
_searchString = toLower _searchString;
// If right panel selection is weapons or binoculars
if (_rightPanelState) then {
// Get the currently selected item in panel
private _selectedItemIndex = lbCurSel _rightPanelCtrl;
private _selectedItem = "";
private _itemsToGo = lbSize _rightPanelCtrl;
private _lbIndex = 0;
while {_itemsToGo > 0} do {
private _currentData = _rightPanelCtrl lbText _lbIndex;
private _currentClassname = _rightPanelCtrl lbData _lbIndex;
// If something is selected, save it
if (_selectedItemIndex != -1) then {
_selectedItem = _rightPanelCtrl lbText _selectedItemIndex;
};
if ((_currentData isEqualTo "") || {(((toUpper _currentData) find (toUpper _textString)) == -1) && {((toUpper _currentClassname) find (toUpper _textString)) == -1}}) then {
private _currentDisplayName = "";
private _currentClassname = "";
// Go through all items in panel and see if they need to be deleted or not
for "_lbIndex" from (lbSize _rightPanelCtrl) - 1 to 0 step -1 do {
_currentDisplayName = toLower (_rightPanelCtrl lbText _lbIndex);
_currentClassname = toLower (_rightPanelCtrl lbData _lbIndex);
// Remove item in panel if it doesn't match search, skip otherwise
if ((_currentDisplayName == "") || {!(_searchString in _currentDisplayName) && {!(_searchString in _currentClassname)}}) then {
_rightPanelCtrl lbDelete _lbIndex;
} else {
_lbIndex = _lbIndex + 1;
};
_itemsToGo = _itemsToGo - 1;
};
_rightPanelCtrl lbSetCurSel -1;
// Try to select previously selected item again, otherwise select nothing
if (_selectedItemIndex != -1) then {
private _index = -1;
// Try to find previously selected item in panel
for "_lbIndex" from 0 to (lbSize _rightPanelCtrl) - 1 do {
if ((_rightPanelCtrl lbText _lbIndex) == _selectedItem) exitWith {
_index = _lbIndex;
};
};
// Select old item if found, otherwise don't select anything
_rightPanelCtrl lbSetCurSel _index;
} else {
_rightPanelCtrl lbSetCurSel -1;
};
} else {
// Get the currently selected item in panel
private _selectedItemIndex = lnbCurSelRow _rightPanelCtrl;
private _selectedItem = "";
private _itemsToGo = (lnbSize _rightPanelCtrl) select 0;
private _lbIndex = 0;
while {_itemsToGo > 0} do {
private _currentData = _rightPanelCtrl lnbText [_lbIndex, 1];
private _currentClassname = _rightPanelCtrl lnbData [_lbIndex, 0];
if ((_currentData isEqualTo "") || {(((toUpper _currentData) find (toUpper _textString)) == -1) && {((toUpper _currentClassname) find (toUpper _textString)) == -1}}) then {
_rightPanelCtrl lnbDeleteRow _lbIndex;
} else {
_lbIndex = _lbIndex + 1;
};
_itemsToGo = _itemsToGo - 1;
// If something is selected, save it
if (_selectedItemIndex != -1) then {
_selectedItem = _rightPanelCtrl lnbText [_selectedItemIndex, 1];
};
private _currentDisplayName = "";
private _currentClassname = "";
// Go through all items in panel and see if they need to be deleted or not
for "_lbIndex" from (lnbSize _rightPanelCtrl select 0) - 1 to 0 step -1 do {
_currentDisplayName = toLower (_rightPanelCtrl lnbText [_lbIndex, 1]);
_currentClassname = toLower (_rightPanelCtrl lnbData [_lbIndex, 0]);
// Remove item in panel if it doesn't match search, skip otherwise
if ((_currentDisplayName == "") || {!(_searchString in _currentDisplayName) && {!(_searchString in _currentClassname)}}) then {
_rightPanelCtrl lnbDeleteRow _lbIndex;
};
};
// Try to select previously selected item again, otherwise select nothing
if (_selectedItemIndex != -1) then {
private _index = -1;
// Try to find previously selected item in panel
for "_lbIndex" from 0 to (lnbSize _rightPanelCtrl select 0) - 1 do {
if ((_rightPanelCtrl lnbText [_lbIndex, 1]) == _selectedItem) exitWith {
_index = _lbIndex;
};
};
// Select old item if found, otherwise don't select anything
_rightPanelCtrl lnbSetCurSelRow _index;
} else {
_rightPanelCtrl lnbSetCurSelRow -1;
};
_rightPanelCtrl lnbSetCurSelRow -1;
};
[_display, nil, nil, configNull] call FUNC(itemInfo);
} else {
if !(GVAR(lastSearchTextLeft) isEqualTo "" || {(_textString find GVAR(lastSearchTextLeft)) == 0}) then {//don't refill if there is no need
// Left panel search bar
// Don't refill if there is no need
if (GVAR(lastSearchTextLeft) != "" && {(_searchString find GVAR(lastSearchTextLeft)) != 0}) then {
[_display, _display displayCtrl GVAR(currentLeftPanel)] call FUNC(fillLeftPanel);
};
GVAR(lastSearchTextLeft) = _textString;
if (count _textString == 0) exitWith {};
GVAR(lastSearchTextLeft) = _searchString;
// If nothing searched, quit here
if (_searchString == "") exitWith {};
private _leftPanelCtrl = _display displayCtrl IDC_leftTabContent;
_searchString = toLower _searchString;
private _itemsToGo = (lbSize _leftPanelCtrl);
private _lbIndex = 0;
while {_itemsToGo > 0} do {
private _currentData = _leftPanelCtrl lbText _lbIndex;
private _currentClassname = _leftPanelCtrl lbData _lbIndex;
// Get the currently selected item in panel
private _selectedItemIndex = lbCurSel _leftPanelCtrl;
private _selectedItem = "";
if ((_currentData isEqualTo "") || {(((toUpper _currentData) find (toUpper _textString)) == -1) && {((toUpper _currentClassname) find (toUpper _textString)) == -1}}) then {
_leftPanelCtrl lbDelete _lbIndex;
} else {
_lbIndex = _lbIndex + 1;
};
_itemsToGo = _itemsToGo - 1;
// If something is selected, save it
if (_selectedItemIndex != -1) then {
_selectedItem = _leftPanelCtrl lbText _selectedItemIndex;
};
_leftPanelCtrl lbSetCurSel -1;
private _currentDisplayName = "";
private _currentClassname = "";
// Go through all items in panel and see if they need to be deleted or not
for "_lbIndex" from (lbSize _leftPanelCtrl) - 1 to 0 step -1 do {
_currentDisplayName = toLower (_leftPanelCtrl lbText _lbIndex);
_currentClassname = toLower (_leftPanelCtrl lbData _lbIndex);
// Remove item in panel if it doesn't match search, skip otherwise
if ((_currentDisplayName == "") || {!(_searchString in _currentDisplayName) && {!(_searchString in _currentClassname)}}) then {
_leftPanelCtrl lbDelete _lbIndex;
};
};
// Try to select previously selected item again, otherwise select nothing
if (_selectedItemIndex != -1) then {
private _index = -1;
for "_lbIndex" from 0 to (lbSize _leftPanelCtrl) - 1 do {
if ((_leftPanelCtrl lbText _lbIndex) == _selectedItem) exitWith {
_index = _lbIndex;
};
};
_leftPanelCtrl lbSetCurSel _index;
} else {
_leftPanelCtrl lbSetCurSel -1;
};
[_display, nil, nil, configNull] call FUNC(itemInfo);
};

View File

@ -2,12 +2,12 @@
#include "..\defines.hpp"
/*
* Author: Alganthe
* Handles the stats control group
* Handles the stats control group.
*
* Arguments:
* 0: Arsenal display <DISPLAY>
* 1: Current panel control <CONTROL>
* 2: Current panel selection <SCALAR>
* 2: Current panel selection <NUMBER>
* 3: Item config entry <CONFIG>
*
* Return Value:
@ -27,7 +27,7 @@ private _hideUnusedFnc = {
params ["_numbers"];
{
private _statsTitleCtrl = _display displayCtrl (5101 + ((_x - 1) * 4));
private _statsTitleCtrl = _display displayCtrl (IDC_statsTitle1 + ((_x - 1) * 4));
private _statsTitleIDC = ctrlIDC _statsTitleCtrl;
private _statsBackgroundCtrl = _display displayCtrl (_statsTitleIDC + 1);
@ -47,34 +47,40 @@ private _hideUnusedFnc = {
};
if (!isNil "_itemCfg") then {
private _handleStatsFnc = {
params ["_statsIndex", "_leftPanel"];
// Get the proper list and page
if (_leftPanel) then {
[true, (GVAR(statsListLeftPanel)) select _statsIndex, GVAR(statsPagesLeft) select _statsIndex]
[(GVAR(statsListLeftPanel)) select _statsIndex, GVAR(statsPagesLeft) select _statsIndex]
} else {
[false, (GVAR(statsListRightPanel)) select _statsIndex, GVAR(statsPagesRight) select _statsIndex]
} params ["_isLeftPanel", "_statsArray", "_currentPage"];
[(GVAR(statsListRightPanel)) select _statsIndex, GVAR(statsPagesRight) select _statsIndex]
} params ["_statsArray", "_currentPage"];
private _statsList = _statsArray select _currentPage;
private _statsCount = 0;
// Handle titles, bars and text
_statsList = _statsList select [0, 5];
if (_statsList isNotEqualTo []) then {
private _statsTitleCtrl = controlNull;
private _statsTitleIDC = -1;
private _statsBackgroundCtrl = controlNull;
private _statsBarCtrl = controlNull;
private _statsTextCtrl = controlNull;
private _textStatementResult = "";
{
_x params ["_ID", "_configEntry", "_title", "_bools", "_statements"];
_bools params ["_showBar", "_showText"];
_statements params [["_barStatement", {}, [{}]], ["_textStatement", {}, [{}]], ["_condition", {true}, [{}]]];
private _statsTitleCtrl = _display displayCtrl (5101 + _forEachIndex * 4);
private _statsTitleIDC = ctrlIDC _statsTitleCtrl;
private _statsBackgroundCtrl = _display displayCtrl (_statsTitleIDC + 1);
private _statsBarCtrl = _display displayCtrl (_statsTitleIDC + 2);
private _statsTextCtrl = _display displayCtrl (_statsTitleIDC + 3);
_statsTitleCtrl = _display displayCtrl (IDC_statsTitle1 + _forEachIndex * 4);
_statsTitleIDC = ctrlIDC _statsTitleCtrl;
_statsBackgroundCtrl = _display displayCtrl (_statsTitleIDC + 1);
_statsBarCtrl = _display displayCtrl (_statsTitleIDC + 2);
_statsTextCtrl = _display displayCtrl (_statsTitleIDC + 3);
_statsCount = _statsCount + 1;
_statsTitleCtrl ctrlSetText _title;
@ -83,7 +89,6 @@ if (!isNil "_itemCfg") then {
// Handle bars
if (_showBar) then {
_statsBarCtrl progressSetPosition ([_configEntry, _itemCfg] call _barStatement);
_statsBackgroundCtrl ctrlSetFade 0;
_statsBarCtrl ctrlSetFade 0;
} else {
@ -93,15 +98,14 @@ if (!isNil "_itemCfg") then {
// Handle text entries
if (_showText) then {
private _textStatementResult = [_configEntry, _itemCfg] call _textStatement;
_textStatementResult = [_configEntry, _itemCfg] call _textStatement;
if (_textStatementResult isEqualtype "") then {
_statsTextCtrl ctrlSetText _textStatementResult;
} else {
_statsTextCtrl ctrlSetText (str _textStatementResult);
if !(_textStatementResult isEqualtype "") then {
_textStatementResult = str _textStatementResult;
};
_statsTextCtrl ctrlSetTextColor ([[1,1,1,1], [0,0,0,1]] select (_showBar));
_statsTextCtrl ctrlSetText _textStatementResult;
_statsTextCtrl ctrlSetTextColor ([[1, 1, 1, 1], [0, 0, 0, 1]] select (_showBar));
_statsTextCtrl ctrlSetFade 0;
} else {
_statsTextCtrl ctrlSetFade 1;
@ -116,8 +120,8 @@ if (!isNil "_itemCfg") then {
_statsTextCtrl
];
} forEach (_statsList select {
_x params ["_ID","_configEntry", "_title", "_bools", "_statements"];
_statements params [["_barStatement", {}, [{}]], ["_textStatement", {}, [{}]], ["_condition", {true}, [{}]]];
_x params ["", "_configEntry", "", "", "_statements"];
_statements params ["", "", ["_condition", {true}, [{}]]];
([_configEntry, _itemCfg] call _condition)
});
@ -133,12 +137,12 @@ if (!isNil "_itemCfg") then {
];
_statsBoxCtrl ctrlCommit 0;
GVAR(statsInfo) = [_isLeftPanel, _statsIndex, _control, _curSel, _itemCfg];
GVAR(statsInfo) = [_leftPanel, _statsIndex, _control, _curSel, _itemCfg];
// Toggle page buttons
_statsPreviousPageCtrl ctrlEnable !(_currentPage == 0);
_statsNextPageCtrl ctrlEnable !(_currentPage + 1 >= count _statsArray);
_statsCurrentPageCtrl ctrlSetText ([localize LSTRING(page), str (_currentPage + 1)] joinString " ");
_statsPreviousPageCtrl ctrlEnable (_currentPage > 0);
_statsNextPageCtrl ctrlEnable (_currentPage + 1 < count _statsArray);
_statsCurrentPageCtrl ctrlSetText ([LLSTRING(page), str (_currentPage + 1)] joinString " ");
{
_x ctrlSetFade 0;
@ -150,10 +154,10 @@ if (!isNil "_itemCfg") then {
];
};
// Check if in left or right panel
if (ctrlIDC _control == IDC_leftTabContent) then {
// Faces, voices and insigna do not have stats
if ([IDC_buttonFace, IDC_buttonVoice, IDC_buttonInsignia] find GVAR(currentLeftPanel) > -1) then {
[[1, 2, 3, 4, 5]] call _hideUnusedFnc;
_statsBoxCtrl ctrlSetPosition [
(0.5 - WIDTH_TOTAL / 2) + WIDTH_GAP,
@ -227,7 +231,7 @@ if (!isNil "_itemCfg") then {
};
};
} else {
// If nothing is chosen, hide stats
[[1, 2, 3, 4, 5]] call _hideUnusedFnc;
_statsBoxCtrl ctrlSetPosition [
(0.5 - WIDTH_TOTAL / 2) + WIDTH_GAP,

View File

@ -1,12 +1,12 @@
#include "script_component.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Initialize a box / object for arsenal.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Items <BOOL> or <ARRAY>
* 2: Initialize globally <BOOL>
* 1: Items <BOOL> <ARRAY>
* 2: Initialize globally <BOOL> (default: true)
*
* Return Value:
* None
@ -22,42 +22,36 @@ params [["_object", objNull, [objNull]], ["_items", true, [[], true]], ["_global
if (isNull _object) exitWith {};
if (isNil QGVAR(EHIDArray)) then {
GVAR(EHIDArray) = [];
};
if (_global && {isMultiplayer} && {isNil {_object getVariable QGVAR(initBoxJIP)}}) then {
private _id = [QGVAR(initBox), [_object, _items, false]] call CBA_fnc_globalEventJIP;
if (_global && {isMultiplayer} && {{_object in _x} count GVAR(EHIDArray) == 0}) then {
// Remove JIP EH if object is deleted
[_id, _object] call CBA_fnc_removeGlobalEventJIP;
private _ID = [QGVAR(initBox), [_object, _items, false]] call CBA_fnc_globalEventJIP;
[_ID, _object] call CBA_fnc_removeGlobalEventJIP;
GVAR(EHIDArray) pushBack [_ID, _object];
publicVariable QGVAR(EHIDArray);
// Save JIP ID
_object setVariable [QGVAR(initBoxJIP), _id, true];
} else {
// Only add interaction if there isn't one already present
if (((_object getVariable [QEGVAR(interact_menu,actions), []]) findIf {((_x select 0) select 0) == QGVAR(interaction)}) != -1) exitWith {};
if ({(_x select 0) select 0 isEqualTo QGVAR(interaction)} count (_object getVariable [QEGVAR(interact_menu,actions), []]) == 0) then {
private _action = [
QGVAR(interaction),
localize "STR_A3_Arsenal",
"",
{
params ["_target", "_player"];
private _action = [
QGVAR(interaction),
localize "STR_A3_Arsenal",
"",
{
params ["_target", "_player"];
[_target, _player] call FUNC(openBox);
},
{
params ["_target", "_player"];
[_target, _player] call FUNC(openBox);
},
{
params ["_target", "_player"];
[_player, _target] call EFUNC(common,canInteractWith)
}
] call EFUNC(interact_menu,createAction);
[_object, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToObject);
[_player, _target] call EFUNC(common,canInteractWith)
},
{},
[]
] call EFUNC(interact_menu,createAction);
[_object, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToObject);
[_object, _items, false] call FUNC(addVirtualItems);
[_object, _items, false] call FUNC(addVirtualItems);
[QGVAR(boxInitialized), [_object, _items]] call CBA_fnc_localEvent;
};
[QGVAR(boxInitialized), [_object, _items]] call CBA_fnc_localEvent;
};

View File

@ -1,13 +1,14 @@
#include "script_component.hpp"
#include "..\defines.hpp"
#include "\a3\ui_f\hpp\defineResincl.inc"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Update arsenal's info box.
*
* Arguments:
* 0: Arsenal display <DISPLAY>
* 1: Current panel control <CONTROL>
* 2: Current panel selection <SCALAR>
* 2: Current panel selection <NUMBER>
* 3: Item config entry <CONFIG>
*
* Return Value:
@ -16,60 +17,55 @@
* Public: No
*/
params ["_display", "_control", "_curSel" ,"_itemCfg"];
params ["_display", "_control", "_curSel", "_itemCfg"];
private _ctrlInfo = _display displayCtrl IDC_infoBox;
if (isClass _itemCfg) then {
_ctrlInfo ctrlSetFade 0;
_ctrlInfo ctrlCommit FADE_DELAY;
[QGVAR(displayStats), [_display, _control, _curSel, _itemCfg]] call CBA_fnc_localEvent;
// Name + author
private _ctrlInfoName = _display displayCtrl IDC_infoName;
_ctrlInfoName ctrlSetText ([_control lbText _curSel, _control lnbText [_curSel, 1]] select (ctrlType _control == 102));
private _ctrlInfoAuthor = _display displayctrl IDC_infoAuthor;
_ctrlInfoAuthor ctrlSetText "";
(_display displayCtrl IDC_infoName) ctrlSetText ([_control lbText _curSel, _control lnbText [_curSel, 1]] select (ctrlType _control == CT_LISTNBOX));
private _itemAuthor = getText (_itemCfg >> "author");
_ctrlInfoAuthor ctrlSetText ([localize "STR_AUTHOR_UNKNOWN", format [localize "STR_FORMAT_AUTHOR_SCRIPTED",_itemAuthor]] select (_itemAuthor != ""));
(_display displayctrl IDC_infoAuthor) ctrlSetText ([localize "STR_AUTHOR_UNKNOWN", format [localize "STR_FORMAT_AUTHOR_SCRIPTED", _itemAuthor]] select (_itemAuthor != ""));
// DLC / mod icon
private _ctrlDLC = _display displayctrl IDC_DLCIcon;
private _ctrlDLCBackground = _display displayctrl IDC_DLCBackground;
private _dlc = _itemCfg call GETDLC;
private _dlc = _itemCfg call EFUNC(common,getAddon);
if (_dlc != "") then {
(modParams [_dlc, ["name", "logo", "logoOver"]]) params ["_name", "_logo", "_logoOver"];
private _dlcParams = modParams [_dlc, ["name", "logo", "logoOver"]];
_dlcParams params ["_name", "_logo", "_logoOver"];
private _appId = getnumber (configfile >> "CfgMods" >> _dlc >> "appId");
_ctrlDLC ctrlSetTooltip _name;
_ctrlDLC ctrlSetText _logo;
_ctrlDLCBackground ctrlSetFade 0;
_ctrlDLC ctrlSetFade 0;
_ctrlDLC ctrlsettooltip _name;
_ctrlDLC ctrlsettext _logo;
_ctrlDLCBackground ctrlsetfade 0;
_ctrlDLC ctrlsetfade 0;
if (_appId > 0) then {
_ctrlDLC ctrlseteventhandler ["mouseexit",format ["(_this select 0) ctrlsettext '%1';",_logo]];
_ctrlDLC ctrlseteventhandler ["mouseenter",format ["(_this select 0) ctrlsettext '%1';",_logoOver]];
_ctrlDLC ctrlseteventhandler [
"buttonclick",
format ["uiNamespace setvariable ['RscDisplayDLCPreview_dlc','%1']; ctrlparent (_this select 0) createDisplay 'RscDisplayDLCPreview';", _dlc]
// If an item is from a DLC, set it so when you press the icon on the bottom right it opens the DLC page
if ((getNumber (configfile >> "CfgMods" >> _dlc >> "appId")) > 0) then {
_ctrlDLC ctrlSetEventHandler ["mouseExit", format ["(_this select 0) ctrlSetText '%1';", _logo]];
_ctrlDLC ctrlSetEventHandler ["mouseEnter", format ["(_this select 0) ctrlSetText '%1';", _logoOver]];
_ctrlDLC ctrlSetEventHandler [
"buttonClick",
format ["uiNamespace setVariable ['RscDisplayDLCPreview_dlc','%1']; ctrlParent (_this select 0) createDisplay 'RscDisplayDLCPreview';", _dlc]
];
} else {
_ctrlDLC ctrlRemoveAllEventHandlers "buttonclick";
_ctrlDLC ctrlRemoveAllEventHandlers "mouseexit";
_ctrlDLC ctrlRemoveAllEventHandlers "mouseenter";
_ctrlDLC ctrlRemoveAllEventHandlers "mouseExit";
_ctrlDLC ctrlRemoveAllEventHandlers "mouseEnter";
_ctrlDLC ctrlRemoveAllEventHandlers "buttonClick";
};
} else {
_ctrlDLC ctrlsetfade 1;
_ctrlDLCBackground ctrlsetfade 1;
_ctrlDLC ctrlSetFade 1;
_ctrlDLCBackground ctrlSetFade 1;
};
_ctrlDLC ctrlcommit 0;
_ctrlDLCBackground ctrlcommit 0;
_ctrlDLC ctrlCommit 0;
_ctrlDLCBackground ctrlCommit 0;
} else {
[QGVAR(displayStats), [_display, _control, -1, nil]] call CBA_fnc_localEvent;

View File

@ -27,7 +27,6 @@ private _renameButtonCtrl = _display displayCtrl IDC_buttonRename;
// Update UI visual elements
if (GVAR(currentLoadoutsTab) != -1) then {
private _previousCtrlBackground = _display displayCtrl (GVAR(currentLoadoutsTab) - 1);
_previousCtrlBackground ctrlSetBackgroundColor [0, 0, 0, 0.8];
_previousCtrlBackground ctrlCommit 0;
@ -45,26 +44,36 @@ _control ctrlSetTextColor [0, 0, 0, 1];
_control ctrlCommit 0;
switch (ctrlIDC _control) do {
// Local loadouts
case IDC_buttonMyLoadouts: {
_centerBoxTitleCtrl ctrlSetText (localize LSTRING(tabMyLoadoutsText));
_centerBoxTitleCtrl ctrlSetText LLSTRING(tabMyLoadoutsText);
if (is3DEN) then {
_saveButtonCtrl ctrlSetTooltip format ["%1\n%2", LLSTRING(buttonSaveTooltip), LLSTRING(buttonSaveTooltip_shiftClick)];
};
if (is3den) then { _saveButtonCtrl ctrlSetTooltip format ["%1\n%2", localize LSTRING(buttonSaveTooltip), localize LSTRING(buttonSaveTooltip_shiftClick)]; };
_saveButtonCtrl ctrlEnable true;
_saveButtonCtrl ctrlCommit 0;
};
// Default loadouts
case IDC_buttonDefaultLoadouts: {
_centerBoxTitleCtrl ctrlSetText (localize LSTRING(tabDefaultLoadoutsText));
_centerBoxTitleCtrl ctrlSetText LLSTRING(tabDefaultLoadoutsText);
if (is3den) then { _saveButtonCtrl ctrlSetTooltip localize LSTRING(buttonSaveTooltip); };
_saveButtonCtrl ctrlEnable (is3DEN);
if (is3DEN) then {
_saveButtonCtrl ctrlSetTooltip LLSTRING(buttonSaveTooltip);
};
_saveButtonCtrl ctrlEnable is3DEN;
_saveButtonCtrl ctrlCommit 0;
};
// Shared loadouts
case IDC_buttonSharedLoadouts: {
_centerBoxTitleCtrl ctrlSetText (localize LSTRING(tabSharedLoadoutsText));
_centerBoxTitleCtrl ctrlSetText LLSTRING(tabSharedLoadoutsText);
if (is3DEN) then {
_saveButtonCtrl ctrlSetTooltip LLSTRING(buttonSaveTooltip);
};
if (is3den) then { _saveButtonCtrl ctrlSetTooltip localize LSTRING(buttonSaveTooltip); };
_saveButtonCtrl ctrlEnable false;
_saveButtonCtrl ctrlCommit 0;
};
@ -73,8 +82,9 @@ switch (ctrlIDC _control) do {
{
_x ctrlEnable false;
_x ctrlCommit 0;
} foreach [_shareButtonCtrl, _loadButtonCtrl, _deleteButtonCtrl, _renameButtonCtrl];
} forEach [_shareButtonCtrl, _loadButtonCtrl, _deleteButtonCtrl, _renameButtonCtrl];
// Save new tab as current tab
GVAR(currentLoadoutsTab) = ctrlIDC _control;
[QGVAR(loadoutsTabChanged), [_display, _control]] call CBA_fnc_localEvent;

View File

@ -19,6 +19,7 @@ params ["_display", "_message"];
private _messageBoxCtrl = _display displayCtrl IDC_message;
private _handle = _messageBoxCtrl getVariable QGVAR(messageBoxHandle);
// Stop previous message being displayed
if (!isNil "_handle") then {
terminate _handle;
};
@ -26,29 +27,30 @@ if (!isNil "_handle") then {
_handle = [_display, _messageBoxCtrl, time + 5, _message, FADE_DELAY] spawn {
disableSerialization;
_this params ["_display", "_control", "_timer", "_message", "_delay"];
params ["_display", "_control", "_timer", "_message", "_delay"];
// Refresh message box, in case previous message box is still shown
_control ctrlSetText _message;
_control ctrlSetFade 1;
_control ctrlCommit 0;
_control ctrlSetFade 0;
_control ctrlCommit _delay;
while {_timer >= time} do {
switch true do {
case (_display isEqualTo displayNull): {
terminate _thisScript;
};
case (round (_timer - time) == 5): {
_control ctrlSetText _message;
_control ctrlSetFade 1;
_control ctrlCommit 0;
_control ctrlSetFade 0;
_control ctrlCommit _delay;
};
// If the display has been closed, quit
if (isNull _display) then {
terminate _thisScript;
};
uiSleep 1;
};
// Hide message box and finish
_control ctrlSetFade 1;
_control ctrlCommit _delay;
terminate _thisScript;
};
_messageBoxCtrl setVariable [QGVAR(messageBoxHandle), _handle];

View File

@ -4,7 +4,10 @@
* onUnLoad EH for arsenal.
*
* Arguments:
* None
* 0: Not used
* 1: Args <ARRAY>
* 1.0: Not used
* 1.1: Exit code <NUMBER>
*
* Return Value:
* None
@ -14,13 +17,10 @@
(_this select 1) params ["", "_exitCode"];
private _cameraData = [getposAtl GVAR(camera), (getposAtl GVAR(camera)) vectorFromTo (getposAtl GVAR(cameraHelper))];
[QGVAR(displayClosed), []] call CBA_fnc_localEvent;
removeMissionEventHandler ["draw3D", GVAR(camPosUpdateHandle)];
if (is3DEN) then {
private _centerOriginParent = objectParent GVAR(centerOrigin);
if !(isNull _centerOriginParent) then {
@ -31,11 +31,14 @@ if (is3DEN) then {
// Apply the loadout from the dummy to all selected units
if (_exitCode == 1) then {
{
[_x, GVAR(center) call FUNC(getLoadout)] call CBA_fnc_setLoadout;
} foreach (get3DENSelected "object");
private _extendedLoadout = GVAR(center) call CBA_fnc_getLoadout;
private _objects = get3DENSelected "object";
save3DENInventory (get3DENSelected "object");
{
[_x, _extendedLoadout] call CBA_fnc_setLoadout;
} forEach _objects;
save3DENInventory _objects;
};
deleteVehicle GVAR(light);
@ -44,21 +47,21 @@ if (is3DEN) then {
GVAR(centerOrigin) = nil;
GVAR(light) = nil;
get3DENCamera cameraEffect ["internal","back"];
["ShowInterface",true] call bis_fnc_3DENInterface;
GVAR(visionMode) call bis_fnc_3DENVisionMode;
get3DENCamera cameraEffect ["Internal", "BACK"];
["ShowInterface", true] call BIS_fnc_3DENInterface;
GVAR(visionMode) call BIS_fnc_3DENVisionMode;
} else {
// Select correct weapon
switch GVAR(selectedWeaponType) do {
case 0: {GVAR(center) selectWeapon primaryWeapon GVAR(center);};
case 1: {GVAR(center) selectWeapon secondaryWeapon GVAR(center);};
case 2: {GVAR(center) selectWeapon handgunWeapon GVAR(center);};
switch (GVAR(selectedWeaponType)) do {
case 0: {GVAR(center) selectWeapon (primaryWeapon GVAR(center))};
case 1: {GVAR(center) selectWeapon (secondaryWeapon GVAR(center))};
case 2: {GVAR(center) selectWeapon (handgunWeapon GVAR(center))};
};
if (!(isnull curatorCamera) && {ACE_player == player}) then {
curatorcamera cameraEffect ["internal","back"];
if (!isNull curatorCamera && {ACE_player == player}) then {
curatorCamera cameraEffect ["Internal", "BACK"];
} else {
GVAR(camera) cameraEffect ["terminate","back"];
GVAR(camera) cameraEffect ["Terminate", "BACK"];
};
};
@ -80,12 +83,13 @@ if (!isNull curatorCamera) then {
curatorCamera setVectorDirAndUp _dirAndUp;
};
if (isMultiplayer) then {
[QGVAR(broadcastFace), [GVAR(center), GVAR(currentFace)], QGVAR(center) + "_face"] call CBA_fnc_globalEventJIP;
[QGVAR(center) + "_face", GVAR(center)] call CBA_fnc_removeGlobalEventJIP;
// Make face and voice selection JIP compatible; 3DEN doesn't need this though
if (isMultiplayer && {!is3DEN}) then {
private _id = [QGVAR(broadcastFace), [GVAR(center), GVAR(currentFace)], QGVAR(centerFace_) + netId GVAR(center)] call CBA_fnc_globalEventJIP;
[_id, GVAR(center)] call CBA_fnc_removeGlobalEventJIP;
[QGVAR(broadcastVoice), [GVAR(center), GVAR(currentVoice)], QGVAR(center) + "_voice"] call CBA_fnc_globalEventJIP;
[QGVAR(center) + "_voice", GVAR(center)] call CBA_fnc_removeGlobalEventJIP;
_id = [QGVAR(broadcastVoice), [GVAR(center), GVAR(currentVoice)], QGVAR(centerVoice_) + netId GVAR(center)] call CBA_fnc_globalEventJIP;
[_id, GVAR(center)] call CBA_fnc_removeGlobalEventJIP;
};
GVAR(currentBox) = objNull;
@ -104,10 +108,12 @@ GVAR(shiftState) = nil;
GVAR(leftTabFocus) = nil;
GVAR(rightTabFocus) = nil;
GVAR(rightTabLnBFocus) = nil;
GVAR(ignoreFirstSortPanelCall) = nil;
GVAR(selectedWeaponType) = nil;
GVAR(virtualItems) = nil;
GVAR(virtualItemsFlat) = nil;
GVAR(virtualItemsFlatAll) = nil;
GVAR(currentItems) = nil;
GVAR(currentFace) = nil;
GVAR(currentVoice) = nil;

View File

@ -1,13 +1,13 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* onLoad EH for arsenal.
*
* Arguments:
* 0: Ignored
* 0: Not used
* 1: Arguments <ARRAY>
* 1.1: Arsenal display <DISPLAY>
* 1.0: Arsenal display <DISPLAY>
*
* Return Value:
* None
@ -23,7 +23,7 @@ if (isNil QGVAR(center)) then {
GVAR(center) = player;
};
GVAR(mouseButtonState) = [[],[]];
GVAR(mouseButtonState) = [[], []];
if (isNil QGVAR(sharedLoadoutsNamespace)) then {
GVAR(sharedLoadoutsNamespace) = true call CBA_fnc_createNamespace;
@ -36,171 +36,155 @@ if (isNil {GVAR(sharedLoadoutsNamespace) getVariable QGVAR(sharedLoadoutsVars)})
if (isNil QGVAR(defaultLoadoutsList)) then {
if (is3DEN) then {
GVAR(defaultLoadoutsList) = (QGVAR(DummyCategory) get3DENMissionAttribute QGVAR(DefaultLoadoutsListAttribute));
GVAR(defaultLoadoutsList) = QGVAR(DummyCategory) get3DENMissionAttribute QGVAR(DefaultLoadoutsListAttribute);
} else {
GVAR(defaultLoadoutsList) = [];
};
};
if (isNil QGVAR(virtualItems)) then {
GVAR(virtualItems) = [[[], [], []], [[], [], [], []], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []];
};
private _virtualItems = [
[IDX_VIRT_WEAPONS, createHashMapFromArray [[IDX_VIRT_PRIMARY_WEAPONS, createHashMap], [IDX_VIRT_SECONDARY_WEAPONS, createHashMap], [IDX_VIRT_HANDGUN_WEAPONS, createHashMap]]],
[IDX_VIRT_ATTACHMENTS, createHashMapFromArray [[IDX_VIRT_OPTICS_ATTACHMENTS, createHashMap], [IDX_VIRT_FLASHLIGHT_ATTACHMENTS, createHashMap], [IDX_VIRT_MUZZLE_ATTACHMENTS, createHashMap], [IDX_VIRT_BIPOD_ATTACHMENTS, createHashMap]]]
];
GVAR(currentItems) = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", [], [], [], [], [], []];
_virtualItems = createHashMapFromArray _virtualItems;
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
_virtualItems set [_index, createHashMap];
};
GVAR(virtualItems) = _virtualItems;
// Flatten out hashmaps for easy checking later
private _virtualItemsFlat = +_virtualItems;
private _weapons = _virtualItemsFlat deleteAt IDX_VIRT_WEAPONS;
private _attachments = _virtualItemsFlat deleteAt IDX_VIRT_ATTACHMENTS;
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
_virtualItemsFlat merge [_virtualItemsFlat deleteAt _index, true];
};
for "_index" from IDX_VIRT_PRIMARY_WEAPONS to IDX_VIRT_HANDGUN_WEAPONS do {
_virtualItemsFlat merge [_weapons deleteAt _index, true];
};
for "_index" from IDX_VIRT_OPTICS_ATTACHMENTS to IDX_VIRT_BIPOD_ATTACHMENTS do {
_virtualItemsFlat merge [_attachments deleteAt _index, true];
};
GVAR(virtualItemsFlat) = _virtualItemsFlat;
};
GVAR(currentFace) = face GVAR(center);
GVAR(currentVoice) = speaker GVAR(center);
GVAR(currentInsignia) = GVAR(center) param [0, objNull, [objNull]] getVariable ["BIS_fnc_setUnitInsignia_class", ""];
GVAR(currentInsignia) = GVAR(center) call BIS_fnc_getUnitInsignia;
GVAR(currentAction) = "Stand";
GVAR(shiftState) = false;
GVAR(showStats) = true;
GVAR(statsPagesLeft) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
GVAR(statsPagesRight) = [0, 0, 0, 0, 0, 0, 0, 0];
GVAR(statsPagesLeft) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
GVAR(statsPagesRight) = [0, 0, 0, 0, 0, 0, 0, 0];
GVAR(statsInfo) = [true, 0, controlNull, nil, nil];
// Cache assignedItems
private _assignedItems = (getUnitLoadout GVAR(center)) select 9;
// Add the items the player has to virtualItems
for "_index" from 0 to 14 do {
switch (_index) do {
// primary, secondary, handgun weapons
case IDX_VIRT_WEAPONS: {
private _array = LIST_DEFAULTS select _index;
if ((_array select 0) isNotEqualTo "") then {
((GVAR(virtualItems) select _index) select 0) pushBackUnique (_array select 0);
};
if ((_array select 1) isNotEqualTo "") then {
((GVAR(virtualItems) select _index) select 1) pushBackUnique (_array select 1);
};
if ((_array select 2) isNotEqualTo "") then {
((GVAR(virtualItems) select _index) select 2) pushBackUnique (_array select 2);
};
};
// Accs for the weapons above
case IDX_VIRT_ATTACHEMENTS: {
private _array = LIST_DEFAULTS select _index;
_array params ["_accsArray", "_magsArray"];
{
private _subIndex = _forEachIndex;
{
if (_x != "") then {
(GVAR(virtualItems) select _index) select ([2, 1, 0, 3] select _forEachIndex) pushBackUnique _x;
};
} forEach _x;
} forEach _accsArray;
{
if (_x isNotEqualTo []) then {
if (_x select 0 != "") then {
(GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL) pushBackUnique (_x select 0);
};
if (count _x > 1 && {_x select 1 != ""}) then {
(GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL) pushBackUnique (_x select 1);
};
};
} forEach _magsArray;
};
// Assigned items
case IDX_VIRT_MAP: { (GVAR(virtualItems) select _index) pushBackUnique (_assignedItems select 0) };
case IDX_VIRT_COMMS: { (GVAR(virtualItems) select _index) pushBackUnique (_assignedItems select 1) };
case IDX_VIRT_RADIO: { (GVAR(virtualItems) select _index) pushBackUnique (_assignedItems select 2) };
case IDX_VIRT_COMPASS: { (GVAR(virtualItems) select _index) pushBackUnique (_assignedItems select 3) };
case IDX_VIRT_WATCH: { (GVAR(virtualItems) select _index) pushBackUnique (_assignedItems select 4) };
// Inventory items
case IDX_VIRT_ITEMS_ALL: {
call FUNC(updateUniqueItemsList);
};
// The rest
default {
private _array = (LIST_DEFAULTS select _index) select {_x isNotEqualTo ""};
if (_array isNotEqualTo []) then {
{(GVAR(virtualItems) select _index) pushBackUnique _x} forEach _array;
};
};
};
};
// Fill current items
for "_index" from 0 to 15 do {
switch (_index) do {
case 0;
case 1;
case 2:{
GVAR(currentItems) set [_index, ((LIST_DEFAULTS select 0) select _index)];
};
case 3;
case 4;
case 5;
case 6;
case 7;
case 8;
case 9: {
GVAR(currentItems) set [_index, (LIST_DEFAULTS select _index) select 0];
};
case 10: {
{(GVAR(currentItems) select 15) pushBack _x} forEach (uniformItems GVAR(center));
};
case 11: {
{(GVAR(currentItems) select 16) pushBack _x} forEach (vestItems GVAR(center));
};
case 12: {
{(GVAR(currentItems) select 17) pushBack _x} forEach (backpackItems GVAR(center));
};
case 13: {
GVAR(currentItems) set [18, (primaryWeaponItems GVAR(center)) + (primaryWeaponMagazine GVAR(center))];
};
case 14: {
GVAR(currentItems) set [19, (secondaryWeaponItems GVAR(center)) + (secondaryWeaponMagazine GVAR(center))];
};
case 15: {
GVAR(currentItems) set [20, (handgunItems GVAR(center)) + (handgunMagazine GVAR(center))];
};
};
};
{
switch (_forEachIndex) do {
case 0: { // Map
GVAR(currentItems) set [10, _x];
// Primary weapon, Secondary weapon, Handgun weapon, Binoculars
case IDX_LOADOUT_PRIMARY_WEAPON;
case IDX_LOADOUT_SECONDARY_WEAPON;
case IDX_LOADOUT_HANDGUN_WEAPON;
case IDX_LOADOUT_BINO: {
_x params [["_weapon", ""], ["_muzzle", ""], ["_flashlight", ""], ["_optics", ""], ["_primaryMagazine", []], ["_secondaryMagazine", []], ["_bipod", ""]];
// Add weapon
if (_weapon != "") then {
_weapon = _weapon call FUNC(baseWeapon);
// If bino, add it in a different place than regular weapons
if (_forEachIndex != IDX_LOADOUT_BINO) then {
((GVAR(virtualItems) get IDX_VIRT_WEAPONS) get _forEachIndex) set [_weapon, nil];
} else {
(GVAR(virtualItems) get IDX_VIRT_BINO) set [_weapon, nil];
};
};
// Add weapon attachments
{
if (_x != "") then {
((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get _forEachIndex) set [_x call FUNC(baseWeapon), nil];
};
} forEach [_optics, _flashlight, _muzzle, _bipod];
// Add magazines
{
// Check if there is a magazine (ammo count is unnecssary to check)
if ((_x param [0, ""]) != "") then {
(GVAR(virtualItems) get IDX_VIRT_ITEMS_ALL) set [_x select 0, nil];
};
} forEach [_primaryMagazine, _secondaryMagazine];
};
case 1: { // GPS
GVAR(currentItems) set [14, _x];
// Uniform, vest, backpack
case IDX_LOADOUT_UNIFORM;
case IDX_LOADOUT_VEST;
case IDX_LOADOUT_BACKPACK: {
_x params [["_containerClass", ""]];
if (_containerClass != "") then {
(GVAR(virtualItems) get (_forEachIndex + 1)) set [_containerClass, nil];
};
};
case 2: { // Radio
GVAR(currentItems) set [12, _x];
// Helmet
case IDX_LOADOUT_HEADGEAR: {
if (_x != "") then {
(GVAR(virtualItems) get IDX_VIRT_HEADGEAR) set [_x, nil];
};
};
case 3: { // Compass
GVAR(currentItems) set [11, _x];
// Facewear
case IDX_LOADOUT_GOGGLES: {
if (_x != "") then {
(GVAR(virtualItems) get IDX_VIRT_GOGGLES) set [_x, nil];
};
};
case 4: { // Watch
GVAR(currentItems) set [13, _x];
// Assigned items: Map, Compass, Watch, GPS / UAV Terminal, Radio, NVGs
case IDX_LOADOUT_ASSIGNEDITEMS: {
{
// Order of storing virtualItems is different than what getUnitLoadout returns, so do some math
if (_x != "") then {
(GVAR(virtualItems) get (IDX_VIRT_NVG + ([2, 6, 4, 3, 5, 0] select _forEachIndex))) set [_x, nil];
};
} forEach _x;
};
};
} forEach _assignedItems;
} forEach (getUnitLoadout GVAR(center)); // Only need items, not extended loadout
GVAR(currentWeaponType) = switch true do {
case (currentWeapon GVAR(center) == GVAR(currentItems) select 0): {0};
case (currentWeapon GVAR(center) == GVAR(currentItems) select 1): {1};
case (currentWeapon GVAR(center) == GVAR(currentItems) select 2): {2};
default {-1};
// Get a list of all virtual items, including single panel items that are unique
private _virtualItemsFlat = +GVAR(virtualItems);
private _weapons = _virtualItemsFlat deleteAt IDX_VIRT_WEAPONS;
private _attachments = _virtualItemsFlat deleteAt IDX_VIRT_ATTACHMENTS;
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
_virtualItemsFlat merge [_virtualItemsFlat deleteAt _index, true];
};
for "_index" from IDX_VIRT_PRIMARY_WEAPONS to IDX_VIRT_HANDGUN_WEAPONS do {
_virtualItemsFlat merge [_weapons deleteAt _index, true];
};
for "_index" from IDX_VIRT_OPTICS_ATTACHMENTS to IDX_VIRT_BIPOD_ATTACHMENTS do {
_virtualItemsFlat merge [_attachments deleteAt _index, true];
};
GVAR(virtualItemsFlatAll) = _virtualItemsFlat;
// Update current item list
call FUNC(updateCurrentItemsList);
// This takes care of items that aren't available in the arsenal (either wrong tab or arsenal doesn't have it whitelisted)
call FUNC(updateUniqueItemsList);
[QGVAR(displayOpened), [_display]] call CBA_fnc_localEvent;
//--------------- Fade out unused elements
@ -250,7 +234,7 @@ if (isMultiplayer) then {
};
//--------------- Camera prep
cutText ["","plain"];
cutText ["", "PLAIN"];
showCommandingMenu "";
GVAR(cameraView) = cameraView;
@ -260,73 +244,71 @@ GVAR(center) switchCamera "internal";
private _mouseAreaCtrl = _display displayCtrl IDC_mouseArea;
ctrlSetFocus _mouseAreaCtrl;
private _centerPos = position GVAR(center);
// 3DEN support, lifted from BIS_fnc_arsenal
if (is3DEN) then {
GVAR(centerOrigin) = GVAR(center);
GVAR(centerOrigin) hideObject true;
private _centerOriginParent = objectParent GVAR(centerOrigin);
if !(isNull _centerOriginParent) then {
_centerOriginParent hideObject true;
};
private _centerPos = position GVAR(centerOrigin);
GVAR(center) = createAgent [typeOf GVAR(centerOrigin), position GVAR(centerOrigin), [], 0, "none"];
GVAR(center) setPosAtl getPosAtl GVAR(centerOrigin);
GVAR(center) = createAgent [typeOf GVAR(centerOrigin), _centerPos, [], 0, "none"];
GVAR(center) setPosATL getPosATL GVAR(centerOrigin);
GVAR(center) setDir (getDir GVAR(centerOrigin));
GVAR(center) switchMove animationState GVAR(centerOrigin);
GVAR(center) switchAction "playerstand";
GVAR(center) switchAction "playerStand";
GVAR(center) enableSimulation false;
GVAR(center) setUnitLoadout (getUnitLoadout GVAR(centerOrigin));
GVAR(center) setFace GVAR(currentFace);
GVAR(center) setSpeaker GVAR(currentVoice);
[GVAR(center), GVAR(centerOrigin) call CBA_fnc_getLoadout] call CBA_fnc_setLoadout;
//--- Create light for night editing (code based on BIS_fnc_3DENFlashlight)
private _intensity = 1;
GVAR(light) = "#lightpoint" createVehicle _centerPos;
GVAR(light) setLightBrightness _intensity;
GVAR(light) setLightAmbient [1,1,1];
GVAR(light) setLightColor [0,0,0];
GVAR(light) lightAttachObject [GVAR(centerOrigin), [0, 0, -_intensity * 7]];
GVAR(light) setLightBrightness 1;
GVAR(light) setLightAmbient [1, 1, 1];
GVAR(light) setLightColor [0, 0, 0];
GVAR(light) lightAttachObject [GVAR(centerOrigin), [0, 0, -7]];
//--- Use the same vision mode as in Eden
GVAR(visionMode)= -2 call bis_fnc_3DENVisionMode;
["ShowInterface",false] spawn bis_fnc_3DENInterface;
if (get3denactionstate "togglemap" > 0) then {do3DENAction "togglemap";};
GVAR(visionMode) = -2 call BIS_fnc_3DENVisionMode;
["ShowInterface", false] spawn BIS_fnc_3DENInterface;
if (get3DENActionState "toggleMap" > 0) then {
do3DENAction "toggleMap";
};
private _ctrl = controlNull;
{
private _ctrl = _display displayctrl _x;
_ctrl = _display displayCtrl _x;
_ctrl ctrlEnable false;
_ctrl ctrlSetFade 0.6;
_ctrl ctrlCommit 0;
} forEach [
IDC_buttonFace,
IDC_buttonVoice,
IDC_buttonInsignia
];
} forEach [IDC_buttonFace, IDC_buttonVoice, IDC_buttonInsignia];
_buttonCloseCtrl = _display displayCtrl IDC_menuBarClose;
_buttonCloseCtrl ctrlSetText (localize "str_ui_debug_but_apply");
} else {
GVAR(centerNotPlayer) = (GVAR(center) != player);
GVAR(centerNotPlayer) = GVAR(center) != player;
if (currentVisionMode ACE_Player == 1) then {
GVAR(center) action ["NVGogglesOff", GVAR(center)];
};
private _ctrl = controlNull;
{
private _ctrl = _display displayCtrl _x;
_ctrl = _display displayCtrl _x;
_ctrl ctrlEnable GVAR(enableIdentityTabs);
_ctrl ctrlSetFade ([0.6, 0] select GVAR(enableIdentityTabs));
_ctrl ctrlCommit 0;
} forEach [
IDC_buttonFace,
IDC_buttonVoice,
IDC_buttonInsignia
];
} forEach [IDC_buttonFace, IDC_buttonVoice, IDC_buttonInsignia];
};
//--------------- Prepare the left panel
@ -337,6 +319,7 @@ GVAR(rightSearchbarFocus) = false;
GVAR(leftTabFocus) = false;
GVAR(rightTabFocus) = false;
GVAR(rightTabLnBFocus) = false;
GVAR(ignoreFirstSortPanelCall) = false;
{
private _panel = _display displayCtrl _x;
@ -348,26 +331,28 @@ GVAR(rightTabLnBFocus) = false;
//--------------- Init camera
if (isNil QGVAR(cameraPosition)) then {
GVAR(cameraPosition) = [5,0,0,[0,0,0.85]];
GVAR(cameraPosition) = [5, 0, 0, [0, 0, 0.85]];
};
// Save curator camera state so camera position and direction are not modified while using arsenal
if (!isNull curatorCamera) then {
GVAR(curatorCameraData) = [getPosASL curatorCamera, [vectorDir curatorCamera, vectorUp curatorCamera]];
private _curatorCamera = curatorCamera;
if (!isNull _curatorCamera) then {
GVAR(curatorCameraData) = [getPosASL _curatorCamera, [vectorDir _curatorCamera, vectorUp _curatorCamera]];
};
GVAR(cameraHelper) = createAgent ["Logic", position GVAR(center) ,[] ,0 ,"none"];
GVAR(cameraHelper) = createAgent ["Logic", _centerPos, [], 0, "none"];
GVAR(cameraHelper) attachTo [GVAR(center), GVAR(cameraPosition) select 3, ""];
GVAR(camera) = "camera" camCreate position GVAR(center);
GVAR(camera) cameraEffect ["internal","back"];
GVAR(camera) camPrepareFocus [-1,-1];
GVAR(camera) = "camera" camCreate _centerPos;
GVAR(camera) cameraEffect ["internal", "back"];
GVAR(camera) camPrepareFocus [-1, -1];
GVAR(camera) camPrepareFov 0.35;
GVAR(camera) camCommitPrepared 0;
showCinemaBorder false;
["#(argb,8,8,3)color(0,0,0,1)",false,nil,0,[0,0.5]] call bis_fnc_textTiles;
["#(argb,8,8,3)color(0,0,0,1)", false, nil, 0, [0, 0.5]] call BIS_fnc_textTiles;
//--------------- Reset camera pos
[nil, [controlNull,0,0]] call FUNC(handleMouse);
GVAR(camPosUpdateHandle) = addMissionEventHandler ["draw3D",{ [] call FUNC(updateCamPos) }];
[nil, [controlNull, 0, 0]] call FUNC(handleMouse);
GVAR(camPosUpdateHandle) = addMissionEventHandler ["draw3D", {call FUNC(updateCamPos)}];

View File

@ -2,12 +2,12 @@
#include "..\defines.hpp"
#include "\a3\ui_f\hpp\defineDIKCodes.inc"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Handles keyboard inputs in arsenal.
*
* Arguments:
* 0: Arsenal display <DISPLAY>
* 1: Key being pressed <SCALAR>
* 1: Key being pressed <NUMBER>
* 2: Shift state <BOOL>
* 3: Ctrl state <BOOL>
* 4: Alt state <BOOL>
@ -25,12 +25,14 @@ GVAR(shiftState) = _shiftState;
private _return = true;
private _loadoutsDisplay = findDisplay IDD_loadouts_display;
if (_loadoutsDisplay isNotEqualTo displayNull) then {
if !(GVAR(loadoutsSearchbarFocus)) then {
switch true do {
// If in loadout screen
if (!isNull _loadoutsDisplay) then {
// If loadout search bar isn't focussed
if (!GVAR(loadoutsSearchbarFocus)) then {
switch (true) do {
// Close button
case (_keyPressed == DIK_ESCAPE): {
_display closeDisplay 2;
_display closeDisplay IDC_CANCEL;
};
// Search field
case (_keyPressed == DIK_F && {_ctrlState}): {
@ -38,48 +40,37 @@ if (_loadoutsDisplay isNotEqualTo displayNull) then {
};
};
} else {
switch true do {
// If loadout search bar is focussed
switch (true) do {
// Close button
case (_keyPressed == DIK_ESCAPE): {
_display closeDisplay 2;
};
case (_keyPressed == DIK_BACKSPACE): {
_return = false;
_display closeDisplay IDC_CANCEL;
};
// Search
case (_keyPressed == DIK_NUMPADENTER);
case (_keyPressed == DIK_RETURN): {
[_loadoutsDisplay, _loadoutsDisplay displayCtrl IDC_loadoutsSearchbar] call FUNC(handleLoadoutsSearchBar);
};
case (_keyPressed == DIK_BACKSPACE);
case (_keyPressed in [DIK_LEFT, DIK_RIGHT]): {
_return = false;
};
};
};
switch true do {
case (_keyPressed == DIK_C && {_ctrlState}): {
_return = false;
};
case (_keyPressed == DIK_V && {_ctrlState}): {
_return = false;
};
case (_keyPressed == DIK_A && {_ctrlState}): {
_return = false;
};
case (_keyPressed == DIK_X && {_ctrlState}): {
_return = false;
};
switch (true) do {
case (_keyPressed in [DIK_C, DIK_V, DIK_A, DIK_X] && {_ctrlState});
case (GVAR(loadoutsPanelFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}): {
_return = false;
};
};
} else {
// If in arsenal and no search bar is selected
if (!GVAR(leftSearchbarFocus) && {!GVAR(rightSearchbarFocus)}) then {
switch true do {
switch (true) do {
// Close button
case (_keyPressed == DIK_ESCAPE): {
_display closeDisplay 2;
_display closeDisplay IDC_CANCEL;
};
// Hide button
case (_keyPressed == DIK_BACKSPACE): {
@ -88,7 +79,7 @@ if (_loadoutsDisplay isNotEqualTo displayNull) then {
// Export button / export classname
case (_keyPressed == DIK_C && {_ctrlState}): {
if (GVAR(leftTabFocus) || {GVAR(rightTabFocus)} || {GVAR(rightTabLnBFocus)}) then {
switch true do {
switch (true) do {
case (GVAR(leftTabFocus)): {
private _control = (_display displayCtrl IDC_leftTabContent);
_control lbData (lbCurSel _control)
@ -99,14 +90,14 @@ if (_loadoutsDisplay isNotEqualTo displayNull) then {
};
case (GVAR(rightTabLnBFocus)): {
private _control = (_display displayCtrl IDC_rightTabContentListnBox);
_control lnbData [(lnbCurSelRow _control), 0]
_control lnbData [lnbCurSelRow _control, 0]
};
} params ["_className"];
"ace_clipboard" callExtension (_className + ";");
"ace_clipboard" callExtension "--COMPLETE--";
[_display, localize LSTRING(exportedClassnameText)] call FUNC(message);
[_display, LLSTRING(exportedClassnameText)] call FUNC(message);
} else {
[_display] call FUNC(buttonExport);
};
@ -115,36 +106,37 @@ if (_loadoutsDisplay isNotEqualTo displayNull) then {
case (_keyPressed == DIK_V && {_ctrlState}): {
[_display] call FUNC(buttonImport);
};
// Search fields
// Focus search
case (_keyPressed == DIK_F && {_ctrlState}): {
ctrlSetFocus (_display displayCtrl IDC_leftSearchbar);
};
// Switch vision mode
case (_keyPressed in (actionkeys "nightvision")): {
case (_keyPressed in (actionKeys "nightvision")): {
if (isNil QGVAR(visionMode)) then {
GVAR(visionMode) = 0;
};
GVAR(visionMode) = (GVAR(visionMode) + 1) % 3;
switch GVAR(visionMode) do {
//--- Normal
switch (GVAR(visionMode)) do {
// Normal
case 0: {
camusenvg false;
false setCamUseTi 0;
camUseNVG false;
false setCamUseTI 0;
};
//--- NVG
// NVG
case 1: {
camusenvg true;
false setCamUseTi 0;
camUseNVG true;
false setCamUseTI 0;
};
//--- TI
// TI
default {
camusenvg false;
true setCamUseTi 0;
camUseNVG false;
true setCamUseTI 0;
};
};
playsound ["RscDisplayCurator_visionMode",true];
playSound ["RscDisplayCurator_visionMode", true];
};
// Panel up down
case (_keyPressed in [DIK_UP, DIK_DOWN]): {
@ -160,38 +152,29 @@ if (_loadoutsDisplay isNotEqualTo displayNull) then {
};
};
} else {
switch true do {
// If in arsenal and a search bar is selected
switch (true) do {
// Close button
case (_keyPressed == DIK_ESCAPE): {
_display closeDisplay 2;
};
case (_keyPressed == DIK_BACKSPACE): {
_return = false;
_display closeDisplay IDC_CANCEL;
};
// Search
case (_keyPressed == DIK_NUMPADENTER);
case (_keyPressed == DIK_RETURN): {
if (GVAR(leftSearchbarFocus)) then {
[_display, _display displayCtrl IDC_leftSearchbar] call FUNC(handleSearchBar);
};
if (GVAR(rightSearchbarFocus)) then {
[_display, _display displayCtrl IDC_rightSearchbar] call FUNC(handleSearchBar);
};
};
case (_keyPressed in [DIK_LEFT, DIK_RIGHT]): {
case (_keyPressed in [DIK_LEFT, DIK_RIGHT]);
case (_keyPressed == DIK_BACKSPACE);
case (_keyPressed in [DIK_C, DIK_V, DIK_A, DIK_X] && {_ctrlState}): {
_return = false;
};
case (_keyPressed == DIK_C && {_ctrlState}): {
_return = false;
};
case (_keyPressed == DIK_V && {_ctrlState}): {
_return = false;
};
case (_keyPressed == DIK_A && {_ctrlState}): {
_return = false;
};
case (_keyPressed == DIK_X && {_ctrlState}): {
_return = false;
};
// Search fields
// Focus search fields
case (_keyPressed == DIK_F && {_ctrlState}): {
if (GVAR(rightSearchbarFocus)) then {
ctrlSetFocus (_display displayCtrl IDC_leftSearchbar);

View File

@ -14,13 +14,11 @@
*/
GVAR(currentLoadoutsTab) = nil;
private _arsenalDisplay = findDisplay IDD_ace_arsenal;
private _mouseBlockCtrl = _arsenalDisplay displayCtrl IDC_mouseBlock;
GVAR(loadoutsSearchbarFocus) = nil;
GVAR(loadoutsPanelFocus) = nil;
private _arsenalDisplay = findDisplay IDD_ace_arsenal;
private _mouseBlockCtrl = _arsenalDisplay displayCtrl IDC_mouseBlock;
_mouseBlockCtrl ctrlEnable false;
_mouseBlockCtrl ctrlCommit 0;
@ -28,4 +26,4 @@ _mouseBlockCtrl ctrlCommit 0;
[QGVAR(loadoutsDisplayClosed), []] call CBA_fnc_localEvent;
[_arsenalDisplay , _arsenalDisplay displayCtrl GVAR(currentLeftPanel)] call FUNC(fillLeftPanel);
[_arsenalDisplay, _arsenalDisplay displayCtrl GVAR(currentLeftPanel)] call FUNC(fillLeftPanel);

View File

@ -5,9 +5,9 @@
* onLoad EH for arsenal loadouts display.
*
* Arguments:
* 0: Ignored
* 0: Not used
* 1: Arguments <ARRAY>
* 1.1: Loadouts display <DISPLAY>
* 1.0: Loadouts display <DISPLAY>
*
* Return Value:
* None
@ -34,6 +34,7 @@ private _panelContentCtrl = _display displayCtrl IDC_contentPanel;
_panelContentCtrl ctrlSetFontHeight (4.5 * GRID_H);
_panelContentCtrl ctrlCommit 0;
// If default loadouts are disabled, disable button
if !(GVAR(allowDefaultLoadouts)) then {
private _buttonDefaultLoadoutsCtrl = _display displayCtrl IDC_buttonDefaultLoadouts;
_buttonDefaultLoadoutsCtrl ctrlEnable false;
@ -44,6 +45,7 @@ if !(GVAR(allowDefaultLoadouts)) then {
_buttonDefaultLoadoutsBackgroundCtrl ctrlCommit 0;
};
// If shared loadouts are disabled or it's singleplayer, disable button
if !(GVAR(allowSharedLoadouts) && {isMultiplayer}) then {
private _buttonShareLoadoutsCtrl = _display displayCtrl IDC_buttonSharedLoadouts;
_buttonShareLoadoutsCtrl ctrlEnable false;

View File

@ -1,6 +1,18 @@
#include "script_component.hpp"
/*
* Author: commy2
* Handles mouse button press.
*
* Arguments:
* 0: Not used
* 1: Args <ARRAY>
* 1.0: Not used
* 1.1: Mouse button <NUMBER>
* 1.2: Mouse X position <NUMBER>
* 1.3: Mouse Y position <NUMBER>
*
* Return Value:
* None
*
* Public: No
*/

View File

@ -1,6 +1,16 @@
#include "script_component.hpp"
/*
* Author: commy2
* Handles mouse button release.
*
* Arguments:
* 0: Not used
* 1: Args <ARRAY>
* 1.0: Not used
* 1.1: Mouse button <NUMBER>
*
* Return Value:
* None
*
* Public: No
*/

View File

@ -1,12 +1,13 @@
#include "script_component.hpp"
#include "..\defines.hpp"
#include "\a3\ui_f\hpp\defineResincl.inc"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Handles selection changes on the left panel.
*
* Arguments:
* 0: Left panel control <CONTROL>
* 1: Left panel selection <SCALAR>
* 1: Left panel selection <NUMBER>
*
* Return Value:
* None
@ -18,429 +19,678 @@ params ["_control", "_curSel"];
if (_curSel < 0) exitwith {};
private _ctrlIDC = ctrlIDC _control;
private _display = ctrlParent _control;
private _item = [_control lnbData [_curSel, 0], _control lbData _curSel] select !(ctrlType _control == 102);
private _item = [_control lbData _curSel, _control lnbData [_curSel, 0]] select (ctrlType _control == CT_LISTNBOX);
private _weaponDefaultRightPanel = _display displayCtrl IDC_buttonOptic;
private _selectCorrectPanelWeapon = [_weaponDefaultRightPanel, _display displayCtrl GVAR(currentRightPanel)] select (!isNil QGVAR(currentRightPanel) && {GVAR(currentRightPanel) in [RIGHT_PANEL_ACC_IDCS, IDC_buttonCurrentMag, IDC_buttonCurrentMag2]});
// When having chosen a new category, see if the current right panel can be kept open, otherwise take default
private _selectCorrectPanelWeapon = [_display displayCtrl IDC_buttonOptic, _display displayCtrl GVAR(currentRightPanel)] select (!isNil QGVAR(currentRightPanel) && {GVAR(currentRightPanel) in [RIGHT_PANEL_ACC_IDCS, IDC_buttonCurrentMag, IDC_buttonCurrentMag2]});
private _selectCorrectPanelContainer = [_display displayCtrl IDC_buttonMisc, _display displayCtrl GVAR(currentRightPanel)] select (!isNil QGVAR(currentRightPanel) && {GVAR(currentRightPanel) in [RIGHT_PANEL_ITEMS_IDCS]});
private _containerDefaultRightPanel = _display displayCtrl IDC_buttonMisc;
private _selectCorrectPanelContainer = [_containerDefaultRightPanel, _display displayCtrl GVAR(currentRightPanel)] select (!isNil QGVAR(currentRightPanel) && {GVAR(currentRightPanel) in [RIGHT_PANEL_ITEMS_IDCS]});
private _fnc_clearPreviousWepMags = {
private _compatibleMagsBaseWeapon = [_baseWeapon, true] call CBA_fnc_compatibleMagazines;
// Remove all magazines from the current weapon that aren't compatible with the new weapon
private _fnc_clearCurrentWeaponMags = {
private _compatibleMagsCurrentWeapon = compatibleMagazines _currentWeapon;
// If nothing was selected, remove all magazines from the current weapon
if (_item != "") then {
_compatibleMagsBaseWeapon = _compatibleMagsBaseWeapon select {!(_x in _compatibleMags)};
_compatibleMagsCurrentWeapon = _compatibleMagsCurrentWeapon - _compatibleMags;
};
{
GVAR(center) removeMagazines _x;
} foreach _compatibleMagsBaseWeapon;
} forEach _compatibleMagsCurrentWeapon;
GVAR(currentItems) set [15, uniformItems GVAR(center)];
GVAR(currentItems) set [16, vestItems GVAR(center)];
GVAR(currentItems) set [17, backpackItems GVAR(center)];
// Update currentItems
private _loadout = getUnitLoadout GVAR(center);
GVAR(currentItems) set [IDX_CURR_UNIFORM_ITEMS, (_loadout select IDX_LOADOUT_UNIFORM) param [1, []]];
GVAR(currentItems) set [IDX_CURR_VEST_ITEMS, (_loadout select IDX_LOADOUT_VEST) param [1, []]];
GVAR(currentItems) set [IDX_CURR_BACKPACK_ITEMS, (_loadout select IDX_LOADOUT_BACKPACK) param [1, []]];
};
// Check which right panel has changed
switch (GVAR(currentLeftPanel)) do {
// Primary weapon
case IDC_buttonPrimaryWeapon: {
private _currentWeapon = GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON;
case IDC_buttonPrimaryWeapon : {
private _baseWeapon = ((GVAR(currentItems) select 0) call bis_fnc_baseWeapon);
// If nothing selected, remove primary weapon and its magazines
if (_item == "") then {
call _fnc_clearPreviousWepMags;
call _fnc_clearCurrentWeaponMags;
GVAR(center) removeWeapon (primaryWeapon GVAR(center));
GVAR(currentItems) set [18, ["", "", "", "", "", ""]];
GVAR(currentItems) set [0, _item];
GVAR(currentItems) set [IDX_CURR_PRIMARY_WEAPON_ITEMS, ["", "", "", "", "", ""]];
GVAR(currentItems) set [IDX_CURR_PRIMARY_WEAPON, ""];
TOGGLE_RIGHT_PANEL_HIDE
} else {
if ((GVAR(currentItems) select 0) != _item && {_baseWeapon != _item}) then {
private _compatibleItems = (_item call bis_fnc_compatibleItems) apply {tolower _x};
private _cfgMags = configFile >> "CfgMagazines";
private _compatibleMags = ([_item, true] call CBA_fnc_compatibleMagazines) select { getNumber (_cfgMags >> _x >> "scope") == 2 };
// Check if a new primary weapon was selected
if (_item != _currentWeapon) then {
// Get magazines that are compatible with the new weapon
private _compatibleMags = compatibleMagazines _item;
call _fnc_clearPreviousWepMags;
// Remove all magazines from the current weapon that aren't compatible with the new one
call _fnc_clearCurrentWeaponMags;
[GVAR(center), _item] call CBA_fnc_addWeaponWithoutItems;
if (_compatibleMags isNotEqualTo []) then {
GVAR(center) addWeaponItem [_item, [_compatibleMags select 0], true];
// Add new weapon without taking a magazine from the inventory
[GVAR(center), _item] call EFUNC(common,addWeapon);
private _linkedItems = primaryWeaponItems GVAR(center) - [""];
// Remove linked items if unavailable
if (_linkedItems isNotEqualTo []) then {
{
if !(_x in GVAR(virtualItemsFlat)) then {
GVAR(center) removePrimaryWeaponItem _x;
};
} forEach _linkedItems;
};
// Add old attachments and magazines back if they are compatible
{
if (tolower _x in _compatibleItems || {_x in _compatibleMags}) then {
GVAR(center) addPrimaryWeaponItem _x;
if (_item canAdd _x) then {
GVAR(center) addWeaponItem [_item, _x, true];
};
} foreach (GVAR(currentItems) select 18);
} forEach (GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON_ITEMS);
private _primaryMags = primaryWeaponMagazine GVAR(center);
GVAR(currentItems) set [18, (primaryWeaponItems GVAR(center)) + ([_primaryMags + [""], _primaryMags] select (count _primaryMags > 1))];
GVAR(currentItems) set [0, _item];
(getUnitLoadout GVAR(center) select IDX_LOADOUT_PRIMARY_WEAPON) params ["", "_muzzle", "_flashlight", "_optics", "_primaryMagazine", "_secondaryMagazine", "_bipod"];
_primaryMagazine = _primaryMagazine param [0, ""];
// Add a magazine to the primary muzzle if empty
if (_primaryMagazine == "") then {
// Get magazines that are compatible with the new weapon's primary muzzle only
private _compatibleMagsPrimaryMuzzle = compatibleMagazines [_item, "this"];
private _compatibleMagIndex = _compatibleMagsPrimaryMuzzle findAny (keys (GVAR(virtualItems) get IDX_VIRT_ITEMS_ALL));
if (_compatibleMagIndex != -1) then {
_primaryMagazine = _compatibleMagsPrimaryMuzzle select _compatibleMagIndex;
GVAR(center) addWeaponItem [_item, _primaryMagazine, true];
};
};
// Update currentItems
GVAR(currentItems) set [IDX_CURR_PRIMARY_WEAPON_ITEMS, [_muzzle, _flashlight, _optics, _bipod, _primaryMagazine, _secondaryMagazine param [0, ""]]];
GVAR(currentItems) set [IDX_CURR_PRIMARY_WEAPON, _item];
};
TOGGLE_RIGHT_PANEL_WEAPON
[_display, _selectCorrectPanelWeapon] call FUNC(fillRightPanel);
};
// Make unit switch to new item
call FUNC(showItem);
[_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo);
// Display new items's info on the bottom right
[_display, _control, _curSel, configFile >> "CfgWeapons" >> _item] call FUNC(itemInfo);
};
// Handgun weapon
case IDC_buttonHandgun: {
private _currentWeapon = GVAR(currentItems) select IDX_CURR_HANDGUN_WEAPON;
case IDC_buttonHandgun : {
private _baseWeapon = ((GVAR(currentItems) select 2) call bis_fnc_baseWeapon);
// If nothing selected, remove handgun weapon and its magazines
if (_item == "") then {
call _fnc_clearPreviousWepMags;
call _fnc_clearCurrentWeaponMags;
GVAR(center) removeWeapon (handgunWeapon GVAR(center));
GVAR(currentItems) set [18, ["", "", "", "", "", ""]];
GVAR(currentItems) set [2, _item];
GVAR(currentItems) set [IDX_CURR_HANDGUN_WEAPON_ITEMS, ["", "", "", "", "", ""]];
GVAR(currentItems) set [IDX_CURR_HANDGUN_WEAPON, ""];
TOGGLE_RIGHT_PANEL_HIDE
} else {
if ((GVAR(currentItems) select 2) != _item && {_baseWeapon != _item}) then {
private _compatibleItems = (_item call bis_fnc_compatibleItems) apply {tolower _x};
private _cfgMags = configFile >> "CfgMagazines";
private _compatibleMags = ([_item, true] call CBA_fnc_compatibleMagazines) select { getNumber (_cfgMags >> _x >> "scope") == 2 };
// Check if a new handgun weapon was selected
if (_item != _currentWeapon) then {
// Get magazines that are compatible with the new weapon
private _compatibleMags = compatibleMagazines _item;
call _fnc_clearPreviousWepMags;
// Remove all magazines from the current weapon that aren't compatible with the new one
call _fnc_clearCurrentWeaponMags;
[GVAR(center), _item] call CBA_fnc_addWeaponWithoutItems;
if (_compatibleMags isNotEqualTo []) then {
GVAR(center) addWeaponItem [_item, [_compatibleMags select 0], true];
// Add new weapon without taking a magazine from the inventory
[GVAR(center), _item] call EFUNC(common,addWeapon);
private _linkedItems = handgunItems GVAR(center) - [""];
// Remove linked items if unavailable
if (_linkedItems isNotEqualTo []) then {
{
if !(_x in GVAR(virtualItemsFlat)) then {
GVAR(center) removeHandgunItem _x;
};
} forEach _linkedItems;
};
// Add old attachments and magazines back if they are compatible
{
if (tolower _x in _compatibleItems || {_x in _compatibleMags}) then {
GVAR(center) addHandgunItem _x;
};
} foreach (GVAR(currentItems) select 20);
private _handgunMags = handgunMagazine GVAR(center);
GVAR(currentItems) set [20, (handgunItems GVAR(center)) + ([_handgunMags + [""], _handgunMags] select (count _handgunMags > 1))];
GVAR(currentItems) set [2, _item];
if (_item canAdd _x) then {
GVAR(center) addWeaponItem [_item, _x, true];
};
} forEach (GVAR(currentItems) select IDX_CURR_HANDGUN_WEAPON_ITEMS);
(getUnitLoadout GVAR(center) select IDX_LOADOUT_HANDGUN_WEAPON) params ["", "_muzzle", "_flashlight", "_optics", "_primaryMagazine", "_secondaryMagazine", "_bipod"];
_primaryMagazine = _primaryMagazine param [0, ""];
// Add a magazine to the primary muzzle if empty
if (_primaryMagazine == "") then {
// Get magazines that are compatible with the new weapon's primary muzzle only
private _compatibleMagsPrimaryMuzzle = compatibleMagazines [_item, "this"];
private _compatibleMagIndex = _compatibleMagsPrimaryMuzzle findAny (keys (GVAR(virtualItems) get IDX_VIRT_ITEMS_ALL));
if (_compatibleMagIndex != -1) then {
_primaryMagazine = _compatibleMagsPrimaryMuzzle select _compatibleMagIndex;
GVAR(center) addWeaponItem [_item, _primaryMagazine, true];
};
};
// Update currentItems
GVAR(currentItems) set [IDX_CURR_HANDGUN_WEAPON_ITEMS, [_muzzle, _flashlight, _optics, _bipod, _primaryMagazine, _secondaryMagazine param [0, ""]]];
GVAR(currentItems) set [IDX_CURR_HANDGUN_WEAPON, _item];
};
TOGGLE_RIGHT_PANEL_WEAPON
[_display, [_selectCorrectPanelWeapon, _weaponDefaultRightPanel] select (GVAR(currentRightPanel) == IDC_buttonCurrentMag2)] call FUNC(fillRightPanel);
[_display, _selectCorrectPanelWeapon] call FUNC(fillRightPanel);
};
// Make unit switch to new item
call FUNC(showItem);
[_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo);
// Display new items's info on the bottom right
[_display, _control, _curSel, configFile >> "CfgWeapons" >> _item] call FUNC(itemInfo);
};
// Secondary weapon
case IDC_buttonSecondaryWeapon: {
private _currentWeapon = GVAR(currentItems) select IDX_CURR_SECONDARY_WEAPON;
private _isDisposable = _item in (uiNamespace getVariable QGVAR(CBAdisposableLaunchers));
case IDC_buttonSecondaryWeapon : {
private _baseWeapon = ((GVAR(currentItems) select 1) call bis_fnc_baseWeapon);
// If nothing selected, remove secondary weapon and its magazines
if (_item == "") then {
call _fnc_clearPreviousWepMags;
call _fnc_clearCurrentWeaponMags;
GVAR(center) removeWeapon (secondaryWeapon GVAR(center));
GVAR(currentItems) set [18, ["", "", "", "", "", ""]];
GVAR(currentItems) set [1, _item];
GVAR(currentItems) set [IDX_CURR_SECONDARY_WEAPON_ITEMS, ["", "", "", "", "", ""]];
GVAR(currentItems) set [IDX_CURR_SECONDARY_WEAPON, ""];
TOGGLE_RIGHT_PANEL_HIDE
} else {
if ((GVAR(currentItems) select 1) != _item && {_baseWeapon != _item}) then {
private _compatibleItems = (_item call bis_fnc_compatibleItems) apply {tolower _x};
private _cfgMags = configFile >> "CfgMagazines";
private _compatibleMags = ([_item, true] call CBA_fnc_compatibleMagazines) select { getNumber (_cfgMags >> _x >> "scope") == 2 };
// Check if a new secondary weapon was selected
if (_item != _currentWeapon) then {
// Get magazines that are compatible with the new weapon
private _compatibleMags = compatibleMagazines _item;
call _fnc_clearPreviousWepMags;
// Remove all magazines from the current weapon that aren't compatible with the new one
call _fnc_clearCurrentWeaponMags;
[GVAR(center), _item] call CBA_fnc_addWeaponWithoutItems;
if (_compatibleMags isNotEqualTo []) then {
GVAR(center) addWeaponItem [_item, [_compatibleMags select 0], true];
// Add new weapon without taking a magazine from the inventory
[GVAR(center), _item] call EFUNC(common,addWeapon);
private _linkedItems = secondaryWeaponItems GVAR(center) - [""];
// Remove linked items if unavailable
if (_linkedItems isNotEqualTo []) then {
{
if !(_x in GVAR(virtualItemsFlat)) then {
GVAR(center) removeSecondaryWeaponItem _x;
};
} forEach _linkedItems;
};
// Add old attachments and magazines back if they are compatible
{
if (tolower _x in _compatibleItems || {_x in _compatibleMags}) then {
GVAR(center) addSecondaryWeaponItem _x;
if (_item canAdd _x) then {
GVAR(center) addWeaponItem [_item, _x, true];
};
} foreach (GVAR(currentItems) select 19);
} forEach (GVAR(currentItems) select IDX_CURR_SECONDARY_WEAPON_ITEMS);
private _secondaryMags = secondaryWeaponMagazine GVAR(center);
GVAR(currentItems) set [19, (secondaryWeaponItems GVAR(center)) + ([_secondaryMags + [""], _secondaryMags] select (count _secondaryMags > 1))];
GVAR(currentItems) set [1, _item];
(getUnitLoadout GVAR(center) select IDX_LOADOUT_SECONDARY_WEAPON) params ["", "_muzzle", "_flashlight", "_optics", "_primaryMagazine", "_secondaryMagazine", "_bipod"];
_primaryMagazine = _primaryMagazine param [0, ""];
// Add a magazine to the primary muzzle if empty
if (_primaryMagazine == "") then {
// Get magazines that are compatible with the new weapon's primary muzzle only
private _compatibleMagsPrimaryMuzzle = compatibleMagazines [_item, "this"];
private _compatibleMagIndex = _compatibleMagsPrimaryMuzzle findAny (keys (GVAR(virtualItems) get IDX_VIRT_ITEMS_ALL));
if (_compatibleMagIndex != -1) then {
_primaryMagazine = _compatibleMagsPrimaryMuzzle select _compatibleMagIndex;
GVAR(center) addWeaponItem [_item, _primaryMagazine, true];
};
};
// Update currentItems
GVAR(currentItems) set [IDX_CURR_SECONDARY_WEAPON_ITEMS, [_muzzle, _flashlight, _optics, _bipod, _primaryMagazine, _secondaryMagazine param [0, ""]]];
GVAR(currentItems) set [IDX_CURR_SECONDARY_WEAPON, _item];
};
TOGGLE_RIGHT_PANEL_WEAPON
[_display, [_selectCorrectPanelWeapon, _weaponDefaultRightPanel] select (GVAR(currentRightPanel) == IDC_buttonCurrentMag2)] call FUNC(fillRightPanel);
// If item is a disposable launcher, delay a bit to show new compatible items
if (_isDisposable) then {
[{
_this call FUNC(fillRightPanel);
}, [_display, _selectCorrectPanelWeapon]] call CBA_fnc_execNextFrame;
} else {
[_display, _selectCorrectPanelWeapon] call FUNC(fillRightPanel);
};
};
call FUNC(showItem);
[_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo);
// If item is a disposable launcher, delay a bit to show new compatible items
if (_isDisposable) then {
[{
// Make unit switch to new item
call FUNC(showItem);
// Display new items's info on the bottom right
_this call FUNC(itemInfo);
}, [_display, _control, _curSel, configFile >> "CfgWeapons" >> _item]] call CBA_fnc_execNextFrame;
} else {
// Make unit switch to new item
call FUNC(showItem);
// Display new items's info on the bottom right
[_display, _control, _curSel, configFile >> "CfgWeapons" >> _item] call FUNC(itemInfo);
};
};
case IDC_buttonHeadgear : {
// Headgear
case IDC_buttonHeadgear: {
if (_item == "") then {
removeHeadgear GVAR(center);
GVAR(currentItems) set [3, _item];
GVAR(currentItems) set [IDX_CURR_HEADGEAR, ""];
} else {
if ((GVAR(currentItems) select 3) != _item) then {
if ((GVAR(currentItems) select IDX_CURR_HEADGEAR) != _item) then {
GVAR(center) addHeadgear _item;
GVAR(currentItems) set [3, _item];
GVAR(currentItems) set [IDX_CURR_HEADGEAR, _item];
};
};
// Make unit switch to new item
call FUNC(showItem);
TOGGLE_RIGHT_PANEL_HIDE
[_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo);
// Display new items's info on the bottom right
[_display, _control, _curSel, configFile >> "CfgWeapons" >> _item] call FUNC(itemInfo);
};
case IDC_buttonUniform : {
// Uniform
case IDC_buttonUniform: {
if (_item == "") then {
removeUniform GVAR(center);
GVAR(currentItems) set [IDX_CURR_UNIFORM_ITEMS, []];
GVAR(currentItems) set [IDX_CURR_UNIFORM, ""];
removeuniform GVAR(center);
GVAR(currentItems) set [15, []];
GVAR(currentItems) set [4, _item];
TOGGLE_RIGHT_PANEL_HIDE
} else {
if ((GVAR(currentItems) select IDX_CURR_UNIFORM) != _item) then {
// Get the unit's current loadout and just change the container
private _loadout = getUnitLoadout GVAR(center);
_loadout set [IDX_LOADOUT_UNIFORM, [_item, GVAR(currentItems) select IDX_CURR_UNIFORM_ITEMS]];
GVAR(center) setUnitLoadout _loadout;
if ((GVAR(currentItems) select 4) != _item) then {
GVAR(center) forceAddUniform _item;
private _uniformItems = uniformItems GVAR(center);
private _index = count _uniformItems - 1;
while {count uniformItems GVAR(center) > 0} do {
GVAR(center) removeItemFromUniform (uniformItems GVAR(center) select 0);
}; //--- Remove default config contents
// Remove any items that can't fit in the container (this prevents overloading)
while {loadUniform GVAR(center) > 1 && {_index >= 0}} do {
GVAR(center) removeItemFromUniform (_uniformItems select _index);
DEC(_index);
};
{GVAR(center) addItemtoUniform _x} foreach (GVAR(currentItems) select 15);
GVAR(currentItems) set [4, _item];
GVAR(currentItems) set [IDX_CURR_UNIFORM, _item];
[GVAR(center), ""] call bis_fnc_setUnitInsignia;
[GVAR(center), GVAR(currentInsignia)] call bis_fnc_setUnitInsignia;
[GVAR(center), ""] call BIS_fnc_setUnitInsignia;
[GVAR(center), GVAR(currentInsignia)] call BIS_fnc_setUnitInsignia;
};
TOGGLE_RIGHT_PANEL_CONTAINER
[_display, _selectCorrectPanelContainer] call FUNC(fillRightPanel);
};
// Make unit switch to new item
call FUNC(showItem);
[_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo);
};
// Display new items's info on the bottom right
[_display, _control, _curSel, configFile >> "CfgWeapons" >> _item] call FUNC(itemInfo);
};
// Vest
case IDC_buttonVest: {
if (_item == "") then {
removeVest GVAR(center);
GVAR(currentItems) set [16, []];
GVAR(currentItems) set [5, _item];
GVAR(currentItems) set [IDX_CURR_VEST_ITEMS, []];
GVAR(currentItems) set [IDX_CURR_VEST, ""];
TOGGLE_RIGHT_PANEL_HIDE
} else {
if ((GVAR(currentItems) select IDX_CURR_VEST) != _item) then {
// Get the unit's current loadout and just change the container
private _loadout = getUnitLoadout GVAR(center);
_loadout set [IDX_LOADOUT_VEST, [_item, GVAR(currentItems) select IDX_CURR_VEST_ITEMS]];
GVAR(center) setUnitLoadout _loadout;
if ((GVAR(currentItems) select 5) != _item) then {
GVAR(center) addVest _item;
while {count vestItems GVAR(center) > 0} do {
GVAR(center) removeItemFromVest (VestItems GVAR(center) select 0);
}; //--- Remove default config contents
{GVAR(center) addItemToVest _x} foreach (GVAR(currentItems) select 16);
private _vestItems = vestItems GVAR(center);
private _index = count _vestItems - 1;
GVAR(currentItems) set [5, _item];
// Remove any items that can't fit in the container (this prevents overloading)
while {loadVest GVAR(center) > 1 && {_index >= 0}} do {
GVAR(center) removeItemFromVest (_vestItems select _index);
DEC(_index);
};
GVAR(currentItems) set [IDX_CURR_VEST, _item];
};
TOGGLE_RIGHT_PANEL_CONTAINER
[_display, _selectCorrectPanelContainer] call FUNC(fillRightPanel);
};
// Make unit switch to new item
call FUNC(showItem);
[_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo);
};
case IDC_buttonBackpack : {
// Display new items's info on the bottom right
[_display, _control, _curSel, configFile >> "CfgWeapons" >> _item] call FUNC(itemInfo);
};
// Backpack
case IDC_buttonBackpack: {
if (_item == "") then {
removeBackpack GVAR(center);
GVAR(currentItems) set [17, []];
GVAR(currentItems) set [6, _item];
GVAR(currentItems) set [IDX_CURR_BACKPACK_ITEMS, []];
GVAR(currentItems) set [IDX_CURR_BACKPACK, ""];
TOGGLE_RIGHT_PANEL_HIDE
} else {
if ((GVAR(currentItems) select IDX_CURR_BACKPACK) != _item) then {
// Get the unit's current loadout and just change the container
private _loadout = getUnitLoadout GVAR(center);
_loadout set [IDX_LOADOUT_BACKPACK, [_item, GVAR(currentItems) select IDX_CURR_BACKPACK_ITEMS]];
GVAR(center) setUnitLoadout _loadout;
if ((GVAR(currentItems) select 6) != _item) then {
removeBackpack GVAR(center);
GVAR(center) addBackpackGlobal _item;
while {count backpackItems GVAR(center) > 0} do {
GVAR(center) removeItemFromBackpack (backpackItems GVAR(center) select 0);
}; //--- Remove default config contents
{GVAR(center) addItemToBackpack _x} foreach (GVAR(currentItems) select 17);
private _backpackItems = backpackItems GVAR(center);
private _index = count _backpackItems - 1;
GVAR(currentItems) set [6, _item];
// Remove any items that can't fit in the container (this prevents overloading)
while {loadBackpack GVAR(center) > 1 && {_index >= 0}} do {
GVAR(center) removeItemFromBackpack (_backpackItems select _index);
DEC(_index);
};
GVAR(currentItems) set [IDX_CURR_BACKPACK, _item];
};
TOGGLE_RIGHT_PANEL_CONTAINER
[_display, _selectCorrectPanelContainer] call FUNC(fillRightPanel);
};
// Make unit switch to new item
call FUNC(showItem);
[_display, _control, _curSel, (configFile >> "CfgVehicles" >> _item)] call FUNC(itemInfo);
};
case IDC_buttonGoggles : {
// Display new items's info on the bottom right
[_display, _control, _curSel, configFile >> "CfgVehicles" >> _item] call FUNC(itemInfo);
};
// Facewear
case IDC_buttonGoggles: {
if (_item == "") then {
removeGoggles GVAR(center);
GVAR(currentItems) set [7, _item];
GVAR(currentItems) set [IDX_CURR_GOGGLES, ""];
} else {
if ((GVAR(currentItems) select 7) != _item) then {
if ((GVAR(currentItems) select IDX_CURR_GOGGLES) != _item) then {
GVAR(center) addGoggles _item;
GVAR(currentItems) set [7, _item];
GVAR(currentItems) set [IDX_CURR_GOGGLES, _item];
};
};
// Make unit switch to new item
call FUNC(showItem);
TOGGLE_RIGHT_PANEL_HIDE
[_display, _control, _curSel, (configFile >> "CfgGlasses" >> _item)] call FUNC(itemInfo);
};
case IDC_buttonNVG : {
TOGGLE_RIGHT_PANEL_HIDE
// Display new items's info on the bottom right
[_display, _control, _curSel, configFile >> "CfgGlasses" >> _item] call FUNC(itemInfo);
};
// NVG
case IDC_buttonNVG: {
if (_item == "") then {
GVAR(center) unlinkItem (GVAR(currentItems) select 8);
GVAR(currentItems) set [8, _item];
GVAR(center) unlinkItem (GVAR(currentItems) select IDX_CURR_NVG);
GVAR(currentItems) set [IDX_CURR_NVG, ""];
} else {
if ((GVAR(currentItems) select 8) != _item) then {
if ((GVAR(currentItems) select IDX_CURR_NVG) != _item) then {
GVAR(center) linkItem _item;
GVAR(currentItems) set [8, _item];
GVAR(currentItems) set [IDX_CURR_NVG, _item];
};
};
// Make unit switch to new item
call FUNC(showItem);
TOGGLE_RIGHT_PANEL_HIDE
[_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo);
};
case IDC_buttonBinoculars : {
TOGGLE_RIGHT_PANEL_HIDE
// Display new items's info on the bottom right
[_display, _control, _curSel, configFile >> "CfgWeapons" >> _item] call FUNC(itemInfo);
};
// Binoculars
case IDC_buttonBinoculars: {
private _currentWeapon = GVAR(currentItems) select IDX_CURR_BINO;
// If nothing selected, remove secondary weapon and its magazines
if (_item == "") then {
call _fnc_clearCurrentWeaponMags;
GVAR(center) removeWeapon (binocular GVAR(center));
GVAR(currentItems) set [9, _item];
} else {
if ((GVAR(currentItems) select 9) != _item) then {
GVAR(center) addWeapon _item;
GVAR(currentItems) set [9, _item];
call FUNC(showItem);
ADDBINOCULARSMAG
};
};
call FUNC(showItem);
TOGGLE_RIGHT_PANEL_HIDE
[_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo);
};
GVAR(currentItems) set [IDX_CURR_BINO_ITEMS, ["", "", "", "", "", ""]];
GVAR(currentItems) set [IDX_CURR_BINO, ""];
case IDC_buttonMap : {
TOGGLE_RIGHT_PANEL_HIDE
} else {
// Check if a new binocular was selected
if (_item != _currentWeapon) then {
// Get magazines that are compatible with the new binocular
private _compatibleMags = compatibleMagazines _item;
// Remove all magazines from the current binocular that aren't compatible with the new one
call _fnc_clearCurrentWeaponMags;
// Add new weapon without taking a magazine from the inventory
[GVAR(center), _item] call EFUNC(common,addWeapon);
private _linkedItems = binocularItems GVAR(center) - [""];
// Remove linked items if unavailable
if (_linkedItems isNotEqualTo []) then {
{
if !(_x in GVAR(virtualItemsFlat)) then {
GVAR(center) removeBinocularItem _x;
};
} forEach _linkedItems;
};
// Add old attachments and magazines back if they are compatible
{
if (_item canAdd _x) then {
GVAR(center) addWeaponItem [_item, _x, true];
};
} forEach (GVAR(currentItems) select IDX_CURR_BINO_ITEMS);
(getUnitLoadout GVAR(center) select IDX_LOADOUT_BINO) params ["", "_muzzle", "_flashlight", "_optics", "_primaryMagazine", "_secondaryMagazine", "_bipod"];
_primaryMagazine = _primaryMagazine param [0, ""];
// Add a magazine to the primary muzzle if empty
if (_primaryMagazine == "") then {
// Get magazines that are compatible with the new weapon's primary muzzle only
private _compatibleMagsPrimaryMuzzle = compatibleMagazines [_item, "this"];
private _compatibleMagIndex = _compatibleMagsPrimaryMuzzle findAny (keys (GVAR(virtualItems) get IDX_VIRT_ITEMS_ALL));
if (_compatibleMagIndex != -1) then {
_primaryMagazine = _compatibleMagsPrimaryMuzzle select _compatibleMagIndex;
GVAR(center) addWeaponItem [_item, _primaryMagazine, true];
};
};
// Update currentItems
GVAR(currentItems) set [IDX_CURR_BINO_ITEMS, [_muzzle, _flashlight, _optics, _bipod, _primaryMagazine, _secondaryMagazine param [0, ""]]];
GVAR(currentItems) set [IDX_CURR_BINO, _item];
};
TOGGLE_RIGHT_PANEL_WEAPON
[_display, _selectCorrectPanelWeapon] call FUNC(fillRightPanel);
};
// Make unit switch to new item
call FUNC(showItem);
// Display new items's info on the bottom right
[_display, _control, _curSel, configFile >> "CfgWeapons" >> _item] call FUNC(itemInfo);
};
// Map
case IDC_buttonMap: {
if (_item == "") then {
GVAR(center) unlinkItem (GVAR(currentItems) select 10) select 0;
GVAR(currentItems) set [10, _item];
GVAR(center) unlinkItem (GVAR(currentItems) select IDX_CURR_MAP);
GVAR(currentItems) set [IDX_CURR_MAP, ""];
} else {
if ((GVAR(currentItems) select 10) != _item) then {
if ((GVAR(currentItems) select IDX_CURR_MAP) != _item) then {
GVAR(center) linkItem _item;
GVAR(currentItems) set [10, _item];
GVAR(currentItems) set [IDX_CURR_MAP, _item];
};
};
// Make unit switch to new item
call FUNC(showItem);
TOGGLE_RIGHT_PANEL_HIDE
[_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo);
};
case IDC_buttonCompass : {
TOGGLE_RIGHT_PANEL_HIDE
// Display new items's info on the bottom right
[_display, _control, _curSel, configFile >> "CfgWeapons" >> _item] call FUNC(itemInfo);
};
// Compass
case IDC_buttonCompass: {
if (_item == "") then {
GVAR(center) unlinkItem (GVAR(currentItems) select 11) select 0;
GVAR(currentItems) set [11, _item];
GVAR(center) unlinkItem (GVAR(currentItems) select IDX_CURR_COMPASS);
GVAR(currentItems) set [IDX_CURR_COMPASS, ""];
} else {
if ((GVAR(currentItems) select 11) != _item) then {
if ((GVAR(currentItems) select IDX_CURR_COMPASS) != _item) then {
GVAR(center) linkItem _item;
GVAR(currentItems) set [11, _item];
GVAR(currentItems) set [IDX_CURR_COMPASS, _item];
};
};
// Make unit switch to new item
call FUNC(showItem);
TOGGLE_RIGHT_PANEL_HIDE
[_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo);
};
case IDC_buttonRadio : {
TOGGLE_RIGHT_PANEL_HIDE
[_display, _control, _curSel, configFile >> "CfgWeapons" >> _item] call FUNC(itemInfo);
};
// Radio
case IDC_buttonRadio: {
if (_item == "") then {
GVAR(center) unlinkItem (GVAR(currentItems) select 12) select 0;
GVAR(currentItems) set [12, _item];
GVAR(center) unlinkItem (GVAR(currentItems) select IDX_CURR_RADIO);
GVAR(currentItems) set [IDX_CURR_RADIO, ""];
} else {
if ((GVAR(currentItems) select 12) != _item) then {
if ((GVAR(currentItems) select IDX_CURR_RADIO) != _item) then {
GVAR(center) linkItem _item;
GVAR(currentItems) set [12, _item];
GVAR(currentItems) set [IDX_CURR_RADIO, _item];
};
};
// Make unit switch to new item
call FUNC(showItem);
TOGGLE_RIGHT_PANEL_HIDE
[_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo);
};
case IDC_buttonWatch : {
TOGGLE_RIGHT_PANEL_HIDE
// Display new items's info on the bottom right
[_display, _control, _curSel, configFile >> "CfgWeapons" >> _item] call FUNC(itemInfo);
};
// Watch
case IDC_buttonWatch: {
if (_item == "") then {
GVAR(center) unlinkItem (GVAR(currentItems) select 13);
GVAR(currentItems) set [13, _item];
GVAR(center) unlinkItem (GVAR(currentItems) select IDX_CURR_WATCH);
GVAR(currentItems) set [IDX_CURR_WATCH, ""];
} else {
if ((GVAR(currentItems) select 13) != _item) then {
if ((GVAR(currentItems) select IDX_CURR_WATCH) != _item) then {
GVAR(center) linkItem _item;
GVAR(currentItems) set [13, _item];
GVAR(currentItems) set [IDX_CURR_WATCH, _item];
};
};
// Make unit switch to new item
call FUNC(showItem);
TOGGLE_RIGHT_PANEL_HIDE
[_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo);
};
case IDC_buttonGPS : {
TOGGLE_RIGHT_PANEL_HIDE
[_display, _control, _curSel, configFile >> "CfgWeapons" >> _item] call FUNC(itemInfo);
};
// GPS or UAV Terminal
case IDC_buttonGPS: {
if (_item == "") then {
GVAR(center) unlinkItem (GVAR(currentItems) select 14) select 0;
GVAR(currentItems) set [14, _item];
GVAR(center) unlinkItem (GVAR(currentItems) select IDX_CURR_COMMS);
GVAR(currentItems) set [IDX_CURR_COMMS, ""];
} else {
if ((GVAR(currentItems) select 14) != _item) then {
if ((GVAR(currentItems) select IDX_CURR_COMMS) != _item) then {
GVAR(center) linkItem _item;
GVAR(currentItems) set [14, _item];
GVAR(currentItems) set [IDX_CURR_COMMS, _item];
};
};
// Make unit switch to new item
call FUNC(showItem);
TOGGLE_RIGHT_PANEL_HIDE
[_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo);
};
case IDC_buttonFace : {
TOGGLE_RIGHT_PANEL_HIDE
// Display new items's info on the bottom right
[_display, _control, _curSel, configFile >> "CfgWeapons" >> _item] call FUNC(itemInfo);
};
// Face
case IDC_buttonFace: {
private _face = [_item, "Default"] select (_item == "");
GVAR(center) setFace _face;
GVAR(currentFace) = _face;
// Make unit switch to new item
call FUNC(showItem);
TOGGLE_RIGHT_PANEL_HIDE
[_display, _control, _curSel, (configFile >> "CfgFaces" >> _item)] call FUNC(itemInfo);
};
case IDC_buttonVoice : {
TOGGLE_RIGHT_PANEL_HIDE
[_display, _control, _curSel, configFile >> "CfgFaces" >> _item] call FUNC(itemInfo);
};
// Voice
case IDC_buttonVoice: {
GVAR(center) setSpeaker _item;
GVAR(currentVoice) = _item;
// Make unit switch to new item
call FUNC(showItem);
TOGGLE_RIGHT_PANEL_HIDE
[_display, _control, _curSel, (configFile >> "CfgVoice" >> _item)] call FUNC(itemInfo);
};
case IDC_buttonInsignia : {
[GVAR(center), _item] call bis_fnc_setUnitInsignia;
TOGGLE_RIGHT_PANEL_HIDE
// Display new items's info on the bottom right
[_display, _control, _curSel, configFile >> "CfgVoice" >> _item] call FUNC(itemInfo);
};
// Insignia
case IDC_buttonInsignia: {
[GVAR(center), _item] call BIS_fnc_setUnitInsignia;
GVAR(currentInsignia) = _item;
// Make unit switch to new item
call FUNC(showItem);
TOGGLE_RIGHT_PANEL_HIDE
private _unitInsigniaConfig = (configFile >> "CfgUnitInsignia" >> _item);
private _unitInsigniaConfig = configFile >> "CfgUnitInsignia" >> _item;
if (configName _unitInsigniaConfig isEqualTo "") then {
[_display, _control, _curSel, (missionConfigFile >> "CfgUnitInsignia" >> _item)] call FUNC(itemInfo);
// Display new items's info on the bottom right
if (isNull _unitInsigniaConfig) then {
[_display, _control, _curSel, missionConfigFile >> "CfgUnitInsignia" >> _item] call FUNC(itemInfo);
} else {
[_display, _control, _curSel, _unitInsigniaConfig] call FUNC(itemInfo);
};
};
};
(_display displayCtrl IDC_totalWeightText) ctrlSetText (format ["%1 (%2)", [GVAR(center), 2] call EFUNC(common,getWeight), [GVAR(center), 1] call EFUNC(common,getWeight)]);
(_display displayCtrl IDC_totalWeightText) ctrlSetText (format ["%1 (%2)", GVAR(center) call EFUNC(common,getWeight), [GVAR(center), 1] call EFUNC(common,getWeight)]);

View File

@ -5,8 +5,9 @@
* Handles selection changes on loadouts panel.
*
* Arguments:
* 0: Loadouts panel control <CONTROL>
* 1: Loadouts panel selection <SCALAR>
* 0: Arsenal display <DISPLAY>
* 1: Loadouts panel control <CONTROL>
* 2: Currently selected loadout's index <NUMBER>
*
* Return Value:
* None
@ -23,74 +24,76 @@ private _deleteButtonCtrl = _display displayCtrl IDC_buttonDelete;
private _renameButtonCtrl = _display displayCtrl IDC_buttonRename;
private _textEditBoxCtrl= _display displayCtrl IDC_textEditBox;
// If nothing selected, disable all buttons
if (_curSel == -1) exitWith {
if (GVAR(currentLoadoutsTab) == IDC_buttonSharedLoadouts) then {
_saveButtonCtrl ctrlEnable false;
_saveButtonCtrl ctrlCommit 0;
};
_shareButtonCtrl ctrlSetText (localize LSTRING(buttonSharePrivateText));
_shareButtonCtrl ctrlSetText LLSTRING(buttonSharePrivateText);
{
_x ctrlEnable false;
_x ctrlCommit 0;
} foreach [_shareButtonCtrl, _loadButtonCtrl, _deleteButtonCtrl, _renameButtonCtrl];
} forEach [_shareButtonCtrl, _loadButtonCtrl, _renameButtonCtrl, _deleteButtonCtrl];
};
switch (GVAR(currentLoadoutsTab)) do {
// Local loadouts
case IDC_buttonMyLoadouts: {
// Enable shared loadouts if option is enabled and MP
_shareButtonCtrl ctrlEnable (GVAR(allowSharedLoadouts) && {isMultiplayer});
_shareButtonCtrl ctrlCommit 0;
_loadButtonCtrl ctrlEnable true;
_loadButtonCtrl ctrlCommit 0;
_shareButtonCtrl ctrlSetText ( [
localize LSTRING(buttonSharePrivateText),
localize LSTRING(buttonSharePublicText)
// Rename share button, depending if it's already shared or not
_shareButtonCtrl ctrlSetText ([
LLSTRING(buttonSharePrivateText),
LLSTRING(buttonSharePublicText)
] select ((_control lnbValue [_curSel, 0]) == 1));
// Enable all other buttons
{
_x ctrlEnable true;
_x ctrlCommit 0;
} foreach [_renameButtonCtrl, _deleteButtonCtrl];
} forEach [_loadButtonCtrl, _renameButtonCtrl, _deleteButtonCtrl];
_textEditBoxCtrl ctrlSetText (_control lnbText [_curSel, 1]);
};
// Default loadouts
case IDC_buttonDefaultLoadouts: {
// Enable saving and loading for everyone
{
_x ctrlEnable true;
_x ctrlCommit 0;
} foreach [_saveButtonCtrl, _loadButtonCtrl];
} forEach [_saveButtonCtrl, _loadButtonCtrl];
// Disable sharing button
_shareButtonCtrl ctrlEnable false;
_shareButtonCtrl ctrlCommit 0;
// Enable delete and renaming button if in 3DEN
{
_x ctrlEnable (is3DEN);
_x ctrlCommit 0;
} foreach [_deleteButtonCtrl, _renameButtonCtrl];
} forEach [_renameButtonCtrl, _deleteButtonCtrl];
_textEditBoxCtrl ctrlSetText (_control lnbText [_curSel, 1]);
};
// Shared loadouts
case IDC_buttonSharedLoadouts: {
// Enable saving and loading for everyone
{
_x ctrlEnable true;
_x ctrlCommit 0;
} foreach [_saveButtonCtrl, _loadButtonCtrl];
} forEach [_saveButtonCtrl, _loadButtonCtrl];
// Disable sharing button
_shareButtonCtrl ctrlEnable false;
_shareButtonCtrl ctrlCommit 0;
// If admin or loadout author, enable button for shared loadout
if ((serverCommandAvailable "#logout") || {(_control lnbText [_curSel, 0]) == profileName}) then {
_deleteButtonCtrl ctrlEnable true;
_deleteButtonCtrl ctrlCommit 0;
} else {

View File

@ -1,12 +1,12 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Handles selection changes on the right panel.
*
* Arguments:
* 0: Right panel control <CONTROL>
* 1: Right panel selection <SCALAR>
* 1: Right panel selection <NUMBER>
*
* Return Value:
* None
@ -18,61 +18,185 @@ params ["_control", "_curSel"];
if (_curSel < 0) exitwith {};
private _ctrlIDC = ctrlIDC _control;
private _display = ctrlParent _control;
private _item = _control lbData _curSel;
private _currentItemsIndex = IDX_CURR_PRIMARY_WEAPON_ITEMS + ([IDC_buttonPrimaryWeapon, IDC_buttonSecondaryWeapon, IDC_buttonHandgun, IDC_buttonBinoculars] find GVAR(currentLeftPanel));
private _itemIndex = [IDC_buttonMuzzle, IDC_buttonItemAcc, IDC_buttonOptic, IDC_buttonBipod, IDC_buttonCurrentMag, IDC_buttonCurrentMag2] find GVAR(currentRightPanel);
// Check which right panel has changed
switch (_currentItemsIndex) do {
// Primary weapon
case IDX_CURR_PRIMARY_WEAPON_ITEMS: {
// If removal
if (_item == "") then {
private _secondaryMagazine = (GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON_ITEMS) select 5;
private _fnc_selectItem = {
params ["_item", "_currentItemsIndex", "_itemIndex"];
// If secondary magazine, make sure to remove from correct muzzle
if (_itemIndex == 5 && {_secondaryMagazine != ""} && {((GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON_ITEMS) select 4) == _secondaryMagazine}) then {
// Remove both magazines
GVAR(center) removePrimaryWeaponItem _secondaryMagazine;
GVAR(center) removePrimaryWeaponItem _secondaryMagazine;
switch (_currentItemsIndex) do {
case 18: {
if (_item == "") then {
GVAR(center) removePrimaryWeaponItem ((GVAR(currentItems) select 18) select _itemIndex);
private _primaryMags = primaryWeaponMagazine GVAR(center);
GVAR(currentItems) set [18, (primaryWeaponItems GVAR(center)) + ([_primaryMags + [""], _primaryMags] select (count _primaryMags > 1))];
// Add magazine back into primary muzzle
GVAR(center) addWeaponItem [primaryWeapon GVAR(center), _secondaryMagazine, true];
} else {
GVAR(center) addWeaponItem [primaryWeapon GVAR(center), _item, true];
private _primaryMags = primaryWeaponMagazine GVAR(center);
GVAR(currentItems) set [18, (primaryWeaponItems GVAR(center)) + ([_primaryMags + [""], _primaryMags] select (count _primaryMags > 1))];
GVAR(center) removePrimaryWeaponItem ((GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON_ITEMS) select _itemIndex);
};
} else {
// Don't add item if it isn't a different item than what the unit already has
if (_item != ((GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON_ITEMS) select _itemIndex)) then {
// If magazine, make sure to add to correct muzzle
if (_itemIndex >= 4) then {
private _weapon = primaryWeapon GVAR(center);
GVAR(center) addWeaponItem [_weapon, [_item, nil, (_weapon call CBA_fnc_getMuzzles) param [_itemIndex - 4, ""]], true];
} else {
GVAR(center) addWeaponItem [primaryWeapon GVAR(center), _item, true];
};
};
[_display, _control, _curSel, (configFile >> (["CfgWeapons", "CfgMagazines"] select (_itemIndex in [4, 5]))>> _item)] call FUNC(itemInfo);
};
case 19: {
if (_item == "") then {
if (cba_disposable_replaceDisposableLauncher && !isNil {cba_disposable_LoadedLaunchers getVariable secondaryWeapon GVAR(center)}) exitWith { TRACE_1("ignoring unload of disposable",secondaryWeapon GVAR(center)); };
GVAR(center) removeSecondaryWeaponItem ((GVAR(currentItems) select 19) select _itemIndex);
private _secondaryMags = secondaryWeaponMagazine GVAR(center);
GVAR(currentItems) set [19, (secondaryWeaponItems GVAR(center)) + ([_secondaryMags + [""], _secondaryMags] select (count _secondaryMags > 1))];
} else {
GVAR(center) addWeaponItem [secondaryWeapon GVAR(center), _item, true];
private _secondaryMags = secondaryWeaponMagazine GVAR(center);
GVAR(currentItems) set [19, (secondaryWeaponItems GVAR(center)) + ([_secondaryMags + [""], _secondaryMags] select (count _secondaryMags > 1))];
// Update currentItems
(getUnitLoadout GVAR(center) select IDX_LOADOUT_PRIMARY_WEAPON) params ["", "_muzzle", "_flashlight", "_optics", "_primaryMagazine", "_secondaryMagazine", "_bipod"];
GVAR(currentItems) set [IDX_CURR_PRIMARY_WEAPON_ITEMS, [_muzzle, _flashlight, _optics, _bipod, _primaryMagazine param [0, ""], _secondaryMagazine param [0, ""]]];
[_display, _control, _curSel, configFile >> ["CfgWeapons", "CfgMagazines"] select (_itemIndex >= 4) >> _item] call FUNC(itemInfo);
};
// Secondary weapon
case IDX_CURR_SECONDARY_WEAPON_ITEMS: {
private _isDisposable = CBA_disposable_replaceDisposableLauncher && {!isNil {CBA_disposable_loadedLaunchers getVariable (secondaryWeapon GVAR(center))}};
// If removal
if (_item == "") then {
// Don't unload magazines from diposable weapons
if (_isDisposable && {_itemIndex >= 4}) exitWith {
TRACE_1("Ignoring unload of magazine from disposable",secondaryWeapon GVAR(center));
};
private _secondaryMagazine = (GVAR(currentItems) select IDX_CURR_SECONDARY_WEAPON_ITEMS) select 5;
// If secondary magazine, make sure to remove from correct muzzle
if (_itemIndex == 5 && {_secondaryMagazine != ""} && {((GVAR(currentItems) select IDX_CURR_SECONDARY_WEAPON_ITEMS) select 4) == _secondaryMagazine}) then {
// Remove both magazines
GVAR(center) removeSecondaryWeaponItem _secondaryMagazine;
GVAR(center) removeSecondaryWeaponItem _secondaryMagazine;
// Add magazine back into primary muzzle
GVAR(center) addWeaponItem [secondaryWeapon GVAR(center), _secondaryMagazine, true];
} else {
GVAR(center) removeSecondaryWeaponItem ((GVAR(currentItems) select IDX_CURR_SECONDARY_WEAPON_ITEMS) select _itemIndex);
};
} else {
// Don't add item if it isn't a different item than what the unit already has
if (_item != ((GVAR(currentItems) select IDX_CURR_SECONDARY_WEAPON_ITEMS) select _itemIndex)) then {
// If magazine, make sure to add to correct muzzle
if (_itemIndex >= 4) then {
private _weapon = secondaryWeapon GVAR(center);
GVAR(center) addWeaponItem [_weapon, [_item, nil, (_weapon call CBA_fnc_getMuzzles) param [_itemIndex - 4, ""]], true];
} else {
GVAR(center) addWeaponItem [secondaryWeapon GVAR(center), _item, true];
};
};
[_display, _control, _curSel, (configFile >> (["CfgWeapons", "CfgMagazines"] select (_itemIndex in [4, 5]))>> _item)] call FUNC(itemInfo);
};
case 20: {
if (_item == "") then {
GVAR(center) removeHandgunItem ((GVAR(currentItems) select 20) select _itemIndex);
private _handgunMags = handgunMagazine GVAR(center);
GVAR(currentItems) set [20, (handgunItems GVAR(center)) + ([_handgunMags + [""], _handgunMags] select (count _handgunMags > 1))];
} else {
GVAR(center) addWeaponItem [handgunWeapon GVAR(center), _item, true];
private _handgunMags = handgunMagazine GVAR(center);
GVAR(currentItems) set [20, (handgunItems GVAR(center)) + ([_handgunMags + [""], _handgunMags] select (count _handgunMags > 1))];
};
[_display, _control, _curSel, (configFile >> (["CfgWeapons", "CfgMagazines"] select (_itemIndex in [4, 5]))>> _item)] call FUNC(itemInfo);
// Update currentItems
if !(_isDisposable && {_itemIndex >= 4}) then {
(getUnitLoadout GVAR(center) select IDX_LOADOUT_SECONDARY_WEAPON) params ["", "_muzzle", "_flashlight", "_optics", "_primaryMagazine", "_secondaryMagazine", "_bipod"];
GVAR(currentItems) set [IDX_CURR_SECONDARY_WEAPON_ITEMS, [_muzzle, _flashlight, _optics, _bipod, _primaryMagazine param [0, ""], _secondaryMagazine param [0, ""]]];
};
[_display, _control, _curSel, configFile >> ["CfgWeapons", "CfgMagazines"] select (_itemIndex >= 4) >> _item] call FUNC(itemInfo);
};
// Handgun weapon
case IDX_CURR_HANDGUN_WEAPON_ITEMS: {
if (_item == "") then {
private _secondaryMagazine = (GVAR(currentItems) select IDX_CURR_HANDGUN_WEAPON_ITEMS) select 5;
// If secondary magazine, make sure to remove from correct muzzle
if (_itemIndex == 5 && {_secondaryMagazine != ""} && {((GVAR(currentItems) select IDX_CURR_HANDGUN_WEAPON_ITEMS) select 4) == _secondaryMagazine}) then {
// Remove both magazines
GVAR(center) removeHandgunItem _secondaryMagazine;
GVAR(center) removeHandgunItem _secondaryMagazine;
// Add magazine back into primary muzzle
GVAR(center) addWeaponItem [handgunWeapon GVAR(center), _secondaryMagazine, true];
} else {
GVAR(center) removeHandgunItem ((GVAR(currentItems) select IDX_CURR_HANDGUN_WEAPON_ITEMS) select _itemIndex);
};
} else {
// Don't add item if it isn't a different item than what the unit already has
if (_item != ((GVAR(currentItems) select IDX_CURR_HANDGUN_WEAPON_ITEMS) select _itemIndex)) then {
// If magazine, make sure to add to correct muzzle
if (_itemIndex >= 4) then {
private _weapon = handgunWeapon GVAR(center);
GVAR(center) addWeaponItem [_weapon, [_item, nil, (_weapon call CBA_fnc_getMuzzles) param [_itemIndex - 4, ""]], true];
} else {
GVAR(center) addWeaponItem [handgunWeapon GVAR(center), _item, true];
};
};
};
// Update currentItems
(getUnitLoadout GVAR(center) select IDX_LOADOUT_HANDGUN_WEAPON) params ["", "_muzzle", "_flashlight", "_optics", "_primaryMagazine", "_secondaryMagazine", "_bipod"];
// https://feedback.bistudio.com/T173880
_primaryMagazine = _primaryMagazine param [0, ""];
private _handgunMagazines = handgunMagazine GVAR(center);
// Delete the first magazine (but keep one if both magazines are the same)
_handgunMagazines deleteAt (_handgunMagazines findIf {_x == _primaryMagazine});
GVAR(currentItems) set [IDX_CURR_HANDGUN_WEAPON_ITEMS, [_muzzle, _flashlight, _optics, _bipod, _primaryMagazine, _handgunMagazines param [0, ""]]];
[_display, _control, _curSel, configFile >> ["CfgWeapons", "CfgMagazines"] select (_itemIndex >= 4) >> _item] call FUNC(itemInfo);
};
// Binoculars
case IDX_CURR_BINO_ITEMS: {
if (_item == "") then {
private _secondaryMagazine = (GVAR(currentItems) select IDX_CURR_BINO_ITEMS) select 5;
// If secondary magazine, make sure to remove from correct muzzle
if (_itemIndex == 5 && {_secondaryMagazine != ""} && {((GVAR(currentItems) select IDX_CURR_BINO_ITEMS) select 4) == _secondaryMagazine}) then {
// Remove both magazines
GVAR(center) removeBinocularItem _secondaryMagazine;
GVAR(center) removeBinocularItem _secondaryMagazine;
// Add magazine back into primary muzzle
GVAR(center) addWeaponItem [binocular GVAR(center), _secondaryMagazine, true];
} else {
GVAR(center) removeBinocularItem ((GVAR(currentItems) select IDX_CURR_BINO_ITEMS) select _itemIndex);
};
} else {
// Don't add item if it isn't a different item than what the unit already has
if (_item != ((GVAR(currentItems) select IDX_CURR_BINO_ITEMS) select _itemIndex)) then {
// If magazine, make sure to add to correct muzzle
if (_itemIndex >= 4) then {
private _weapon = binocular GVAR(center);
GVAR(center) addWeaponItem [_weapon, [_item, nil, (_weapon call CBA_fnc_getMuzzles) param [_itemIndex - 4, ""]], true];
} else {
GVAR(center) addWeaponItem [binocular GVAR(center), _item, true];
};
};
};
// Update currentItems
(getUnitLoadout GVAR(center) select IDX_LOADOUT_BINO) params ["", "_muzzle", "_flashlight", "_optics", "_primaryMagazine", "_secondaryMagazine", "_bipod"];
// https://feedback.bistudio.com/T173880 (unsure if binocular weapons are affected by this)
_primaryMagazine = _primaryMagazine param [0, ""];
private _binocularMagazines = binocularMagazine GVAR(center);
// Delete the first magazine (but keep one if both magazines are the same)
_binocularMagazines deleteAt (_binocularMagazines findIf {_x == _primaryMagazine});
GVAR(currentItems) set [IDX_CURR_BINO_ITEMS, [_muzzle, _flashlight, _optics, _bipod, _primaryMagazine, _binocularMagazines param [0, ""]]];
[_display, _control, _curSel, configFile >> ["CfgWeapons", "CfgMagazines"] select (_itemIndex >= 4) >> _item] call FUNC(itemInfo);
};
};
[
_item,
18 + ([IDC_buttonPrimaryWeapon, IDC_buttonSecondaryWeapon, IDC_buttonHandgun] find GVAR(currentLeftPanel)),
[IDC_buttonMuzzle, IDC_buttonItemAcc, IDC_buttonOptic, IDC_buttonBipod, IDC_buttonCurrentMag, IDC_buttonCurrentMag2] find GVAR(currentRightPanel)
] call _fnc_selectItem;
(_display displayCtrl IDC_totalWeightText) ctrlSetText (format ["%1 (%2)", [GVAR(center), 2] call EFUNC(common,getWeight), [GVAR(center), 1] call EFUNC(common,getWeight)]);
// Update weight display
(_display displayCtrl IDC_totalWeightText) ctrlSetText (format ["%1 (%2)", GVAR(center) call EFUNC(common,getWeight), [GVAR(center), 1] call EFUNC(common,getWeight)]);

View File

@ -1,12 +1,12 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Handles selection changes on the right panel (listnbox).
*
* Arguments:
* 0: Right panel control <CONTROL>
* 1: Right panel selection <SCALAR>
* 1: Right panel selection <NUMBER>
*
* Return Value:
* None
@ -16,36 +16,41 @@
params ["_control", "_curSel"];
if (_curSel < 0) exitwith {};
if (_curSel < 0 || {!(GVAR(currentLeftPanel) in [IDC_buttonUniform, IDC_buttonVest, IDC_buttonBackpack])}) exitWith {};
private _ctrlIDC = ctrlIDC _control;
private _display = ctrlParent _control;
private _item = [_control lnbData [_curSel, 0], _control lbData _curSel] select !(ctrlType _control == 102);
private _hasItems = false;
private _fnc_selectRight = {
params ["_item", "_cfgEntry"];
// Get relevant container
private _container = switch (GVAR(currentLeftPanel)) do {
case IDC_buttonUniform: {
_hasItems = (GVAR(currentItems) select IDX_CURR_UNIFORM_ITEMS) isNotEqualTo [];
// Load remaining
private _maxLoad = switch (GVAR(currentLeftPanel)) do {
case IDC_buttonUniform: {
gettext (configfile >> "CfgWeapons" >> uniform GVAR(center) >> "ItemInfo" >> "containerClass")
};
case IDC_buttonVest: {
gettext (configfile >> "CfgWeapons" >> vest GVAR(center) >> "ItemInfo" >> "containerClass")
};
case IDC_buttonBackpack: {
backpack GVAR(center)
};
uniformContainer GVAR(center)
};
case IDC_buttonVest: {
_hasItems = (GVAR(currentItems) select IDX_CURR_VEST_ITEMS) isNotEqualTo [];
[_control, _maxLoad] call FUNC(updateRightPanel);
[_display, _control, _curSel, (configFile >> _cfgEntry >> _item)] call FUNC(itemInfo);
vestContainer GVAR(center)
};
case IDC_buttonBackpack: {
_hasItems = (GVAR(currentItems) select IDX_CURR_BACKPACK_ITEMS) isNotEqualTo [];
backpackContainer GVAR(center)
};
};
if (GVAR(currentLeftPanel) in [IDC_buttonUniform, IDC_buttonVest, IDC_buttonBackpack]) then {
// Refresh availibility of items based on space remaining in container
[_control, _container, _hasItems] call FUNC(updateRightPanel);
[
_item,
["CfgWeapons", "CfgMagazines"] select (GVAR(currentRightPanel) in [IDC_buttonMag, IDC_buttonMagALL, IDC_buttonThrow, IDC_buttonPut])
] call _fnc_selectRight;
private _item = _control lnbData [_curSel, 0];
private _cfgEntry = ["CfgWeapons", "CfgMagazines"] select (GVAR(currentRightPanel) in [IDC_buttonMag, IDC_buttonMagALL, IDC_buttonThrow, IDC_buttonPut] || {_item in (uiNamespace getVariable [QGVAR(magazineMiscItems), []])});
_cfgEntry = configFile >> _cfgEntry >> _item;
// If e.g. in misc. items, item could be e.g. a backpack
if (isNull _cfgEntry) then {
_cfgEntry = _item call CBA_fnc_getItemConfig;
};
// Display item info on the bottom right
[ctrlParent _control, _control, _curSel, _cfgEntry] call FUNC(itemInfo);

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
/*
* Author: Alganthe
* Replace the 3DEN "edit loadout" menu action
* Replace the 3DEN "edit loadout" menu action.
*
* Arguments:
* None
@ -9,9 +9,8 @@
* Return Value:
* None
*
*
* Public: No
*/
private _entity = (uinamespace getvariable ["bis_fnc_3DENEntityMenu_data",[]]) param [1, objnull];
private _entity = (uiNamespace getVariable ["BIS_fnc_3DENEntityMenu_data", []]) param [1, objNull];
[_entity, _entity, true] call FUNC(openBox);

View File

@ -1,12 +1,13 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Open arsenal.
*
* Arguments:
* 0: Box <OBJECT>
* 1: Unit to open the arsenal on <OBJECT>
* 2: Ignore virtual items and fill arsenal <BOOL>
* 2: Ignore virtual items and fill arsenal <BOOL> (default: false)
*
* Return Value:
* None
@ -26,31 +27,68 @@ if (
{!(isNull objectParent _center) && {!is3DEN}}
) exitWith {};
if (isNil {_object getVariable [QGVAR(virtualItems), nil]} && {!_mode}) exitWith {
[localize LSTRING(noVirtualItems), false, 5, 1] call EFUNC(common,displayText);
// If object has no arsenal and chosen option is to not ignore virtual items of object, exit
if (isNil {_object getVariable QGVAR(virtualItems)} && {!_mode}) exitWith {
[LLSTRING(noVirtualItems), false, 5, 1] call EFUNC(common,displayText);
};
// Don't execute in scheduled environment
if (canSuspend) exitWith {
[{_this call FUNC(openBox)}, _this] call CBA_fnc_directCall;
};
private _displayToUse = [findDisplay 46, findDIsplay 312] select (!isNull findDisplay 312);
_displayToUse = [_displayToUse, findDisplay 313] select (is3DEN);
private _displayToUse = findDisplay IDD_RSCDISPLAYCURATOR;
_displayToUse = [_displayToUse, findDisplay IDD_MISSION] select (isNull _displayToUse);
_displayToUse = [_displayToUse, findDisplay IDD_DISPLAY3DEN] select is3DEN;
if (isNil "_displayToUse" || {!isnil QGVAR(camera)}) exitWith {
[localize LSTRING(CantOpenDisplay), false, 5, 1] call EFUNC(common,displayText);
// Check if the display is available and that there isn't already a camera for the arsenal
if (isNull _displayToUse || {!isNil QGVAR(camera)}) exitWith {
[LLSTRING(CantOpenDisplay), false, 5, 1] call EFUNC(common,displayText);
};
GVAR(currentBox) = _object;
if (_mode) then {
// Add all the items from the game that the arsenal has detected
GVAR(virtualItems) = +(uiNamespace getVariable QGVAR(configItems));
GVAR(virtualItemsFlat) = +(uiNamespace getVariable QGVAR(configItemsFlat));
} else {
GVAR(virtualItems) = +(_object getVariable [QGVAR(virtualItems), [
[[], [], []], [[], [], [], []], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []
]]);
GVAR(virtualItemsFlat) = flatten GVAR(virtualItems);
// Add only specified items to the arsenal
private _virtualItems = _object getVariable QGVAR(virtualItems);
GVAR(virtualItems) = if (isNil "_virtualItems") then {
_virtualItems = [
[IDX_VIRT_WEAPONS, createHashMapFromArray [[IDX_VIRT_PRIMARY_WEAPONS, createHashMap], [IDX_VIRT_SECONDARY_WEAPONS, createHashMap], [IDX_VIRT_HANDGUN_WEAPONS, createHashMap]]],
[IDX_VIRT_ATTACHMENTS, createHashMapFromArray [[IDX_VIRT_OPTICS_ATTACHMENTS, createHashMap], [IDX_VIRT_FLASHLIGHT_ATTACHMENTS, createHashMap], [IDX_VIRT_MUZZLE_ATTACHMENTS, createHashMap], [IDX_VIRT_BIPOD_ATTACHMENTS, createHashMap]]]
];
_virtualItems = createHashMapFromArray _virtualItems;
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
_virtualItems set [_index, createHashMap];
};
} else {
+_virtualItems
};
// Flatten out hashmaps for easy checking later
private _virtualItemsFlat = +_virtualItems;
private _weapons = _virtualItemsFlat deleteAt IDX_VIRT_WEAPONS;
private _attachments = _virtualItemsFlat deleteAt IDX_VIRT_ATTACHMENTS;
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
_virtualItemsFlat merge [_virtualItemsFlat deleteAt _index, true];
};
for "_index" from IDX_VIRT_PRIMARY_WEAPONS to IDX_VIRT_HANDGUN_WEAPONS do {
_virtualItemsFlat merge [_weapons deleteAt _index, true];
};
for "_index" from IDX_VIRT_OPTICS_ATTACHMENTS to IDX_VIRT_BIPOD_ATTACHMENTS do {
_virtualItemsFlat merge [_attachments deleteAt _index, true];
};
GVAR(virtualItemsFlat) = _virtualItemsFlat;
};
GVAR(center) = _center;
@ -58,5 +96,7 @@ GVAR(center) = _center;
if (is3DEN) then {
_displayToUse createDisplay QGVAR(display);
} else {
[{(_this select 0) createDisplay (_this select 1)}, [_displayToUse, QGVAR(display)]] call CBA_fnc_execNextFrame;
[{
_this createDisplay QGVAR(display);
}, _displayToUse] call CBA_fnc_execNextFrame;
};

View File

@ -1,6 +1,6 @@
#include "script_component.hpp"
/*
* Author: alganthe
* Author: Alganthe, johnb43
* Port VA loadouts to ACE Arsenal.
*
* Arguments:
@ -15,31 +15,40 @@
* Public: Yes
*/
private _VALoadouts = +(profilenamespace getvariable ["bis_fnc_saveInventory_data",[]]);
private _aceLoadouts = +(profileNamespace getVariable [QGVAR(saved_loadouts),[]]);
private _unit = player;
if (isNull player) exitWith {
[localize LSTRING(portLoadoutsPlayerError)] call BIS_fnc_error;
// Need a player object to transfer loadouts
if (isNull _unit) exitWith {
[LLSTRING(portLoadoutsPlayerError)] call BIS_fnc_error;
};
// Check if there are any VA loadouts
private _VALoadouts = profileNamespace getVariable ["BIS_fnc_saveInventory_data", []];
if (_VALoadouts isEqualTo []) exitWith {
[localize LSTRING(portLoadoutsLoadoutError)] call BIS_fnc_error;
[LLSTRING(portLoadoutsLoadoutError)] call BIS_fnc_error;
};
for "_i" from 0 to (count _VALoadouts - 1) step 2 do {
private _aceLoadouts = +(profileNamespace getVariable [QGVAR(saved_loadouts),[]]);
private _name = "";
private _index = -1;
// Go through all VA loadouts and save them as ACE Arsenal loadouts
for "_i" from 0 to (count _VALoadouts) - 1 step 2 do {
_name = _VALoadouts select _i;
_inventory = _VALoadouts select (_i + 1);
private _sameNameLoadoutsList = _aceLoadouts select {_x select 0 == _name};
[player, [profilenamespace, _name]] call bis_fnc_loadinventory;
// Load VA loadout onto player
[_unit, [profileNamespace, _name]] call BIS_fnc_loadInventory;
private _loadout = getUnitLoadout player;
if (count _sameNameLoadoutsList > 0) then {
_aceLoadouts set [_aceLoadouts find (_sameNameLoadoutsList select 0), [_name, _loadout]];
// See if there is an already existing loadout with the same name
_index = _aceLoadouts findIf {(_x select 0) == _name};
// If there is an already existing loadout with same name, overwrite it (in CBA extended loadout array)
if (_index != -1) then {
_aceLoadouts set [_index, [_name, [getUnitLoadout _unit, createHashMap]]];
} else {
_aceLoadouts pushBack [_name, _loadout];
// Otherwise just add
_aceLoadouts pushBack [_name, [getUnitLoadout _unit, createHashMap]];
};
};

View File

@ -1,11 +1,11 @@
#include "script_component.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Remove arsenal from target.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Remove globally <BOOL>
* 1: Remove globally <BOOL> (default: true)
*
* Return Value:
* None
@ -18,19 +18,24 @@
params [["_object", objNull, [objNull]], ["_global", true, [true]]];
if (isNull _object || {isNil QGVAR(EHIDArray)}) exitWith {};
if (isNull _object) exitWith {};
if (_global && {isMultiplayer}) then {
private _ID = (GVAR(EHIDArray) select {_x select 1 == _object}) select 0;
private _id = _object getVariable QGVAR(initBoxJIP);
if (!isNil "_ID") then {
[_ID select 0] call CBA_fnc_removeGlobalEventJIP;
GVAR(EHIDArray) deleteAt (GVAR(EHIDArray) find _ID);
publicVariable QGVAR(EHIDArray);
[QGVAR(removeBox), [_object, false]] call CBA_fnc_globalEvent;
};
if (_global && {isMultiplayer} && {!isNil "_id"}) then {
// Remove event from JIP queue
[_id] call CBA_fnc_removeGlobalEventJIP;
// Reset JIP ID
_object setVariable [QGVAR(initBoxJIP), nil, true];
// Remove box for everyone
[QGVAR(removeBox), [_object, false]] call CBA_fnc_globalEvent;
// Remove from JIP
_object setVariable [QGVAR(virtualItems), nil, true];
} else {
_object setVariable [QGVAR(virtualItems), nil, false];
_object setVariable [QGVAR(virtualItems), nil];
[_object, 0, ["ACE_MainActions", QGVAR(interaction)]] call EFUNC(interact_menu,removeActionFromObject);
[QGVAR(boxRemoved), _object] call CBA_fnc_localEvent;
};

View File

@ -0,0 +1,54 @@
#include "script_component.hpp"
/*
* Author: johnb43
* Remove a sort from ACE Arsenal.
*
* Arguments:
* 0: Array of IDs <ARRAY of STRINGS>
*
* Return Value:
* None
*
* Example:
*
[["scopeSortL00", "scopeSortL01", "scopeSortL02", "scopeSortR07"]] call ace_arsenal_fnc_removeSort;
*
* Public: Yes
*/
params ["_IDList"];
// Compile sorts from config (in case this is called before preInit)
call FUNC(compileSorts);
private _currentID = "";
private _stringCount = 0;
private _tabSide = "";
private _tab = "";
private _tabToChange = [];
{
_currentID = _x;
_stringCount = count _currentID;
// Make sure to keep at least 1 sort per category, so make default sort not deletable
if ("ace_alphabetically" in toLower (_currentID select [0, _stringCount - 3])) then {
continue;
};
// Get tab info
_tabSide = _currentID select [_stringCount - 3, 1];
_tab = _currentID select [_stringCount - 2, 2];
_tab = parseNumber _tab;
// Check which side to delete it from
_tabToChange = if (_tabSide == "R") then {
GVAR(sortListRightPanel) select _tab
} else {
GVAR(sortListLeftPanel) select _tab
};
// Remove entry (all names are unique, there are no duplicates)
_tabToChange deleteAt (_tabToChange findIf {_x select 0 == _currentID});
} forEach _IDList;

View File

@ -4,57 +4,81 @@
* Remove a stat from ACE Arsenal.
*
* Arguments:
* 0: Array of IDs <ARRAY>
* 0: Array of IDs <ARRAY of STRINGS>
*
* Return Value:
* None
*
* Example:
* [["scopeStatL00","scopeStatL01","scopeStatL02","scopeStatR07"]] call ace_arsenal_fnc_removeStat;
* [["scopeStatL00", "scopeStatL01", "scopeStatL02", "scopeStatR07"]] call ace_arsenal_fnc_removeStat;
*
* Public: Yes
*/
params ["_IDList"];
// Compile stats from config (in case this is called before preInit)
call FUNC(compileStats);
private _currentID = "";
private _stringCount = 0;
private _tabSide = "";
private _tab = "";
private _tabToChange = [];
private _changes = [];
{
private _currentID = _x;
private _stringCount = count _currentID;
private _side = _currentID select [_stringCount - 3, 1];
private _tab = _currentID select [_stringCount - 2, 2];
// Get tab info
_currentID = _x;
_stringCount = count _currentID;
_tabSide = _currentID select [_stringCount - 3, 1];
_tab = _currentID select [_stringCount - 2, 2];
_tab = parseNumber _tab;
private _tabToChange = if (_side == "R") then {
// Check which side to delete it from
_tabToChange = if (_tabSide == "R") then {
GVAR(statsListRightPanel) select _tab
} else {
GVAR(statsListLeftPanel) select _tab
};
// Delete stat
{
_x deleteAt (_x findIf {_x select 0 == _currentID});
} foreach _tabToChange;
} foreach _IDList;
} forEach _tabToChange;
// Clear empty pages
private _fnc_deleteEmptyPage = {
params ["_list"];
// Store information, so that only tabs that were changed can be sorted again
_changes pushBackUnique [_tab, _tabSide];
} forEach _IDList;
private _statsFlat = [];
private _stats = [];
// Fill empty spots
{
_x params ["_tab", "_tabSide"];
_tabToChange = if (_tabSide == "R") then {
GVAR(statsListRightPanel)
} else {
GVAR(statsListLeftPanel)
};
_statsFlat = [];
// Get all stats of a tab into a single array
{
private _evaluatedTab = _forEachIndex;
{
if (count _x == 0) then {
_markedForDeletion pushBack [_evaluatedTab, _forEachIndex];
};
} foreach _x;
_statsFlat append _x;
} forEach (_tabToChange select _tab);
{
(_list select (_x select 0)) deleteAt (_x select 1);
} foreach _markedForDeletion;
} foreach (_this select 0);
};
// Priority has stayed intact, so no need to sort
_stats = [];
private _markedForDeletion = [];
// Group stats into groups of 5
for "_index" from 0 to count _statsFlat - 1 step 5 do {
_stats pushBack (_statsFlat select [_index, _index + 5]);
};
[GVAR(statsListLeftPanel)] call _fnc_deleteEmptyPage;
[GVAR(statsListRightPanel)] call _fnc_deleteEmptyPage;
_tabToChange set [_tab, _stats];
} forEach _changes;

View File

@ -1,12 +1,13 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Remove virtual items to the provided target.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Items <ARRAY of strings> <BOOL>
* 2: Add globally <BOOL>
* 1: Items <ARRAY of STRINGS> <BOOL>
* 2: Remove globally <BOOL> (default: false)
*
* Return Value:
* None
@ -18,63 +19,84 @@
* Public: Yes
*/
params [ ["_object", objNull, [objNull]], ["_items", [], [true, [""]]], ["_global", false, [false]] ];
params [["_object", objNull, [objNull]], ["_items", [], [true, [""]]], ["_global", false, [false]]];
if (isNull _object) exitWith {};
if (_items isEqualType [] && {count _items == 0}) exitWith {};
private _cargo = _object getVariable [QGVAR(virtualItems), [
[[], [], []], // Weapons 0, primary, handgun, secondary
[[], [], [], []], // WeaponAccessories 1, optic,side,muzzle,bipod
[ ], // Magazines 2
[ ], // Headgear 3
[ ], // Uniform 4
[ ], // Vest 5
[ ], // Backpacks 6
[ ], // Goggles 7
[ ], // NVGs 8
[ ], // Binoculars 9
[ ], // Map 10
[ ], // Compass 11
[ ], // Radio slot 12
[ ], // Watch slot 13
[ ], // Comms slot 14
[ ], // WeaponThrow 15
[ ], // WeaponPut 16
[ ] // InventoryItems 17
]];
if (isNull _object || {_items isEqualTo []}) exitWith {};
if (_items isEqualType true) then {
if (_items) then {
[_object, _global] call FUNC(removeBox);
_object setVariable [QGVAR(virtualItems), nil, _global];
};
} else {
private _cargo = _object getVariable QGVAR(virtualItems);
// Make sure all items are in string form
_items = _items select {_x isEqualType "" && {_x != ""}};
if (isNil "_cargo") exitWith {
[_object, _global] call FUNC(removeBox);
};
// Make sure all items are in string form, then convert to config case (non-existent items return "")
_items = (_items select {_x isEqualType ""}) apply {_x call EFUNC(common,getConfigName)};
// Remove any invalid/non-existing items
_items = _items - [""];
private _configItemsFlat = uiNamespace getVariable QGVAR(configItemsFlat);
// Convert all items to their baseWeapon
_items = _items apply {if (_x in _configItemsFlat) then {_x} else {_x call FUNC(baseWeapon)}};
// Remove items from lists
{
if (_forEachIndex isEqualTo 0) then {
_cargo set [_forEachIndex, [(_x select 0) - _items, (_x select 1) - _items, (_x select 2) - _items]];
} else {
if (_forEachIndex isEqualTo 1) then {
_cargo set [_forEachIndex, [(_x select 0) - _items, (_x select 1) - _items, (_x select 2) - _items, (_x select 3) - _items]];
} else {
_cargo set [_cargo find _x, _x - _items];
switch (true) do {
// Weapons
case (_x in ((_cargo get IDX_VIRT_WEAPONS) get IDX_VIRT_PRIMARY_WEAPONS)): {
((_cargo get IDX_VIRT_WEAPONS) get IDX_VIRT_PRIMARY_WEAPONS) deleteAt _x;
};
case (_x in ((_cargo get IDX_VIRT_WEAPONS) get IDX_VIRT_HANDGUN_WEAPONS)): {
((_cargo get IDX_VIRT_WEAPONS) get IDX_VIRT_HANDGUN_WEAPONS) deleteAt _x;
};
case (_x in ((_cargo get IDX_VIRT_WEAPONS) get IDX_VIRT_SECONDARY_WEAPONS)): {
((_cargo get IDX_VIRT_WEAPONS) get IDX_VIRT_SECONDARY_WEAPONS) deleteAt _x;
};
// Weapon attachments
case (_x in ((_cargo get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_OPTICS_ATTACHMENTS)): {
((_cargo get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_OPTICS_ATTACHMENTS) deleteAt _x;
};
case (_x in ((_cargo get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_FLASHLIGHT_ATTACHMENTS)): {
((_cargo get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_FLASHLIGHT_ATTACHMENTS) deleteAt _x;
};
case (_x in ((_cargo get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_MUZZLE_ATTACHMENTS)): {
((_cargo get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_MUZZLE_ATTACHMENTS) deleteAt _x;
};
case (_x in ((_cargo get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_BIPOD_ATTACHMENTS)): {
((_cargo get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_BIPOD_ATTACHMENTS) deleteAt _x;
};
// Other
default {
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
if (_x in (_cargo get _index)) exitWith {
(_cargo get _index) deleteAt _x;
};
};
};
};
} foreach _cargo;
} forEach _items;
private _itemCount = {
if (_x isEqualTo (_cargo select 0) || {_x isEqualTo (_cargo select 1)}) then {
(_x isNotEqualTo [[],[],[]] || {_x isEqualTo [[],[],[],[]]})
} else {
(_x isNotEqualTo [])
};
} count _cargo;
private _empty = [
[IDX_VIRT_WEAPONS, createHashMapFromArray [[IDX_VIRT_PRIMARY_WEAPONS, createHashMap], [IDX_VIRT_SECONDARY_WEAPONS, createHashMap], [IDX_VIRT_HANDGUN_WEAPONS, createHashMap]]],
[IDX_VIRT_ATTACHMENTS, createHashMapFromArray [[IDX_VIRT_OPTICS_ATTACHMENTS, createHashMap], [IDX_VIRT_FLASHLIGHT_ATTACHMENTS, createHashMap], [IDX_VIRT_MUZZLE_ATTACHMENTS, createHashMap], [IDX_VIRT_BIPOD_ATTACHMENTS, createHashMap]]]
];
if (_itemCount == 0) then {
_empty = createHashMapFromArray _empty;
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
_empty set [_index, createHashMap];
};
// If nothing is left, remove arsenal from object
if (_cargo isEqualTo _empty) then {
[_object, _global] call FUNC(removeBox);
} else {
_object setVariable [QGVAR(virtualItems), _cargo, _global];

View File

@ -0,0 +1,150 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: johnb43
* Replaces unique items in a loadout with their base items. Weapons are replaced with their base weapon.
*
* Arguments:
* 0: CBA extended loadout or getUnitLoadout array <ARRAY>
*
* Return Value:
* Sanitised loadout <ARRAY> (getUnitLoadout array)
*
* Example:
* [getUnitLoadout player] call ace_arsenal_fnc_replaceUniqueItemsLoadout
*
* Public: Yes
*/
params [["_loadout", [], [[]]]];
// IF CBA extended loadout, just take getUnitLoadout array
if (count _loadout == 2) then {
_loadout = _loadout select 0;
};
if (count _loadout != 10) exitWith {[]};
private _weapon = "";
private _weaponsInfo = [];
private _uniqueBaseCfgText = "";
private _cfgWeapons = configFile >> "CfgWeapons";
private _cfgMagazines = configFile >> "CfgMagazines";
private _cfgVehicles = configFile >> "CfgVehicles";
{
switch (_forEachIndex) do {
// Primary weapon, Secondary weapon, Handgun weapon, Binoculars
case IDX_LOADOUT_PRIMARY_WEAPON;
case IDX_LOADOUT_SECONDARY_WEAPON;
case IDX_LOADOUT_HANDGUN_WEAPON;
case IDX_LOADOUT_BINO: {
_weaponsInfo = _x;
// Check weapon & weapon attachments
{
// Magazines
if (_forEachIndex in [4, 5]) then {
_x params [["_magazine", ""], "_count"];
if (_magazine != "") then {
_uniqueBaseCfgText = (getText (_cfgMagazines >> _magazine >> QGVAR(uniqueBase))) call EFUNC(common,getConfigName);
if (_uniqueBaseCfgText != "") then {
_weaponsInfo set [_forEachIndex, [_uniqueBaseCfgText, _count]];
};
};
} else {
// Other
if (_x != "") then {
_weaponsInfo set [_forEachIndex, _x call FUNC(baseWeapon)];
};
};
} forEach _weaponsInfo;
};
// Uniform, vest, backpack
case IDX_LOADOUT_UNIFORM;
case IDX_LOADOUT_VEST;
case IDX_LOADOUT_BACKPACK: {
_x params [["_containerClass", ""], ["_items", []]];
if (_containerClass != "") then {
_uniqueBaseCfgText = (getText ([_cfgWeapons, _cfgVehicles] select (_forEachIndex == IDX_LOADOUT_BACKPACK) >> _containerClass >> QGVAR(uniqueBase))) call EFUNC(common,getConfigName);
if (_uniqueBaseCfgText != "") then {
(_x select 0) set [0, _uniqueBaseCfgText];
};
// Check if container has items that need replacing with a defined base
{
switch (true) do {
// Containers have 2 entries: Name and isBackpack
case (_x isEqualTypeArray ["", false]);
// Misc. items have 2 entries: Name and amount
case (_x isEqualTypeArray ["", 0]): {
_x params ["_item", "_arg"];
if (_item != "") then {
_uniqueBaseCfgText = (getText ([_cfgWeapons, _cfgVehicles] select ((_arg isEqualType false) && {_arg}) >> _item >> QGVAR(uniqueBase))) call EFUNC(common,getConfigName);
if (_uniqueBaseCfgText != "") then {
_x set [0, _uniqueBaseCfgText];
};
};
};
// Weapons have 2 entries: Weapon info array and amount
case (_x isEqualTypeArray [[], 0]): {
_weaponsInfo = _x select 0;
// Check weapon & weapon attachments
{
// Magazines
if (_forEachIndex in [4, 5]) then {
_uniqueBaseCfgText = (getText (_cfgMagazines >> _x >> QGVAR(uniqueBase))) call EFUNC(common,getConfigName);
if (_uniqueBaseCfgText != "") then {
_weaponsInfo set [_forEachIndex, _uniqueBaseCfgText];
};
} else {
// Other
if (_x != "") then {
_weaponsInfo set [_forEachIndex, _x call FUNC(baseWeapon)];
};
};
} forEach _weaponsInfo;
};
// Magazines have 3 entries: Name, amount and ammo count
case (_x isEqualTypeArray ["", 0, 0]): {
_x params ["_item"];
if (_item != "") then {
_uniqueBaseCfgText = (getText (_cfgMagazines >> _item >> QGVAR(uniqueBase))) call EFUNC(common,getConfigName);
if (_uniqueBaseCfgText != "") then {
_x set [0, _uniqueBaseCfgText];
};
};
};
};
} forEach _items;
};
};
// Assigned items: Map, Compass, Watch, GPS / UAV Terminal, Radio, NVGs
case IDX_LOADOUT_ASSIGNEDITEMS: {
// Check if assignedItems have items that need replacing with a defined base
_items = _x;
{
if (_x != "") then {
_uniqueBaseCfgText = (getText (_cfgWeapons >> _x >> QGVAR(uniqueBase))) call EFUNC(common,getConfigName);
if (_uniqueBaseCfgText != "") then {
_items set [_forEachIndex, _uniqueBaseCfgText];
};
};
} forEach _items;
};
};
} forEach _loadout;
_loadout

View File

@ -1,7 +1,8 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Dedmen
* Cache an array of all the compatible items for arsenal.
* Author: Dedmen, johnb43
* Cache an array of all the compatible items for arsenals.
*
* Arguments:
* None
@ -12,178 +13,256 @@
* Public: No
*/
private _cargo = [
[[], [], []], // Weapons 0, primary, secondary, handgun
[[], [], [], []], // WeaponAccessories 1, optic,side,muzzle,bipod
[ ], // Magazines 2
[ ], // Headgear 3
[ ], // Uniform 4
[ ], // Vest 5
[ ], // Backpacks 6
[ ], // Goggles 7
[ ], // NVGs 8
[ ], // Binoculars 9
[ ], // Map 10
[ ], // Compass 11
[ ], // Radio slot 12
[ ], // Watch slot 13
[ ], // Comms slot 14
[ ], // WeaponThrow 15
[ ], // WeaponPut 16
[ ] // InventoryItems 17
private _configItems = [
[IDX_VIRT_WEAPONS, createHashMapFromArray [[IDX_VIRT_PRIMARY_WEAPONS, createHashMap], [IDX_VIRT_SECONDARY_WEAPONS, createHashMap], [IDX_VIRT_HANDGUN_WEAPONS, createHashMap]]],
[IDX_VIRT_ATTACHMENTS, createHashMapFromArray [[IDX_VIRT_OPTICS_ATTACHMENTS, createHashMap], [IDX_VIRT_FLASHLIGHT_ATTACHMENTS, createHashMap], [IDX_VIRT_MUZZLE_ATTACHMENTS, createHashMap], [IDX_VIRT_BIPOD_ATTACHMENTS, createHashMap]]]
];
private _configCfgWeapons = configFile >> "CfgWeapons"; //Save this lookup in variable for perf improvement
_configItems = createHashMapFromArray _configItems;
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
_configItems set [_index, createHashMap];
};
// https://community.bistudio.com/wiki/Arma_3:_Characters_And_Gear_Encoding_Guide#Character_configuration
// https://github.com/acemod/ACE3/pull/9040#issuecomment-1597748331
private _filterFunction = toString {
isClass _x && {if (isNumber (_x >> "scopeArsenal")) then {getNumber (_x >> "scopeArsenal") == 2 && {getNumber (_x >> "scope") > 0}} else {getNumber (_x >> "scope") == 2}} && {getNumber (_x >> QGVAR(hide)) != 1}
};
private _cfgWeapons = configFile >> "CfgWeapons";
private _cfgMagazines = configFile >> "CfgMagazines";
private _className = "";
private _simulationType = "";
private _configItemInfo = "";
private _hasItemInfo = false;
private _itemInfoType = 0;
private _isMiscItem = false;
// Get weapons and other various items
{
private _configItemInfo = _x >> "ItemInfo";
private _simulationType = getText (_x >> "simulation");
private _className = configName _x;
private _hasItemInfo = isClass (_configItemInfo);
private _itemInfoType = if (_hasItemInfo) then {getNumber (_configItemInfo >> "type")} else {0};
private _isMiscItem = _className isKindOf ["CBA_MiscItem", (_configCfgWeapons)];
_className = configName _x;
_simulationType = getText (_x >> "simulation");
_configItemInfo = _x >> "ItemInfo";
_hasItemInfo = isClass (_configItemInfo);
_itemInfoType = if (_hasItemInfo) then {getNumber (_configItemInfo >> "type")} else {0};
_isMiscItem = _className isKindOf ["CBA_MiscItem", _cfgWeapons];
switch true do {
/* Weapon acc */
switch (true) do {
// Weapon attachments
case (
_hasItemInfo &&
{_itemInfoType in [TYPE_MUZZLE, TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_BIPOD]} &&
{!_isMiscItem}
): {
//Convert type to array index
(_cargo select 1) select ([TYPE_OPTICS,TYPE_FLASHLIGHT,TYPE_MUZZLE,TYPE_BIPOD] find _itemInfoType) pushBackUnique _className;
_hasItemInfo &&
{!_isMiscItem} &&
{_itemInfoType in [TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_MUZZLE, TYPE_BIPOD]}
): {
// Convert type to array index
((_configItems get IDX_VIRT_ATTACHMENTS) get ([TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_MUZZLE, TYPE_BIPOD] find _itemInfoType)) set [_className call FUNC(baseWeapon), nil];
};
/* Headgear */
// Headgear
case (_itemInfoType == TYPE_HEADGEAR): {
(_cargo select 3) pushBackUnique _className;
(_configItems get IDX_VIRT_HEADGEAR) set [_className, nil];
};
/* Uniform */
// Uniform
case (_itemInfoType == TYPE_UNIFORM): {
(_cargo select 4) pushBackUnique _className;
(_configItems get IDX_VIRT_UNIFORM) set [_className, nil];
};
/* Vest */
// Vest
case (_itemInfoType == TYPE_VEST): {
(_cargo select 5) pushBackUnique _className;
(_configItems get IDX_VIRT_VEST) set [_className, nil];
};
/* NVgs */
// NVGs
case (_simulationType == "NVGoggles"): {
(_cargo select 8) pushBackUnique _className;
(_configItems get IDX_VIRT_NVG) set [_className, nil];
};
/* Binos */
case (_simulationType == "Binocular" ||
((_simulationType == 'Weapon') && {(getNumber (_x >> 'type') == TYPE_BINOCULAR_AND_NVG)})): {
(_cargo select 9) pushBackUnique _className;
// Binos
case (
_simulationType == "Binocular" ||
{_simulationType == "Weapon" && {getNumber (_x >> "type") == TYPE_BINOCULAR_AND_NVG}}
): {
(_configItems get IDX_VIRT_BINO) set [_className call FUNC(baseWeapon), nil];
};
/* Map */
// Map
case (_simulationType == "ItemMap"): {
(_cargo select 10) pushBackUnique _className;
(_configItems get IDX_VIRT_MAP) set [_className, nil];
};
/* Compass */
// Compass
case (_simulationType == "ItemCompass"): {
(_cargo select 11) pushBackUnique _className;
(_configItems get IDX_VIRT_COMPASS) set [_className, nil];
};
/* Radio */
// Radio
case (_simulationType == "ItemRadio"): {
(_cargo select 12) pushBackUnique _className;
(_configItems get IDX_VIRT_RADIO) set [_className, nil];
};
/* Watch */
// Watch
case (_simulationType == "ItemWatch"): {
(_cargo select 13) pushBackUnique _className;
(_configItems get IDX_VIRT_WATCH) set [_className, nil];
};
/* GPS */
case (_simulationType == "ItemGPS"): {
(_cargo select 14) pushBackUnique _className;
// GPS and UAV terminals
case (
_simulationType == "ItemGPS" ||
{_itemInfoType == TYPE_UAV_TERMINAL}
): {
(_configItems get IDX_VIRT_COMMS) set [_className, nil];
};
/* UAV terminals */
case (_itemInfoType == TYPE_UAV_TERMINAL): {
(_cargo select 14) pushBackUnique _className;
};
/* Weapon, at the bottom to avoid adding binos */
case (isClass (_x >> "WeaponSlotsInfo") &&
{getNumber (_x >> 'type') != TYPE_BINOCULAR_AND_NVG}): {
// Weapon, at the bottom to avoid adding binos
case (
isClass (_x >> "WeaponSlotsInfo") &&
{getNumber (_x >> "type") != TYPE_BINOCULAR_AND_NVG}
): {
switch (getNumber (_x >> "type")) do {
case TYPE_WEAPON_PRIMARY: {
(_cargo select 0) select 0 pushBackUnique (_className call bis_fnc_baseWeapon);
((_configItems get IDX_VIRT_WEAPONS) get IDX_VIRT_PRIMARY_WEAPONS) set [_className call FUNC(baseWeapon), nil];
};
case TYPE_WEAPON_HANDGUN: {
(_cargo select 0) select 2 pushBackUnique (_className call bis_fnc_baseWeapon);
((_configItems get IDX_VIRT_WEAPONS) get IDX_VIRT_HANDGUN_WEAPONS) set [_className call FUNC(baseWeapon), nil];
};
case TYPE_WEAPON_SECONDARY: {
(_cargo select 0) select 1 pushBackUnique (_className call bis_fnc_baseWeapon);
((_configItems get IDX_VIRT_WEAPONS) get IDX_VIRT_SECONDARY_WEAPONS) set [_className call FUNC(baseWeapon), nil];
};
};
};
/* Misc items */
// Misc. items
case (
_hasItemInfo &&
(_itemInfoType in [TYPE_MUZZLE, TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_BIPOD] &&
{_isMiscItem}) ||
{_itemInfoType in [TYPE_FIRST_AID_KIT, TYPE_MEDIKIT, TYPE_TOOLKIT]} ||
{(getText ( _x >> "simulation")) == "ItemMineDetector"}
): {
(_cargo select 17) pushBackUnique _className;
_hasItemInfo &&
{_isMiscItem &&
{_itemInfoType in [TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_MUZZLE, TYPE_BIPOD]}} ||
{_itemInfoType in [TYPE_FIRST_AID_KIT, TYPE_MEDIKIT, TYPE_TOOLKIT]} ||
{_simulationType == "ItemMineDetector"}
): {
(_configItems get IDX_VIRT_MISC_ITEMS) set [_className, nil];
};
};
} foreach configProperties [_configCfgWeapons, "isClass _x && {(if (isNumber (_x >> 'scopeArsenal')) then {getNumber (_x >> 'scopeArsenal')} else {getNumber (_x >> 'scope')}) == 2} && {getNumber (_x >> 'ace_arsenal_hide') != 1}", true];
} forEach configProperties [_cfgWeapons, _filterFunction, true];
private _grenadeList = [];
{
_grenadeList append getArray (_configCfgWeapons >> "Throw" >> _x >> "magazines");
} foreach getArray (_configCfgWeapons >> "Throw" >> "muzzles");
private _putList = [];
{
_putList append getArray (_configCfgWeapons >> "Put" >> _x >> "magazines");
} foreach getArray (_configCfgWeapons >> "Put" >> "muzzles");
// Get all grenades
private _grenadeList = createHashMap;
{
private _className = configName _x;
_grenadeList insert [true, (getArray (_cfgWeapons >> "Throw" >> _x >> "magazines")) apply {_x call EFUNC(common,getConfigName)}, []];
} forEach getArray (_cfgWeapons >> "Throw" >> "muzzles");
switch true do {
// Get all explosives, mines, IEDS and similar
private _putList = createHashMap;
{
_putList insert [true, (getArray (_cfgWeapons >> "Put" >> _x >> "magazines")) apply {_x call EFUNC(common,getConfigName)}, []];
} forEach getArray (_cfgWeapons >> "Put" >> "muzzles");
// Remove invalid/non-existent entries
_grenadeList deleteAt "";
_putList deleteAt "";
private _magazineMiscItems = createHashMap;
// Get all other grenades, explosives (and similar) and magazines
{
_className = configName _x;
switch (true) do {
// "Misc. items" magazines (e.g. spare barrels, intel, photos)
case (getNumber (_x >> "ACE_isUnique") == 1): {
(_configItems get IDX_VIRT_MISC_ITEMS) set [_className, nil];
_magazineMiscItems set [_className, nil];
};
// Grenades
case (_className in _grenadeList): {
(_cargo select 15) pushBackUnique _className;
(_configItems get IDX_VIRT_GRENADES) set [_className, nil];
};
// Put
// Explosives
case (_className in _putList): {
(_cargo select 16) pushBackUnique _className;
(_configItems get IDX_VIRT_EXPLOSIVES) set [_className, nil];
};
// Rifle, handgun, secondary weapons mags
// Primary, handgun & secondary weapon magazines, and magazines that are forced with "ace_arsenal_hide = -1"
case (
((getNumber (_x >> "type") in [TYPE_MAGAZINE_PRIMARY_AND_THROW,TYPE_MAGAZINE_SECONDARY_AND_PUT,1536,TYPE_MAGAZINE_HANDGUN_AND_GL,TYPE_MAGAZINE_MISSILE]) ||
{(getNumber (_x >> QGVAR(hide))) == -1})
): {
(_cargo select 2) pushBackUnique _className;
getNumber (_x >> QGVAR(hide)) == -1 ||
{getNumber (_x >> "type") in [TYPE_MAGAZINE_PRIMARY_AND_THROW, TYPE_MAGAZINE_SECONDARY_AND_PUT, 1536, TYPE_MAGAZINE_HANDGUN_AND_GL, TYPE_MAGAZINE_MISSILE]}
): {
(_configItems get IDX_VIRT_ITEMS_ALL) set [_className, nil];
};
};
} foreach configProperties [(configFile >> "CfgMagazines"), "isClass _x && {(if (isNumber (_x >> 'scopeArsenal')) then {getNumber (_x >> 'scopeArsenal')} else {getNumber (_x >> 'scope')}) == 2} && {getNumber (_x >> 'ace_arsenal_hide') != 1}", true];
} forEach configProperties [_cfgMagazines, _filterFunction, true];
// Get all backpacks
{
if (getNumber (_x >> "isBackpack") == 1) then {
(_cargo select 6) pushBackUnique (configName _x);
(_configItems get IDX_VIRT_BACKPACK) set [configName _x, nil];
};
} foreach configProperties [(configFile >> "CfgVehicles"), "isClass _x && {(if (isNumber (_x >> 'scopeArsenal')) then {getNumber (_x >> 'scopeArsenal')} else {getNumber (_x >> 'scope')}) == 2} && {getNumber (_x >> 'ace_arsenal_hide') != 1}", true];
} forEach configProperties [configFile >> "CfgVehicles", _filterFunction, true];
// Get all facewear
{
(_configItems get IDX_VIRT_GOGGLES) set [configName _x, nil];
} forEach configProperties [configFile >> "CfgGlasses", _filterFunction, true];
// Get all faces
private _faceCache = createHashMap;
private _dlcName = "";
private _modPicture = "";
private _faceCategory = "";
{
(_cargo select 7) pushBackUnique (configName _x);
} foreach configProperties [(configFile >> "CfgGlasses"), "isClass _x && {(if (isNumber (_x >> 'scopeArsenal')) then {getNumber (_x >> 'scopeArsenal')} else {getNumber (_x >> 'scope')}) == 2} && {getNumber (_x >> 'ace_arsenal_hide') != 1}", true];
_faceCategory = configName _x;
private _magazineGroups = createHashMap;
private _cfgMagazines = configFile >> "CfgMagazines";
{
private _magList = [];
{
private _magazines = (getArray _x) select {isClass (_cfgMagazines >> _x)}; //filter out non-existent magazines
_magazines = _magazines apply {configName (_cfgMagazines >> _x)}; //Make sure classname case is correct
_magList append _magazines;
} foreach configProperties [_x, "isArray _x", true];
if (getNumber (_x >> "disabled") == 0 && {getText (_x >> "head") != ""} && {configName _x != "Default"}) then {
_dlcName = _x call EFUNC(common,getAddon);
_modPicture = "";
_magazineGroups set [toLower configName _x, _magList arrayIntersect _magList];
} foreach configProperties [(configFile >> "CfgMagazineWells"), "isClass _x", true];
if (_dlcName != "") then {
_modPicture = (modParams [_dlcName, ["logo"]]) param [0, ""];
};
uiNamespace setVariable [QGVAR(configItems), _cargo];
uiNamespace setVariable [QGVAR(configItemsFlat), flatten _cargo];
uiNamespace setVariable [QGVAR(magazineGroups), _magazineGroups];
_faceCache set [configName _x, [getText (_x >> "displayName"), _modPicture, _faceCategory]];
};
} forEach ("true" configClasses _x);
} forEach ("true" configClasses (configfile >> "CfgFaces"));
// Get all voices
private _voiceCache = (configProperties [configFile >> "CfgVoice", "isClass _x && {getNumber (_x >> 'scope') == 2}", true]) - [configfile >> "CfgVoice" >> "NoVoice"];
_voiceCache = _voiceCache apply {configName _x};
// Get all insignia
private _insigniaCache = "(if (isNumber (_x >> 'scope')) then {getNumber (_x >> 'scope')} else {2}) == 2" configClasses (configFile >> "CfgUnitInsignia");
_insigniaCache = _insigniaCache apply {configName _x};
// Get all disposable launchers
private _launchersConfig = configProperties [configFile >> "CBA_DisposableLaunchers"];
private _launchers = createHashMap;
private _launcher = "";
// Get the loaded launchers (used launchers aren't necessary)
{
// Convert to config case
_launcher = ((getArray _x) param [0, ""]) call EFUNC(common,getConfigName);
if (_launcher != "") then {
_launchers set [_launcher, nil];
};
} forEach _launchersConfig;
private _configItemsFlat = +_configItems;
private _weapons = _configItemsFlat deleteAt IDX_VIRT_WEAPONS;
private _attachments = _configItemsFlat deleteAt IDX_VIRT_ATTACHMENTS;
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
_configItemsFlat merge [_configItemsFlat deleteAt _index, true];
};
for "_index" from IDX_VIRT_PRIMARY_WEAPONS to IDX_VIRT_HANDGUN_WEAPONS do {
_configItemsFlat merge [_weapons deleteAt _index, true];
};
for "_index" from IDX_VIRT_OPTICS_ATTACHMENTS to IDX_VIRT_BIPOD_ATTACHMENTS do {
_configItemsFlat merge [_attachments deleteAt _index, true];
};
// This contains config case entries only
uiNamespace setVariable [QGVAR(configItems), _configItems];
uiNamespace setVariable [QGVAR(configItemsFlat), _configItemsFlat];
uiNamespace setVariable [QGVAR(faceCache), _faceCache];
uiNamespace setVariable [QGVAR(voiceCache), _voiceCache];
uiNamespace setVariable [QGVAR(insigniaCache), _insigniaCache];
uiNamespace setVariable [QGVAR(grenadeCache), _grenadeList];
uiNamespace setVariable [QGVAR(putCache), _putList];
uiNamespace setVariable [QGVAR(magazineMiscItems), _magazineMiscItems];
uiNamespace setVariable [QGVAR(CBAdisposableLaunchers), _launchers];

View File

@ -15,54 +15,46 @@
if (GVAR(centerNotPlayer)) exitWith {};
// Determine action to play based on current category selection
private _nextAction = switch (GVAR(currentLeftPanel)) do {
case IDC_buttonPrimaryWeapon : {
["Civil", "PrimaryWeapon"] select ((GVAR(currentItems) select 0) != "")
// Primary weapon
case IDC_buttonPrimaryWeapon: {
["Civil", "PrimaryWeapon"] select ((GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON) != "")
};
case IDC_buttonSecondaryWeapon : {
["Civil", "SecondaryWeapon"] select (GVAR(currentItems) select 1 != "")
// Secondary weapon
case IDC_buttonSecondaryWeapon: {
["Civil", "SecondaryWeapon"] select ((GVAR(currentItems) select IDX_CURR_SECONDARY_WEAPON) != "")
};
case IDC_buttonHandgun : {
["Civil", "HandGunOn"] select (GVAR(currentItems) select 2 != "")
// Handgun weapon
case IDC_buttonHandgun: {
["Civil", "HandGunOn"] select ((GVAR(currentItems) select IDX_CURR_HANDGUN_WEAPON) != "")
};
case IDC_buttonHeadgear;
case IDC_buttonUniform;
case IDC_buttonVest;
case IDC_buttonBackpack;
case IDC_buttonGoggles;
case IDC_buttonMap;
case IDC_buttonGPS;
case IDC_buttonRadio;
case IDC_buttonCompass;
case IDC_buttonWatch;
case IDC_buttonFace;
case IDC_buttonNVG : {
"Civil"
// Binoculars
case IDC_buttonBinoculars: {
["Civil", "Binoculars"] select ((GVAR(currentItems) select IDX_CURR_BINO) != "")
};
case IDC_buttonBinoculars : {
["Civil", "Binoculars"] select (GVAR(currentItems) select 9 != "")
};
case IDC_buttonInsignia : {
// Insignia
case IDC_buttonInsignia: {
"Salute"
};
case IDC_buttonVoice : {
// Voice
case IDC_buttonVoice: {
GVAR(center) directSay "CuratorObjectPlaced";
"Civil"
};
// Other
default {
"Civil"
};
};
// Play the action if a new category of item was selected
if (_nextAction != GVAR(currentAction)) then {
switch (_nextAction) do {
case "PrimaryWeapon": {
GVAR(selectedWeaponType) = 0;
};
case "SecondaryWeapon": {
GVAR(selectedWeaponType) = 1;
};
case "HandGunOn": {
GVAR(selectedWeaponType) = 2;
};
GVAR(selectedWeaponType) = switch (_nextAction) do {
case "PrimaryWeapon": {0};
case "SecondaryWeapon": {1};
case "HandGunOn": {2};
default {GVAR(selectedWeaponType)};
};
if (simulationEnabled GVAR(center)) then {

View File

@ -1,11 +1,11 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe, Dedmen, Brett Mayson
* Sort arsenal panel.
* Author: Alganthe, Dedmen, Brett Mayson, johnb43
* Sort an arsenal panel.
*
* Arguments:
* 0: Sort control <CONTROL>
* 0: Control <CONTROL>
*
* Return Value:
* None
@ -13,12 +13,23 @@
* Public: No
*/
params ["_sortControl"];
params ["_control"];
private _display = ctrlParent _sortControl;
// When filling the sorting panel, FUNC(sortPanel) is called twice, so ignore first call
if (GVAR(ignoreFirstSortPanelCall)) exitWith {
GVAR(ignoreFirstSortPanelCall) = false;
};
private _rightSort = ctrlIDC _sortControl == 17;
private _display = ctrlParent _control;
private _rightSort = (ctrlIDC _control) in [IDC_sortRightTab, IDC_sortRightTabDirection];
private _right = _rightSort && {GVAR(currentLeftPanel) in [IDC_buttonUniform, IDC_buttonVest, IDC_buttonBackpack]};
private _sortCtrl = _display displayCtrl ([IDC_sortLeftTab, IDC_sortRightTab] select _rightSort);
private _sortDirectionCtrl = _display displayCtrl ([IDC_sortLeftTabDirection, IDC_sortRightTabDirection] select _rightSort);
private _cfgMagazines = configFile >> "CfgMagazines";
private _cfgFaces = configFile >> "CfgFaces";
private _cfgUnitInsignia = configFile >> "CfgUnitInsignia";
private _cfgUnitInsigniaMission = missionConfigFile >> "CfgUnitInsignia";
if (_rightSort) then {
[
@ -33,8 +44,8 @@ if (_rightSort) then {
case IDC_buttonThrow;
case IDC_buttonPut;
case IDC_buttonMag;
case IDC_buttonMagALL: { configFile >> "CfgMagazines" };
default { configFile >> "CfgWeapons" };
case IDC_buttonMagALL: {_cfgMagazines};
default {configFile >> "CfgWeapons"};
},
GVAR(sortListRightPanel) select (
switch (GVAR(currentRightPanel)) do {
@ -56,12 +67,12 @@ if (_rightSort) then {
[
_display displayCtrl IDC_leftTabContent,
switch (GVAR(currentLeftPanel)) do {
case IDC_buttonBackpack: { configFile >> "CfgVehicles" };
case IDC_buttonGoggles: { configFile >> "CfgGlasses" };
case IDC_buttonFace: { configFile >> "CfgFaces" >> "Man_A3" };
case IDC_buttonVoice: { configFile >> "CfgVoice" };
case IDC_buttonInsignia: { configFile >> "CfgUnitInsignia" };
default { configFile >> "CfgWeapons" };
case IDC_buttonBackpack: {configFile >> "CfgVehicles"};
case IDC_buttonGoggles: {configFile >> "CfgGlasses"};
case IDC_buttonFace: {_cfgFaces};
case IDC_buttonVoice: {configFile >> "CfgVoice"};
case IDC_buttonInsignia: {_cfgUnitInsignia};
default {configFile >> "CfgWeapons"};
},
(GVAR(sortListLeftPanel) select ([
IDC_buttonPrimaryWeapon,
@ -86,101 +97,174 @@ if (_rightSort) then {
]
} params ["_panel", "_cfgClass", "_sorts"];
// Get sort & sort direction
private _sortName = _sortCtrl lbData (0 max lbCurSel _sortCtrl);
private _sortDirection = _sortDirectionCtrl lbValue (0 max lbCurSel _sortDirectionCtrl);
(_sorts select (0 max (_sorts findIf {(_x select 0) == _sortName}))) params ["", "_displayName", "_statement"];
// Update last sort & sort direction
missionNamespace setVariable [
[QGVAR(lastSortLeft), QGVAR(lastSortRight)] select _rightSort,
_displayName
];
missionNamespace setVariable [
[QGVAR(lastSortDirectionLeft), QGVAR(lastSortDirectionRight)] select _rightSort,
_sortDirection
];
// Get currently selected item
private _curSel = if (_right) then {
lnbCurSelRow _panel
} else {
lbCurSel _panel
};
private _selected = if (_right) then {
_panel lnbData [_curSel, 0];
_panel lnbData [_curSel, 0]
} else {
_panel lbData _curSel
};
private _sortName = _sortControl lbData (0 max lbCurSel _sortControl);
private _sortConfig = _sorts select (0 max (_sorts findIf {(_x select 0) isEqualTo _sortName}));
private _statement = _sortConfig select 2;
missionNamespace setVariable [
[QGVAR(lastSortLeft), QGVAR(lastSortRight)] select _rightSort,
_sortConfig select 1
];
private _originalNames = createHashMap;
private _item = "";
private _quantity = "";
private _itemCfg = configNull;
private _value = "";
private _name = "";
private _magazineMiscItems = uiNamespace getVariable QGVAR(magazineMiscItems);
private _sortCache = uiNamespace getVariable QGVAR(sortCache);
private _faceCache = if (_cfgClass == _cfgFaces) then {
uiNamespace getVariable [QGVAR(faceCache), createHashMap]
} else {
createHashMap
};
private _countColumns = if (_right) then {
count lnbGetColumnsPosition _panel
} else {
0
};
private _for = if (_right) then {
for '_i' from 0 to ((lnbSize _panel select 0) - 1)
for '_i' from 0 to (lnbSize _panel select 0) - 1
} else {
for '_i' from 0 to (lbSize _panel - 1)
for '_i' from 0 to (lbSize _panel) - 1
};
_for do {
private _item = if (_right) then {
// Get item
_item = if (_right) then {
_panel lnbData [_i, 0]
} else {
_panel lbData _i
};
private _quantity = if (_right) then {
// Get item's count
_quantity = if (_right) then {
parseNumber (_panel lnbText [_i, 2])
} else {
0
};
private _itemCfg = _cfgClass >> _item;
// "Misc. items" magazines (e.g. spare barrels, intel, photos)
if (_item in _magazineMiscItems) then {
_cfgClass = _cfgMagazines;
};
// In rare cases, item may not belong to the config class for the panel
// For example, misc items panel can contain CfgVehicles and CfgGlasses items in addition to the usual CfgWeapons items
// Check item's config
_itemCfg = if !(_cfgClass in [_cfgFaces, _cfgUnitInsignia]) then {
_cfgClass >> _item
} else {
// If insignia, check both config and mission file
if (_cfgClass == _cfgUnitInsignia) then {
_itemCfg = _cfgClass >> _item;
if (isNull _itemCfg) then {
_itemCfg = _cfgUnitInsigniaMission >> _item;
};
_itemCfg
} else {
// If face, check correct category
_cfgClass >> (_faceCache get _item) param [2, "Man_A3"] >> _item
};
};
// Some items may not belong to the config class for the panel (e.g. misc. items panel can have unique items)
if (isNull _itemCfg) then {
_itemCfg = _item call CBA_fnc_getItemConfig;
};
private _value = [_itemCfg, _item, _quantity] call _statement;
if (_value isEqualType 0) then {
_value = [_value, 8] call CBA_fnc_formatNumber;
};
if (_value isEqualTo "") then {
_value = "_";
};
// Value can be any type
_value = _sortCache getOrDefaultCall [format ["%1_%2_%3", _sortName, _item, _quantity], {
private _value = [_itemCfg, _item, _quantity] call _statement;
// If number, convert to string (keep 2 decimal after comma; Needed for correct weight sorting)
if (_value isEqualType 0) then {
_value = [_value, 8, 2] call CBA_fnc_formatNumber;
};
// If empty string, add alphabetically small char at beginning to make it sort correctly
if (_value isEqualTo "") then {
_value = "_";
};
_value
}, true];
// Save the current row's item's name in a cache and set text to it's sorting value
if (_right) then {
private _name = _panel lnbText [_i, 1];
_originalNames set [_item, _name];
_originalNames set [_item, _panel lnbText [_i, 1]];
_panel lnbSetText [[_i, 1], format ["%1%2", _value, _name]];
// Use tooltip to sort, as it also contains the classname, which means a fixed alphabetical order is guaranteed
_panel lnbSetText [[_i, 1], format ["%1%2", _value, _panel lbTooltip (_i * _countColumns)]];
} else {
if (_item isNotEqualTo "") then {
private _name = _panel lbText _i;
_originalNames set [_item, _name];
if (_item != "") then {
_originalNames set [_item, _panel lbText _i];
_panel lbSetText [_i, format ["%1%2", _value, _name]];
// Use tooltip to sort, as it also contains the classname, which means a fixed alphabetical order is guaranteed
_panel lbSetText [_i, format ["%1%2", _value, _panel lbTooltip _i]];
};
};
};
// Sort alphabetically, find the previously selected item, select it again and reset text to original text
if (_right) then {
_panel lnbSort [1, false];
_panel lnbSort [1, _sortDirection == ASCENDING];
_for do {
private _data = _panel lnbData [_i, 0];
_item = _panel lnbData [_i, 0];
if (_curSel >= 0 && {_data == _selected}) then {
_panel lnbSetText [[_i, 1], _originalNames get _item];
// Set selection after text, otherwise item info box on the right side shows invalid name
if (_curSel != -1 && {_item == _selected}) then {
_panel lnbSetCurSelRow _i;
};
_panel lnbSetText [[_i, 1], _originalNames get _data];
// To avoid unnecessary checks after previsouly selected item was found
_curSel = -1;
};
};
} else {
lbSort [_panel, "ASC"];
lbSort [_panel, ["DESC", "ASC"] select _sortDirection];
_for do {
private _data = _panel lbData _i;
_item = _panel lbData _i;
if (_curSel >= 0 && {_data == _selected}) then {
_panel lbSetCurSel _i;
// Check if valid item (problems can be caused when searching)
if (_item != "") then {
_panel lbSetText [_i, _originalNames get _item];
};
if (_data isNotEqualTo "") then {
_panel lbSetText [_i, _originalNames get _data];
// Set selection after text, otherwise item info box on the right side shows invalid name
if (_curSel != -1 && {_item == _selected}) then {
_panel lbSetCurSel _i;
// To avoid unnecessary checks after previsouly selected item was found
_curSel = -1;
};
};
};

View File

@ -14,7 +14,6 @@
params ["_config"];
private _fireModes = getArray (_config >> "modes");
private _dispersion = [];
{
@ -27,7 +26,7 @@ private _dispersion = [];
_dispersion pushBackUnique _n;
};
} foreach _fireModes;
} forEach (getArray (_config >> "modes"));
_dispersion sort true;

View File

@ -4,8 +4,8 @@
* Statement to sort items by the amount in inventory.
*
* Arguments:
* 0: Item Config <CONFIG>
* 1: Item Name <STRING>
* 0: Not used
* 1: Not used
* 2: Quantity <NUMBER>
*
* Return Value:

View File

@ -1,6 +1,6 @@
#include "script_component.hpp"
/*
* Author: Brett Mayson
* Author: Brett Mayson, johnb43
* Statement to sort items by the mod they belong to.
*
* Arguments:
@ -14,13 +14,4 @@
params ["_config"];
private _dlc = "";
private _addons = configSourceAddonList _config;
if (_addons isNotEqualTo []) then {
private _mods = configSourceModList (configfile >> "CfgPatches" >> _addons select 0);
if (_mods isNotEqualTo []) then {
_dlc = _mods select 0;
};
};
modParams [_dlc, ["name"]] param [0, ""]
(modParams [_config call EFUNC(common,getAddon), ["name"]]) param [0, ""]

View File

@ -15,10 +15,8 @@
*/
params ["_itemInfo", "_ballisticCo", "_explosiveCo"];
_itemInfo params ["_itemCfg"];
_itemInfo params ["_config"];
(([[_itemCfg], ["passthrough", "armor"]] call BIS_fnc_configExtremes) select 1) params [["_passthroughMax", 0], ["_armorMax", 0]];
(([[_config], ["passthrough", "armor"]] call BIS_fnc_configExtremes) select 1) params [["_passthroughMax", 0], ["_armorMax", 0]];
private _protectionCombined = _passthroughMax * _ballisticCo + _armorMax * _explosiveCo;
_protectionCombined
_passthroughMax * _ballisticCo + _armorMax * _explosiveCo;

View File

@ -14,15 +14,15 @@
params ["_config"];
private _fireModes = getArray (_config >> "modes");
private _fireRate = [];
{
_fireRate pushBackUnique getNumber (_config >> _x >> "reloadTime");
} foreach _fireModes;
} forEach (getArray (_config >> "modes"));
_fireRate sort true;
_fireRate = _fireRate param [0, 0];
if (_fireRate == 0) exitWith {0};
round (60 / _fireRate)

View File

@ -7,7 +7,7 @@
* 0: Item Config <CONFIG>
*
* Return Value:
* Sorting Value <NUMBER|STRING>
* Sorting Value <NUMBER> <STRING>
*
* Public: No
*/
@ -15,6 +15,7 @@
params ["_config"];
private _minZoom = 999; // FOV, so smaller is more zoomed in
{
_minZoom = _minZoom min getNumber (_x >> "opticsZoomMin");
} forEach configProperties [_config >> "ItemInfo" >> "OpticsModes", "isClass _x"];

View File

@ -4,11 +4,11 @@
* Accuracy bar statement.
*
* Arguments:
* 0: stats array (ARRAY)
* 1: item config path (CONFIG)
* 2: Args
* 2.1: Stat limits (ARRAY of BOOL)
* 2.2: Bar limits (ARRAY of SCALAR)
* 0: Not used
* 1: Item config path <CONFIG>
* 2: Args <ARRAY>
* 2.0: Stat limits <ARRAY of BOOLS>
* 2.1: Bar limits <ARRAY of NUMBERS>
*
* Return Value:
* <NUMBER>
@ -16,20 +16,22 @@
* Public: No
*/
params ["_stat", "_config", "_args"];
params ["", "_config", "_args"];
_args params ["_statMinMax", "_barLimits"];
private _fireModes = getArray (_config >> "modes");
private _dispersion = [];
{
if (getNumber (_config >> _x >> "showToPlayer") != 0) then {
private _n = log (getNumber (_config >> _x >> "dispersion"));
if (!finite _n) then {_n = 0;};
if (!finite _n) then {
_n = 0;
};
_dispersion pushBackUnique _n;
};
} foreach _fireModes;
} forEach (getArray (_config >> "modes"));
_dispersion sort true;

View File

@ -7,9 +7,9 @@
* 0: Stat <STRING>
* 1: Item config path <CONFIG>
* 2: Args for configExtreme <ARRAY>
* 2.1: Stat limits <ARRAY of BOOLS>
* 2.2: Bar limits <ARRAY of NUMBERS>
* 2.3: Evaluate as a logarithmic number <BOOL>
* 2.0: Stat limits <ARRAY of BOOLS>
* 2.1: Bar limits <ARRAY of NUMBERS>
* 2.2: Evaluate as a logarithmic number <BOOL>
*
* Return Value:
* Bar statement <NUMBER>

View File

@ -1,15 +1,15 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Impact bar statement.
*
* Arguments:
* 0: stats array (ARRAY)
* 1: item config path (CONFIG)
* 2: Args for configExtreme
* 2.1: Stat limits (ARRAY of BOOL)
* 2.2: Bar limits (ARRAY of SCALAR)
* 2.3: Evaluate as a logarithmic number (BOOL)
* 0: Stats array <ARRAY>
* 1: Item config path <CONFIG>
* 2: Args for configExtreme <ARRAY>
* 2.0: Stats limits <ARRAY of BOOLS>
* 2.1: Bar limits <ARRAY of NUMBERS>
*
* Return Value:
* Number
@ -18,7 +18,7 @@
*/
params ["_stats", "_config", "_args"];
_args params ["_hitMinMax", "_initSpeedMinMax", "_launcherTabIDC"];
_args params ["_hitMinMax", "_initSpeedMinMax"];
private _statValues = [
[_config],
@ -31,4 +31,5 @@ private _statValues = [
_hit = linearConversion [_hitMinMax select 0, _hitMinMax select 1, _hit, 0.01, 1];
_initSpeed = linearConversion [_initSpeedMinMax select 0, _initSpeedMinMax select 1, _initSpeed, 0.01, 1];
[sqrt(_hit^2 * _initSpeed), _hit] select (GVAR(currentLeftPanel) == _launcherTabIDC)
// If launcher tab
[sqrt (_hit ^ 2 * _initSpeed), _hit] select (GVAR(currentLeftPanel) == IDC_buttonSecondaryWeapon)

View File

@ -4,11 +4,11 @@
* Rate of fire bar statement.
*
* Arguments:
* 0: stats array (ARRAY)
* 1: item config path (CONFIG)
* 2: Args
* 2.1: Stat limits (ARRAY of BOOL)
* 2.2: Bar limits (ARRAY of SCALAR)
* 0: Not used
* 1: Item config path <CONFIG>
* 2: Args <ARRAY>
* 2.0: Stat limits <ARRAY of BOOLS>
* 2.1: Bar limits <ARRAY of NUMBERS>
*
* Return Value:
* Number
@ -16,17 +16,20 @@
* Public: No
*/
params ["_stat", "_config", "_args"];
params ["", "_config", "_args"];
_args params ["_statMinMax", "_barLimits"];
private _fireModes = getArray (_config >> "modes");
private _fireRate = [];
{
private _n = log (getNumber (_config >> _x >> "reloadTime"));
if (!finite _n) then {_n = 0;};
if (!finite _n) then {
_n = 0;
};
_fireRate pushBackUnique _n;
} foreach _fireModes;
} forEach (getArray (_config >> "modes"));
_fireRate sort true;

View File

@ -1,34 +1,30 @@
#include "script_component.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Accuracy text statement.
*
* Arguments:
* 0: stat (STRING)
* 1: item config path (CONFIG)
* 2: Args for configExtreme
* 2.1: Stat limits (ARRAY of BOOL)
* 2.2: Evaluate as a logarithmic number (BOOL)
* 0: Not used
* 1: Item config path <CONFIG>
*
* Return Value:
* Number
* Stat Text <STRING>
*
* Public: No
*/
params ["_stat", "_config", "_args"];
_args params ["_statMinMax", "_configExtremeBool"];
params ["", "_config"];
TRACE_1("statTextStatement_accuracy",_config);
private _fireModes = getArray (_config >> "modes");
private _dispersion = [];
{
if (getNumber (_config >> _x >> "showToPlayer") != 0) then {
_dispersion pushBackUnique (getNumber (_config >> _x >> "dispersion"));
};
} foreach _fireModes;
} forEach (getArray (_config >> "modes"));
_dispersion sort true;
_dispersion = _dispersion param [0, 0];
format ["%1 MIL (%2 MOA)", (_dispersion * 1000) toFixed 2, (_dispersion / pi * 10800) ToFixed 1];
format ["%1 MIL (%2 MOA)", (_dispersion * 1000) toFixed 2, (_dispersion / pi * 10800) toFixed 1];

View File

@ -4,8 +4,8 @@
* Text statement for the explosion time stat.
*
* Arguments:
* 0: Stats Array (not used) <ARRAY>
* 1: Item Config <CONFIG>
* 0: Not used
* 1: Item config path <CONFIG>
*
* Return Value:
* Stat Text <STRING>
@ -17,17 +17,19 @@
*/
params ["", "_config"];
TRACE_1("statTextStatement_explosionTime",_config);
private _ammoConfig = configFile >> "CfgAmmo" >> getText (_config >> "ammo");
private _timeToLive = getNumber (_ammoConfig >> "timeToLive");
private _explosionTime = getNumber (_ammoConfig >> "explosionTime");
// Handle IR grenades
if (_explosionTime > _timeToLive) exitWith {
"-" // Handle IR grenades
"-"
};
if (_explosionTime == -1) exitWith {
localize LSTRING(DetonatesOnImpact)
LLSTRING(DetonatesOnImpact)
};
format ["%1s", _explosionTime]

View File

@ -4,16 +4,17 @@
* Text statement for the mass stat.
*
* Arguments:
* 0: not used
* 1: item config path (CONFIG)
* 0: Not used
* 1: Item config path <CONFIG>
*
* Return Value:
* String to display
* Stat Text <STRING>
*
* Public: No
*/
params ["", "_config"];
TRACE_1("statTextStatement_mass",_config);
private _mass = getNumber (_config >> "mass");
@ -25,4 +26,4 @@ if (_mass == 0 && {isClass (_config >> "WeaponSlotsInfo")}) then {
_mass = getNumber (_config >> "WeaponSlotsInfo" >> "mass");
};
format ["%1kg (%2lb)",((_mass * 0.1 * (1/2.2046) * 100) / 100) ToFixed 2, ((_mass * 0.1 * 100) / 100) ToFixed 2]
format ["%1kg (%2lb)", ((_mass * 0.1 * (1 / 2.2046) * 100) / 100) toFixed 2, ((_mass * 0.1 * 100) / 100) toFixed 2]

View File

@ -4,30 +4,27 @@
* Rate of fire text statement.
*
* Arguments:
* 0: stat (STRING)
* 1: item config path (CONFIG)
* 2: Args for configExtreme
* 2.1: Stat limits (ARRAY of BOOL)
* 2.2: Evaluate as a logarithmic number (BOOL)
* 0: Not used
* 1: Item config path <CONFIG>
*
* Return Value:
* String
* Stat Text <STRING>
*
* Public: No
*/
params ["_stat", "_config", "_args"];
_args params ["_statMinMax", "_configExtremeBool"];
params ["", "_config"];
TRACE_1("statTextStatement_rateOfFire",_config);
private _fireModes = getArray (_config >> "modes");
private _fireRate = [];
{
_fireRate pushBackUnique (getNumber (_config >> _x >> "reloadTime"));
} foreach _fireModes;
} forEach (getArray (_config >> "modes"));
_fireRate sort true;
_fireRate = _fireRate param [0, 0];
if (_fireRate == 0) exitWith {"PEWPEWPEW"};
format ["%1 rpm", round (60 / _fireRate)]

View File

@ -4,11 +4,11 @@
* Text statement for the scope magnification stat.
*
* Arguments:
* 0: not used
* 1: item config path (CONFIG)
* 0: Not used
* 1: Item config path <CONFIG>
*
* Return Value:
* String to display
* Stat Text <STRING>
*
* Public: No
*/
@ -17,10 +17,11 @@ params ["", "_config"];
TRACE_1("statTextStatement_scopeMag",_config);
private _minZoom = 999; // FOV, so smaller is more zoomed in
{
_minZoom = _minZoom min (getNumber (_x >> "opticsZoomMin"));
} forEach configProperties [_config >> "ItemInfo" >> "OpticsModes"];
if (_minZoom in [0, 999]) exitWith {"?"};
format ["%1x", (0.25/_minZoom) toFixed 1]
format ["%1x", (0.25 / _minZoom) toFixed 1]

View File

@ -1,14 +1,14 @@
#include "script_component.hpp"
/*
* Author: Dedmen
* Author: Dedmen, johnb43
* Text statement for the scope Night vision support stat.
*
* Arguments:
* 0: not used
* 1: item config path (CONFIG)
* 0: Not used
* 1: Item config path <CONFIG>
*
* Return Value:
* String to display
* Stat Text <STRING>
*
* Public: No
*/
@ -17,12 +17,12 @@ params ["", "_config"];
TRACE_1("statTextStatement_scopeVisionMode",_config);
private _opticsModes = ("true" configClasses (_config >> "ItemInfo" >> "OpticsModes")) apply {
private _visionMode = getArray (_x >> "visionMode");
private _visionMode = getArray (_x >> "visionMode") apply {toLower _x};
[
getNumber (_x >> "useModelOptics") == 1, //is in optics
_visionMode isEqualTo [], //optional NVG
"NVG" in _visionMode, //Integrated NVG
"Ti" in _visionMode //Integrated Thermal
getNumber (_x >> "useModelOptics") == 1, // Is in optics
_visionMode isEqualTo [], // Optional NVG
"nvg" in _visionMode, // Integrated NVG
"ti" in _visionMode // Integrated Thermal
]
};
@ -33,26 +33,29 @@ private _secondaryNVGSupported = false;
{
_x params ["_isPrimary", "_optionalNvg", "_integratedNVG", "_integratedTi"];
if (_isPrimary) then {
if (_integratedNVG) then {
_primaryNVGIntegrated = true;
};
if (_optionalNvg) then {
_primaryNVGSupported = true;
};
if (_integratedTi) then {
_primaryTiIntegrated = true;
};
} else {
if (_optionalNvg) then {
_secondaryNVGSupported = true;
}
}
};
};
} forEach _opticsModes;
//Detecting Primary by useModelOptics works in 99.9% of cases.
//But on some scopes (from one specific mod) even the primary mode has useModelOptics=false
//So we have this workaround
// Detecting Primary by useModelOptics works in 99.9% of cases.
// But on some scopes (from one specific mod) even the primary mode has useModelOptics=false
// So we have this workaround
// If we only have a single mode and it's a secondary, then consider it primary.
if (count _opticsModes == 1 && {!(_opticsModes select 0 select 0)}) then {

View File

@ -4,22 +4,22 @@
* Text statement for the smoke / chemlight time to live stat.
*
* Arguments:
* 0: not used
* 1: item config path (CONFIG)
* 0: Not used
* 1: Item config path <CONFIG>
*
* Return Value:
* String to display
* Stat Text <STRING>
*
* Public: No
*/
params ["", "_config"];
TRACE_1("statTextStatement_smokeChemTTL",_config);
private _TTL = getNumber (configFile >> "CfgAmmo" >> getText (_config >> "ammo") >> "timeToLive");
if (_TTL > 3600) then {
_TTL = _TTL / 60^2;
_TTL = _TTL / 3600;
_TTL = str _TTL splitString ".";
if (count _TTL > 1) then {
@ -35,6 +35,5 @@ if (_TTL > 3600) then {
]
};
} else {
format ["%1m", round (_TTL / 60)];
format ["%1m", round (_TTL / 60)]
};

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
/*
* Author: Karel Moricky, modified by Alganthe
* Update camera position
* Update camera position.
* Modernized a bit, modified vars to fit arsenal rewrite.
*
* Arguments:
@ -16,9 +16,10 @@
* Public: Yes
*/
GVAR(cameraPosition) params ["_distance", "_dirH", "_dirV"];
[GVAR(cameraHelper), [_dirH + 180, - _dirV, 0]] call bis_fnc_setobjectrotation;
GVAR(cameraHelper) attachTo [GVAR(center), GVAR(cameraPosition) select 3, ""]; //--- Reattach for smooth movement
GVAR(cameraPosition) params ["_distance", "_dirH", "_dirV"];
[GVAR(cameraHelper), [_dirH + 180, - _dirV, 0]] call BIS_fnc_setObjectRotation;
GVAR(cameraHelper) attachTo [GVAR(center), GVAR(cameraPosition) select 3, ""]; // Reattach for smooth movement
GVAR(camera) setPos (GVAR(cameraHelper) modelToWorld [0, -_distance, 0]);
GVAR(camera) setVectorDirAndUp [vectorDir GVAR(cameraHelper), vectorUp GVAR(cameraHelper)];

View File

@ -0,0 +1,85 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: johnb43
* Updates the list of current items.
*
* Arguments:
* None
*
* Return Value:
* None
*
* Public: No
*/
GVAR(currentItems) = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", [], [], [], [], [], [], []];
private _isWeapon = false;
private _indexCurrentItems = -1;
// Add the items the player has to currentItems
{
switch (_forEachIndex) do {
// Primary weapon, Secondary weapon, Handgun weapon, Binoculars
case IDX_LOADOUT_PRIMARY_WEAPON;
case IDX_LOADOUT_SECONDARY_WEAPON;
case IDX_LOADOUT_HANDGUN_WEAPON;
case IDX_LOADOUT_BINO: {
_x params [["_weapon", ""], ["_muzzle", ""], ["_flashlight", ""], ["_optics", ""], ["_primaryMagazine", []], ["_secondaryMagazine", []], ["_bipod", ""]];
// Find baseweapon of weapon
if (_weapon != "") then {
_weapon = _weapon call FUNC(baseWeapon);
};
_isWeapon = _forEachIndex != IDX_LOADOUT_BINO;
// If bino, add it in a different place than regular weapons
GVAR(currentItems) set [[IDX_CURR_BINO, _forEachIndex] select _isWeapon, _weapon];
_indexCurrentItems = [IDX_CURR_BINO_ITEMS, IDX_CURR_PRIMARY_WEAPON_ITEMS + _forEachIndex] select _isWeapon;
// Add weapon attachments
{
(GVAR(currentItems) select _indexCurrentItems) set [[2, 1, 0, 3] select _forEachIndex, if (_x != "") then {_x call FUNC(baseWeapon)} else {_x}];
} forEach [_optics, _flashlight, _muzzle, _bipod];
// Add magazines
{
// Magazines are at index 4 & 5 in array -> That's why +4
(GVAR(currentItems) select _indexCurrentItems) set [_forEachIndex + 4, _x param [0, ""]];
} forEach [_primaryMagazine, _secondaryMagazine];
};
// Uniform
case IDX_LOADOUT_UNIFORM: {
GVAR(currentItems) set [IDX_CURR_UNIFORM, _x param [0, ""]];
GVAR(currentItems) set [IDX_CURR_UNIFORM_ITEMS, _x param [1, []]];
};
// Vest
case IDX_LOADOUT_VEST: {
GVAR(currentItems) set [IDX_CURR_VEST, _x param [0, ""]];
GVAR(currentItems) set [IDX_CURR_VEST_ITEMS, _x param [1, []]];
};
// Backpack
case IDX_LOADOUT_BACKPACK: {
GVAR(currentItems) set [IDX_CURR_BACKPACK, _x param [0, ""]];
GVAR(currentItems) set [IDX_CURR_BACKPACK_ITEMS, _x param [1, []]];
};
// Helmet
case IDX_LOADOUT_HEADGEAR: {
GVAR(currentItems) set [IDX_CURR_HEADGEAR, _x];
};
// Facewear
case IDX_LOADOUT_GOGGLES: {
GVAR(currentItems) set [IDX_CURR_GOGGLES, _x];
};
// Assigned items: Map, Compass, Watch, GPS / UAV Terminal, Radio, NVGs
case IDX_LOADOUT_ASSIGNEDITEMS: {
{
// Order of storing currentItems is different than what getUnitLoadout returns, so do some math
GVAR(currentItems) set [IDX_CURR_NVG + ([2, 6, 4, 3, 5, 0] select _forEachIndex), _x];
} forEach _x;
};
};
} forEach (getUnitLoadout GVAR(center)); // Only need items, not extended loadout

View File

@ -1,12 +1,13 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Author: Alganthe, johnb43
* Update the right panel (listnbox).
*
* Arguments:
* 0: Right panel control <CONTROL>
* 1: Max load of the current container <STRING>
* 1: Container <OBJECT>
* 2: If container has items <BOOL>
*
* Return Value:
* None
@ -14,44 +15,43 @@
* Public: No
*/
params ["_control", "_maxLoad"];
params ["_control", "_container", "_hasItems"];
private _loadIndicatorBarCtrl = _display displayCtrl IDC_loadIndicatorBar;
private _curSel = lnbCurSelRow _control;
private _loadRemaining = maxLoad _container - loadAbs _container;
private _rightPanelCache = uiNamespace getVariable [QGVAR(rightPanelCache), createHashMap];
(lnbSize _control) params ["_rows"];
private _mass = -1;
private _color = [];
_maxLoad = getnumber (configfile >> "CfgVehicles" >> _maxLoad >> "maximumLoad");
_maxLoad = _maxLoad * (1 - (progressPosition _loadIndicatorBarCtrl));
_maxLoad = parseNumber (_maxLoad toFixed 2); // Required to avoid an issue where even though the typename returns "SCALAR" it doesn't act as one.
// Grey out items that are too big to fit in remaining space of the container
for "_row" from 0 to (lnbSize _control select 0) - 1 do {
_mass = _rightPanelCache getOrDefault [_control lnbData [_row, 0], 0];
// Grey out items too big
for "_r" from 0 to (_rows - 1) do {
private _mass = _control getVariable (_control lnbData [_r, 0]);
private _class = _control lnbText [_r, 1];
private _alpha = [0.25, 1.0] select (_mass <= _maxLoad);
private _color = [1, 1, 1, _alpha];
_control lnbSetColor [[_r, 1],_color];
_control lnbSetColor [[_r, 2],_color];
// Lower alpha on color for items that can't fit
_color = [1, 1, 1, [0.25, 1] select (_mass <= _loadRemaining)];
_control lnbSetColor [[_row, 1], _color];
_control lnbSetColor [[_row, 2], _color];
};
// Remove all from container show / hide
private _display = ctrlParent _control;
// If there are items inside container, show "remove all" button
private _removeAllCtrl = _display displayCtrl IDC_buttonRemoveAll;
if (progressPosition _loadIndicatorBarCtrl > 0) then {
// A separate "_hasItems" argument is needed, because items can have no mass
_removeAllCtrl ctrlSetFade 0;
_removeAllCtrl ctrlShow _hasItems;
_removeAllCtrl ctrlEnable _hasItems;
_removeAllCtrl ctrlCommit FADE_DELAY;
_removeAllCtrl ctrlSetFade 0;
_removeAllCtrl ctrlShow true;
_removeAllCtrl ctrlEnable true;
_removeAllCtrl ctrlCommit FADE_DELAY;
};
// Update weight display
(_display displayCtrl IDC_totalWeightText) ctrlSetText (format ["%1 (%2)", GVAR(center) call EFUNC(common,getWeight), [GVAR(center), 1] call EFUNC(common,getWeight)]);
(_display displayCtrl IDC_totalWeightText) ctrlSetText (format ["%1 (%2)", [GVAR(center), 2] call EFUNC(common,getWeight), [GVAR(center), 1] call EFUNC(common,getWeight)]);
private _curSel = lnbCurSelRow _control;
// change button color if unique or too big
// Disable '+' button if item is unique or too big to fit in remaining space
if (_curSel != -1) then {
private _plusButtonCtrl = _display displayCtrl IDC_arrowPlus;
_plusButtonCtrl ctrlEnable !((_control lnbValue [_curSel, 2]) == 1 || {(_control getVariable (_control lnbData [_curSel, 0])) > _maxLoad});
_plusButtonCtrl ctrlEnable !((_control lnbValue [_curSel, 2]) == 1 || {(_rightPanelCache getOrDefault [_control lnbData [_curSel, 0], 0]) > _loadRemaining});
_plusButtonCtrl ctrlCommit FADE_DELAY;
};

View File

@ -1,8 +1,9 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Update the list of unique items.
* Author: Alganthe, johnb43
* Updates the list of unique items.
* Unique items are items that can't be multiplied using the arsenal.
*
* Arguments:
* None
@ -13,106 +14,166 @@
* Public: No
*/
GVAR(virtualItems) set [18, []];
GVAR(virtualItems) set [19, []];
GVAR(virtualItems) set [20, []];
GVAR(virtualItems) set [21, []];
GVAR(virtualItems) set [22, [[], [], [], []]];
GVAR(virtualItems) set [23, []];
GVAR(virtualItems) set [24, []];
GVAR(virtualItems) set [IDX_VIRT_UNIQUE_MISC_ITEMS, createHashMap];
GVAR(virtualItems) set [IDX_VIRT_UNIQUE_VIRT_ITEMS_ALL, createHashMap];
GVAR(virtualItems) set [IDX_VIRT_UNIQUE_GRENADES, createHashMap];
GVAR(virtualItems) set [IDX_VIRT_UNIQUE_EXPLOSIVES, createHashMap];
GVAR(virtualItems) set [IDX_VIRT_UNIQUE_ATTACHMENTS, createHashMapFromArray [[IDX_VIRT_OPTICS_ATTACHMENTS, createHashMap], [IDX_VIRT_FLASHLIGHT_ATTACHMENTS, createHashMap], [IDX_VIRT_MUZZLE_ATTACHMENTS, createHashMap], [IDX_VIRT_BIPOD_ATTACHMENTS, createHashMap]]];
GVAR(virtualItems) set [IDX_VIRT_UNIQUE_BACKPACKS, createHashMap];
GVAR(virtualItems) set [IDX_VIRT_UNIQUE_GOGGLES, createHashMap];
GVAR(virtualItems) set [IDX_VIRT_UNIQUE_UNKNOWN_ITEMS, createHashMap];
private _array = LIST_DEFAULTS select IDX_VIRT_ITEMS_ALL;
private _itemsCache = uiNamespace getVariable QGVAR(configItems);
private _configItems = uiNamespace getVariable QGVAR(configItems);
private _configCfgWeapons = configFile >> "CfgWeapons";
private _configMagazines = configFile >> "CfgMagazines";
private _configVehicles = configFile >> "CfgVehicles";
private _configGlasses = configFile >> "CfgGlasses";
private _cfgWeapons = configFile >> "CfgWeapons";
private _cfgMagazines = configFile >> "CfgMagazines";
private _cfgVehicles = configFile >> "CfgVehicles";
private _cfgGlasses = configFile >> "CfgGlasses";
private _isMagazine = false;
private _isWeapon = false;
private _config = configNull;
private _simulationType = "";
private _configItemInfo = "";
private _hasItemInfo = false;
private _itemInfoType = 0;
private _isMiscItem = false;
{
switch true do {
// Weapon mag
case (
isClass (_configMagazines >> _x) &&
{_x in (_itemsCache select 2)} &&
{!(_x in (GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL))}
): {
(GVAR(virtualItems) select 19) pushBackUnique _x;
};
_isMagazine = isClass (_cfgMagazines >> _x);
_isWeapon = isClass (_cfgWeapons >> _x);
// Mag throw
case (
isClass (_configMagazines >> _x) &&
{_x in (_itemsCache select 15)} &&
{!(_x in (GVAR(virtualItems) select 15))}
): {
(GVAR(virtualItems) select 20) pushBackUnique _x;
};
switch (true) do {
// Magazines
case (_isMagazine): {
_config = _cfgMagazines >> _x;
// Mag put
case (
isClass (_configMagazines >> _x) &&
{_x in (_itemsCache select 16)} &&
{!(_x in (GVAR(virtualItems) select 16))}
): {
(GVAR(virtualItems) select 21) pushBackUnique _x;
switch (true) do {
// "Misc. items" magazines (e.g. spare barrels, intel, photos)
case (
!(_x in (GVAR(virtualItems) get IDX_VIRT_MISC_ITEMS)) &&
{_x in (uiNamespace getVariable QGVAR(magazineMiscItems)) ||
{getNumber (_config >> "ACE_isUnique") == 1}}
): {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_MISC_ITEMS) set [_x, nil];
};
// Primary, Handgun, Secondary weapon magazines
case (
!(_x in (GVAR(virtualItems) get IDX_VIRT_ITEMS_ALL)) &&
{_x in (_configItems get IDX_VIRT_ITEMS_ALL) ||
{getNumber (_config >> QGVAR(hide)) == -1} ||
{getNumber (_config >> "type") in [TYPE_MAGAZINE_PRIMARY_AND_THROW, TYPE_MAGAZINE_SECONDARY_AND_PUT, 1536, TYPE_MAGAZINE_HANDGUN_AND_GL, TYPE_MAGAZINE_MISSILE]}}
): {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_VIRT_ITEMS_ALL) set [_x, nil];
};
// Grenades
case (
!(_x in (GVAR(virtualItems) get IDX_VIRT_GRENADES)) &&
{_x in (uiNamespace getVariable QGVAR(grenadeCache))}
): {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_GRENADES) set [_x, nil];
};
// Explosives
case (
!(_x in (GVAR(virtualItems) get IDX_VIRT_EXPLOSIVES)) &&
{_x in (uiNamespace getVariable QGVAR(putCache))}
): {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_EXPLOSIVES) set [_x, nil];
};
// Unknown
default {
// Don't add items that are part of the arsenal
if !(_x in GVAR(virtualItemsFlatAll)) then {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS) set [_x, nil];
};
};
};
};
// Weapons
case (_isWeapon): {
_config = _cfgWeapons >> _x;
_simulationType = getText (_config >> "simulation");
_configItemInfo = _config >> "ItemInfo";
_hasItemInfo = isClass (_configItemInfo);
_itemInfoType = if (_hasItemInfo) then {getNumber (_configItemInfo >> "type")} else {0};
_isMiscItem = _x isKindOf ["CBA_MiscItem", _cfgWeapons];
// acc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select IDX_VIRT_ATTACHEMENTS) select 0))} &&
{_x in ((_itemsCache select 1) select 0)}
): {
((GVAR(virtualItems) select 22) select 0) pushBackUnique _x;
switch (true) do {
// Optics
case (
!(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_OPTICS_ATTACHMENTS)) &&
{_x in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_OPTICS_ATTACHMENTS) ||
{_hasItemInfo &&
{!_isMiscItem} &&
{_itemInfoType == TYPE_OPTICS}}}
): {
((GVAR(virtualItems) get IDX_VIRT_UNIQUE_ATTACHMENTS) get IDX_VIRT_OPTICS_ATTACHMENTS) set [_x, nil];
};
// Flashlights
case (
!(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_FLASHLIGHT_ATTACHMENTS)) &&
{_x in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_FLASHLIGHT_ATTACHMENTS) ||
{_hasItemInfo &&
{!_isMiscItem} &&
{_itemInfoType == TYPE_FLASHLIGHT}}}
): {
((GVAR(virtualItems) get IDX_VIRT_UNIQUE_ATTACHMENTS) get IDX_VIRT_FLASHLIGHT_ATTACHMENTS) set [_x, nil];
};
// Muzzle attachments
case (
!(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_MUZZLE_ATTACHMENTS)) &&
{_x in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_MUZZLE_ATTACHMENTS) ||
{_hasItemInfo &&
{!_isMiscItem} &&
{_itemInfoType == TYPE_MUZZLE}}}
): {
((GVAR(virtualItems) get IDX_VIRT_UNIQUE_ATTACHMENTS) get IDX_VIRT_MUZZLE_ATTACHMENTS) set [_x, nil];
};
// Bipods
case (
!(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_BIPOD_ATTACHMENTS)) &&
{_x in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_BIPOD_ATTACHMENTS) ||
{_hasItemInfo &&
{!_isMiscItem} &&
{_itemInfoType == TYPE_BIPOD}}}
): {
((GVAR(virtualItems) get IDX_VIRT_UNIQUE_ATTACHMENTS) get IDX_VIRT_BIPOD_ATTACHMENTS) set [_x, nil];
};
// Misc. items
case (
!(_x in (GVAR(virtualItems) get IDX_VIRT_MISC_ITEMS)) &&
{_x in (_configItems get IDX_VIRT_MISC_ITEMS) ||
{_hasItemInfo &&
{_isMiscItem &&
{_itemInfoType in [TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_MUZZLE, TYPE_BIPOD]}} ||
{_itemInfoType in [TYPE_FIRST_AID_KIT, TYPE_MEDIKIT, TYPE_TOOLKIT]} ||
{_simulationType == "ItemMineDetector"}}}
): {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_MISC_ITEMS) set [_x, nil];
};
// Unknown
default {
// Don't add items that are part of the arsenal
if !(_x in GVAR(virtualItemsFlatAll)) then {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS) set [_x, nil];
};
};
};
};
// acc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select IDX_VIRT_ATTACHEMENTS) select 1))} &&
{_x in ((_itemsCache select 1) select 1)}
): {
((GVAR(virtualItems) select 22) select 1) pushBackUnique _x;
};
// acc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select IDX_VIRT_ATTACHEMENTS) select 2))} &&
{_x in ((_itemsCache select 1) select 2)}
): {
((GVAR(virtualItems) select 22) select 2) pushBackUnique _x;
};
// acc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select IDX_VIRT_ATTACHEMENTS) select 3))} &&
{_x in ((_itemsCache select 1) select 3)}
): {
((GVAR(virtualItems) select 22) select 3) pushBackUnique _x;
};
// Misc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in (GVAR(virtualItems) select 17))} &&
{!(_x in ((_itemsCache select 1) select 0))} &&
{!(_x in ((_itemsCache select 1) select 1))} &&
{!(_x in ((_itemsCache select 1) select 2))} &&
{!(_x in ((_itemsCache select 1) select 3))}
): {
(GVAR(virtualItems) select 18) pushBackUnique _x;
};
// Backpacks
case (getNumber (_configVehicles >> _x >> "isBackpack") == 1): {
(GVAR(virtualItems) select 23) pushBackUnique _x;
case (getNumber (_cfgVehicles >> _x >> "isBackpack") == 1): {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_BACKPACKS) set [_x, nil];
};
// Facewear
case (isClass (_configGlasses >> _x)): {
(GVAR(virtualItems) select 24) pushBackUnique _x;
case (isClass (_cfgGlasses >> _x)): {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_GOGGLES) set [_x, nil];
};
// Unknown
default {
// Don't add items that are part of the arsenal
if !(_x in GVAR(virtualItemsFlatAll)) then {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS) set [_x, nil];
};
};
};
} foreach _array;
} forEach (keys ([GVAR(center), 0, 3, 3, 3, false] call EFUNC(common,uniqueUnitItems))); // Get all items from unit

View File

@ -1,8 +1,8 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe
* Verify the provided loadout.
* Author: Alganthe, johnb43
* Verify the provided loadout: Check what items do not exist and what items aren't available in current arsenal.
*
* Arguments:
* 0: Loadout <ARRAY> (CBA Extended Loadout or getUnitLoadout format)
@ -23,220 +23,274 @@ if (count _loadout == 2) then {
_loadout = _loadout select 0;
};
private _weaponCfg = configFile >> "CfgWeapons";
private _magCfg = configFile >> "CfgMagazines";
private _vehcCfg = configFile >> "CfgVehicles";
private _glassesCfg = configFile >> "CfgGlasses";
private _weaponsArray = GVAR(virtualItems) select IDX_VIRT_WEAPONS;
private _accsArray = GVAR(virtualItems) select IDX_VIRT_ATTACHEMENTS;
private _cfgWeapons = configFile >> "CfgWeapons";
private _cfgMagazines = configFile >> "CfgMagazines";
private _cfgVehicles = configFile >> "CfgVehicles";
private _cfgGlasses = configFile >> "CfgGlasses";
private _weapons = GVAR(virtualItems) get IDX_VIRT_WEAPONS;
private _attachments = GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS;
private _name = "";
private _nullItemsAmount = 0;
private _unavailableItemsAmount = 0;
private _nullItemsList = [];
private _unavailableItemsList = [];
private _fnc_weaponCheck = {
params ["_dataPath"];
// Search for all items and turn them into config case; Don't touch other value types
private _fnc_toConfigCase = {
_this apply {
if (_x isEqualType "") then {
if (_x != "") then {
_name = _x call EFUNC(common,getConfigName);
if (count _dataPath != 0) then {
{
if (_x isEqualType "") then {
private _item = _x;
if (_item != "") then {
if (isClass (_weaponCfg >> _item)) then {
if !(CHECK_WEAPON_OR_ACC) then {
_unavailableItemsList pushBackUnique _item;
_dataPath set [_forEachIndex, ""];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
};
} else {
_nullItemsList pushBackUnique _item;
_dataPath set [_forEachIndex, ""];
_nullItemsAmount = _nullItemsAmount + 1;
};
// If item doesn't exist in config, "" is returned
// Just return unaltered item name in that case, so it can be documented as being unavailable
if (_name != "") then {
_name
} else {
_x
};
} else {
if (count _x != 0) then {
private _mag = _x select 0;
if (isClass (_magCfg >> _mag)) then {
if !(_mag in (GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL)) then {
_unavailableItemsList pushBackUnique _mag;
_dataPath set [_forEachIndex, []];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
};
} else {
_nullItemsList pushBackUnique _mag;
_dataPath set [_forEachIndex, []];
_nullItemsAmount = _nullItemsAmount + 1;
};
};
_x
};
} foreach _dataPath;
} else {
// Handle arrays
if (_x isEqualType []) then {
_x call _fnc_toConfigCase
} else {
// All other types
_x
};
};
};
};
for "_dataIndex" from 0 to 9 do {
switch (_dataIndex) do {
case 0;
case 1;
case 2;
case 8: {
[_loadout select _dataIndex] call _fnc_weaponCheck;
// Convert loadout to config case
// Loadout might come from a different modpack, which might have different config naming
_loadout = _loadout call _fnc_toConfigCase;
// Check a weapon, with its attachments and magazines, if items are available
private _fnc_weaponCheck = {
params ["_weaponArray", ["_index", -1]];
{
// Weapons and attachments
if (_x isEqualType "") then {
if (_x != "") then {
// Check if item exists
if (isClass (_cfgWeapons >> _x)) then {
// Get base weapon
_x = _x call FUNC(baseWeapon);
// Check if item is available in arsenal
if !(
// Weapon class name is at the very start of the array
if (_forEachIndex == 0) then {
// If the type of weapon is known, only look through that array
if (_index != -1) then {
// If binos, choose differently
if (_index == IDX_LOADOUT_BINO) then {
_x in (GVAR(virtualItems) get IDX_VIRT_BINO)
} else {
_x in (_weapons get _index)
};
} else {
_x in (_weapons get IDX_VIRT_PRIMARY_WEAPONS) ||
{_x in (_weapons get IDX_VIRT_SECONDARY_WEAPONS)} ||
{_x in (_weapons get IDX_VIRT_HANDGUN_WEAPONS)} ||
{_x in (GVAR(virtualItems) get IDX_VIRT_BINO)}
};
} else {
_x in (_attachments get IDX_VIRT_OPTICS_ATTACHMENTS) ||
{_x in (_attachments get IDX_VIRT_FLASHLIGHT_ATTACHMENTS)} ||
{_x in (_attachments get IDX_VIRT_MUZZLE_ATTACHMENTS)} ||
{_x in (_attachments get IDX_VIRT_BIPOD_ATTACHMENTS)}
}
) then {
_unavailableItemsList pushBackUnique _x;
_weaponArray set [_forEachIndex, ""];
INC(_unavailableItemsAmount);
};
} else {
_nullItemsList pushBackUnique _x;
_weaponArray set [_forEachIndex, ""];
INC(_nullItemsAmount);
};
};
} else {
// Magazines
if (_x isNotEqualTo []) then {
_x params ["_magazine"];
// Check if item exists
if (isClass (_cfgMagazines >> _magazine)) then {
// Check if item is available in arsenal
if !(_magazine in (GVAR(virtualItems) get IDX_VIRT_ITEMS_ALL)) then {
_unavailableItemsList pushBackUnique _magazine;
_weaponArray set [_forEachIndex, []];
INC(_unavailableItemsAmount);
};
} else {
_nullItemsList pushBackUnique _magazine;
_weaponArray set [_forEachIndex, []];
INC(_nullItemsAmount);
};
};
};
} forEach _weaponArray;
};
case 3;
case 4;
case 5: {
private _containerArray = (_loadout select _dataIndex);
private _item = "";
if (count _containerArray != 0) then {
_containerArray params ["_item", "_containerItems"];
if (isClass (_vehcCfg >> _item) || {isClass (_weaponCfg >> _item)}) then {
if !(CHECK_CONTAINER) then {
// Go through entire loadout to check if items are available in current arsenal
for "_dataIndex" from IDX_LOADOUT_PRIMARY_WEAPON to IDX_LOADOUT_ASSIGNEDITEMS do {
switch (_dataIndex) do {
// Primary weapon, Secondary weapon, Handgun weapon, Binoculars
case IDX_LOADOUT_PRIMARY_WEAPON;
case IDX_LOADOUT_SECONDARY_WEAPON;
case IDX_LOADOUT_HANDGUN_WEAPON;
case IDX_LOADOUT_BINO: {
[_loadout select _dataIndex, _dataIndex] call _fnc_weaponCheck;
};
// Uniform, vest, backpack
case IDX_LOADOUT_UNIFORM;
case IDX_LOADOUT_VEST;
case IDX_LOADOUT_BACKPACK: {
(_loadout select _dataIndex) params [["_item", ""], ["_containerItems", []]];
if (_item != "") then {
// Check if item exists
if (isClass (_cfgVehicles >> _item) || {isClass (_cfgWeapons >> _item)}) then {
// Check if item is available in arsenal
if !(_item in (GVAR(virtualItems) get (_dataIndex + 1))) then {
_unavailableItemsList pushBackUnique _item;
_loadout set [_dataIndex, []];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
INC(_unavailableItemsAmount);
} else {
{
switch (true) do {
// Magazines have each 3 entries: Name, number of magazines and ammo count
case (_x isEqualTypeArray ["", 0, 0]): {
_x params ["_item"];
if (count _containerItems != 0) then {
{
private _currentIndex = _forEachIndex;
switch (count _x) do {
case 2: {
if ((_x select 0) isEqualType "") then {
private _item = _x select 0;
if (CLASS_CHECK_ITEM) then {
if !(CHECK_CONTAINER_ITEMS) then {
_unavailableItemsList pushBackUnique _item;
((_loadout select _dataIndex) select 1) set [_currentIndex, []];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
};
} else {
_nullItemsList pushBackUnique _item;
((_loadout select _dataIndex) select 1) set [_currentIndex, []];
_nullItemsAmount = _nullItemsAmount + 1;
};
} else {
[(((_loadout select _dataIndex) select 1) select _currentIndex) select 0] call _fnc_weaponCheck;
};
};
case 3: {
private _item = _x select 0;
if (isClass (_magCfg >> _item)) then {
if !(
_item in (GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL) ||
_item in (GVAR(virtualItems) select 15) ||
_item in (GVAR(virtualItems) select 16)
) then {
_unavailableItemsList pushBackUnique _item;
((_loadout select _dataIndex) select 1) set [_currentIndex, []];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
};
} else {
_nullItemsList pushBackUnique _item;
((_loadout select _dataIndex) select 1) set [_currentIndex, []];
_nullItemsAmount = _nullItemsAmount + 1;
// Check if item exists
if (isClass (_cfgMagazines >> _item)) then {
// Check if item is available in arsenal
if !(
_item in (GVAR(virtualItems) get IDX_VIRT_ITEMS_ALL) ||
{_item in (GVAR(virtualItems) get IDX_VIRT_GRENADES)} ||
{_item in (GVAR(virtualItems) get IDX_VIRT_EXPLOSIVES)} ||
{_item in (GVAR(virtualItems) get IDX_VIRT_MISC_ITEMS)}
) then {
_unavailableItemsList pushBackUnique _item;
((_loadout select _dataIndex) select 1) set [_forEachIndex, []];
INC(_unavailableItemsAmount);
};
} else {
_nullItemsList pushBackUnique _item;
((_loadout select _dataIndex) select 1) set [_forEachIndex, []];
INC(_nullItemsAmount);
};
};
} foreach _containerItems;
};
// Weapons have 2 entries: Weapon info array and amount
case (_x isEqualTypeArray [[], 0]): {
[_x select 0] call _fnc_weaponCheck;
};
// Misc. items have 2 entries: Name and amount, containers have 2 entries: Name and isBackpack
default {
_x params ["_item"];
// Check if item exists
if (
isClass (_cfgWeapons >> _item) ||
{isClass (_cfgMagazines >> _item)} ||
{isClass (_cfgGlasses >> _item)} ||
{isClass (_cfgVehicles >> _item)}
) then {
// Check if item is available in arsenal
if !(_item in GVAR(virtualItemsFlat)) then {
_unavailableItemsList pushBackUnique _item;
((_loadout select _dataIndex) select 1) set [_forEachIndex, []];
INC(_unavailableItemsAmount);
};
} else {
_nullItemsList pushBackUnique _item;
((_loadout select _dataIndex) select 1) set [_forEachIndex, []];
INC(_nullItemsAmount);
};
};
};
} forEach _containerItems;
};
} else {
_nullItemsList pushBackUnique _item;
_loadout set [_dataIndex, []];
_nullItemsAmount = _nullItemsAmount + 1;
INC(_nullItemsAmount);
};
};
};
case 6: {
private _item = _loadout select _dataIndex;
// Headgear
case IDX_LOADOUT_HEADGEAR: {
_item = _loadout select _dataIndex;
if (_item != "") then {
if (isClass (_weaponCfg >> _item)) then {
if !(_item in (GVAR(virtualItems) select IDX_VIRT_HEADGEAR)) then {
// Check if item exists
if (isClass (_cfgWeapons >> _item)) then {
// Check if item is available in arsenal
if !(_item in (GVAR(virtualItems) get IDX_VIRT_HEADGEAR)) then {
_unavailableItemsList pushBackUnique _item;
_loadout set [_dataIndex, ""];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
INC(_unavailableItemsAmount);
};
} else {
_nullItemsList pushBackUnique _item;
_loadout set [_dataIndex, ""];
_nullItemsAmount = _nullItemsAmount + 1;
INC(_nullItemsAmount);
};
};
};
case 7: {
private _item = _loadout select _dataIndex;
// Facewear
case IDX_LOADOUT_GOGGLES: {
_item = _loadout select _dataIndex;
if (_item != "") then {
if (isClass (_glassesCfg >> _item)) then {
if !(_item in (GVAR(virtualItems) select IDX_VIRT_GOGGLES)) then {
// Check if item exists
if (isClass (_cfgGlasses >> _item)) then {
// Check if item is available in arsenal
if !(_item in (GVAR(virtualItems) get IDX_VIRT_GOGGLES)) then {
_unavailableItemsList pushBackUnique _item;
_loadout set [_dataIndex, ""];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
INC(_unavailableItemsAmount);
};
} else {
_nullItemsList pushBackUnique _item;
_loadout set [_dataIndex, ""];
_nullItemsAmount = _nullItemsAmount + 1;
INC(_nullItemsAmount);
};
};
};
// Assigned items: Map, Compass, Watch, GPS / UAV Terminal, Radio, NVGs
case IDX_LOADOUT_ASSIGNEDITEMS: {
private _assignedItems = _loadout select _dataIndex;
case 9: {
for "_subIndex" from 0 to 5 do {
private _item = (_loadout select _dataIndex) select _subIndex;
_item = _assignedItems select _subIndex;
if (_item != "") then {
if (isClass (_weaponCfg >> _item)) then {
if !(CHECK_ASSIGNED_ITEMS) then {
// Check if item exists
if (isClass (_cfgWeapons >> _item)) then {
// Check if item is available in arsenal
if !(_item in (GVAR(virtualItems) get (IDX_VIRT_NVG + ([2, 6, 4, 3, 5, 0] select _subIndex)))) then {
_unavailableItemsList pushBackUnique _item;
(_loadout select _dataIndex) set [_subIndex, ""];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
_assignedItems set [_subIndex, ""];
INC(_unavailableItemsAmount);
};
} else {
_nullItemsList pushBackUnique _item;
(_loadout select _dataIndex) set [_subIndex, ""];
_nullItemsAmount = _nullItemsAmount + 1;
_assignedItems set [_subIndex, ""];
INC(_nullItemsAmount);
};
};
};

View File

@ -8,7 +8,7 @@ cba_diagnostic_projectileMaxLines = 10;
[QGVAR(displayOpened), {
private _player = player;
// player pose
// Player pose
[{
switch (true) do {
case (primaryWeapon _this != ""): {
@ -23,15 +23,16 @@ cba_diagnostic_projectileMaxLines = 10;
};
}, _player] call CBA_fnc_execNextFrame;
// hide everything except the player
// Hide everything except the player
{
_x enableSimulation false;
_x hideObject true;
} forEach (allMissionObjects "" - [_player] - attachedObjects _player);
if ((_player getVariable ["cba_projectile_firedEhId", -1]) != -1) then {
if ((_player getVariable ["CBA_projectile_firedEhId", -1]) != -1) then {
_player call CBA_fnc_removeUnitTrackProjectiles;
};
_player setFatigue 0;
// Esc to close mission
@ -44,6 +45,7 @@ cba_diagnostic_projectileMaxLines = 10;
if (_key isEqualTo DIK_ESCAPE && {!_shift}) then {
[_display] spawn {
disableSerialization;
params ["_display"];
private _return = [
@ -54,47 +56,50 @@ cba_diagnostic_projectileMaxLines = 10;
] call BIS_fnc_GUImessage;
if (_return) then {
// Save loadout for next time arsenal mission is played
profileNamespace setVariable [QGVAR(missionLastLoadout), [player] call CBA_fnc_getLoadout];
_display closeDisplay 2;
findDisplay 46 closeDisplay 0;
// Quit mission
_display closeDisplay IDC_CANCEL;
findDisplay IDD_MISSION closeDisplay 0;
};
};
true
};
}];
private _buttonClose = _display displayCtrl IDC_menuBarClose;
_buttonClose ctrlSetText localize "str_a3_rscdisplayarsenal_buttonok";
(_display displayCtrl IDC_menuBarClose) ctrlSetText localize "str_a3_rscdisplayarsenal_buttonok";
} call CBA_fnc_execNextFrame;
}] call CBA_fnc_addEventHandler;
[QGVAR(displayClosed), {
private _player = player;
// unhide everthing
// Unhide everthing
{
_x enableSimulation true;
_x hideObject false;
} forEach allMissionObjects "";
// update VR unit gear
{
private _unit = _x;
private _unit = objNull,
// Update VR unit gear
{
_unit = _x;
removeVest _unit;
_unit addVest vest _player;
removeBackpack _unit;
_unit addBackpack backpack _player;
removeHeadgear _unit;
_unit addHeadgear headgear _player;
removeGoggles _unit;
_unit addGoggles goggles _player;
removeAllWeapons _unit;
_unit addWeapon primaryWeapon _player;
{
_unit addPrimaryWeaponItem _x;
} forEach primaryWeaponItems _player;
@ -106,6 +111,7 @@ cba_diagnostic_projectileMaxLines = 10;
} forEach secondaryWeaponItems _player;
_unit addWeapon handgunWeapon _player;
{
_unit addHandgunItem _x;
} forEach handgunItems _player;

Some files were not shown because too many files have changed in this diff Show More