forked from ElunaLuaEngine/Eluna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathElunaConfig.cpp
70 lines (60 loc) · 1.97 KB
/
ElunaConfig.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Copyright (C) 2010 - 2024 Eluna Lua Engine <https://elunaluaengine.github.io/>
* This program is free software licensed under GPL version 3
* Please see the included DOCS/LICENSE.md for more information
*/
#if defined TRINITY || defined MANGOS
#include "Config.h"
#elif defined CMANGOS || defined VMANGOS
#include "Config/Config.h"
#endif
#include "ElunaConfig.h"
ElunaConfig::ElunaConfig()
{
}
ElunaConfig* ElunaConfig::instance()
{
static ElunaConfig instance;
return &instance;
}
ElunaConfig::~ElunaConfig()
{
}
void ElunaConfig::Initialize()
{
// Load bools
SetConfig(CONFIG_ELUNA_ENABLED, "Eluna.Enabled", true);
SetConfig(CONFIG_ELUNA_COMPATIBILITY_MODE, "Eluna.CompatibilityMode", true);
SetConfig(CONFIG_ELUNA_TRACEBACK, "Eluna.TraceBack", false);
// Load strings
SetConfig(CONFIG_ELUNA_SCRIPT_PATH, "Eluna.ScriptPath", "lua_scripts");
SetConfig(CONFIG_ELUNA_ONLY_ON_MAPS, "Eluna.OnlyOnMaps", "");
SetConfig(CONFIG_ELUNA_REQUIRE_PATH_EXTRA, "Eluna.RequirePaths", "");
SetConfig(CONFIG_ELUNA_REQUIRE_CPATH_EXTRA, "Eluna.RequireCPaths", "");
}
void ElunaConfig::SetConfig(ElunaConfigBoolValues index, char const* fieldname, bool defvalue)
{
#ifdef TRINITY
SetConfig(index, sConfigMgr->GetBoolDefault(fieldname, defvalue));
#elif defined CMANGOS || defined VMANGOS || defined MANGOS
SetConfig(index, sConfig.GetBoolDefault(fieldname, defvalue));
#endif
}
void ElunaConfig::SetConfig(ElunaConfigStringValues index, char const* fieldname, std::string defvalue)
{
#ifdef TRINITY
SetConfig(index, sConfigMgr->GetStringDefault(fieldname, defvalue));
#elif CMANGOS
SetConfig(index, sConfig.GetStringDefault(fieldname, defvalue));
#elif defined VMANGOS || defined MANGOS
SetConfig(index, sConfig.GetStringDefault(fieldname, defvalue.c_str()));
#endif
}
bool ElunaConfig::IsElunaEnabled()
{
return GetConfig(CONFIG_ELUNA_ENABLED);
}
bool ElunaConfig::IsElunaCompatibilityMode()
{
return GetConfig(CONFIG_ELUNA_COMPATIBILITY_MODE);
}