mirror of
https://github.com/motajs/template.git
synced 2026-11-01 22:24:31 +08:00
feat(04-14): 部分 UI 进一步接口适配·第二步(D-74..D-78)
D-78: main.tsx 状态栏更新改为在 client.hero.attribute 上 addHook({ onUpdateAttribute }) 并在 onUnmounted 注销;移除全局 hook 残留与手工调用垫片。
D-74/D-75: load.tsx 改依新加载系统 client.loader.start() + client.loader.manager.get*;移除旧接口成员与失效 @ts-expect-error。
D-76/D-77: 删除 render/index.tsx 的 restart 注释块、client.ts 两段兼容层注释、entry-client/src/create.ts 被注释接线与模块创建函数块。
仅含五个生产文件与 04-14-SUMMARY.md;未触用户 04-CONTEXT.md 并发改动。
This commit is contained in:
1 parent
cab6fe2e5a
commit
bc7d631dc2
6 files changed
+227
-53
No files matched your search
@@ -85,12 +85,6 @@ export class ClientCore extends CoreState implements IClientCore {
|
||||
|
||||
//#endregion
|
||||
|
||||
// 兼容层
|
||||
// loading.once('loaded', () => {
|
||||
// fallbackLoad(this.materials);
|
||||
// loading.emit('assetBuilt');
|
||||
// });
|
||||
|
||||
//#region 渲染系统
|
||||
|
||||
const rafExcitation = new RafExcitation();
|
||||
@@ -121,11 +115,6 @@ export class ClientCore extends CoreState implements IClientCore {
|
||||
this.mainMapRenderer = new MapRenderer(this.materials);
|
||||
this.mainMapExtension = new MapExtensionManager(this.mainMapRenderer);
|
||||
|
||||
// 兼容层
|
||||
// loading.once('assetBuilt', () => {
|
||||
// this.initMapExtensions();
|
||||
// });
|
||||
|
||||
//#endregion
|
||||
|
||||
this.loader.addCoreConfig('client', config.clientURL);
|
||||
|
||||
@@ -32,11 +32,6 @@ export function createRender() {
|
||||
createAction();
|
||||
createWeather();
|
||||
|
||||
// hook.on('restart', () => {
|
||||
// sceneController.closeAll();
|
||||
// sceneController.open(GameTitleUI, {});
|
||||
// });
|
||||
|
||||
Font.setDefaults(DEFAULT_FONT);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,15 +68,11 @@ export const LoadScene = defineComponent<ILoadProps>(props => {
|
||||
};
|
||||
|
||||
const startLoad = async () => {
|
||||
loader.initSystemLoadTask();
|
||||
loader.load().then(() => {
|
||||
loadEnd();
|
||||
});
|
||||
// @ts-expect-error 需要重构
|
||||
for await (const _ of loader.progress) {
|
||||
taskProgress.set(loader.progress.getLoadedTasks());
|
||||
byteProgress.set(loader.progress.getLoadedByte());
|
||||
for await (const _ of loader.start()) {
|
||||
taskProgress.set(loader.manager.getLoadedTasks());
|
||||
byteProgress.set(loader.manager.getLoadedByte());
|
||||
}
|
||||
loadEnd();
|
||||
};
|
||||
|
||||
// 开始加载
|
||||
@@ -88,8 +84,8 @@ export const LoadScene = defineComponent<ILoadProps>(props => {
|
||||
ctx.lineCap = 'round';
|
||||
ctx.lineWidth = LOAD_TASK_LINE_WIDTH;
|
||||
ctx.font = taskFont.string();
|
||||
const loaded = loader.progress.getLoadedTasks();
|
||||
const total = loader.progress.getAddedTasks();
|
||||
const loaded = loader.manager.getLoadedTasks();
|
||||
const total = loader.manager.getAddedTasks();
|
||||
// 这里使用渐变参数,因为要有动画效果
|
||||
const progress = clamp(taskProgress.value / total, 0, 1);
|
||||
const cx = taskLoc[2]! / 2;
|
||||
@@ -115,8 +111,8 @@ export const LoadScene = defineComponent<ILoadProps>(props => {
|
||||
ctx.lineCap = 'round';
|
||||
ctx.lineWidth = LOAD_BYTE_LINE_WIDTH;
|
||||
ctx.font = byteFont.string();
|
||||
const total = loader.progress.getTotalByte();
|
||||
const loaded = loader.progress.getLoadedByte();
|
||||
const total = loader.manager.getTotalByte();
|
||||
const loaded = loader.manager.getLoadedByte();
|
||||
// 这里使用渐变参数,因为要有动画效果
|
||||
const progress = clamp(byteProgress.value / total, 0, 1);
|
||||
const sx = LOAD_BYTE_LINE_WIDTH;
|
||||
@@ -136,7 +132,7 @@ export const LoadScene = defineComponent<ILoadProps>(props => {
|
||||
ctx.fillStyle = LOAD_FONT_COLOR;
|
||||
const loadedMB = (loaded / 2 ** 20).toFixed(2);
|
||||
const totalMB = (total / 2 ** 20).toFixed(2);
|
||||
const percent = loader.progress.getByteRatio() * 100;
|
||||
const percent = loader.manager.getByteRatio() * 100;
|
||||
ctx.fillText(
|
||||
`${loadedMB}MB / ${totalMB}MB | ${percent.toFixed(2)}%`,
|
||||
byteLoc[2]! - LOAD_BYTE_LINE_WIDTH,
|
||||
|
||||
@@ -137,19 +137,17 @@ const MainScene = defineComponent(() => {
|
||||
locked.value = core.status.lockControl;
|
||||
};
|
||||
|
||||
// 保留函数调用,避免被识别为未使用函数而报错
|
||||
// 后续修改后需要删除
|
||||
updateDataFallback();
|
||||
updateStatus();
|
||||
|
||||
// 监听状态栏更新事件
|
||||
// hook.on('statusBarUpdate', updateStatus);
|
||||
// hook.on('statusBarUpdate', updateDataFallback);
|
||||
const attributeHook = client.hero.attribute.addHook({
|
||||
onUpdateAttribute: () => {
|
||||
updateStatus();
|
||||
updateDataFallback();
|
||||
}
|
||||
});
|
||||
|
||||
// onUnmounted(() => {
|
||||
// hook.off('statusBarUpdate', updateStatus);
|
||||
// hook.off('statusBarUpdate', updateDataFallback);
|
||||
// });
|
||||
onUnmounted(() => {
|
||||
attributeHook.unload();
|
||||
});
|
||||
|
||||
//#region sprite 渲染
|
||||
|
||||
|
||||
Reference in new issue
Block a user