fix: 统计数据

This commit is contained in:
unanmed 2025-05-27 20:54:36 +08:00
parent 12c289d06a
commit 5ddeed6d19
5 changed files with 43 additions and 13 deletions

View File

@ -73,18 +73,36 @@ export const List = defineComponent<ListProps, ListEmits, keyof ListEmits>(
props.loc[2] ?? 200, props.loc[2] ?? 200,
lineHeight.value lineHeight.value
]; ];
const selectionLoc: ElementLocator = [
0,
0,
(props.loc[2] ?? 200) - 10,
lineHeight.value
];
const textLoc: ElementLocator = [
10,
lineHeight.value / 2,
void 0,
void 0,
0,
0.5
];
return ( return (
<container onClick={() => select(key)}> <container loc={loc} onClick={() => select(key)}>
{selected.value === key && ( {selected.value === key && (
<Selection <Selection
loc={loc} loc={selectionLoc}
color={props.color} color={props.color}
border={props.border} border={props.border}
winskin={props.winskin} winskin={props.winskin}
alphaRange={props.alphaRange} alphaRange={props.alphaRange}
/> />
)} )}
<text text={value} font={props.font} /> <text
loc={textLoc}
text={value}
font={props.font}
/>
</container> </container>
); );
})} })}
@ -171,7 +189,7 @@ export const ListPage = defineComponent<
}; };
return () => ( return () => (
<container> <container loc={props.loc}>
<List <List
{...props} {...props}
loc={listLoc.value} loc={listLoc.value}

View File

@ -1,7 +1,7 @@
import { LayerShadowExtends } from '@motajs/legacy-ui'; import { LayerShadowExtends } from '@motajs/legacy-ui';
import { Props, Font } from '@motajs/render'; import { Props, Font } from '@motajs/render';
import { WeatherController } from '../../weather'; import { WeatherController } from '../../weather';
import { defineComponent, onMounted, reactive, ref } from 'vue'; import { defineComponent, onMounted, reactive, ref, watch } from 'vue';
import { Textbox, Tip } from '../components'; import { Textbox, Tip } from '../components';
import { GameUI } from '@motajs/system-ui'; import { GameUI } from '@motajs/system-ui';
import { import {
@ -209,7 +209,8 @@ const MainScene = defineComponent(() => {
)} )}
<container <container
loc={[0, 0, MAIN_WIDTH, MAIN_HEIGHT]} loc={[0, 0, MAIN_WIDTH, MAIN_HEIGHT]}
hidden={mainUIController.showBack.value} hidden={!mainUIController.showBack.value}
zIndex={200}
> >
{mainUIController.render()} {mainUIController.render()}
</container> </container>

View File

@ -30,7 +30,7 @@ export interface StatisticsProps extends UIComponentProps, DefaultProps {
} }
const statisticsProps = { const statisticsProps = {
props: ['data'] props: ['data', 'controller', 'instance']
} satisfies SetupComponentOptions<StatisticsProps>; } satisfies SetupComponentOptions<StatisticsProps>;
export const Statistics = defineComponent<StatisticsProps>(props => { export const Statistics = defineComponent<StatisticsProps>(props => {
@ -52,6 +52,7 @@ export const Statistics = defineComponent<StatisticsProps>(props => {
loc={[180, 0, 480, 480]} loc={[180, 0, 480, 480]}
close close
onClose={close} onClose={close}
lineHeight={24}
> >
{{ {{
total: () => <TotalStatistics data={props.data} />, total: () => <TotalStatistics data={props.data} />,
@ -67,21 +68,29 @@ interface StatisticsPanelProps extends DefaultProps {
data: StatisticsData; data: StatisticsData;
} }
const statisticsPanelProps = {
props: ['data']
} satisfies SetupComponentOptions<StatisticsPanelProps>;
const TotalStatistics = defineComponent<StatisticsPanelProps>(props => { const TotalStatistics = defineComponent<StatisticsPanelProps>(props => {
return () => <container></container>; return () => (
}, statisticsProps); <container>
<text text="测试"></text>
</container>
);
}, statisticsPanelProps);
const FloorStatistics = defineComponent<StatisticsPanelProps>(props => { const FloorStatistics = defineComponent<StatisticsPanelProps>(props => {
return () => <container></container>; return () => <container></container>;
}, statisticsProps); }, statisticsPanelProps);
const EnemyStatistics = defineComponent<StatisticsPanelProps>(props => { const EnemyStatistics = defineComponent<StatisticsPanelProps>(props => {
return () => <container></container>; return () => <container></container>;
}, statisticsProps); }, statisticsPanelProps);
const PotionStatistics = defineComponent<StatisticsPanelProps>(props => { const PotionStatistics = defineComponent<StatisticsPanelProps>(props => {
return () => <container></container>; return () => <container></container>;
}, statisticsProps); }, statisticsPanelProps);
function calculateStatistics(): StatisticsData { function calculateStatistics(): StatisticsData {
core.setFlag('__statistics__', true); core.setFlag('__statistics__', true);

View File

@ -125,7 +125,7 @@ export class Hotkey extends EventEmitter<HotkeyEvent> {
}; };
this.ensureMap(d.key); this.ensureMap(d.key);
if (d.id in this.data) { if (d.id in this.data) {
console.warn(`已存在id为${d.id}的按键,已将其覆盖`); // console.warn(`已存在id为${d.id}的按键,已将其覆盖`);
} }
this.data[d.id] = d; this.data[d.id] = d;
const arr = this.keyMap.get(d.key)!; const arr = this.keyMap.get(d.key)!;

View File

@ -194,6 +194,7 @@ export class UIController
break; break;
} }
this.sysShowBack.value = true; this.sysShowBack.value = true;
this.emit('open', ui, ins); this.emit('open', ui, ins);
return ins; return ins;
} }
@ -230,6 +231,7 @@ export class UIController
if (!this.keepBack && this.stack.length === 0) { if (!this.keepBack && this.stack.length === 0) {
this.sysShowBack.value = false; this.sysShowBack.value = false;
} }
this.keepBack = false; this.keepBack = false;
this.emit('close', ui); this.emit('close', ui);
} }