Add QOL improvement for the ACE Arsenal loadouts screen (#5973)

* 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
This commit is contained in:
Josuan Albin 2017-12-30 08:13:06 +01:00 committed by PabstMirror
parent 65fe101aaf
commit 1b332129e6
8 changed files with 211 additions and 89 deletions

View File

@ -14,6 +14,7 @@ PREP(clearSearchbar);
PREP(fillLeftPanel);
PREP(fillLoadoutsList);
PREP(fillRightPanel);
PREP(handleLoadoutsSearchbar);
PREP(handleMouse);
PREP(handleScrollWheel);
PREP(handleSearchbar);

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -21,13 +21,60 @@
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 {
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);
};
};
} 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): {
[_loadoutsDisplay, _loadoutsDisplay displayCtrl IDC_loadoutsSearchbar] call FUNC(handleLoadoutsSearchBar);
};
case (_keyPressed in [DIK_LEFT, DIK_RIGHT]): {
_return = false;
};
};
};
switch true do {
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;
};
case (GVAR(loadoutsPanelFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}): {
_return = false;
};
};
} else {
if (!GVAR(leftSearchbarFocus) && {!GVAR(rightSearchbarFocus)}) then {
switch true do {
// Close button
@ -78,7 +125,7 @@ if (!GVAR(leftSearchbarFocus) && {!GVAR(rightSearchbarFocus)}) then {
playsound ["RscDisplayCurator_visionMode",true];
};
};
} else {
} else {
switch true do {
case (_keyPressed == DIK_ESCAPE): {
_display closeDisplay 2;
@ -119,22 +166,23 @@ if (!GVAR(leftSearchbarFocus) && {!GVAR(rightSearchbarFocus)}) then {
};
};
};
};
};
if (GVAR(leftTabFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then {
if (GVAR(leftTabFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then {
_return = false;
};
};
if (GVAR(rightTabFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then {
if (GVAR(rightTabFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then {
_return = false;
};
};
if (GVAR(rightTabLnBFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then {
if (GVAR(rightTabLnBFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then {
_return = false;
};
};
if (GVAR(rightTabLnBFocus) && {_keyPressed in [DIK_LEFT, DIK_RIGHT]}) then {
if (GVAR(rightTabLnBFocus) && {_keyPressed in [DIK_LEFT, DIK_RIGHT]}) then {
[_display, [1, 0] select (_keyPressed == DIK_LEFT)] call FUNC(buttonCargo);
};
};
_return

View File

@ -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;

View File

@ -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]];

View File

@ -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);
@ -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);
@ -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 {