移动鼠标查看怪物信息

This commit is contained in:
AncTe committed 2023-01-06 21:51:58 +08:00
1 parent b84b1e6137
commit ac55517d57
21 files changed
+476 -141

No files matched your search

+3 -1
View File
@@ -5,6 +5,7 @@
<Studied
v-if="showStudiedSkill && showStatusBar && showStudied"
></Studied>
<Fixed v-if="showStatusBar && useFixed"></Fixed>
<Chapter v-if="chapterShowed" :chapter="chapterContent"></Chapter>
</div>
</template>
@@ -18,7 +19,8 @@ import Chapter from './ui/chapter.vue';
import { chapterContent, chapterShowed } from './plugin/ui/chapter';
import { showMarkedEnemy } from './plugin/mark';
import Studied from './ui/studied.vue';
import { showStudied } from './plugin/settings';
import { showStudied, useFixed } from './plugin/settings';
import Fixed from './ui/fixed.vue';
</script>
<style lang="less" scoped>
+18 -6
View File
@@ -14,18 +14,22 @@
"同时每次增加新内容时都会有提示。",
"<br>",
"<br>",
"3. 本塔中<span style=\"color: gold\">几乎所有 ui </span>都可以纵向滚动,如果发现显示不全,",
"3. 背包中的系统设置同样非常重要,有些问题可以在那里找到原因。例如当你获得技能时可能会发现开启不了技能,",
"就是因为你打开了自动切换技能的功能,在系统设置里面有说。",
"<br>",
"<br>",
"4. 本塔中<span style=\"color: gold\">几乎所有 ui </span>都可以纵向滚动,如果发现显示不全,",
"可以尝试上下拖动,就像浏览网页一样。电脑端还可以使用滚轮上下滚动。",
"大部分可以纵向滚动的 ui 都会在右方有一个滚动条,也可以拖动它进行滚动,例如本百科全书的条目列表和",
"条目说明都是可以通过上述方式滚动的。",
"<br>",
"<br>",
"4. 本塔主要面向电脑端设计,",
"5. 本塔主要面向电脑端设计,",
"<span style=\"color: gold\">建议使用电脑游玩以获得更好的游戏体验</span>。但是手机依然可以游玩本塔,",
"但部分操作可能不是很方便,ui 也可能不是很美观,不过依然可以完整体验本游戏。",
"<br>",
"<br>",
"5. 对于手机端,可以点击<span style=\"color: gold\">右下角的难度文字</span>来切换工具栏至数字键。",
"6. 对于手机端,可以点击<span style=\"color: gold\">右下角的难度文字</span>来切换工具栏至数字键。",
"这样,你可以更加方便地进行使用技能等操作。",
"<br>",
"<br>",
@@ -135,6 +139,7 @@
"condition": "true",
"desc": [
"这里包含本塔中所有的快捷键。对于手机端,可以点击工具栏的难度的位置切换工具栏至数字键。",
"下面会分为样板快捷键和本塔快捷键两类。",
"<br>",
"<br>",
"下面是样板中的所有快捷键:",
@@ -176,13 +181,15 @@
"<span style=\"color: gold\">P</span>:打开评论区",
"<br>",
"<br>",
"下面是本塔中新增的快捷键:",
"下面是本塔中新增的快捷键(不包括技能,技能快捷键请在查看技能界面中查看):",
"<br>",
"<span style=\"color: gold\">M</span>:快速标记怪物",
"<br>",
"<span style=\"color: gold\">J</span>:打开技能树",
"<br>",
"<span style=\"color: gold\">H</span>:打开百科全书"
"<span style=\"color: gold\">H</span>:打开百科全书",
"<br>",
"<span style=\"color: gold\">K</span>:查看鼠标位置怪物的详细信息"
]
},
"extraAttr": {
@@ -476,7 +483,12 @@
"该特技会撞碎路上的所有地形和门,不需要消耗钥匙,拾取路上的所有道具,与路上的怪物战斗,最后与该怪物战斗。",
"如果怪物所在位置可以被嘲讽,那么勇士会被继续嘲讽。如果在被嘲讽的路上可以被其他怪物嘲讽,则不会触发。",
"如果一个点可以被多个怪物嘲讽,那么会优先选择最靠左上角的怪物。",
"<span style=\"color: gold\">在被嘲讽之前会自动存档。</span>"
"<span style=\"color: gold\">在被嘲讽之前会自动存档。</span>",
"<br>",
"<br>",
"<span style=\"color: #d8a\">2. 永夜</span>、<span style=\"color: #ffd\">极昼</span>:",
"战斗后会在本楼层中加减怪物与勇士的攻防,每个楼层会单独存储。例如你在1楼层增加了100点攻击,2楼层减少了100点攻击,",
"那么当你从2楼层到1楼层时,攻击会增加200点,反之亦然。注意这里没有计算buff。"
]
}
}
+9
View File
@@ -34,6 +34,15 @@
"text": "展示范围光环",
"desc": ["开启后,会在地图上显示范围光环。"]
},
"useFixed": {
"text": "移动鼠标显示怪物信息",
"desc": [
"开启后,当鼠标移动到怪物上时,会以盒子的形式展示该点的怪物信息。",
"<br>",
"<br>",
"注:当鼠标移动到怪物上时,经过200毫秒才会显示信息,防止误操作。"
]
},
"showStudied": {
"text": "展示已学习技能",
"desc": [
+3 -1
View File
@@ -10,6 +10,7 @@ import setting from './plugin/settings';
import chapter from './plugin/ui/chapter';
import fly from './plugin/ui/fly';
import chase from './plugin/chase/chase';
import fixed from './plugin/ui/fixed';
function forward() {
// 每个引入的插件都要在这里执行,否则不会被转发
@@ -24,7 +25,8 @@ function forward() {
setting(),
chapter(),
fly(),
chase()
chase(),
fixed()
];
// 初始化所有插件,并转发到core上
+2 -2
View File
@@ -117,8 +117,8 @@ const ratio = core.status.thisMap.ratio;
const nowDamage = computed(() => {
const dam = core.getDamageInfo(enemy, {
atk: core.status.hero.atk + addAtk.value * ratio,
def: core.status.hero.def + addDef.value * ratio
atk: core.getStatus('atk') + addAtk.value * ratio,
def: core.getStatus('def') + addDef.value * ratio
});
if (!has(dam)) return ['???', '???'];
if (!has(originDamage)) return [-dam.damage, dam.damage];
+9
View File
@@ -30,6 +30,11 @@ export const showHalo = ref(true);
*/
export const showStudied = ref(true);
/**
* 是否使用定点查看功能
*/
export const useFixed = ref(true);
watch(transition, n => {
core.plugin.transition.value = n;
core.setLocalStorage('transition', n);
@@ -58,6 +63,10 @@ watch(showHalo, n => {
core.setLocalStorage('showHalo', n);
});
watch(useFixed, n => {
core.setLocalStorage('useFixed', n);
});
/**
* 重置设置信息,从localStorage读取即可
*/
+4 -4
View File
@@ -60,8 +60,8 @@ export function getDefDamage(
for (let i = 0; i <= max; i++) {
const dam = core.getDamageInfo(enemy.id, {
def: core.status.hero.def + ratio * i + addDef,
atk: core.status.hero.atk + addAtk
def: core.getStatus('def') + ratio * i + addDef,
atk: core.getStatus('atk') + addAtk
});
if (res.length === 0) {
@@ -100,8 +100,8 @@ export function getCriticalDamage(
for (let i = 0; i <= max; i++) {
const dam = core.getDamageInfo(enemy.id, {
atk: core.status.hero.atk + ratio * i + addAtk,
def: core.status.hero.def + addDef
atk: core.getStatus('atk') + ratio * i + addAtk,
def: core.getStatus('def') + addDef
});
if (res.length === 0) {
+64
View File
@@ -0,0 +1,64 @@
import { cloneDeep, debounce } from 'lodash';
import { ref } from 'vue';
import { getDamageColor } from '../utils';
export const showFixed = ref(false);
const show = debounce((ev: MouseEvent) => {
if (!window.flags) return;
if (!flags.mouseLoc) return;
flags.clientLoc = [ev.clientX, ev.clientY];
const [x, y] = flags.mouseLoc;
const e = core.getBlockId(x, y);
if (!e || !core.getClsFromId(e)?.startsWith('enemy')) return;
const enemy = core.material.enemys[e as EnemyIds];
const detail = getDetailedEnemy(enemy, x, y);
core.plugin.bookDetailEnemy = detail;
showFixed.value = true;
}, 200);
export default function init() {
const data = core.canvas.data.canvas;
data.addEventListener('mousemove', ev => {
showFixed.value = false;
show(ev);
});
}
export function getDetailedEnemy<I extends EnemyIds>(
enemy: Enemy<I>,
x: number,
y: number,
floorId: FloorIds = core.status.floorId
): DetailedEnemy<I> {
const ratio = core.status.maps[floorId].ratio;
const enemyInfo = Object.assign(
core.getEnemyInfo(enemy, void 0, x, y),
core.getDamageInfo(enemy, void 0, x, y) ?? {},
enemy
);
const critical = core.nextCriticals(enemy, 1, x, y);
const defDamage = core.getDefDamage(enemy, ratio, x, y);
const specialText = core.getSpecialText(enemyInfo);
let toShowSpecial = cloneDeep(specialText);
if (toShowSpecial.length > 2) {
toShowSpecial = toShowSpecial.slice(0, 2).concat(['...']);
}
const specialColor = core.getSpecialColor(enemyInfo);
let toShowColor = cloneDeep(specialColor);
if (toShowColor.length > 2) {
toShowColor = toShowColor.slice(0, 2).concat(['#fff']);
}
const damageColor = getDamageColor(enemyInfo.damage);
const detail: DetailedEnemy<I> = Object.assign(enemyInfo, {
critical: critical[0][0],
criticalDamage: critical[0][1],
defDamage,
specialColor,
specialText,
toShowColor,
toShowSpecial,
damageColor
});
return detail;
}
+5
View File
@@ -1372,6 +1372,11 @@ interface Flags {
*/
mouseLoc: LocArr;
/**
* 鼠标的像素位置
*/
clientLoc: LocArr;
[key: string]: any;
}
+157
View File
@@ -0,0 +1,157 @@
<template>
<div id="fixed">
<Transition>
<Box
v-if="showFixed"
v-model:height="height"
v-model:left="left"
v-model:top="top"
v-model:width="width"
>
<div id="enemy-fixed">
<span id="enemy-name">{{ enemy.name }}</span>
<div id="enemy-special">
<span
v-for="(text, i) of enemy.toShowSpecial"
:style="{color: (enemy.toShowColor[i] as string)} "
>{{ text }}</span
>
</div>
<div class="enemy-attr" v-for="(a, i) of toShowAttrs">
<span
class="attr-name"
:style="{ color: attrColor[i] }"
>{{ getLabel(a) }}</span
>
<span
class="attr-value"
:style="{ color: attrColor[i] }"
>{{ enemy[a] }}</span
>
</div>
</div>
</Box>
</Transition>
</div>
</template>
<script lang="ts" setup>
import { onMounted, onUpdated, ref, watch } from 'vue';
import Box from '../components/box.vue';
import { showFixed } from '../plugin/ui/fixed';
watch(showFixed, calHeight);
let main: HTMLDivElement;
const toShowAttrs: (keyof DetailedEnemy)[] = [
'hp',
'atk',
'def',
'money',
'exp',
'critical',
'criticalDamage',
'defDamage'
];
const attrColor = [
'lightgreen',
'lightcoral',
'lightblue',
'lightyellow',
'lawngreen',
'lightsalmon',
'lightpink',
'cyan'
];
const enemy = ref(core.plugin.bookDetailEnemy);
const left = ref(0);
const top = ref(0);
const width = ref(300);
const height = ref(400);
let vh = window.innerHeight;
let vw = window.innerWidth;
async function calHeight() {
enemy.value = core.plugin.bookDetailEnemy;
vh = window.innerHeight;
vw = window.innerWidth;
width.value = vh * 0.28;
await new Promise(res => requestAnimationFrame(res));
main = document.getElementById('enemy-fixed') as HTMLDivElement;
const style = getComputedStyle(main);
const h = parseFloat(style.height);
const [cx, cy] = flags.clientLoc;
if (cy + h + 10 > vh - 10) top.value = vh - h - 10;
else top.value = cy + 10;
if (cx + width.value + 10 > vw - 10) left.value = vw - width.value - 10;
else left.value = cx + 10;
height.value = h;
}
function getLabel(attr: keyof DetailedEnemy) {
if (attr === 'critical') return '临界';
if (attr === 'criticalDamage') return '临界减伤';
if (attr === 'defDamage') return `${core.status.thisMap.ratio}防`;
return core.getStatusLabel(attr);
}
onUpdated(calHeight);
onMounted(() => {
main = document.getElementById('enemy-fixed') as HTMLDivElement;
calHeight();
});
</script>
<style lang="less" scoped>
#fixed {
font-family: 'normal';
font-size: 2.5vh;
}
.v-enter-active,
.v-leave-active {
transition: opacity 0.2s linear;
}
.v-enter-from,
.v-leave-to {
opacity: 0;
}
#enemy-fixed {
display: flex;
flex-direction: column;
align-items: center;
background-color: #000c;
padding: 1vh;
}
#enemy-special {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-around;
}
.enemy-attr {
display: flex;
flex-direction: row;
width: 100%;
}
.attr-name {
flex-basis: 50%;
width: 100%;
text-align: right;
padding-right: 5%;
}
.attr-value {
flex-basis: 50%;
padding-left: 5%;
}
</style>
+3 -3
View File
@@ -97,7 +97,7 @@ const nowArea = ref(
Object.keys(area).find(v => area[v].includes(core.status.floorId))!
);
const nowFloor = ref(core.status.floorId);
const noBorder = ref(false);
const noBorder = ref(true);
const tradition = ref(false);
let scale = isMobile ? 1.5 : 3;
let ox = 0;
@@ -105,8 +105,8 @@ let oy = 0;
let drawedThumbnail: Partial<Record<FloorIds, boolean>> = {};
let thumbnailLoc: Partial<Record<FloorIds, Loc2>> = {};
noBorder.value = core.getLocalStorage('noBorder') ?? false;
tradition.value = core.getLocalStorage('flyTradition') ?? false;
noBorder.value = core.getLocalStorage('noBorder', true);
tradition.value = core.getLocalStorage('flyTradition', false);
const floor = computed(() => {
return core.status.maps[nowFloor.value];
+14 -1
View File
@@ -42,6 +42,14 @@
showHalo ? 'ON' : 'OFF'
}}</span
>
<span
class="selectable"
:selected="selected === 'useFixed'"
@click="click('useFixed')"
>移动鼠标显示怪物信息:&nbsp;&nbsp;&nbsp;{{
useFixed ? 'ON' : 'OFF'
}}</span
>
<span
class="selectable"
:selected="selected === 'showStudied'"
@@ -65,7 +73,8 @@ import {
autoSkill,
autoScale,
showStudied,
showHalo
showHalo,
useFixed
} from '../plugin/settings';
import settingInfo from '../data/settings.json';
import { has, splitText } from '../plugin/utils';
@@ -100,6 +109,10 @@ function click(id: keyof Settings) {
autoScale.value = !autoScale.value;
} else if (id === 'showHalo') {
showHalo.value = !showHalo.value;
} else if (id === 'showStudied') {
showStudied.value = !showStudied.value;
} else if (id === 'useFixed') {
useFixed.value = !useFixed.value;
}
}
</script>