From e49486201d2bc62e804e5246c4e40604dac4b13c Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 6 Dec 2011 00:17:54 +0000 Subject: [PATCH] Eliminate the duplication between VideoContext::videoName and VideoContext::videoFile Originally committed to SVN as r5969. --- aegisub/src/command/audio.cpp | 2 +- aegisub/src/command/subtitle.cpp | 2 +- aegisub/src/command/video.cpp | 4 ++-- aegisub/src/dialog_detached_video.cpp | 2 +- aegisub/src/dialog_video_details.cpp | 2 +- aegisub/src/frame_main.cpp | 4 ++-- aegisub/src/video_context.cpp | 8 +++----- aegisub/src/video_context.h | 6 +++--- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/aegisub/src/command/audio.cpp b/aegisub/src/command/audio.cpp index 1924593cb..70510ec3e 100644 --- a/aegisub/src/command/audio.cpp +++ b/aegisub/src/command/audio.cpp @@ -151,7 +151,7 @@ struct audio_open_video : public Command { void operator()(agi::Context *c) { try { - c->audioController->OpenAudio(c->videoController->videoName); + c->audioController->OpenAudio(c->videoController->GetVideoName()); } catch (agi::Exception const& e) { wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxICON_ERROR | wxOK); diff --git a/aegisub/src/command/subtitle.cpp b/aegisub/src/command/subtitle.cpp index 2aa6f2eb9..988beab7d 100644 --- a/aegisub/src/command/subtitle.cpp +++ b/aegisub/src/command/subtitle.cpp @@ -299,7 +299,7 @@ struct subtitle_open_video : public Command { CMD_TYPE(COMMAND_VALIDATE) void operator()(agi::Context *c) { - wxGetApp().frame->LoadSubtitles(c->videoController->videoName, "binary"); + wxGetApp().frame->LoadSubtitles(c->videoController->GetVideoName(), "binary"); } bool Validate(const agi::Context *c) { diff --git a/aegisub/src/command/video.cpp b/aegisub/src/command/video.cpp index 32f9b0cb7..c4f06a5fd 100644 --- a/aegisub/src/command/video.cpp +++ b/aegisub/src/command/video.cpp @@ -480,13 +480,13 @@ struct video_frame_prev_large : public validator_video_loaded { static void save_snapshot(agi::Context *c, bool raw) { static const agi::OptionValue* ssPath = OPT_GET("Path/Screenshot"); wxString option = lagi_wxString(ssPath->GetString()); - wxFileName videoFile(c->videoController->videoName); + wxFileName videoFile(c->videoController->GetVideoName()); wxString basepath; // Is it a path specifier and not an actual fixed path? if (option[0] == '?') { // If dummy video is loaded, we can't save to the video location - if (option.StartsWith("?video") && (c->videoController->videoName.Find("?dummy") != wxNOT_FOUND)) { + if (option.StartsWith("?video") && (c->videoController->GetVideoName().Find("?dummy") != wxNOT_FOUND)) { // So try the script location instead option = "?script"; } diff --git a/aegisub/src/dialog_detached_video.cpp b/aegisub/src/dialog_detached_video.cpp index d5274cc31..d468dd4f0 100644 --- a/aegisub/src/dialog_detached_video.cpp +++ b/aegisub/src/dialog_detached_video.cpp @@ -62,7 +62,7 @@ DialogDetachedVideo::DialogDetachedVideo(agi::Context *context, const wxSize &in // Set obscure stuff SetExtraStyle((GetExtraStyle() & ~wxWS_EX_BLOCK_EVENTS) | wxWS_EX_PROCESS_UI_UPDATES); - SetTitle(wxString::Format(_("Video: %s"), wxFileName(context->videoController->videoName).GetFullName())); + SetTitle(wxString::Format(_("Video: %s"), wxFileName(context->videoController->GetVideoName()).GetFullName())); // Set a background panel wxPanel *panel = new wxPanel(this,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL | wxCLIP_CHILDREN); diff --git a/aegisub/src/dialog_video_details.cpp b/aegisub/src/dialog_video_details.cpp index 1be45abdb..f0bf4b190 100644 --- a/aegisub/src/dialog_video_details.cpp +++ b/aegisub/src/dialog_video_details.cpp @@ -83,7 +83,7 @@ DialogVideoDetails::DialogVideoDetails(agi::Context *c) double fps = c->videoController->FPS().FPS(); wxFlexGridSizer *fg = new wxFlexGridSizer(2, 5, 10); - make_field(this, fg, _("File name:"), c->videoController->videoName); + make_field(this, fg, _("File name:"), c->videoController->GetVideoName()); make_field(this, fg, _("FPS:"), wxString::Format("%.3f", fps)); make_field(this, fg, _("Resolution:"), wxString::Format("%dx%d (%s)", width, height, pretty_ar(width, height))); make_field(this, fg, _("Length:"), wxString::Format(_("%d frames (%s)"), framecount, pretty_time_stamp(framecount, fps))); diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index 1aaa06803..cf2c3addc 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -606,7 +606,7 @@ void FrameMain::OnSubtitlesOpen() { bool doLoad = false; if (curSubsAudio != context->audioController->GetAudioURL() || curSubsVFR != context->videoController->GetTimecodesName() || - curSubsVideo != context->videoController->videoName || + curSubsVideo != context->videoController->GetVideoName() || curSubsKeyframes != context->videoController->GetKeyFramesName() ) { @@ -620,7 +620,7 @@ void FrameMain::OnSubtitlesOpen() { if (doLoad) { // Video - if (!blockVideoLoad && curSubsVideo != context->videoController->videoName) { + if (!blockVideoLoad && curSubsVideo != context->videoController->GetVideoName()) { context->videoController->SetVideo(curSubsVideo); if (context->videoController->IsLoaded()) { context->videoController->JumpToFrame(context->ass->GetScriptInfoAsInt("Video Position")); diff --git a/aegisub/src/video_context.cpp b/aegisub/src/video_context.cpp index ee5243a63..d4a74b61d 100644 --- a/aegisub/src/video_context.cpp +++ b/aegisub/src/video_context.cpp @@ -119,7 +119,7 @@ void VideoContext::Reset() { frame_n = 0; // Clean up video data - videoName.clear(); + videoFile.clear(); // Remove provider provider.reset(); @@ -188,10 +188,8 @@ void VideoContext::SetVideo(const wxString &filename) { } // Set filename - videoName = filename; config::mru->Add("Video", STD_STR(filename)); - wxFileName fn(filename); - StandardPaths::SetPathValue("?video",fn.GetPath()); + StandardPaths::SetPathValue("?video", wxFileName(filename).GetPath()); // Get frame frame_n = 0; @@ -256,7 +254,7 @@ void VideoContext::OnSubtitlesSave() { else ar = wxString::Format("%d", arType); - context->ass->SetScriptInfo("Video File", MakeRelativePath(videoName, context->ass->filename)); + context->ass->SetScriptInfo("Video File", MakeRelativePath(videoFile, context->ass->filename)); context->ass->SetScriptInfo("Video Aspect Ratio", ar); context->ass->SetScriptInfo("Video Position", wxString::Format("%d", frame_n)); context->ass->SetScriptInfo("VFR File", MakeRelativePath(GetTimecodesName(), context->ass->filename)); diff --git a/aegisub/src/video_context.h b/aegisub/src/video_context.h index 3af1873eb..fe99e58a3 100644 --- a/aegisub/src/video_context.h +++ b/aegisub/src/video_context.h @@ -134,9 +134,6 @@ class VideoContext : public wxEvtHandler { void Reset(); public: - /// File name of currently open video, if any - wxString videoName; - const agi::vfr::Framerate &VFR_Input; const agi::vfr::Framerate &VFR_Output; @@ -158,6 +155,9 @@ public: /// @brief Is there a video loaded? bool IsLoaded() const { return !!videoProvider; } + /// Get the file name of the currently open video, if any + wxString GetVideoName() const { return videoFile; } + /// @brief Is the video currently playing? bool IsPlaying() const { return playback.IsRunning(); }