From b990160fa47dbbc1bd298fde1e5ef8dfa3d7b410 Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 24 Aug 2018 18:16:49 +0200 Subject: [PATCH 1/8] add keybinding menu subcategories --- addons/keybinding/fnc_gui_editKey.sqf | 6 +-- addons/keybinding/fnc_gui_update.sqf | 36 ++++++++++++---- .../keybinding/fnc_initDisplayConfigure.sqf | 5 --- addons/keybinding/gui.hpp | 41 +++++++++++++++++-- addons/keybinding/script_component.hpp | 2 + 5 files changed, 70 insertions(+), 20 deletions(-) diff --git a/addons/keybinding/fnc_gui_editKey.sqf b/addons/keybinding/fnc_gui_editKey.sqf index ad74be20c..44ce8122a 100644 --- a/addons/keybinding/fnc_gui_editKey.sqf +++ b/addons/keybinding/fnc_gui_editKey.sqf @@ -3,7 +3,7 @@ params ["_control", "_index"]; private _parentDisplay = ctrlParent _control; -parseSimpleArray (_control lnbData [_index, 0]) params ["_action", "_displayName", "_keybinds", "_defaultKeybind"]; +(_control getVariable QGVAR(data)) params ["_action", "_displayName", "_keybinds", "_defaultKeybind"]; private _display = _parentDisplay createDisplay "RscDisplayConfigureAction"; @@ -220,7 +220,7 @@ _ctrlButtonPrev ctrlAddEventHandler ["ButtonClick", { private _display = ctrlParent _control; private _parentDisplay = displayParent _display; - private _ctrlActionList = _parentDisplay displayCtrl IDC_KEY_LIST; + private _ctrlActionList = _parentDisplay displayCtrl IDC_KEY_LIST; // @todo private _ctrlAction = _display displayCtrl IDC_CONFIGURE_ACTION_TITLE; private _ctrlKeyList = _display displayCtrl IDC_CONFIGURE_ACTION_KEYS; @@ -261,7 +261,7 @@ _ctrlButtonNext ctrlAddEventHandler ["ButtonClick", { private _display = ctrlParent _control; private _parentDisplay = displayParent _display; - private _ctrlActionList = _parentDisplay displayCtrl IDC_KEY_LIST; + private _ctrlActionList = _parentDisplay displayCtrl IDC_KEY_LIST; // @todo private _ctrlAction = _display displayCtrl IDC_CONFIGURE_ACTION_TITLE; private _ctrlKeyList = _display displayCtrl IDC_CONFIGURE_ACTION_KEYS; diff --git a/addons/keybinding/fnc_gui_update.sqf b/addons/keybinding/fnc_gui_update.sqf index ab1976356..d5ad53267 100644 --- a/addons/keybinding/fnc_gui_update.sqf +++ b/addons/keybinding/fnc_gui_update.sqf @@ -6,7 +6,15 @@ if (isNull _display) exitWith {}; private _ctrlAddonList = _display displayCtrl IDC_ADDON_LIST; private _ctrlKeyList = _display displayCtrl IDC_KEY_LIST; -lnbClear _ctrlKeyList; +// clear key list +private _subcontrols = _ctrlKeyList getVariable [QGVAR(KeyListSubcontrols), []]; + +{ + ctrlDelete _x; +} forEach _subcontrols; + +_subcontrols = []; +_ctrlKeyList setVariable [QGVAR(KeyListSubcontrols), _subcontrols]; private _index = lbCurSel _ctrlAddonList; private _addon = _ctrlAddonList lbData _index; @@ -59,16 +67,28 @@ private _tempNamespace = uiNamespace getVariable QGVAR(tempKeybinds); }; } forEach _keybinds; - // add keybinds to action list - private _index = _ctrlKeyList lnbAddRow [_displayName, _keyNames joinString ", "]; - // tooltips bugged for lnb - _ctrlKeyList lbSetTooltip [2 * _index, _tooltip]; - _ctrlKeyList lbSetTooltip [2 * _index + 1, _tooltip]; + private _subcontrol = _display ctrlCreate [QGVAR(key), -1, _ctrlKeyList]; - _ctrlKeyList lnbSetData [[_index, 0], str [_action, _displayName, _keybinds, _defaultKeybind]]; + _subcontrol ctrlSetPosition [POS_W(0), _forEachIndex * POS_H(1)]; + _subcontrol ctrlCommit 0; + + private _edit = _subcontrol controlsGroupCtrl IDC_KEY_EDIT; + _edit ctrlSetText _displayName; + _edit ctrlSetTooltip _tooltip; + _edit ctrlSetTooltipColorShade [0,0,0,0.5]; + + private _assigned = _subcontrol controlsGroupCtrl IDC_KEY_ASSIGNED; + _assigned ctrlSetText (_keyNames joinString ", "); + _assigned ctrlSetTooltip _tooltip; + _assigned ctrlSetTooltipColorShade [0,0,0,0.5]; + + _subcontrol setVariable [QGVAR(data), [_action, _displayName, _keybinds, _defaultKeybind]]; if (_isDuplicated) then { - _ctrlKeyList lnbSetColor [[_index, 1], [1, 0, 0, 1]]; + _edit ctrlSetTextColor [1,0,0,1]; + _assigned ctrlSetTextColor [1,0,0,1]; }; + + _subcontrols pushBack _subcontrol; } forEach _addonActions; diff --git a/addons/keybinding/fnc_initDisplayConfigure.sqf b/addons/keybinding/fnc_initDisplayConfigure.sqf index 0fd0a2770..1b5c847c6 100644 --- a/addons/keybinding/fnc_initDisplayConfigure.sqf +++ b/addons/keybinding/fnc_initDisplayConfigure.sqf @@ -45,11 +45,6 @@ lbSort _ctrlAddonList; _ctrlAddonList lbSetCurSel (uiNamespace getVariable [QGVAR(addonIndex), 0]); _ctrlAddonList ctrlAddEventHandler ["LBSelChanged", {_this call (uiNamespace getVariable QFUNC(gui_update))}]; -private _ctrlKeyList = _display displayCtrl IDC_KEY_LIST; - -_ctrlKeyList ctrlSetTooltipColorShade [0, 0, 0, 0.5]; -_ctrlKeyList ctrlAddEventHandler ["LBSelChanged", {_this call (uiNamespace getVariable QFUNC(gui_editKey))}]; - // ----- namespace for temp changed keybinds uiNamespace setVariable [QGVAR(tempKeybinds), _display ctrlCreate ["RscText", -1]]; diff --git a/addons/keybinding/gui.hpp b/addons/keybinding/gui.hpp index f8abb887f..f65af6e68 100644 --- a/addons/keybinding/gui.hpp +++ b/addons/keybinding/gui.hpp @@ -1,8 +1,42 @@ -class RscButtonMenu; class RscControlsGroupNoScrollbars; +class RscButton; +class RscButtonMenu; class RscText; class RscCombo; -class RscListNBox; + +class GVAR(key): RscControlsGroupNoScrollbars { + idc = -1; + enableDisplay = 0; + x = POS_W(0); + y = POS_H(0); + w = POS_W(37); + h = POS_H(1); + + class controls { + class EditButton: RscButton { + idc = IDC_KEY_EDIT; + onButtonClick = QUOTE(_this call (uiNamespace getVariable 'FUNC(gui_editKey)')); + style = ST_LEFT; + colorFocused[] = {0,0,0,0}; + colorBackground[] = {0,0,0,0}; + colorBackgroundActive[] = {1,1,1,1}; + x = POS_W(0); + y = POS_H(0); + w = POS_W(17); + h = POS_H(1); + }; + + class AssignedKey: RscText { + idc = IDC_KEY_ASSIGNED; + shadow = 2; + colorShadow[] = {0,0,0,0}; + x = POS_W(17); + y = POS_H(0); + w = POS_W(20); + h = POS_H(1); + }; + }; +}; class RscDisplayConfigure { class controls { @@ -58,9 +92,8 @@ class RscDisplayConfigure { h = POS_H(1); wholeHeight = POS_H(12); }; - class CA_ValueKeys: RscListNBox { + class KeyList: RscControlsGroupNoScrollbars { idc = IDC_KEY_LIST; - columns[] = {0, 0.459459459}; //17/37 x = POS_W(0.5); y = POS_H(3.5); w = POS_W(37); diff --git a/addons/keybinding/script_component.hpp b/addons/keybinding/script_component.hpp index 00506bb6b..424269e76 100644 --- a/addons/keybinding/script_component.hpp +++ b/addons/keybinding/script_component.hpp @@ -20,6 +20,8 @@ #define IDC_BTN_KEYBOARD_FAKE 8000 #define IDC_ADDON_LIST 9000 #define IDC_KEY_LIST 9001 +#define IDC_KEY_EDIT 9002 +#define IDC_KEY_ASSIGNED 9003 #define POS_X(N) ((N) * GUI_GRID_W + GUI_GRID_CENTER_X) #define POS_Y(N) ((N) * GUI_GRID_H + GUI_GRID_CENTER_Y) From bd3acaad9a2e93a6526ef9c17c0e7979262ff52d Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 24 Aug 2018 19:06:45 +0200 Subject: [PATCH 2/8] add keybinding menu subcategories --- addons/keybinding/fnc_gui_editKey.sqf | 4 ++-- addons/keybinding/fnc_gui_update.sqf | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/keybinding/fnc_gui_editKey.sqf b/addons/keybinding/fnc_gui_editKey.sqf index 44ce8122a..31e4d9b70 100644 --- a/addons/keybinding/fnc_gui_editKey.sqf +++ b/addons/keybinding/fnc_gui_editKey.sqf @@ -1,6 +1,6 @@ #include "script_component.hpp" -params ["_control", "_index"]; +params ["_control"]; private _parentDisplay = ctrlParent _control; (_control getVariable QGVAR(data)) params ["_action", "_displayName", "_keybinds", "_defaultKeybind"]; @@ -18,7 +18,7 @@ _ctrlAction ctrlSetText _displayName; _ctrlKeyList lbSetData [_ctrlKeyList lbAdd (_x call CBA_fnc_localizeKey), str _x]; } forEach _keybinds; -_ctrlKeyList setVariable [QGVAR(index), _index]; +//_ctrlKeyList setVariable [QGVAR(index), _index]; @todo _ctrlKeyList setVariable [QGVAR(action), _action]; _ctrlKeyList setVariable [QGVAR(undoKeybinds), _keybinds]; _ctrlKeyList setVariable [QGVAR(defaultKeybind), _defaultKeybind]; diff --git a/addons/keybinding/fnc_gui_update.sqf b/addons/keybinding/fnc_gui_update.sqf index d5ad53267..98aa1907c 100644 --- a/addons/keybinding/fnc_gui_update.sqf +++ b/addons/keybinding/fnc_gui_update.sqf @@ -77,13 +77,10 @@ private _tempNamespace = uiNamespace getVariable QGVAR(tempKeybinds); _edit ctrlSetText _displayName; _edit ctrlSetTooltip _tooltip; _edit ctrlSetTooltipColorShade [0,0,0,0.5]; + _edit setVariable [QGVAR(data), [_action, _displayName, _keybinds, _defaultKeybind]]; private _assigned = _subcontrol controlsGroupCtrl IDC_KEY_ASSIGNED; _assigned ctrlSetText (_keyNames joinString ", "); - _assigned ctrlSetTooltip _tooltip; - _assigned ctrlSetTooltipColorShade [0,0,0,0.5]; - - _subcontrol setVariable [QGVAR(data), [_action, _displayName, _keybinds, _defaultKeybind]]; if (_isDuplicated) then { _edit ctrlSetTextColor [1,0,0,1]; From aa06cd8740646cadbd00a1f8f983e8c260c29486 Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 24 Aug 2018 20:06:58 +0200 Subject: [PATCH 3/8] add keybinding menu subcategories --- addons/keybinding/fnc_gui_editKey.sqf | 16 ++++++++++------ addons/keybinding/fnc_gui_update.sqf | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/keybinding/fnc_gui_editKey.sqf b/addons/keybinding/fnc_gui_editKey.sqf index 31e4d9b70..bf646aa33 100644 --- a/addons/keybinding/fnc_gui_editKey.sqf +++ b/addons/keybinding/fnc_gui_editKey.sqf @@ -3,7 +3,7 @@ params ["_control"]; private _parentDisplay = ctrlParent _control; -(_control getVariable QGVAR(data)) params ["_action", "_displayName", "_keybinds", "_defaultKeybind"]; +(_control getVariable QGVAR(data)) params ["_action", "_displayName", "_keybinds", "_defaultKeybind", "_index"]; private _display = _parentDisplay createDisplay "RscDisplayConfigureAction"; @@ -18,7 +18,7 @@ _ctrlAction ctrlSetText _displayName; _ctrlKeyList lbSetData [_ctrlKeyList lbAdd (_x call CBA_fnc_localizeKey), str _x]; } forEach _keybinds; -//_ctrlKeyList setVariable [QGVAR(index), _index]; @todo +_ctrlKeyList setVariable [QGVAR(index), _index]; _ctrlKeyList setVariable [QGVAR(action), _action]; _ctrlKeyList setVariable [QGVAR(undoKeybinds), _keybinds]; _ctrlKeyList setVariable [QGVAR(defaultKeybind), _defaultKeybind]; @@ -220,7 +220,7 @@ _ctrlButtonPrev ctrlAddEventHandler ["ButtonClick", { private _display = ctrlParent _control; private _parentDisplay = displayParent _display; - private _ctrlActionList = _parentDisplay displayCtrl IDC_KEY_LIST; // @todo + private _ctrlActionList = _parentDisplay displayCtrl IDC_KEY_LIST; private _ctrlAction = _display displayCtrl IDC_CONFIGURE_ACTION_TITLE; private _ctrlKeyList = _display displayCtrl IDC_CONFIGURE_ACTION_KEYS; @@ -230,7 +230,9 @@ _ctrlButtonPrev ctrlAddEventHandler ["ButtonClick", { _index = (lnbSize _ctrlActionList select 0) - 1 }; - parseSimpleArray (_ctrlActionList lnbData [_index, 0]) params ["_action", "_displayName", "_keybinds", "_defaultKeybind"]; + _ctrlActionList getVariable QGVAR(KeyListSubcontrols) select _index controlsGroupCtrl IDC_KEY_EDIT getVariable QGVAR(data) params [ + "_action", "_displayName", "_keybinds", "_defaultKeybind" + ]; private _tempNamespace = uiNamespace getVariable QGVAR(tempKeybinds); _keybinds = _tempNamespace getVariable [_action, _keybinds]; @@ -261,7 +263,7 @@ _ctrlButtonNext ctrlAddEventHandler ["ButtonClick", { private _display = ctrlParent _control; private _parentDisplay = displayParent _display; - private _ctrlActionList = _parentDisplay displayCtrl IDC_KEY_LIST; // @todo + private _ctrlActionList = _parentDisplay displayCtrl IDC_KEY_LIST; private _ctrlAction = _display displayCtrl IDC_CONFIGURE_ACTION_TITLE; private _ctrlKeyList = _display displayCtrl IDC_CONFIGURE_ACTION_KEYS; @@ -271,7 +273,9 @@ _ctrlButtonNext ctrlAddEventHandler ["ButtonClick", { _index = 0; }; - parseSimpleArray (_ctrlActionList lnbData [_index, 0]) params ["_action", "_displayName", "_keybinds", "_defaultKeybind"]; + _ctrlActionList getVariable QGVAR(KeyListSubcontrols) select _index controlsGroupCtrl IDC_KEY_EDIT getVariable QGVAR(data) params [ + "_action", "_displayName", "_keybinds", "_defaultKeybind" + ]; private _tempNamespace = uiNamespace getVariable QGVAR(tempKeybinds); _keybinds = _tempNamespace getVariable [_action, _keybinds]; diff --git a/addons/keybinding/fnc_gui_update.sqf b/addons/keybinding/fnc_gui_update.sqf index 98aa1907c..6adae6c4e 100644 --- a/addons/keybinding/fnc_gui_update.sqf +++ b/addons/keybinding/fnc_gui_update.sqf @@ -77,7 +77,7 @@ private _tempNamespace = uiNamespace getVariable QGVAR(tempKeybinds); _edit ctrlSetText _displayName; _edit ctrlSetTooltip _tooltip; _edit ctrlSetTooltipColorShade [0,0,0,0.5]; - _edit setVariable [QGVAR(data), [_action, _displayName, _keybinds, _defaultKeybind]]; + _edit setVariable [QGVAR(data), [_action, _displayName, _keybinds, _defaultKeybind, _forEachIndex]]; private _assigned = _subcontrol controlsGroupCtrl IDC_KEY_ASSIGNED; _assigned ctrlSetText (_keyNames joinString ", "); From bb91d85f61c790b1c22115b711b29010b6f2f8d4 Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 24 Aug 2018 20:25:53 +0200 Subject: [PATCH 4/8] add keybinding menu subcategories --- addons/keybinding/fnc_gui_editKey.sqf | 10 ++++++---- addons/keybinding/gui.hpp | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/keybinding/fnc_gui_editKey.sqf b/addons/keybinding/fnc_gui_editKey.sqf index bf646aa33..8d790023b 100644 --- a/addons/keybinding/fnc_gui_editKey.sqf +++ b/addons/keybinding/fnc_gui_editKey.sqf @@ -225,12 +225,13 @@ _ctrlButtonPrev ctrlAddEventHandler ["ButtonClick", { private _ctrlKeyList = _display displayCtrl IDC_CONFIGURE_ACTION_KEYS; private _index = (_ctrlKeyList getVariable QGVAR(index)) - 1; + private _subcontrols = _ctrlActionList getVariable QGVAR(KeyListSubcontrols); if (_index < 0) then { - _index = (lnbSize _ctrlActionList select 0) - 1 + _index = count _subcontrols - 1 }; - _ctrlActionList getVariable QGVAR(KeyListSubcontrols) select _index controlsGroupCtrl IDC_KEY_EDIT getVariable QGVAR(data) params [ + _subcontrols select _index controlsGroupCtrl IDC_KEY_EDIT getVariable QGVAR(data) params [ "_action", "_displayName", "_keybinds", "_defaultKeybind" ]; @@ -268,12 +269,13 @@ _ctrlButtonNext ctrlAddEventHandler ["ButtonClick", { private _ctrlKeyList = _display displayCtrl IDC_CONFIGURE_ACTION_KEYS; private _index = (_ctrlKeyList getVariable QGVAR(index)) + 1; + private _subcontrols = _ctrlActionList getVariable QGVAR(KeyListSubcontrols); - if (_index >= lnbSize _ctrlActionList select 0) then { + if (_index >= count _subcontrols) then { _index = 0; }; - _ctrlActionList getVariable QGVAR(KeyListSubcontrols) select _index controlsGroupCtrl IDC_KEY_EDIT getVariable QGVAR(data) params [ + _subcontrols select _index controlsGroupCtrl IDC_KEY_EDIT getVariable QGVAR(data) params [ "_action", "_displayName", "_keybinds", "_defaultKeybind" ]; diff --git a/addons/keybinding/gui.hpp b/addons/keybinding/gui.hpp index f65af6e68..32a2dfa15 100644 --- a/addons/keybinding/gui.hpp +++ b/addons/keybinding/gui.hpp @@ -17,9 +17,9 @@ class GVAR(key): RscControlsGroupNoScrollbars { idc = IDC_KEY_EDIT; onButtonClick = QUOTE(_this call (uiNamespace getVariable 'FUNC(gui_editKey)')); style = ST_LEFT; - colorFocused[] = {0,0,0,0}; colorBackground[] = {0,0,0,0}; colorBackgroundActive[] = {1,1,1,1}; + colorFocused[] = {1,1,1,1}; x = POS_W(0); y = POS_H(0); w = POS_W(17); From 3d4155407263cd2fe9b5c29fb3021465bb15f764 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 25 Aug 2018 10:04:09 +0200 Subject: [PATCH 5/8] add keybinding menu subcategories --- addons/keybinding/fnc_gui_editKey.sqf | 4 +-- addons/keybinding/fnc_gui_update.sqf | 4 +++ addons/keybinding/gui.hpp | 38 +++++++++++++++++++++++++- addons/keybinding/script_component.hpp | 1 + 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/addons/keybinding/fnc_gui_editKey.sqf b/addons/keybinding/fnc_gui_editKey.sqf index 8d790023b..5b4988aeb 100644 --- a/addons/keybinding/fnc_gui_editKey.sqf +++ b/addons/keybinding/fnc_gui_editKey.sqf @@ -225,7 +225,7 @@ _ctrlButtonPrev ctrlAddEventHandler ["ButtonClick", { private _ctrlKeyList = _display displayCtrl IDC_CONFIGURE_ACTION_KEYS; private _index = (_ctrlKeyList getVariable QGVAR(index)) - 1; - private _subcontrols = _ctrlActionList getVariable QGVAR(KeyListSubcontrols); + private _subcontrols = _ctrlActionList getVariable QGVAR(KeyListEditableSubcontrols); if (_index < 0) then { _index = count _subcontrols - 1 @@ -269,7 +269,7 @@ _ctrlButtonNext ctrlAddEventHandler ["ButtonClick", { private _ctrlKeyList = _display displayCtrl IDC_CONFIGURE_ACTION_KEYS; private _index = (_ctrlKeyList getVariable QGVAR(index)) + 1; - private _subcontrols = _ctrlActionList getVariable QGVAR(KeyListSubcontrols); + private _subcontrols = _ctrlActionList getVariable QGVAR(KeyListEditableSubcontrols); if (_index >= count _subcontrols) then { _index = 0; diff --git a/addons/keybinding/fnc_gui_update.sqf b/addons/keybinding/fnc_gui_update.sqf index 6adae6c4e..51344a5f3 100644 --- a/addons/keybinding/fnc_gui_update.sqf +++ b/addons/keybinding/fnc_gui_update.sqf @@ -16,6 +16,9 @@ private _subcontrols = _ctrlKeyList getVariable [QGVAR(KeyListSubcontrols), []]; _subcontrols = []; _ctrlKeyList setVariable [QGVAR(KeyListSubcontrols), _subcontrols]; +private _editableSubcontrols = []; +_ctrlKeyList setVariable [QGVAR(KeyListEditableSubcontrols), _editableSubcontrols]; + private _index = lbCurSel _ctrlAddonList; private _addon = _ctrlAddonList lbData _index; @@ -88,4 +91,5 @@ private _tempNamespace = uiNamespace getVariable QGVAR(tempKeybinds); }; _subcontrols pushBack _subcontrol; + _editableSubcontrols pushBack _subcontrol; } forEach _addonActions; diff --git a/addons/keybinding/gui.hpp b/addons/keybinding/gui.hpp index 32a2dfa15..15ea53b0d 100644 --- a/addons/keybinding/gui.hpp +++ b/addons/keybinding/gui.hpp @@ -1,7 +1,7 @@ class RscControlsGroupNoScrollbars; +class RscText; class RscButton; class RscButtonMenu; -class RscText; class RscCombo; class GVAR(key): RscControlsGroupNoScrollbars { @@ -38,6 +38,42 @@ class GVAR(key): RscControlsGroupNoScrollbars { }; }; +class GVAR(subCat): RscControlsGroupNoScrollbars { + x = POS_W(1); + y = POS_H(0); + w = POS_W(37); + h = POS_H(0.75); + + class controls { + class Background: RscText { + colorBackground[] = {0.25,0.25,0.25,0.4}; + x = POS_W(0); + y = POS_H(0); + w = POS_W(36); + h = POS_H(1); + }; + + class Name: RscText { + idc = IDC_SUBCATEGORY_NAME; + style = ST_LEFT; + SizeEx = POS_H(0.75); + x = POS_W(0); + y = POS_H(0); + w = POS_W(15.5); + h = POS_H(0.75); + }; + + class Bar: RscText { + colorBackground[] = {1,1,1,1}; + style = ST_LEFT; + x = POS_W(0); + y = POS_H(0.75) - 2 * pixelH; + w = POS_W(36); + h = pixelH; + }; + }; +}; + class RscDisplayConfigure { class controls { class CBA_ButtonConfigureAddons: RscButtonMenu { diff --git a/addons/keybinding/script_component.hpp b/addons/keybinding/script_component.hpp index 424269e76..b4fcb84eb 100644 --- a/addons/keybinding/script_component.hpp +++ b/addons/keybinding/script_component.hpp @@ -22,6 +22,7 @@ #define IDC_KEY_LIST 9001 #define IDC_KEY_EDIT 9002 #define IDC_KEY_ASSIGNED 9003 +#define IDC_SUBCATEGORY_NAME 9004 #define POS_X(N) ((N) * GUI_GRID_W + GUI_GRID_CENTER_X) #define POS_Y(N) ((N) * GUI_GRID_H + GUI_GRID_CENTER_Y) From e4c1ec638cd4550ac120ed5bab37683d3ec7b673 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 25 Aug 2018 12:23:41 +0200 Subject: [PATCH 6/8] add keybinding menu subcategories --- addons/keybinding/fnc_addKeybind.sqf | 7 +++-- addons/keybinding/fnc_gui_update.sqf | 43 ++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/addons/keybinding/fnc_addKeybind.sqf b/addons/keybinding/fnc_addKeybind.sqf index f56a89cf7..803814ad5 100644 --- a/addons/keybinding/fnc_addKeybind.sqf +++ b/addons/keybinding/fnc_addKeybind.sqf @@ -22,7 +22,7 @@ Description: 0xF9: Mouse wheel down Parameters: - _addon - Name of the registering mod + _addon - Name of the registering mod + optional sub-category _action - Id of the key action. _title - Pretty name, or an array of pretty name and tooltip _downCode - Code for down event, empty string for no code. @@ -68,7 +68,7 @@ if (canSuspend) exitWith { }; params [ - ["_addon", "", [""]], + ["_addonArg", "", ["", []]], ["_addonAction", "", [""]], ["_title", "", ["", []]], ["_downCode", {}, [{}, ""]], @@ -79,6 +79,7 @@ params [ ["_overwrite", false, [false]] ]; +_addonArg params [["_addon", "", [""]], ["_subcategory", "", [""]]]; _title params [["_displayName", _addonAction, [""]], ["_tooltip", "", [""]]]; private _action = toLower format ["%1$%2", _addon, _addonAction]; @@ -156,7 +157,7 @@ if (isNil "_addonInfo") then { (_addonInfo select 1) pushBackUnique toLower _addonAction; -GVAR(actions) setVariable [_action, [_displayName, _tooltip, _keybinds, _defaultKeybind, _downCode, _upCode, _holdKey, _holdDelay]]; +GVAR(actions) setVariable [_action, [_displayName, _tooltip, _keybinds, _defaultKeybind, _downCode, _upCode, _holdKey, _holdDelay, _subcategory]]; // add this action to all keybinds { diff --git a/addons/keybinding/fnc_gui_update.sqf b/addons/keybinding/fnc_gui_update.sqf index 51344a5f3..97fad42e1 100644 --- a/addons/keybinding/fnc_gui_update.sqf +++ b/addons/keybinding/fnc_gui_update.sqf @@ -28,8 +28,29 @@ uiNamespace setVariable [QGVAR(addonIndex), _index]; private _tempNamespace = uiNamespace getVariable QGVAR(tempKeybinds); +private _categoryKeyActions = []; + { private _action = format ["%1$%2", _addon, _x]; + private _subcategory = (GVAR(actions) getVariable _action) param [8, "", [""]]; + + _categoryKeyActions pushBack [_subcategory, _forEachIndex, _x]; +} forEach _addonActions; + +_categoryKeyActions sort true; +private _lastSubcategory = "$START"; +private _tablePosY = 0; + +{ + _x params ["_subcategory", "", "_keyAction"]; + + private _createHeader = false; + if (_subcategory != _lastSubcategory) then { + _lastSubcategory = _subcategory; + _createHeader = _subcategory != ""; + }; + + private _action = format ["%1$%2", _addon, _keyAction]; (GVAR(actions) getVariable _action) params ["_displayName", "_tooltip", "_keybinds", "_defaultKeybind"]; if (isLocalized _displayName) then { @@ -70,12 +91,30 @@ private _tempNamespace = uiNamespace getVariable QGVAR(tempKeybinds); }; } forEach _keybinds; + // add subcategory header + if (_createHeader) then { + private _header = _display ctrlCreate [QGVAR(subCat), -1, _ctrlKeyList]; + + if (isLocalized _subcategory) then { + _subcategory = localize _subcategory; + }; + + (_header controlsGroupCtrl IDC_SUBCATEGORY_NAME) ctrlSetText format ["%1:", _subcategory]; + _header ctrlSetPosition [POS_W(0), _tablePosY]; + _header ctrlCommit 0; + + _tablePosY = _tablePosY + getNumber (configFile >> QGVAR(subCat) >> "h"); + _subcontrols pushBack _header; + }; + // tooltips bugged for lnb private _subcontrol = _display ctrlCreate [QGVAR(key), -1, _ctrlKeyList]; - _subcontrol ctrlSetPosition [POS_W(0), _forEachIndex * POS_H(1)]; + _subcontrol ctrlSetPosition [POS_W(0), _tablePosY]; _subcontrol ctrlCommit 0; + _tablePosY = _tablePosY + POS_H(1); + private _edit = _subcontrol controlsGroupCtrl IDC_KEY_EDIT; _edit ctrlSetText _displayName; _edit ctrlSetTooltip _tooltip; @@ -92,4 +131,4 @@ private _tempNamespace = uiNamespace getVariable QGVAR(tempKeybinds); _subcontrols pushBack _subcontrol; _editableSubcontrols pushBack _subcontrol; -} forEach _addonActions; +} forEach _categoryKeyActions; From 1a2536b6cee31a429a4065e6e44aaf251df401d8 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 25 Aug 2018 12:28:56 +0200 Subject: [PATCH 7/8] add the missing scrollbar --- addons/keybinding/gui.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/keybinding/gui.hpp b/addons/keybinding/gui.hpp index 15ea53b0d..9b3cae8f3 100644 --- a/addons/keybinding/gui.hpp +++ b/addons/keybinding/gui.hpp @@ -1,3 +1,4 @@ +class RscControlsGroup; class RscControlsGroupNoScrollbars; class RscText; class RscButton; @@ -128,7 +129,7 @@ class RscDisplayConfigure { h = POS_H(1); wholeHeight = POS_H(12); }; - class KeyList: RscControlsGroupNoScrollbars { + class KeyList: RscControlsGroup { idc = IDC_KEY_LIST; x = POS_W(0.5); y = POS_H(3.5); From 690ad9f8f1fc529c57b36eba1c47292413745801 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 31 Aug 2018 10:06:42 -0500 Subject: [PATCH 8/8] fix scrolling on subcategories --- addons/keybinding/gui.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/keybinding/gui.hpp b/addons/keybinding/gui.hpp index 9b3cae8f3..7785d3a49 100644 --- a/addons/keybinding/gui.hpp +++ b/addons/keybinding/gui.hpp @@ -51,7 +51,7 @@ class GVAR(subCat): RscControlsGroupNoScrollbars { x = POS_W(0); y = POS_H(0); w = POS_W(36); - h = POS_H(1); + h = POS_H(0.75); }; class Name: RscText {