refactor: 章节显示

This commit is contained in:
unanmed 2023-11-13 12:53:22 +08:00
parent 5e4a8c1eb3
commit 2d3146758b
10 changed files with 12 additions and 79 deletions

View File

@ -35,7 +35,7 @@ main.floors.MT0=
"\r[red]注意!!!\r[]该塔新增了很多新的功能同时对样板的ui进行了大幅度的改动操作也有改变由于内容过多这里不再一一描述具体请在道具栏查看百科全书百科全书是在你面前的几个道具中的其中一个",
{
"type": "function",
"function": "function(){\ncore.plugin.gameUi.showChapter('序章 起源');\n}"
"function": "function(){\nmota.ui.fixed.open('chapter', { chapter: '序章 起源' });\n}"
}
],
"parallelDo": "",

View File

@ -157,7 +157,7 @@ main.floors.MT21=
"\t[低级智人]\b[up,hero]或许智慧结晶会告诉我答案吧。",
{
"type": "function",
"function": "function(){\ncore.plugin.gameUi.showChapter('第二章 智慧');\ncore.plugin.removeMap.removeMaps('tower1', 'tower7', true);\ndelete flags.tower1;\ndelete flags.wordsTimeOut;\ndelete flags.boom;\ndelete flags.booming;\n}"
"function": "function(){\nmota.ui.fixed.open('chapter', { chapter: '第二章 智慧' });\ncore.plugin.removeMap.removeMaps('tower1', 'tower7', true);\ndelete flags.tower1;\ndelete flags.wordsTimeOut;\ndelete flags.boom;\ndelete flags.booming;\n}"
},
{
"type": "setValue",

View File

@ -63,7 +63,7 @@ main.floors.MT6=
"\t[原始人]\b[down,hero]感觉好像可以学习一些简单的东西了。",
{
"type": "function",
"function": "function(){\ncore.plugin.gameUi.showChapter('第一章 勇气');\n}"
"function": "function(){\nmota.ui.fixed.open('chapter', { chapter: '第一章 勇气' });\n}"
},
{
"type": "setValue",

View File

@ -18,10 +18,8 @@ interface AncTePlugin {
utils: ReturnType<typeof import('../plugin/utils').default>;
status: ReturnType<typeof import('../plugin/ui/statusBar').default>;
mark: ReturnType<typeof import('../plugin/mark').default>;
chapter: ReturnType<typeof import('../plugin/ui/chapter').default>;
fly: ReturnType<typeof import('../plugin/ui/fly').default>;
chase: ReturnType<typeof import('../plugin/chase/chase').default>;
fixed: ReturnType<typeof import('../plugin/ui/fixed').default>;
webglUtils: ReturnType<typeof import('../plugin/webgl/utils').default>;
shadow: ReturnType<typeof import('../plugin/shadow/shadow').default>;
gameShadow: ReturnType<

View File

@ -5,7 +5,6 @@ import animate from '@/plugin/animateController';
import utils from '@/plugin/utils';
import status from '@/plugin/ui/statusBar';
import mark from '@/plugin/mark';
import chapter from '@/plugin/ui/chapter';
import fly from '@/plugin/ui/fly';
import chase from '@/plugin/chase/chase';
import webglUtils from '@/plugin/webgl/utils';
@ -29,7 +28,6 @@ export function resolvePlugin() {
['utils', utils()],
['status', status()],
['mark', mark()],
['chapter', chapter()],
['fly', fly()],
['chase', chase()],
['webglUtils', webglUtils()],

View File

@ -5,7 +5,6 @@ export {};
if (main.replayChecking)
return (core.plugin.gameUi = {
openItemShop: () => 0,
showChapter: () => 0,
openSkill: () => 0
});
@ -86,12 +85,6 @@ export {};
}
};
function showChapter(chapter) {
if (core.isReplaying()) return;
mota.plugin.chapter.chapterContent.value = chapter;
mota.plugin.chapter.chapterShowed.value = true;
}
function openSkill() {
if (core.isReplaying()) return;
mota.ui.main.open('skill');
@ -99,7 +92,6 @@ export {};
core.plugin.gameUi = {
openItemShop,
openSkill,
showChapter
openSkill
};
})();

View File

@ -1,8 +0,0 @@
import { ref } from 'vue';
export const chapterShowed = ref(false);
export const chapterContent = ref('');
export default function init() {
return { chapterShowed, chapterContent };
}

View File

@ -1,51 +1,8 @@
import { cloneDeep, debounce } from 'lodash-es';
import { ref } from 'vue';
import { getDamageColor } from '../utils';
import { ToShowEnemy, detailInfo } from './book';
import { ToShowEnemy } from './book';
import { DamageEnemy } from '../game/enemy/damage';
import { isMobile } from '../use';
// export const showFixed = ref(false);
// let lastId: EnemyIds;
// const show = debounce((ev: MouseEvent) => {
// if (!window.flags) return;
// if (!flags.mouseLoc) return;
// flags.clientLoc = [ev.clientX, ev.clientY];
// const [mx, my] = getLocFromMouseLoc(...flags.mouseLoc);
// const e = core.status.thisMap.enemy.list.find(v => {
// return v.x === mx && v.y === my;
// });
// if (!e) return;
// lastId = e.id;
// const detail = getDetailedEnemy(e);
// detailInfo.enemy = detail;
// showFixed.value = true;
// }, 200);
// export default function init() {
// const data = core.canvas.data.canvas;
// data.addEventListener('mousemove', ev => {
// if (!core.isPlaying() || core.status.lockControl) return;
// const [mx, my] = getLocFromMouseLoc(...flags.mouseLoc);
// const e = core.getBlockId(mx, my);
// if (e !== lastId) showFixed.value = false;
// if (!e) return;
// show(ev);
// });
// data.addEventListener('mousedown', ev => {
// showFixed.value = false;
// });
// return {
// showFixed
// };
// }
export function getLocFromMouseLoc(x: number, y: number): LocArr {
const mx = Math.round(x + core.bigmap.offsetX / 32);
const my = Math.round(y + core.bigmap.offsetY / 32);

View File

@ -177,12 +177,6 @@ interface PluginUis {
/** 是否展示标记的怪物 */
readonly showMarkedEnemy: Ref<boolean>;
/**
*
* @param chapter
*/
showChapter(chapter: string): void;
/**
*
*/

View File

@ -6,12 +6,14 @@
</template>
<script lang="ts" setup>
import { Animation, hyper, power, sleep } from 'mutate-animate';
import { onMounted, ref } from 'vue';
import { Animation, hyper, sleep } from 'mutate-animate';
import { onMounted } from 'vue';
import { has } from '../plugin/utils';
import { chapterShowed } from '../plugin/ui/chapter';
import { GameUi } from '@/core/main/custom/ui';
const props = defineProps<{
num: number;
ui: GameUi;
chapter: string;
}>();
@ -27,7 +29,7 @@ onMounted(async () => {
const ani = new Animation();
const w = window.innerWidth * devicePixelRatio;
const h = window.innerHeight * devicePixelRatio;
ctx.font = '5vh scroll';
ctx.font = '5vh normal';
const textWidth = ctx.measureText(props.chapter).width;
const line = h * 0.05;
ani.register('rect', 0);
@ -54,7 +56,7 @@ onMounted(async () => {
}
if (time >= 4050) {
chapterShowed.value = false;
mota.ui.fixed.close(props.num);
ani.ticker.destroy();
}