refactor: 插件系统结构

This commit is contained in:
AncTe committed 2026-10-20 20:44:33 +08:00
1 parent 3cc97e5ed3
commit e6f4346924
30 files changed
+260 -169

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ import {
} from '@motajs/system';
import { DefaultProps } from '@motajs/render-vue';
import { defineComponent } from 'vue';
import { MAIN_HEIGHT, MAIN_WIDTH } from './constant';
import { MAIN_HEIGHT, MAIN_WIDTH } from '@/client';
export interface MainBackgroundProps
extends DefaultProps, IUIDefaultPropsBase {}
+1 -1
View File
@@ -7,7 +7,7 @@ import { IEnemyView } from '@user/data-system';
import { IReadonlyEnemy } from '@user/data-base';
import { IEnemyAttr } from '@user/data-common';
import { BookDetailUI } from './bookDetail';
import { FULL_LOC, MAIN_HEIGHT, MAIN_WIDTH } from './constant';
import { FULL_LOC, MAIN_HEIGHT, MAIN_WIDTH } from '@/client';
import { IUIPropsBase } from '@user/client-modules';
export interface BookProps extends IUIPropsBase {}
+1 -1
View File
@@ -6,7 +6,7 @@ import { Scroll, TextContent } from '@user/client-base';
import { IEnemyCritical, IEnemyView, EnemyView } from '@user/data-system';
import { IEnemy, IReadonlyEnemy } from '@user/data-base';
import { IEnemyAttr } from '@user/data-common';
import { FULL_LOC, MAIN_HEIGHT, MAIN_WIDTH } from './constant';
import { FULL_LOC, MAIN_HEIGHT, MAIN_WIDTH } from '@/client';
import { IUIPropsBase } from '@user/client-modules';
/** 详情当前展示的属性模式 */
-86
View File
@@ -1,86 +0,0 @@
import { ElementLocator, Font } from '@motajs/render';
// 本文件为 UI 配置文件,你可以修改下面的每个常量来控制 UI 的显示参数,每个常量都有注释说明
//#region 地图配置
/** 每个格子的宽度 */
export const CELL_WIDTH = 32;
/** 每个格子的高度 */
export const CELL_HEIGHT = 32;
/** 地图格子宽度,此处仅影响画面,不影响游戏内逻辑,游戏内逻辑地图大小请在 core.js 中修改 */
export const MAP_BLOCK_WIDTH = 13;
/** 地图格子高度,此处仅影响画面,不影响游戏内逻辑,游戏内逻辑地图大小请在 core.js 中修改 */
export const MAP_BLOCK_HEIGHT = 13;
/** 地图像素宽度 */
export const MAP_WIDTH = CELL_WIDTH * MAP_BLOCK_WIDTH;
/** 地图像素高度 */
export const MAP_HEIGHT = CELL_HEIGHT * MAP_BLOCK_HEIGHT;
/** 地图宽度的一半 */
export const HALF_MAP_WIDTH = MAP_WIDTH / 2;
/** 地图高度的一半 */
export const HALF_MAP_HEIGHT = MAP_HEIGHT / 2;
/**
* 动态内容预留,不明白含义的话不要动。地图上所有正在移动的图块称为动态内容,这些内容的数量无法预测,因此需要预留数组大小,
* 如果不够再临时扩充。如果你的塔中有大量的移动操作,可以适当提高此值,避免频繁的内存扩充行为,可以一定程度上提高性能表现。
*/
export const DYNAMIC_RESERVE = 16;
/**
* 移动图块容忍度,不明白含义的话不要动。如果移动图块的数量长期小于当前预留数量,那么将会降低预留数量,提升性能表现。
* 调整此值可以调整频率,值越大,越不容易因为数量小于预留数量而减小预留。
*/
export const MOVING_TOLERANCE = 60;
/** 开关门动画的动画时长 */
export const DOOR_ANIMATE_INTERVAL = 50;
//#endregion
//#region 状态栏配置
/** 状态栏像素宽度 */
export const STATUS_BAR_WIDTH = 180;
/** 状态栏像素高度 */
export const STATUS_BAR_HEIGHT = 32 * MAP_BLOCK_HEIGHT;
/** 右侧状态栏的横坐标 */
export const RIGHT_STATUS_POS = STATUS_BAR_WIDTH + MAP_WIDTH;
/** 是否启用右侧状态栏 */
export const ENABLE_RIGHT_STATUS_BAR = false;
/** 状态栏数量,启用右侧状态栏为两个,不启用为一个 */
export const STATUS_BAR_COUNT = ENABLE_RIGHT_STATUS_BAR ? 2 : 1;
/** 状态栏宽度的一半 */
export const HALF_STATUS_WIDTH = STATUS_BAR_WIDTH / 2;
//#endregion
//#region 游戏画面
/** 游戏画面像素宽度,宽=地图宽度+状态栏宽度*状态栏数量 */
export const MAIN_WIDTH = MAP_WIDTH + STATUS_BAR_WIDTH * STATUS_BAR_COUNT;
/** 游戏画面像素高度 */
export const MAIN_HEIGHT = MAP_HEIGHT;
/** 游戏画面宽度的一半 */
export const HALF_WIDTH = MAIN_WIDTH / 2;
/** 游戏画面高度的一半 */
export const HALF_HEIGHT = MAIN_HEIGHT / 2;
/** 全屏显示的 loc */
export const FULL_LOC: ElementLocator = [0, 0, MAIN_WIDTH, MAIN_HEIGHT];
/** 居中显示的 loc */
export const CENTER_LOC: ElementLocator = [
HALF_WIDTH,
HALF_HEIGHT,
void 0,
void 0,
0.5,
0.5
];
//#endregion
//#region 通用配置
/** 弹框的宽度,使用在内置 UI 与组件中,包括确认框、选择框、等待框等 */
export const POP_BOX_WIDTH = MAP_WIDTH / 2;
/** 默认字体 */
export const DEFAULT_FONT = new Font('Verdana', 16);
//#endregion
+1 -1
View File
@@ -5,7 +5,7 @@ import { Font } from '@motajs/render';
import { Scroll, TextContent } from '@user/client-base';
import { EquipStatus, IHeroState } from '@user/data-base';
import { IHeroAttr } from '@user/data-common';
import { FULL_LOC, MAIN_HEIGHT, MAIN_WIDTH } from './constant';
import { FULL_LOC, MAIN_HEIGHT, MAIN_WIDTH } from '@/client';
import { IUIPropsBase } from '@user/client-modules';
interface IHeroAttrItem {
+2 -3
View File
@@ -1,14 +1,13 @@
import { DefaultProps } from '@motajs/render-vue';
import { GameUI, SetupComponentOptions } from '@motajs/system';
import { defineComponent } from 'vue';
import { FULL_LOC, MAIN_HEIGHT, MAIN_WIDTH } from './constant';
import { FULL_LOC, MAIN_HEIGHT, MAIN_WIDTH } from '@/client';
import { ElementLocator, Font, MotaOffscreenCanvas2D } from '@motajs/render';
import { transitioned } from '../../../packages-user/client-modules/src/render/use';
import { cosh, CurveMode, linear } from '@motajs/animate';
import { clamp } from 'lodash-es';
import { sleep } from '@motajs/common';
import { GameTitleUI } from './title';
import { IUIPropsBase } from '@user/client-modules';
import { IUIPropsBase, transitioned } from '@user/client-modules';
/** 加载界面的任务进度条半径 */
export const LOAD_TASK_RADIUS = Math.min(MAIN_WIDTH, MAIN_HEIGHT) / 6;
+1 -1
View File
@@ -12,7 +12,7 @@ import {
RIGHT_STATUS_POS,
STATUS_BAR_HEIGHT,
STATUS_BAR_WIDTH
} from './constant';
} from '@/client';
import { LeftStatusBar, RightStatusBar } from './statusBar';
import { isNil } from 'lodash-es';
import { IUIPropsBase, using } from '@user/client-modules';
+1 -1
View File
@@ -17,7 +17,7 @@ import {
IGameUIPropsBase,
MAP_BLOCK_WIDTH
} from '@user/client-base';
import { HALF_HEIGHT, HALF_WIDTH, MAP_WIDTH, POP_BOX_WIDTH } from './constant';
import { HALF_HEIGHT, HALF_WIDTH, MAP_WIDTH, POP_BOX_WIDTH } from '@/client';
import { adjustGrid, IGridLayoutData } from '@user/client-base';
import { getSave, IUIPropsBase, SaveData, useKey } from '@user/client-modules';
+1 -1
View File
@@ -16,7 +16,7 @@ import { openStatistics } from './statistics';
import { saveWithExist } from './save';
import { compressToBase64 } from 'lz-string';
import { ViewMapUI } from './viewmap';
import { CENTER_LOC, FULL_LOC, MAIN_HEIGHT, POP_BOX_WIDTH } from './constant';
import { CENTER_LOC, FULL_LOC, MAIN_HEIGHT, POP_BOX_WIDTH } from '@/client';
import { IUIPropsBase, useKey } from '@user/client-modules';
export interface MainSettingsProps extends Partial<ChoicesProps>, IUIPropsBase {
+1 -1
View File
@@ -16,7 +16,7 @@ import {
MAIN_WIDTH,
STATUS_BAR_HEIGHT,
STATUS_BAR_WIDTH
} from './constant';
} from '@/client';
import { IUIPropsBase } from '@user/client-modules';
import { DefaultProps } from '@motajs/render-vue';
+1 -1
View File
@@ -1,7 +1,7 @@
import { DefaultProps } 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 './constant';
import { HALF_HEIGHT, HALF_WIDTH, MAIN_HEIGHT, MAIN_WIDTH } from '@/client';
import { ElementLocator, Font } from '@motajs/render';
import {
ExitFullscreen,
+2 -2
View File
@@ -13,12 +13,12 @@ import {
} from '@user/client-base';
import { gameKey, generateKeyboardEvent } from '@motajs/system';
import { linear } from 'mutate-animate';
import { KeyCode } from '@motajs/client-base';
import { KeyCode } from '@motajs/system';
import { Progress } from '@user/client-base';
import { generateBinary } from '@motajs/legacy-common';
import { SetupComponentOptions } from '@motajs/system';
import { saveSave, saveLoad } from './save';
import { MAIN_HEIGHT, FULL_LOC, POP_BOX_WIDTH, CENTER_LOC } from './constant';
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';
+1 -1
View File
@@ -4,7 +4,7 @@ import { Font } from '@motajs/render';
import { Scroll, TextContent } from '@user/client-base';
import { IHeroItemState, IHeroState } from '@user/data-base';
import { IHeroAttr } from '@user/data-common';
import { FULL_LOC, MAIN_HEIGHT, MAIN_WIDTH } from './constant';
import { FULL_LOC, MAIN_HEIGHT, MAIN_WIDTH } from '@/client';
import { IUIPropsBase } from '@user/client-modules';
export interface ToolBoxProps extends IUIPropsBase {
+1 -1
View File
@@ -38,7 +38,7 @@ import {
RIGHT_STATUS_POS,
STATUS_BAR_HEIGHT,
STATUS_BAR_WIDTH
} from './constant';
} from '@/client';
import { useKey } from '@user/client-modules';
export interface ViewMapProps extends IUIDefaultPropsBase, BaseProps {