完善装备栏和道具栏

This commit is contained in:
unanmed 2022-12-28 00:11:11 +08:00
parent 2f88272df8
commit ed4b0fe730
2 changed files with 42 additions and 9 deletions

View File

@ -4,7 +4,9 @@
<span class="button-text tools" @click="exit" <span class="button-text tools" @click="exit"
><left-outlined /> 返回游戏</span ><left-outlined /> 返回游戏</span
> >
<span class="button-text tools">道具栏 <right-outlined /></span> <span class="button-text tools" @click="toTool"
>道具栏 <right-outlined
/></span>
</div> </div>
<div id="equipbox-main"> <div id="equipbox-main">
<div id="equip-list"> <div id="equip-list">
@ -69,8 +71,9 @@
<div id="equip-status-main"> <div id="equip-status-main">
<div id="equip-now"> <div id="equip-now">
<Scroll <Scroll
style="width: 100%; height: 30vh" :style="{
:type="isMobile ? 'horizontal' : 'vertical'" height: isMobile ? '10vh' : '30vh'
}"
> >
<div id="equip-now-div" @touchmove="dragout"> <div id="equip-now-div" @touchmove="dragout">
<div <div
@ -80,7 +83,6 @@
:access="canDragin(i)" :access="canDragin(i)"
:selected="isCol && selected === i" :selected="isCol && selected === i"
@mouseenter="dragin($event, i)" @mouseenter="dragin($event, i)"
@touchmove="dragin($event, i)"
@mouseleave="dragout" @mouseleave="dragout"
@click="select(i, true)" @click="select(i, true)"
> >
@ -183,7 +185,7 @@ import { getAddStatus, getEquips, getNowStatus } from '../plugin/ui/equipbox';
import BoxAnimate from '../components/boxAnimate.vue'; import BoxAnimate from '../components/boxAnimate.vue';
import { has, type } from '../plugin/utils'; import { has, type } from '../plugin/utils';
import { cancelGlobalDrag, isMobile, useDrag } from '../plugin/use'; import { cancelGlobalDrag, isMobile, useDrag } from '../plugin/use';
import { hyper } from 'mutate-animate'; import { hyper, sleep } from 'mutate-animate';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
const equips = ref(getEquips()); const equips = ref(getEquips());
@ -392,7 +394,6 @@ function bind() {
if (draged.value) { if (draged.value) {
draged.value = false; draged.value = false;
loadEquip(); loadEquip();
console.log(toEquipType.value);
} }
}, },
true true
@ -422,6 +423,15 @@ function dragout(e: Event) {
toEquipType.value = -1; toEquipType.value = -1;
} }
async function toTool() {
const before = core.plugin.transition.value;
core.plugin.transition.value = false;
exit();
await sleep(50);
core.plugin.toolOpened.value = true;
core.plugin.transition.value = before;
}
watch(toShow, n => { watch(toShow, n => {
bind(); bind();
}); });
@ -672,12 +682,25 @@ onUnmounted(() => {
} }
#equipbox-main { #equipbox-main {
height: 100%; height: 90vh;
flex-direction: column-reverse; flex-direction: column-reverse;
} }
#equip-now-div { #equip-now-div {
flex-wrap: nowrap; flex-wrap: nowrap;
} }
#equip-status {
flex-direction: column;
flex-basis: auto;
}
#equip-list {
flex-basis: 50%;
}
.divider {
margin: 1% 0 1% 0;
}
} }
</style> </style>

View File

@ -4,7 +4,7 @@
<span class="button-text tools" @click="exit" <span class="button-text tools" @click="exit"
><left-outlined /> 返回游戏</span ><left-outlined /> 返回游戏</span
> >
<span class="button-text tools" @click="exit" <span class="button-text tools" @click="toEquip"
>装备栏 <right-outlined >装备栏 <right-outlined
/></span> /></span>
</div> </div>
@ -173,11 +173,12 @@ async function use(id: ShowItemIds) {
if (id === 'none') return; if (id === 'none') return;
if (core.canUseItem(id)) { if (core.canUseItem(id)) {
// //
const before = core.plugin.transition.value;
core.plugin.transition.value = false; core.plugin.transition.value = false;
exit(); exit();
await sleep(50); await sleep(50);
core.useItem(id); core.useItem(id);
core.plugin.transition.value = true; core.plugin.transition.value = before;
} else { } else {
message.warn({ message.warn({
content: '当前无法使用该道具!', content: '当前无法使用该道具!',
@ -186,6 +187,15 @@ async function use(id: ShowItemIds) {
} }
} }
async function toEquip() {
const before = core.plugin.transition.value;
core.plugin.transition.value = false;
exit();
await sleep(50);
core.plugin.equipOpened.value = true;
core.plugin.transition.value = before;
}
function keyup(e: KeyboardEvent) { function keyup(e: KeyboardEvent) {
const c = keycode(e.keyCode); const c = keycode(e.keyCode);
if (c === KeyCode.Escape || c === KeyCode.KeyX) { if (c === KeyCode.Escape || c === KeyCode.KeyX) {