mirror of https://github.com/odrling/Aegisub
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:
parent
07cf50f7d3
commit
ce358c1367
|
@ -36,7 +36,7 @@
|
||||||
#include "../frame_main.h"
|
#include "../frame_main.h"
|
||||||
#include "../include/aegisub/context.h"
|
#include "../include/aegisub/context.h"
|
||||||
#include "../libresrc/libresrc.h"
|
#include "../libresrc/libresrc.h"
|
||||||
#include "../main.h"
|
#include "../options.h"
|
||||||
|
|
||||||
#include <libaegisub/make_unique.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")
|
STR_HELP("Reload all Automation scripts and rescan the autoload folder")
|
||||||
|
|
||||||
void operator()(agi::Context *c) override {
|
void operator()(agi::Context *c) override {
|
||||||
wxGetApp().global_scripts->Reload();
|
config::global_scripts->Reload();
|
||||||
c->local_scripts->Reload();
|
c->local_scripts->Reload();
|
||||||
c->frame->StatusTimeout(_("Reloaded all Automation scripts"));
|
c->frame->StatusTimeout(_("Reloaded all Automation scripts"));
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ struct reload_autoload final : public Command {
|
||||||
STR_HELP("Rescan the Automation autoload folder")
|
STR_HELP("Rescan the Automation autoload folder")
|
||||||
|
|
||||||
void operator()(agi::Context *c) override {
|
void operator()(agi::Context *c) override {
|
||||||
wxGetApp().global_scripts->Reload();
|
config::global_scripts->Reload();
|
||||||
c->frame->StatusTimeout(_("Reloaded autoload Automation scripts"));
|
c->frame->StatusTimeout(_("Reloaded autoload Automation scripts"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
#include "include/aegisub/context.h"
|
#include "include/aegisub/context.h"
|
||||||
#include "libresrc/libresrc.h"
|
#include "libresrc/libresrc.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
#include <libaegisub/signal.h>
|
#include <libaegisub/signal.h>
|
||||||
|
|
||||||
|
@ -108,7 +107,7 @@ DialogAutomation::DialogAutomation(agi::Context *c)
|
||||||
, context(c)
|
, context(c)
|
||||||
, local_manager(c->local_scripts.get())
|
, local_manager(c->local_scripts.get())
|
||||||
, local_scripts_changed(local_manager->AddScriptChangeListener(&DialogAutomation::RebuildList, this))
|
, 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))
|
, global_scripts_changed(global_manager->AddScriptChangeListener(&DialogAutomation::RebuildList, this))
|
||||||
{
|
{
|
||||||
SetIcon(GETICON(automation_toolbutton_16));
|
SetIcon(GETICON(automation_toolbutton_16));
|
||||||
|
|
|
@ -76,6 +76,7 @@ namespace config {
|
||||||
agi::Options *opt = nullptr;
|
agi::Options *opt = nullptr;
|
||||||
agi::MRUManager *mru = nullptr;
|
agi::MRUManager *mru = nullptr;
|
||||||
agi::Path *path = nullptr;
|
agi::Path *path = nullptr;
|
||||||
|
Automation4::AutoloadScriptManager *global_scripts;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxIMPLEMENT_APP(AegisubApp);
|
wxIMPLEMENT_APP(AegisubApp);
|
||||||
|
@ -278,7 +279,7 @@ bool AegisubApp::OnInit() {
|
||||||
|
|
||||||
// Load Automation scripts
|
// Load Automation scripts
|
||||||
StartupLog("Load global 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
|
// Load export filters
|
||||||
StartupLog("Register export filters");
|
StartupLog("Register export filters");
|
||||||
|
@ -365,7 +366,7 @@ int AegisubApp::OnExit() {
|
||||||
hotkey::clear();
|
hotkey::clear();
|
||||||
cmd::clear();
|
cmd::clear();
|
||||||
|
|
||||||
delete global_scripts;
|
delete config::global_scripts;
|
||||||
|
|
||||||
AssExportFilterChain::Clear();
|
AssExportFilterChain::Clear();
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
|
|
||||||
class FrameMain;
|
class FrameMain;
|
||||||
|
|
||||||
namespace Automation4 { class AutoloadScriptManager; }
|
|
||||||
|
|
||||||
class AegisubApp : public wxApp {
|
class AegisubApp : public wxApp {
|
||||||
friend class FrameMain;
|
friend class FrameMain;
|
||||||
|
|
||||||
|
@ -66,7 +64,6 @@ class AegisubApp : public wxApp {
|
||||||
public:
|
public:
|
||||||
AegisubApp();
|
AegisubApp();
|
||||||
AegisubLocale locale;
|
AegisubLocale locale;
|
||||||
Automation4::AutoloadScriptManager *global_scripts = nullptr;
|
|
||||||
|
|
||||||
// Apple events
|
// Apple events
|
||||||
void MacOpenFile(const wxString &filename);
|
void MacOpenFile(const wxString &filename);
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "libresrc/libresrc.h"
|
#include "libresrc/libresrc.h"
|
||||||
#include "main.h"
|
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
#include <libaegisub/cajun/reader.h>
|
#include <libaegisub/cajun/reader.h>
|
||||||
|
@ -41,7 +40,6 @@
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
#include <boost/algorithm/string/case_conv.hpp>
|
||||||
#include <boost/range/algorithm_ext/push_back.hpp>
|
#include <boost/range/algorithm_ext/push_back.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <wx/app.h>
|
|
||||||
#include <wx/frame.h>
|
#include <wx/frame.h>
|
||||||
#include <wx/menu.h>
|
#include <wx/menu.h>
|
||||||
#include <wx/menuitem.h>
|
#include <wx/menuitem.h>
|
||||||
|
@ -402,7 +400,7 @@ class AutomationMenu final : public wxMenu {
|
||||||
for (size_t i = items.size() - 1; i >= 2; --i)
|
for (size_t i = items.size() - 1; i >= 2; --i)
|
||||||
Delete(items[i]);
|
Delete(items[i]);
|
||||||
|
|
||||||
auto macros = wxGetApp().global_scripts->GetMacros();
|
auto macros = config::global_scripts->GetMacros();
|
||||||
boost::push_back(macros, c->local_scripts->GetMacros());
|
boost::push_back(macros, c->local_scripts->GetMacros());
|
||||||
if (macros.empty()) {
|
if (macros.empty()) {
|
||||||
Append(-1, _("No Automation macros loaded"))->Enable(false);
|
Append(-1, _("No Automation macros loaded"))->Enable(false);
|
||||||
|
@ -438,7 +436,7 @@ public:
|
||||||
AutomationMenu(agi::Context *c, CommandManager *cm)
|
AutomationMenu(agi::Context *c, CommandManager *cm)
|
||||||
: c(c)
|
: c(c)
|
||||||
, cm(cm)
|
, 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))
|
, local_slot(c->local_scripts->AddScriptChangeListener(&AutomationMenu::Regenerate, this))
|
||||||
{
|
{
|
||||||
cm->AddCommand(cmd::get("am/meta"), this);
|
cm->AddCommand(cmd::get("am/meta"), this);
|
||||||
|
|
|
@ -18,15 +18,15 @@
|
||||||
#include <libaegisub/option.h>
|
#include <libaegisub/option.h>
|
||||||
#include <libaegisub/option_value.h>
|
#include <libaegisub/option_value.h>
|
||||||
|
|
||||||
namespace agi {
|
namespace agi { class Path; }
|
||||||
class Path;
|
namespace Automation4 { class AutoloadScriptManager; }
|
||||||
}
|
|
||||||
|
|
||||||
/// For holding all configuration-related objects and values.
|
/// For holding all configuration-related objects and values.
|
||||||
namespace config {
|
namespace config {
|
||||||
extern agi::Options *opt; ///< Options
|
extern agi::Options *opt; ///< Options
|
||||||
extern agi::MRUManager *mru; ///< Most Recently Used
|
extern agi::MRUManager *mru; ///< Most Recently Used
|
||||||
extern agi::Path *path;
|
extern agi::Path *path;
|
||||||
|
extern Automation4::AutoloadScriptManager *global_scripts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Macro to get OptionValue object
|
/// Macro to get OptionValue object
|
||||||
|
|
Loading…
Reference in New Issue