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 1 commit
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: 10 additions & 14 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,17 @@ private _tablePosY = 0;

// search the addon for any other keybinds using this key.
if (_keybind select 0 > DIK_ESCAPE) then {
{
if (_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;

_keyNames pushBack _keyName;
_keybind in _duplicateKeybinds && {_action != _duplicateAction}
} > -1) then {
Copy link
Contributor

Choose a reason for hiding this comment

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

Very cool. Apparently Travis doesn't understand if findIf.

_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 @@ -123,12 +121,10 @@ private _tablePosY = 0;
_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];
};
_assigned ctrlSetTooltipColorBox [1,1,1,1];
_assigned ctrlSetTooltipColorShade [0,0,0,0.7];
Copy link
Contributor

Choose a reason for hiding this comment

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

These already were the values used I believe. Although setting them explicitly may be more robust if future changes happen (e.g. by BI).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RscStructuredText, unlike RscText, has no entries for tooltip defined, and the defaults look different to these. Should probably just move these to config though.


_subcontrols pushBack _subcontrol;
_editableSubcontrols pushBack _subcontrol;
Expand Down
5 changes: 3 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 @@ -30,9 +31,9 @@ class GVAR(key): RscControlsGroupNoScrollbars {
h = POS_H(1);
};

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