refactor: 定点查看怪物详细信息

This commit is contained in:
unanmed 2023-11-19 20:47:21 +08:00
parent eaad1f0a5a
commit 1e58dbe411
4 changed files with 31 additions and 17 deletions

View File

@ -1,6 +1,6 @@
import { debounce } from 'lodash-es';
import { gameListener } from '../game';
import { fixedUi } from './ui';
import { gameListener, hook } from '../game';
import { fixedUi, mainUi } from './ui';
import { ref } from 'vue';
import { sleep } from 'mutate-animate';
@ -53,3 +53,10 @@ gameListener.on('mouseMove', e => {
showFixed(hovered);
}
});
hook.once('mounted', () => {
mainUi.on('start', () => {
showFixed.cancel();
closeFixed();
});
});

View File

@ -3,6 +3,7 @@ import { Hotkey } from '../custom/hotkey';
import { generateBinary, keycode } from '@/plugin/utils';
import { hovered } from './fixed';
import { hasMarkedEnemy, markEnemy, unmarkEnemy } from '@/plugin/mark';
import { mainUi } from './ui';
export const mainScope = Symbol.for('@key_main');
export const gameKey = new Hotkey('gameKey', '游戏按键');
@ -405,8 +406,12 @@ gameKey
else markEnemy(id);
}
})
.realize('special', () => {})
.realize('critical', () => {})
.realize('special', () => {
mainUi.open('fixedDetail', { panel: 'special' });
})
.realize('critical', () => {
mainUi.open('fixedDetail', { panel: 'critical' });
})
.realize('restart', () => {
core.confirmRestart();
})

View File

@ -76,8 +76,6 @@ import { useDrag } from '../plugin/use';
import EnemySpecial from '../panel/enemySpecial.vue';
import { LeftOutlined, RightOutlined } from '@ant-design/icons-vue';
import EnemyCritical from '../panel/enemyCritical.vue';
import { KeyCode } from '../plugin/keyCodes';
import { keycode } from '../plugin/utils';
import { sleep } from 'mutate-animate';
import EnemyTarget from '../panel/enemyTarget.vue';
import { detailInfo } from '../plugin/ui/book';

View File

@ -9,12 +9,15 @@
</template>
<script lang="ts" setup>
import { getDetailedEnemy, getLocFromMouseLoc } from '../plugin/ui/fixed';
import { getDetailedEnemy } from '../plugin/ui/fixed';
import BookDetail from './bookDetail.vue';
import { detailInfo } from '../plugin/ui/book';
import { hovered } from '@/core/main/init/fixed';
import { GameUi } from '@/core/main/custom/ui';
const props = defineProps<{
num: number;
ui: GameUi;
panel?: 'special' | 'critical' | 'target';
}>();
@ -22,16 +25,17 @@ const panel = props.panel ?? 'special';
detailInfo.pos = 0;
const [x, y] = flags.mouseLoc;
const [mx, my] = getLocFromMouseLoc(x, y);
const enemy = core.status.thisMap.enemy.list.find(v => {
return v.x === mx && v.y === my;
});
if (enemy) {
const detail = getDetailedEnemy(enemy);
detailInfo.enemy = detail;
} else {
close();
if (hovered) {
const { x, y } = hovered;
const enemy = core.status.thisMap.enemy.list.find(v => {
return v.x === x && v.y === y;
});
if (enemy) {
const detail = getDetailedEnemy(enemy);
detailInfo.enemy = detail;
} else {
close();
}
}
function close() {