dl
dl_mod.h
浏览该文件的文档.
1
12#pragma once
13
14#ifndef DL_DISABLE_RENDER
15#include "io/dl_json.h"
16
17namespace dl
18{
20class Mod
21{
22 friend class ModManager;
23public:
24 enum class State
25 {
26 ERR, // 错误
27 DISABLE, // 未启用
28 NORMAL, // 正常
29 };
30
31 std::string_view GetPathRoot() const { return _pathRoot; }
32 std::string_view GetName() const { return _name; }
33
34 Mod();
35private:
36 //-------------------------config-------------------------
37 uint64_t _uid;
38 std::string _name;
39 std::string _author;
40 std::string _versionType;
41 std::array<size_t, 3> _versionCode;
42
43 size_t _id;
44 State _state;
45 std::string _pathRoot;// 根目录
46
47 bool _load_config(json& j);
48};
49
51{
52public:
58 void LoadMod(std::string_view path);
59
60 void LoadModAll(std::string_view path);
61
65 void CallLuaScript(std::string_view path_name);
66
70 std::string GetPathCurrentMod()
71 {
72 return _pathCurrentMod;
73 }
74
75 const std::vector<Mod>& GetAll() { return _allMod; }
76private:
77 std::vector<Mod> _allMod;
78
79 // 当前执行的脚本根目录
80 std::string _pathCurrentMod;
81};
82
83extern ModManager* g_mod;
84}
85#endif
friend class ModManager
std::string_view GetName() const
std::string_view GetPathRoot() const
模组管理器
std::string GetPathCurrentMod()
返回当前上下文的mod根路径
const std::vector< Mod > & GetAll()
void LoadMod(std::string_view path)
加载模组
void CallLuaScript(std::string_view path_name)
调用每个模组的lua脚本
void LoadModAll(std::string_view path)
json格式相关
nlohmann::json json
ModManager * g_mod