Pause all keybinds while recording and add debugger keybind

This commit is contained in:
Samuel Elliott 2018-03-21 00:16:42 +00:00
parent 1772edd37c
commit 2fb5d8fe11
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
6 changed files with 57 additions and 3 deletions

View File

@ -51,6 +51,12 @@
"hint": "Adds some of BetterDiscord's internal modules to `global._bd`.",
"value": false
},
{
"id": "debugger-keybind",
"type": "keybind",
"text": "Debugger keybind",
"hint": "When this keybind is activated the developer tools will be opened and Discord will be paused."
},
{
"id": "ignore-content-manager-errors",
"type": "bool",

View File

@ -13,6 +13,7 @@ import BdCss from './styles/index.scss';
import { Events, CssEditor, Globals, Settings, Database, Updater, ModuleManager, PluginManager, ThemeManager, ExtModuleManager, Vendor, WebpackModules, Patcher, MonkeyPatch, ReactComponents, ReactAutoPatcher, DiscordApi } from 'modules';
import { ClientLogger as Logger, ClientIPC, Utils } from 'common';
import { EmoteModule } from 'builtin';
import electron from 'electron';
const ignoreExternal = false;
const DEV = true;
@ -40,6 +41,14 @@ class BetterDiscord {
else if (window._bd) delete window._bd;
});
const debuggerkeybind = Settings.getSetting('core', 'advanced', 'debugger-keybind');
debuggerkeybind.on('keybind-activated', () => {
const currentWindow = electron.remote.getCurrentWindow();
if (currentWindow.isDevToolsOpened()) return eval('debugger;');
currentWindow.openDevTools();
setTimeout(() => eval('debugger;'), 1000);
});
DOM.injectStyle(BdCss, 'bdmain');
this.globalReady = this.globalReady.bind(this);
Events.on('global-ready', this.globalReady);

View File

@ -2,3 +2,4 @@ export { default as SettingsSet } from './settingsset';
export { default as SettingsCategory } from './settingscategory';
export { default as Setting } from './setting';
export { default as SettingsScheme } from './settingsscheme';
export * from './types';

View File

@ -0,0 +1,12 @@
export { default as BoolSetting } from './bool';
export { default as StringSetting } from './text';
export { default as NumberSetting } from './number';
export { default as DropdownSetting } from './dropdown';
export { default as RadioSetting } from './radio';
export { default as SliderSetting } from './slider';
export { default as ColourSetting } from './colour';
export { default as KeybindSetting } from './keybind';
export { default as FileSetting } from './file';
export { default as GuildSetting } from './guild';
export { default as ArraySetting } from './array';
export { default as CustomSetting } from './custom';

View File

@ -11,18 +11,42 @@
import Setting from './basesetting';
import Combokeys from 'combokeys';
let keybindsPaused = false;
export default class KeybindSetting extends Setting {
constructor(args, ...merge) {
super(args, ...merge);
this.__keybind_activated = this.__keybind_activated.bind(this);
this.combokeys = new Combokeys(document);
this.combokeys.bind(this.value, event => this.emit('keybind-activated', event));
this.combokeys.bind(this.value, this.__keybind_activated);
}
/**
* The value to use when the setting doesn't have a value.
*/
get defaultValue() {
return '';
}
setValueHook() {
this.combokeys.reset();
this.combokeys.bind(this.value, event => this.emit('keybind-activated', event));
this.combokeys.bind(this.value, this.__keybind_activated);
}
__keybind_activated(event) {
if (KeybindSetting.paused) return;
this.emit('keybind-activated', event);
}
static get paused() {
return keybindsPaused;
}
static set paused(paused) {
keybindsPaused = paused;
}
}

View File

@ -24,8 +24,9 @@
</template>
<script>
import { shell } from 'electron';
import { KeybindSetting } from 'structs';
import { ClientIPC, ClientLogger as Logger } from 'common';
import { shell } from 'electron';
import Combokeys from 'combokeys';
import CombokeysRecord from 'combokeys/plugins/record';
@ -49,6 +50,7 @@
},
watch: {
active(active) {
KeybindSetting.paused = active;
if (active) combokeys.record(this.recorded);
}
},