mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-02 09:15:05 +08:00
feat: 存档界面接口
This commit is contained in:
1 parent
99432d4fd3
commit
da05785694
13 files changed
+86
-30
No files matched your search
@@ -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;
|
||||
};
|
||||
@@ -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) {}
|
||||
Reference in new issue
Block a user