From ad91cb4460a1d6a9e9599d5414ace9e85ca90f4c Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sat, 1 Jul 2006 07:22:57 +0000 Subject: [PATCH] Fixed the default resolution for video display and resolution resampler when the script's field is blank. Originally committed to SVN as r454. --- core/ass_file.cpp | 27 +++++++++++++++++++++++++++ core/ass_file.h | 5 +++-- core/changelog.txt | 1 + core/dialog_resample.cpp | 10 ++++++---- core/video_display.cpp | 23 +---------------------- 5 files changed, 38 insertions(+), 28 deletions(-) diff --git a/core/ass_file.cpp b/core/ass_file.cpp index 78601cd1d..1507c575b 100644 --- a/core/ass_file.cpp +++ b/core/ass_file.cpp @@ -673,6 +673,33 @@ void AssFile::SetScriptInfo(const wxString _key,const wxString value) { } +////////////////// +// Get resolution +void AssFile::GetResolution(int &sw,int &sh) { + // Height + wxString temp = GetScriptInfo(_T("PlayResY")); + if (temp.IsEmpty() || !temp.IsNumber()) { + sh = 288; + } + else { + long templ; + temp.ToLong(&templ); + sh = templ; + } + + // Width + temp = GetScriptInfo(_T("PlayResX")); + if (temp.IsEmpty() || !temp.IsNumber()) { + sw = 384; + } + else { + long templ; + temp.ToLong(&templ); + sw = templ; + } +} + + /////////////////////////////////// // Adds a comment to [Script Info] void AssFile::AddComment(const wxString _comment) { diff --git a/core/ass_file.h b/core/ass_file.h index e6869f56b..a5789f81e 100644 --- a/core/ass_file.h +++ b/core/ass_file.h @@ -96,8 +96,9 @@ public: void AddToRecent(wxString file); // Adds file name to list of recently opened files bool CanSave(); // Return true if the file can be saved in its current format - int GetScriptInfoAsInt(const wxString key); - wxString GetScriptInfo(const wxString key); // Returns the value in a [Script Info] key. + void GetResolution(int &w,int &h); // Get resolution + int GetScriptInfoAsInt(const wxString key); // Returns the value in a [Script Info] key as int. + wxString GetScriptInfo(const wxString key); // Returns the value in a [Script Info] key as string. void SetScriptInfo(const wxString key,const wxString value); // Sets the value of a [Script Info] key. Adds it if it doesn't exist. void AddComment(const wxString comment); // Adds a ";" comment under [Script Info]. int AddLine(wxString data,wxString group,int lasttime,bool &IsSSA,wxString *outGroup=NULL); diff --git a/core/changelog.txt b/core/changelog.txt index d01de3a5d..b4931eb23 100644 --- a/core/changelog.txt +++ b/core/changelog.txt @@ -92,6 +92,7 @@ Please visit http://aegisub.net to download latest version - Added recent menu to Video Timecodes. (AMZ) - Playing in video mode will now play the audio as well even if it hasn't been previously loaded into audio mode (experimental). (AMZ) - Added hotkey to Audio's "play to end of file" (defaulting to "T"). (AMZ) +- Fixed the default resolution for video display and resolution resampler when the script's field is blank. (AMZ) = 1.09 beta - 2006.01.16 =========================== diff --git a/core/dialog_resample.cpp b/core/dialog_resample.cpp index cb9683985..82605c439 100644 --- a/core/dialog_resample.cpp +++ b/core/dialog_resample.cpp @@ -60,8 +60,10 @@ DialogResample::DialogResample(wxWindow *parent, SubtitlesGrid *_grid) // Resolution line wxSizer *ResBoxSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Resolution")); wxSizer *ResSizer = new wxBoxSizer(wxHORIZONTAL); - ResXValue = subs->GetScriptInfo(_T("PlayResX")); - ResYValue = subs->GetScriptInfo(_T("PlayResY")); + int sw,sh; + subs->GetResolution(sw,sh); + ResXValue = wxString::Format(_T("%i"),sw); + ResYValue = wxString::Format(_T("%i"),sh); ResX = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(50,20),0,NumValidator(&ResXValue)); ResY = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(50,20),0,NumValidator(&ResYValue)); wxStaticText *ResText = new wxStaticText(this,-1,_("x")); @@ -152,8 +154,8 @@ void DialogResample::ResampleTags (wxString name,int n,AssOverrideParameter *cur void DialogResample::OnResample (wxCommandEvent &event) { // Resolutions AssFile *subs = AssFile::top; - long x1 = subs->GetScriptInfoAsInt(_T("PlayResX")); - long y1 = subs->GetScriptInfoAsInt(_T("PlayResY")); + int x1,y1; + subs->GetResolution(x1,y1); long x2 = 0; long y2 = 0; ResX->GetValue().ToLong(&x2); diff --git a/core/video_display.cpp b/core/video_display.cpp index 23bb3c8b4..7c63c24cf 100644 --- a/core/video_display.cpp +++ b/core/video_display.cpp @@ -793,28 +793,7 @@ wxBitmap VideoDisplay::GetFrame(int n) { //////////////////////////// // Get dimensions of script void VideoDisplay::GetScriptSize(int &sw,int &sh) { - // Height - wxString temp = grid->ass->GetScriptInfo(_T("PlayResY")); - if (temp.IsEmpty() || !temp.IsNumber()) { - //sh = orig_h; - sh = 384; - } - else { - long templ; - temp.ToLong(&templ); - sh = templ; - } - - // Width - temp = grid->ass->GetScriptInfo(_T("PlayResX")); - if (temp.IsEmpty() || !temp.IsNumber()) { - sw = 288; - } - else { - long templ; - temp.ToLong(&templ); - sw = templ; - } + grid->ass->GetResolution(sw,sh); }