fix(09-05): adapt IUIController/UIController to required IGameUIPropsBase generic

- add <IGameUIPropsBase> to 16 IUIController annotation sites (client-modules + client-base)
This commit is contained in:
unanmed 2026-10-10 14:14:12 +08:00
parent 1bcdcc3677
commit 3a49b37c25
10 changed files with 29 additions and 23 deletions

View File

@ -9,6 +9,7 @@ import { GameUI, IUIController, SetupComponentOptions } from '@motajs/system';
import { useKey } from '../use';
import { sleep } from 'mutate-animate';
import { DefaultProps } from '@motajs/render-vue';
import { IGameUIPropsBase } from '../types';
export interface ConfirmBoxProps extends DefaultProps, TextContentProps {
/** 确认框的提示文本内容 */
@ -595,7 +596,7 @@ export const Choices = defineComponent<
* @param props 额外的 props,参考 {@link ConfirmBoxProps}
*/
export function getConfirm(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
text: string,
loc: ElementLocator,
width: number,
@ -648,7 +649,7 @@ export function getConfirm(
* @param props 额外的 props,参考 {@link ChoicesProps}
*/
export function getChoice<T extends ChoiceKey = ChoiceKey>(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
choices: ChoiceItem<T>[],
loc: ElementLocator,
width: number,
@ -707,7 +708,7 @@ function getChoiceRoute(defaults: number) {
* @param props 额外的 props,参考 {@link ConfirmBoxProps}
*/
export async function routedConfirm(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
text: string,
loc: ElementLocator,
width: number,
@ -762,7 +763,7 @@ export async function routedConfirm(
* @param props 额外的 props,参考 {@link ChoicesProps}
*/
export async function routedChoices<T extends ChoiceKey>(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
choices: ChoiceItem<T>[],
loc: ElementLocator,
width: number,

View File

@ -17,6 +17,7 @@ import { linear } from 'mutate-animate';
import { Background, Selection } from './misc';
import { GameUI, IUIController, SetupComponentOptions } from '@motajs/system';
import { KeyCode } from '@motajs/client-base';
import { IGameUIPropsBase } from '../types';
export interface InputProps extends DefaultProps, Partial<TextContentProps> {
/** 输入框的提示内容 */
@ -544,7 +545,7 @@ export const InputBox = defineComponent<
* @param props 额外的 props,参考 {@link ConfirmBoxProps}
*/
export function getInput(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
text: string,
loc: ElementLocator,
width: number,
@ -581,7 +582,7 @@ export function getInput(
* @param props 额外的 props,参考 {@link ConfirmBoxProps}
*/
export async function getInputNumber(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
text: string,
loc: ElementLocator,
width: number,

View File

@ -15,6 +15,7 @@ import { clamp } from 'lodash-es';
// @ts-expect-error render/renderer 按 D-54 留在实现层,本文件已移入系统层,按 D-59 暂以标注记录,不反向引用、不解耦
import { using } from '../renderer';
import { cosh, CurveMode } from '@motajs/animate';
import { IGameUIPropsBase } from '../types';
interface ProgressProps extends DefaultProps {
/** 进度条的位置 */
@ -568,7 +569,7 @@ export const WaitBox = defineComponent<
* @param props 额外的 props,参考 {@link WaitBoxProps}
*/
export function waitbox<T>(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
loc: ElementLocator,
width: number,
promise: Promise<T>,

View File

@ -1,3 +1,4 @@
import { UIController } from '@motajs/system';
import { IGameUIPropsBase } from '@user/client-base';
export const sceneController = new UIController('main-scene');
export const sceneController = new UIController<IGameUIPropsBase>();

View File

@ -1,5 +1,5 @@
import { compressToBase64, decompressFromBase64 } from 'lz-string';
import { getConfirm, waitbox } from '@user/client-base';
import { getConfirm, waitbox, IGameUIPropsBase } from '@user/client-base';
import { IUIController } from '@motajs/system';
import { SyncSaveFromServerResponse } from '@motajs/client-base';
import { CENTER_LOC, POP_BOX_WIDTH } from '../../shared';
@ -122,7 +122,7 @@ async function syncLoad(id: string, password: string) {
}
export async function syncFromServer(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
identifier: string
): Promise<void> {
if (!/^\d{6}\w{4}$/.test(identifier) && !/^\d{4}\w{3}$/.test(identifier)) {

View File

@ -1,7 +1,8 @@
import { UIController } from '@motajs/system';
import { IGameUIPropsBase } from '@user/client-base';
import { MainBackgroundUI } from './background';
export const mainUIController = new UIController('main-ui');
export const mainUIController = new UIController<IGameUIPropsBase>();
export function createMainController() {
mainUIController.setBackground(MainBackgroundUI, {});

View File

@ -13,7 +13,7 @@ import {
onMounted,
shallowReactive
} from 'vue';
import { getConfirm, Page, PageExpose, Thumbnail } from '@user/client-base';
import { getConfirm, Page, PageExpose, Thumbnail, IGameUIPropsBase } from '@user/client-base';
import { useKey } from '../render/use';
import {
HALF_HEIGHT,
@ -492,7 +492,7 @@ export type SaveValidationFunction = (
* @returns 选择的存档索引
*/
export function selectSave(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
loc: ElementLocator,
mode: SaveMode,
validate?: SaveValidationFunction,
@ -542,7 +542,7 @@ export function selectSave(
}
export async function saveSave(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
loc: ElementLocator,
props?: SaveProps
) {
@ -566,7 +566,7 @@ export async function saveSave(
}
export async function saveLoad(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
loc: ElementLocator,
props?: SaveProps
) {
@ -590,7 +590,7 @@ export async function saveLoad(
}
export async function saveWithExist(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
loc: ElementLocator,
props?: SaveProps
) {

View File

@ -7,7 +7,8 @@ import {
Choices,
ChoicesProps,
getConfirm,
waitbox
waitbox,
IGameUIPropsBase
} from '@user/client-base';
import { mainUi } from '@motajs/legacy-ui';
import { gameKey, generateKeyboardEvent } from '@motajs/system';
@ -677,7 +678,7 @@ export const ClearSaveSelectUI = new GameUI(
);
export function openSettings(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
loc: ElementLocator,
props?: MainSettingsProps
) {
@ -688,7 +689,7 @@ export function openSettings(
}
export function openReplay(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
loc: ElementLocator,
props?: MainSettingsProps
) {

View File

@ -5,7 +5,7 @@ import {
IUIDefaultPropsBase
} from '@motajs/system';
import { defineComponent } from 'vue';
import { waitbox, ListPage, TextContent } from '@user/client-base';
import { waitbox, ListPage, TextContent, IGameUIPropsBase } from '@user/client-base';
import { DefaultProps } from '@motajs/render-vue';
// @ts-expect-error 需要重构
import { ItemState } from '@user/data-state';
@ -280,7 +280,7 @@ export function calculateStatistics(): StatisticsData {
* 打开数据统计界面
* @param controller 要在哪个 UI 控制器上打开
*/
export async function openStatistics(controller: IUIController) {
export async function openStatistics(controller: IUIController<IGameUIPropsBase>) {
const cal = Promise.resolve().then<StatisticsData>(() => {
return new Promise(res => {
const data = calculateStatistics();

View File

@ -26,7 +26,7 @@ import {
import { FloorSelector } from '@user/client-base';
import { clamp, mean } from 'lodash-es';
import { StatisticsDataOneFloor } from './statistics';
import { Tip, TipExpose } from '@user/client-base';
import { Tip, TipExpose, IGameUIPropsBase } from '@user/client-base';
import { useKey } from '../render/use';
import {
ENABLE_RIGHT_STATUS_BAR,
@ -556,7 +556,7 @@ export const ViewMap = defineComponent<ViewMapProps>(props => {
export const ViewMapUI = new GameUI('view-map', ViewMap);
export function openViewMap(
controller: IUIController,
controller: IUIController<IGameUIPropsBase>,
loc: ElementLocator,
props?: ViewMapProps
) {