mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-06-14 20:48:00 +08:00
feat: 存档界面接口
This commit is contained in:
parent
99432d4fd3
commit
da05785694
@ -45,7 +45,7 @@ function error(code: number, ...params: string[]): void;
|
||||
#### 行为
|
||||
|
||||
- 如果未找到对应 `code` 的错误信息,会触发 `error(16)` 表示代码未定义。
|
||||
- 根据日志级别 `level` 决定是否输出到控制台,并在页面右下角显示提示。
|
||||
- 根据日志级别 `level` 决定是否输出到控制台
|
||||
|
||||
### `warn`
|
||||
|
||||
@ -79,7 +79,9 @@ function log(text: string): void;
|
||||
|
||||
#### 参数
|
||||
|
||||
`text`: 日志文本内容。 ####行为
|
||||
`text`: 日志文本内容。
|
||||
|
||||
#### 行为
|
||||
|
||||
- 仅在 `level <= LogLevel.LOG` 时输出到控制台。
|
||||
|
||||
@ -181,7 +183,6 @@ const logger = new Logger(LogLevel.WARNING, logInfo);
|
||||
```ts
|
||||
logger.error(404, 'home');
|
||||
// 控制台输出: [ERROR Code 404] Page home not found.
|
||||
// 页面右下角显示红色提示(5 秒后消失)
|
||||
```
|
||||
|
||||
- 记录警告
|
||||
@ -189,7 +190,6 @@ logger.error(404, 'home');
|
||||
```ts
|
||||
logger.warn(101, '/old-api');
|
||||
// 控制台输出: [WARNING Code 101] Deprecated API: /old-api
|
||||
// 页面右下角显示金色提示
|
||||
```
|
||||
|
||||
- 捕获日志
|
||||
|
@ -2,10 +2,9 @@ import { DefaultProps, ElementLocator, Font } from '@motajs/render';
|
||||
import { computed, defineComponent, reactive, ref } from 'vue';
|
||||
import { Background, Selection } from './misc';
|
||||
import { TextContent, TextContentExpose, TextContentProps } from './textbox';
|
||||
import { SetupComponentOptions } from './types';
|
||||
import { TextAlign } from './textboxTyper';
|
||||
import { Page, PageExpose } from './page';
|
||||
import { GameUI, IUIMountable } from '@motajs/system-ui';
|
||||
import { GameUI, IUIMountable, SetupComponentOptions } from '@motajs/system-ui';
|
||||
import { useKey } from '../use';
|
||||
|
||||
export interface ConfirmBoxProps extends DefaultProps, TextContentProps {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { DefaultProps, ElementLocator, GraphicPropsBase } from '@motajs/render';
|
||||
import { SetupComponentOptions } from '@motajs/system-ui';
|
||||
import { computed, defineComponent, onMounted, Ref, ref, watch } from 'vue';
|
||||
import { SetupComponentOptions } from './types';
|
||||
|
||||
export interface IconsProps extends DefaultProps<GraphicPropsBase> {
|
||||
loc: ElementLocator;
|
||||
|
@ -6,4 +6,3 @@ export * from './scroll';
|
||||
export * from './textbox';
|
||||
export * from './textboxTyper';
|
||||
export * from './tip';
|
||||
export * from './types';
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { DefaultProps } from '@motajs/render-vue';
|
||||
import { computed, defineComponent, onUnmounted, ref, watch } from 'vue';
|
||||
import { TextContent, TextContentProps } from './textbox';
|
||||
import { SetupComponentOptions } from './types';
|
||||
import { RectRCircleParams } from '@motajs/render-elements';
|
||||
import {
|
||||
Container,
|
||||
@ -14,7 +13,7 @@ import { Font } from '@motajs/render-style';
|
||||
import { transitionedColor } from '../use';
|
||||
import { linear } from 'mutate-animate';
|
||||
import { Background, Selection } from './misc';
|
||||
import { GameUI, IUIMountable } from '@motajs/system-ui';
|
||||
import { GameUI, IUIMountable, SetupComponentOptions } from '@motajs/system-ui';
|
||||
|
||||
export interface InputProps extends DefaultProps, Partial<TextContentProps> {
|
||||
/** 输入框的提示内容 */
|
||||
|
@ -6,14 +6,13 @@ import {
|
||||
Sprite
|
||||
} from '@motajs/render';
|
||||
import { computed, defineComponent, ref, SetupContext, watch } from 'vue';
|
||||
import { SetupComponentOptions } from './types';
|
||||
import { MotaOffscreenCanvas2D } from '@motajs/render';
|
||||
import { TextContent, TextContentProps } from './textbox';
|
||||
import { Scroll, ScrollExpose, ScrollProps } from './scroll';
|
||||
import { transitioned } from '../use';
|
||||
import { hyper } from 'mutate-animate';
|
||||
import { logger } from '@motajs/common';
|
||||
import { GameUI, IUIMountable } from '@motajs/system-ui';
|
||||
import { GameUI, IUIMountable, SetupComponentOptions } from '@motajs/system-ui';
|
||||
import { clamp } from 'lodash-es';
|
||||
|
||||
interface ProgressProps extends DefaultProps {
|
||||
|
@ -8,9 +8,9 @@ import {
|
||||
VNode,
|
||||
watch
|
||||
} from 'vue';
|
||||
import { SetupComponentOptions } from './types';
|
||||
import { clamp } from 'lodash-es';
|
||||
import { DefaultProps, ElementLocator, Font } from '@motajs/render';
|
||||
import { SetupComponentOptions } from '@motajs/system-ui';
|
||||
|
||||
/** 圆角矩形页码距离容器的边框大小,与 pageSize 相乘 */
|
||||
const RECT_PAD = 0.1;
|
||||
|
@ -10,7 +10,6 @@ import {
|
||||
VNode,
|
||||
watch
|
||||
} from 'vue';
|
||||
import { SetupComponentOptions } from './types';
|
||||
import {
|
||||
Container,
|
||||
DefaultProps,
|
||||
@ -26,6 +25,7 @@ import {
|
||||
import { hyper, linear, Transition } from 'mutate-animate';
|
||||
import { clamp } from 'lodash-es';
|
||||
import { transitioned } from '../use';
|
||||
import { SetupComponentOptions } from '@motajs/system-ui';
|
||||
|
||||
export const enum ScrollDirection {
|
||||
Horizontal,
|
||||
|
@ -1,12 +0,0 @@
|
||||
import { ComponentOptions, EmitsOptions, SlotsType } from 'vue';
|
||||
|
||||
export type SetupComponentOptions<
|
||||
Props extends Record<string, any>,
|
||||
E extends EmitsOptions = {},
|
||||
EE extends string = string,
|
||||
S extends SlotsType = {}
|
||||
> = Pick<ComponentOptions, 'name' | 'inheritAttrs'> & {
|
||||
props?: (keyof Props)[];
|
||||
emits?: E | EE[];
|
||||
slots?: S;
|
||||
};
|
44
packages-user/client-modules/src/render/ui/save.tsx
Normal file
44
packages-user/client-modules/src/render/ui/save.tsx
Normal file
@ -0,0 +1,44 @@
|
||||
import { ElementLocator, IWheelEvent } from '@motajs/render-core';
|
||||
import { DefaultProps } from '@motajs/render-vue';
|
||||
import { SetupComponentOptions, UIComponentProps } from '@motajs/system-ui';
|
||||
import { defineComponent } from 'vue';
|
||||
import { Page } from '../components';
|
||||
import { useKey } from '../use';
|
||||
|
||||
export interface SaveProps extends UIComponentProps, DefaultProps {
|
||||
loc: ElementLocator;
|
||||
}
|
||||
|
||||
export type SaveEmits = {
|
||||
/** 点击存档时触发 */
|
||||
emit: (index: number) => void;
|
||||
};
|
||||
|
||||
const saveProps = {
|
||||
props: ['loc', 'controller', 'instance']
|
||||
} satisfies SetupComponentOptions<SaveProps, SaveEmits, keyof SaveEmits>;
|
||||
|
||||
export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
|
||||
(props, { emit }) => {
|
||||
// 这些注释写完之后删了
|
||||
// 这里是 UI 部分,不负责任何存读档操作,这些在特定场景下传入 onEmit 来实现
|
||||
// 缩略图暂用 container 元素替代,点击时触发 onEmit
|
||||
// onEmit 事件在点击存档或按键确认时触发
|
||||
// 存读档执行函数在 ../../utils/saves.ts
|
||||
|
||||
// 参考 ../../action/hotkey.ts 中的按键定义
|
||||
const [key] = useKey();
|
||||
key.realize('confirm', () => {});
|
||||
key.realize('exit', () => {});
|
||||
// 其他按键自定义,需要新开一个 save 的 group
|
||||
|
||||
const emitSave = (index: number) => {
|
||||
emit('emit', index);
|
||||
};
|
||||
|
||||
const wheel = (ev: IWheelEvent) => {};
|
||||
|
||||
return () => <Page loc={props.loc} pages={1000} onWheel={wheel}></Page>;
|
||||
},
|
||||
saveProps
|
||||
);
|
@ -1,5 +1,9 @@
|
||||
import { ElementLocator } from '@motajs/render';
|
||||
import { GameUI, UIComponentProps } from '@motajs/system-ui';
|
||||
import {
|
||||
GameUI,
|
||||
SetupComponentOptions,
|
||||
UIComponentProps
|
||||
} from '@motajs/system-ui';
|
||||
import { defineComponent } from 'vue';
|
||||
import {
|
||||
ChoiceItem,
|
||||
@ -7,7 +11,6 @@ import {
|
||||
Choices,
|
||||
ChoicesProps,
|
||||
getConfirm,
|
||||
SetupComponentOptions,
|
||||
waitbox
|
||||
} from '../components';
|
||||
import { mainUi } from '@motajs/legacy-ui';
|
||||
|
@ -169,3 +169,24 @@ export async function syncFromServer(
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//#region 存读档操作
|
||||
|
||||
export const enum LoadMode {
|
||||
Load,
|
||||
ReplayFrom,
|
||||
ContinueReplayFrom,
|
||||
ContinueReplayTo
|
||||
}
|
||||
|
||||
/**
|
||||
* 对当前状态存档并存档至目标索引
|
||||
* @param index 存档至的索引
|
||||
*/
|
||||
export function saveTo(index: number) {}
|
||||
|
||||
/**
|
||||
* 从指定索引读档
|
||||
* @param index 从哪个索引读档
|
||||
*/
|
||||
export function loadFrom(index: number, mode: LoadMode) {}
|
||||
|
@ -105,10 +105,12 @@ export class Font implements IFontConfig {
|
||||
let unit = this.defaultSizeUnit;
|
||||
let family = this.defaultFamily;
|
||||
const tokens = str.split(/\s+/);
|
||||
tokens.forEach(v => {
|
||||
let lastIndex = 0;
|
||||
tokens.forEach((v, i) => {
|
||||
// font-italic
|
||||
if (v === 'italic') {
|
||||
italic = true;
|
||||
lastIndex = i;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -116,6 +118,7 @@ export class Font implements IFontConfig {
|
||||
const num = Number(v);
|
||||
if (!isNaN(num)) {
|
||||
weight = num;
|
||||
lastIndex = i;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -124,10 +127,11 @@ export class Font implements IFontConfig {
|
||||
if (!isNaN(parse)) {
|
||||
size = parse;
|
||||
unit = v.slice(parse.toString().length);
|
||||
lastIndex = i;
|
||||
return;
|
||||
}
|
||||
});
|
||||
family = tokens.at(-1) ?? 'Verdana';
|
||||
family = tokens.slice(lastIndex + 1).join(' ') ?? 'Verdana';
|
||||
return new Font(family, size, unit, weight, italic);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user