This commit is contained in:
lenheart
2025-04-05 22:03:40 +08:00
parent 4d65103501
commit eeb773e723
53 changed files with 2348 additions and 505 deletions

View File

@@ -0,0 +1,47 @@
/*
文件名:ConfigClass.nut
路径:Dps_A/BaseClass/ConfigClass/ConfigClass.nut
创建日期:2025-03-29 23:54
文件用途:全局配置类
*/
class _GlobalConfig {
ConfigMap = null;
constructor() {
//在全局中注册自己
getroottable().GlobalConfig <- this;
ConfigMap = {};
local WorkPath = "/dp_s/OfficialConfig";
local FilePaths = sq_GetListFiles(WorkPath);
foreach(FilePath in FilePaths) {
try {
LoadJson(FilePath, WorkPath + "/" + FilePath);
} catch (exception) {
error("加载配置文件失败:" + FilePath);
}
}
//开启热重载配置
GameManager.OpenHotFix("/dp_s/OfficialConfig");
}
function LoadJson(FilePath, Path) {
local Config = sq_ReadJsonFile(Path);
if (Config) {
ConfigMap.rawset(FilePath, Config);
}
}
function Get(ConfigName) {
if (ConfigMap.rawin(ConfigName)) {
return ConfigMap[ConfigName];
} else {
return null;
}
}
}
_GlobalConfig();