Only show unbind note on custom presets

This commit is contained in:
redphx 2024-12-09 17:42:51 +07:00
parent 5381575048
commit d292bef5e7
4 changed files with 15 additions and 3 deletions

View File

@ -221,5 +221,6 @@
.bx-settings-row { .bx-settings-row {
background: none; background: none;
padding: 10px;
} }
} }

View File

@ -174,7 +174,7 @@ export abstract class BaseProfileManagerDialog<T extends PresetRecord> extends N
$header, $header,
this.$defaultNote = CE('div', { class: 'bx-default-preset-note bx-gone' }, t('default-preset-note')), this.$defaultNote = CE('div', { class: 'bx-default-preset-note bx-gone' }, t('default-preset-note')),
), ),
CE('div', { class: 'bx-dialog-content bx-hide-scroll-bar' }, this.$content), CE('div', { class: 'bx-dialog-content' }, this.$content),
); );
} }

View File

@ -19,6 +19,7 @@ export class KeyboardShortcutsManagerDialog extends BaseProfileManagerDialog<Key
// private readonly LOG_TAG = 'KeyboardShortcutsManagerDialog'; // private readonly LOG_TAG = 'KeyboardShortcutsManagerDialog';
protected $content: HTMLElement; protected $content: HTMLElement;
private $unbindNote: HTMLElement;
private readonly allKeyElements: BxKeyBindingButton[] = []; private readonly allKeyElements: BxKeyBindingButton[] = [];
protected readonly BLANK_PRESET_DATA: KeyboardShortcutPresetData = { protected readonly BLANK_PRESET_DATA: KeyboardShortcutPresetData = {
@ -65,7 +66,10 @@ export class KeyboardShortcutsManagerDialog extends BaseProfileManagerDialog<Key
} }
} }
this.$content = CE('div', {}, $rows); this.$content = CE('div', {},
this.$unbindNote = CE('i', { class: 'bx-mkb-note' }, t('right-click-to-unbind')),
$rows,
);
} }
private onKeyChanged = (e: Event) => { private onKeyChanged = (e: Event) => {
@ -109,6 +113,9 @@ export class KeyboardShortcutsManagerDialog extends BaseProfileManagerDialog<Key
const isDefaultPreset = id <= 0; const isDefaultPreset = id <= 0;
this.updateButtonStates(); this.updateButtonStates();
// Toggle unbind note
this.$unbindNote.classList.toggle('bx-gone', isDefaultPreset);
// Update buttons // Update buttons
for (const $elm of this.allKeyElements) { for (const $elm of this.allKeyElements) {
const { action } = this.parseDataset($elm); const { action } = this.parseDataset($elm);

View File

@ -48,6 +48,7 @@ export class MkbMappingManagerDialog extends BaseProfileManagerDialog<MkbPresetR
private $mouseSensitivityX!: BxNumberStepper; private $mouseSensitivityX!: BxNumberStepper;
private $mouseSensitivityY!: BxNumberStepper; private $mouseSensitivityY!: BxNumberStepper;
private $mouseDeadzone!: BxNumberStepper; private $mouseDeadzone!: BxNumberStepper;
private $unbindNote!: HTMLElement;
constructor(title: string) { constructor(title: string) {
super(title, MkbMappingPresetsTable.getInstance()); super(title, MkbMappingPresetsTable.getInstance());
@ -93,7 +94,7 @@ export class MkbMappingManagerDialog extends BaseProfileManagerDialog<MkbPresetR
private render() { private render() {
const $rows = CE('div', {}, const $rows = CE('div', {},
CE('i', { class: 'bx-mkb-note' }, t('right-click-to-unbind')), this.$unbindNote = CE('i', { class: 'bx-mkb-note' }, t('right-click-to-unbind')),
); );
for (const buttonIndex of this.BUTTONS_ORDER) { for (const buttonIndex of this.BUTTONS_ORDER) {
@ -185,6 +186,9 @@ export class MkbMappingManagerDialog extends BaseProfileManagerDialog<MkbPresetR
const isDefaultPreset = id <= 0; const isDefaultPreset = id <= 0;
this.updateButtonStates(); this.updateButtonStates();
// Toggle unbind note
this.$unbindNote.classList.toggle('bx-gone', isDefaultPreset);
// Update buttons // Update buttons
for (const $elm of this.allKeyElements) { for (const $elm of this.allKeyElements) {
const { buttonIndex, keySlot } = this.parseDataset($elm); const { buttonIndex, keySlot } = this.parseDataset($elm);