mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-30 05:54:30 +08:00
refactor: 完善各个ui的按键控制
This commit is contained in:
1 parent
bfc4f70160
commit
bd0205ff46
9 files changed
+117
-48
No files matched your search
+13
-1
@@ -20,11 +20,14 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import desc from '../data/desc.json';
|
||||
import { has, splitText } from '../plugin/utils';
|
||||
import { splitText } from '../plugin/utils';
|
||||
import Colomn from '../components/colomn.vue';
|
||||
import { GameUi } from '@/core/main/custom/ui';
|
||||
import { gameKey } from '@/core/main/init/hotkey';
|
||||
|
||||
const props = defineProps<{
|
||||
num: number;
|
||||
ui: GameUi;
|
||||
}>();
|
||||
|
||||
type DescKey = keyof typeof desc;
|
||||
@@ -47,6 +50,15 @@ function click(key: DescKey) {
|
||||
function show(condition: string) {
|
||||
return eval(condition);
|
||||
}
|
||||
|
||||
gameKey.use(props.ui.symbol);
|
||||
gameKey
|
||||
.realize('exit', () => {
|
||||
exit();
|
||||
})
|
||||
.realize('desc', () => {
|
||||
exit();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
+14
-15
@@ -196,6 +196,7 @@ import { cancelGlobalDrag, isMobile, useDrag } from '../plugin/use';
|
||||
import { hyper, sleep } from 'mutate-animate';
|
||||
import { KeyCode } from '../plugin/keyCodes';
|
||||
import { GameUi } from '@/core/main/custom/ui';
|
||||
import { gameKey } from '@/core/main/init/hotkey';
|
||||
|
||||
const props = defineProps<{
|
||||
num: number;
|
||||
@@ -440,17 +441,19 @@ function toTool() {
|
||||
mota.ui.main.open('toolbox');
|
||||
}
|
||||
|
||||
function keyup(e: KeyboardEvent) {
|
||||
const c = keycode(e.keyCode);
|
||||
if (c === KeyCode.KeyQ || c === KeyCode.KeyX || c === KeyCode.Escape) {
|
||||
gameKey.use(props.ui.symbol);
|
||||
gameKey
|
||||
.realize('exit', () => {
|
||||
exit();
|
||||
}
|
||||
if (e.altKey) {
|
||||
const n = e.keyCode - 48;
|
||||
core.quickSaveEquip(n);
|
||||
tip('success', `已保存至${n}号套装`);
|
||||
}
|
||||
}
|
||||
})
|
||||
.realize('equipbox', () => {
|
||||
exit();
|
||||
})
|
||||
.realize('quickEquip', id => {
|
||||
const num = parseInt(id.split('_').at(-1)!);
|
||||
core.quickSaveEquip(num);
|
||||
tip('success', `已保存至${num}号套装`);
|
||||
});
|
||||
|
||||
watch(toShow, n => {
|
||||
bind();
|
||||
@@ -458,15 +461,11 @@ watch(toShow, n => {
|
||||
|
||||
onMounted(async () => {
|
||||
bind();
|
||||
await sleep(50);
|
||||
nextTick(() => {
|
||||
document.addEventListener('keyup', keyup);
|
||||
});
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
cancelGlobalDrag(dragEquip);
|
||||
document.removeEventListener('keyup', keyup);
|
||||
gameKey.dispose(props.ui.symbol);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -558,6 +558,9 @@ gameKey
|
||||
})
|
||||
.realize('confirm', () => {
|
||||
fly();
|
||||
})
|
||||
.realize('fly', () => {
|
||||
exit();
|
||||
});
|
||||
|
||||
// -------------------- 触摸事件
|
||||
|
||||
+4
-4
@@ -169,12 +169,9 @@ import {
|
||||
RightOutlined,
|
||||
DoubleRightOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import { keycode, splitText, tip } from '../plugin/utils';
|
||||
import { splitText, tip } from '../plugin/utils';
|
||||
import Scroll from '../components/scroll.vue';
|
||||
import { isMobile } from '../plugin/use';
|
||||
import BoxAnimate from '../components/boxAnimate.vue';
|
||||
import { KeyCode } from '../plugin/keyCodes';
|
||||
import { sleep } from 'mutate-animate';
|
||||
import { GameUi } from '@/core/main/custom/ui';
|
||||
import { gameKey } from '@/core/main/init/hotkey';
|
||||
|
||||
@@ -302,6 +299,9 @@ gameKey
|
||||
})
|
||||
.realize('confirm', () => {
|
||||
confirm();
|
||||
})
|
||||
.realize('shop', () => {
|
||||
exit();
|
||||
});
|
||||
|
||||
function exit() {
|
||||
|
||||
+14
-10
@@ -77,13 +77,15 @@
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
import { LeftOutlined, RightOutlined } from '@ant-design/icons-vue';
|
||||
import Scroll from '../components/scroll.vue';
|
||||
import { has, keycode, splitText, tip } from '../plugin/utils';
|
||||
import { has, splitText, tip } from '../plugin/utils';
|
||||
import { isMobile } from '../plugin/use';
|
||||
import { sleep } from 'mutate-animate';
|
||||
import { KeyCode } from '../plugin/keyCodes';
|
||||
import { gameKey } from '@/core/main/init/hotkey';
|
||||
import { GameUi } from '@/core/main/custom/ui';
|
||||
|
||||
const props = defineProps<{
|
||||
num: number;
|
||||
ui: GameUi;
|
||||
}>();
|
||||
|
||||
let canvas: HTMLCanvasElement;
|
||||
@@ -262,14 +264,17 @@ function upgrade(index: number) {
|
||||
}
|
||||
}
|
||||
|
||||
function key(e: KeyboardEvent) {
|
||||
const c = keycode(e.keyCode);
|
||||
if (c === KeyCode.Escape || c === KeyCode.KeyX || c === KeyCode.KeyJ)
|
||||
gameKey.use(props.ui.symbol);
|
||||
gameKey
|
||||
.realize('exit', () => {
|
||||
exit();
|
||||
if (c === KeyCode.Space || c === KeyCode.Enter || c === KeyCode.KeyC) {
|
||||
})
|
||||
.realize('confirm', () => {
|
||||
upgrade(selected.value);
|
||||
}
|
||||
}
|
||||
})
|
||||
.realize('skillTree', () => {
|
||||
exit();
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
canvas = document.getElementById('skill-canvas') as HTMLCanvasElement;
|
||||
@@ -280,11 +285,10 @@ onMounted(async () => {
|
||||
await sleep(50);
|
||||
// if (mota.plugin.ui.transition.value) await sleep(600);
|
||||
canvas.addEventListener('click', click);
|
||||
document.addEventListener('keyup', key);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener('keyup', key);
|
||||
gameKey.dispose(props.ui.symbol);
|
||||
});
|
||||
|
||||
function selectChapter(delta: number) {
|
||||
|
||||
@@ -235,6 +235,9 @@ gameKey
|
||||
})
|
||||
.realize('confirm', () => {
|
||||
use(selected.value);
|
||||
})
|
||||
.realize('toolbox', () => {
|
||||
exit();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
Reference in new issue
Block a user