mirror of
https://github.com/motajs/template.git
synced 2026-12-02 20:24:31 +08:00
fix: 由 icon 引发的所有类型错误
This commit is contained in:
1 parent
9ac2898b15
commit
4f1e8c6f19
39 files changed
+188
-602
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import { logger } from '@motajs/common';
|
||||
import {
|
||||
excitationDivider,
|
||||
IClientCore,
|
||||
IClientCoreConfig,
|
||||
IClientPluginDefine
|
||||
@@ -23,17 +22,18 @@ export class MainClientPlugin implements IClientPluginDefine {
|
||||
|
||||
awake(state: IClientCore): void {
|
||||
// 渲染调试配置
|
||||
const divider = state.excitationDivider;
|
||||
if (DEBUG_VARIATOR) {
|
||||
const variator = new ExcitationVariator();
|
||||
variator.bindExcitation(state.rafExcitation);
|
||||
variator.setSpeed(VARIATOR_DEBUG_SPEED);
|
||||
excitationDivider.bindExcitation(variator);
|
||||
divider.bindExcitation(variator);
|
||||
} else {
|
||||
excitationDivider.bindExcitation(state.rafExcitation);
|
||||
divider.bindExcitation(state.rafExcitation);
|
||||
}
|
||||
|
||||
if (DEBUG_DIVIDER) {
|
||||
excitationDivider.setDivider(DIVIDER_DEBUG_DIVIDER);
|
||||
divider.setDivider(DIVIDER_DEBUG_DIVIDER);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { GameUI, SetupComponentOptions } from '@motajs/system';
|
||||
import { computed, defineComponent, onMounted, ref } from 'vue';
|
||||
import { Font } from '@motajs/render';
|
||||
import { Scroll, TextContent } from '@user/client-base';
|
||||
import { Scroll, TextContent, Icon } from '@user/client-base';
|
||||
import { IHeroState } from '@user/data-base';
|
||||
import { IHeroAttr } from '@user/data-common';
|
||||
import { IGameUIPropsBase } from '@user/client-base';
|
||||
@@ -274,8 +274,9 @@ export const Shop = defineComponent<IShopProps>(props => {
|
||||
: 'rgba(255, 255, 255, 0.05)'
|
||||
}
|
||||
/>
|
||||
<icon
|
||||
<Icon
|
||||
icon={item.num}
|
||||
manager={props.state.materials}
|
||||
loc={[10, 6, ROW_ICON_SIZE, ROW_ICON_SIZE]}
|
||||
/>
|
||||
<text
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { adjustGrid } from '@user/client-base/layout/layout';
|
||||
import { adjustGrid } from '@user/client-base';
|
||||
import enemyOneSource from '../enemyOne.tsx?raw';
|
||||
import bookSource from '../book.tsx?raw';
|
||||
import bookDetailSource from '../bookDetail.tsx?raw';
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { GameUI, SetupComponentOptions } from '@motajs/system';
|
||||
import { ElementLocator } from '@motajs/render';
|
||||
import { DefaultProps } from '@motajs/render-vue';
|
||||
import { computed, defineComponent } from 'vue';
|
||||
import { MAIN_HEIGHT, MAIN_WIDTH } from '@/client';
|
||||
import { SetupComponentOptions, GameUI } from '@motajs/system';
|
||||
import { IGameUIPropsBase } from '@user/client-base';
|
||||
import { defineComponent } from 'vue';
|
||||
import { MAIN_WIDTH, MAIN_HEIGHT } from '../uiConstant';
|
||||
|
||||
export interface MainBackgroundProps extends DefaultProps, IGameUIPropsBase {}
|
||||
|
||||
@@ -23,48 +22,3 @@ export const MainBackground = defineComponent<MainBackgroundProps>(() => {
|
||||
|
||||
/** 主 UI 控制器的背景 UI */
|
||||
export const MainBackgroundUI = new GameUI('main-background', MainBackground);
|
||||
|
||||
export interface BackgroundProps extends DefaultProps {
|
||||
loc: ElementLocator;
|
||||
winskin?: ImageIds;
|
||||
color?: CanvasStyle;
|
||||
border?: CanvasStyle;
|
||||
}
|
||||
|
||||
const backgroundProps = {
|
||||
props: ['loc', 'winskin', 'color', 'border']
|
||||
} satisfies SetupComponentOptions<BackgroundProps>;
|
||||
|
||||
/**
|
||||
* 背景组件,与 Selection 类似,不过绘制的是背景,而不是选择光标,参数参考 {@link BackgroundProps},用例如下:
|
||||
* ```tsx
|
||||
* // 使用 winskin2.png 作为背景
|
||||
* <Background loc={[8, 8, 160, 160]} winskin="winskin2.png" />
|
||||
* // 使用指定填充和边框颜色作为背景
|
||||
* <Background loc={[8, 8, 160, 160]} color="#333" border="gold" />
|
||||
* ```
|
||||
*/
|
||||
export const Background = defineComponent<BackgroundProps>(props => {
|
||||
const isWinskin = computed(() => !!props.winskin);
|
||||
const fixedLoc = computed<ElementLocator>(() => {
|
||||
const [x = 0, y = 0, width = 200, height = 200] = props.loc;
|
||||
return [x + 2, y + 2, width - 4, height - 4];
|
||||
});
|
||||
|
||||
return () =>
|
||||
isWinskin.value ? (
|
||||
<winskin imageName={props.winskin!} loc={props.loc} noanti />
|
||||
) : (
|
||||
<g-rectr
|
||||
loc={fixedLoc.value}
|
||||
fillStyle={props.color}
|
||||
strokeStyle={props.border}
|
||||
fill
|
||||
stroke
|
||||
lineWidth={2}
|
||||
circle={[4]}
|
||||
/>
|
||||
);
|
||||
}, backgroundProps);
|
||||
|
||||
export const BackgroundUI = new GameUI('background', Background);
|
||||
@@ -115,6 +115,7 @@ export const Book = defineComponent<BookProps>(props => {
|
||||
context={markRaw(ctx.value)}
|
||||
enemy={markRaw(base)}
|
||||
selected={selected.value === i}
|
||||
materials={props.state.materials}
|
||||
onClick={() => showDetail(base)}
|
||||
onEnter={() => void (selected.value = i)}
|
||||
/>
|
||||
|
||||
@@ -305,6 +305,7 @@ export const BookDetail = defineComponent<BookDetailProps>(props => {
|
||||
view={props.view}
|
||||
locator={props.locator}
|
||||
selected={false}
|
||||
materials={props.state.materials}
|
||||
/>
|
||||
<g-line
|
||||
line={SUMMARY_SPECIAL_DIVIDER}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ElementLocator, Font } from '@motajs/render';
|
||||
import { computed, defineComponent, reactive, ref } from 'vue';
|
||||
import { Background } from './background';
|
||||
import { Background } from '../../../packages-user/client-base/src/components/background';
|
||||
import {
|
||||
TextContent,
|
||||
TextContentProps,
|
||||
@@ -145,11 +145,11 @@ export const ConfirmBox = defineComponent<
|
||||
height.value = textHeight + pad.value * 4;
|
||||
};
|
||||
|
||||
const setYes = (width: number, height: number) => {
|
||||
const setYes = (_: unknown, width: number, height: number) => {
|
||||
yesSize.value = [width, height];
|
||||
};
|
||||
|
||||
const setNo = (width: number, height: number) => {
|
||||
const setNo = (_: unknown, width: number, height: number) => {
|
||||
noSize.value = [width, height];
|
||||
};
|
||||
|
||||
@@ -466,7 +466,7 @@ export const Choices = defineComponent<
|
||||
contentHeight.value = height;
|
||||
};
|
||||
|
||||
const updateTitleHeight = (_: number, height: number) => {
|
||||
const updateTitleHeight = (_0: unknown, _1: unknown, height: number) => {
|
||||
titleHeight.value = height;
|
||||
};
|
||||
|
||||
@@ -563,7 +563,7 @@ export const Choices = defineComponent<
|
||||
zIndex={5}
|
||||
fillStyle={props.selFill}
|
||||
onClick={() => emit('choose', v[0])}
|
||||
onResize={(width, height) =>
|
||||
onResize={(_, width, height) =>
|
||||
updateChoiceSize(i, width, height)
|
||||
}
|
||||
onEnter={() => (selected.value = i)}
|
||||
|
||||
@@ -2,7 +2,13 @@ import { SetupComponentOptions } from '@motajs/system';
|
||||
import { computed, defineComponent, ref, watch } from 'vue';
|
||||
import { Font } from '@motajs/render';
|
||||
import { ITileLocator } from '@motajs/common';
|
||||
import { adjustGrid2, TextAlign, TextContent } from '@user/client-base';
|
||||
import {
|
||||
adjustGrid2,
|
||||
Icon,
|
||||
ITextureManager,
|
||||
TextAlign,
|
||||
TextContent
|
||||
} from '@user/client-base';
|
||||
import {
|
||||
IDamageSystem,
|
||||
IEnemyView,
|
||||
@@ -27,11 +33,13 @@ export interface IEnemyOneProps extends DefaultProps {
|
||||
computed?: boolean;
|
||||
/** 当前行是否处于选中态 */
|
||||
selected?: boolean;
|
||||
/** 素材管理器 */
|
||||
materials?: ITextureManager;
|
||||
}
|
||||
|
||||
/** 怪物主信息组件的 props 声明 */
|
||||
const enemyOneProps = {
|
||||
props: ['enemy', 'view', 'selected', 'loc', 'width', 'height']
|
||||
props: ['enemy', 'view', 'selected', 'loc', 'width', 'height', 'materials']
|
||||
} satisfies SetupComponentOptions<IEnemyOneProps>;
|
||||
|
||||
/** 怪物图标尺寸 */
|
||||
@@ -266,8 +274,9 @@ export const EnemyOne = defineComponent<IEnemyOneProps>(props => {
|
||||
lineWidth={1.5}
|
||||
noevent
|
||||
/>
|
||||
<icon
|
||||
<Icon
|
||||
icon={enemy.value?.code ?? 0}
|
||||
manager={props.materials}
|
||||
loc={[ICON_CENTER, height.value / 2, ICON_SIZE, ICON_SIZE]}
|
||||
anc={[0.5, 0.5]}
|
||||
noevent
|
||||
|
||||
@@ -3,7 +3,7 @@ import { computed, defineComponent, ref } from 'vue';
|
||||
import { isNil } from 'lodash-es';
|
||||
import { Font } from '@motajs/render';
|
||||
import { ElementLocator, IActionEvent } from '@motajs/render';
|
||||
import { Scroll, TextContent, useKey } from '@user/client-base';
|
||||
import { Icon, Scroll, TextContent, useKey } from '@user/client-base';
|
||||
import { EquipStatus, IEquipmentState, IHeroState } from '@user/data-base';
|
||||
import { IHeroAttr } from '@user/data-common';
|
||||
import { FULL_LOC, MAIN_HEIGHT, MAIN_WIDTH } from '@/client';
|
||||
@@ -472,8 +472,9 @@ export const EquipBox = defineComponent<EquipBoxProps>(props => {
|
||||
onLeave={getSlotLeave(i)}
|
||||
/>,
|
||||
// 拖动起手仍只在图标上,整格只负责悬停判定
|
||||
<icon
|
||||
<Icon
|
||||
icon={slotEquip ? slotEquip.item.num : 0}
|
||||
manager={props.state.materials}
|
||||
loc={slotIconLoc}
|
||||
cursor="pointer"
|
||||
onEnter={getSlotEnter(i)}
|
||||
@@ -530,8 +531,9 @@ export const EquipBox = defineComponent<EquipBoxProps>(props => {
|
||||
cursor="pointer"
|
||||
onDown={getOwnedDown(item.uid)}
|
||||
/>,
|
||||
<icon
|
||||
<Icon
|
||||
icon={item.item.num}
|
||||
manager={props.state.materials}
|
||||
loc={ownedIconLoc}
|
||||
noevent
|
||||
/>,
|
||||
@@ -559,8 +561,9 @@ export const EquipBox = defineComponent<EquipBoxProps>(props => {
|
||||
/>
|
||||
|
||||
{/* 拖拽浮层 */}
|
||||
<icon
|
||||
<Icon
|
||||
icon={dragNum.value > 0 ? dragNum.value : 0}
|
||||
manager={props.state.materials}
|
||||
loc={dragLoc}
|
||||
noevent
|
||||
zIndex={100}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export * from './background';
|
||||
export * from '../../../packages-user/client-base/src/components/background';
|
||||
export * from './book';
|
||||
export * from './bookDetail';
|
||||
export * from './equipbox';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ElementLocator, Font } from '@motajs/render';
|
||||
import { GameUI, IUIController, SetupComponentOptions } from '@motajs/system';
|
||||
import { computed, defineComponent, ref } from 'vue';
|
||||
import { Background } from './background';
|
||||
import { Background } from '../../../packages-user/client-base/src/components/background';
|
||||
import {
|
||||
Input,
|
||||
InputEmits,
|
||||
@@ -173,11 +173,11 @@ export const InputBox = defineComponent<
|
||||
emit('input', value);
|
||||
};
|
||||
|
||||
const setYes = (width: number, height: number) => {
|
||||
const setYes = (_: unknown, width: number, height: number) => {
|
||||
yesSize.value = [width, height];
|
||||
};
|
||||
|
||||
const setNo = (width: number, height: number) => {
|
||||
const setNo = (_: unknown, width: number, height: number) => {
|
||||
noSize.value = [width, height];
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DefaultProps } from '@motajs/render-vue';
|
||||
import { DefaultProps, transitioned } from '@motajs/render-vue';
|
||||
import { GameUI, SetupComponentOptions } from '@motajs/system';
|
||||
import { defineComponent } from 'vue';
|
||||
import { FULL_LOC, MAIN_HEIGHT, MAIN_WIDTH } from '@/client';
|
||||
@@ -7,7 +7,6 @@ import { cosh, CurveMode, linear } from '@motajs/animate';
|
||||
import { clamp } from 'lodash-es';
|
||||
import { sleep } from '@motajs/common';
|
||||
import { GameTitleUI } from './title';
|
||||
import { transitioned } from '@user/client-modules';
|
||||
import { IGameUIPropsBase } from '@user/client-base';
|
||||
|
||||
/** 加载界面的任务进度条半径 */
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Font, MotaOffscreenCanvas2D, CustomRenderItem } from '@motajs/render';
|
||||
import { defineComponent, ref } from 'vue';
|
||||
import {
|
||||
IGameUIPropsBase,
|
||||
MapText,
|
||||
Textbox,
|
||||
TextboxProps,
|
||||
Tip
|
||||
@@ -20,8 +21,7 @@ import {
|
||||
} from '@/client';
|
||||
import { LeftStatusBar, RightStatusBar } from './statusBar';
|
||||
import { isNil } from 'lodash-es';
|
||||
import { using } from '@user/client-modules';
|
||||
import { DefaultProps } from '@motajs/render-vue';
|
||||
import { DefaultProps, onExcitedFunc } from '@motajs/render-vue';
|
||||
|
||||
interface MainSceneProps extends IGameUIPropsBase, DefaultProps {}
|
||||
|
||||
@@ -31,7 +31,6 @@ const mainSceneProps = {
|
||||
|
||||
const MainScene = defineComponent<MainSceneProps>(props => {
|
||||
const mainMapRenderer = props.state.mainMapRenderer;
|
||||
const mainMapExtension = props.state.mainMapExtension;
|
||||
|
||||
//#region 基本定义
|
||||
|
||||
@@ -60,7 +59,7 @@ const MainScene = defineComponent<MainSceneProps>(props => {
|
||||
//#region sprite 渲染
|
||||
|
||||
let lastLength = 0;
|
||||
using.onExcitedFunc(() => {
|
||||
onExcitedFunc(() => {
|
||||
const len = core.status.stepPostfix?.length ?? 0;
|
||||
if (len !== lastLength) {
|
||||
mapMiscSprite.value?.update();
|
||||
@@ -123,9 +122,10 @@ const MainScene = defineComponent<MainSceneProps>(props => {
|
||||
renderer={mainMapRenderer}
|
||||
// @ts-expect-error 需要重构
|
||||
layerState={state.maps}
|
||||
extension={mainMapExtension}
|
||||
loc={[0, 0, MAP_WIDTH, MAP_HEIGHT]}
|
||||
/>
|
||||
>
|
||||
<MapText />
|
||||
</map-render>
|
||||
<Textbox id="main-textbox" {...mainTextboxProps}></Textbox>
|
||||
{/* <FloorChange id="floor-change" zIndex={50}></FloorChange> */}
|
||||
<Tip
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
shallowReactive
|
||||
} from 'vue';
|
||||
import {
|
||||
getConfirm,
|
||||
Page,
|
||||
PageExpose,
|
||||
Thumbnail,
|
||||
@@ -20,7 +19,7 @@ import {
|
||||
} from '@user/client-base';
|
||||
import { HALF_HEIGHT, HALF_WIDTH, MAP_WIDTH, POP_BOX_WIDTH } from '@/client';
|
||||
import { adjustGrid, IGridLayoutData } from '@user/client-base';
|
||||
import { getSave, SaveData } from '@user/client-modules';
|
||||
import { getConfirm } from './choices';
|
||||
|
||||
/** 存档缩略图尺寸 */
|
||||
export const SAVE_ITEM_SIZE = MAP_BLOCK_WIDTH * 10;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { IClientCore } from '@user/client-modules';
|
||||
import { defineComponent } from 'vue';
|
||||
import { MAIN_HEIGHT, MAIN_WIDTH } from '../uiConstant';
|
||||
import { UIComponent } from '@motajs/system';
|
||||
|
||||
export function createRendererScene(state: IClientCore): UIComponent {
|
||||
return defineComponent(() => {
|
||||
return () => (
|
||||
<container width={MAIN_WIDTH} height={MAIN_HEIGHT}>
|
||||
{state.sceneController.render()}
|
||||
</container>
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
import { DefaultProps } from '@motajs/render-vue';
|
||||
import {
|
||||
DefaultProps,
|
||||
ITransitionedController,
|
||||
transitioned,
|
||||
transitionedColor
|
||||
} from '@motajs/render-vue';
|
||||
import { GameUI, SetupComponentOptions } from '@motajs/system';
|
||||
import { defineComponent, nextTick, onMounted, ref } from 'vue';
|
||||
import { HALF_HEIGHT, HALF_WIDTH, MAIN_HEIGHT, MAIN_WIDTH } from '@/client';
|
||||
@@ -16,11 +21,6 @@ import { MainSceneUI } from './main';
|
||||
import { adjustCover } from '@user/client-base';
|
||||
import { cosh, CurveMode, linear } from '@motajs/animate';
|
||||
import { sleep } from '@motajs/common';
|
||||
import {
|
||||
ITransitionedController,
|
||||
transitioned,
|
||||
transitionedColor
|
||||
} from '@user/client-modules';
|
||||
|
||||
/** 标题图 */
|
||||
export const TITLE_BACKGROUND_IMAGE = 'bg.jpg';
|
||||
|
||||
@@ -18,8 +18,8 @@ import { saveSave, saveLoad } from './save';
|
||||
import { MAIN_HEIGHT, FULL_LOC, POP_BOX_WIDTH, CENTER_LOC } from '@/client';
|
||||
import { openReplay, openSettings } from './settings';
|
||||
import { openViewMap } from './viewmap';
|
||||
import { DefaultProps } from '@motajs/render-vue';
|
||||
import { IClientCoreExtended, transitioned } from '@user/client-modules';
|
||||
import { DefaultProps, transitioned } from '@motajs/render-vue';
|
||||
import { IClientCoreExtended } from '@user/client-modules';
|
||||
|
||||
interface ToolbarProps extends DefaultProps, IClientCoreExtended {
|
||||
loc?: ElementLocator;
|
||||
|
||||
@@ -2,6 +2,7 @@ import { GameUI, SetupComponentOptions } from '@motajs/system';
|
||||
import { computed, defineComponent, nextTick, onUnmounted, ref } from 'vue';
|
||||
import { ElementLocator, Font } from '@motajs/render';
|
||||
import {
|
||||
Icon,
|
||||
IGameUIPropsBase,
|
||||
Scroll,
|
||||
TextContent,
|
||||
@@ -251,8 +252,9 @@ export const ToolBox = defineComponent<ToolBoxProps>(props => {
|
||||
cursor="pointer"
|
||||
onClick={getItemClick(item, 'permanent')}
|
||||
/>,
|
||||
<icon
|
||||
<Icon
|
||||
icon={item.num}
|
||||
manager={props.state.materials}
|
||||
loc={[10, y + 7, ROW_ICON_SIZE, ROW_ICON_SIZE]}
|
||||
noevent
|
||||
/>,
|
||||
@@ -303,8 +305,9 @@ export const ToolBox = defineComponent<ToolBoxProps>(props => {
|
||||
cursor="pointer"
|
||||
onClick={getItemClick(item, 'consumable')}
|
||||
/>,
|
||||
<icon
|
||||
<Icon
|
||||
icon={item.num}
|
||||
manager={props.state.materials}
|
||||
loc={[10, y + 7, ROW_ICON_SIZE, ROW_ICON_SIZE]}
|
||||
noevent
|
||||
/>,
|
||||
@@ -328,8 +331,9 @@ export const ToolBox = defineComponent<ToolBoxProps>(props => {
|
||||
})}
|
||||
</Scroll>
|
||||
{/* 详情图标、名称与类型 */}
|
||||
<icon
|
||||
<Icon
|
||||
icon={current ? current.num : 0}
|
||||
manager={props.state.materials}
|
||||
loc={[INFO_LEFT + 8, 8, DETAIL_ICON_SIZE, DETAIL_ICON_SIZE]}
|
||||
noevent
|
||||
hidden={!current}
|
||||
|
||||
@@ -2,7 +2,10 @@ import { logger } from '@motajs/common';
|
||||
import { ElementLocator } from '@motajs/render';
|
||||
import { GameUI, IUIController, SetupComponentOptions } from '@motajs/system';
|
||||
import { computed, defineComponent, ref, SetupContext } from 'vue';
|
||||
import { Background, BackgroundProps } from './background';
|
||||
import {
|
||||
Background,
|
||||
BackgroundProps
|
||||
} from '../../../packages-user/client-base/src/components/background';
|
||||
import {
|
||||
TextContent,
|
||||
TextContentProps,
|
||||
|
||||
Reference in new issue
Block a user