Compare commits

...

7 Commits

Author SHA1 Message Date
99432d4fd3 fix: ListPage 的关闭按钮 2025-05-27 21:12:19 +08:00
dd0f596e21 feat: ui 控制器添加 active 用于控制是否显示 2025-05-27 21:04:54 +08:00
046d136b5a chore: 删除未使用引入 2025-05-27 20:55:50 +08:00
5ddeed6d19 fix: 统计数据 2025-05-27 20:54:36 +08:00
12c289d06a fix: logger 2025-05-27 20:26:35 +08:00
6a7b58cb5e chore: 删除一个 log 2025-05-27 15:56:00 +08:00
7d94f6026c fix: 按 B 报错 2025-05-27 15:51:08 +08:00
8 changed files with 101 additions and 58 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>
); );
})} })}
@ -103,6 +121,8 @@ export interface ListPageProps extends ListProps {
right?: boolean; right?: boolean;
/** 是否显示关闭按钮 */ /** 是否显示关闭按钮 */
close?: boolean; close?: boolean;
/** 关闭按钮的位置,相对于组件定位 */
closeLoc?: ElementLocator;
} }
export type ListPageEmits = { export type ListPageEmits = {
@ -127,7 +147,9 @@ const listPageProps = {
'winskin', 'winskin',
'color', 'color',
'border', 'border',
'alphaRange' 'alphaRange',
'close',
'closeLoc'
], ],
emits: ['update', 'update:selected', 'close'] emits: ['update', 'update:selected', 'close']
} satisfies SetupComponentOptions< } satisfies SetupComponentOptions<
@ -171,7 +193,7 @@ export const ListPage = defineComponent<
}; };
return () => ( return () => (
<container> <container loc={props.loc}>
<List <List
{...props} {...props}
loc={listLoc.value} loc={listLoc.value}
@ -184,7 +206,12 @@ export const ListPage = defineComponent<
slots.default?.(selected.value)} slots.default?.(selected.value)}
</container> </container>
{props.close && ( {props.close && (
<text text="关闭" cursor="pointer" font={props.font}></text> <text
loc={props.closeLoc}
text="关闭"
cursor="pointer"
font={props.font}
></text>
)} )}
</container> </container>
); );

View File

@ -431,7 +431,7 @@ export interface WaitBoxExpose<T> {
} }
const waitBoxProps = { const waitBoxProps = {
props: ['promise', 'loc', 'winskin', 'color', 'border'], props: ['promise', 'loc', 'winskin', 'color', 'border', 'width'],
emits: ['resolve'] emits: ['resolve']
} satisfies SetupComponentOptions< } satisfies SetupComponentOptions<
WaitBoxProps<unknown>, WaitBoxProps<unknown>,

View File

@ -180,6 +180,7 @@ export class Winskin extends RenderItem<EWinskinEvent> {
private generatePattern() { private generatePattern() {
const pattern = this.requireCanvas(); const pattern = this.requireCanvas();
pattern.setScale(1);
const img = this.image; const img = this.image;
pattern.size(32, 16); pattern.size(32, 16);
pattern.setHD(false); pattern.setHD(false);

View File

@ -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.active.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,8 @@ export const Statistics = defineComponent<StatisticsProps>(props => {
loc={[180, 0, 480, 480]} loc={[180, 0, 480, 480]}
close close
onClose={close} onClose={close}
lineHeight={24}
closeLoc={[10, 470, void 0, void 0, 0, 1]}
> >
{{ {{
total: () => <TotalStatistics data={props.data} />, total: () => <TotalStatistics data={props.data} />,
@ -67,21 +69,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);
@ -185,7 +195,7 @@ export async function openStatistics(controller: IUIMountable) {
}); });
const data = await waitbox( const data = await waitbox(
controller, controller,
[240 + 180, void 0, void 0, 240, 0.5, 0.5], [240 + 180, 240, void 0, void 0, 0.5, 0.5],
240, 240,
cal, cal,
{ {

View File

@ -1,3 +1,4 @@
import { debounce } from 'lodash-es';
import logInfo from './logger.json'; import logInfo from './logger.json';
export const enum LogLevel { export const enum LogLevel {
@ -20,28 +21,28 @@ interface LoggerCatchReturns<T> {
info: LoggerCatchInfo[]; info: LoggerCatchInfo[];
} }
// let logTip: HTMLSpanElement; let logTip: HTMLSpanElement;
// if (!main.replayChecking) { if (!main.replayChecking) {
// const tip = document.createElement('span'); const tip = document.createElement('span');
// logTip = tip; logTip = tip;
// tip.style.position = 'fixed'; tip.style.position = 'fixed';
// tip.style.right = '0'; tip.style.right = '0';
// tip.style.bottom = '0'; tip.style.bottom = '0';
// tip.style.height = '20px'; tip.style.height = '20px';
// tip.style.width = 'auto'; tip.style.width = 'auto';
// tip.style.textAlign = 'right'; tip.style.textAlign = 'right';
// tip.style.padding = '0 5px'; tip.style.padding = '0 5px';
// tip.style.fontSize = '16px'; tip.style.fontSize = '16px';
// tip.style.fontFamily = 'Arial'; tip.style.fontFamily = 'Arial';
// tip.style.display = 'none'; tip.style.display = 'none';
// tip.style.margin = '2px'; tip.style.margin = '2px';
// document.body.appendChild(tip); document.body.appendChild(tip);
// } }
// const hideTipText = debounce(() => { const hideTipText = debounce(() => {
// if (main.replayChecking) return; if (main.replayChecking) return;
// logTip.style.display = 'none'; logTip.style.display = 'none';
// }, 5000); }, 5000);
const nums = new Set('1234567890'); const nums = new Set('1234567890');
@ -107,7 +108,8 @@ export class Logger {
logger.error(16, 'error', code.toString()); logger.error(16, 'error', code.toString());
return; return;
} }
const text = this.parseInfo(info[code], ...params);
const text = this.parseInfo(info, ...params);
if (this.catching) { if (this.catching) {
this.catchedInfo.push({ this.catchedInfo.push({
level: LogLevel.ERROR, level: LogLevel.ERROR,
@ -116,15 +118,15 @@ export class Logger {
}); });
} }
if (this.level <= LogLevel.ERROR && this.enabled) { if (this.level <= LogLevel.ERROR && this.enabled) {
// if (!main.replayChecking) { if (!main.replayChecking) {
// logTip.style.color = 'lightcoral'; logTip.style.color = 'lightcoral';
// logTip.style.display = 'block'; logTip.style.display = 'block';
// logTip.textContent = `Error thrown, please check in console.`; logTip.textContent = `Error thrown, please check in console.`;
// hideTipText(); hideTipText();
// } }
const n = Math.floor(code / 50) + 1; const n = Math.floor(code / 50) + 1;
const n2 = code % 50; const n2 = code % 50;
const url = `/_docs/logger/error/error${n}.html#error-code-${n2}`; const url = `${location.origin}/_docs/logger/error/error${n}.html#error-code-${n2}`;
console.error(`[ERROR Code ${code}] ${text}. See ${url}`); console.error(`[ERROR Code ${code}] ${text}. See ${url}`);
} }
} }
@ -140,7 +142,8 @@ export class Logger {
logger.error(16, 'warn', code.toString()); logger.error(16, 'warn', code.toString());
return; return;
} }
const text = this.parseInfo(info[code], ...params); const text = this.parseInfo(info, ...params);
if (this.catching) { if (this.catching) {
this.catchedInfo.push({ this.catchedInfo.push({
level: LogLevel.ERROR, level: LogLevel.ERROR,
@ -149,15 +152,15 @@ export class Logger {
}); });
} }
if (this.level <= LogLevel.WARNING && this.enabled) { if (this.level <= LogLevel.WARNING && this.enabled) {
// if (!main.replayChecking) { if (!main.replayChecking) {
// logTip.style.color = 'gold'; logTip.style.color = 'gold';
// logTip.style.display = 'block'; logTip.style.display = 'block';
// logTip.textContent = `Warning thrown, please check in console.`; logTip.textContent = `Warning thrown, please check in console.`;
// hideTipText(); hideTipText();
// } }
const n = Math.floor(code / 50) + 1; const n = Math.floor(code / 50) + 1;
const n2 = code % 50; const n2 = code % 50;
const url = `/_docs/logger/warn/warn${n}.html#warn-code-${n2}`; const url = `${location.origin}/_docs/logger/warn/warn${n}.html#warn-code-${n2}`;
console.warn(`[WARNING Code ${code}] ${text}. See ${url}`); console.warn(`[WARNING Code ${code}] ${text}. See ${url}`);
} }
} }

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

@ -98,11 +98,8 @@ export class UIController
readonly showBack: ComputedRef<boolean> = computed( readonly showBack: ComputedRef<boolean> = computed(
() => this.userShowBack.value && this.sysShowBack.value () => this.userShowBack.value && this.sysShowBack.value
); );
/** 当前 UI 是否激活 */
/** 当前是否显示 UI */ readonly active: Ref<boolean> = ref(false);
get active() {
return this.sysShowBack.value;
}
/** 自定义显示模式下的配置信息 */ /** 自定义显示模式下的配置信息 */
private config?: IUICustomConfig; private config?: IUICustomConfig;
@ -194,6 +191,8 @@ export class UIController
break; break;
} }
this.sysShowBack.value = true; this.sysShowBack.value = true;
this.active.value = true;
this.emit('open', ui, ins); this.emit('open', ui, ins);
return ins; return ins;
} }
@ -229,7 +228,9 @@ 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.active.value = false;
} }
this.keepBack = false; this.keepBack = false;
this.emit('close', ui); this.emit('close', ui);
} }