#include "DeerRender/UIEngine.h" #include "DeerRender/UIEngine/UIEngine_ErrorHandle.h" #include "DeerRender/UIEngine/UIEngine_Functions.h" #include "DeerRender/UIEngine/UIEngine.h" #include "DeerRender/UIEngine/DockPanelObject.h" #include "Deer/Log.h" #include #include "angelscript.h" #include "scriptbuilder.h" #include "scriptstdstring.h" namespace Deer { namespace UIEngine { asIScriptEngine* scriptEngine = nullptr; asIScriptModule* scriptModule = nullptr; asIScriptContext* scriptContext = nullptr; std::vector dockPanels; DockPanelObject* currentDockPanelExecution = nullptr; bool active = false; } void UIEngine::initialize() { int err = 0; // If it exist we will reload it deinitialize(); scriptEngine = asCreateScriptEngine(); RegisterStdString(scriptEngine); AS_RET_CHECK(scriptEngine->SetMessageCallback(asFUNCTION(Deer::UIEngine::errorCallback), 0, asCALL_CDECL)); registerUIEngineFunctions(); registerDockPanel(); loadScripts(); scriptModule = scriptEngine->GetModule("DeerModule"); scriptContext = scriptEngine->CreateContext(); extractDockPanels(); active = true; } void UIEngine::deinitialize() { dockPanels.clear(); if (scriptContext) scriptContext->Release(); if (scriptEngine) scriptEngine->ShutDownAndRelease(); scriptEngine = nullptr; scriptModule = nullptr; scriptContext = nullptr; active = false; } void UIEngine::execute() { if (!active) return; for (auto& panel : dockPanels) { currentDockPanelExecution = &panel; panel.executeRender(); } currentDockPanelExecution = nullptr; } }