diff --git a/AUTHORS.txt b/AUTHORS.txt index 0c8267b448..6756c0bec3 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -44,7 +44,6 @@ Andrea "AtixNeon" Verano Anthariel Arcanum417 Anton -Arcanum417 Arkhir Asgar Serran BaerMitUmlaut @@ -139,6 +138,7 @@ Robert Boklahánics ruPaladin Rutger "RedBery" Meijering Schwaggot +shukari simon84 Skengman2 Smith diff --git a/addons/arsenal/XEH_PREP.hpp b/addons/arsenal/XEH_PREP.hpp index dca05e5892..30117d5d81 100644 --- a/addons/arsenal/XEH_PREP.hpp +++ b/addons/arsenal/XEH_PREP.hpp @@ -1,5 +1,6 @@ PREP(addDefaultLoadout); PREP(addListBoxItem); +PREP(addRightPanelButton); PREP(addStat); PREP(addVirtualItems); PREP(attributeAddCompatible); diff --git a/addons/arsenal/config.cpp b/addons/arsenal/config.cpp index 6eb4c895ce..0bc1ba37d6 100644 --- a/addons/arsenal/config.cpp +++ b/addons/arsenal/config.cpp @@ -15,6 +15,7 @@ class CfgPatches { }; #include "ui\RscAttributes.hpp" +#include "ui\RscCustomArsenalButton.hpp" #include "Display3DEN.hpp" #include "Cfg3DEN.hpp" #include "CfgEventHandlers.hpp" diff --git a/addons/arsenal/data/iconCustom.paa b/addons/arsenal/data/iconCustom.paa new file mode 100644 index 0000000000..8c0c6ff94f Binary files /dev/null and b/addons/arsenal/data/iconCustom.paa differ diff --git a/addons/arsenal/defines.hpp b/addons/arsenal/defines.hpp index 35d2edc461..f0ce0bc894 100644 --- a/addons/arsenal/defines.hpp +++ b/addons/arsenal/defines.hpp @@ -172,10 +172,12 @@ #define FADE_DELAY 0.15 #define CAM_DIS_MAX 5 +#define RIGHT_PANEL_CUSTOM_BUTTONS 61, 63, 65, 67, 69, 71, 73, 75, 77, 79 +#define RIGHT_PANEL_CUSTOM_BACKGROUND 60, 62, 64, 66, 68, 70, 72, 74, 76, 78 #define RIGHT_PANEL_ACC_IDCS IDC_buttonOptic, IDC_buttonItemAcc, IDC_buttonMuzzle, IDC_buttonBipod #define RIGHT_PANEL_ACC_BACKGROUND_IDCS IDC_iconBackgroundOptic, IDC_iconBackgroundItemAcc, IDC_iconBackgroundMuzzle, IDC_iconBackgroundBipod -#define RIGHT_PANEL_ITEMS_IDCS IDC_buttonMag, IDC_buttonMagALL, IDC_buttonThrow, IDC_buttonPut, IDC_buttonMisc -#define RIGHT_PANEL_ITEMS_BACKGROUND_IDCS IDC_iconBackgroundMag, IDC_iconBackgroundMagALL, IDC_iconBackgroundThrow, IDC_iconBackgroundPut, IDC_iconBackgroundMisc +#define RIGHT_PANEL_ITEMS_IDCS IDC_buttonMag, IDC_buttonMagALL, IDC_buttonThrow, IDC_buttonPut, IDC_buttonMisc, RIGHT_PANEL_CUSTOM_BUTTONS +#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\ @@ -304,7 +306,38 @@ _buttonCurrentMag2Ctrl ctrlCommit FADE_DELAY;\ } foreach [\ IDC_blockRightFrame,\ IDC_blockRighttBackground\ -]; +];\ +if (!isNil QGVAR(customRightPanelButtons)) then {\ + private _miscOffset = 0;\ + {\ + if (!isNil "_x") then {\ + _x params ["", "_picture", "_tooltip"];\ + _miscOffset = _forEachIndex + 1;\ + private _ctrl = _display ctrlCreate [QGVAR(customArsenalButton_Background), 60 + (_forEachIndex * 2)];\ + _ctrl ctrlSetPosition [\ + safezoneW + safezoneX - 13 * GRID_W,\ + safezoneY + (88 + (10 * _forEachIndex)) * GRID_H\ + ];\ + _ctrl ctrlCommit 0;\ + _ctrl = _display ctrlCreate [QGVAR(customArsenalButton_Button), 61 + (_forEachIndex * 2)];\ + _ctrl ctrlSetPosition [\ + safezoneW + safezoneX - 10 * GRID_W,\ + safezoneY + (88 + (10 * _forEachIndex)) * GRID_H\ + ];\ + _ctrl ctrlSetText _picture;\ + _ctrl ctrlSetTooltip _tooltip;\ + _ctrl ctrlCommit 0;\ + };\ + } forEach GVAR(customRightPanelButtons);\ + {\ + _x = _display displayCtrl _x;\ + _x ctrlSetPosition [\ + safezoneW + safezoneX - (10 + (3 * _forEachIndex)) * GRID_W,\ + safezoneY + (88 + (10 * _miscOffset)) * GRID_H\ + ];\ + _x ctrlCommit 0;\ + } forEach [IDC_buttonMisc, IDC_iconBackgroundMisc];\ +}; #define TOGGLE_RIGHT_PANEL_HIDE\ {\ diff --git a/addons/arsenal/functions/fnc_addRightPanelButton.sqf b/addons/arsenal/functions/fnc_addRightPanelButton.sqf new file mode 100644 index 0000000000..b906c13c4f --- /dev/null +++ b/addons/arsenal/functions/fnc_addRightPanelButton.sqf @@ -0,0 +1,55 @@ +#include "script_component.hpp" +#include "..\defines.hpp" +/* + * Author: shukari, Schwaggot + * Adds a right panel button for uniforms, vests and backpacks with + * defined misc items. + * + * Arguments: + * 0: items only misc items + * 1: tooltip (Optional) + * 2: picture path (Optional) + * 3: override a spezific button (0-9) (Optional) + * + * Return Value: + * successful: number of the slot; error: -1 + * + * Example: + * [["ACE_bloodIV_500", "ACE_Banana"], "MedicalStuff", "\z\ace\addons\arsenal\data\iconCustom.paa", 5] call ace_arsenal_fnc_addRightPanelButton + * + * Public: Yes +*/ + +params [["_items", [], [[]]], ["_tooltip", "", [""]], ["_picture", QPATHTOF(data\iconCustom.paa), [""]], ["_override", -1, [0]]]; + +if (isNil QGVAR(customRightPanelButtons)) then { + GVAR(customRightPanelButtons) = []; +}; + +private _position = count GVAR(customRightPanelButtons); + +if (_override != -1 && {_override >= 0} && {_override <= 9}) then { + _position = _override; +} else { + 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]]; +}; + +_return diff --git a/addons/arsenal/functions/fnc_fillRightPanel.sqf b/addons/arsenal/functions/fnc_fillRightPanel.sqf index e683c82d01..8cd64c73f2 100644 --- a/addons/arsenal/functions/fnc_fillRightPanel.sqf +++ b/addons/arsenal/functions/fnc_fillRightPanel.sqf @@ -273,9 +273,20 @@ switch (_ctrlIDC) do { }; case IDC_buttonMisc : { + // hide custom button items + private _blockItems = []; + if (!isNil QGVAR(customRightPanelButtons)) then { + { + if (!isNil "_x") then { + _blockItems append (_x select 0); + }; + } forEach GVAR(customRightPanelButtons); + }; + { ["CfgWeapons", _x, false] call _fnc_fill_right_Container; - } foreach (GVAR(virtualItems) select 17); + } forEach ((GVAR(virtualItems) select 17) select {!((toLower _x) in _blockItems)}); + { ["CfgWeapons", _x, false, true] call _fnc_fill_right_Container; } foreach (GVAR(virtualItems) select 18); @@ -286,6 +297,20 @@ switch (_ctrlIDC) do { ["CfgGlasses", _x, false, true] call _fnc_fill_right_Container; } foreach (GVAR(virtualItems) select 24); }; + + 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, true] call _fnc_fill_right_Container; + } foreach ((GVAR(virtualItems) select 17) select {(toLower _x) in _items}); + }; + }; + }; }; (_display displayCtrl IDC_rightSearchbar) ctrlSetText ""; diff --git a/addons/arsenal/ui/RscAttributes.hpp b/addons/arsenal/ui/RscAttributes.hpp index 2794e42119..7f452a55eb 100644 --- a/addons/arsenal/ui/RscAttributes.hpp +++ b/addons/arsenal/ui/RscAttributes.hpp @@ -787,7 +787,7 @@ class GVAR(display) { colorBackground[]={0,0,0,1}; fade=1; enable=0; - x = QUOTE(safezoneW + safezoneX - 13 * GRID_W); + x = QUOTE(safezoneW + safezoneX - 13 * GRID_W); y = QUOTE(safezoneY + 8 * GRID_H); w = QUOTE(12 * GRID_W); h = QUOTE(9 * GRID_H); @@ -798,7 +798,7 @@ class GVAR(display) { text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\ItemOptic_ca.paa"; onButtonClick = QUOTE([ARR_2(ctrlParent (_this select 0), _this select 0)] call FUNC(fillRightPanel)); colorBackground[]={0,0,0,0.5}; - x = QUOTE(safezoneW + safezoneX - 10 * GRID_W); + x = QUOTE(safezoneW + safezoneX - 10 * GRID_W); y = QUOTE(safezoneY + 8 * GRID_H); w = QUOTE(9 * GRID_W); h = QUOTE(9 * GRID_H); @@ -903,6 +903,7 @@ class GVAR(display) { tooltip="$STR_A3_RscDisplayArsenal_tab_CargoMisc"; y = QUOTE(safezoneY + 88 * GRID_H); }; + class buttonRemoveAll: ctrlButtonPicture { idc = IDC_buttonRemoveAll; text = QPATHTOF(data\iconClearContainer.paa); @@ -911,7 +912,7 @@ class GVAR(display) { onButtonClick = QUOTE(ctrlParent (_this select 0) call FUNC(buttonClearAll)); fade=1; enable=0; - x = QUOTE(safezoneW + safezoneX - 11 * GRID_W); + x = QUOTE(safezoneW + safezoneX - 11 * GRID_W); y = QUOTE(safeZoneH + safezoneY - 29 * GRID_H); w = QUOTE(9 * GRID_W); h = QUOTE(9 * GRID_H); @@ -926,7 +927,7 @@ class GVAR(loadoutsDisplay) { class controls { class centerBox: ctrlControlsGroupNoScrollbars { idc = IDC_centerBox; - x = QUOTE(safezoneW + safezoneX - (180 * GRID_W)); + x = QUOTE(safezoneW + safezoneX - (180 * GRID_W)); y = QUOTE(safezoneY + (5 * GRID_H)); w = QUOTE(160 * GRID_W); h = QUOTE(safezoneH - (34 * GRID_H)); @@ -1056,7 +1057,7 @@ class GVAR(loadoutsDisplay) { }; class buttonClose: ctrlButton { idc = -1; - x = QUOTE(safezoneW + safezoneX - 32 * GRID_W); + x = QUOTE(safezoneW + safezoneX - 32 * GRID_W); y = QUOTE(safezoneH + safezoneY - 9 * GRID_H); w = QUOTE(30 * GRID_W); h = QUOTE(7 * GRID_H); diff --git a/addons/arsenal/ui/RscCustomArsenalButton.hpp b/addons/arsenal/ui/RscCustomArsenalButton.hpp new file mode 100644 index 0000000000..7f0a139374 --- /dev/null +++ b/addons/arsenal/ui/RscCustomArsenalButton.hpp @@ -0,0 +1,22 @@ +class GVAR(customArsenalButton_Button) : RscButtonArsenal { + x = QUOTE(safezoneW + safezoneX - 10 * GRID_W); + y = QUOTE(safezoneY + 88 * GRID_H); + w = QUOTE(9 * GRID_W); + h = QUOTE(9 * GRID_H); + + text = QPATHTOF(data\iconCustom.paa); + tooltip = ""; + onButtonClick = QUOTE([ARR_2(ctrlParent (_this select 0), _this select 0)] call FUNC(fillRightPanel)); + colorBackground[] = {0,0,0,0.5}; +}; + +class GVAR(customArsenalButton_Background) : ctrlStaticBackground { + x = QUOTE(safezoneW + safezoneX - 13 * GRID_W); + y = QUOTE(safezoneY + 88 * GRID_H); + w = QUOTE(12 * GRID_W); + h = QUOTE(9 * GRID_H); + + colorBackground[] = {0,0,0,1}; + fade = 1; + enable = 0; +};