feat(09-01): dedup controller/background and fix load/title props base (D-10)

- Move render/ui/controller.tsx -> src/ui/controller.tsx keeping only mainUIController + createMainController; import MainBackgroundUI from ./background
- Move MainBackground/MainBackgroundUI/MainBackgroundProps ownership to src/ui/background.tsx; drop ../render import; add DefaultProps (render-vue) + IUIDefaultPropsBase (system)
- Fix load.tsx/title.tsx props base: IUIDefaultPropsBase -> IUIPropsBase (own ./types); drop unused system import in title.tsx
- Rewrite render capability imports from ../render barrel to ../render/use leaf (avoid render/index.tsx <-> ui cycle)
- Complete barrel: + ./controller ./background ./func (7 same-dir exports)
- Delete old render/ui/controller.tsx
This commit is contained in:
unanmed 2026-10-09 15:57:03 +08:00
parent 24ee08cc2d
commit b637d3b5f3
6 changed files with 23 additions and 47 deletions

View File

@ -1,34 +0,0 @@
import { DefaultProps } from '@motajs/render-vue';
import {
GameUI,
SetupComponentOptions,
IUIDefaultPropsBase,
UIController
} from '@motajs/system';
import { defineComponent } from 'vue';
import { MAIN_HEIGHT, MAIN_WIDTH } from '../../shared';
export const mainUIController = new UIController('main-ui');
export interface MainBackgroundProps
extends DefaultProps, IUIDefaultPropsBase {}
const mainBackgroundProps = {
props: ['controller', 'instance']
} satisfies SetupComponentOptions<MainBackgroundProps>;
export const MainBackground = defineComponent<MainBackgroundProps>(() => {
return () => (
<g-rect
loc={[0, 0, MAIN_WIDTH, MAIN_HEIGHT]}
fill
fillStyle="rgba(0, 0, 0, 0.8)"
/>
);
}, mainBackgroundProps);
export const MainBackgroundUI = new GameUI('main-background', MainBackground);
export function createMainController() {
mainUIController.setBackground(MainBackgroundUI, {});
}

View File

@ -1,8 +1,11 @@
import { GameUI, SetupComponentOptions } from '@motajs/system';
import { GameUI, SetupComponentOptions, IUIDefaultPropsBase } from '@motajs/system';
import { DefaultProps } from '@motajs/render-vue';
import { defineComponent } from 'vue';
import { MainBackgroundProps } from '../render';
import { MAIN_WIDTH, MAIN_HEIGHT } from '../shared';
export interface MainBackgroundProps
extends DefaultProps, IUIDefaultPropsBase {}
const mainBackgroundProps = {
props: ['controller', 'instance']
} satisfies SetupComponentOptions<MainBackgroundProps>;

View File

@ -0,0 +1,8 @@
import { UIController } from '@motajs/system';
import { MainBackgroundUI } from './background';
export const mainUIController = new UIController('main-ui');
export function createMainController() {
mainUIController.setBackground(MainBackgroundUI, {});
}

View File

@ -2,3 +2,6 @@ export * from './types';
export * from './save';
export * from './statistics';
export * from './viewmap';
export * from './controller';
export * from './background';
export * from './func';

View File

@ -15,14 +15,14 @@ import {
MAIN_WIDTH
} from '../shared';
import { ElementLocator, Font, MotaOffscreenCanvas2D } from '@motajs/render';
import { transitioned } from '../render';
import { transitioned } from '../render/use';
import { cosh, CurveMode, linear } from '@motajs/animate';
import { clamp } from 'lodash-es';
import { sleep } from '@motajs/common';
import { GameTitleUI } from './title';
import { IUIDefaultPropsBase } from './types';
import { IUIPropsBase } from './types';
export interface ILoadProps extends IUIDefaultPropsBase, DefaultProps {}
export interface ILoadProps extends IUIPropsBase, DefaultProps {}
const loadSceneProps = {
props: ['controller', 'instance', 'state']

View File

@ -1,9 +1,5 @@
import { DefaultProps } from '@motajs/render-vue';
import {
GameUI,
SetupComponentOptions,
IUIDefaultPropsBase
} from '@motajs/system';
import { GameUI, SetupComponentOptions } from '@motajs/system';
import { defineComponent, nextTick, onMounted, ref } from 'vue';
import {
BUTTONS_HEIGHT,
@ -27,7 +23,7 @@ import {
transitioned,
transitionedColor,
useKey
} from '../render';
} from '../render/use';
import { ExitFullscreen, Fullscreen, SoundVolume } from '@user/client-base';
import { mainSetting, triggerFullscreen } from '@motajs/legacy-ui';
import { saveLoad } from './save';
@ -35,7 +31,7 @@ import { MainSceneUI } from './main';
import { adjustCover } from '@user/client-base';
import { cosh, CurveMode, linear } from '@motajs/animate';
import { sleep } from '@motajs/common';
import { IUIDefaultPropsBase } from './types';
import { IUIPropsBase } from './types';
const enum TitleButton {
StartGame,
@ -57,7 +53,7 @@ interface ButtonOption {
colorTrans: ITransitionedController<string>;
}
export interface GameTitleProps extends DefaultProps, IUIDefaultPropsBase {}
export interface GameTitleProps extends DefaultProps, IUIPropsBase {}
const gameTitleProps = {
props: ['controller', 'instance', 'state']