mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
Added systems logs
This commit is contained in:
@@ -22,6 +22,8 @@ namespace Nuake
|
||||
|
||||
bool PhysicsSystem::Init()
|
||||
{
|
||||
Logger::Log("Initializing the physic system");
|
||||
|
||||
// We need to initialize shapes first, then bodies...
|
||||
InitializeShapes();
|
||||
|
||||
@@ -42,7 +44,7 @@ namespace Nuake
|
||||
|
||||
// PhysicsManager::Get()->RegisterGhostBody(ghostBody);
|
||||
//}
|
||||
|
||||
Logger::Log("Physic system initialized successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace Nuake {
|
||||
{
|
||||
ScriptingEngine::Init();
|
||||
|
||||
Logger::Log("Initializing ScriptingSystem");
|
||||
|
||||
auto& entities = m_Scene->m_Registry.view<WrenScriptComponent>();
|
||||
for (auto& e : entities)
|
||||
{
|
||||
@@ -24,7 +26,10 @@ namespace Nuake {
|
||||
wren.mWrenScript->Build(wren.mModule, true);
|
||||
|
||||
if (!wren.mWrenScript->HasCompiledSuccesfully())
|
||||
{
|
||||
Logger::Log("ScriptingSystem failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
wren.mWrenScript->SetScriptableEntityID((int)e);
|
||||
wren.mWrenScript->CallInit();
|
||||
@@ -69,8 +74,15 @@ namespace Nuake {
|
||||
{
|
||||
WrenScriptComponent& wren = entities.get<WrenScriptComponent>(e);
|
||||
|
||||
if (wren.mWrenScript != nullptr)
|
||||
wren.mWrenScript->CallExit();
|
||||
try
|
||||
{
|
||||
if (wren.mWrenScript != nullptr)
|
||||
wren.mWrenScript->CallExit();
|
||||
}
|
||||
catch (std::exception* e)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ScriptingEngine::Close();
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace Nuake {
|
||||
const char* module, const int line,
|
||||
const char* msg)
|
||||
{
|
||||
Logger::Log("YO");
|
||||
switch (errorType)
|
||||
{
|
||||
case WREN_ERROR_COMPILE:
|
||||
@@ -37,6 +38,12 @@ namespace Nuake {
|
||||
std::string t = "Script Runtime Error: " + std::string(msg);
|
||||
Logger::Log(t, WARNING);
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
std::string t = "Script Runtime Error: " + std::string(msg);
|
||||
Logger::Log(t, CRITICAL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +150,7 @@ namespace Nuake {
|
||||
|
||||
void ScriptingEngine::Init()
|
||||
{
|
||||
Logger::Log("Initializing Scripting Engine");
|
||||
m_Scripts = std::map<std::string, Ref<WrenScript>>();
|
||||
m_LoadedScripts.clear();
|
||||
|
||||
@@ -156,6 +164,7 @@ namespace Nuake {
|
||||
|
||||
m_WrenVM = wrenNewVM(&config);
|
||||
|
||||
Logger::Log("Registing Scripting Modules");
|
||||
Ref<ScriptAPI::EngineModule> engineModule = CreateRef<ScriptAPI::EngineModule>();
|
||||
RegisterModule(engineModule);
|
||||
Ref<ScriptAPI::SceneModule> sceneModule = CreateRef<ScriptAPI::SceneModule>();
|
||||
@@ -166,6 +175,8 @@ namespace Nuake {
|
||||
RegisterModule(inputModule);
|
||||
Ref<ScriptAPI::PhysicsModule> physicsModule = CreateRef<ScriptAPI::PhysicsModule>();
|
||||
RegisterModule(physicsModule);
|
||||
Logger::Log("Scripting Modules Registered");
|
||||
Logger::Log("Scripting Engine initialized successfully");
|
||||
}
|
||||
|
||||
void ScriptingEngine::Close()
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "WrenScript.h"
|
||||
|
||||
#include "src/Core/Logger.h"
|
||||
#include "src/Core/String.h"
|
||||
|
||||
#include <src/Vendors/wren/src/include/wren.h>
|
||||
@@ -48,19 +50,27 @@ namespace Nuake {
|
||||
WrenVM* vm = ScriptingEngine::GetWrenVM();
|
||||
|
||||
std::string relativePath = mFile->GetRelativePath();
|
||||
|
||||
// Can't import twice the same script, otherwise gives a compile error.
|
||||
if (!ScriptingEngine::IsScriptImported(relativePath))
|
||||
{
|
||||
std::string source = "import \"" + relativePath + "\" for " + GetModules()[moduleId];
|
||||
WrenInterpretResult result = wrenInterpret(vm, "main", source.c_str());
|
||||
|
||||
if (result != WREN_RESULT_SUCCESS)
|
||||
|
||||
Logger::Log("Wren result: " + std::to_string(result));
|
||||
if (result == WREN_RESULT_SUCCESS)
|
||||
{
|
||||
Logger::Log("Wren result success: " + std::to_string(result));
|
||||
CompiledSuccesfully = true;
|
||||
ScriptingEngine::ImportScript(relativePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Log("Wren result failed: " + std::to_string(result));
|
||||
CompiledSuccesfully = false;
|
||||
|
||||
if (!CompiledSuccesfully)
|
||||
return;
|
||||
|
||||
ScriptingEngine::ImportScript(relativePath);
|
||||
}
|
||||
}
|
||||
|
||||
// Get handle to class
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Nuake {
|
||||
Ref<File> mFile;
|
||||
|
||||
std::map <std::string, WrenHandle*> methods;
|
||||
WrenHandle* m_Instance;
|
||||
WrenHandle* m_Instance = nullptr;
|
||||
WrenHandle* m_OnInitHandle;
|
||||
WrenHandle* m_OnUpdateHandle;
|
||||
WrenHandle* m_OnFixedUpdateHandle;
|
||||
|
||||
Reference in New Issue
Block a user