diff --git a/aegisub/src/audio_timing_dialogue.cpp b/aegisub/src/audio_timing_dialogue.cpp index 42592351c..943418e4c 100644 --- a/aegisub/src/audio_timing_dialogue.cpp +++ b/aegisub/src/audio_timing_dialogue.cpp @@ -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(); } diff --git a/aegisub/src/dialog_jumpto.cpp b/aegisub/src/dialog_jumpto.cpp index 738345a9e..895998641 100644 --- a/aegisub/src/dialog_jumpto.cpp +++ b/aegisub/src/dialog_jumpto.cpp @@ -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); diff --git a/aegisub/src/subtitle_format_srt.cpp b/aegisub/src/subtitle_format_srt.cpp index 2133bb9de..097f9d63f 100644 --- a/aegisub/src/subtitle_format_srt.cpp +++ b/aegisub/src/subtitle_format_srt.cpp @@ -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 // "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 diff --git a/aegisub/src/subtitle_format_transtation.cpp b/aegisub/src/subtitle_format_transtation.cpp index 788ec5ceb..d843e40e4 100644 --- a/aegisub/src/subtitle_format_transtation.cpp +++ b/aegisub/src/subtitle_format_transtation.cpp @@ -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"; diff --git a/aegisub/src/subtitle_format_ttxt.cpp b/aegisub/src/subtitle_format_ttxt.cpp index d43fbaf71..40d526a96 100644 --- a/aegisub/src/subtitle_format_ttxt.cpp +++ b/aegisub/src/subtitle_format_ttxt.cpp @@ -288,8 +288,7 @@ void TTXTSubtitleFormat::ConvertToTTXT () { // Find last line AssTime lastTime; for (std::list::reverse_iterator cur=Line->rbegin();cur!=Line->rend();cur++) { - AssDialogue *prev = dynamic_cast(*cur); - if (prev) { + if (AssDialogue *prev = dynamic_cast(*cur)) { lastTime = prev->End; break; }