2006-12-28 22:18:35 +01:00
|
|
|
// Copyright (c) 2006, Niels Martin Hansen
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
|
|
|
/// @file auto4_base.h
|
|
|
|
/// @see auto4_base.cpp
|
|
|
|
/// @ingroup scripting
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2009-09-18 04:48:31 +02:00
|
|
|
#pragma once
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-09-28 21:47:40 +02:00
|
|
|
#include <libaegisub/background_runner.h>
|
|
|
|
#include <libaegisub/exception.h>
|
2013-01-04 16:01:50 +01:00
|
|
|
#include <libaegisub/fs_fwd.h>
|
2011-09-28 21:45:55 +02:00
|
|
|
#include <libaegisub/signal.h>
|
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
#include "ass_export_filter.h"
|
2013-01-04 16:01:50 +01:00
|
|
|
|
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
class AssStyle;
|
2011-09-28 21:47:40 +02:00
|
|
|
class DialogProgress;
|
2006-12-28 22:18:35 +01:00
|
|
|
class wxWindow;
|
|
|
|
class wxDialog;
|
|
|
|
|
2011-09-28 21:45:55 +02:00
|
|
|
namespace agi { struct Context; }
|
2011-09-28 21:48:47 +02:00
|
|
|
namespace cmd { class Command; }
|
2011-09-28 21:45:55 +02:00
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
namespace Automation4 {
|
2014-05-29 14:57:27 +02:00
|
|
|
DEFINE_EXCEPTION(AutomationError, agi::Exception);
|
|
|
|
DEFINE_EXCEPTION(ScriptLoadError, AutomationError);
|
|
|
|
DEFINE_EXCEPTION(MacroRunError, AutomationError);
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
// Calculate the extents of a text string given a style
|
2013-01-04 16:01:50 +01:00
|
|
|
bool CalculateTextExtents(AssStyle *style, std::string const& text, double &width, double &height, double &descent, double &extlead);
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:49:27 +02:00
|
|
|
class ScriptDialog;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-09-28 21:48:47 +02:00
|
|
|
class ExportFilter : public AssExportFilter {
|
2013-01-04 16:01:50 +01:00
|
|
|
std::unique_ptr<ScriptDialog> config_dialog;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:49:27 +02:00
|
|
|
/// subclasses should implement this, producing a new ScriptDialog
|
2014-04-23 01:34:18 +02:00
|
|
|
virtual std::unique_ptr<ScriptDialog> GenerateConfigDialog(wxWindow *parent, agi::Context *c) = 0;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:48:47 +02:00
|
|
|
protected:
|
2013-01-04 16:01:50 +01:00
|
|
|
std::string GetScriptSettingsIdentifier();
|
2007-04-04 02:01:17 +02:00
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
public:
|
2013-01-04 16:01:50 +01:00
|
|
|
ExportFilter(std::string const& name, std::string const& description, int priority);
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
wxWindow* GetConfigDialogWindow(wxWindow *parent, agi::Context *c) override;
|
|
|
|
void LoadSettings(bool is_default, agi::Context *c) override;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
// Subclasses must implement ProcessSubs from AssExportFilter
|
|
|
|
};
|
|
|
|
|
2011-09-28 21:49:27 +02:00
|
|
|
/// A "dialog" which actually generates a non-top-level window that is then
|
|
|
|
/// either inserted into a dialog or into the export filter configuration
|
|
|
|
/// panel
|
|
|
|
class ScriptDialog {
|
2006-12-28 22:18:35 +01:00
|
|
|
public:
|
2014-04-25 19:01:07 +02:00
|
|
|
virtual ~ScriptDialog() = default;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-09-28 21:49:27 +02:00
|
|
|
/// Create a window with the given parent
|
|
|
|
virtual wxWindow *CreateWindow(wxWindow *parent) = 0;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-09-28 21:49:27 +02:00
|
|
|
/// Serialize the values of the controls in this dialog to a string
|
|
|
|
/// suitable for storage in the subtitle script
|
2013-01-04 16:01:50 +01:00
|
|
|
virtual std::string Serialise() { return ""; }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-09-28 21:49:27 +02:00
|
|
|
/// Restore the values of the controls in this dialog from a string
|
|
|
|
/// stored in the subtitle script
|
2013-01-04 16:01:50 +01:00
|
|
|
virtual void Unserialise(std::string const& serialised) { }
|
2006-12-28 22:18:35 +01:00
|
|
|
};
|
|
|
|
|
2011-09-28 21:47:40 +02:00
|
|
|
class ProgressSink;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:47:40 +02:00
|
|
|
class BackgroundScriptRunner {
|
2013-01-04 16:01:50 +01:00
|
|
|
std::unique_ptr<DialogProgress> impl;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
public:
|
2012-02-22 05:17:16 +01:00
|
|
|
wxWindow *GetParentWindow() const;
|
2013-01-04 16:01:50 +01:00
|
|
|
std::string GetTitle() const;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2012-09-25 01:35:27 +02:00
|
|
|
void Run(std::function<void(ProgressSink*)> task);
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
BackgroundScriptRunner(wxWindow *parent, std::string const& title);
|
2011-09-28 21:47:40 +02:00
|
|
|
~BackgroundScriptRunner();
|
2006-12-28 22:18:35 +01:00
|
|
|
};
|
|
|
|
|
2011-09-28 21:47:40 +02:00
|
|
|
/// A wrapper around agi::ProgressSink which adds the ability to open
|
|
|
|
/// dialogs on the GUI thread
|
2014-03-13 02:39:07 +01:00
|
|
|
class ProgressSink final : public agi::ProgressSink {
|
2011-09-28 21:47:40 +02:00
|
|
|
agi::ProgressSink *impl;
|
|
|
|
BackgroundScriptRunner *bsr;
|
2007-01-18 21:47:56 +01:00
|
|
|
int trace_level;
|
2006-12-28 22:18:35 +01:00
|
|
|
public:
|
2013-11-21 18:13:36 +01:00
|
|
|
void SetIndeterminate() override { impl->SetIndeterminate(); }
|
|
|
|
void SetTitle(std::string const& title) override { impl->SetTitle(title); }
|
|
|
|
void SetMessage(std::string const& msg) override { impl->SetMessage(msg); }
|
|
|
|
void SetProgress(int64_t cur, int64_t max) override { impl->SetProgress(cur, max); }
|
|
|
|
void Log(std::string const& str) override { impl->Log(str); }
|
|
|
|
bool IsCancelled() override { return impl->IsCancelled(); }
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:47:40 +02:00
|
|
|
/// Show the passed dialog on the GUI thread, blocking the calling
|
|
|
|
/// thread until it closes
|
2011-09-28 21:49:27 +02:00
|
|
|
void ShowDialog(ScriptDialog *config_dialog);
|
2012-02-22 05:17:16 +01:00
|
|
|
int ShowDialog(wxDialog *dialog);
|
|
|
|
wxWindow *GetParentWindow() const { return bsr->GetParentWindow(); }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-09-28 21:47:40 +02:00
|
|
|
/// Get the current automation trace level
|
|
|
|
int GetTraceLevel() const { return trace_level; }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-09-28 21:47:40 +02:00
|
|
|
ProgressSink(agi::ProgressSink *impl, BackgroundScriptRunner *bsr);
|
2006-12-28 22:18:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class Script {
|
2013-01-04 16:01:50 +01:00
|
|
|
agi::fs::path filename;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
protected:
|
2011-09-28 21:48:37 +02:00
|
|
|
/// The automation include path, consisting of the user-specified paths
|
|
|
|
/// along with the script's path
|
2013-01-04 16:01:50 +01:00
|
|
|
std::vector<agi::fs::path> include_path;
|
|
|
|
Script(agi::fs::path const& filename);
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
public:
|
2014-04-25 19:01:07 +02:00
|
|
|
virtual ~Script() = default;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:48:37 +02:00
|
|
|
/// Reload this script
|
2006-12-28 22:18:35 +01:00
|
|
|
virtual void Reload() = 0;
|
|
|
|
|
2011-09-28 21:48:37 +02:00
|
|
|
/// The script's file name with path
|
2013-01-04 16:01:50 +01:00
|
|
|
agi::fs::path GetFilename() const { return filename; }
|
2011-09-28 21:48:37 +02:00
|
|
|
/// The script's file name without path
|
2013-01-04 16:01:50 +01:00
|
|
|
agi::fs::path GetPrettyFilename() const { return filename.filename(); }
|
2011-09-28 21:48:37 +02:00
|
|
|
/// The script's name. Not required to be unique.
|
2013-01-04 16:01:50 +01:00
|
|
|
virtual std::string GetName() const=0;
|
2011-09-28 21:48:37 +02:00
|
|
|
/// A short description of the script
|
2013-01-04 16:01:50 +01:00
|
|
|
virtual std::string GetDescription() const=0;
|
2011-09-28 21:48:37 +02:00
|
|
|
/// The author of the script
|
2013-01-04 16:01:50 +01:00
|
|
|
virtual std::string GetAuthor() const=0;
|
2011-09-28 21:48:37 +02:00
|
|
|
/// A version string that should not be used for anything but display
|
2013-01-04 16:01:50 +01:00
|
|
|
virtual std::string GetVersion() const=0;
|
2011-09-28 21:48:37 +02:00
|
|
|
/// Did the script load correctly?
|
|
|
|
virtual bool GetLoadedState() const=0;
|
|
|
|
|
2011-09-28 21:48:47 +02:00
|
|
|
/// Get a list of commands provided by this script
|
|
|
|
virtual std::vector<cmd::Command*> GetMacros() const=0;
|
|
|
|
/// Get a list of export filters provided by this script
|
|
|
|
virtual std::vector<ExportFilter*> GetFilters() const=0;
|
2006-12-28 22:18:35 +01:00
|
|
|
};
|
|
|
|
|
2011-09-28 21:48:58 +02:00
|
|
|
/// A manager of loaded automation scripts
|
2006-12-28 22:18:35 +01:00
|
|
|
class ScriptManager {
|
2011-09-28 21:49:56 +02:00
|
|
|
protected:
|
2013-06-08 06:19:40 +02:00
|
|
|
std::vector<std::unique_ptr<Script>> scripts;
|
2011-09-28 21:48:47 +02:00
|
|
|
std::vector<cmd::Command*> macros;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:49:56 +02:00
|
|
|
agi::signal::Signal<> ScriptsChanged;
|
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
public:
|
2011-09-28 21:48:58 +02:00
|
|
|
/// Deletes all scripts managed
|
2014-05-22 03:32:42 +02:00
|
|
|
virtual ~ScriptManager() = default;
|
2013-06-08 06:19:40 +02:00
|
|
|
/// Add a script to the manager.
|
2013-09-16 15:43:17 +02:00
|
|
|
void Add(std::unique_ptr<Script> script);
|
2011-09-28 21:48:58 +02:00
|
|
|
/// Remove a script from the manager, and delete the Script object.
|
|
|
|
void Remove(Script *script);
|
|
|
|
/// Deletes all scripts managed
|
|
|
|
void RemoveAll();
|
2012-03-09 01:23:30 +01:00
|
|
|
/// Reload all scripts managed
|
2011-09-28 21:45:55 +02:00
|
|
|
virtual void Reload() = 0;
|
2011-10-25 21:02:01 +02:00
|
|
|
/// Reload a single managed script
|
|
|
|
virtual void Reload(Script *script);
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:48:58 +02:00
|
|
|
/// Get all managed scripts (both loaded and invalid)
|
2013-06-08 06:19:40 +02:00
|
|
|
const std::vector<std::unique_ptr<Script>>& GetScripts() const { return scripts; }
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:48:47 +02:00
|
|
|
const std::vector<cmd::Command*>& GetMacros();
|
2006-12-28 22:18:35 +01:00
|
|
|
// No need to have getters for the other kinds of features, I think.
|
|
|
|
// They automatically register themselves in the relevant places.
|
2011-09-28 21:49:56 +02:00
|
|
|
|
|
|
|
DEFINE_SIGNAL_ADDERS(ScriptsChanged, AddScriptChangeListener)
|
2006-12-28 22:18:35 +01:00
|
|
|
};
|
|
|
|
|
2011-09-28 21:45:55 +02:00
|
|
|
/// Manager for scripts specified by a subtitle file
|
2014-03-13 02:39:07 +01:00
|
|
|
class LocalScriptManager final : public ScriptManager {
|
2011-09-28 21:45:55 +02:00
|
|
|
agi::Context *context;
|
2014-05-22 03:32:42 +02:00
|
|
|
agi::signal::Connection file_open_connection;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2014-05-22 03:32:42 +02:00
|
|
|
void SaveLoadedList();
|
2011-09-28 21:45:55 +02:00
|
|
|
public:
|
|
|
|
LocalScriptManager(agi::Context *context);
|
2013-11-21 18:13:36 +01:00
|
|
|
void Reload() override;
|
2011-09-28 21:45:55 +02:00
|
|
|
};
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-09-28 21:48:58 +02:00
|
|
|
/// Manager for scripts in the autoload directory
|
2014-03-13 02:39:07 +01:00
|
|
|
class AutoloadScriptManager final : public ScriptManager {
|
2013-01-04 16:01:50 +01:00
|
|
|
std::string path;
|
2006-12-28 22:18:35 +01:00
|
|
|
public:
|
2013-11-21 18:13:36 +01:00
|
|
|
AutoloadScriptManager(std::string path);
|
|
|
|
void Reload() override;
|
2006-12-28 22:18:35 +01:00
|
|
|
};
|
|
|
|
|
2011-09-28 21:47:40 +02:00
|
|
|
/// Both a base class for script factories and a manager of registered
|
|
|
|
/// script factories
|
2006-12-28 22:18:35 +01:00
|
|
|
class ScriptFactory {
|
2013-01-04 16:01:50 +01:00
|
|
|
std::string engine_name;
|
|
|
|
std::string filename_pattern;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2012-11-13 17:51:01 +01:00
|
|
|
/// Load a file, or return nullptr if the file is not in a supported
|
2011-09-28 21:46:05 +02:00
|
|
|
/// format. If the file is in a supported format but is invalid, a
|
|
|
|
/// script should be returned which returns false from IsLoaded and
|
|
|
|
/// an appropriate error message from GetDescription.
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
///
|
2011-09-28 21:46:05 +02:00
|
|
|
/// This is private as it should only ever be called through
|
|
|
|
/// CreateFromFile
|
2013-06-08 06:19:40 +02:00
|
|
|
virtual std::unique_ptr<Script> Produce(agi::fs::path const& filename) const = 0;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2013-06-08 06:19:40 +02:00
|
|
|
static std::vector<std::unique_ptr<ScriptFactory>>& Factories();
|
2012-04-27 21:08:17 +02:00
|
|
|
|
2011-09-28 21:46:05 +02:00
|
|
|
protected:
|
2013-11-21 18:13:36 +01:00
|
|
|
ScriptFactory(std::string engine_name, std::string filename_pattern);
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
public:
|
2014-04-25 19:01:07 +02:00
|
|
|
virtual ~ScriptFactory() = default;
|
2013-06-08 06:19:40 +02:00
|
|
|
|
2011-09-28 21:46:05 +02:00
|
|
|
/// Name of this automation engine
|
2013-01-04 16:01:50 +01:00
|
|
|
const std::string& GetEngineName() const { return engine_name; }
|
2011-09-28 21:46:05 +02:00
|
|
|
/// Extension which this engine supports
|
2013-01-04 16:01:50 +01:00
|
|
|
const std::string& GetFilenamePattern() const { return filename_pattern; }
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2013-06-08 06:19:40 +02:00
|
|
|
/// Register an automation engine.
|
2013-09-16 15:43:17 +02:00
|
|
|
static void Register(std::unique_ptr<ScriptFactory> factory);
|
2011-09-28 21:46:05 +02:00
|
|
|
|
|
|
|
/// Get the full wildcard string for all loaded engines
|
2013-01-04 16:01:50 +01:00
|
|
|
static std::string GetWildcardStr();
|
2011-09-28 21:46:05 +02:00
|
|
|
|
|
|
|
/// Load a script from a file
|
|
|
|
/// @param filename Script to load
|
2013-02-08 00:58:51 +01:00
|
|
|
/// @param complain_about_unrecognised Should an error be displayed for files that aren't automation scripts?
|
2013-01-04 16:01:50 +01:00
|
|
|
/// @param create_unknown Create a placeholder rather than returning nullptr if no script engine supports the file
|
2013-06-08 06:19:40 +02:00
|
|
|
static std::unique_ptr<Script> CreateFromFile(agi::fs::path const& filename, bool complain_about_unrecognised, bool create_unknown=true);
|
2011-09-28 21:46:05 +02:00
|
|
|
|
2013-06-08 06:19:40 +02:00
|
|
|
static const std::vector<std::unique_ptr<ScriptFactory>>& GetFactories();
|
2006-12-28 22:18:35 +01:00
|
|
|
};
|
|
|
|
|
2011-09-28 21:47:40 +02:00
|
|
|
/// A script which represents a file not recognized by any registered
|
|
|
|
/// automation engines
|
2014-03-13 02:39:07 +01:00
|
|
|
class UnknownScript final : public Script {
|
2006-12-28 22:18:35 +01:00
|
|
|
public:
|
2013-01-04 16:01:50 +01:00
|
|
|
UnknownScript(agi::fs::path const& filename) : Script(filename) { }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
void Reload() override { }
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
std::string GetName() const override { return GetFilename().stem().string(); }
|
2014-05-23 00:40:16 +02:00
|
|
|
std::string GetDescription() const override;
|
2013-11-21 18:13:36 +01:00
|
|
|
std::string GetAuthor() const override { return ""; }
|
|
|
|
std::string GetVersion() const override { return ""; }
|
|
|
|
bool GetLoadedState() const override { return false; }
|
2011-09-28 21:48:37 +02:00
|
|
|
|
2013-12-12 00:11:06 +01:00
|
|
|
std::vector<cmd::Command*> GetMacros() const override { return {}; }
|
|
|
|
std::vector<ExportFilter*> GetFilters() const override { return {}; }
|
2011-09-28 21:48:37 +02:00
|
|
|
};
|
2011-12-28 22:27:06 +01:00
|
|
|
}
|