Shuffle some stuff around in MicroDVDSubtitleFormat::ReadFile

This commit is contained in:
Thomas Goyne 2013-04-16 19:30:29 -07:00
parent b743bb39b0
commit d6fd2f016b
1 changed files with 23 additions and 22 deletions

View File

@ -96,34 +96,35 @@ void MicroDVDSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& file
while (file.HasMoreLines()) {
boost::smatch match;
std::string line = file.ReadLineFromFile();
if (regex_match(line, match, line_regex)) {
int f1 = boost::lexical_cast<int>(match[0]);
int f2 = boost::lexical_cast<int>(match[1]);
std::string text = match[2].str();
if (!regex_match(line, match, line_regex)) continue;
// If it's the first, check if it contains fps information
if (isFirst) {
isFirst = false;
std::string text = match[2].str();
double cfr;
if (agi::util::try_parse(text, &cfr)) {
fps = cfr;
continue;
}
// If it's the first, check if it contains fps information
if (isFirst) {
isFirst = false;
// If it wasn't an fps line, ask the user for it
fps = AskForFPS(true, false);
if (!fps.IsLoaded()) return;
double cfr;
if (agi::util::try_parse(text, &cfr)) {
fps = cfr;
continue;
}
boost::replace_all(text, "|", "\\N");
AssDialogue *diag = new AssDialogue;
diag->Start = fps.TimeAtFrame(f1, agi::vfr::START);
diag->End = fps.TimeAtFrame(f2, agi::vfr::END);
diag->Text = text;
target->Line.push_back(*diag);
// If it wasn't an fps line, ask the user for it
fps = AskForFPS(true, false);
if (!fps.IsLoaded()) return;
}
int f1 = boost::lexical_cast<int>(match[0]);
int f2 = boost::lexical_cast<int>(match[1]);
boost::replace_all(text, "|", "\\N");
AssDialogue *diag = new AssDialogue;
diag->Start = fps.TimeAtFrame(f1, agi::vfr::START);
diag->End = fps.TimeAtFrame(f2, agi::vfr::END);
diag->Text = text;
target->Line.push_back(*diag);
}
}