Skip to content

Commit

Permalink
Add QOL improvement for the ACE Arsenal loadouts screen (#5973)
Browse files Browse the repository at this point in the history
* Add search bar in loadouts screen

* Add onKeyDown support for the loadouts display

* Add ctrl+key support to both editbox in the loadouts screen

* Fix syntax error
  • Loading branch information
alganthe authored and PabstMirror committed Dec 30, 2017
1 parent 65fe101 commit 1b33212
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 88 deletions.
1 change: 1 addition & 0 deletions addons/arsenal/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ PREP(clearSearchbar);
PREP(fillLeftPanel);
PREP(fillLoadoutsList);
PREP(fillRightPanel);
PREP(handleLoadoutsSearchbar);
PREP(handleMouse);
PREP(handleScrollWheel);
PREP(handleSearchbar);
Expand Down
1 change: 1 addition & 0 deletions addons/arsenal/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
GVAR(EH_ID) = 0;
GVAR(lastSearchTextLeft) = "";
GVAR(lastSearchTextRight) = "";
GVAR(lastSearchTextLoadouts) = "";

[QGVAR(initBox), {_this call FUNC(initBox)}] call CBA_fnc_addEventHandler;
[QGVAR(removeBox), {_this call FUNC(removeBox)}] call CBA_fnc_addEventHandler;
Expand Down
1 change: 1 addition & 0 deletions addons/arsenal/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
#define IDC_buttonShare 306
#define IDC_buttonDelete 307
#define IDC_buttonRename 308
#define IDC_loadoutsSearchbar 309
#define IDC_buttonMyLoadoutsBackground 401
#define IDC_buttonMyLoadouts 402
#define IDC_buttonDefaultLoadoutsBackground 403
Expand Down
45 changes: 45 additions & 0 deletions addons/arsenal/functions/fnc_handleLoadoutsSearchbar.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Author: Alganthe
* Handles keyboard inputs inside the searchbars text boxes.
*
* Arguments:
* 0: Loadouts display <DISPLAY>
* 1: Searchbar control <CONTROL>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
#include "..\defines.hpp"

params ["_display", "_control"];

private _textString = ctrlText _control;

private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;

if !(GVAR(lastSearchTextLoadouts) isEqualTo "" || {(_textString find GVAR(lastSearchTextLoadouts)) == 0}) then {//don't refill if there is no need
[_display, _display displayCtrl GVAR(currentLoadoutsTab)] call FUNC(fillLoadoutsList);
};

GVAR(lastSearchTextLoadouts) = _textString;
if (count _textString == 0) exitWith {};

private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;

private _itemsToGo = (lnbSize _contentPanelCtrl) select 0;
private _lbIndex = 0;
while {_itemsToGo > 0} do {
private _currentData = _contentPanelCtrl lnbText [_lbIndex, 1];
private _currentClassname = _contentPanelCtrl lnbData [_lbIndex, 0];

if ((_currentData isEqualTo "") || {(((toUpper _currentData) find (toUpper _textString)) == -1) && {((toUpper _currentClassname) find (toUpper _textString)) == -1}}) then {
_contentPanelCtrl lnbDeleteRow _lbIndex;
} else {
_lbIndex = _lbIndex + 1;
};
_itemsToGo = _itemsToGo - 1;
};
_contentPanelCtrl lnbSetCurSelRow -1;
218 changes: 133 additions & 85 deletions addons/arsenal/functions/fnc_onKeyDown.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,83 +21,41 @@
params ["", "_args"];
_args params ["_display", "_keyPressed", "_shiftState", "_ctrlState", "_altState"];

if !((findDisplay IDD_loadouts_display) isEqualTo displayNull) exitWith {};

GVAR(shiftState) = _shiftState;

private _return = true;
private _loadoutsDisplay = findDisplay IDD_loadouts_display;

if (!GVAR(leftSearchbarFocus) && {!GVAR(rightSearchbarFocus)}) then {

switch true do {
// Close button
case (_keyPressed == DIK_ESCAPE): {
_display closeDisplay 2;
};
// Hide button
case (_keyPressed == DIK_BACKSPACE): {
[_display] call FUNC(buttonHide);
};
// Export button
case (_keyPressed == DIK_C && {_ctrlState}): {
[_display] call FUNC(buttonExport);
};
// Import button
case (_keyPressed == DIK_V && {_ctrlState}): {
[_display] call FUNC(buttonImport);
};
// Search fields
case (_keyPressed == DIK_F && {_ctrlState}): {
ctrlSetFocus (_display displayCtrl IDC_leftSearchbar);
if !(_loadoutsDisplay isEqualTo displayNull) then {
if !(GVAR(loadoutsSearchbarFocus)) then {
switch true do {
// Close button
case (_keyPressed == DIK_ESCAPE): {
_display closeDisplay 2;
};
// Search field
case (_keyPressed == DIK_F && {_ctrlState}): {
ctrlSetFocus (_loadoutsDisplay displayCtrl IDC_loadoutsSearchbar);
};
};
// Switch vision mode
case (_keyPressed in (actionkeys "nightvision")): {
if (isNil QGVAR(visionMode)) then {
GVAR(visionMode) = 0;
} else {
switch true do {
case (_keyPressed == DIK_ESCAPE): {
_display closeDisplay 2;
};
GVAR(visionMode) = (GVAR(visionMode) + 1) % 3;

switch GVAR(visionMode) do {
//--- Normal
case 0: {
camusenvg false;
false setCamUseTi 0;
};
//--- NVG
case 1: {
camusenvg true;
false setCamUseTi 0;
};
//--- TI
default {
camusenvg false;
true setCamUseTi 0;
};
case (_keyPressed == DIK_BACKSPACE): {
_return = false;
};
case (_keyPressed == DIK_NUMPADENTER);
case (_keyPressed == DIK_RETURN): {
[_loadoutsDisplay, _loadoutsDisplay displayCtrl IDC_loadoutsSearchbar] call FUNC(handleLoadoutsSearchBar);
};
case (_keyPressed in [DIK_LEFT, DIK_RIGHT]): {
_return = false;
};

playsound ["RscDisplayCurator_visionMode",true];
};
};
} else {

switch true do {
case (_keyPressed == DIK_ESCAPE): {
_display closeDisplay 2;
};
case (_keyPressed == DIK_BACKSPACE): {
_return = false;
};
case (_keyPressed == DIK_NUMPADENTER);
case (_keyPressed == DIK_RETURN): {
if (GVAR(leftSearchbarFocus)) then {
[_display, _display displayCtrl IDC_leftSearchbar] call FUNC(handleSearchBar);
};
if (GVAR(rightSearchbarFocus)) then {
[_display, _display displayCtrl IDC_rightSearchbar] call FUNC(handleSearchBar);
};
};
case (_keyPressed in [DIK_LEFT, DIK_RIGHT]): {
_return = false;
};
case (_keyPressed == DIK_C && {_ctrlState}): {
_return = false;
};
Expand All @@ -110,31 +68,121 @@ if (!GVAR(leftSearchbarFocus) && {!GVAR(rightSearchbarFocus)}) then {
case (_keyPressed == DIK_X && {_ctrlState}): {
_return = false;
};
// Search fields
case (_keyPressed == DIK_F && {_ctrlState}): {
if (GVAR(rightSearchbarFocus)) then {
case (GVAR(loadoutsPanelFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}): {
_return = false;
};
};
} else {

if (!GVAR(leftSearchbarFocus) && {!GVAR(rightSearchbarFocus)}) then {

switch true do {
// Close button
case (_keyPressed == DIK_ESCAPE): {
_display closeDisplay 2;
};
// Hide button
case (_keyPressed == DIK_BACKSPACE): {
[_display] call FUNC(buttonHide);
};
// Export button
case (_keyPressed == DIK_C && {_ctrlState}): {
[_display] call FUNC(buttonExport);
};
// Import button
case (_keyPressed == DIK_V && {_ctrlState}): {
[_display] call FUNC(buttonImport);
};
// Search fields
case (_keyPressed == DIK_F && {_ctrlState}): {
ctrlSetFocus (_display displayCtrl IDC_leftSearchbar);
} else {
ctrlSetFocus (_display displayCtrl IDC_rightSearchbar);
};
// Switch vision mode
case (_keyPressed in (actionkeys "nightvision")): {
if (isNil QGVAR(visionMode)) then {
GVAR(visionMode) = 0;
};
GVAR(visionMode) = (GVAR(visionMode) + 1) % 3;

switch GVAR(visionMode) do {
//--- Normal
case 0: {
camusenvg false;
false setCamUseTi 0;
};
//--- NVG
case 1: {
camusenvg true;
false setCamUseTi 0;
};
//--- TI
default {
camusenvg false;
true setCamUseTi 0;
};
};

playsound ["RscDisplayCurator_visionMode",true];
};
};
} else {
switch true do {
case (_keyPressed == DIK_ESCAPE): {
_display closeDisplay 2;
};
case (_keyPressed == DIK_BACKSPACE): {
_return = false;
};
case (_keyPressed == DIK_NUMPADENTER);
case (_keyPressed == DIK_RETURN): {
if (GVAR(leftSearchbarFocus)) then {
[_display, _display displayCtrl IDC_leftSearchbar] call FUNC(handleSearchBar);
};
if (GVAR(rightSearchbarFocus)) then {
[_display, _display displayCtrl IDC_rightSearchbar] call FUNC(handleSearchBar);
};
};
case (_keyPressed in [DIK_LEFT, DIK_RIGHT]): {
_return = false;
};
case (_keyPressed == DIK_C && {_ctrlState}): {
_return = false;
};
case (_keyPressed == DIK_V && {_ctrlState}): {
_return = false;
};
case (_keyPressed == DIK_A && {_ctrlState}): {
_return = false;
};
case (_keyPressed == DIK_X && {_ctrlState}): {
_return = false;
};
// Search fields
case (_keyPressed == DIK_F && {_ctrlState}): {
if (GVAR(rightSearchbarFocus)) then {
ctrlSetFocus (_display displayCtrl IDC_leftSearchbar);
} else {
ctrlSetFocus (_display displayCtrl IDC_rightSearchbar);
};
};
};
};
};

if (GVAR(leftTabFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then {
_return = false;
};
if (GVAR(leftTabFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then {
_return = false;
};

if (GVAR(rightTabFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then {
_return = false;
};
if (GVAR(rightTabFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then {
_return = false;
};

if (GVAR(rightTabLnBFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then {
_return = false;
};
if (GVAR(rightTabLnBFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then {
_return = false;
};

if (GVAR(rightTabLnBFocus) && {_keyPressed in [DIK_LEFT, DIK_RIGHT]}) then {
[_display, [1, 0] select (_keyPressed == DIK_LEFT)] call FUNC(buttonCargo);
if (GVAR(rightTabLnBFocus) && {_keyPressed in [DIK_LEFT, DIK_RIGHT]}) then {
[_display, [1, 0] select (_keyPressed == DIK_LEFT)] call FUNC(buttonCargo);
};
};

_return
2 changes: 2 additions & 0 deletions addons/arsenal/functions/fnc_onLoadoutsClose.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ private _mouseBlockCtrl = _arsenalDisplay displayCtrl IDC_mouseBlock;

GVAR(cameraPosition) = GVAR(previousCameraPos);
GVAR(previousCameraPos) = nil;
GVAR(loadoutsSearchbarFocus) = nil;
GVAR(loadoutsPanelFocus) = nil;

_mouseBlockCtrl ctrlEnable false;
_mouseBlockCtrl ctrlCommit 0;
Expand Down
2 changes: 2 additions & 0 deletions addons/arsenal/functions/fnc_onLoadoutsOpen.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ _mouseBlockCtrl ctrlCommit 0;
[_arsenalDisplay] call FUNC(buttonHide);

GVAR(currentLoadoutsTab) = -1;
GVAR(loadoutsSearchbarFocus) = false;
GVAR(loadoutsPanelFocus) = false;

GVAR(previousCameraPos) = GVAR(cameraPosition);
GVAR(cameraPosition) = [5,0,20,[-0.85,0,0.85]];
Expand Down
28 changes: 25 additions & 3 deletions addons/arsenal/ui/RscAttributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,8 @@ class GVAR(loadoutsDisplay) {
columns[]={0, 0.05, 0.40, 0.50, 0.60, 0.70, 0.75, 0.80, 0.85, 0.90};
drawSideArrows=0;
disableOverflow=1;
onSetFocus = QUOTE(GVAR(loadoutsPanelFocus) = true);
onKillFocus = QUOTE(GVAR(loadoutsPanelFocus) = false);
onLBSelChanged = QUOTE([ARR_3(ctrlParent (_this select 0), _this select 0, _this select 1)] call FUNC(onSelChangedLoadouts));
onLBDblClick = QUOTE([ARR_2(ctrlparent (_this select 0), (ctrlParent (_this select 0)) displayCtrl IDC_buttonLoad)] call FUNC(buttonLoadoutsLoad));
x = QUOTE(0);
Expand All @@ -786,7 +788,7 @@ class GVAR(loadoutsDisplay) {
class textTitle: RscText {
idc= -1;
text="$STR_DISP_GAME_NAME";
x = QUOTE(1 * GRID_W);
x = QUOTE(0 * GRID_W);
y = QUOTE(safezoneH - (51 * GRID_H));
w = QUOTE(15 * GRID_W);
h = QUOTE(5 * GRID_H);
Expand All @@ -795,9 +797,29 @@ class GVAR(loadoutsDisplay) {
};
class textEditBox: ctrlEdit {
idc= IDC_textEditBox;
x = QUOTE(16 * GRID_W);
x = QUOTE(15 * GRID_W);
y = QUOTE(safezoneH - (51 * GRID_H));
w = QUOTE(80 * GRID_W);
w = QUOTE(65 * GRID_W);
h = QUOTE(5 * GRID_H);
};
class loadoutsSearchbar: ctrlEdit {
idc = IDC_loadoutsSearchbar;
onSetFocus = QUOTE(GVAR(loadoutsSearchbarFocus) = true);
onKillFocus = QUOTE(GVAR(loadoutsSearchbarFocus) = false);
onMouseButtonClick = QUOTE([ARR_3(ctrlParent (_this select 0), _this select 0, _this select 1)] call FUNC(clearSearchbar));
x = QUOTE(83 * GRID_W);
y = QUOTE(safezoneH - (51 * GRID_H));
w = QUOTE(72 * GRID_W);
h = QUOTE(5 * GRID_H);
};
class loadoutsSearchbarButton: ctrlButtonPicture {
idc = -1;
text = "\a3\Ui_f\data\GUI\RscCommon\RscButtonSearch\search_start_ca.paa";
colorBackground[]={0,0,0,0.5};
onButtonClick = QUOTE([ARR_2(ctrlparent (_this select 0), ctrlparent (_this select 0) displayCtrl IDC_loadoutsSearchbar)] call FUNC(handleLoadoutsSearchbar));
x = QUOTE(155 * GRID_W);
y = QUOTE(safezoneH - (51 * GRID_H));
w = QUOTE(5 * GRID_W);
h = QUOTE(5 * GRID_H);
};
class buttonSave: ctrlButton {
Expand Down

0 comments on commit 1b33212

Please sign in to comment.