MCPcopy Create free account
hub / github.com/AmelieHeinrich/Termina / Load

Method Load

Sources/Termina/Scripting/ScriptModuleManager.cpp:30–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 }
29
30 bool ScriptModuleManager::Load(const std::string& name, const std::string& path)
31 {
32 if (m_Modules.count(name)) {
33 TN_ERROR("Module '%s' is already loaded.", name.c_str());
34 return false;
35 }
36
37 auto dll = std::make_unique<DLL>(path.c_str());
38 if (!dll->IsValid()) {
39 TN_WARN("Module '%s': DLL '%s' not found, scripting disabled.", name.c_str(), path.c_str());
40 return false;
41 }
42 void* regSym = dll->GetSymbol("RegisterComponents");
43 if (!regSym) {
44 TN_ERROR("'%s' has no RegisterComponents symbol.", path.c_str());
45 return false;
46 }
47
48 reinterpret_cast<void(*)()>(regSym)();
49 PropagateImGuiContext(dll.get());
50
51 std::vector<std::string> names;
52 void* namesSym = dll->GetSymbol("GetComponentNames");
53 if (namesSym) {
54 using GetNamesFn = const std::vector<std::string>&(*)();
55 names = reinterpret_cast<GetNamesFn>(namesSym)();
56 }
57
58 m_Modules.emplace(name, LoadedModule{ name, path, std::move(dll), std::move(names) });
59 return true;
60 }
61
62 void ScriptModuleManager::Reload(const std::string& name, World* world)
63 {

Callers 2

ScriptSystemMethod · 0.45
ShowDebugWindowMethod · 0.45

Calls 5

PropagateImGuiContextFunction · 0.85
c_strMethod · 0.80
IsValidMethod · 0.45
GetSymbolMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected