refactor: 迁移旧ui至新ui系统

This commit is contained in:
AncTe committed 2023-11-05 10:54:26 +08:00
1 parent 9a97a470f1
commit 8fcc570e5d
29 files changed
+219 -320

No files matched your search

+2 -1
View File
@@ -715,10 +715,11 @@ export class DamageEnemy<T extends EnemyIds = EnemyIds> {
start = curr;
}
if (i++ >= 10000) {
throw new Error(
console.warn(
`Unexpected endless loop in calculating critical.` +
`Enemy Id: ${this.id}. Loc: ${this.x},${this.y}. Floor: ${this.floorId}`
);
break;
}
}
+4 -2
View File
@@ -113,8 +113,10 @@ function getRealStatus(
declare global {
interface PluginDeclaration {
getHeroStatusOf: typeof getHeroStatusOf;
getHeroStatusOn: typeof getHeroStatusOn;
hero: {
getHeroStatusOf: typeof getHeroStatusOf;
getHeroStatusOn: typeof getHeroStatusOn;
};
}
}
+1 -1
View File
@@ -227,7 +227,7 @@ export function getSkillConsume(skill) {
export function openTree() {
if (main.replayChecking) return;
mota.plugin.ui.skillTreeOpened.value = true;
mota.ui.main.open('skillTree');
}
/**
+9 -10
View File
@@ -11,8 +11,9 @@ export {};
function openItemShop(itemShopId) {
if (!core.isReplaying()) {
core.plugin.openedShopId = itemShopId;
mota.plugin.ui.shopOpened.value = true;
mota.ui.main.open('shop', void 0, {
shopId: itemShopId
});
}
}
@@ -24,22 +25,19 @@ export {};
}
ui.prototype.drawBook = function () {
if (!core.isReplaying())
return (mota.plugin.ui.bookOpened.value = true);
if (!core.isReplaying()) return mota.ui.main.open('book');
};
ui.prototype._drawToolbox = function () {
if (!core.isReplaying())
return (mota.plugin.ui.toolOpened.value = true);
if (!core.isReplaying()) return mota.ui.main.open('toolbox');
};
ui.prototype._drawEquipbox = function () {
if (!core.isReplaying())
return (mota.plugin.ui.equipOpened.value = true);
if (!core.isReplaying()) return mota.ui.main.open('equipbox');
};
ui.prototype.drawFly = function () {
if (!core.isReplaying()) return (mota.plugin.ui.flyOpened.value = true);
if (!core.isReplaying()) return mota.ui.main.open('fly');
};
control.prototype.updateStatusBar_update = function () {
@@ -54,6 +52,7 @@ export {};
updateVueStatusBar();
};
// todo: 多个状态栏分离与控制
control.prototype.showStatusBar = function () {
if (main.mode == 'editor') return;
core.removeFlag('hideStatusBar');
@@ -93,7 +92,7 @@ export {};
function openSkill() {
if (core.isReplaying()) return;
mota.plugin.ui.skillOpened.value = true;
mota.ui.main.open('skill');
}
core.plugin.gameUi = {
+1 -1
View File
@@ -67,7 +67,7 @@ export function getNowStatus(nowEquip?: Equip, onCol: boolean = false) {
{toShow.map(v => {
let status: string;
if (v === 'lv') status = core.getLvName() ?? '';
else status = core.plugin.getHeroStatusOn(v)?.toString();
else status = core.plugin.hero.getHeroStatusOn(v)?.toString();
let add = 0;
if (has(nowEquip)) {
+2 -107
View File
@@ -1,126 +1,21 @@
import { sleep } from 'mutate-animate';
import { Component, markRaw, ref, Ref, shallowReactive, watch } from 'vue';
import Book from '../ui/book.vue';
import Toolbox from '../ui/toolbox.vue';
import Equipbox from '../ui/equipbox.vue';
import Settings from '../ui/settings.vue';
import Desc from '../ui/desc.vue';
import Skill from '../ui/skill.vue';
import SkillTree from '../ui/skillTree.vue';
import Fly from '../ui/fly.vue';
import FixedDetail from '../ui/fixedDetail.vue';
import Shop from '../ui/shop.vue';
import Achievement from '../ui/achievement.vue';
import Bgm from '../ui/bgmList.vue';
import { ref } from 'vue';
// todo: 优化开启控制器
export const bookOpened = ref(false);
export const toolOpened = ref(false);
export const equipOpened = ref(false);
export const showStatusBar = ref(false);
export const settingsOpened = ref(false);
export const descOpened = ref(false);
export const skillOpened = ref(false);
export const skillTreeOpened = ref(false);
export const flyOpened = ref(false);
export const showStudiedSkill = ref(false);
export const fixedDetailOpened = ref(false);
export const shopOpened = ref(false);
export const startOpened = ref(true);
export const achievementOpened = ref(false);
export const bgmOpened = ref(false);
export const transition = ref(true);
export const noClosePanel = ref(false);
export const startAnimationEnded = ref(false);
let app: HTMLDivElement;
/** ui声明列表 */
const UI_LIST: [Ref<boolean>, Component][] = [
// [bookOpened, Book],
// [toolOpened, Toolbox],
// [equipOpened, Equipbox],
// [settingsOpened, Settings],
// [descOpened, Desc],
// [skillOpened, Skill],
// [skillTreeOpened, SkillTree],
// [flyOpened, Fly],
// [fixedDetailOpened, FixedDetail],
// [shopOpened, Shop],
// [achievementOpened, Achievement],
// [bgmOpened, Bgm]
];
/** ui栈 */
export const uiStack = shallowReactive<Component[]>([]);
export default function init() {
// app = document.getElementById('root') as HTMLDivElement;
// UI_LIST.forEach(([ref, com]) => {
// watch(ref, n => {
// if (n === true) {
// uiStack.push(markRaw(com));
// showApp();
// } else {
// const index = uiStack.findIndex(v => v === com);
// if (index === -1) return;
// if (uiStack.length === 1) {
// hideApp(index);
// } else {
// uiStack.splice(index, 1);
// }
// }
// });
// });
return {
uiStack,
transition,
bookOpened,
toolOpened,
equipOpened,
showStatusBar,
settingsOpened,
descOpened,
skillOpened,
skillTreeOpened,
flyOpened,
showStudiedSkill,
fixedDetailOpened,
shopOpened,
startOpened,
startAnimationEnded,
achievementOpened,
bgmOpened
startAnimationEnded
};
}
async function showApp() {
core.lockControl();
if (transition.value) {
app.style.transition = 'all 0.6s linear';
} else {
app.style.transition = 'none';
}
app.style.display = 'flex';
await sleep(50);
app.style.opacity = '1';
}
async function hideApp(index: number) {
if (transition.value) {
app.style.transition = 'all 0.6s linear';
app.style.opacity = '0';
await sleep(600);
} else {
app.style.transition = '';
app.style.opacity = '0';
}
uiStack.splice(index, 1);
app.style.display = 'none';
if (!noClosePanel.value) core.closePanel();
noClosePanel.value = false;
}