Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions docs/develop/share/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ See API design in [`module_ProjectRunner.ts`](./module_ProjectRunner.ts).
See API design in [`module_Recording.ts`](./module_Recording.ts).

### MobileKeyboard

移动键盘的组件,负责键盘的展示与编辑逻辑,与 Project 绑定。

See API design in [`module_MobileKeyboard.ts`](./module_MobileKeyboard.ts).
Expand Down Expand Up @@ -93,12 +94,12 @@ graph TB

%% 功能模块层
subgraph FunctionLayer["功能模块层"]
VirtualKeyboard["`**VirtualKeyboard**
虚拟键盘模块`"]
MobileKeyboard["`**MobileKeyboard**
移动端键盘模块`"]

ProjectRunner["`**ProjectRunner**
游戏引擎接口模块`"]

Recording["`**Recording**
录屏展示模块`"]
end
Expand All @@ -107,7 +108,7 @@ graph TB
subgraph APILayer["API 服务层"]
RecordingAPIs["`**Recording APIs**
录屏管理服务`"]

ProjectAPIs["`**Project APIs**
项目管理服务`"]
end
Expand All @@ -116,10 +117,10 @@ graph TB
subgraph ShareLayer["分享界面层"]
DirectSharing["`**DirectSharing**
直接分享弹窗`"]

ProjectRecordingSharing["`**ProjectRecordingSharing**
录屏分享弹窗`"]

ScreenShotSharing["`**ScreenShotSharing**
截屏分享弹窗`"]
end
Expand All @@ -128,7 +129,7 @@ graph TB
subgraph PlatformLayer["平台集成层"]
PlatformSelector["`**PlatformSelector**
平台选择组件`"]

PlatformShare["`**PlatformShare**
第三方平台集成`"]
end
Expand All @@ -140,16 +141,16 @@ graph TB
end

%% 主要流程连接
BuilderUI --> VirtualKeyboard
BuilderUI --> MobileKeyboard
BuilderUI --> ProjectRunner
BuilderUI --> Recording
BuilderUI --> DirectSharing
BuilderUI --> ScreenShotSharing
BuilderUI --> ProjectRecordingSharing

%% 功能模块间连接
VirtualKeyboard --> ProjectRunner
VirtualKeyboard --> ProjectAPIs
MobileKeyboard --> ProjectRunner
MobileKeyboard --> ProjectAPIs

%% 分享流程连接
DirectSharing --> PlatformSelector
Expand Down
55 changes: 19 additions & 36 deletions docs/develop/share/module_MobileKeyboard.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { dispatchKeyToEvent } from "./module_ProjectAPIs";
import type {
MobileKeyboardZoneToKeyMapping,
MobileKeyboardBtns,
MobileKeyboardType,
} from "./module_ProjectAPIs";

export type KeyboardConfig = {
type: MobileKeyboardType;
mapping: MobileKeyboardZoneToKeyMapping;
btns: MobileKeyboardBtns;
};
export type UI = any;

export declare function useModal<T>(
component: any
): (props?: any) => Promise<T>;

export declare function KeyboardEditorModal(
export declare function KeyboardEditor(
props: {
zoneToKeyMapping: MobileKeyboardZoneToKeyMapping;
mobileKeyboardBtns: MobileKeyboardBtns;
},
emits: {
resolved: (result: MobileKeyboardZoneToKeyMapping) => void;
resolved: (result: MobileKeyboardBtns) => void;
}
): UI;

Expand All @@ -37,44 +37,27 @@ export declare function KeyboardEditorModal(
*
* use:
* ```vue
* <MobileKeyboardView :ZoneToKeyMapping="{ lt: 'Q', rt: 'E' }">
* <MobileKeyboardView
* :ZoneToKeyMapping="{ label: 'Q', posX: 0, posY: 0, btnWidth: 50, btnHeight: 50 }"
* @close="emit('close')"
* @rerun="emit('rerun')"
* />
* <template>
* <ProjectRunner :project="project" />
* </template>
* </MobileKeyboardView>
* ```
*/
export type MobileKeyboardViewProps = {
zoneToKeyMapping: MobileKeyboardZoneToKeyMapping;
};

export declare function MobileKeyboardView({
zoneToKeyMapping,
}: MobileKeyboardViewProps): UI;
// {
// const zones = Object.keys(ZoneToKeyMapping);
// const zoneToKey = ZoneToKeyMapping;
// const handleKeyEvent = (type: string, key: string, code: string) => {
// dispatchKeyToEvent(type, code);
// };

// const keyButtons = zones
// .map(
// (zone) =>
// `<UIKeyBtn key="${zone}" value="${zoneToKey[zone]}" active={true} onKeyEvent=${handleKeyEvent} />`
// )
// .join("");

// return `
// <div className="phone-layout">
// <slot name="gameView">
// </slot>
// <div className="keyboard-zones">
// ${keyButtons}
// </div>
// </div>
// `;
// }
export declare function MobileKeyboardView(
props: {
mobileKeyboardBtns: MobileKeyboardBtns;
},
emits: {
close: [];
rerun: [];
}
): UI;

// key UI in Keyboard. provide to MobileKeyboardView and MobileKeyboardEidt
// active is used to indicate whether a button has functionality(onKeyEvent).
Expand Down
38 changes: 12 additions & 26 deletions docs/develop/share/module_ProjectAPIs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,15 @@ import type {
} from "../../../spx-gui/src/apis/common/index.ts";
import { type ProjectRelease } from "../../../spx-gui/src/apis/project-release.ts";

/**
* Valid mobile keyboard zones
*/
export const MOBILE_KEYBOARD_ZONES = [
"lt",
"rt",
"lbUp",
"lbLeft",
"lbRight",
"lbDown",
"rbA",
"rbB",
"rbX",
"rbY",
] as const;

export type MobileKeyboardZone = (typeof MOBILE_KEYBOARD_ZONES)[number];
/**
* Zone to key mapping for mobile keyboard
*/
export type MobileKeyboardZoneToKeyMapping = {
[zone in MobileKeyboardZone]: string | null;
export type KeyBtn = {
/** The text displayed on the key. */
label: string;
/** The horizontal coordinate of the left top corner of the key (pixels). */
posX: number;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外还有 #2133 (comment) 这个问题需要考虑下

/** The vertical coordinate of the left top corner of the key (pixels). */
posY: number;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还缺了说明“这个 btn 绑定的是哪个 key”的字段?

};
export type MobileKeyboardBtns = KeyBtn[];
/**
* Mobile keyboard type
* - NoKeyboard: No keyboard
Expand Down Expand Up @@ -77,7 +63,7 @@ export type ProjectData = {
/** Mobile keyboard type */
mobileKeyboardType: MobileKeyboardType;
/** Zone to key mapping for mobile keyboard */
mobileKeyboardZoneToKey?: MobileKeyboardZoneToKeyMapping;
mobileKeyboardBtns?: MobileKeyboardBtns;
};

/**
Expand All @@ -95,7 +81,7 @@ export type AddProjectParams = {
/** Mobile keyboard type */
mobileKeyboardType: MobileKeyboardType;
/** Zone to key mapping for mobile keyboard */
mobileKeyboardZoneToKey?: MobileKeyboardZoneToKeyMapping;
mobileKeyboardBtns?: MobileKeyboardBtns;
};

/**
Expand All @@ -111,7 +97,7 @@ export type AddProjectByRemixParams = {
/** Mobile keyboard type */
mobileKeyboardType: MobileKeyboardType;
/** Zone to key mapping for mobile keyboard */
mobileKeyboardZoneToKey?: MobileKeyboardZoneToKeyMapping;
mobileKeyboardBtns?: MobileKeyboardBtns;
};

/**
Expand All @@ -131,7 +117,7 @@ export type UpdateProjectParams = {
/** Mobile keyboard type */
mobileKeyboardType?: MobileKeyboardType;
/** Zone to key mapping for mobile keyboard */
mobileKeyboardZoneToKey?: MobileKeyboardZoneToKeyMapping;
mobileKeyboardBtns?: MobileKeyboardBtns;
};

/**
Expand Down
Loading