-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Arsenal - Improvements to 3DEN attribute (#6849)
* Improvements to arsenal 3DEN attribute * Better alignment of button * Remove magazineGroups copy
- Loading branch information
1 parent
2ff614c
commit 695416d
Showing
8 changed files
with
213 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include "script_component.hpp" | ||
#include "..\defines.hpp" | ||
/* | ||
* Author: mharis001 | ||
* Adds compatible attachments or magazines for all weapons in 3DEN attribute. | ||
* | ||
* Arguments: | ||
* 0: Attribute controls group <CONTROL> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [CONTROL] call ace_arsenal_fnc_attributeAddCompatible | ||
* | ||
* Public: No | ||
*/ | ||
|
||
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 {}; | ||
|
||
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}}; | ||
|
||
// 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"; | ||
|
||
{ | ||
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, toLower _x] call CBA_fnc_hashGet); | ||
} forEach getArray (_muzzleConfig >> "magazineWell"); | ||
} forEach getArray (_weaponConfig >> "muzzles"); | ||
} forEach _attributeWeapons; | ||
} else { | ||
private _attachmentCategory = _category - 4; | ||
private _filter = ["optic", "pointer", "muzzle", "bipod"] select _attachmentCategory; | ||
|
||
{ | ||
_itemsToAdd append ([_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)}; | ||
}; | ||
|
||
_attributeItems append _itemsToAdd; | ||
_attributeValue set [0, _attributeItems arrayIntersect _attributeItems]; | ||
|
||
// Refresh the list for new items | ||
[_controlsGroup] call FUNC(attributeAddItems); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "script_component.hpp" | ||
#include "..\defines.hpp" | ||
/* | ||
* Author: mharis001 | ||
* Handles changing the category in 3DEN attribute. | ||
* | ||
* Arguments: | ||
* 0: Attribute controls group <CONTROL> | ||
* 1: Category <NUMBER> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [CONTROL, 0] call ace_arsenal_fnc_attributeCategory | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_controlsGroup", "_category"]; | ||
|
||
// Store selected category | ||
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]; | ||
_compatibleButton ctrlEnable _enable; | ||
_compatibleButton ctrlShow _enable; | ||
|
||
// Refresh the list for selected category | ||
[_controlsGroup] call FUNC(attributeAddItems); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: mharis001 | ||
* Handles importing items list from clipboard into 3DEN attribute. | ||
* | ||
* Arguments: | ||
* 0: Attribute controls group <CONTROL> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [CONTROL] call ace_arsenal_fnc_attributeImport | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_controlsGroup"]; | ||
|
||
private _importList = call compile copyFromClipboard; | ||
|
||
// Verify import list is in correct format | ||
if (isNil "_importList" || {!(_importList isEqualType [])} || {!(_importList isEqualTypeAll "")}) exitWith { | ||
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); | ||
|
||
private _filteredList = []; | ||
|
||
{ | ||
private _item = _x; | ||
{ | ||
private _index = _x findIf {_x == _item}; | ||
if (_index > -1) then { | ||
_filteredList pushBackUnique (_x select _index); | ||
}; | ||
} forEach _configItemsFlat; | ||
} forEach _importList; | ||
|
||
private _attributeValue = uiNamespace getVariable [QGVAR(attributeValue), [[], 0]]; | ||
_attributeValue set [0, _filteredList]; | ||
|
||
// Refresh the list for new items | ||
[_controlsGroup] call FUNC(attributeAddItems); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters