Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CBA_MiscItem to virtual arsenal #744

Merged
merged 4 commits into from
Sep 12, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/common/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class CfgFunctions {
PATHTO_FNC(waitAndExecute);
PATHTO_FNC(waitUntilAndExecute);
PATHTO_FNC(compileFinal);
PATHTO_FNC(handleArsenalOpened);
};

class Ui {
Expand Down
10 changes: 10 additions & 0 deletions addons/common/CfgWeapons.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CfgWeapons {
class ItemCore;
class InventoryItem_Base_F;
class CBA_MiscItem_ItemInfo: InventoryItem_Base_F {
type = 302; // "bipod"
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this class (CBA_MiscItem_ItemInfo) is really needed or if the modified entries couldn't just be put in CBA_MiscItem/ItemInfo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes configs easier IMHO because you just add the 2 parent defines instead of having to add the full inhertiance from the parent.
Also makes it a drop in replacement for our existing configs (just change InventoryItem_Base_F):

    class ACE_fieldDressing: ACE_ItemCore {
        class ItemInfo: InventoryItem_Base_F {
            mass = 1;
        };
    };

class CBA_MiscItem: ItemCore { // type = 131072;
class ItemInfo: CBA_MiscItem_ItemInfo {};
};
};
3 changes: 3 additions & 0 deletions addons/common/XEH_preClientInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ if (hasInterface) then {
GVAR(actionListUpdated) = false; // Set true to force recreation of actions.
GVAR(nextActionIndex) = 0; // Next index that will be given out.
GVAR(actionListPFEH) = false;

// Add CBA_MiscItems to VirtualArsenal
[missionnamespace, "arsenalOpened", {call CBA_fnc_handleArsenalOpened}] call bis_fnc_addscriptedeventhandler;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check camelCase capitalization in:
XEH_preClientInit - line 13.
fnc_handleArsenalOpened - lines 13, 19, 21, 30-44, 51-57 and 60.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[missionNamespace, "arsenalOpened", {call CBA_fnc_handleArsenalOpened}] call BIS_fnc_addScriptedEventHandler;

};
1 change: 1 addition & 0 deletions addons/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ class CfgPatches {

#include "CfgVehicles.hpp"
#include "CfgLocationTypes.hpp"
#include "CfgWeapons.hpp"
66 changes: 66 additions & 0 deletions addons/common/fnc_handleArsenalOpened.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#define DEBUG_MODE_FULL
#include "script_component.hpp"

#define IDC_RSCDISPLAYARSENAL_LIST 960
#define IDC_RSCDISPLAYARSENAL_TAB_CARGOMISC 24
#define IDC_RSCDISPLAYARSENAL_SORT 800
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are already part of:

#include "\a3\ui_f\hpp\defineResinclDesign.inc"

But that file cannot be included in the components script_component.hpp, because it has a double define that crashes the binarizer. It can be included in this file though.



params ["_display"];
TRACE_1("handleArsenalOpened",_display);

if (missionNamespace getVariable [QGVAR(arsenalDataModified), false]) exitWith {
TRACE_1("Already set", bis_fnc_arsenal_data select 24)
};

private _cbaMiscItems = [];
{
private _class = _x;
private _scope = if (isnumber (_class >> "scopeArsenal")) then {getnumber (_class >> "scopeArsenal")} else {getnumber (_class >> "scope")};
TRACE_2("",_class,_scope);
if (_scope == 2 && {gettext (_class >> "model") != ""}) then {
_cbaMiscItems pushBack (configName _class);
};
} forEach (configProperties [configFile >> "CfgWeapons", "(isClass _x) && {(configName _x) isKindOf ['CBA_MiscItem', configFile >> 'CfgWeapons']}"]);
TRACE_2("Items to add",count _cbaMiscItems,_cbaMiscItems);


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant whitespace?

// Much of this is from fn_arsenal.sqf -> "ListAdd"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same?

private _fullVersion = missionnamespace getvariable ["BIS_fnc_arsenal_fullArsenal",false];
private _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
private _cargo = (missionnamespace getvariable ["BIS_fnc_arsenal_cargo",objnull]);

private _virtualItemCargo =
(missionnamespace call bis_fnc_getVirtualItemCargo) +
(_cargo call bis_fnc_getVirtualItemCargo) +
items _center +
assigneditems _center +
primaryweaponitems _center +
secondaryweaponitems _center +
handgunitems _center +
[uniform _center,vest _center,headgear _center,goggles _center];

private _ctrlList = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + IDC_RSCDISPLAYARSENAL_TAB_CARGOMISC);
private _virtualCargo = _virtualItemCargo;
private _virtualAll = _fullVersion || {"%ALL" in _virtualCargo};
private _columns = count lnbGetColumnsPosition _ctrlList;
{
// Add item to display list if allowed:
if (_virtualAll || {_x in _virtualCargo}) then {
private _xCfg = configfile >> "cfgweapons" >> _x;
private _lbAdd = _ctrlList lnbaddrow ["",gettext (_xCfg >> "displayName"),str 0];
_ctrlList lnbsetdata [[_lbAdd,0],_x];
_ctrlList lnbsetpicture [[_lbAdd,0],gettext (_xCfg >> "picture")];
_ctrlList lnbsetvalue [[_lbAdd,0],getnumber (_xCfg >> "itemInfo" >> "mass")];
_ctrlList lbsettooltip [_lbAdd * _columns,format ["%1\n%2",gettext (_xCfg >> "displayName"),_x]];
};

// Add item to main list (will be used on next arsenalOpened automaticly)
(bis_fnc_arsenal_data select IDC_RSCDISPLAYARSENAL_TAB_CARGOMISC) pushBack _x;
} foreach _cbaMiscItems;

missionNamespace setVariable [QGVAR(arsenalDataModified), true];
TRACE_1("finished",GVAR(arsenalDataModified));

nil