From 4796334ec4281aeccb8804e630c28fc57c4dc6c8 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Wed, 8 Nov 2023 19:50:11 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20fixedUi=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- idea.md | 2 +- public/project/functions.js | 16 ++++++++-------- src/components/colomn.vue | 2 +- src/core/main/setting.ts | 3 +-- src/plugin/game/ui.js | 6 ++++-- src/plugin/uiController.ts | 16 +--------------- src/types/plugin.d.ts | 9 --------- src/ui/achievement.vue | 7 ------- src/ui/book.vue | 13 ++++++------- src/ui/equipbox.vue | 1 - src/ui/fly.vue | 2 +- src/ui/settings.vue | 2 +- src/ui/shop.vue | 2 +- src/ui/skillTree.vue | 2 +- src/ui/toolbox.vue | 18 +++++++++--------- 15 files changed, 35 insertions(+), 66 deletions(-) diff --git a/idea.md b/idea.md index 41e35df..b145405 100644 --- a/idea.md +++ b/idea.md @@ -82,7 +82,7 @@ dam4.png ---- 存档 59 [] 优化 Scroll 组件 [] 重写技能控制系统 [] 自定义快捷键 -[] 优化 ui 控制系统 +[x] 优化 ui 控制系统 [] 优化游戏进程与渲染进程间的通讯 [] 优化资源分离,音乐放到 bgm 目录下 [] 一次性道具拾取与清怪 diff --git a/public/project/functions.js b/public/project/functions.js index eda09d7..59e7cdd 100644 --- a/public/project/functions.js +++ b/public/project/functions.js @@ -638,14 +638,14 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { if (main.replayChecking) return; // 已学习的技能 - if ( - core.plugin.skillTree.getSkillLevel(11) > 0 && - (core.status.hero.special?.num ?? []).length > 0 - ) { - mota.plugin.ui.showStudiedSkill.value = true; - } else { - mota.plugin.ui.showStudiedSkill.value = false; - } + // if ( + // core.plugin.skillTree.getSkillLevel(11) > 0 && + // (core.status.hero.special?.num ?? []).length > 0 + // ) { + // mota.plugin.ui.showStudiedSkill.value = true; + // } else { + // mota.plugin.ui.showStudiedSkill.value = false; + // } }, moveOneStep: function (callback) { // 勇士每走一步后执行的操作。callback为行走完毕后的回调 diff --git a/src/components/colomn.vue b/src/components/colomn.vue index fb844e8..584b237 100644 --- a/src/components/colomn.vue +++ b/src/components/colomn.vue @@ -68,7 +68,7 @@ onMounted(async () => { resize(); await sleep(50); - if (mota.plugin.ui.transition.value) await sleep(600); + // if (mota.plugin.ui.transition.value) await sleep(600); document.addEventListener('keyup', key); }); onUpdated(resize); diff --git a/src/core/main/setting.ts b/src/core/main/setting.ts index 04aaa4e..c0edb54 100644 --- a/src/core/main/setting.ts +++ b/src/core/main/setting.ts @@ -1,6 +1,5 @@ import { reactive } from 'vue'; import { EmitableEvent, EventEmitter } from '../common/eventEmitter'; -import { transition } from '@/plugin/uiController'; import { loading } from '../loader/load'; import { hook } from './game'; import { GameStorage } from './storage'; @@ -297,7 +296,7 @@ function handleScreenSetting( } else if (key === 'transition') { // 界面动画 core.setLocalStorage('transition', n); - transition.value = n as boolean; + // transition.value = n as boolean; } else if (key === 'antiAlias') { // 抗锯齿 core.setLocalStorage('antiAlias', n); diff --git a/src/plugin/game/ui.js b/src/plugin/game/ui.js index bca0c75..071299e 100644 --- a/src/plugin/game/ui.js +++ b/src/plugin/game/ui.js @@ -56,7 +56,9 @@ export {}; control.prototype.showStatusBar = function () { if (main.mode == 'editor') return; core.removeFlag('hideStatusBar'); - mota.plugin.ui.showStatusBar.value = true; + if (!mota.ui.fixed.hasName('statusBar')) { + mota.ui.fixed.open('statusBar'); + } core.dom.tools.hard.style.display = 'block'; core.dom.toolBar.style.display = 'block'; }; @@ -67,7 +69,7 @@ export {}; // 如果原本就是隐藏的,则先显示 if (!core.domStyle.showStatusBar) this.showStatusBar(); if (core.isReplaying()) showToolbox = true; - mota.plugin.ui.showStatusBar.value = false; + mota.ui.fixed.closeByName('statusBar'); var toolItems = core.dom.tools; core.setFlag('hideStatusBar', true); diff --git a/src/plugin/uiController.ts b/src/plugin/uiController.ts index dac4b3f..64e88e6 100644 --- a/src/plugin/uiController.ts +++ b/src/plugin/uiController.ts @@ -2,20 +2,6 @@ import { ref } from 'vue'; // todo: 优化开启控制器 -export const showStatusBar = ref(false); -export const showStudiedSkill = ref(false); -export const startOpened = ref(true); - -export const transition = ref(true); -export const noClosePanel = ref(false); - -export const startAnimationEnded = ref(false); - export default function init() { - return { - transition, - showStatusBar, - showStudiedSkill, - startAnimationEnded - }; + return {}; } diff --git a/src/types/plugin.d.ts b/src/types/plugin.d.ts index c9be6f7..be61d72 100644 --- a/src/types/plugin.d.ts +++ b/src/types/plugin.d.ts @@ -168,12 +168,6 @@ interface PluginUtils { } interface PluginUis { - /** ui是否使用渐变 */ - readonly transition: Ref; - - /** 是否显示状态栏 */ - readonly showStatusBar: Ref; - /** 是否正在进行章节显示 */ readonly chapterShowed: Ref; @@ -183,9 +177,6 @@ interface PluginUis { /** 是否展示标记的怪物 */ readonly showMarkedEnemy: Ref; - /** 是否展示已学习的技能 */ - readonly showStudiedSkill: Ref; - /** 是否展示移动鼠标显示怪物信息的盒子 */ readonly showFixed: Ref; diff --git a/src/ui/achievement.vue b/src/ui/achievement.vue index 69efa53..8042f3c 100644 --- a/src/ui/achievement.vue +++ b/src/ui/achievement.vue @@ -98,7 +98,6 @@ diff --git a/src/ui/book.vue b/src/ui/book.vue index 692e21b..617b2aa 100644 --- a/src/ui/book.vue +++ b/src/ui/book.vue @@ -46,7 +46,6 @@ import { getDamageColor, has, keycode } from '../plugin/utils'; import BookDetail from './bookDetail.vue'; import { LeftOutlined } from '@ant-design/icons-vue'; import { KeyCode } from '../plugin/keyCodes'; -import { noClosePanel } from '../plugin/uiController'; import { ToShowEnemy, detailInfo } from '../plugin/ui/book'; import { getDetailedEnemy } from '../plugin/ui/fixed'; import { GameUi } from '@/core/main/custom/ui'; @@ -118,17 +117,17 @@ async function show() { * 退出怪物手册 */ async function exit() { - noClosePanel.value = true; + const hold = mota.ui.main.holdOn(); mota.ui.main.close(props.num); - if (mota.plugin.ui.transition.value) await sleep(650); - else await sleep(100); + // if (mota.plugin.ui.transition.value) await sleep(650); + // else await sleep(100); if (core.events.recoverEvents(core.status.event.interval)) { return; } else if (has(core.status.event.ui)) { core.status.boxAnimateObjs = []; // @ts-ignore core.ui._drawViewMaps(core.status.event.ui); - } else core.ui.closePanel(); + } else hold.end(); } function checkScroll() { @@ -197,8 +196,8 @@ function keydown(e: KeyboardEvent) { } onMounted(async () => { - if (mota.plugin.ui.transition.value) await sleep(600); - else await sleep(50); + // if (mota.plugin.ui.transition.value) await sleep(600); + await sleep(50); document.addEventListener('keyup', keyup); document.addEventListener('keydown', keydown); }); diff --git a/src/ui/equipbox.vue b/src/ui/equipbox.vue index 51ccde9..622fb67 100644 --- a/src/ui/equipbox.vue +++ b/src/ui/equipbox.vue @@ -435,7 +435,6 @@ function dragout(e: Event) { } function toTool() { - mota.plugin.ui.transition.value = false; mota.ui.main.holdOn(); exit(); mota.ui.main.open('toolbox'); diff --git a/src/ui/fly.vue b/src/ui/fly.vue index 09a065c..48e3313 100644 --- a/src/ui/fly.vue +++ b/src/ui/fly.vue @@ -614,7 +614,7 @@ onMounted(async () => { }); await sleep(50); - if (mota.plugin.ui.transition.value) await sleep(600); + // if (mota.plugin.ui.transition.value) await sleep(600); document.addEventListener('keyup', keyup); map.addEventListener('touchstart', touchdown); diff --git a/src/ui/settings.vue b/src/ui/settings.vue index 626de85..4c17d45 100644 --- a/src/ui/settings.vue +++ b/src/ui/settings.vue @@ -182,7 +182,7 @@ function key(e: KeyboardEvent) { onMounted(async () => { await sleep(50); - if (mota.plugin.ui.transition.value) await sleep(600); + // if (mota.plugin.ui.transition.value) await sleep(600); document.addEventListener('keyup', key); }); diff --git a/src/ui/shop.vue b/src/ui/shop.vue index 4d71f02..d74221c 100644 --- a/src/ui/shop.vue +++ b/src/ui/shop.vue @@ -313,7 +313,7 @@ function exit() { onMounted(async () => { await sleep(50); - if (mota.plugin.ui.transition.value) await sleep(600); + // if (mota.plugin.ui.transition.value) await sleep(600); document.addEventListener('keyup', keyup); document.addEventListener('keydown', keydown); core.status.route.push(`openShop:${id}`); diff --git a/src/ui/skillTree.vue b/src/ui/skillTree.vue index 60a5df0..06f2207 100644 --- a/src/ui/skillTree.vue +++ b/src/ui/skillTree.vue @@ -278,7 +278,7 @@ onMounted(async () => { draw(); await sleep(50); - if (mota.plugin.ui.transition.value) await sleep(600); + // if (mota.plugin.ui.transition.value) await sleep(600); canvas.addEventListener('click', click); document.addEventListener('keyup', key); }); diff --git a/src/ui/toolbox.vue b/src/ui/toolbox.vue index bb36867..1b76a4d 100644 --- a/src/ui/toolbox.vue +++ b/src/ui/toolbox.vue @@ -172,16 +172,16 @@ function exit() { mota.ui.main.close(props.num); } -async function use(id: ShowItemIds) { +function use(id: ShowItemIds) { if (id === 'none') return; if (core.canUseItem(id)) { - // 应该暂时把动画去掉 - const before = mota.plugin.ui.transition.value; - mota.plugin.ui.transition.value = false; + const hold = mota.ui.main.holdOn(); exit(); - await sleep(50); - core.useItem(id); - mota.plugin.ui.transition.value = before; + core.useItem(id, false, () => { + if (mota.ui.main.stack.length === 0) { + hold.end(); + } + }); } else { message.warn({ content: '当前无法使用该道具!', @@ -240,8 +240,8 @@ function keydown(e: KeyboardEvent) { } onMounted(async () => { - if (mota.plugin.ui.transition.value) await sleep(600); - else await sleep(50); + // if (mota.plugin.ui.transition.value) await sleep(600); + await sleep(50); document.addEventListener('keyup', keyup); document.addEventListener('keydown', keydown); });