Files
itgmania212121/stepmania/src/smpackage/smpackage.cpp
T

144 lines
4.1 KiB
C++
Raw Normal View History

2005-12-10 08:23:10 +00:00
#define CO_EXIST_WITH_MFC
#include "global.h"
2002-01-28 21:24:17 +00:00
#include "stdafx.h"
#include "smpackage.h"
2003-02-06 23:15:21 +00:00
#include "smpackageExportDlg.h"
2002-01-28 21:24:17 +00:00
#include "smpackageInstallDlg.h"
#include "RageUtil.h"
#include "smpackageUtil.h"
#include "MainMenuDlg.h"
2005-12-10 08:23:10 +00:00
#include "RageFileManager.h"
2005-12-18 01:27:54 +00:00
#include "arch/arch.h"
2002-01-28 21:24:17 +00:00
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BEGIN_MESSAGE_MAP(CSmpackageApp, CWinApp)
//{{AFX_MSG_MAP(CSmpackageApp)
//}}AFX_MSG_MAP
2002-01-28 21:24:17 +00:00
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
CSmpackageApp::CSmpackageApp()
{
// Place all significant initialization in InitInstance
}
CSmpackageApp theApp;
2005-12-18 01:27:54 +00:00
#include "RageLog.h"
#include "RageFileManager.h"
2002-01-28 21:24:17 +00:00
BOOL CSmpackageApp::InitInstance()
{
2005-12-18 01:27:54 +00:00
/* Almost everything uses this to read and write files. Load this early. */
FILEMAN = new RageFileManager( "" );
FILEMAN->MountInitialFilesystems();
2002-02-12 06:55:04 +00:00
2005-12-18 01:27:54 +00:00
/* Set this up next. Do this early, since it's needed for RageException::Throw. */
LOG = new RageLog();
2002-02-12 06:55:04 +00:00
2004-02-27 22:48:17 +00:00
2005-12-18 01:27:54 +00:00
if( DoesFileExist("Songs") ) // this is a SM program directory
2002-01-28 21:24:17 +00:00
{
// make sure it's in the list of install directories
TCHAR szCurrentDirectory[MAX_PATH];
GetCurrentDirectory( MAX_PATH, szCurrentDirectory );
2005-12-10 08:23:10 +00:00
SMPackageUtil::AddStepManiaInstallDir( szCurrentDirectory );
2002-01-28 21:24:17 +00:00
}
2002-02-12 06:55:04 +00:00
2002-01-28 21:24:17 +00:00
// check if there's a .smzip command line argument
2005-12-10 08:23:10 +00:00
vector<RString> arrayCommandLineBits;
2002-01-28 21:24:17 +00:00
split( ::GetCommandLine(), "\"", arrayCommandLineBits );
for( unsigned i=0; i<arrayCommandLineBits.size(); i++ )
2002-01-28 21:24:17 +00:00
{
2005-12-10 08:23:10 +00:00
RString sPath = arrayCommandLineBits[i];
TrimLeft( sPath );
TrimRight( sPath );
RString sPathLower = sPath;
2002-01-28 21:24:17 +00:00
sPathLower.MakeLower();
// test to see if this is a smzip file
if( sPathLower.Right(3) == "zip" )
{
2005-12-10 08:23:10 +00:00
if( !FILEMAN->DoesFileExist(sPath) )
{
AfxMessageBox( ssprintf("The file '%s' does not exist. Aborting installation.",sPath), MB_ICONERROR );
exit(0);
}
2002-01-28 21:24:17 +00:00
// We found a zip package. Prompt the user to install it!
2005-12-10 08:23:10 +00:00
CSMPackageInstallDlg dlg( CString(sPath.c_str()) );
2002-01-28 21:24:17 +00:00
int nResponse = dlg.DoModal();
if( nResponse == IDOK )
{
CSmpackageExportDlg dlg;
int nResponse = dlg.DoModal();
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
2002-01-28 21:24:17 +00:00
}
else if (nResponse == IDCANCEL)
{
// the user cancelled. Don't fall through to the Manager.
2002-01-28 21:24:17 +00:00
exit(0);
}
}
}
2005-12-10 08:23:10 +00:00
FILEMAN = new RageFileManager( "" );
2002-01-28 21:24:17 +00:00
// Show the Manager Dialog
MainMenuDlg dlg;
2002-01-28 21:24:17 +00:00
int nResponse = dlg.DoModal();
// if (nResponse == IDOK)
2005-12-10 08:23:10 +00:00
SAFE_DELETE( FILEMAN );
2002-01-28 21:24:17 +00:00
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
namespace StepMania
{
void NORETURN HandleException( RString sErr )
{
MessageBox( NULL, "exception", sErr, MB_ICONERROR );
}
}
2005-12-23 00:59:00 +00:00
/*
* (c) 2002-2005 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/