Welcome to mirror list, hosted at ThFree Co, Russian Federation.

vsconv.cpp « vsconv « apps « src - github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 27152b2f432b14806b601b3df2092be690beec72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
 * $Id$
 *
 * (C) 2003-2005 Gabest
 *
 * This file is part of vsconv.
 *
 * Vsconv is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Vsconv is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "stdafx.h"
#include "vsconv.h"
#include "vsconvDlg.h"
#include "..\..\subtitles\VobSubFile.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CvsconvApp

BEGIN_MESSAGE_MAP(CvsconvApp, CWinApp)
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()


// CvsconvApp construction

CvsconvApp::CvsconvApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}


// The one and only CvsconvApp object

CvsconvApp theApp;


// CvsconvApp initialization

BOOL CvsconvApp::InitInstance()
{
	// InitCommonControls() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	InitCommonControls();

	CWinApp::InitInstance();

	AfxEnableControlContainer();

	// TODO
//	if(__argc > 1)
	{
		CString in, out;
		CVobSubFile::SubFormat sf = CVobSubFile::None;
		int iLang = -1;
		bool fIgnoreForcedOnly = false;
		bool fForcedOnly = false;

		try
		{
			for(int i = 1; i < __argc; i++)
			{
				if(__targv[i][0] == '-' || __targv[i][0] == '/')
				{
					CString sw(&__targv[i][1]);

					if(sw == _T("f"))
					{
						if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/')
						{
							CString fmt = CString(__targv[i]).MakeLower();

							if(fmt == _T("winsubmux"))
								sf = CVobSubFile::WinSubMux;
							else if(fmt == _T("scenarist"))
								sf = CVobSubFile::Scenarist;
							else if(fmt == _T("maestro"))
								sf = CVobSubFile::Maestro;
							else
								throw _T("Unrecognized conversion format");
						}
						else
							throw _T("No conversion format given");
					}
					else if(sw == _T("i"))
					{
						if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/')
							in = __targv[i];
						else
							throw _T("Missing input file");
					}
					else if(sw == _T("o"))
					{
						if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/')
							out = __targv[i];
						else
							throw _T("Missing output file");
					}
					else if(sw == _T("id"))
					{
						if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/')
							iLang = _tcstol(__targv[i], NULL, 10);
						else
							throw _T("Missing stream id");
					}
					else if(sw == _T("ignoreforcedonly"))
					{
						fIgnoreForcedOnly = true;
					}
					else if(sw == _T("forcedonly"))
					{
						fForcedOnly = true;
					}
				}
			}

			if(!in.IsEmpty() && !out.IsEmpty() && sf != CVobSubFile::None)
			{
				CVobSubFile vsf(NULL);

				if(!vsf.Open(in))
					throw _T("Can't open input");

				if(iLang >= 0 && iLang < 32)
					vsf.m_iLang = iLang;

				if(fForcedOnly)
					vsf.m_fOnlyShowForcedSubs = true;

				if(fIgnoreForcedOnly)
					vsf.m_fOnlyShowForcedSubs = false;

				if(!vsf.Save(out, sf))
					throw _T("Can't save output");

				return FALSE;
			}
		}
		catch(LPCTSTR msg)
		{
			AfxMessageBox(CString(_T("Error: ")) + msg);
		}

		AfxMessageBox(
			_T("Usage: vsconv.exe <switches>\n\n")
			_T("-f \"format\" (winsubmux, scenarist, maestro)\n")
			_T("-i \"input\"\n")
			_T("-o \"output\"\n")
			_T("-id 0-31 (optional)\n")
			_T("-ignoreforcedonly (optional)\n")
			_T("-forcedonly (optional)\n")
			);

		return FALSE;
	}

	// TODO
	return FALSE;


	CvsconvDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}