mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-05-20 23:17:14 +08:00
2. 存储模块性能提升,添加LRU缓存、批量操作支持,优化内存使用 3. 多语言模块性能与内存管理优化,组件查询性能提升 4. 时间模块类型安全与性能优化,使用泛型替代any,对象池机制减少内存分配 5. 事件系统修复双重注册、重复注册等严重问题,实现EventData对象池减少GC压力 6. RandomManager修复4个逻辑BUG,包括边界问题和越界问题 7. 音频模块内存与性能优化,避免重复加载,优化数据结构,添加完整清理机制 8. CCView与CCViewVM合并,支持按需启用MVVM 9. Collection模块优化,AsyncQueue添加队列容量限制,Collection查询性能提升 10. ECS系统全面优化,对象池复用减少内存分配,循环性能提升 11. 优化MVVM组件性能
83 lines
2.3 KiB
TypeScript
83 lines
2.3 KiB
TypeScript
import type { TTFFont } from 'cc';
|
||
|
||
/*
|
||
* @Author: dgflash
|
||
* @Date: 2022-02-11 09:31:52
|
||
* @LastEditors: dgflash
|
||
* @LastEditTime: 2023-08-22 16:37:40
|
||
*/
|
||
|
||
/** 框架支持的语言数据类型 */
|
||
export enum LanguageDataType {
|
||
/** Json格式配置 */
|
||
Json = 'Json',
|
||
/** Excel生成的Json配置 */
|
||
Excel = 'Excel',
|
||
}
|
||
|
||
export class LanguageData {
|
||
/** JSON资源目录 */
|
||
static path_json = 'language/json';
|
||
/** 纹理资源目录 */
|
||
static path_texture = 'language/texture';
|
||
/** SPINE资源目录 */
|
||
static path_spine = 'language/spine';
|
||
|
||
/** 当前语言 */
|
||
static current = '';
|
||
/** 语言数据 */
|
||
static language: Map<string, any> = new Map();
|
||
/** TTF字体 */
|
||
static font: TTFFont = null!;
|
||
|
||
/**
|
||
* 通过多语言关键字获取语言文本
|
||
*
|
||
* 注:
|
||
*
|
||
* 1、先获取language/json中的配置数据,如果没有者获取config/game/Language配置表中的多语言数据
|
||
*
|
||
* 2、config/game/Language配置表可选使用,不用时不创建同名配置表即可
|
||
*
|
||
* 3、config/game/Language配置表使用oops-plugin-excel-to-json插件生成,点击项目根目录下载update-oops-plugin-framework.bat或update-oops-plugin-framework.sh脚本下载插件
|
||
*/
|
||
static getLangByID(labId: string): string {
|
||
let content: string = null!;
|
||
for (const [key, value] of this.language) {
|
||
if (key === LanguageDataType.Excel) {
|
||
const lang = value[labId];
|
||
if (lang) content = lang[this.current];
|
||
}
|
||
else {
|
||
content = value[labId];
|
||
}
|
||
if (content) return content;
|
||
}
|
||
return labId;
|
||
}
|
||
|
||
/**
|
||
* 清理语言数据,释放内存
|
||
* 建议在游戏退出或切换场景时调用
|
||
*/
|
||
static clear() {
|
||
this.language.clear();
|
||
this.font = null!;
|
||
this.current = '';
|
||
}
|
||
|
||
/**
|
||
* 清理指定类型的语言数据
|
||
* @param type 语言数据类型
|
||
*/
|
||
static clearType(type: LanguageDataType) {
|
||
this.language.delete(type);
|
||
}
|
||
}
|
||
|
||
export const LanguageType = [
|
||
'LanguageLabel',
|
||
'LanguageSprite',
|
||
'LanguageSpine'
|
||
];
|