mirror of
https://github.com/motajs/template.git
synced 2026-12-01 19:34: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
@@ -0,0 +1,65 @@
|
||||
import { DefaultProps } from '@motajs/render-vue';
|
||||
import { SetupComponentOptions } from '@motajs/system';
|
||||
import { computed, defineComponent, markRaw } from 'vue';
|
||||
import { IMaterialFramedData, ITextureManager } from '../material';
|
||||
import { isNil } from 'lodash-es';
|
||||
import { ITexture, TextureRowAnimater } from '@motajs/render';
|
||||
|
||||
export interface IIconProps extends DefaultProps {
|
||||
/** 当前显示的图标 */
|
||||
icon?: number | string;
|
||||
/** 贴图管理器 */
|
||||
manager?: ITextureManager;
|
||||
/** 是否播放图块动画 */
|
||||
animate?: boolean;
|
||||
/** 展示图块指定帧数的动画,传入时会忽略 `animate` 的动画 */
|
||||
frame?: number;
|
||||
}
|
||||
|
||||
const iconProps = {
|
||||
props: ['icon', 'manager', 'animate', 'frame'],
|
||||
emits: ['change', 'input', 'update:value']
|
||||
} satisfies SetupComponentOptions<IIconProps>;
|
||||
|
||||
export const Icon = defineComponent<IIconProps>(props => {
|
||||
const animater = markRaw(new TextureRowAnimater());
|
||||
|
||||
/** 图块的渲染数据 */
|
||||
const data = computed<IMaterialFramedData | null>(() => {
|
||||
if (!props.manager) return null;
|
||||
const icon = props.icon ?? 0;
|
||||
if (typeof icon === 'number') {
|
||||
return props.manager.getTile(icon);
|
||||
} else {
|
||||
return props.manager.getTileByAlias(icon);
|
||||
}
|
||||
});
|
||||
/** 图块的完整贴图 */
|
||||
const texture = computed<ITexture | null>(
|
||||
() => data.value?.texture ?? null
|
||||
);
|
||||
/** 是否播放图块动画 */
|
||||
const animate = computed<boolean>(() => {
|
||||
const frames = data.value?.frames ?? 1;
|
||||
return isNil(props.frame) && !!props.animate && frames > 1;
|
||||
});
|
||||
/** 当不播放图块动画时,静态使用的贴图 */
|
||||
const staticImage = computed<ITexture | null>(() => {
|
||||
if (!animate.value || !data.value) return null;
|
||||
const frame = props.frame ?? data.value.defaultFrame;
|
||||
const o = data.value.offset * frame;
|
||||
const tex = data.value.texture;
|
||||
return tex.clip({ x: o, y: 0, w: o, h: tex.height });
|
||||
});
|
||||
|
||||
return () =>
|
||||
animate.value ? (
|
||||
<animated
|
||||
texture={texture.value}
|
||||
animater={animater}
|
||||
param={data.value?.offset}
|
||||
></animated>
|
||||
) : (
|
||||
<image image={staticImage.value}></image>
|
||||
);
|
||||
}, iconProps);
|
||||
@@ -1,4 +1,6 @@
|
||||
export * from './background';
|
||||
export * from './floorSelect';
|
||||
export * from './icon';
|
||||
export * from './icons';
|
||||
export * from './input';
|
||||
export * from './list';
|
||||
|
||||
@@ -2,13 +2,11 @@ import {
|
||||
ElementLocator,
|
||||
Font,
|
||||
CustomRenderItem,
|
||||
Text,
|
||||
MotaOffscreenCanvas2D
|
||||
} from '@motajs/render';
|
||||
import {
|
||||
computed,
|
||||
defineComponent,
|
||||
nextTick,
|
||||
onMounted,
|
||||
onUnmounted,
|
||||
ref,
|
||||
@@ -32,6 +30,7 @@ import {
|
||||
import { SetupComponentOptions } from '@motajs/system';
|
||||
import { texture } from '../elements';
|
||||
import { DefaultProps, onExcited } from '@motajs/render-vue';
|
||||
import { Icon } from './icon';
|
||||
|
||||
// todo: TextContent 应该改成渲染元素?
|
||||
|
||||
@@ -526,7 +525,8 @@ export const Textbox = defineComponent<
|
||||
></g-rect>
|
||||
)}
|
||||
{hasIcon.value && (
|
||||
<icon icon={data.icon as AllIds} loc={iconLoc.value} animate />
|
||||
// TODO: manager
|
||||
<Icon icon={data.icon} loc={iconLoc.value} animate />
|
||||
)}
|
||||
{hasIcon.value && (
|
||||
<g-rect
|
||||
|
||||
@@ -6,6 +6,7 @@ import { debounce } from 'lodash-es';
|
||||
import { texture } from '../elements';
|
||||
import { SetupComponentOptions } from '@motajs/system';
|
||||
import { DefaultProps, transitioned } from '@motajs/render-vue';
|
||||
import { Icon } from './icon';
|
||||
|
||||
export interface TipProps extends DefaultProps {
|
||||
/** 显示的位置 */
|
||||
@@ -105,7 +106,7 @@ export const Tip = defineComponent<TipProps>((props, { expose }) => {
|
||||
hide();
|
||||
};
|
||||
|
||||
const onSetText = (width: number) => {
|
||||
const onSetText = (_: unknown, width: number) => {
|
||||
textWidth.value = width;
|
||||
};
|
||||
|
||||
@@ -128,9 +129,10 @@ export const Tip = defineComponent<TipProps>((props, { expose }) => {
|
||||
fill
|
||||
fillStyle="rgba(0,0,0,0.8)"
|
||||
/>
|
||||
<icon
|
||||
hidden={!showIcon.value}
|
||||
<Icon
|
||||
icon={iconNum.value}
|
||||
// TODO: manager
|
||||
hidden={!showIcon.value}
|
||||
loc={iconLoc.value}
|
||||
/>
|
||||
<text
|
||||
|
||||
@@ -486,19 +486,3 @@ function splitAutotiles(map: IdToNumber): AutotileCaches {
|
||||
|
||||
return cache as AutotileCaches;
|
||||
}
|
||||
|
||||
export function createCache() {
|
||||
const { loading } = Mota.require('@user/data-base');
|
||||
loading.once('loaded', () => {
|
||||
[
|
||||
'enemys',
|
||||
'enemy48',
|
||||
'npcs',
|
||||
'npc48',
|
||||
'terrains',
|
||||
'items',
|
||||
'animates'
|
||||
].forEach(v => (imageMap[v as ImageMapKeys] = i(v as ImageMapKeys)));
|
||||
texture.init();
|
||||
});
|
||||
}
|
||||
@@ -1,173 +1,10 @@
|
||||
import { logger } from '@motajs/common';
|
||||
import {
|
||||
RenderItem,
|
||||
MotaOffscreenCanvas2D,
|
||||
Transform,
|
||||
SizedCanvasImageSource
|
||||
} from '@motajs/render';
|
||||
import { isNil } from 'lodash-es';
|
||||
import { RenderableData, AutotileRenderable, texture } from './cache';
|
||||
import { IExcitable } from '@motajs/animate';
|
||||
import { IMotaIcon, IMotaWinskin } from './types';
|
||||
|
||||
export class Icon extends RenderItem implements IMotaIcon, IExcitable<number> {
|
||||
/** 图标id */
|
||||
icon: AllNumbers = 0;
|
||||
/** 渲染动画的第几帧 */
|
||||
frame: number = 0;
|
||||
/** 是否启用动画 */
|
||||
animate: boolean = false;
|
||||
/** 当前动画速度 */
|
||||
frameSpeed: number = 300;
|
||||
/** 当前帧率 */
|
||||
nowFrame: number = 0;
|
||||
|
||||
/** 图标的渲染信息 */
|
||||
private renderable?: RenderableData | AutotileRenderable;
|
||||
|
||||
private pendingIcon?: AllNumbers;
|
||||
|
||||
/** 委托激励对象 id,用于图标的动画展示 */
|
||||
private delegation: number = -1;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.setAntiAliasing(false);
|
||||
this.setHD(false);
|
||||
}
|
||||
|
||||
protected getDefaultCache(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
excited(payload: number): void {
|
||||
if (!this.renderable) return;
|
||||
const frame = Math.floor(payload / 300);
|
||||
if (frame === this.nowFrame) return;
|
||||
this.nowFrame = frame;
|
||||
this.update();
|
||||
}
|
||||
|
||||
protected render(
|
||||
canvas: MotaOffscreenCanvas2D,
|
||||
_transform: Transform
|
||||
): void {
|
||||
const ctx = canvas.ctx;
|
||||
const renderable = this.renderable;
|
||||
if (!renderable) return;
|
||||
const [x, y, w, h] = renderable.render[0];
|
||||
const cw = this.width;
|
||||
const ch = this.height;
|
||||
const frame = this.animate
|
||||
? this.nowFrame % renderable.frame
|
||||
: this.frame;
|
||||
|
||||
if (!this.animate) {
|
||||
if (renderable.autotile) {
|
||||
ctx.drawImage(renderable.image[0], x, y, w, h, 0, 0, cw, ch);
|
||||
} else {
|
||||
ctx.drawImage(renderable.image, x, y, w, h, 0, 0, cw, ch);
|
||||
}
|
||||
} else {
|
||||
const [x1, y1, w1, h1] = renderable.render[frame];
|
||||
if (renderable.autotile) {
|
||||
const img = renderable.image[0];
|
||||
ctx.drawImage(img, x1, y1, w1, h1, 0, 0, cw, ch);
|
||||
} else {
|
||||
ctx.drawImage(renderable.image, x1, y1, w1, h1, 0, 0, cw, ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置图标
|
||||
* @param id 图标id
|
||||
*/
|
||||
setIcon(id: AllIdsWithNone | AllNumbers) {
|
||||
if (id === 0 || id === 'none') {
|
||||
this.renderable = void 0;
|
||||
return;
|
||||
}
|
||||
const num = typeof id === 'number' ? id : texture.idNumberMap[id];
|
||||
|
||||
const { loading } = Mota.require('@user/data-base');
|
||||
if (loading.loaded) {
|
||||
this.setIconRenderable(num);
|
||||
} else {
|
||||
if (isNil(this.pendingIcon)) {
|
||||
loading.once('loaded', () => {
|
||||
this.setIconRenderable(this.pendingIcon ?? 0);
|
||||
delete this.pendingIcon;
|
||||
});
|
||||
}
|
||||
this.pendingIcon = num;
|
||||
}
|
||||
}
|
||||
|
||||
setFrameSpeed(speed: number): void {
|
||||
this.frameSpeed = speed;
|
||||
this.update();
|
||||
}
|
||||
|
||||
setFrame(frame: number): void {
|
||||
if (frame < 0) {
|
||||
this.setAnimateStatus(true);
|
||||
return;
|
||||
}
|
||||
this.frame = frame;
|
||||
this.update();
|
||||
}
|
||||
|
||||
setAnimateStatus(animate: boolean): void {
|
||||
this.animate = animate;
|
||||
// if (!animate) this.removeExcitable(this.delegation);
|
||||
// else this.delegation = this.delegateExcitable(this);
|
||||
this.update();
|
||||
}
|
||||
|
||||
private setIconRenderable(num: AllNumbers) {
|
||||
const renderable = texture.getRenderable(num);
|
||||
|
||||
if (!renderable) {
|
||||
logger.warn(43, num.toString());
|
||||
return;
|
||||
} else {
|
||||
this.icon = num;
|
||||
this.renderable = renderable;
|
||||
this.frame = renderable.frame;
|
||||
}
|
||||
this.update();
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
protected handleProps(
|
||||
key: string,
|
||||
_prevValue: any,
|
||||
nextValue: any
|
||||
): boolean {
|
||||
switch (key) {
|
||||
case 'icon':
|
||||
this.setIcon(nextValue);
|
||||
return true;
|
||||
case 'animate':
|
||||
if (!this.assertType(nextValue, 'boolean', key)) return false;
|
||||
this.setAnimateStatus(nextValue);
|
||||
return true;
|
||||
case 'frame':
|
||||
if (!this.assertType(nextValue, 'number', key)) return false;
|
||||
this.setFrame(nextValue);
|
||||
return true;
|
||||
case 'speed':
|
||||
if (!this.assertType(nextValue, 'number', key)) return false;
|
||||
this.setFrameSpeed(nextValue);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
import { IMotaWinskin } from './types';
|
||||
|
||||
export class Winskin extends RenderItem implements IMotaWinskin {
|
||||
image: SizedCanvasImageSource | null = null;
|
||||
|
||||
@@ -3,17 +3,6 @@ import { IRenderItemBaseHooks, SizedCanvasImageSource } from '@motajs/render';
|
||||
import { IGameMap } from '@user/data-base';
|
||||
import { IMapRenderer } from '../map';
|
||||
|
||||
export interface IconProps extends BaseProps {
|
||||
/** 图标 id 或数字 */
|
||||
icon: AllNumbers | AllIds;
|
||||
/** 显示图标的第几帧 */
|
||||
frame?: number;
|
||||
/** 是否开启动画,开启后 frame 参数无效 */
|
||||
animate?: boolean;
|
||||
/** 动画速度 */
|
||||
speed?: number;
|
||||
}
|
||||
|
||||
export interface WinskinProps extends BaseProps {
|
||||
/** 直接设置 winskin 图片 */
|
||||
image?: SizedCanvasImageSource;
|
||||
@@ -31,7 +20,6 @@ export interface MapRenderProps extends BaseProps {
|
||||
declare module 'vue/jsx-runtime' {
|
||||
namespace JSX {
|
||||
export interface IntrinsicElements {
|
||||
icon: TagDefine<IconProps, IRenderItemBaseHooks>;
|
||||
winskin: TagDefine<WinskinProps, IRenderItemBaseHooks>;
|
||||
'map-render': TagDefine<MapRenderProps, IRenderItemBaseHooks>;
|
||||
}
|
||||
|
||||
@@ -1,42 +1,5 @@
|
||||
import { IRenderItem, SizedCanvasImageSource } from '@motajs/render';
|
||||
|
||||
export interface IMotaIcon extends IRenderItem {
|
||||
/** 图标id */
|
||||
readonly icon: AllNumbers;
|
||||
/** 渲染动画的第几帧 */
|
||||
readonly frame: number;
|
||||
/** 是否启用动画 */
|
||||
readonly animate: boolean;
|
||||
/** 当前动画帧数,如果没有启用动画则为 -1 */
|
||||
readonly nowFrame: number;
|
||||
/** 当前图标的动画速度,每多长时间切换至下一帧,单位毫秒 */
|
||||
readonly frameSpeed: number;
|
||||
|
||||
/**
|
||||
* 设置图标
|
||||
* @param id 图标id
|
||||
*/
|
||||
setIcon(id: AllIdsWithNone | AllNumbers): void;
|
||||
|
||||
/**
|
||||
* 设置当前图标的帧动画速度,单位毫秒
|
||||
* @param speed 帧动画速度
|
||||
*/
|
||||
setFrameSpeed(speed: number): void;
|
||||
|
||||
/**
|
||||
* 设置当前图标是否启用帧动画
|
||||
* @param animate 是否启用帧动画
|
||||
*/
|
||||
setAnimateStatus(animate: boolean): void;
|
||||
|
||||
/**
|
||||
* 设置图标显示第几帧,如果传入负数视为启用帧动画
|
||||
* @param frame 显示图标的第几帧
|
||||
*/
|
||||
setFrame(frame: number): void;
|
||||
}
|
||||
|
||||
export interface IMotaWinskin extends IRenderItem {
|
||||
/** winskin 图片源 */
|
||||
readonly image: SizedCanvasImageSource | null;
|
||||
|
||||
@@ -2,9 +2,11 @@ import {
|
||||
ActionEventMap,
|
||||
ActionType,
|
||||
EventProgress,
|
||||
IRenderItemBaseHooks,
|
||||
IRenderTreeRoot,
|
||||
MotaOffscreenCanvas2D,
|
||||
RenderItem,
|
||||
RenderItemDefaultHooks,
|
||||
Transform
|
||||
} from '@motajs/render';
|
||||
import { mat3 } from 'gl-matrix';
|
||||
@@ -39,6 +41,10 @@ export class MapRenderItem extends RenderItem implements IMapRenderItem {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected getDefaultHook(): IRenderItemBaseHooks {
|
||||
return new RenderItemDefaultHooks(this.events);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重设 WebGL2 画布的宽高
|
||||
* @param width 宽度
|
||||
|
||||
@@ -10,14 +10,13 @@ import {
|
||||
TileType
|
||||
} from '@user/data-common';
|
||||
import { IHeroLocation, IHeroLocationHooks, IMapLayer } from '@user/data-base';
|
||||
import { IMapRenderer, IMapRendererTicker, IMovingBlock } from '../types';
|
||||
import { IMapRenderer } from '../types';
|
||||
import { isNil } from 'lodash-es';
|
||||
import { IFaceHandler, IHookController, logger } from '@motajs/common';
|
||||
import { IMaterialFramedData } from '@user/client-base';
|
||||
import { ITexture, ITextureSplitter, TextureRowSplitter } from '@motajs/render';
|
||||
import { IMapHeroRenderer } from './types';
|
||||
import { ExcitationCurve2D } from '@motajs/animate';
|
||||
import { state } from '@user/data-state';
|
||||
|
||||
/** 默认的移动时长 */
|
||||
const DEFAULT_TIME = 100;
|
||||
|
||||
@@ -9,16 +9,12 @@ import { IMapRenderer } from '../types';
|
||||
import { MapHeroRenderer } from './hero';
|
||||
import { logger } from '@motajs/common';
|
||||
import { MapDoorRenderer } from './door';
|
||||
import { OnMapTextRenderer } from './text';
|
||||
import { IOnMapTextRenderer } from './types';
|
||||
|
||||
export class MapExtensionManager implements IMapExtensionManager {
|
||||
/** 勇士状态至勇士渲染器的映射 */
|
||||
readonly heroMap: Map<IHeroLocation, IMapHeroRenderer> = new Map();
|
||||
/** 地图图层到门渲染器的映射 */
|
||||
readonly doorMap: Map<IMapLayer, IMapDoorRenderer> = new Map();
|
||||
/** 单例的文字渲染拓展(独立图层) */
|
||||
textRenderer: IOnMapTextRenderer | null = null;
|
||||
|
||||
constructor(readonly renderer: IMapRenderer) {}
|
||||
|
||||
@@ -58,22 +54,6 @@ export class MapExtensionManager implements IMapExtensionManager {
|
||||
return doorRenderer;
|
||||
}
|
||||
|
||||
addText(): IOnMapTextRenderer | null {
|
||||
if (this.textRenderer) {
|
||||
logger.error(45, 'on-map text renderer');
|
||||
return null;
|
||||
}
|
||||
const r = new OnMapTextRenderer(this.renderer);
|
||||
this.textRenderer = r;
|
||||
return r;
|
||||
}
|
||||
|
||||
removeText(): void {
|
||||
if (!this.textRenderer) return;
|
||||
this.textRenderer.destroy();
|
||||
this.textRenderer = null;
|
||||
}
|
||||
|
||||
removeDoor(layer: IMapLayer): void {
|
||||
const renderer = this.doorMap.get(layer);
|
||||
if (!renderer) return;
|
||||
@@ -86,7 +66,5 @@ export class MapExtensionManager implements IMapExtensionManager {
|
||||
this.doorMap.forEach(v => void v.destroy());
|
||||
this.heroMap.clear();
|
||||
this.doorMap.clear();
|
||||
this.textRenderer?.destroy();
|
||||
this.textRenderer = null;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ export * from './chunk';
|
||||
export * from './constant';
|
||||
export * from './element';
|
||||
export * from './mapText';
|
||||
export * from './moving';
|
||||
export * from './renderer';
|
||||
export * from './status';
|
||||
export * from './types';
|
||||
|
||||
@@ -41,6 +41,7 @@ import {
|
||||
} from '@motajs/animate';
|
||||
import { IUIController, UIController } from '@motajs/system';
|
||||
import { createUIPropsBase } from './ui/func';
|
||||
import { markRaw } from 'vue';
|
||||
|
||||
export class ClientCore extends CoreState implements IClientCore {
|
||||
// Layer 4 渲染基础层
|
||||
@@ -68,29 +69,29 @@ export class ClientCore extends CoreState implements IClientCore {
|
||||
constructor(config: IClientCoreConfig) {
|
||||
super(config);
|
||||
|
||||
this.save = new SaveSystem();
|
||||
this.audioContext = new MotaAudioContext();
|
||||
this.soundPlayer = new SoundPlayer(this.audioContext);
|
||||
this.bgmPlayer = new BGMPlayer(this.audioContext);
|
||||
this.materials = new TextureManager(
|
||||
this,
|
||||
config.tilesetReserve,
|
||||
config.tilesetUnit
|
||||
this.save = markRaw(new SaveSystem());
|
||||
this.audioContext = markRaw(new MotaAudioContext());
|
||||
this.soundPlayer = markRaw(new SoundPlayer(this.audioContext));
|
||||
this.bgmPlayer = markRaw(new BGMPlayer(this.audioContext));
|
||||
this.materials = markRaw(
|
||||
new TextureManager(this, config.tilesetReserve, config.tilesetUnit)
|
||||
);
|
||||
this.hotkey = new ClientHotkey();
|
||||
this.hotkey = markRaw(new ClientHotkey());
|
||||
|
||||
this.rafExcitation = new RafExcitation();
|
||||
this.excitationDivider = new ExcitationDivider<number>();
|
||||
this.rafExcitation = markRaw(new RafExcitation());
|
||||
this.excitationDivider = markRaw(new ExcitationDivider<number>());
|
||||
|
||||
this.renderer = new MotaRenderer({
|
||||
canvas: '#render-main',
|
||||
width: config.renderWidth,
|
||||
height: config.renderHeight,
|
||||
// 使用分频器,用户可以在设置中调整,如果设备性能较差调高分频有助于提高性能表现
|
||||
excitaion: this.excitationDivider
|
||||
});
|
||||
this.mainMapRenderer = new MapRenderer(this.materials);
|
||||
this.expandMapRenderer = new MapRenderer(this.materials);
|
||||
this.renderer = markRaw(
|
||||
new MotaRenderer({
|
||||
canvas: '#render-main',
|
||||
width: config.renderWidth,
|
||||
height: config.renderHeight,
|
||||
// 使用分频器,用户可以在设置中调整,如果设备性能较差调高分频有助于提高性能表现
|
||||
excitaion: this.excitationDivider
|
||||
})
|
||||
);
|
||||
this.mainMapRenderer = markRaw(new MapRenderer(this.materials));
|
||||
this.expandMapRenderer = markRaw(new MapRenderer(this.materials));
|
||||
this.sceneController = new UIController<IGameUIPropsBase>();
|
||||
this.mainUIController = new UIController<IGameUIPropsBase>();
|
||||
const pbCreator = createUIPropsBase(this);
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
import { createRender } from './render';
|
||||
|
||||
export function create() {
|
||||
createRender();
|
||||
}
|
||||
|
||||
export * from './action';
|
||||
export * from './render';
|
||||
export * from './ui';
|
||||
|
||||
@@ -1,9 +1,2 @@
|
||||
import { createElements } from '@user/client-base';
|
||||
|
||||
export function createRender() {
|
||||
createElements();
|
||||
}
|
||||
|
||||
export * from './fx';
|
||||
export * from './utils';
|
||||
export * from './weather';
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './saves';
|
||||
export * from './use';
|
||||
@@ -1,198 +0,0 @@
|
||||
// TODO: 需要换用新的接口,且需要做网络存档支持
|
||||
|
||||
// import { compressToBase64, decompressFromBase64 } from 'lz-string';
|
||||
// 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';
|
||||
|
||||
// export interface SaveData {
|
||||
// name: string;
|
||||
// version: string;
|
||||
// data: Save;
|
||||
// }
|
||||
|
||||
// export interface SaveDataArray {
|
||||
// name: string;
|
||||
// version: string;
|
||||
// data: Save[];
|
||||
// }
|
||||
|
||||
// export function getSave(index: number) {
|
||||
// return new Promise<SaveData | null>(res => {
|
||||
// core.getSave(index, data => {
|
||||
// if (!data) {
|
||||
// res(null);
|
||||
// return;
|
||||
// }
|
||||
// const content = {
|
||||
// name: core.firstData.name,
|
||||
// version: core.firstData.version,
|
||||
// data: data instanceof Array ? data.at(-1)! : data
|
||||
// };
|
||||
// res(content);
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
|
||||
// export function getAllSaves() {
|
||||
// return new Promise<SaveDataArray | null>(res => {
|
||||
// core.getAllSaves(saves => {
|
||||
// if (!saves) {
|
||||
// res(null);
|
||||
// return;
|
||||
// }
|
||||
// const content = {
|
||||
// name: core.firstData.name,
|
||||
// version: core.firstData.version,
|
||||
// data: saves
|
||||
// };
|
||||
// res(content);
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
|
||||
// export async function getSaveData(index: number) {
|
||||
// const data = await getSave(index);
|
||||
// if (!data) return '';
|
||||
// return compressToBase64(JSON.stringify(data));
|
||||
// }
|
||||
|
||||
// export async function getAllSavesData() {
|
||||
// const data = await getAllSaves();
|
||||
// if (!data) return '';
|
||||
// return compressToBase64(JSON.stringify(data));
|
||||
// }
|
||||
|
||||
// //#region 服务器加载
|
||||
|
||||
// const enum FromServerResponse {
|
||||
// Success,
|
||||
// ErrorCannotParse,
|
||||
// ErrorCannotSync,
|
||||
// ErrorUnexpectedCode
|
||||
// }
|
||||
|
||||
// function parseIdPassword(id: string): [string, string] {
|
||||
// if (id.length === 7) return [id.slice(0, 4), id.slice(4)];
|
||||
// else return [id.slice(0, 6), id.slice(6)];
|
||||
// }
|
||||
|
||||
// async function parseResponse(response: SyncSaveFromServerResponse) {
|
||||
// let msg: Save | Save[] | null = null;
|
||||
// try {
|
||||
// msg = JSON.parse(decompressFromBase64(response.msg));
|
||||
// } catch {
|
||||
// // 无视报错
|
||||
// }
|
||||
// if (!msg) {
|
||||
// try {
|
||||
// msg = JSON.parse(response.msg);
|
||||
// } catch {
|
||||
// // 无视报错
|
||||
// }
|
||||
// }
|
||||
// if (msg) {
|
||||
// return msg;
|
||||
// } else {
|
||||
// return FromServerResponse.ErrorCannotParse;
|
||||
// }
|
||||
// }
|
||||
|
||||
// async function syncLoad(id: string, password: string) {
|
||||
// const formData = new FormData();
|
||||
// formData.append('type', 'load');
|
||||
// formData.append('name', core.firstData.name);
|
||||
// formData.append('id', id);
|
||||
// formData.append('password', password);
|
||||
|
||||
// try {
|
||||
// const response = await fetch('/games/sync.php', {
|
||||
// method: 'POST',
|
||||
// body: formData
|
||||
// });
|
||||
|
||||
// const data = (await response.json()) as SyncSaveFromServerResponse;
|
||||
// if (data.code === 0) {
|
||||
// return parseResponse(data);
|
||||
// } else {
|
||||
// return FromServerResponse.ErrorUnexpectedCode;
|
||||
// }
|
||||
// } catch {
|
||||
// return FromServerResponse.ErrorCannotSync;
|
||||
// }
|
||||
// }
|
||||
|
||||
// export async function syncFromServer(
|
||||
// controller: IUIController<IGameUIPropsBase>,
|
||||
// identifier: string
|
||||
// ): Promise<void> {
|
||||
// if (!/^\d{6}\w{4}$/.test(identifier) && !/^\d{4}\w{3}$/.test(identifier)) {
|
||||
// return void getConfirm(
|
||||
// controller,
|
||||
// '不合法的存档编号+密码!请检查格式!',
|
||||
// CENTER_LOC,
|
||||
// POP_BOX_WIDTH
|
||||
// );
|
||||
// }
|
||||
// const [id, password] = parseIdPassword(identifier);
|
||||
// const result = await waitbox(
|
||||
// controller,
|
||||
// CENTER_LOC,
|
||||
// POP_BOX_WIDTH,
|
||||
// syncLoad(id, password)
|
||||
// );
|
||||
// if (typeof result === 'number') {
|
||||
// const map = {
|
||||
// [FromServerResponse.ErrorCannotParse]: '出错啦!\n存档解析失败',
|
||||
// [FromServerResponse.ErrorCannotSync]:
|
||||
// '出错啦!\n无法从服务器同步存档。',
|
||||
// [FromServerResponse.ErrorUnexpectedCode]:
|
||||
// '出错啦!\n无法从服务器同步存档。'
|
||||
// };
|
||||
// return void getConfirm(
|
||||
// controller,
|
||||
// map[result],
|
||||
// CENTER_LOC,
|
||||
// POP_BOX_WIDTH
|
||||
// );
|
||||
// }
|
||||
// if (result instanceof Array) {
|
||||
// const confirm = await getConfirm(
|
||||
// controller,
|
||||
// '所有本地存档都将被覆盖,确认?',
|
||||
// CENTER_LOC,
|
||||
// POP_BOX_WIDTH,
|
||||
// {
|
||||
// defaultYes: true
|
||||
// }
|
||||
// );
|
||||
// if (confirm) {
|
||||
// const max = 5 * (main.savePages || 30);
|
||||
// for (let i = 1; i <= max; i++) {
|
||||
// if (i <= result.length) {
|
||||
// core.setLocalForage('save' + i, result[i - 1]);
|
||||
// } else if (core.saves.ids[i]) {
|
||||
// core.removeLocalForage('save' + i);
|
||||
// }
|
||||
// }
|
||||
// return void getConfirm(
|
||||
// controller,
|
||||
// '同步成功!\n你的本地所有存档均已被覆盖。',
|
||||
// CENTER_LOC,
|
||||
// POP_BOX_WIDTH
|
||||
// );
|
||||
// }
|
||||
// } else {
|
||||
// const idx = core.saves.saveIndex;
|
||||
// await new Promise<void>(res => {
|
||||
// core.setLocalForage(`save${idx}`, result, res);
|
||||
// });
|
||||
// return void getConfirm(
|
||||
// controller,
|
||||
// `同步成功!\n单存档已覆盖至存档 ${idx}`,
|
||||
// CENTER_LOC,
|
||||
// POP_BOX_WIDTH
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
@@ -1,13 +0,0 @@
|
||||
import { onUnmounted } from 'vue';
|
||||
import { WeatherController } from '../weather';
|
||||
import { IRenderTreeRoot } from '@motajs/render';
|
||||
|
||||
export function useWeather(renderer: IRenderTreeRoot): [WeatherController] {
|
||||
const weather = new WeatherController(renderer);
|
||||
|
||||
onUnmounted(() => {
|
||||
weather.destroy();
|
||||
});
|
||||
|
||||
return [weather];
|
||||
}
|
||||
@@ -79,7 +79,7 @@ export abstract class CloudLike extends Weather<CustomRenderItem> {
|
||||
}
|
||||
|
||||
createElement(level: number): CustomRenderItem {
|
||||
const element = new CustomRenderItem(true);
|
||||
const element = new CustomRenderItem();
|
||||
element.setRenderFn(canvas => this.drawImage(canvas));
|
||||
this.maxSpeed = Math.sqrt(level) * 100;
|
||||
this.vx = ((Math.random() - 0.5) * this.maxSpeed) / 2;
|
||||
|
||||
@@ -42,7 +42,7 @@ export class SunWeather extends Weather<CustomRenderItem> {
|
||||
}
|
||||
|
||||
createElement(level: number): CustomRenderItem {
|
||||
const element = new CustomRenderItem(true);
|
||||
const element = new CustomRenderItem();
|
||||
element.setRenderFn(canvas => this.drawSun(canvas));
|
||||
this.maxAlpha = level / 10;
|
||||
this.minAlpha = level / 20;
|
||||
|
||||
@@ -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