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

Arsenal - Favorites System #9307

Merged
merged 42 commits into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ff81181
improve page handling
LinkIsGrim Jul 26, 2023
975f2ec
drop MAX_STATS_PER_PAGE for now
LinkIsGrim Jul 26, 2023
1cbdcec
hide stats box when empty
LinkIsGrim Jul 27, 2023
955a40f
improve hiding
LinkIsGrim Jul 27, 2023
d824a5a
improve _fnc_hideUnused
LinkIsGrim Jul 27, 2023
7d9c9ba
condition
LinkIsGrim Jul 27, 2023
521d7c6
Merge remote-tracking branch 'upstream' into arsenal-improve-page-han…
LinkIsGrim Jul 28, 2023
033870e
prevent page overflow
LinkIsGrim Jul 28, 2023
7b49f22
Merge branch 'master' of https://github.com/acemod/ACE3 into arsenal-…
LinkIsGrim Aug 2, 2023
4c95f39
favorites var
LinkIsGrim Aug 2, 2023
3b76354
function prep
LinkIsGrim Aug 2, 2023
f6daa50
favorites only
LinkIsGrim Aug 2, 2023
7d2a436
improve favorites adding, add include
LinkIsGrim Aug 2, 2023
62ec4c4
fix stupid
LinkIsGrim Aug 2, 2023
64378e3
fix color setting (todo: lnb color)
LinkIsGrim Aug 3, 2023
b68824d
add button, finalize
LinkIsGrim Aug 5, 2023
0e6dcb2
setting tooltip
LinkIsGrim Aug 5, 2023
b745ac3
stringtable again
LinkIsGrim Aug 5, 2023
064ecdf
fix setting overwrite, improve tooltip
LinkIsGrim Aug 5, 2023
c9a9bba
fix losing weapon items
LinkIsGrim Aug 5, 2023
a47432e
fix macro
LinkIsGrim Aug 5, 2023
fd79ea3
fix setting to intended overwrite
LinkIsGrim Aug 5, 2023
80f4386
remove unnecessary private
LinkIsGrim Aug 5, 2023
e5af568
docs
LinkIsGrim Aug 5, 2023
2110643
more docs
LinkIsGrim Aug 5, 2023
fe4b0bd
is
LinkIsGrim Aug 5, 2023
103df86
improve button text
LinkIsGrim Aug 5, 2023
2afcfda
docs
LinkIsGrim Aug 5, 2023
ffb2b3b
fix tooltip not showing unless menuBar was clicked
LinkIsGrim Aug 5, 2023
cbcc6d9
improve weapon accessory lookup
LinkIsGrim Aug 5, 2023
ef0fa6d
empty line
LinkIsGrim Aug 5, 2023
62a0b9d
update refresh calls
LinkIsGrim Aug 5, 2023
ba7dbdc
fix left panel
LinkIsGrim Aug 5, 2023
ea81bda
cleanup currentCargo
LinkIsGrim Aug 5, 2023
a04309a
use BI string for favorites
LinkIsGrim Aug 5, 2023
ca7af2a
BI strings again
LinkIsGrim Aug 5, 2023
0faa788
no favorites for face/voice/insignia
LinkIsGrim Aug 5, 2023
3386c3f
stringtable again
LinkIsGrim Aug 7, 2023
792598f
Merge remote-tracking branch 'upstream/master' into arsenal-favorites
LinkIsGrim Aug 9, 2023
347c707
add missing setColorRight
LinkIsGrim Aug 9, 2023
3ab3a64
Merge branch 'master' into arsenal-favorites
LinkIsGrim Aug 19, 2023
0038628
Add comment for favorites setup
LinkIsGrim Aug 20, 2023
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
2 changes: 2 additions & 0 deletions addons/arsenal/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ PREP(buttonActionsPage);
PREP(buttonCargo);
PREP(buttonClearAll);
PREP(buttonExport);
PREP(buttonFavorites);
PREP(buttonHide);
PREP(buttonImport);
PREP(buttonLoadoutsDelete);
Expand Down Expand Up @@ -55,6 +56,7 @@ PREP(onLoadoutsClose);
PREP(onLoadoutsOpen);
PREP(onMouseButtonDown);
PREP(onMouseButtonUp);
PREP(onPanelDblClick);
PREP(onSelChangedLeft);
PREP(onSelChangedLoadouts);
PREP(onSelChangedRight);
Expand Down
6 changes: 5 additions & 1 deletion addons/arsenal/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#define WIDTH_TOTAL (safezoneW - 2 * (93 * GRID_W))
#define WIDTH_GAP (WIDTH_TOTAL / 100)
#define WIDTH_SINGLE ((WIDTH_TOTAL - 6 * WIDTH_GAP) / 5)
#define WIDTH_SINGLE ((WIDTH_TOTAL - 7 * WIDTH_GAP) / 6)

// IDDs
#define IDD_MISSION 46
Expand All @@ -19,6 +19,9 @@
#define ASCENDING 0
#define DESCENDING 1

// Favorites
#define FAVORITES_COLOR (GVAR(favoritesColor) + [1])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since alpha is modified for the right panel (in case the item doesn't fit), I opted for this solution instead, but it's a bit dirty.


// IDCs
#define IDD_ace_arsenal 1127001
#define IDC_mouseArea 0
Expand All @@ -39,6 +42,7 @@
#define IDC_buttonLoadouts 1003
#define IDC_buttonExport 1004
#define IDC_buttonImport 1005
#define IDC_buttonFavorites 1006
#define IDC_infoBox 11
#define IDC_infoBackground 1101
#define IDC_infoName 1102
Expand Down
26 changes: 26 additions & 0 deletions addons/arsenal/functions/fnc_addListBoxItem.sqf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Dedmen, johnb43
* Add a listbox row.
Expand All @@ -20,6 +21,26 @@

params ["_configCategory", "_className", "_ctrlPanel", ["_pictureEntryName", "picture", [""]]];

private _skip = GVAR(favoritesOnly) && {!(_className in GVAR(currentItems))} && {!((toLower _className) in GVAR(favorites))};
if (_skip) then {
switch (GVAR(currentLeftPanel)) do {
case IDC_buttonPrimaryWeapon: {
_skip = !(_className in (GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON_ITEMS));
};
case IDC_buttonHandgun: {
_skip = !(_className in (GVAR(currentItems) select IDX_CURR_HANDGUN_WEAPON_ITEMS));
};
case IDC_buttonSecondaryWeapon: {
_skip = !(_className in (GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON_ITEMS));
};
case IDC_buttonBinoculars: {
_skip = !(_className in (GVAR(currentItems) select IDX_CURR_BINO_ITEMS));
};
};
};

if (_skip) exitWith {};

// 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
Expand All @@ -35,3 +56,8 @@ _ctrlPanel lbSetData [_lbAdd, _className];
_ctrlPanel lbSetPicture [_lbAdd, _itemPicture];
_ctrlPanel lbSetPictureRight [_lbAdd, ["", _modPicture] select GVAR(enableModIcons)];
_ctrlPanel lbSetTooltip [_lbAdd, format ["%1\n%2", _displayName, _className]];

if ((toLower _className) in GVAR(favorites)) then {
_ctrlPanel lbSetColor [_lbAdd, FAVORITES_COLOR];
_ctrlPanel lbSetSelectColor [_lbAdd, FAVORITES_COLOR];
};
32 changes: 32 additions & 0 deletions addons/arsenal/functions/fnc_buttonFavorites.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: LinkIsGrim
* Switches the arsenal between displaying all items and favorites
*
* Arguments:
* 0: Arsenal display <DISPLAY>
* 1: Button control <CONTROL>
*
* Return Value:
* None
*
* Public: No
*/

params ["_display", "_control"];

private _firstRun = false;

if (isNil QGVAR(favoritesOnly)) then {
GVAR(favoritesOnly) = GVAR(defaultToFavorites);
_firstRun = true;
} else {
GVAR(favoritesOnly) = !GVAR(favoritesOnly);
};

_control ctrlSetText format ["%1: %2", localize "STR_GEAR_ITEMS", localize (["str_word_all", "STR_3DEN_Favorite_textPlural"] select GVAR(favoritesOnly))];

if (_firstRun) exitWith {};

[false] call FUNC(refresh);
2 changes: 1 addition & 1 deletion addons/arsenal/functions/fnc_buttonImport.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if (GVAR(shiftState) && {is3DEN}) then {
[GVAR(center), _extendedLoadout] call CBA_fnc_setLoadout;

// Update current item list and unique items
call FUNC(refresh);
[true] call FUNC(refresh);

_extendedLoadout params ["_loadout", "_extendedInfo"];

Expand Down
2 changes: 1 addition & 1 deletion addons/arsenal/functions/fnc_buttonLoadoutsLoad.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private _extendedLoadout = switch (GVAR(currentLoadoutsTab)) do {
[GVAR(center), _extendedLoadout, true] call CBA_fnc_setLoadout;

// Update current item list and unique items
call FUNC(refresh);
[true] call FUNC(refresh);

_extendedLoadout params ["_loadout", "_extendedInfo"];

Expand Down
9 changes: 9 additions & 0 deletions addons/arsenal/functions/fnc_fillRightPanel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ private _cfgMagazines = configFile >> "CfgMagazines";
private _cfgWeapons = configFile >> "CfgWeapons";
private _rightPanelCache = uiNamespace getVariable QGVAR(rightPanelCache);

private _currentCargo = itemsWithMagazines GVAR(center);

private _fnc_fillRightContainer = {
params ["_configCategory", "_className", "_hasItemInfo", ["_isUnique", false, [false]], ["_unknownOrigin", false, [false]]];

if (GVAR(favoritesOnly) && {!(_className in _currentCargo)} && {!((toLower _className) in GVAR(favorites))}) exitWith {};

// If item is not in the arsenal, it must be unique
if (!_isUnique && {!(_className in GVAR(virtualItemsFlat))}) then {
_isUnique = true;
Expand Down Expand Up @@ -94,11 +98,16 @@ private _fnc_fillRightContainer = {
}, true]) params ["_displayName", "_picture", "_mass"];

private _lbAdd = _ctrlPanel lnbAddRow ["", _displayName, "0"];
_ctrlPanel lnbSetText [[_lbAdd, 1], _displayName];
_ctrlPanel lnbSetData [[_lbAdd, 0], _className];
_ctrlPanel lnbSetPicture [[_lbAdd, 0], _picture];
_ctrlPanel lnbSetValue [[_lbAdd, 0], _mass];
_ctrlPanel lnbSetValue [[_lbAdd, 2], [0, 1] select _isUnique];
_ctrlPanel lnbSetTooltip [[_lbAdd, 0], format ["%1\n%2", _displayName, _className]];
if ((toLower _className) in GVAR(favorites)) then {
_ctrlPanel lnbSetColor [[_lbAdd, 1], FAVORITES_COLOR];
_ctrlPanel lnbSetColorRight [[_lbAdd, 1], FAVORITES_COLOR];
};
};

private _ctrlPanel = _display displayCtrl IDC_rightTabContent;
Expand Down
5 changes: 2 additions & 3 deletions addons/arsenal/functions/fnc_handleActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ _actionsCurrentPageCtrl ctrlCommit 0;
case ACTION_TYPE_BUTTON: {
_actionButtonCtrl ctrlRemoveAllEventHandlers "ButtonClick";
_actionButtonCtrl ctrlAddEventHandler ["ButtonClick", {
if (is3DEN) exitWith {call FUNC(refresh)};

if (is3DEN) exitWith {[true] call FUNC(refresh)};
[{
call FUNC(refresh);
[true] call FUNC(refresh);
}] call CBA_fnc_execNextFrame;
}];
_actionButtonCtrl ctrlAddEventHandler ["ButtonClick", _statement];
Expand Down
4 changes: 4 additions & 0 deletions addons/arsenal/functions/fnc_onArsenalClose.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ GVAR(statsInfo) = nil;
GVAR(showActions) = nil;
GVAR(currentActionPage) = nil;

profileNamespace setVariable [QGVAR(favorites), GVAR(favorites)];
GVAR(favoritesOnly) = nil;
GVAR(favorites) = nil;

GVAR(center) = nil;
GVAR(centerNotPlayer) = nil;

Expand Down
4 changes: 4 additions & 0 deletions addons/arsenal/functions/fnc_onArsenalOpen.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ GVAR(currentActionPage) = 0;
// Update current item list
call FUNC(updateCurrentItemsList);

// Setup favorites button text and switch to default mode defined by setting
[_display, _display displayCtrl IDC_buttonFavorites] call FUNC(buttonFavorites);
LinkIsGrim marked this conversation as resolved.
Show resolved Hide resolved
GVAR(favorites) = profileNamespace getVariable [QGVAR(favorites), createHashMap];

// This takes care of unique inventory items and unique equipment (arsenal doesn't have items/equipment whitelisted)
call FUNC(updateUniqueItemsList);

Expand Down
50 changes: 50 additions & 0 deletions addons/arsenal/functions/fnc_onPanelDblClick.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "script_component.hpp"
#include "..\defines.hpp"
#include "\a3\ui_f\hpp\defineResincl.inc"
/*
* Author: LinkIsGrim
* Add or remove item(s) to favorites when LShift is pressed
*
* Arguments:
* 0: Left panel control <CONTROL>
* 1: Left panel selection <NUMBER>
*
* Return Value:
* None
*
* Public: No
*/
params ["_control", "_curSel"];

if !(GVAR(shiftState)) exitWith {};

if (GVAR(currentLeftPanel) in [IDC_buttonFace, IDC_buttonVoice, IDC_buttonInsigina]) exitWith {};

private _isLnB = (ctrlType _control) == CT_LISTNBOX;

private _favorited = false;

// Favorites/blacklist will always be lowercase to handle configCase changes
private _item = "";
if (_isLnB) then {
_item = toLower (_control lnbData [_curSel, 0]);
} else {
_item = toLower (_control lbData _curSel);
};

if (_item in GVAR(favorites)) then {
GVAR(favorites) deleteAt _item;
} else {
GVAR(favorites) set [_item, nil];
_favorited = true;
};

private _color = ([[1, 1, 1], GVAR(favoritesColor)] select _favorited) + [1];

if (_isLnB) then {
_control lnbSetColor [[_curSel, 1], _color];
_control lnbSetColorRight [[_curSel, 1], _color];
} else {
_control lbSetColor [_curSel, _color];
_control lbSetSelectColor [_curSel, _color];
};
19 changes: 14 additions & 5 deletions addons/arsenal/functions/fnc_refresh.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,26 @@
* Author: Brett Mayson, johnb43
* Refreshes the arsenal to show external changes.
*
* Arguments:
* 0: Update current and unique items lists <BOOL> (default: true)
*
* Return Value:
* None
*
* Public: No
* Example:
* call ace_arsenal_fnc_refresh
*
* Public: Yes
*/
params [["_updateItems", true, [true]]];

// Update current item list
call FUNC(updateCurrentItemsList);
if (_updateItems) then {
// Update current item list
call FUNC(updateCurrentItemsList);

// This takes care of unique inventory items (arsenal doesn't have it whitelisted)
call FUNC(updateUniqueItemsList);
// This takes care of unique inventory items (arsenal doesn't have it whitelisted)
call FUNC(updateUniqueItemsList);
};

// Don't refresh left panel if in loadout tab
if (!isNull findDisplay IDD_loadouts_display) exitWith {};
Expand Down
7 changes: 5 additions & 2 deletions addons/arsenal/functions/fnc_updateRightPanel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ private _rightPanelCache = uiNamespace getVariable [QGVAR(rightPanelCache), crea

private _mass = -1;
private _color = [];
private _alpha = 1;

// 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];
_color = _control lnbColor [_row, 1];

// Lower alpha on color for items that can't fit
_color = [1, 1, 1, [0.25, 1] select (_mass <= _loadRemaining)];
_alpha = [0.25, 1] select (_mass <= _loadRemaining);
_color set [3, _alpha];
_control lnbSetColor [[_row, 1], _color];
_control lnbSetColor [[_row, 2], _color];
_control lnbSetColor [[_row, 2], [1, 1, 1, _alpha]];
};

private _display = ctrlParent _control;
Expand Down
36 changes: 30 additions & 6 deletions addons/arsenal/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,47 @@ private _category = LLSTRING(settingCategory);
true
] call CBA_fnc_addSetting;

[
QGVAR(defaultToFavorites),
"CHECKBOX",
[LSTRING(defaultToFavoritesSetting), LSTRING(defaultToFavoritesTooltip)],
_category,
false,
2 // never overwrite the client
] call CBA_fnc_addSetting;

[
QGVAR(favoritesColor),
"COLOR",
[LSTRING(favoritesColorSetting), LSTRING(favoritesColorTooltip)],
_category,
[0.9, 0.875, 0.6],
2 // never overwrite the client
] call CBA_fnc_addSetting;

private _loadoutCategory = LLSTRING(loadoutSubcategory);

// Arsenal loadouts
[QGVAR(allowDefaultLoadouts),
[
QGVAR(allowDefaultLoadouts),
"CHECKBOX",
[LSTRING(allowDefaultLoadoutsSetting), LSTRING(defaultLoadoutsTooltip)],
[_category, _loadoutCategory],
true,
true
] call CBA_fnc_addSetting;

[QGVAR(allowSharedLoadouts),
[
QGVAR(allowSharedLoadouts),
"CHECKBOX",
LLSTRING(allowSharingSetting),
[_category, _loadoutCategory],
true,
true
] call CBA_fnc_addSetting;

[QGVAR(EnableRPTLog),
[
QGVAR(EnableRPTLog),
"CHECKBOX",
[LSTRING(printToRPTSetting),
LSTRING(printToRPTTooltip)],
Expand All @@ -61,21 +82,24 @@ private _loadoutCategory = LLSTRING(loadoutSubcategory);
false
] call CBA_fnc_addSetting;

[QGVAR(loadoutsSaveFace),
[
QGVAR(loadoutsSaveFace),
"CHECKBOX",
LLSTRING(loadoutsSaveFaceSetting),
[_category, _loadoutCategory],
false
] call CBA_fnc_addSetting;

[QGVAR(loadoutsSaveVoice),
[
QGVAR(loadoutsSaveVoice),
"CHECKBOX",
LLSTRING(loadoutsSaveVoiceSetting),
[_category, _loadoutCategory],
false
] call CBA_fnc_addSetting;

[QGVAR(loadoutsSaveInsignia),
[
QGVAR(loadoutsSaveInsignia),
"CHECKBOX",
LLSTRING(loadoutsSaveInsigniaSetting),
[_category, _loadoutCategory],
Expand Down
Loading