2022-11-21 20:00:34 +08:00
|
|
|
|
<template>
|
|
|
|
|
<div id="toolbox">
|
2022-11-21 21:21:51 +08:00
|
|
|
|
<div id="tools">
|
2022-11-30 16:42:44 +08:00
|
|
|
|
<span class="button-text tools" @click="exit"
|
2022-11-21 21:21:51 +08:00
|
|
|
|
><left-outlined /> 返回游戏</span
|
|
|
|
|
>
|
2022-12-28 00:11:11 +08:00
|
|
|
|
<span class="button-text tools" @click="toEquip"
|
2022-11-21 21:21:51 +08:00
|
|
|
|
>装备栏 <right-outlined
|
|
|
|
|
/></span>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="toolbox-main">
|
|
|
|
|
<div v-for="cls of toShow" class="item-main">
|
|
|
|
|
<div class="item-info">
|
|
|
|
|
<div class="item-type" v-if="!isMobile">
|
|
|
|
|
{{ getClsName(cls) }}
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else id="item-type-mobile">
|
|
|
|
|
<span
|
2022-11-30 16:42:44 +08:00
|
|
|
|
class="button-text"
|
2022-11-21 21:21:51 +08:00
|
|
|
|
@click="mode = 'tools'"
|
|
|
|
|
:selected="mode === 'tools'"
|
|
|
|
|
>消耗道具</span
|
|
|
|
|
>
|
|
|
|
|
<a-divider
|
|
|
|
|
dashed
|
|
|
|
|
style="border-color: #ddd4; height: 100%"
|
|
|
|
|
type="vertical"
|
|
|
|
|
></a-divider>
|
|
|
|
|
<span
|
2022-11-30 16:42:44 +08:00
|
|
|
|
class="button-text"
|
2022-11-21 21:21:51 +08:00
|
|
|
|
@click="mode = 'constants'"
|
|
|
|
|
:selected="mode === 'constants'"
|
|
|
|
|
>永久道具</span
|
|
|
|
|
>
|
|
|
|
|
</div>
|
2022-11-21 20:00:34 +08:00
|
|
|
|
<a-divider
|
|
|
|
|
dashed
|
2022-11-21 21:21:51 +08:00
|
|
|
|
style="margin: 1vh 0 1vh 0; border-color: #ddd4"
|
2022-11-21 20:00:34 +08:00
|
|
|
|
></a-divider>
|
2023-01-01 22:30:12 +08:00
|
|
|
|
<Scroll class="item-list">
|
2022-11-21 21:21:51 +08:00
|
|
|
|
<div
|
2022-11-30 16:42:44 +08:00
|
|
|
|
class="item selectable"
|
2022-11-21 21:21:51 +08:00
|
|
|
|
v-for="[id, num] of items[cls]"
|
|
|
|
|
:selected="selected === id"
|
|
|
|
|
@click="
|
|
|
|
|
mode = cls;
|
|
|
|
|
select(id);
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
<div class="item-icon">
|
|
|
|
|
<BoxAnimate
|
|
|
|
|
:id="id"
|
|
|
|
|
:width="32"
|
|
|
|
|
:height="32"
|
|
|
|
|
:noborder="true"
|
|
|
|
|
></BoxAnimate>
|
|
|
|
|
<span class="item-name">{{
|
|
|
|
|
all[id].name
|
|
|
|
|
}}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<span>× {{ num }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</Scroll>
|
2022-11-21 20:00:34 +08:00
|
|
|
|
</div>
|
|
|
|
|
<a-divider
|
|
|
|
|
dashed
|
2022-11-21 21:21:51 +08:00
|
|
|
|
:type="isMobile ? 'horizontal' : 'vertical'"
|
|
|
|
|
class="divider"
|
|
|
|
|
style="border-color: #ddd4; margin: 1%"
|
2022-11-21 20:00:34 +08:00
|
|
|
|
></a-divider>
|
|
|
|
|
</div>
|
2022-11-21 21:21:51 +08:00
|
|
|
|
<div id="detail">
|
|
|
|
|
<div id="info">
|
|
|
|
|
<BoxAnimate
|
|
|
|
|
:id="selected"
|
|
|
|
|
:width="32"
|
|
|
|
|
:height="32"
|
|
|
|
|
></BoxAnimate>
|
|
|
|
|
<div id="basic-info">
|
|
|
|
|
<span style="border-bottom: 1px solid #ddd4">{{
|
2022-12-27 23:31:14 +08:00
|
|
|
|
selected === 'none'
|
|
|
|
|
? '没有道具'
|
|
|
|
|
: all[selected].name
|
2022-11-21 21:21:51 +08:00
|
|
|
|
}}</span>
|
|
|
|
|
<span>{{
|
2022-12-27 23:31:14 +08:00
|
|
|
|
selected === 'none'
|
|
|
|
|
? '永久道具'
|
|
|
|
|
: getClsName(all[selected].cls as ItemMode) ??
|
|
|
|
|
'永久道具'
|
2022-11-21 21:21:51 +08:00
|
|
|
|
}}</span>
|
2022-11-21 20:00:34 +08:00
|
|
|
|
</div>
|
2022-11-21 21:21:51 +08:00
|
|
|
|
</div>
|
|
|
|
|
<span style="margin-top: 2vh">点击该物品以使用</span>
|
|
|
|
|
<a-divider dashed style="border-color: #ddd4"></a-divider>
|
|
|
|
|
<div id="desc">
|
2022-12-31 19:49:43 +08:00
|
|
|
|
<span>道具描述</span>
|
2022-11-21 21:21:51 +08:00
|
|
|
|
<Scroll id="desc-text">
|
2022-12-27 23:31:14 +08:00
|
|
|
|
<div v-if="!descText.value!.startsWith('!!html')">
|
2022-11-21 21:21:51 +08:00
|
|
|
|
{{ descText.value }}
|
|
|
|
|
</div>
|
2022-12-27 23:31:14 +08:00
|
|
|
|
<div v-else v-html="descText.value!.slice(6)"></div>
|
2022-11-21 21:21:51 +08:00
|
|
|
|
</Scroll>
|
|
|
|
|
</div>
|
2022-11-21 20:00:34 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2022-11-21 21:21:51 +08:00
|
|
|
|
import { LeftOutlined, RightOutlined } from '@ant-design/icons-vue';
|
2022-11-21 20:00:34 +08:00
|
|
|
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
|
|
|
|
import Scroll from '../components/scroll.vue';
|
|
|
|
|
import BoxAnimate from '../components/boxAnimate.vue';
|
|
|
|
|
import { getClsName, getItems } from '../plugin/ui/toolbox';
|
|
|
|
|
import { isMobile } from '../plugin/use';
|
|
|
|
|
import { type, keycode, has } from '../plugin/utils';
|
|
|
|
|
import { hyper, sleep } from 'mutate-animate';
|
|
|
|
|
import { message } from 'ant-design-vue';
|
|
|
|
|
import { KeyCode } from '../plugin/keyCodes';
|
|
|
|
|
|
2023-11-05 10:54:26 +08:00
|
|
|
|
const props = defineProps<{
|
|
|
|
|
num: number;
|
|
|
|
|
}>();
|
|
|
|
|
|
2022-11-21 20:00:34 +08:00
|
|
|
|
type ItemMode = 'tools' | 'constants';
|
2022-12-27 23:31:14 +08:00
|
|
|
|
type ShowItemIds = ItemIdOf<'constants' | 'tools'> | 'none';
|
2022-11-21 20:00:34 +08:00
|
|
|
|
|
|
|
|
|
const mode = ref<ItemMode>('tools');
|
|
|
|
|
|
|
|
|
|
const items = getItems('all');
|
|
|
|
|
|
|
|
|
|
const toShow = computed<ItemMode[]>(() => {
|
|
|
|
|
return isMobile ? [mode.value] : ['tools', 'constants'];
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const all = core.material.items;
|
|
|
|
|
|
2022-12-27 23:31:14 +08:00
|
|
|
|
const selected = ref<ShowItemIds>(items[toShow.value[0]][0]?.[0] ?? 'none');
|
2022-11-21 20:00:34 +08:00
|
|
|
|
const index = ref(0);
|
|
|
|
|
|
|
|
|
|
watch(index, n => {
|
|
|
|
|
select(items[mode.value][n][0], true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
watch(mode, n => {
|
|
|
|
|
if (!has(items[n][index.value])) {
|
|
|
|
|
selected.value = 'none';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
select(items[n][index.value][0], true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const descText = computed(() => {
|
|
|
|
|
const s = selected.value;
|
|
|
|
|
if (s === 'none') return ref('没有选择道具');
|
2022-12-27 23:31:14 +08:00
|
|
|
|
return type(all[s].text!, 25, hyper('sin', 'out'), true);
|
2022-11-21 20:00:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 选择一个道具时
|
|
|
|
|
* @param id 道具id
|
|
|
|
|
*/
|
2022-12-27 23:31:14 +08:00
|
|
|
|
async function select(id: ShowItemIds, nouse: boolean = false) {
|
2022-11-21 20:00:34 +08:00
|
|
|
|
if (selected.value === id && !nouse) {
|
|
|
|
|
use(id);
|
|
|
|
|
}
|
|
|
|
|
index.value = items[mode.value].findIndex(v => v[0] === id);
|
|
|
|
|
selected.value = id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function exit() {
|
2023-11-05 10:54:26 +08:00
|
|
|
|
mota.ui.main.close(props.num);
|
2022-11-21 20:00:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-08 19:50:11 +08:00
|
|
|
|
function use(id: ShowItemIds) {
|
2022-12-27 23:31:14 +08:00
|
|
|
|
if (id === 'none') return;
|
2022-11-21 20:00:34 +08:00
|
|
|
|
if (core.canUseItem(id)) {
|
2023-11-08 19:50:11 +08:00
|
|
|
|
const hold = mota.ui.main.holdOn();
|
2022-11-21 20:00:34 +08:00
|
|
|
|
exit();
|
2023-11-08 19:50:11 +08:00
|
|
|
|
core.useItem(id, false, () => {
|
|
|
|
|
if (mota.ui.main.stack.length === 0) {
|
|
|
|
|
hold.end();
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-11-21 20:00:34 +08:00
|
|
|
|
} else {
|
|
|
|
|
message.warn({
|
|
|
|
|
content: '当前无法使用该道具!',
|
|
|
|
|
class: 'antdv-message'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-28 00:11:11 +08:00
|
|
|
|
async function toEquip() {
|
2023-11-05 10:54:26 +08:00
|
|
|
|
mota.ui.main.holdOn();
|
2022-12-28 00:11:11 +08:00
|
|
|
|
exit();
|
2023-11-05 10:54:26 +08:00
|
|
|
|
mota.ui.main.open('equipbox');
|
2022-12-28 00:11:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-21 20:00:34 +08:00
|
|
|
|
function keyup(e: KeyboardEvent) {
|
|
|
|
|
const c = keycode(e.keyCode);
|
2022-12-29 13:39:40 +08:00
|
|
|
|
if (c === KeyCode.Escape || c === KeyCode.KeyX || c === KeyCode.KeyT) {
|
2022-11-21 20:00:34 +08:00
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
if (c === KeyCode.Enter || c === KeyCode.KeyC) {
|
|
|
|
|
use(selected.value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function keydown(e: KeyboardEvent) {
|
|
|
|
|
const c = keycode(e.keyCode);
|
|
|
|
|
const total = items[mode.value].length;
|
|
|
|
|
if (c === KeyCode.DownArrow) {
|
|
|
|
|
if (index.value < total - 1) {
|
|
|
|
|
index.value++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (c === KeyCode.UpArrow) {
|
|
|
|
|
if (index.value > 0) {
|
|
|
|
|
index.value--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (c === KeyCode.RightArrow) {
|
|
|
|
|
const constants = items.constants.length;
|
|
|
|
|
if (mode.value === 'tools') {
|
|
|
|
|
if (index.value >= constants) {
|
|
|
|
|
index.value = constants - 1;
|
|
|
|
|
}
|
|
|
|
|
mode.value = 'constants';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (c === KeyCode.LeftArrow) {
|
|
|
|
|
const constants = items.tools.length;
|
|
|
|
|
if (mode.value === 'constants') {
|
|
|
|
|
if (index.value >= constants) {
|
|
|
|
|
index.value = constants - 1;
|
|
|
|
|
}
|
|
|
|
|
mode.value = 'tools';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
2023-11-08 19:50:11 +08:00
|
|
|
|
// if (mota.plugin.ui.transition.value) await sleep(600);
|
|
|
|
|
await sleep(50);
|
2022-11-21 20:00:34 +08:00
|
|
|
|
document.addEventListener('keyup', keyup);
|
|
|
|
|
document.addEventListener('keydown', keydown);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
document.removeEventListener('keyup', keyup);
|
|
|
|
|
document.removeEventListener('keydown', keydown);
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
#toolbox {
|
2022-11-21 21:21:51 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
2022-11-21 20:00:34 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2022-11-21 21:21:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#toolbox-main {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 85vh;
|
2022-11-21 20:00:34 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
font-family: 'normal';
|
2023-08-06 17:46:29 +08:00
|
|
|
|
font-size: 150%;
|
2022-11-21 20:00:34 +08:00
|
|
|
|
user-select: none;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-21 21:21:51 +08:00
|
|
|
|
#tools {
|
|
|
|
|
width: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
2022-11-21 20:00:34 +08:00
|
|
|
|
font-family: 'normal';
|
2022-12-29 19:57:31 +08:00
|
|
|
|
font-size: 3.2vh;
|
2022-11-21 21:21:51 +08:00
|
|
|
|
height: 5vh;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
|
|
.tools {
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
}
|
2022-11-21 20:00:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.item-main {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
|
|
.item-info {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.item-list {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 88vh;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.item-type {
|
|
|
|
|
width: 100%;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#item-type-mobile {
|
|
|
|
|
width: 80%;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
justify-content: space-around;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 16:42:44 +08:00
|
|
|
|
.button-text[selected='true'] {
|
2022-11-21 20:00:34 +08:00
|
|
|
|
color: aqua;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.item {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
2023-01-01 22:30:12 +08:00
|
|
|
|
margin: 1vh 0 0 0;
|
2023-08-06 17:46:29 +08:00
|
|
|
|
padding: 0.5vh 0.5vw;
|
2022-11-21 20:00:34 +08:00
|
|
|
|
border: #0000 0.5px solid;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
|
|
.item-icon {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
.item-name {
|
|
|
|
|
margin-left: 5%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.divider {
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#detail {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
|
|
#info {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
justify-content: space-around;
|
|
|
|
|
align-items: center;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
|
|
|
|
#basic-info {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
border-left: 1px solid #ddd4;
|
|
|
|
|
padding-left: 5%;
|
|
|
|
|
margin-left: 10%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#desc {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
|
|
#desc-text {
|
|
|
|
|
margin-top: 2vh;
|
|
|
|
|
margin-left: 0.5vw;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media screen and (max-width: 600px) {
|
|
|
|
|
#toolbox {
|
|
|
|
|
padding: 5%;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-21 21:21:51 +08:00
|
|
|
|
#tools {
|
|
|
|
|
span {
|
|
|
|
|
margin: 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#toolbox-main {
|
|
|
|
|
flex-direction: column-reverse;
|
|
|
|
|
height: 100%;
|
2023-08-06 17:46:29 +08:00
|
|
|
|
font-size: 100%;
|
2022-11-21 21:21:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-21 20:00:34 +08:00
|
|
|
|
.item-list {
|
|
|
|
|
width: 100%;
|
2022-12-29 19:57:31 +08:00
|
|
|
|
height: 40vh;
|
2022-11-21 20:00:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.divider {
|
|
|
|
|
height: auto;
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.item-main {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column-reverse;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|