Revamp script resolution setting logic

Rather than setting the default script resolution to 640x480, leave it
unset in new files. When video is opened, if the user has not already
manually set a script resolution, automatically use the video's
resolution as the script resolution. If the user has and the set
resolution is not a multiple of the video resolution, use the old prompt
for updating it.

This eliminates the confusing prompt about mismatched resolutions when
opening video with a new file while hopefully resulting in users using
the correct resolution more often.

Originally committed to SVN as r5921.
This commit is contained in:
Thomas Goyne 2011-11-28 22:16:22 +00:00
parent f519a493c8
commit ca91097b8f
3 changed files with 31 additions and 25 deletions

View file

@ -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);

View file

@ -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)

View file

@ -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