mirror of
https://github.com/motajs/template.git
synced 2026-10-11 23:20:21 +08:00
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:
parent
24ee08cc2d
commit
b637d3b5f3
@ -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, {});
|
|
||||||
}
|
|
||||||
@ -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 { defineComponent } from 'vue';
|
||||||
import { MainBackgroundProps } from '../render';
|
|
||||||
import { MAIN_WIDTH, MAIN_HEIGHT } from '../shared';
|
import { MAIN_WIDTH, MAIN_HEIGHT } from '../shared';
|
||||||
|
|
||||||
|
export interface MainBackgroundProps
|
||||||
|
extends DefaultProps, IUIDefaultPropsBase {}
|
||||||
|
|
||||||
const mainBackgroundProps = {
|
const mainBackgroundProps = {
|
||||||
props: ['controller', 'instance']
|
props: ['controller', 'instance']
|
||||||
} satisfies SetupComponentOptions<MainBackgroundProps>;
|
} satisfies SetupComponentOptions<MainBackgroundProps>;
|
||||||
|
|||||||
8
packages-user/client-modules/src/ui/controller.tsx
Normal file
8
packages-user/client-modules/src/ui/controller.tsx
Normal 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, {});
|
||||||
|
}
|
||||||
@ -2,3 +2,6 @@ export * from './types';
|
|||||||
export * from './save';
|
export * from './save';
|
||||||
export * from './statistics';
|
export * from './statistics';
|
||||||
export * from './viewmap';
|
export * from './viewmap';
|
||||||
|
export * from './controller';
|
||||||
|
export * from './background';
|
||||||
|
export * from './func';
|
||||||
|
|||||||
@ -15,14 +15,14 @@ import {
|
|||||||
MAIN_WIDTH
|
MAIN_WIDTH
|
||||||
} from '../shared';
|
} from '../shared';
|
||||||
import { ElementLocator, Font, MotaOffscreenCanvas2D } from '@motajs/render';
|
import { ElementLocator, Font, MotaOffscreenCanvas2D } from '@motajs/render';
|
||||||
import { transitioned } from '../render';
|
import { transitioned } from '../render/use';
|
||||||
import { cosh, CurveMode, linear } from '@motajs/animate';
|
import { cosh, CurveMode, linear } from '@motajs/animate';
|
||||||
import { clamp } from 'lodash-es';
|
import { clamp } from 'lodash-es';
|
||||||
import { sleep } from '@motajs/common';
|
import { sleep } from '@motajs/common';
|
||||||
import { GameTitleUI } from './title';
|
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 = {
|
const loadSceneProps = {
|
||||||
props: ['controller', 'instance', 'state']
|
props: ['controller', 'instance', 'state']
|
||||||
|
|||||||
@ -1,9 +1,5 @@
|
|||||||
import { DefaultProps } from '@motajs/render-vue';
|
import { DefaultProps } from '@motajs/render-vue';
|
||||||
import {
|
import { GameUI, SetupComponentOptions } from '@motajs/system';
|
||||||
GameUI,
|
|
||||||
SetupComponentOptions,
|
|
||||||
IUIDefaultPropsBase
|
|
||||||
} from '@motajs/system';
|
|
||||||
import { defineComponent, nextTick, onMounted, ref } from 'vue';
|
import { defineComponent, nextTick, onMounted, ref } from 'vue';
|
||||||
import {
|
import {
|
||||||
BUTTONS_HEIGHT,
|
BUTTONS_HEIGHT,
|
||||||
@ -27,7 +23,7 @@ import {
|
|||||||
transitioned,
|
transitioned,
|
||||||
transitionedColor,
|
transitionedColor,
|
||||||
useKey
|
useKey
|
||||||
} from '../render';
|
} from '../render/use';
|
||||||
import { ExitFullscreen, Fullscreen, SoundVolume } from '@user/client-base';
|
import { ExitFullscreen, Fullscreen, SoundVolume } from '@user/client-base';
|
||||||
import { mainSetting, triggerFullscreen } from '@motajs/legacy-ui';
|
import { mainSetting, triggerFullscreen } from '@motajs/legacy-ui';
|
||||||
import { saveLoad } from './save';
|
import { saveLoad } from './save';
|
||||||
@ -35,7 +31,7 @@ import { MainSceneUI } from './main';
|
|||||||
import { adjustCover } from '@user/client-base';
|
import { adjustCover } from '@user/client-base';
|
||||||
import { cosh, CurveMode, linear } from '@motajs/animate';
|
import { cosh, CurveMode, linear } from '@motajs/animate';
|
||||||
import { sleep } from '@motajs/common';
|
import { sleep } from '@motajs/common';
|
||||||
import { IUIDefaultPropsBase } from './types';
|
import { IUIPropsBase } from './types';
|
||||||
|
|
||||||
const enum TitleButton {
|
const enum TitleButton {
|
||||||
StartGame,
|
StartGame,
|
||||||
@ -57,7 +53,7 @@ interface ButtonOption {
|
|||||||
colorTrans: ITransitionedController<string>;
|
colorTrans: ITransitionedController<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GameTitleProps extends DefaultProps, IUIDefaultPropsBase {}
|
export interface GameTitleProps extends DefaultProps, IUIPropsBase {}
|
||||||
|
|
||||||
const gameTitleProps = {
|
const gameTitleProps = {
|
||||||
props: ['controller', 'instance', 'state']
|
props: ['controller', 'instance', 'state']
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user