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/
|
2006-12-28 22:18:35 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @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
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2009-09-11 04:36:34 +02:00
|
|
|
#ifndef AGI_PRE
|
2011-09-28 21:49:27 +02:00
|
|
|
#include <list>
|
2009-09-11 04:36:34 +02:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <wx/dialog.h>
|
2011-09-28 21:48:37 +02:00
|
|
|
#include <wx/filename.h>
|
2007-09-12 01:22:26 +02:00
|
|
|
#include <wx/gauge.h>
|
2009-09-11 04:36:34 +02:00
|
|
|
#include <wx/sizer.h>
|
2007-09-12 01:22:26 +02:00
|
|
|
#include <wx/stattext.h>
|
2009-09-11 04:36:34 +02:00
|
|
|
#include <wx/string.h>
|
2007-09-12 01:22:26 +02:00
|
|
|
#include <wx/textctrl.h>
|
2009-09-11 04:36:34 +02:00
|
|
|
#include <wx/timer.h>
|
|
|
|
#endif
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:47:40 +02:00
|
|
|
#include <libaegisub/background_runner.h>
|
|
|
|
#include <libaegisub/exception.h>
|
|
|
|
#include <libaegisub/scoped_ptr.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"
|
2009-09-11 04:36:34 +02:00
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
class AssFile;
|
|
|
|
class AssStyle;
|
2011-09-28 21:47:40 +02:00
|
|
|
class DialogProgress;
|
|
|
|
class SubtitleFormat;
|
2006-12-28 22:18:35 +01:00
|
|
|
class wxWindow;
|
|
|
|
class wxDialog;
|
|
|
|
class wxStopWatch;
|
|
|
|
class wxPathList;
|
|
|
|
|
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
|
|
|
|
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
|
|
|
/// DOCME
|
2006-12-28 22:18:35 +01:00
|
|
|
namespace Automation4 {
|
2011-09-28 21:48:28 +02:00
|
|
|
DEFINE_BASE_EXCEPTION_NOINNER(AutomationError, agi::Exception)
|
|
|
|
DEFINE_SIMPLE_EXCEPTION_NOINNER(ScriptLoadError, AutomationError, "automation/load/generic")
|
|
|
|
DEFINE_SIMPLE_EXCEPTION_NOINNER(MacroRunError, AutomationError, "automation/macro/generic")
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
// Calculate the extents of a text string given a style
|
2011-09-28 21:49:27 +02:00
|
|
|
bool CalculateTextExtents(AssStyle *style, wxString 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 {
|
2012-03-07 02:30:52 +01:00
|
|
|
agi::scoped_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
|
|
|
|
virtual 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:
|
2007-04-04 02:01:17 +02:00
|
|
|
wxString GetScriptSettingsIdentifier();
|
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
public:
|
2011-09-28 21:48:47 +02:00
|
|
|
ExportFilter(wxString const& name, wxString const& description, int priority);
|
|
|
|
virtual ~ExportFilter();
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:48:47 +02:00
|
|
|
wxWindow* GetConfigDialogWindow(wxWindow *parent, agi::Context *c);
|
|
|
|
void LoadSettings(bool is_default, agi::Context *c);
|
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:
|
2011-09-28 21:49:27 +02:00
|
|
|
virtual ~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: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
|
|
|
|
virtual wxString 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
|
|
|
|
virtual void Unserialise(wxString 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 {
|
|
|
|
agi::scoped_ptr<DialogProgress> impl;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:49:27 +02:00
|
|
|
void OnDialog(wxThreadEvent &evt);
|
2012-02-22 05:17:16 +01:00
|
|
|
void OnScriptDialog(wxThreadEvent &evt);
|
2006-12-28 22:18:35 +01:00
|
|
|
public:
|
2011-09-28 21:47:40 +02:00
|
|
|
void QueueEvent(wxEvent *evt);
|
2012-02-22 05:17:16 +01:00
|
|
|
wxWindow *GetParentWindow() const;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:47:40 +02:00
|
|
|
void Run(std::tr1::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
|
|
|
|
2011-09-28 21:47:40 +02:00
|
|
|
BackgroundScriptRunner(wxWindow *parent, wxString const& title);
|
|
|
|
~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
|
|
|
|
class ProgressSink : public agi::ProgressSink {
|
|
|
|
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:
|
2011-09-28 21:47:40 +02:00
|
|
|
void SetIndeterminate() { impl->SetIndeterminate(); }
|
|
|
|
void SetTitle(std::string const& title) { impl->SetTitle(title); }
|
|
|
|
void SetMessage(std::string const& msg) { impl->SetMessage(msg); }
|
2012-03-10 02:00:13 +01:00
|
|
|
void SetProgress(int64_t cur, int64_t max) { impl->SetProgress(cur, max); }
|
2011-09-28 21:47:40 +02:00
|
|
|
void Log(std::string const& str) { impl->Log(str); }
|
|
|
|
bool IsCancelled() { 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 {
|
|
|
|
wxString filename;
|
|
|
|
|
|
|
|
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
|
2006-12-28 22:18:35 +01:00
|
|
|
wxPathList include_path;
|
2011-09-28 21:48:37 +02:00
|
|
|
Script(wxString const& filename);
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
public:
|
2011-09-28 21:48:37 +02:00
|
|
|
virtual ~Script() { }
|
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
|
|
|
|
wxString GetFilename() const { return filename; }
|
|
|
|
/// The script's file name without path
|
|
|
|
wxString GetPrettyFilename() const { return wxFileName(filename).GetFullName(); }
|
|
|
|
/// The script's name. Not required to be unique.
|
|
|
|
virtual wxString GetName() const=0;
|
|
|
|
/// A short description of the script
|
|
|
|
virtual wxString GetDescription() const=0;
|
|
|
|
/// The author of the script
|
|
|
|
virtual wxString GetAuthor() const=0;
|
|
|
|
/// A version string that should not be used for anything but display
|
|
|
|
virtual wxString GetVersion() const=0;
|
|
|
|
/// 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;
|
|
|
|
/// Get a list of subtitle formats provided by this script
|
|
|
|
virtual std::vector<SubtitleFormat*> GetFormats() 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:
|
2006-12-28 22:18:35 +01:00
|
|
|
std::vector<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
|
|
|
|
virtual ~ScriptManager();
|
|
|
|
/// Add a script to the manager. The ScriptManager takes ownership of the script and will automatically delete it.
|
|
|
|
void Add(Script *script);
|
|
|
|
/// 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)
|
|
|
|
const std::vector<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
|
|
|
|
class LocalScriptManager : public ScriptManager {
|
|
|
|
std::list<agi::signal::Connection> slots;
|
|
|
|
agi::Context *context;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:45:55 +02:00
|
|
|
void OnSubtitlesSave();
|
|
|
|
public:
|
|
|
|
LocalScriptManager(agi::Context *context);
|
|
|
|
void Reload();
|
|
|
|
};
|
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
|
2006-12-28 22:18:35 +01:00
|
|
|
class AutoloadScriptManager : public ScriptManager {
|
|
|
|
wxString path;
|
|
|
|
public:
|
2011-09-28 21:48:58 +02:00
|
|
|
AutoloadScriptManager(wxString const& path);
|
2006-12-28 22:18:35 +01:00
|
|
|
void Reload();
|
|
|
|
};
|
|
|
|
|
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 {
|
2011-09-28 21:46:05 +02:00
|
|
|
wxString engine_name;
|
|
|
|
wxString 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
|
|
|
|
2011-09-28 21:46:05 +02:00
|
|
|
/// Load a file, or return NULL if the file is not in a supported
|
|
|
|
/// 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
|
|
|
|
virtual Script* Produce(wxString 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
|
|
|
|
2012-04-27 21:08:17 +02:00
|
|
|
static inline std::vector<ScriptFactory*>& Factories();
|
|
|
|
|
2011-09-28 21:46:05 +02:00
|
|
|
protected:
|
|
|
|
ScriptFactory(wxString engine_name, wxString filename_pattern);
|
|
|
|
virtual ~ScriptFactory() { }
|
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:
|
2011-09-28 21:46:05 +02:00
|
|
|
/// Name of this automation engine
|
|
|
|
const wxString& GetEngineName() const { return engine_name; }
|
|
|
|
/// Extension which this engine supports
|
|
|
|
const wxString& GetFilenamePattern() const { return filename_pattern; }
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:46:05 +02:00
|
|
|
/// Register an automation engine. Calling code retains ownership of pointer
|
2006-12-28 22:18:35 +01:00
|
|
|
static void Register(ScriptFactory *factory);
|
2011-09-28 21:46:05 +02:00
|
|
|
/// Unregister and delete an automation engine
|
2006-12-28 22:18:35 +01:00
|
|
|
static void Unregister(ScriptFactory *factory);
|
2011-09-28 21:46:05 +02:00
|
|
|
/// Is there an automation engine registered which can open the file?
|
|
|
|
static bool CanHandleScriptFormat(wxString const& filename);
|
|
|
|
|
|
|
|
/// Get the full wildcard string for all loaded engines
|
|
|
|
static wxString GetWildcardStr();
|
|
|
|
|
|
|
|
/// Load a script from a file
|
|
|
|
/// @param filename Script to load
|
|
|
|
/// @param log_errors Should load errors be displayed?
|
|
|
|
/// @return Always returns a valid Script, even if no engine could load the file
|
|
|
|
static Script* CreateFromFile(wxString const& filename, bool log_errors);
|
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
static const std::vector<ScriptFactory*>& GetFactories();
|
|
|
|
};
|
|
|
|
|
2011-09-28 21:47:40 +02:00
|
|
|
/// A script which represents a file not recognized by any registered
|
|
|
|
/// automation engines
|
2006-12-28 22:18:35 +01:00
|
|
|
class UnknownScript : public Script {
|
|
|
|
public:
|
2011-09-28 21:48:37 +02:00
|
|
|
UnknownScript(wxString const& 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
|
|
|
|
2011-09-28 21:48:37 +02:00
|
|
|
void Reload() { }
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2011-09-28 21:48:37 +02:00
|
|
|
wxString GetName() const { return wxFileName(GetFilename()).GetName(); }
|
|
|
|
wxString GetDescription() const { return _("File was not recognized as a script"); }
|
|
|
|
wxString GetAuthor() const { return ""; }
|
|
|
|
wxString GetVersion() const { return ""; }
|
|
|
|
bool GetLoadedState() const { return false; }
|
|
|
|
|
2011-09-28 21:48:47 +02:00
|
|
|
std::vector<cmd::Command*> GetMacros() const { return std::vector<cmd::Command*>(); }
|
|
|
|
std::vector<ExportFilter*> GetFilters() const { return std::vector<ExportFilter*>(); }
|
|
|
|
std::vector<SubtitleFormat*> GetFormats() const { return std::vector<SubtitleFormat*>(); }
|
2011-09-28 21:48:37 +02:00
|
|
|
};
|
2011-12-28 22:27:06 +01:00
|
|
|
}
|