diff --git a/src/command/automation.cpp b/src/command/automation.cpp index 817bfabb5..96669940b 100644 --- a/src/command/automation.cpp +++ b/src/command/automation.cpp @@ -36,7 +36,7 @@ #include "../frame_main.h" #include "../include/aegisub/context.h" #include "../libresrc/libresrc.h" -#include "../main.h" +#include "../options.h" #include @@ -50,7 +50,7 @@ struct reload_all final : public Command { STR_HELP("Reload all Automation scripts and rescan the autoload folder") void operator()(agi::Context *c) override { - wxGetApp().global_scripts->Reload(); + config::global_scripts->Reload(); c->local_scripts->Reload(); c->frame->StatusTimeout(_("Reloaded all Automation scripts")); } @@ -63,7 +63,7 @@ struct reload_autoload final : public Command { STR_HELP("Rescan the Automation autoload folder") void operator()(agi::Context *c) override { - wxGetApp().global_scripts->Reload(); + config::global_scripts->Reload(); c->frame->StatusTimeout(_("Reloaded autoload Automation scripts")); } }; diff --git a/src/dialog_automation.cpp b/src/dialog_automation.cpp index dd53db7b4..840a6868c 100644 --- a/src/dialog_automation.cpp +++ b/src/dialog_automation.cpp @@ -36,7 +36,6 @@ #include "include/aegisub/context.h" #include "libresrc/libresrc.h" #include "options.h" -#include "main.h" #include @@ -108,7 +107,7 @@ DialogAutomation::DialogAutomation(agi::Context *c) , context(c) , local_manager(c->local_scripts.get()) , local_scripts_changed(local_manager->AddScriptChangeListener(&DialogAutomation::RebuildList, this)) -, global_manager(wxGetApp().global_scripts) +, global_manager(config::global_scripts) , global_scripts_changed(global_manager->AddScriptChangeListener(&DialogAutomation::RebuildList, this)) { SetIcon(GETICON(automation_toolbutton_16)); diff --git a/src/main.cpp b/src/main.cpp index c5b27dee0..2473af282 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -76,6 +76,7 @@ namespace config { agi::Options *opt = nullptr; agi::MRUManager *mru = nullptr; agi::Path *path = nullptr; + Automation4::AutoloadScriptManager *global_scripts; } wxIMPLEMENT_APP(AegisubApp); @@ -278,7 +279,7 @@ bool AegisubApp::OnInit() { // Load Automation scripts StartupLog("Load global Automation scripts"); - global_scripts = new Automation4::AutoloadScriptManager(OPT_GET("Path/Automation/Autoload")->GetString()); + config::global_scripts = new Automation4::AutoloadScriptManager(OPT_GET("Path/Automation/Autoload")->GetString()); // Load export filters StartupLog("Register export filters"); @@ -365,7 +366,7 @@ int AegisubApp::OnExit() { hotkey::clear(); cmd::clear(); - delete global_scripts; + delete config::global_scripts; AssExportFilterChain::Clear(); diff --git a/src/main.h b/src/main.h index 54583270a..89c39696a 100644 --- a/src/main.h +++ b/src/main.h @@ -37,8 +37,6 @@ class FrameMain; -namespace Automation4 { class AutoloadScriptManager; } - class AegisubApp : public wxApp { friend class FrameMain; @@ -66,7 +64,6 @@ class AegisubApp : public wxApp { public: AegisubApp(); AegisubLocale locale; - Automation4::AutoloadScriptManager *global_scripts = nullptr; // Apple events void MacOpenFile(const wxString &filename); diff --git a/src/menu.cpp b/src/menu.cpp index 4a34312da..5a55fc08e 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -26,7 +26,6 @@ #include "compat.h" #include "format.h" #include "libresrc/libresrc.h" -#include "main.h" #include "options.h" #include @@ -41,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -402,7 +400,7 @@ class AutomationMenu final : public wxMenu { for (size_t i = items.size() - 1; i >= 2; --i) Delete(items[i]); - auto macros = wxGetApp().global_scripts->GetMacros(); + auto macros = config::global_scripts->GetMacros(); boost::push_back(macros, c->local_scripts->GetMacros()); if (macros.empty()) { Append(-1, _("No Automation macros loaded"))->Enable(false); @@ -438,7 +436,7 @@ public: AutomationMenu(agi::Context *c, CommandManager *cm) : c(c) , cm(cm) - , global_slot(wxGetApp().global_scripts->AddScriptChangeListener(&AutomationMenu::Regenerate, this)) + , global_slot(config::global_scripts->AddScriptChangeListener(&AutomationMenu::Regenerate, this)) , local_slot(c->local_scripts->AddScriptChangeListener(&AutomationMenu::Regenerate, this)) { cm->AddCommand(cmd::get("am/meta"), this); diff --git a/src/options.h b/src/options.h index bded9e415..8f0240334 100644 --- a/src/options.h +++ b/src/options.h @@ -18,15 +18,15 @@ #include #include -namespace agi { - class Path; -} +namespace agi { class Path; } +namespace Automation4 { class AutoloadScriptManager; } /// For holding all configuration-related objects and values. namespace config { extern agi::Options *opt; ///< Options extern agi::MRUManager *mru; ///< Most Recently Used extern agi::Path *path; + extern Automation4::AutoloadScriptManager *global_scripts; } /// Macro to get OptionValue object