mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-09-23 15:41:48 +08:00
docs:render/components
This commit is contained in:
parent
7cbe35e246
commit
7fef0df1e6
@ -44,6 +44,7 @@ export class HeroKeyMover {
|
|||||||
down: data[config?.down ?? 'moveDown']
|
down: data[config?.down ?? 'moveDown']
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 静止时尝试启动移动
|
||||||
this.ticker.add(() => {
|
this.ticker.add(() => {
|
||||||
if (!this.moving) {
|
if (!this.moving) {
|
||||||
if (this.pressedKey.size > 0) {
|
if (this.pressedKey.size > 0) {
|
||||||
@ -56,6 +57,10 @@ export class HeroKeyMover {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按键移动
|
||||||
|
* @param code 按键码
|
||||||
|
*/
|
||||||
private onPressKey = (code: KeyCode) => {
|
private onPressKey = (code: KeyCode) => {
|
||||||
if (core.isReplaying() || !core.isPlaying()) return;
|
if (core.isReplaying() || !core.isPlaying()) return;
|
||||||
core.waitHeroToStop();
|
core.waitHeroToStop();
|
||||||
@ -65,6 +70,10 @@ export class HeroKeyMover {
|
|||||||
else if (code === this.hotkeyData.down.key) this.press('down');
|
else if (code === this.hotkeyData.down.key) this.press('down');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 释放按键
|
||||||
|
* @param code 按键码
|
||||||
|
*/
|
||||||
private onReleaseKey = (code: KeyCode) => {
|
private onReleaseKey = (code: KeyCode) => {
|
||||||
if (code === this.hotkeyData.left.key) this.release('left');
|
if (code === this.hotkeyData.left.key) this.release('left');
|
||||||
else if (code === this.hotkeyData.right.key) this.release('right');
|
else if (code === this.hotkeyData.right.key) this.release('right');
|
||||||
@ -135,18 +144,26 @@ export class HeroKeyMover {
|
|||||||
this.controller?.stop();
|
this.controller?.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移动结束
|
||||||
|
*/
|
||||||
private onStepEnd = () => {
|
private onStepEnd = () => {
|
||||||
const con = this.controller;
|
const con = this.controller;
|
||||||
if (!con) return;
|
if (!con) return;
|
||||||
|
|
||||||
|
// 被禁止操作时
|
||||||
if (core.status.lockControl) {
|
if (core.status.lockControl) {
|
||||||
con.stop();
|
con.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 未移动时
|
||||||
if (!this.moving) {
|
if (!this.moving) {
|
||||||
con.stop();
|
con.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 尝试移动
|
||||||
if (this.pressedKey.size > 0) {
|
if (this.pressedKey.size > 0) {
|
||||||
if (con.queue.length === 0) {
|
if (con.queue.length === 0) {
|
||||||
con.push({ type: 'dir', value: this.moveDir });
|
con.push({ type: 'dir', value: this.moveDir });
|
||||||
|
@ -9,17 +9,29 @@ import { useKey } from '../use';
|
|||||||
import { sleep } from 'mutate-animate';
|
import { sleep } from 'mutate-animate';
|
||||||
|
|
||||||
export interface ConfirmBoxProps extends DefaultProps, TextContentProps {
|
export interface ConfirmBoxProps extends DefaultProps, TextContentProps {
|
||||||
|
/** 确认框的提示文本内容 */
|
||||||
text: string;
|
text: string;
|
||||||
|
/** 确认框对话框的宽度 */
|
||||||
width: number;
|
width: number;
|
||||||
|
/** 确认框对话框的位置 */
|
||||||
loc: ElementLocator;
|
loc: ElementLocator;
|
||||||
|
/** 确认/取消按钮的字体样式 */
|
||||||
selFont?: Font;
|
selFont?: Font;
|
||||||
|
/** 确认/取消按钮的文本颜色 */
|
||||||
selFill?: CanvasStyle;
|
selFill?: CanvasStyle;
|
||||||
|
/** 对话框内部所有元素的内边距 */
|
||||||
pad?: number;
|
pad?: number;
|
||||||
|
/** 确认按钮的显示文本,默认为"确认" */
|
||||||
yesText?: string;
|
yesText?: string;
|
||||||
|
/** 取消按钮的显示文本,默认为"取消" */
|
||||||
noText?: string;
|
noText?: string;
|
||||||
|
/** 窗口皮肤图片ID,用于对话框背景绘制 */
|
||||||
winskin?: ImageIds;
|
winskin?: ImageIds;
|
||||||
|
/** 是否默认选中确认按钮 */
|
||||||
defaultYes?: boolean;
|
defaultYes?: boolean;
|
||||||
|
/** 对话框背景颜色,当未设置 winskin 时生效 */
|
||||||
color?: CanvasStyle;
|
color?: CanvasStyle;
|
||||||
|
/** 对话框边框颜色,当未设置 winskin 时生效 */
|
||||||
border?: CanvasStyle;
|
border?: CanvasStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,21 +210,37 @@ export type ChoiceItem<T extends ChoiceKey = ChoiceKey> = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export interface ChoicesProps extends DefaultProps, TextContentProps {
|
export interface ChoicesProps extends DefaultProps, TextContentProps {
|
||||||
|
/** 选项数组 */
|
||||||
choices: ChoiceItem[];
|
choices: ChoiceItem[];
|
||||||
|
/** 选择框对话框的位置 */
|
||||||
loc: ElementLocator;
|
loc: ElementLocator;
|
||||||
|
/** 选择框对话框的宽度 */
|
||||||
width: number;
|
width: number;
|
||||||
|
/** 选择框的最大高度,超过时将分页显示 */
|
||||||
maxHeight?: number;
|
maxHeight?: number;
|
||||||
|
/** 选择框的提示文本内容 */
|
||||||
text?: string;
|
text?: string;
|
||||||
|
/** 选择框的标题文本 */
|
||||||
title?: string;
|
title?: string;
|
||||||
|
/** 窗口皮肤图片ID,用于对话框背景绘制 */
|
||||||
winskin?: ImageIds;
|
winskin?: ImageIds;
|
||||||
|
/** 对话框背景颜色,当未设置 winskin 时生效 */
|
||||||
color?: CanvasStyle;
|
color?: CanvasStyle;
|
||||||
|
/** 对话框边框颜色,当未设置 winskin 时生效 */
|
||||||
border?: CanvasStyle;
|
border?: CanvasStyle;
|
||||||
|
/** 选项文本的字体样式 */
|
||||||
selFont?: Font;
|
selFont?: Font;
|
||||||
|
/** 选项文本的颜色 */
|
||||||
selFill?: CanvasStyle;
|
selFill?: CanvasStyle;
|
||||||
|
/** 标题文本的字体样式 */
|
||||||
titleFont?: Font;
|
titleFont?: Font;
|
||||||
|
/** 标题文本的颜色 */
|
||||||
titleFill?: CanvasStyle;
|
titleFill?: CanvasStyle;
|
||||||
|
/** 对话框内部所有元素的内边距 */
|
||||||
pad?: number;
|
pad?: number;
|
||||||
|
/** 选项之间的垂直间隔 */
|
||||||
interval?: number;
|
interval?: number;
|
||||||
|
/** 默认选中的选项索引 */
|
||||||
selected?: number;
|
selected?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +146,7 @@ export const Input = defineComponent<InputProps, InputEmits, keyof InputEmits>(
|
|||||||
const renderer = MotaRenderer.get('render-main');
|
const renderer = MotaRenderer.get('render-main');
|
||||||
const canvas = renderer?.getCanvas();
|
const canvas = renderer?.getCanvas();
|
||||||
if (!canvas) return;
|
if (!canvas) return;
|
||||||
|
|
||||||
const chain: RenderItem[] = [];
|
const chain: RenderItem[] = [];
|
||||||
let now: RenderItem | undefined = root.value;
|
let now: RenderItem | undefined = root.value;
|
||||||
if (!now) return;
|
if (!now) return;
|
||||||
@ -153,6 +154,8 @@ export const Input = defineComponent<InputProps, InputEmits, keyof InputEmits>(
|
|||||||
chain.unshift(now);
|
chain.unshift(now);
|
||||||
now = now.parent;
|
now = now.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 应用内边距偏移.
|
||||||
const { clientLeft, clientTop } = canvas;
|
const { clientLeft, clientTop } = canvas;
|
||||||
const trans = new Transform();
|
const trans = new Transform();
|
||||||
trans.translate(clientLeft, clientTop);
|
trans.translate(clientLeft, clientTop);
|
||||||
@ -163,8 +166,11 @@ export const Input = defineComponent<InputProps, InputEmits, keyof InputEmits>(
|
|||||||
trans.multiply(item.transform);
|
trans.multiply(item.transform);
|
||||||
}
|
}
|
||||||
trans.translate(padding.value, padding.value);
|
trans.translate(padding.value, padding.value);
|
||||||
|
|
||||||
|
// 构建CSS transform的matrix字符串
|
||||||
const [a, b, , c, d, , e, f] = trans.mat;
|
const [a, b, , c, d, , e, f] = trans.mat;
|
||||||
const str = `matrix(${a},${b},${c},${d},${e},${f})`;
|
const str = `matrix(${a},${b},${c},${d},${e},${f})`;
|
||||||
|
|
||||||
const w = width.value * core.domStyle.scale;
|
const w = width.value * core.domStyle.scale;
|
||||||
const h = height.value * core.domStyle.scale;
|
const h = height.value * core.domStyle.scale;
|
||||||
const font = props.font ?? Font.defaults();
|
const font = props.font ?? Font.defaults();
|
||||||
@ -237,17 +243,29 @@ export const Input = defineComponent<InputProps, InputEmits, keyof InputEmits>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export interface InputBoxProps extends TextContentProps {
|
export interface InputBoxProps extends TextContentProps {
|
||||||
|
/** 输入框对话框的位置 */
|
||||||
loc: ElementLocator;
|
loc: ElementLocator;
|
||||||
|
/** 传递给内部 Input 组件的配置参数,用于自定义输入行为 */
|
||||||
input?: InputProps;
|
input?: InputProps;
|
||||||
|
/** 窗口皮肤图片ID,用于对话框背景绘制 */
|
||||||
winskin?: ImageIds;
|
winskin?: ImageIds;
|
||||||
|
/** 对话框背景颜色,当未设置 winskin 时生效 */
|
||||||
color?: CanvasStyle;
|
color?: CanvasStyle;
|
||||||
|
/** 对话框边框颜色,当未设置 winskin 时生效 */
|
||||||
border?: CanvasStyle;
|
border?: CanvasStyle;
|
||||||
|
/** 对话框内部所有元素的内边距 */
|
||||||
pad?: number;
|
pad?: number;
|
||||||
|
/** 内部输入框区域的高度 */
|
||||||
inputHeight?: number;
|
inputHeight?: number;
|
||||||
|
/** 对话框顶部的提示文本 */
|
||||||
text?: string;
|
text?: string;
|
||||||
|
/** 确认按钮的显示文本,默认为"确认" */
|
||||||
yesText?: string;
|
yesText?: string;
|
||||||
|
/** 取消按钮的显示文本,默认为"取消" */
|
||||||
noText?: string;
|
noText?: string;
|
||||||
|
/** 确认/取消按钮的字体样式 */
|
||||||
selFont?: Font;
|
selFont?: Font;
|
||||||
|
/** 确认/取消按钮的文本颜色 */
|
||||||
selFill?: CanvasStyle;
|
selFill?: CanvasStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,6 +523,11 @@ export function getInput(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 与 `getInput` 类似,不过会将结果转为数字。用法参考 {@link getInput}
|
* 与 `getInput` 类似,不过会将结果转为数字。用法参考 {@link getInput}
|
||||||
|
* @param controller UI 控制器
|
||||||
|
* @param text 确认文本内容
|
||||||
|
* @param loc 确认框的位置
|
||||||
|
* @param width 确认框的宽度
|
||||||
|
* @param props 额外的 props,参考 {@link ConfirmBoxProps}
|
||||||
*/
|
*/
|
||||||
export async function getInputNumber(
|
export async function getInputNumber(
|
||||||
controller: IUIMountable,
|
controller: IUIMountable,
|
||||||
|
@ -54,6 +54,7 @@ export interface ScrollExpose {
|
|||||||
export interface ScrollProps extends DefaultProps {
|
export interface ScrollProps extends DefaultProps {
|
||||||
loc: ElementLocator;
|
loc: ElementLocator;
|
||||||
hor?: boolean;
|
hor?: boolean;
|
||||||
|
/** 是否不允许滚动 */
|
||||||
noscroll?: boolean;
|
noscroll?: boolean;
|
||||||
/**
|
/**
|
||||||
* 滚动到最下方(最右方)时的填充大小,如果默认的高度计算方式有误,
|
* 滚动到最下方(最右方)时的填充大小,如果默认的高度计算方式有误,
|
||||||
|
@ -500,18 +500,28 @@ export const Textbox = defineComponent<
|
|||||||
}, textboxOptions);
|
}, textboxOptions);
|
||||||
|
|
||||||
interface TextboxStoreEmits {
|
interface TextboxStoreEmits {
|
||||||
|
/** 结束打字机动画的回调函数 */
|
||||||
endType: () => void;
|
endType: () => void;
|
||||||
|
/** 隐藏文本框的回调函数 */
|
||||||
hide: () => void;
|
hide: () => void;
|
||||||
|
/** 显示文本框的回调函数 */
|
||||||
show: () => void;
|
show: () => void;
|
||||||
|
/** 更新文本框配置的回调函数 */
|
||||||
update: (value: TextboxProps) => void;
|
update: (value: TextboxProps) => void;
|
||||||
|
/** 设置显示文本的回调函数 */
|
||||||
setText: (text: string) => void;
|
setText: (text: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TextboxStoreEvent {
|
interface TextboxStoreEvent {
|
||||||
|
/** 文本框配置更新事件,传递更新后的配置值 */
|
||||||
update: [value: TextboxProps];
|
update: [value: TextboxProps];
|
||||||
|
/** 文本框显示事件 */
|
||||||
show: [];
|
show: [];
|
||||||
|
/** 文本框隐藏事件 */
|
||||||
hide: [];
|
hide: [];
|
||||||
|
/** 打字机开始打字事件 */
|
||||||
typeStart: [];
|
typeStart: [];
|
||||||
|
/** 打字机结束打字事件 */
|
||||||
typeEnd: [];
|
typeEnd: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,10 +75,15 @@ interface TyperConfig extends ITextContentConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface ParserStatus {
|
interface ParserStatus {
|
||||||
|
/** 画布填充描边样式 */
|
||||||
fillStyle: CanvasStyle;
|
fillStyle: CanvasStyle;
|
||||||
|
/** 描边样式 */
|
||||||
fontFamily: string;
|
fontFamily: string;
|
||||||
|
/** 字体大小 */
|
||||||
fontSize: number;
|
fontSize: number;
|
||||||
|
/** 是否斜体 */
|
||||||
fontItalic: boolean;
|
fontItalic: boolean;
|
||||||
|
/** 字体粗细 */
|
||||||
fontWeight: number;
|
fontWeight: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,10 +8,15 @@ import { defineComponent, ref, watch } from 'vue';
|
|||||||
import { SetupComponentOptions } from '@motajs/system-ui';
|
import { SetupComponentOptions } from '@motajs/system-ui';
|
||||||
|
|
||||||
export interface ThumbnailProps extends SpriteProps {
|
export interface ThumbnailProps extends SpriteProps {
|
||||||
|
/** 缩略图的位置 */
|
||||||
loc: ElementLocator;
|
loc: ElementLocator;
|
||||||
|
/** 楼层 ID */
|
||||||
floorId: FloorIds;
|
floorId: FloorIds;
|
||||||
|
/** 缩略图填充样式 */
|
||||||
padStyle?: CanvasStyle;
|
padStyle?: CanvasStyle;
|
||||||
|
/** 楼层信息 */
|
||||||
map?: Block[];
|
map?: Block[];
|
||||||
|
/** 角色信息 */
|
||||||
hero?: HeroStatus;
|
hero?: HeroStatus;
|
||||||
// configs
|
// configs
|
||||||
damage?: boolean;
|
damage?: boolean;
|
||||||
|
@ -8,9 +8,13 @@ import { texture } from '../elements';
|
|||||||
import { SetupComponentOptions } from '@motajs/system-ui';
|
import { SetupComponentOptions } from '@motajs/system-ui';
|
||||||
|
|
||||||
export interface TipProps extends DefaultProps {
|
export interface TipProps extends DefaultProps {
|
||||||
|
/** 显示的位置 */
|
||||||
loc: ElementLocator;
|
loc: ElementLocator;
|
||||||
|
/** 边距 */
|
||||||
pad?: [number, number];
|
pad?: [number, number];
|
||||||
|
/** 圆角 */
|
||||||
corner?: number;
|
corner?: number;
|
||||||
|
/** 显示的图标 */
|
||||||
id?: string;
|
id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,6 +402,8 @@ importers:
|
|||||||
|
|
||||||
packages-user/types: {}
|
packages-user/types: {}
|
||||||
|
|
||||||
|
packages/animate: {}
|
||||||
|
|
||||||
packages/client:
|
packages/client:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@motajs/client-base':
|
'@motajs/client-base':
|
||||||
|
Loading…
Reference in New Issue
Block a user