/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Editor/EditorFramework/EditorApp/Configuration/EnginePlugins.cpp
111 строк
3 KB
Sanakan8472
Pacman fixes and unit test (#1075)
03 окт 2023, 12:58
Не верифицирован
03 окт 2023, 12:58
4a3e861
Код
Авторство
О чём код?
#include <EditorFramework/EditorFrameworkPCH.h> #include <EditorFramework/CodeGen/CppProject.h> #include <EditorFramework/EditorApp/EditorApp.moc.h> #include <Foundation/IO/OSFile.h> #include <Foundation/Profiling/Profiling.h> void ezQtEditorApp::StoreEnginePluginModificationTimes() { for (auto it : m_PluginBundles.m_Plugins) { ezPluginBundle& plugin = it.Value(); for (const ezString& rt : plugin.m_RuntimePlugins) { ezStringBuilder sPath, sCopy; ezPlugin::GetPluginPaths(rt, sPath, sCopy, 0); ezFileStats stats; if (ezOSFile::GetFileStats(sPath, stats).Succeeded()) { if (!plugin.m_LastModificationTime.IsValid() || stats.m_LastModificationTime.Compare(plugin.m_LastModificationTime, ezTimestamp::CompareMode::Newer)) { // store the maximum (latest) modification timestamp plugin.m_LastModificationTime = stats.m_LastModificationTime; } } } } } bool ezQtEditorApp::CheckForEnginePluginModifications() { for (auto it : m_PluginBundles.m_Plugins) { ezPluginBundle& plugin = it.Value(); if (plugin.m_bMissing) { DetectAvailablePluginBundles(ezOSFile::GetApplicationDirectory()); ezCppSettings cppSettings; if (cppSettings.Load().Succeeded()) { ezQtEditorApp::GetSingleton()->DetectAvailablePluginBundles(ezCppProject::GetPluginSourceDir(cppSettings)); } break; } } for (auto it : m_PluginBundles.m_Plugins) { ezPluginBundle& plugin = it.Value(); if (!plugin.m_bSelected || !plugin.m_bLoadCopy) continue; for (const ezString& rt : plugin.m_RuntimePlugins) { ezStringBuilder sPath, sCopy; ezPlugin::GetPluginPaths(rt, sPath, sCopy, 0); ezFileStats stats; if (ezOSFile::GetFileStats(sPath, stats).Succeeded()) { if (!plugin.m_LastModificationTime.IsValid() || stats.m_LastModificationTime.Compare(plugin.m_LastModificationTime, ezTimestamp::CompareMode::Newer)) { return true; } } } } return false; } void ezQtEditorApp::RestartEngineProcessIfPluginsChanged(bool bForce) { if (!ezToolsProject::IsProjectOpen()) return; if (!bForce) { if (m_LastPluginModificationCheck + ezTime::MakeFromSeconds(2) > ezTime::Now()) return; } m_LastPluginModificationCheck = ezTime::Now(); for (auto pMan : ezDocumentManager::GetAllDocumentManagers()) { for (auto pDoc : pMan->ezDocumentManager::GetAllOpenDocuments()) { if (!pDoc->CanEngineProcessBeRestarted()) { // not allowed to restart at the moment return; } } } if (!CheckForEnginePluginModifications()) return; ezLog::Info("Engine plugins have changed, restarting engine process."); StoreEnginePluginModificationTimes(); ezEditorEngineProcessConnection::GetSingleton()->SetPluginConfig(GetRuntimePluginConfig(true)); ezEditorEngineProcessConnection::GetSingleton()->RestartProcess().IgnoreResult(); }