refactor: 怪物手册 UI 重构

This commit is contained in:
AncTe committed 2026-11-05 19:53:25 +08:00
1 parent 376f36b43c
commit 6c6f7da76a
29 files changed
+2577 -930

No files matched your search

+44 -1
View File
@@ -16,7 +16,7 @@ export interface IGridLayoutData {
}
/**
* 网格布局
* 网格布局,如果是指定元素的数量,那么用 `adjustGrid2`
* @param width 总宽度
* @param height 总高度
* @param itemWidth 每个元素的宽度
@@ -58,6 +58,49 @@ export function adjustGrid(
};
}
/**
* 网格布局,如果是指定元素宽高,那么用 `adjustGrid`
* @param width 总宽度
* @param height 总高度
* @param xCount 横向有多少个元素
* @param yCount 纵向有多少个元素
* @param intervalX 元素的横向间隔
* @param intervalY 元素的纵向间隔,不填时等于横向间隔
* @returns 网格布局信息
*/
export function adjustGrid2(
width: number,
height: number,
xCount: number,
yCount: number,
intervalX: number,
intervalY: number = intervalX
) {
const itemWidth = (width - intervalX * (xCount - 1)) / xCount;
const itemHeight = (height - intervalY * (yCount - 1)) / yCount;
const rawWidth = (itemWidth + intervalX) * xCount - intervalX;
const rawHeight = (itemHeight + intervalY) * yCount - intervalY;
const locs: ElementLocator[] = [];
for (let y = 0; y < yCount; y++) {
const iy = (intervalY + itemHeight) * y;
for (let x = 0; x < xCount; x++) {
const ix = (intervalX + itemWidth) * x;
locs.push([ix, iy, itemWidth, itemHeight, 0, 0]);
}
}
return {
cols: xCount,
rows: yCount,
count: xCount * yCount,
width: rawWidth,
height: rawHeight,
locs
};
}
/**
* 适配为覆盖模式,类似于 `object-fit: cover`
* @param itemWidth 元素宽度
+1 -1
View File
@@ -15,7 +15,7 @@ import { IClientHotkey } from './hotkey';
export interface IGameUIPropsBase<
T extends UIComponent = UIComponent
> extends IUIDefaultPropsBase<T> {
> extends IUIDefaultPropsBase<T, IGameUIPropsBase<T>> {
readonly state: IClientBase;
}
@@ -1,2 +1 @@
export * from './types';
export * from './func';
@@ -1,5 +0,0 @@
import { IUIDefaultPropsBase } from '@motajs/system';
import { IClientBaseExtended } from '@user/client-base';
export interface IUIPropsBase
extends IUIDefaultPropsBase, IClientBaseExtended {}
@@ -427,7 +427,7 @@ export interface IDamageCalculator<TEnemy, THero> {
export interface IDamageContext<TEnemy, THero> extends IDataBaseExtended {
/**
* 获取战斗伤害信息
* 获取战斗伤害信息,会使用怪物的计算后属性计算伤害,等价于 `getDamageInfoByComputed(view.getComputedEnemy)`
* @param enemy 怪物视图
*/
getDamageInfo(