R3voA3 / 3den-Enhanced

Official 3den Enhanced repository
https://steamcommunity.com/sharedfiles/filedetails/?id=623475643
Other
48 stars 30 forks source link

ACE/BI Limited Arsenal Editor/Creator Tool #258

Closed linkion closed 1 year ago

linkion commented 1 year ago

Description

An editor for making limited arsenals with options like excluding all the items from a specific mod,

Making limited arsenals in Arma is a pain; this should hopefully solve that.

The tool would create an arsenal of any item selected by the user.

The arsenal would be initialized by filling out the init of that item.

The menu should allow the user to exclude or include mods, specific items, etc.

For example,

  1. Making an arsenal box for a US team,
  2. I want to exclude all items from RHSAFRF and RHSGREF
  3. I use the menu to create the arsenal, and in a exclude tab, I exclude the mods RHSGREF and RHSAFRF
  4. Hit apply, and the init of the selected box would populate with initializing the arsenal and excluding the mods

This should hopefully be easy to make since BI and ACE both have functions to exclude items.

Use-Cases

Many mission creators want to make a limited arsenal. Still, they don't want to go through the tedious vanilla menu, selecting and deselecting every item, especially since many items have different configurations for color/rails/etc.

Relevant Assets

No response

linkion commented 1 year ago

The menu should probably also check whether or not ACE is installed and then give an option to either create a BI Virt Arsenal or Ace arsenal, or both.

Also, for those that might be using the ACE3 Arsenal Extended it should work fine since the extended items are automatically removed when the item is not inside the arsenal.

linkion commented 1 year ago

I'd think the way to go for excluding and including items would be

  1. excluding entire mods
  2. excluding/including all uniforms/weapons/backpacks/etc. of mod
  3. excluding/including specific items

for example, I exclude RHSAFRF but I include RHSAFRF Uniforms

Everything from RHSAFRF but the uniforms are excluded.

Another example, I exclude RHSAFRF I include the rhs_sidor item

Everything from RHSAFRF but the rhs_sidor item is excluded.

linkion commented 1 year ago

Another button would be to include all attachments, like ammo, sights, rail accessories for the included weapons.

linkion commented 1 year ago

Though a feature for the future could be to undo and redo actions done in the menu, like exclusions and inclusions.

Or to be able to edit an existing arsenal by reading it's init.

linkion commented 1 year ago

I'm going to also try to put some work into this,

I've never made an Arma 3 mod, and have zero experience with GUIs, but I'll try to base it on the other tools

R3voA3 commented 1 year ago

What about the Vehicle Inventory Manager? One can use it to convert inventory to Arsenal.

linkion commented 1 year ago

Honestly, I thought the VIM was only for vehicles, but after looking at it, it looks like it can be used to make an arsenal, but that wasn't its primary purpose.

Also, it doesn't have some of the features I was hoping for, like adding all possible attachments for the guns in its inventory or filtering by mod.

The VIM is much more for just altering the inventory rather than making arsenals.

Maybe it would be better to make a new menu for making arsenals specifically. Currently, the only other way of making arsenals in 3den would be to copy and paste from the internet.

linkion commented 1 year ago

What I'm imagining is something like this,

LimitedArsenalGUISelection

Where the user selects and deselects what they don't want to be accessed from the arsenal.

R3voA3 commented 1 year ago

I see. Interesting idea.

Here is a quick proof of concept. image

R3voA3 commented 1 year ago

So what functionality do we need?

linkion commented 1 year ago

Definitely that stuff, and I'm hoping we could have the user select an object from the interface, and then the user can hit apply, and it will apply the limited arsenal.

Maybe later on be able to edit existing arsenals

Also, we're gonna have to find how Ace would handle their ace arsenals since we have how BI stores the inventory from VIM.

But yeah, Ace support is a must

linkion commented 1 year ago

Also, that concept looks perfect, does it have any performance issues with large modsets?

Maybe we can add on having item previews when mousing over the name.

One issue someone from my group pointed out is that there could be major performance issues with large modsets

linkion commented 1 year ago

Though with ACE, I'm struggling with how they implement the ace arsenal with 3den attributes, for BI we just need to change the 3den attribute for "ammobox," but I can't find how they'd do it for ace.

there is fnc_addVirtualItems but that's for ingame

in the other functions like fnc_attributeAddCompatible they call [_controlsGroup] call FUNC(attributeAddItems);

or GVAR(virtualItems) where GVAR is a macro

Macro: GVAR()
    Get full variable identifier for a global variable owned by this component.
R3voA3 commented 1 year ago

Maybe later on be able to edit existing arsenals

Also, we're gonna have to find how Ace would handle their ace arsenals since we have how BI stores the inventory from VIM.

Maybe we can add on having item previews when mousing over the name.

One issue someone from my group pointed out is that there could be major performance issues with large modsets

Though with ACE, I'm struggling with how they implement the ace arsenal with 3den attributes, for BI we just need to change the 3den attribute for "ammobox," but I can't find how they'd do it for ace.

linkion commented 1 year ago

The plan is to use this tool to generate the SQF code needed to add ACE/BI Arsenal to an object. Modifiying the original attribute is possible and creating the ACE Arsenal is not difficult. I still personally prefer the "Export to SQF" method.

Yeah, I agree we can have an export to the SQF option, though it'd be nice if we would be able to apply it to a selected object attribute from 3den. I think it'd be more accessible to people making arsenals for the first time and have no understanding of arma scripting and object inits.

I wanna do this via presets. Just need to figure out how to save it properly

And with the editing existing arsenals, I understand the saving to profiles; it'd be nice to be able to save arsenal templates in the user's profile, but what I mean is that the user would be able to edit existing arsenals. I think that'd work by reading the 3den attributes of the already placed object.

linkion commented 1 year ago

disregard the issue with building, it started working magically when I manually did it from console

linkion commented 1 year ago

Would you be making a dev branch for the arsenal tool?

I would like to contribute since I made this feature request would like to help you make this tool

It would be my first time working on a mod but I do have some experience with sqf

R3voA3 commented 1 year ago

You can directly work in the master branch.

Here is the protoype I wrote

_display = (if (is3DEN) then {findDisplay 313} else {[] call BIS_fnc_displayMission}) createDisplay "RscDisplayEmpty";

_edit = _display ctrlCreate ["RscEdit", 645];
_edit ctrlSetPosition [0,0,1,0.04];
_edit ctrlSetBackgroundColor [0,0,0,1];
_edit ctrlCommit 0;

_tv = _display ctrlCreate ["RscTreeSearch", -1];
_tv ctrlSetFont "EtelkaMonospacePro";
_tv ctrlSetFontHeight 0.03;
_tv ctrlSetPosition [0,0.06,1,0.94];
_tv ctrlSetBackgroundColor [0,0,0,1];
_tv ctrlCommit 0;

if (uiNamespace getVariable ["ENH_VIM_allAddons", []] isEqualTo []) then { call ENH_fnc_getAllItems};

private _allAddons = ((uiNamespace getVariable ["ENH_VIM_allAddons", []]) - [["","Unchanged",""],["","",""]]) + [["", "Arma 3", ""]];

// Prefill tree view with layout
{
    _x params [["_addonClass", ""], ["_addonName", ""], ["_addonIcon", ""]];

    private _indexAddon = _tv tvAdd [[], _addonName];
    _tv tvSetPicture [[_indexAddon], "\a3\3den\data\controls\ctrlcheckbox\baseline_textureunchecked_ca.paa"];
    {
        private _indexCategory = _tv tvAdd [[_indexAddon], _x];
        _tv tvSetPicture [[_indexAddon, _indexCategory], "\a3\3den\data\controls\ctrlcheckbox\baseline_textureunchecked_ca.paa"];
    } foreach (uiNamespace getVariable ["ENH_VIM_types", []]);
} foreach _allAddons;

private _allAddonClasses = [];

_allAddons apply
{
    _allAddonClasses pushBack (_x # 0);
};

// Fill tree view with equipment
{
        _y params ["_displayName", "_picture", "_addonClass", "_addonIcon", "_category", "_specificType", "_descriptionShort", "_class"];

        private _indexAddon = _allAddonClasses find _addonClass;
        private _indexCategory = (uiNamespace getVariable ["ENH_VIM_types", []]) find _category;

        if (_indexCategory < 0) then
        {
            _indexCategory = (uiNamespace getVariable ["ENH_VIM_types", []]) find _specificType;
        };

        private _indexEquipment = _tv tvAdd [[_indexAddon, _indexCategory], _displayName];

        _tv tvSetData [[_indexAddon, _indexCategory, _indexEquipment], _class];
        _tv tvSetPicture [[_indexAddon, _indexCategory, _indexEquipment], "\a3\3den\data\controls\ctrlcheckbox\baseline_textureunchecked_ca.paa"];
        _tv tvSetPictureRight [[_indexAddon, _indexCategory, _indexEquipment], _picture];
    _tv tvSetTooltip [[_indexAddon, _indexCategory, _indexEquipment], _descriptionShort];

} foreach (uiNamespace getVariable ["ENH_VIM_itemsHashMap", []]);

// Remove empty nodes
private _fnc_removeEmptyNodes =
{
    params
    [
        ["_path", []],
        ["_maxLevel", -1]
    ];

    // Exit if path is deeper than wanted level
    if (count _path == _maxLevel && _maxLevel > -1) exitWith {};

    for "_i" from (_tv tvCount _path) to 0 step -1 do
    {
        private _newPath = _path + [_i];

        if (_tv tvCount _newPath == 0) then
        {
            _tv tvDelete _newPath;
        }
        else
        {
            [_newPath, _maxLevel] call _fnc_removeEmptyNodes;
        };
    };
};

[[], 2] call _fnc_removeEmptyNodes;

// Sort TV
_tv tvSortAll [];

// Check and uncheck nodes
_tv ctrlAddEventHandler ["keyDown",
{
    params ["_ctrlTV", "_key", "_shift", "_ctrl", "_alt"];

    if (_key == 14) then
    {
        [_ctrlTV, 0] call ENH_fnc_virtualArsenalManager_switchNodeState;
    };
    if (_key in [28, 156]) then
    {
        [_ctrlTV, 1] call ENH_fnc_virtualArsenalManager_switchNodeState;
    };
    if (_key == 59) then
    {
        call ENH_fnc_virtualArsenalManager_exportToSQF;
    };
}];

ENH_fnc_virtualArsenalManager_switchNodeState =
{
    params ["_ctrlTV", "_add"];

    private _selectedPath = tvCurSel _ctrlTV;
    private _picture = ["\a3\3den\data\controls\ctrlcheckbox\baseline_textureunchecked_ca.paa", "\a3\3den\data\controls\ctrlcheckbox\baseline_texturechecked_ca.paa"] select _add;

    _ctrlTV tvSetPicture [_selectedPath, _picture];
    _ctrlTV tvSetValue [_selectedPath, _add];

    private _fnc_traverseChildren =
    {
        params ["_path"];

        for "_i" from (_ctrlTV tvCount _path) to 0 step -1 do
        {
            private _newPath = _path + [_i];

            _ctrlTV tvSetPicture [_newPath, _picture];
      _ctrlTV tvSetValue [_newPath, _add];

            if (_ctrlTV tvCount _newPath > 0) then
            {
                [_newPath] call _fnc_traverseChildren;
            };
        };
    };

    [_selectedPath] call _fnc_traverseChildren;
};

ENH_fnc_virtualArsenalManager_exportToSQF =
{
    private _data =  //[<items>, <weapons>, <magazines>, <backpacks>]
    [
        [],
        [],
        [],
        []
    ];

    private _fnc_traverseChildren =
    {
        params ["_path"];

        for "_i" from 0 to (_ctrlTV tvCount _path) do
        {
            private _newPath = _path + [_i];

            if (count _newPath == 3) then
            {
                if (_ctrlTV tvValue _newPath > 0) then
                {
                    private _category = (uiNamespace getVariable ["ENH_VIM_itemsHashMap", createHashMap]) get (_ctrlTV tvData _newPath) select 4;
                    diag_log _category;
                };
            };

            if (_ctrlTV tvCount _newPath > 0) then
            {
                [_newPath] call _fnc_traverseChildren;
            };
        };
    };

    [[]] call _fnc_traverseChildren;
};

[[], 2] call _fnc_removeEmptyNodes;
linkion commented 1 year ago

I've added mouse support to your prototype and made it so that clicking in the location of the checkbox would check the box.

I've also added to the ENH_fnc_virtualArsenalManager_switchNodeState to traverse through the item entry's parents and change their checked/unchecked/partial depending on their children

Also I've chosen "\a3\ui_f\data\gui\rsccommon\rsccheckbox\checkbox_checked_ca.paa" to be our partial checked icon which looks like: checkbox_checked_ca