1111
This commit is contained in:
47
Dps_A/BaseClass/ConfigClass/ConfigClass.nut
Normal file
47
Dps_A/BaseClass/ConfigClass/ConfigClass.nut
Normal 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();
|
||||
Reference in New Issue
Block a user