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

Keybinding - Highlight individual duplicate keys #972

Merged
merged 6 commits into from
Sep 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 9 additions & 15 deletions addons/keybinding/fnc_gui_update.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ private _tablePosY = 0;
_keybinds = _tempNamespace getVariable [_action, _keybinds];

private _keyNames = [];
private _isDuplicated = false;

{
private _keybind = _x;
private _keyName = _keybind call CBA_fnc_localizeKey;
Expand All @@ -77,17 +75,19 @@ private _tablePosY = 0;

// search the addon for any other keybinds using this key.
if (_keybind select 0 > DIK_ESCAPE) then {
{
private _isDuplicated = _addonActions findIf {
private _duplicateAction = format ["%1$%2", _addon, _x];
private _duplicateKeybinds = GVAR(actions) getVariable _duplicateAction select 2;
_duplicateKeybinds = _tempNamespace getVariable [_duplicateAction, _duplicateKeybinds];

if (_keybind in _duplicateKeybinds && {_action != _duplicateAction}) exitWith {
_isDuplicated = true;
};
} forEach _addonActions;
_keybind in _duplicateKeybinds && {_action != _duplicateAction}
};

_keyNames pushBack _keyName;
if (_isDuplicated > -1) then {
_keyNames pushBack format ["<t color='#FF0000'>%1</t>", _keyName];
} else {
_keyNames pushBack format ["<t color='#FFFFFF'>%1</t>", _keyName];
};
};
} forEach _keybinds;

Expand Down Expand Up @@ -118,18 +118,12 @@ private _tablePosY = 0;
private _edit = _subcontrol controlsGroupCtrl IDC_KEY_EDIT;
_edit ctrlSetText _displayName;
_edit ctrlSetTooltip _tooltip;
_edit ctrlSetTooltipColorBox [1,1,1,1];
_edit ctrlSetTooltipColorShade [0,0,0,0.7];
_edit setVariable [QGVAR(data), [_action, _displayName, _keybinds, _defaultKeybind, _forEachIndex]];

private _assigned = _subcontrol controlsGroupCtrl IDC_KEY_ASSIGNED;
_assigned ctrlSetText (_keyNames joinString ", ");
_assigned ctrlSetStructuredText parseText (_keyNames joinString ", ");
_assigned ctrlSetTooltip _tooltip;

if (_isDuplicated) then {
_assigned ctrlSetTextColor [1,0,0,1];
};

_subcontrols pushBack _subcontrol;
_editableSubcontrols pushBack _subcontrol;
} forEach _categoryKeyActions;
11 changes: 9 additions & 2 deletions addons/keybinding/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class RscText;
class RscButton;
class RscButtonMenu;
class RscCombo;
class RscStructuredText;

class GVAR(key): RscControlsGroupNoScrollbars {
idc = -1;
Expand All @@ -24,15 +25,21 @@ class GVAR(key): RscControlsGroupNoScrollbars {
colorBackground[] = {0,0,0,0};
colorBackgroundActive[] = {1,1,1,1};
colorFocused[] = {0.5,0.5,0.5,0.5};
tooltipColorBox[] = {1,1,1,1};
tooltipColorShade[] = {0,0,0,0.7};
tooltipColorText[] = {1,1,1,1};
x = POS_W(0);
y = POS_H(0);
w = POS_W(17);
h = POS_H(1);
};

class AssignedKey: RscText {
class AssignedKey: RscStructuredText {
idc = IDC_KEY_ASSIGNED;
colorShadow[] = {0,0,0,0};
shadow = 0;
tooltipColorBox[] = {1,1,1,1};
tooltipColorShade[] = {0,0,0,0.7};
tooltipColorText[] = {1,1,1,1};
x = POS_W(17);
y = POS_H(0);
w = POS_W(20);
Expand Down