mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-12-03 07:44:30 +08:00
feat: 苍蓝之殿下方区域完毕
This commit is contained in:
1 parent
06bcb94eae
commit
684fba1475
23 files changed
+199
-123
No files matched your search
@@ -33,7 +33,11 @@ interface HotkeyData extends Required<RegisterHotkeyData> {
|
||||
/**
|
||||
* @param id 此处的id包含数字后缀
|
||||
*/
|
||||
type HotkeyFunc = (id: string, code: KeyCode, ev: KeyboardEvent) => void;
|
||||
type HotkeyFunc = (
|
||||
id: string,
|
||||
code: KeyCode,
|
||||
ev: KeyboardEvent
|
||||
) => void | '@void';
|
||||
|
||||
export interface HotkeyJSON {
|
||||
key: KeyCode;
|
||||
@@ -129,7 +133,7 @@ export class Hotkey extends EventEmitter<HotkeyEvent> {
|
||||
this.scope = symbol;
|
||||
this.conditionMap.set(symbol, () => true);
|
||||
for (const key of Object.values(this.data)) {
|
||||
key.func.set(symbol, () => {});
|
||||
key.func.set(symbol, () => '@void');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +188,7 @@ export class Hotkey extends EventEmitter<HotkeyEvent> {
|
||||
const toEmit = this.keyMap.get(key);
|
||||
if (!toEmit) return false;
|
||||
const { ctrl, shift, alt } = unwarpBinary(assist);
|
||||
let emitted = false;
|
||||
toEmit.forEach(v => {
|
||||
if (type !== v.type) return;
|
||||
if (ctrl === v.ctrl && shift === v.shift && alt === v.alt) {
|
||||
@@ -191,11 +196,12 @@ export class Hotkey extends EventEmitter<HotkeyEvent> {
|
||||
if (!func) {
|
||||
throw new Error(`Emit unknown scope keys.`);
|
||||
}
|
||||
func(v.id, key, ev);
|
||||
const res = func(v.id, key, ev);
|
||||
if (res !== '@void') emitted = true;
|
||||
}
|
||||
});
|
||||
this.emit('emit', key, assist, type);
|
||||
return toEmit.length > 0;
|
||||
return emitted;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -584,6 +584,52 @@ document.addEventListener('keyup', e => {
|
||||
const code = keycode(e.keyCode);
|
||||
if (gameKey.emitKey(code, assist, 'up', e)) {
|
||||
e.preventDefault();
|
||||
} else {
|
||||
// polyfill样板
|
||||
if (
|
||||
main.dom.startPanel.style.display == 'block' &&
|
||||
(main.dom.startButtons.style.display == 'block' ||
|
||||
main.dom.levelChooseButtons.style.display == 'block')
|
||||
) {
|
||||
if (e.keyCode == 38 || e.keyCode == 33)
|
||||
// up/pgup
|
||||
main.selectButton((main.selectedButton || 0) - 1);
|
||||
else if (e.keyCode == 40 || e.keyCode == 34)
|
||||
// down/pgdn
|
||||
main.selectButton((main.selectedButton || 0) + 1);
|
||||
else if (e.keyCode == 67 || e.keyCode == 13 || e.keyCode == 32)
|
||||
// C/Enter/Space
|
||||
main.selectButton(main.selectedButton);
|
||||
else if (
|
||||
e.keyCode == 27 &&
|
||||
main.dom.levelChooseButtons.style.display == 'block'
|
||||
) {
|
||||
// ESC
|
||||
core.showStartAnimate(true);
|
||||
e.preventDefault();
|
||||
}
|
||||
e.stopPropagation();
|
||||
return;
|
||||
}
|
||||
if (main.dom.inputDiv.style.display == 'block') {
|
||||
if (e.keyCode == 13) {
|
||||
setTimeout(function () {
|
||||
main.dom.inputYes.click();
|
||||
}, 50);
|
||||
} else if (e.keyCode == 27) {
|
||||
setTimeout(function () {
|
||||
main.dom.inputNo.click();
|
||||
}, 50);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (
|
||||
core &&
|
||||
core.isPlaying &&
|
||||
core.status &&
|
||||
(core.isPlaying() || core.status.lockControl)
|
||||
)
|
||||
core.onkeyUp(e);
|
||||
}
|
||||
});
|
||||
document.addEventListener('keydown', e => {
|
||||
|
||||
Reference in new issue
Block a user