Compare commits

..

No commits in common. "99432d4fd3af3c8fca0fb6e29925690f5a8f27ed" and "5fdeee045dfe41623f4d7f88414cdee820ad72d7" have entirely different histories.

8 changed files with 58 additions and 101 deletions

View File

@ -73,36 +73,18 @@ 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 loc={loc} onClick={() => select(key)}> <container onClick={() => select(key)}>
{selected.value === key && ( {selected.value === key && (
<Selection <Selection
loc={selectionLoc} loc={loc}
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 text={value} font={props.font} />
loc={textLoc}
text={value}
font={props.font}
/>
</container> </container>
); );
})} })}
@ -121,8 +103,6 @@ export interface ListPageProps extends ListProps {
right?: boolean; right?: boolean;
/** 是否显示关闭按钮 */ /** 是否显示关闭按钮 */
close?: boolean; close?: boolean;
/** 关闭按钮的位置,相对于组件定位 */
closeLoc?: ElementLocator;
} }
export type ListPageEmits = { export type ListPageEmits = {
@ -147,9 +127,7 @@ 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<
@ -193,7 +171,7 @@ export const ListPage = defineComponent<
}; };
return () => ( return () => (
<container loc={props.loc}> <container>
<List <List
{...props} {...props}
loc={listLoc.value} loc={listLoc.value}
@ -206,12 +184,7 @@ export const ListPage = defineComponent<
slots.default?.(selected.value)} slots.default?.(selected.value)}
</container> </container>
{props.close && ( {props.close && (
<text <text text="关闭" cursor="pointer" font={props.font}></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', 'width'], props: ['promise', 'loc', 'winskin', 'color', 'border'],
emits: ['resolve'] emits: ['resolve']
} satisfies SetupComponentOptions< } satisfies SetupComponentOptions<
WaitBoxProps<unknown>, WaitBoxProps<unknown>,

View File

@ -180,7 +180,6 @@ 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,8 +209,7 @@ const MainScene = defineComponent(() => {
)} )}
<container <container
loc={[0, 0, MAIN_WIDTH, MAIN_HEIGHT]} loc={[0, 0, MAIN_WIDTH, MAIN_HEIGHT]}
hidden={!mainUIController.active.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', 'controller', 'instance'] props: ['data']
} satisfies SetupComponentOptions<StatisticsProps>; } satisfies SetupComponentOptions<StatisticsProps>;
export const Statistics = defineComponent<StatisticsProps>(props => { export const Statistics = defineComponent<StatisticsProps>(props => {
@ -52,8 +52,6 @@ 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} />,
@ -69,29 +67,21 @@ 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 () => ( return () => <container></container>;
<container> }, statisticsProps);
<text text="测试"></text>
</container>
);
}, statisticsPanelProps);
const FloorStatistics = defineComponent<StatisticsPanelProps>(props => { const FloorStatistics = defineComponent<StatisticsPanelProps>(props => {
return () => <container></container>; return () => <container></container>;
}, statisticsPanelProps); }, statisticsProps);
const EnemyStatistics = defineComponent<StatisticsPanelProps>(props => { const EnemyStatistics = defineComponent<StatisticsPanelProps>(props => {
return () => <container></container>; return () => <container></container>;
}, statisticsPanelProps); }, statisticsProps);
const PotionStatistics = defineComponent<StatisticsPanelProps>(props => { const PotionStatistics = defineComponent<StatisticsPanelProps>(props => {
return () => <container></container>; return () => <container></container>;
}, statisticsPanelProps); }, statisticsProps);
function calculateStatistics(): StatisticsData { function calculateStatistics(): StatisticsData {
core.setFlag('__statistics__', true); core.setFlag('__statistics__', true);
@ -195,7 +185,7 @@ export async function openStatistics(controller: IUIMountable) {
}); });
const data = await waitbox( const data = await waitbox(
controller, controller,
[240 + 180, 240, void 0, void 0, 0.5, 0.5], [240 + 180, void 0, void 0, 240, 0.5, 0.5],
240, 240,
cal, cal,
{ {

View File

@ -1,4 +1,3 @@
import { debounce } from 'lodash-es';
import logInfo from './logger.json'; import logInfo from './logger.json';
export const enum LogLevel { export const enum LogLevel {
@ -21,28 +20,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');
@ -108,8 +107,7 @@ 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,
@ -118,15 +116,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 = `${location.origin}/_docs/logger/error/error${n}.html#error-code-${n2}`; const url = `/_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}`);
} }
} }
@ -142,8 +140,7 @@ export class Logger {
logger.error(16, 'warn', code.toString()); logger.error(16, 'warn', code.toString());
return; return;
} }
const text = this.parseInfo(info, ...params); const text = this.parseInfo(info[code], ...params);
if (this.catching) { if (this.catching) {
this.catchedInfo.push({ this.catchedInfo.push({
level: LogLevel.ERROR, level: LogLevel.ERROR,
@ -152,15 +149,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 = `${location.origin}/_docs/logger/warn/warn${n}.html#warn-code-${n2}`; const url = `/_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,8 +98,11 @@ 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 是否激活 */
readonly active: Ref<boolean> = ref(false); /** 当前是否显示 UI */
get active() {
return this.sysShowBack.value;
}
/** 自定义显示模式下的配置信息 */ /** 自定义显示模式下的配置信息 */
private config?: IUICustomConfig; private config?: IUICustomConfig;
@ -191,8 +194,6 @@ 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;
} }
@ -228,9 +229,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.active.value = false;
} }
this.keepBack = false; this.keepBack = false;
this.emit('close', ui); this.emit('close', ui);
} }