Move global_scripts to options.h

Not the perfect place for it by any means, but that's where the rest of
the application-global stuff is these days and it removed the need for
automation stuff to include main.h (and thus all the wxApp garbage).
This commit is contained in:
Thomas Goyne 2014-06-06 08:24:33 -07:00
parent 07cf50f7d3
commit ce358c1367
6 changed files with 12 additions and 17 deletions

View File

@ -36,7 +36,7 @@
#include "../frame_main.h"
#include "../include/aegisub/context.h"
#include "../libresrc/libresrc.h"
#include "../main.h"
#include "../options.h"
#include <libaegisub/make_unique.h>
@ -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"));
}
};

View File

@ -36,7 +36,6 @@
#include "include/aegisub/context.h"
#include "libresrc/libresrc.h"
#include "options.h"
#include "main.h"
#include <libaegisub/signal.h>
@ -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));

View File

@ -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();

View File

@ -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);

View File

@ -26,7 +26,6 @@
#include "compat.h"
#include "format.h"
#include "libresrc/libresrc.h"
#include "main.h"
#include "options.h"
#include <libaegisub/cajun/reader.h>
@ -41,7 +40,6 @@
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/range/algorithm_ext/push_back.hpp>
#include <vector>
#include <wx/app.h>
#include <wx/frame.h>
#include <wx/menu.h>
#include <wx/menuitem.h>
@ -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);

View File

@ -18,15 +18,15 @@
#include <libaegisub/option.h>
#include <libaegisub/option_value.h>
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