From e910464c06d64432607805a8b2a7a7c78c7085e1 Mon Sep 17 00:00:00 2001 From: praydog Date: Thu, 11 Apr 2024 11:30:59 -0700 Subject: [PATCH] .NET: Add "Auto Reload" checkbox --- csharp-api/REFrameworkNET/PluginManager.cpp | 8 ++++++-- csharp-api/REFrameworkNET/PluginManager.hpp | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/csharp-api/REFrameworkNET/PluginManager.cpp b/csharp-api/REFrameworkNET/PluginManager.cpp index c9e5125c6..d317fa287 100644 --- a/csharp-api/REFrameworkNET/PluginManager.cpp +++ b/csharp-api/REFrameworkNET/PluginManager.cpp @@ -304,7 +304,7 @@ namespace REFrameworkNET { } } - s_wants_reload = true; + s_wants_reload_automatic = true; } void PluginManager::SetupIndividualFileWatcher(System::String^ real_path) { @@ -374,8 +374,10 @@ namespace REFrameworkNET { } void PluginManager::BeginRendering() { - if (s_wants_reload) { + bool should_reload = s_wants_reload || (s_wants_reload_automatic && s_auto_reload_plugins); + if (should_reload) { s_wants_reload = false; + s_wants_reload_automatic = false; PluginManager::UnloadPlugins(); @@ -665,6 +667,8 @@ namespace REFrameworkNET { if (ImGuiNET::ImGui::Button("Unload Scripts")) { PluginManager::UnloadPlugins(); } + + ImGuiNET::ImGui::Checkbox("Auto Reload", s_auto_reload_plugins); for each (PluginState^ state in PluginManager::s_plugin_states) { state->DisplayOptions(); diff --git a/csharp-api/REFrameworkNET/PluginManager.hpp b/csharp-api/REFrameworkNET/PluginManager.hpp index 4d4d18b24..025ef2753 100644 --- a/csharp-api/REFrameworkNET/PluginManager.hpp +++ b/csharp-api/REFrameworkNET/PluginManager.hpp @@ -61,6 +61,7 @@ private ref class PluginManager // We also need a watcher list for symlinks that are in the directory static System::Collections::Generic::List^ s_symlink_watchers{gcnew System::Collections::Generic::List()}; static bool s_wants_reload{false}; + static bool s_wants_reload_automatic{false}; static void SetupFileWatcher(); static void SetupIndividualFileWatcher(System::String^ p); // individual symlinks @@ -103,5 +104,6 @@ private ref class PluginManager static System::Collections::Generic::List^ s_plugin_states{gcnew System::Collections::Generic::List()}; static System::Collections::Generic::List^ s_plugin_states_to_remove{gcnew System::Collections::Generic::List()}; + static bool s_auto_reload_plugins{true}; }; } \ No newline at end of file