mirror of https://github.com/odrling/Aegisub
Simplify some AssTime-using code
Originally committed to SVN as r6124.
This commit is contained in:
parent
71345af81a
commit
5cbd35e749
|
@ -464,13 +464,10 @@ void AudioTimingControllerDialogue::Revert()
|
|||
{
|
||||
if (AssDialogue *line = context->selectionController->GetActiveLine())
|
||||
{
|
||||
AssTime new_start = line->Start;
|
||||
AssTime new_end = line->End;
|
||||
|
||||
if (new_start != 0 || new_end != 0)
|
||||
if (line->Start != 0 || line->End != 0)
|
||||
{
|
||||
active_markers[0].SetPosition(context->audioController->SamplesFromMilliseconds(new_start));
|
||||
active_markers[1].SetPosition(context->audioController->SamplesFromMilliseconds(new_end));
|
||||
active_markers[0].SetPosition(context->audioController->SamplesFromMilliseconds(line->Start));
|
||||
active_markers[1].SetPosition(context->audioController->SamplesFromMilliseconds(line->End));
|
||||
timing_modified = false;
|
||||
UpdateSelection();
|
||||
}
|
||||
|
|
|
@ -62,7 +62,6 @@ DialogJumpTo::DialogJumpTo(agi::Context *c)
|
|||
SetIcon(BitmapToIcon(GETIMAGE(jumpto_button_24)));
|
||||
|
||||
// Set initial values
|
||||
AssTime jumptime = c->videoController->TimeAtFrame(jumpframe);
|
||||
wxString maxLength = wxString::Format("%i",c->videoController->GetLength() - 1);
|
||||
|
||||
// Times
|
||||
|
@ -70,7 +69,7 @@ DialogJumpTo::DialogJumpTo(agi::Context *c)
|
|||
wxStaticText *LabelTime = new wxStaticText(this,-1,_("Time: "),wxDefaultPosition,wxSize(60,20));
|
||||
JumpFrame = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(60,20),wxTE_PROCESS_ENTER, NumValidator((int)jumpframe));
|
||||
JumpFrame->SetMaxLength(maxLength.size());
|
||||
JumpTime = new TimeEdit(this, -1, c, jumptime.GetASSFormated(), wxSize(60,20));
|
||||
JumpTime = new TimeEdit(this, -1, c, AssTime(c->videoController->TimeAtFrame(jumpframe)).GetASSFormated(), wxSize(60,20));
|
||||
wxSizer *FrameSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxSizer *TimeSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
FrameSizer->Add(LabelFrame,0,wxALIGN_CENTER_VERTICAL,0);
|
||||
|
|
|
@ -355,20 +355,7 @@ allparsed:
|
|||
|
||||
wxString WriteSRTTime(AssTime const& ts)
|
||||
{
|
||||
int time = ts;
|
||||
|
||||
int ms_part = time % 1000;
|
||||
time /= 1000; // now holds seconds
|
||||
|
||||
int s_part = time % 60;
|
||||
time /= 60; // now holds minutes
|
||||
|
||||
int m_part = time % 60;
|
||||
time /= 60; // now holds hours
|
||||
|
||||
int h_part = time;
|
||||
|
||||
return wxString::Format("%02d:%02d:%02d,%03d", h_part, m_part, s_part, ms_part);
|
||||
return wxString::Format("%02d:%02d:%02d,%03d", ts.GetTimeHours(), ts.GetTimeMinutes(), ts.GetTimeSeconds(), ts.GetTimeMiliseconds());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -397,7 +384,6 @@ void SRTSubtitleFormat::ReadFile(wxString const& filename, wxString const& encod
|
|||
// See parsing algorithm at <http://devel.aegisub.org/wiki/SubtitleFormats/SRT>
|
||||
|
||||
// "hh:mm:ss,fff --> hh:mm:ss,fff" (e.g. "00:00:04,070 --> 00:00:10,04")
|
||||
/// @todo: move the full parsing of SRT timestamps here, instead of having it in AssTime
|
||||
wxRegEx timestamp_regex("^([0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{1,}) --> ([0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{1,})");
|
||||
if (!timestamp_regex.IsValid())
|
||||
throw agi::InternalError("Parsing SRT: Failed compiling regex", 0);
|
||||
|
@ -444,7 +430,6 @@ found_timestamps:
|
|||
line->group = "[Events]";
|
||||
line->Style = "Default";
|
||||
line->Comment = false;
|
||||
// this parsing should best be moved out of AssTime
|
||||
line->Start = ReadSRTTime(timestamp_regex.GetMatch(text_line, 1));
|
||||
line->End = ReadSRTTime(timestamp_regex.GetMatch(text_line, 2));
|
||||
// store pointer to subtitle, we'll continue working on it
|
||||
|
|
|
@ -112,7 +112,6 @@ wxString TranStationSubtitleFormat::ConvertLine(AssDialogue *current, Fractional
|
|||
if (current->Text.Find("\\i1") != wxNOT_FOUND) type = "I";
|
||||
|
||||
// Write header
|
||||
AssTime start = current->Start;
|
||||
AssTime end = current->End;
|
||||
|
||||
// Subtract one frame if the end time of the current line is equal to the
|
||||
|
@ -121,7 +120,7 @@ wxString TranStationSubtitleFormat::ConvertLine(AssDialogue *current, Fractional
|
|||
if (nextl_start > 0 && end == nextl_start)
|
||||
end = ft->FPS().TimeAtFrame(ft->FPS().FrameAtTime(end, agi::vfr::END) - 1, agi::vfr::END);
|
||||
|
||||
wxString header = wxString::Format("SUB[%i%s%s ", valign, halign, type) + ft->ToSMPTE(start) + ">" + ft->ToSMPTE(end) + "]\r\n";
|
||||
wxString header = wxString::Format("SUB[%i%s%s ", valign, halign, type) + ft->ToSMPTE(current->Start) + ">" + ft->ToSMPTE(end) + "]\r\n";
|
||||
|
||||
// Process text
|
||||
wxString lineEnd = "\r\n";
|
||||
|
|
|
@ -288,8 +288,7 @@ void TTXTSubtitleFormat::ConvertToTTXT () {
|
|||
// Find last line
|
||||
AssTime lastTime;
|
||||
for (std::list<AssEntry*>::reverse_iterator cur=Line->rbegin();cur!=Line->rend();cur++) {
|
||||
AssDialogue *prev = dynamic_cast<AssDialogue*>(*cur);
|
||||
if (prev) {
|
||||
if (AssDialogue *prev = dynamic_cast<AssDialogue*>(*cur)) {
|
||||
lastTime = prev->End;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue