diff --git a/aegisub/src/ass_file.cpp b/aegisub/src/ass_file.cpp index da5692f55..534f8746a 100644 --- a/aegisub/src/ass_file.cpp +++ b/aegisub/src/ass_file.cpp @@ -455,8 +455,6 @@ void AssFile::LoadDefault(bool defline) { AddLine("Title: Default Aegisub file","[Script Info]",version); AddLine("ScriptType: v4.00+","[Script Info]",version); AddLine("WrapStyle: 0", "[Script Info]",version); - AddLine("PlayResX: 640","[Script Info]",version); - AddLine("PlayResY: 480","[Script Info]",version); AddLine("ScaledBorderAndShadow: yes","[Script Info]",version); AddLine("Collisions: Normal","[Script Info]",version); AddLine("","[Script Info]",version); diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index 9d375b1d6..16a68a40f 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -407,29 +407,6 @@ void FrameMain::OnVideoOpen() { else if (vidx*3*zoom > windowSize.GetX()*2 || vidy*4*zoom > windowSize.GetY()*3) context->videoDisplay->SetZoom(zoom * .5); - // Check that the video size matches the script video size specified - int scriptx = context->ass->GetScriptInfoAsInt("PlayResX"); - int scripty = context->ass->GetScriptInfoAsInt("PlayResY"); - if (scriptx != vidx || scripty != vidy) { - switch (OPT_GET("Video/Check Script Res")->GetInt()) { - case 1: - // Ask to change on mismatch - if (wxMessageBox(wxString::Format(_("The resolution of the loaded video and the resolution specified for the subtitles don't match.\n\nVideo resolution:\t%d x %d\nScript resolution:\t%d x %d\n\nChange subtitles resolution to match video?"), vidx, vidy, scriptx, scripty), _("Resolution mismatch"), wxYES_NO, this) != wxYES) - break; - // Fallthrough to case 2 - case 2: - // Always change script res - context->ass->SetScriptInfo("PlayResX", wxString::Format("%d", vidx)); - context->ass->SetScriptInfo("PlayResY", wxString::Format("%d", vidy)); - context->ass->Commit(_("Change script resolution"), AssFile::COMMIT_SCRIPTINFO); - break; - case 0: - default: - // Never change - break; - } - } - SetDisplayMode(1,-1); if (OPT_GET("Video/Detached/Enabled")->GetBool() && !context->detachedVideo) diff --git a/aegisub/src/video_context.cpp b/aegisub/src/video_context.cpp index 33e9d8e9f..1b1036a3a 100644 --- a/aegisub/src/video_context.cpp +++ b/aegisub/src/video_context.cpp @@ -159,6 +159,37 @@ void VideoContext::SetVideo(const wxString &filename) { videoProvider = provider->GetVideoProvider(); videoFile = filename; + // Check that the script resolution matches the video resolution + int sx = context->ass->GetScriptInfoAsInt("PlayResX"); + int sy = context->ass->GetScriptInfoAsInt("PlayResY"); + int vx = GetWidth(); + int vy = GetHeight(); + + // If the script resolution hasn't been set at all just force it to the + // video resolution + if (sx == 0 && sy == 0) { + context->ass->SetScriptInfo("PlayResX", wxString::Format("%d", vx)); + context->ass->SetScriptInfo("PlayResY", wxString::Format("%d", vy)); + context->ass->Commit(_("Change script resolution"), AssFile::COMMIT_SCRIPTINFO); + } + // If it has been set to something other than a multiple of the video + // resolution, ask the user if they want it to be fixed + else if (sx % vx != 0 || sy % vy != 0) { + switch (OPT_GET("Video/Check Script Res")->GetInt()) { + case 1: // Ask to change on mismatch + if (wxMessageBox(wxString::Format(_("The resolution of the loaded video and the resolution specified for the subtitles don't match.\n\nVideo resolution:\t%d x %d\nScript resolution:\t%d x %d\n\nChange subtitles resolution to match video?"), vx, vy, sx, sy), _("Resolution mismatch"), wxYES_NO, context->parent) != wxYES) + break; + // Fallthrough to case 2 + case 2: // Always change script res + context->ass->SetScriptInfo("PlayResX", wxString::Format("%d", vx)); + context->ass->SetScriptInfo("PlayResY", wxString::Format("%d", vy)); + context->ass->Commit(_("change script resolution"), AssFile::COMMIT_SCRIPTINFO); + break; + default: // Never change + break; + } + } + keyFrames = videoProvider->GetKeyFrames(); // Set frame rate