forked from mia/Aegisub
Kill VideoContext::Get()
This commit is contained in:
parent
aa46c49403
commit
c4c0f6f125
29 changed files with 54 additions and 70 deletions
|
@ -41,6 +41,7 @@
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "include/aegisub/context.h"
|
#include "include/aegisub/context.h"
|
||||||
#include "subtitle_format.h"
|
#include "subtitle_format.h"
|
||||||
|
#include "video_context.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
|
@ -93,7 +94,7 @@ void AssExporter::Export(agi::fs::path const& filename, std::string const& chars
|
||||||
if (!writer)
|
if (!writer)
|
||||||
throw "Unknown file type.";
|
throw "Unknown file type.";
|
||||||
|
|
||||||
writer->WriteFile(&subs, filename, charset);
|
writer->WriteFile(&subs, filename, c->videoController->FPS(), charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSizer *AssExporter::GetSettingsSizer(std::string const& name) {
|
wxSizer *AssExporter::GetSettingsSizer(std::string const& name) {
|
||||||
|
|
|
@ -24,4 +24,4 @@ namespace crash_writer {
|
||||||
|
|
||||||
void Write();
|
void Write();
|
||||||
void Write(std::string const& error);
|
void Write(std::string const& error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -589,7 +589,7 @@ void DialogStyleManager::OnCurrentImport() {
|
||||||
if (!reader)
|
if (!reader)
|
||||||
wxMessageBox("Unsupported subtitle format", "Error", wxOK | wxICON_ERROR | wxCENTER, this);
|
wxMessageBox("Unsupported subtitle format", "Error", wxOK | wxICON_ERROR | wxCENTER, this);
|
||||||
else
|
else
|
||||||
reader->ReadFile(&temp, filename, charset);
|
reader->ReadFile(&temp, filename, 0, charset);
|
||||||
}
|
}
|
||||||
catch (agi::Exception const& err) {
|
catch (agi::Exception const& err) {
|
||||||
wxMessageBox(to_wx(err.GetChainedMessage()), "Error", wxOK | wxICON_ERROR | wxCENTER, this);
|
wxMessageBox(to_wx(err.GetChainedMessage()), "Error", wxOK | wxICON_ERROR | wxCENTER, this);
|
||||||
|
|
|
@ -206,7 +206,6 @@ bool AegisubApp::OnInit() {
|
||||||
agi::util::SetThreadName("AegiMain");
|
agi::util::SetThreadName("AegiMain");
|
||||||
|
|
||||||
StartupLog("Inside OnInit");
|
StartupLog("Inside OnInit");
|
||||||
frame = nullptr;
|
|
||||||
try {
|
try {
|
||||||
// Initialize randomizer
|
// Initialize randomizer
|
||||||
StartupLog("Initialize random generator");
|
StartupLog("Initialize random generator");
|
||||||
|
|
|
@ -67,11 +67,11 @@ class AegisubApp : public wxApp {
|
||||||
// our ticket to catch exceptions happening in event handlers.
|
// our ticket to catch exceptions happening in event handlers.
|
||||||
void HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const override;
|
void HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const override;
|
||||||
|
|
||||||
FrameMain *frame;
|
FrameMain *frame = nullptr;
|
||||||
public:
|
public:
|
||||||
AegisubApp();
|
AegisubApp();
|
||||||
AegisubLocale locale;
|
AegisubLocale locale;
|
||||||
Automation4::AutoloadScriptManager *global_scripts;
|
Automation4::AutoloadScriptManager *global_scripts = nullptr;
|
||||||
|
|
||||||
// Apple events
|
// Apple events
|
||||||
void MacOpenFile(const wxString &filename);
|
void MacOpenFile(const wxString &filename);
|
||||||
|
|
|
@ -186,7 +186,7 @@ void SubsController::Load(agi::fs::path const& filename, std::string charset) {
|
||||||
const SubtitleFormat *reader = SubtitleFormat::GetReader(filename, charset);
|
const SubtitleFormat *reader = SubtitleFormat::GetReader(filename, charset);
|
||||||
|
|
||||||
AssFile temp;
|
AssFile temp;
|
||||||
reader->ReadFile(&temp, filename, charset);
|
reader->ReadFile(&temp, filename, context->videoController->FPS(), charset);
|
||||||
|
|
||||||
// Make sure the file has at least one style and one dialogue line
|
// Make sure the file has at least one style and one dialogue line
|
||||||
if (temp.Styles.empty())
|
if (temp.Styles.empty())
|
||||||
|
@ -256,7 +256,7 @@ void SubsController::Save(agi::fs::path const& filename, std::string const& enco
|
||||||
|
|
||||||
FileSave();
|
FileSave();
|
||||||
|
|
||||||
writer->WriteFile(context->ass.get(), filename, encoding);
|
writer->WriteFile(context->ass.get(), filename, 0, encoding);
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
autosaved_commit_id = old_autosaved_commit_id;
|
autosaved_commit_id = old_autosaved_commit_id;
|
||||||
|
@ -311,7 +311,7 @@ agi::fs::path SubsController::AutoSave() {
|
||||||
|
|
||||||
path /= str(boost::format("%s.%s.AUTOSAVE.ass") % name.string() % agi::util::strftime("%Y-%m-%d-%H-%M-%S"));
|
path /= str(boost::format("%s.%s.AUTOSAVE.ass") % name.string() % agi::util::strftime("%Y-%m-%d-%H-%M-%S"));
|
||||||
|
|
||||||
SubtitleFormat::GetWriter(path)->WriteFile(context->ass.get(), path);
|
SubtitleFormat::GetWriter(path)->WriteFile(context->ass.get(), path, 0);
|
||||||
autosaved_commit_id = commit_id;
|
autosaved_commit_id = commit_id;
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
|
|
@ -106,15 +106,14 @@ bool SubtitleFormat::CanSave(const AssFile *subs) const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
agi::vfr::Framerate SubtitleFormat::AskForFPS(bool allow_vfr, bool show_smpte) {
|
agi::vfr::Framerate SubtitleFormat::AskForFPS(bool allow_vfr, bool show_smpte, agi::vfr::Framerate const& fps) {
|
||||||
wxArrayString choices;
|
wxArrayString choices;
|
||||||
|
|
||||||
// Video FPS
|
bool vidLoaded = false;
|
||||||
VideoContext *context = VideoContext::Get();
|
if (fps.IsLoaded()) {
|
||||||
bool vidLoaded = context->TimecodesLoaded();
|
vidLoaded = true;
|
||||||
if (vidLoaded) {
|
if (!fps.IsVFR())
|
||||||
if (!context->FPS().IsVFR())
|
choices.Add(wxString::Format(_("From video (%g)"), fps.FPS()));
|
||||||
choices.Add(wxString::Format(_("From video (%g)"), context->FPS().FPS()));
|
|
||||||
else if (allow_vfr)
|
else if (allow_vfr)
|
||||||
choices.Add(_("From video (VFR)"));
|
choices.Add(_("From video (VFR)"));
|
||||||
else
|
else
|
||||||
|
@ -152,7 +151,7 @@ agi::vfr::Framerate SubtitleFormat::AskForFPS(bool allow_vfr, bool show_smpte) {
|
||||||
--choice;
|
--choice;
|
||||||
|
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case -1: return context->FPS(); break; // VIDEO
|
case -1: return fps; break;
|
||||||
case 0: return Framerate(15, 1); break;
|
case 0: return Framerate(15, 1); break;
|
||||||
case 1: return Framerate(24000, 1001); break;
|
case 1: return Framerate(24000, 1001); break;
|
||||||
case 2: return Framerate(24, 1); break;
|
case 2: return Framerate(24, 1); break;
|
||||||
|
@ -166,9 +165,7 @@ agi::vfr::Framerate SubtitleFormat::AskForFPS(bool allow_vfr, bool show_smpte) {
|
||||||
case 10: return Framerate(120000, 1001); break;
|
case 10: return Framerate(120000, 1001); break;
|
||||||
case 11: return Framerate(120, 1); break;
|
case 11: return Framerate(120, 1); break;
|
||||||
}
|
}
|
||||||
|
throw agi::InternalError("Out of bounds result from wxGetSingleChoiceIndex?", nullptr);
|
||||||
assert(false);
|
|
||||||
return Framerate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubtitleFormat::StripTags(AssFile &file) {
|
void SubtitleFormat::StripTags(AssFile &file) {
|
||||||
|
|
|
@ -27,11 +27,6 @@
|
||||||
//
|
//
|
||||||
// Aegisub Project http://www.aegisub.org/
|
// Aegisub Project http://www.aegisub.org/
|
||||||
|
|
||||||
/// @file subtitle_format.h
|
|
||||||
/// @see subtitle_format.cpp
|
|
||||||
/// @ingroup subtitle_io
|
|
||||||
///
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <libaegisub/exception.h>
|
#include <libaegisub/exception.h>
|
||||||
|
@ -70,7 +65,7 @@ public:
|
||||||
/// Prompt the user for a frame rate to use
|
/// Prompt the user for a frame rate to use
|
||||||
/// @param allow_vfr Include video frame rate as an option even if it's vfr
|
/// @param allow_vfr Include video frame rate as an option even if it's vfr
|
||||||
/// @param show_smpte Show SMPTE drop frame option
|
/// @param show_smpte Show SMPTE drop frame option
|
||||||
static agi::vfr::Framerate AskForFPS(bool allow_vfr, bool show_smpte);
|
static agi::vfr::Framerate AskForFPS(bool allow_vfr, bool show_smpte, agi::vfr::Framerate const& fps);
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param Subtitle format name
|
/// @param Subtitle format name
|
||||||
|
@ -103,13 +98,13 @@ public:
|
||||||
/// @param[out] target Destination to read lines into
|
/// @param[out] target Destination to read lines into
|
||||||
/// @param filename File to load
|
/// @param filename File to load
|
||||||
/// @param encoding Encoding to use. May be ignored by the reader.
|
/// @param encoding Encoding to use. May be ignored by the reader.
|
||||||
virtual void ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& encoding) const { }
|
virtual void ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const { }
|
||||||
|
|
||||||
/// Save a subtitle file
|
/// Save a subtitle file
|
||||||
/// @param src Data to write
|
/// @param src Data to write
|
||||||
/// @param filename File to write to
|
/// @param filename File to write to
|
||||||
/// @param forceEncoding Encoding to use or empty string for default
|
/// @param forceEncoding Encoding to use or empty string for default
|
||||||
virtual void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding="") const { }
|
virtual void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding="") const { }
|
||||||
|
|
||||||
/// Get the wildcards for a save or load dialog
|
/// Get the wildcards for a save or load dialog
|
||||||
/// @param mode 0: load 1: save
|
/// @param mode 0: load 1: save
|
||||||
|
|
|
@ -45,7 +45,7 @@ std::vector<std::string> AssSubtitleFormat::GetWriteWildcards() const {
|
||||||
return {"ass", "ssa"};
|
return {"ass", "ssa"};
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& encoding) const {
|
void AssSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const {
|
||||||
TextFileReader file(filename, encoding);
|
TextFileReader file(filename, encoding);
|
||||||
int version = !agi::fs::HasExtension(filename, "ssa");
|
int version = !agi::fs::HasExtension(filename, "ssa");
|
||||||
AssParser parser(target, version);
|
AssParser parser(target, version);
|
||||||
|
@ -119,7 +119,7 @@ struct Writer {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const {
|
void AssSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const {
|
||||||
Writer writer(filename, encoding);
|
Writer writer(filename, encoding);
|
||||||
|
|
||||||
writer.Write(src->Info);
|
writer.Write(src->Info);
|
||||||
|
|
|
@ -44,6 +44,6 @@ public:
|
||||||
// Naturally the ASS subtitle format can save all Ass files
|
// Naturally the ASS subtitle format can save all Ass files
|
||||||
bool CanSave(const AssFile*) const override { return true; }
|
bool CanSave(const AssFile*) const override { return true; }
|
||||||
|
|
||||||
void ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& forceEncoding) const override;
|
void ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& forceEncoding) const override;
|
||||||
void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override;
|
void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -635,7 +635,7 @@ std::vector<std::string> Ebu3264SubtitleFormat::GetWriteWildcards() const
|
||||||
return formats;
|
return formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ebu3264SubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const&) const
|
void Ebu3264SubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const&) const
|
||||||
{
|
{
|
||||||
// collect data from user
|
// collect data from user
|
||||||
EbuExportSettings export_settings = get_export_config(nullptr);
|
EbuExportSettings export_settings = get_export_config(nullptr);
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Ebu3264SubtitleFormat final : public SubtitleFormat {
|
||||||
public:
|
public:
|
||||||
Ebu3264SubtitleFormat();
|
Ebu3264SubtitleFormat();
|
||||||
std::vector<std::string> GetWriteWildcards() const override;
|
std::vector<std::string> GetWriteWildcards() const override;
|
||||||
void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override;
|
void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const override;
|
||||||
|
|
||||||
DEFINE_SIMPLE_EXCEPTION(ConversionFailed, agi::InvalidInputException, "subtitle_io/ebu3264/conversion_error")
|
DEFINE_SIMPLE_EXCEPTION(ConversionFailed, agi::InvalidInputException, "subtitle_io/ebu3264/conversion_error")
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,8 +55,8 @@ std::vector<std::string> EncoreSubtitleFormat::GetWriteWildcards() const {
|
||||||
return formats;
|
return formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncoreSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const&) const {
|
void EncoreSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& video_fps, std::string const&) const {
|
||||||
agi::vfr::Framerate fps = AskForFPS(false, true);
|
agi::vfr::Framerate fps = AskForFPS(false, true, video_fps);
|
||||||
if (!fps.IsLoaded()) return;
|
if (!fps.IsLoaded()) return;
|
||||||
|
|
||||||
// Convert to encore
|
// Convert to encore
|
||||||
|
|
|
@ -38,5 +38,5 @@ class EncoreSubtitleFormat final : public SubtitleFormat {
|
||||||
public:
|
public:
|
||||||
EncoreSubtitleFormat();
|
EncoreSubtitleFormat();
|
||||||
std::vector<std::string> GetWriteWildcards() const override;
|
std::vector<std::string> GetWriteWildcards() const override;
|
||||||
void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const&) const override;
|
void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const&) const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,7 +80,7 @@ bool MicroDVDSubtitleFormat::CanReadFile(agi::fs::path const& filename, std::str
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MicroDVDSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& encoding) const {
|
void MicroDVDSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& vfps, std::string const& encoding) const {
|
||||||
TextFileReader file(filename, encoding);
|
TextFileReader file(filename, encoding);
|
||||||
|
|
||||||
target->LoadDefault(false);
|
target->LoadDefault(false);
|
||||||
|
@ -106,7 +106,7 @@ void MicroDVDSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& file
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it wasn't an fps line, ask the user for it
|
// If it wasn't an fps line, ask the user for it
|
||||||
fps = AskForFPS(true, false);
|
fps = AskForFPS(true, false, vfps);
|
||||||
if (!fps.IsLoaded()) return;
|
if (!fps.IsLoaded()) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,8 +123,8 @@ void MicroDVDSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& file
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MicroDVDSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const {
|
void MicroDVDSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& vfps, std::string const& encoding) const {
|
||||||
agi::vfr::Framerate fps = AskForFPS(true, false);
|
agi::vfr::Framerate fps = AskForFPS(true, false, vfps);
|
||||||
if (!fps.IsLoaded()) return;
|
if (!fps.IsLoaded()) return;
|
||||||
|
|
||||||
AssFile copy(*src);
|
AssFile copy(*src);
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
std::vector<std::string> GetWriteWildcards() const override;
|
std::vector<std::string> GetWriteWildcards() const override;
|
||||||
|
|
||||||
bool CanReadFile(agi::fs::path const& filename, std::string const& encoding) const override;
|
bool CanReadFile(agi::fs::path const& filename, std::string const& encoding) const override;
|
||||||
void ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& forceEncoding) const override;
|
void ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& forceEncoding) const override;
|
||||||
|
|
||||||
void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override;
|
void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -51,6 +51,6 @@ std::vector<std::string> MKVSubtitleFormat::GetReadWildcards() const {
|
||||||
return formats;
|
return formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MKVSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, std::string const&) const {
|
void MKVSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const&) const {
|
||||||
MatroskaWrapper::GetSubtitles(filename, target);
|
MatroskaWrapper::GetSubtitles(filename, target);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,5 +39,5 @@ public:
|
||||||
MKVSubtitleFormat();
|
MKVSubtitleFormat();
|
||||||
std::vector<std::string> GetReadWildcards() const override;
|
std::vector<std::string> GetReadWildcards() const override;
|
||||||
|
|
||||||
void ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& forceEncoding) const override;
|
void ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& forceEncoding) const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -351,7 +351,7 @@ enum ParseState {
|
||||||
STATE_LAST_WAS_BLANK
|
STATE_LAST_WAS_BLANK
|
||||||
};
|
};
|
||||||
|
|
||||||
void SRTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& encoding) const {
|
void SRTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
TextFileReader file(filename, encoding);
|
TextFileReader file(filename, encoding);
|
||||||
|
@ -463,7 +463,7 @@ found_timestamps:
|
||||||
line->Text = tag_parser.ToAss(text);
|
line->Text = tag_parser.ToAss(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SRTSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const {
|
void SRTSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const {
|
||||||
TextFileWriter file(filename, encoding);
|
TextFileWriter file(filename, encoding);
|
||||||
|
|
||||||
// Convert to SRT
|
// Convert to SRT
|
||||||
|
|
|
@ -45,6 +45,6 @@ public:
|
||||||
|
|
||||||
bool CanSave(const AssFile *file) const override;
|
bool CanSave(const AssFile *file) const override;
|
||||||
|
|
||||||
void ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& forceEncoding) const override;
|
void ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& forceEncoding) const override;
|
||||||
void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override;
|
void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -59,8 +59,8 @@ std::vector<std::string> TranStationSubtitleFormat::GetWriteWildcards() const {
|
||||||
return formats;
|
return formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranStationSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const {
|
void TranStationSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& vfps, std::string const& encoding) const {
|
||||||
agi::vfr::Framerate fps = AskForFPS(false, true);
|
agi::vfr::Framerate fps = AskForFPS(false, true, vfps);
|
||||||
if (!fps.IsLoaded()) return;
|
if (!fps.IsLoaded()) return;
|
||||||
|
|
||||||
// Convert to TranStation
|
// Convert to TranStation
|
||||||
|
|
|
@ -43,5 +43,5 @@ class TranStationSubtitleFormat final : public SubtitleFormat {
|
||||||
public:
|
public:
|
||||||
TranStationSubtitleFormat();
|
TranStationSubtitleFormat();
|
||||||
std::vector<std::string> GetWriteWildcards() const override;
|
std::vector<std::string> GetWriteWildcards() const override;
|
||||||
void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override;
|
void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,7 +63,7 @@ std::vector<std::string> TTXTSubtitleFormat::GetWriteWildcards() const {
|
||||||
return GetReadWildcards();
|
return GetReadWildcards();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& encoding) const {
|
void TTXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const {
|
||||||
target->LoadDefault(false);
|
target->LoadDefault(false);
|
||||||
|
|
||||||
// Load XML document
|
// Load XML document
|
||||||
|
@ -160,7 +160,7 @@ void TTXTSubtitleFormat::ProcessHeader(wxXmlNode *node) const {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTXTSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const {
|
void TTXTSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const {
|
||||||
// Convert to TTXT
|
// Convert to TTXT
|
||||||
AssFile copy(*src);
|
AssFile copy(*src);
|
||||||
ConvertToTTXT(copy);
|
ConvertToTTXT(copy);
|
||||||
|
|
|
@ -51,6 +51,6 @@ public:
|
||||||
std::vector<std::string> GetReadWildcards() const override;
|
std::vector<std::string> GetReadWildcards() const override;
|
||||||
std::vector<std::string> GetWriteWildcards() const override;
|
std::vector<std::string> GetWriteWildcards() const override;
|
||||||
|
|
||||||
void ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& forceEncoding) const override;
|
void ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& forceEncoding) const override;
|
||||||
void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override;
|
void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -68,7 +68,7 @@ bool TXTSubtitleFormat::CanWriteFile(agi::fs::path const& filename) const {
|
||||||
return boost::iends_with(str, ".txt") && !(boost::iends_with(str, ".encore.txt") || boost::iends_with(str, ".transtation.txt"));
|
return boost::iends_with(str, ".txt") && !(boost::iends_with(str, ".encore.txt") || boost::iends_with(str, ".transtation.txt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& encoding) const {
|
void TXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const {
|
||||||
DialogTextImport dlg;
|
DialogTextImport dlg;
|
||||||
if (dlg.ShowModal() == wxID_CANCEL) return;
|
if (dlg.ShowModal() == wxID_CANCEL) return;
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ void TXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TXTSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const {
|
void TXTSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const {
|
||||||
size_t num_actor_names = 0, num_dialogue_lines = 0;
|
size_t num_actor_names = 0, num_dialogue_lines = 0;
|
||||||
|
|
||||||
// Detect number of lines with Actor field filled out
|
// Detect number of lines with Actor field filled out
|
||||||
|
|
|
@ -44,6 +44,6 @@ public:
|
||||||
bool CanSave(const AssFile*) const override { return false; }
|
bool CanSave(const AssFile*) const override { return false; }
|
||||||
|
|
||||||
bool CanWriteFile(agi::fs::path const& filename) const override;
|
bool CanWriteFile(agi::fs::path const& filename) const override;
|
||||||
void ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& forceEncoding) const override;
|
void ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& forceEncoding) const override;
|
||||||
void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override;
|
void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#include <libaegisub/path.h>
|
#include <libaegisub/path.h>
|
||||||
#include <libaegisub/scoped_ptr.h>
|
#include <libaegisub/scoped_ptr.h>
|
||||||
#include <libaegisub/util.h>
|
#include <libaegisub/util.h>
|
||||||
|
#include <libaegisub/vfr.h>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
@ -98,7 +99,7 @@ CSRISubtitlesProvider::~CSRISubtitlesProvider() {
|
||||||
void CSRISubtitlesProvider::LoadSubtitles(AssFile *subs) {
|
void CSRISubtitlesProvider::LoadSubtitles(AssFile *subs) {
|
||||||
if (tempfile.empty())
|
if (tempfile.empty())
|
||||||
tempfile = unique_path(config::path->Decode("?temp/csri-%%%%-%%%%-%%%%-%%%%.ass"));
|
tempfile = unique_path(config::path->Decode("?temp/csri-%%%%-%%%%-%%%%-%%%%.ass"));
|
||||||
SubtitleFormat::GetWriter(tempfile)->WriteFile(subs, tempfile, "utf-8");
|
SubtitleFormat::GetWriter(tempfile)->WriteFile(subs, tempfile, 0, "utf-8");
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(csri_mutex);
|
std::lock_guard<std::mutex> lock(csri_mutex);
|
||||||
instance = csri_open_file(renderer, tempfile.string().c_str(), nullptr);
|
instance = csri_open_file(renderer, tempfile.string().c_str(), nullptr);
|
||||||
|
|
|
@ -60,14 +60,11 @@
|
||||||
|
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
|
|
||||||
static VideoContext *instance;
|
|
||||||
|
|
||||||
VideoContext::VideoContext(agi::Context *c)
|
VideoContext::VideoContext(agi::Context *c)
|
||||||
: context(c)
|
: context(c)
|
||||||
, playback(this)
|
, playback(this)
|
||||||
, playAudioOnStep(OPT_GET("Audio/Plays When Stepping Video"))
|
, playAudioOnStep(OPT_GET("Audio/Plays When Stepping Video"))
|
||||||
{
|
{
|
||||||
instance = this;
|
|
||||||
context->ass->AddCommitListener(&VideoContext::OnSubtitlesCommit, this);
|
context->ass->AddCommitListener(&VideoContext::OnSubtitlesCommit, this);
|
||||||
context->subsController->AddFileSaveListener(&VideoContext::OnSubtitlesSave, this);
|
context->subsController->AddFileSaveListener(&VideoContext::OnSubtitlesSave, this);
|
||||||
|
|
||||||
|
@ -89,10 +86,6 @@ VideoContext::VideoContext(agi::Context *c)
|
||||||
|
|
||||||
VideoContext::~VideoContext () { }
|
VideoContext::~VideoContext () { }
|
||||||
|
|
||||||
VideoContext *VideoContext::Get() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VideoContext::Reset() {
|
void VideoContext::Reset() {
|
||||||
config::path->SetToken("?video", "");
|
config::path->SetToken("?video", "");
|
||||||
|
|
||||||
|
|
|
@ -269,6 +269,4 @@ public:
|
||||||
|
|
||||||
int TimeAtFrame(int frame, agi::vfr::Time type = agi::vfr::EXACT) const;
|
int TimeAtFrame(int frame, agi::vfr::Time type = agi::vfr::EXACT) const;
|
||||||
int FrameAtTime(int time, agi::vfr::Time type = agi::vfr::EXACT) const;
|
int FrameAtTime(int time, agi::vfr::Time type = agi::vfr::EXACT) const;
|
||||||
|
|
||||||
static VideoContext *Get();
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue