Skip to content

Commit

Permalink
.NET: Add "Auto Reload" checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Apr 11, 2024
1 parent 0fc6db8 commit 2c4d779
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions csharp-api/REFrameworkNET/PluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ namespace REFrameworkNET {
}
}

s_wants_reload = true;
s_wants_reload_automatic = true;
}

void PluginManager::SetupIndividualFileWatcher(System::String^ real_path) {
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions csharp-api/REFrameworkNET/PluginManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<System::IO::FileSystemWatcher^>^ s_symlink_watchers{gcnew System::Collections::Generic::List<System::IO::FileSystemWatcher^>()};
static bool s_wants_reload{false};
static bool s_wants_reload_automatic{false};

static void SetupFileWatcher();
static void SetupIndividualFileWatcher(System::String^ p); // individual symlinks
Expand Down Expand Up @@ -103,5 +104,6 @@ private ref class PluginManager

static System::Collections::Generic::List<PluginState^>^ s_plugin_states{gcnew System::Collections::Generic::List<PluginState^>()};
static System::Collections::Generic::List<PluginState^>^ s_plugin_states_to_remove{gcnew System::Collections::Generic::List<PluginState^>()};
static bool s_auto_reload_plugins{true};
};
}

0 comments on commit 2c4d779

Please sign in to comment.