VSRipPGCDlg.cpp

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 
00022 // VSRipPGCDlg.cpp : implementation file
00023 //
00024 
00025 #include "stdafx.h"
00026 #include <atlcoll.h>
00027 #include "VSRip.h"
00028 #include "VSRipPGCDlg.h"
00029 #include "..\..\subtitles\VobSubFile.h"
00030 
00031 
00032 // CVSRipPGCDlg dialog
00033 
00034 IMPLEMENT_DYNAMIC(CVSRipPGCDlg, CVSRipPage)
00035 CVSRipPGCDlg::CVSRipPGCDlg(IVSFRipper* pVSFRipper, CWnd* pParent /*=NULL*/)
00036         : CVSRipPage(pVSFRipper, CVSRipPGCDlg::IDD, pParent)
00037         , m_bResetTime(TRUE)
00038         , m_bClosedCaption(FALSE)
00039         , m_bForcedOnly(FALSE)
00040 {
00041         m_rd.Reset();
00042 }
00043 
00044 CVSRipPGCDlg::~CVSRipPGCDlg()
00045 {
00046 }
00047 
00048 void CVSRipPGCDlg::DoDataExchange(CDataExchange* pDX)
00049 {
00050         CVSRipPage::DoDataExchange(pDX);
00051         DDX_Control(pDX, IDC_LIST1, m_pgclist);
00052         DDX_Control(pDX, IDC_LIST2, m_anglelist);
00053         DDX_Control(pDX, IDC_LIST3, m_vclist);
00054         DDX_Control(pDX, IDC_LIST4, m_langlist);
00055         DDX_Check(pDX, IDC_CHECK1, m_bResetTime);
00056         DDX_Check(pDX, IDC_CHECK2, m_bClosedCaption);
00057         DDX_Check(pDX, IDC_CHECK3, m_bForcedOnly);
00058 }
00059 
00060 void CVSRipPGCDlg::OnPrev()
00061 {
00062         OnNext();
00063 }
00064 
00065 void CVSRipPGCDlg::OnNext()
00066 {
00067         CAutoVectorPtr<int> items;
00068 
00069         m_rd.iSelPGC = m_pgclist.GetCurSel();
00070 
00071         m_rd.selids.RemoveAll();
00072         if(items.Allocate(m_langlist.GetSelCount()))
00073         {
00074                 int j = m_langlist.GetSelItems(m_langlist.GetSelCount(), items);
00075                 for(int i = 0; i < j; i++)
00076                         m_rd.selids[(BYTE)m_langlist.GetItemData(items[i])] = true;
00077                 items.Free();
00078         }
00079 
00080         m_rd.pgcs[m_rd.iSelPGC].iSelAngle = m_anglelist.GetCurSel();
00081 
00082         m_rd.selvcs.RemoveAll();
00083         if(items.Allocate(m_vclist.GetSelCount()))
00084         {
00085                 int j = m_vclist.GetSelItems(m_vclist.GetSelCount(), items);
00086                 for(int i = 0; i < j; i++)
00087                         m_rd.selvcs.Add((DWORD)m_vclist.GetItemData(items[i]));
00088                 items.Free();
00089         }
00090 
00091         m_rd.fClosedCaption = !!m_bClosedCaption;
00092         m_rd.fResetTime = !!m_bResetTime;
00093         m_rd.fForcedOnly = !!m_bForcedOnly;
00094 
00095         m_pVSFRipper->UpdateRipperData(m_rd);
00096 }
00097 
00098 bool CVSRipPGCDlg::CanGoNext()
00099 {
00100         UpdateData();
00101 
00102         return(m_pgclist.GetCurSel() >= 0
00103         && m_anglelist.GetCurSel() >= 0 
00104                 && m_vclist.GetSelCount() > 0 
00105                 && (m_langlist.GetSelCount() > 0 || m_bClosedCaption));
00106 }
00107 
00108 void CVSRipPGCDlg::SetupPGCList()
00109 {
00110         ASSERT(m_rd.iSelPGC >= 0);
00111 
00112         m_pgclist.ResetContent();
00113 
00114         for(int i = 0; i < m_rd.pgcs.GetCount(); i++)
00115         {
00116                 CString str;
00117                 str.Format(_T("PGC %d"), i+1);
00118                 m_pgclist.AddString(str);
00119         }
00120 
00121         m_pgclist.SetCurSel(m_rd.iSelPGC);
00122 
00123         SetupLangList();
00124         SetupAngleList();
00125 }
00126 
00127 void CVSRipPGCDlg::SetupLangList()
00128 {
00129         m_langlist.ResetContent();
00130 
00131         for(BYTE i = 0; i < 32; i++)
00132         {
00133                 WORD id = m_rd.pgcs[m_rd.iSelPGC].ids[i];
00134 
00135                 CString str;
00136 
00137                 if(id == 0)
00138                 {
00139                         str.Format(_T("%02d (empty)"), (int)i);
00140                 }
00141                 else if(!isalpha(id>>8) || !isalpha(id&0xff))
00142                 {
00143                         str.Format(_T("%02d (unknown)"), (int)i);
00144                 }
00145                 else
00146                 {
00147                         str.Format(_T("%02d %s (%c%c)"), (int)i, FindLangFromId(id), TCHAR(id>>8), TCHAR(id&0xff));
00148                 }
00149 
00150                 int j = m_langlist.AddString(str);
00151                 m_langlist.SetSel(j, !!id);
00152                 m_langlist.SetItemData(j, (DWORD_PTR)i);
00153         }
00154 
00155         m_langlist.SetTopIndex(0);
00156 }
00157 
00158 void CVSRipPGCDlg::SetupAngleList()
00159 {
00160         m_anglelist.ResetContent();
00161 
00162         m_rd.pgcs[m_rd.iSelPGC].iSelAngle = m_rd.pgcs[m_rd.iSelPGC].nAngles > 0 ? 1 : 0;
00163 
00164         for(int i = 0; i < 10; i++)
00165         {
00166                 CString str;
00167 
00168                 if(i == 0)
00169                 {
00170                         str = _T("Everything");
00171                 }
00172                 else
00173                 {
00174                         str.Format(_T("Angle %d"), i);
00175                         if(i > m_rd.pgcs[m_rd.iSelPGC].nAngles)
00176                                 str += _T(" (empty)");
00177                 }
00178 
00179                 m_anglelist.AddString(str);
00180         }
00181 
00182         m_anglelist.SetCurSel(m_rd.pgcs[m_rd.iSelPGC].iSelAngle);
00183 
00184         SetupVCList();
00185 }
00186 
00187 void CVSRipPGCDlg::SetupVCList()
00188 {
00189         m_vclist.ResetContent();
00190 
00191         CArray<vc_t>& vca = m_rd.pgcs[m_rd.iSelPGC].angles[m_rd.pgcs[m_rd.iSelPGC].iSelAngle];
00192 
00193         for(int i = 0; i < vca.GetCount(); i++)
00194         {
00195                 CString str;
00196                 str.Format(_T("V%02d C%02d"), vca[i].vob, vca[i].cell);
00197 
00198                 DWORD vc = (vca[i].vob<<16)|vca[i].cell;
00199 
00200                 int j = m_vclist.AddString(str);
00201                 m_vclist.SetSel(j, TRUE);
00202                 m_vclist.SetItemData(j, (DWORD_PTR)vc);
00203         }
00204 
00205         m_vclist.SetTopIndex(0);
00206 }
00207 
00208 BEGIN_MESSAGE_MAP(CVSRipPGCDlg, CVSRipPage)
00209         ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
00210         ON_LBN_SELCHANGE(IDC_LIST2, OnLbnSelchangeList2)
00211         ON_WM_SHOWWINDOW()
00212 END_MESSAGE_MAP()
00213 
00214 
00215 // CVSRipPGCDlg message handlers
00216 
00217 void CVSRipPGCDlg::OnLbnSelchangeList1()
00218 {
00219         if(m_rd.iSelPGC == m_pgclist.GetCurSel()) return;
00220         m_rd.iSelPGC = m_pgclist.GetCurSel();
00221         SetupAngleList();
00222 }
00223 
00224 void CVSRipPGCDlg::OnLbnSelchangeList2()
00225 {
00226         if(m_rd.pgcs[m_rd.iSelPGC].iSelAngle == m_anglelist.GetCurSel()) return;
00227         m_rd.pgcs[m_rd.iSelPGC].iSelAngle = m_anglelist.GetCurSel();
00228         SetupVCList();
00229 }
00230 
00231 void CVSRipPGCDlg::OnShowWindow(BOOL bShow, UINT nStatus)
00232 {
00233         CVSRipPage::OnShowWindow(bShow, nStatus);
00234 
00235         if(!bShow) return;
00236 
00237         m_pVSFRipper->GetRipperData(m_rd);
00238         
00239         if(m_rd.iSelPGC == -1)
00240         {
00241                 m_rd.iSelPGC = 0;
00242                 SetupPGCList();
00243 
00244                 m_bClosedCaption = m_rd.vidinfo.line21_1 || m_rd.vidinfo.line21_2;
00245                 UpdateData(FALSE);
00246         }
00247 }

Generated on Tue Dec 13 14:47:06 2005 for guliverkli by  doxygen 1.4.5