// smpackageDlg.cpp : implementation file // #include "stdafx.h" #include "smpackage.h" #include "smpackageDlg.h" #include "../RageUtil.h" #include "ZipArchive\ZipArchive.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSmpackageDlg dialog CSmpackageDlg::CSmpackageDlg(CWnd* pParent /*=NULL*/) : CDialog(CSmpackageDlg::IDD, pParent) { //{{AFX_DATA_INIT(CSmpackageDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CSmpackageDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSmpackageDlg) DDX_Control(pDX, IDC_BUTTON_EXPORT_AS_ONE, m_buttonExportAsOne); DDX_Control(pDX, IDC_BUTTON_EXPORT_AS_INDIVIDUAL, m_buttonExportAsIndividual); DDX_Control(pDX, IDC_LIST, m_listBox); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSmpackageDlg, CDialog) //{{AFX_MSG_MAP(CSmpackageDlg) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_LBN_SELCHANGE(IDC_LIST, OnSelchangeList) ON_BN_CLICKED(IDC_BUTTON_EXPORT_AS_ONE, OnButtonExportAsOne) ON_BN_CLICKED(IDC_BUTTON_EXPORT_AS_INDIVIDUAL, OnButtonExportAsIndividual) ON_BN_CLICKED(IDC_BUTTON_PLAY, OnButtonPlay) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSmpackageDlg message handlers BOOL CSmpackageDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // // TODO: Add extra initialization here // // // Add announcers, themes, BGAnimations, random movies, and visualizations // { CStringArray as1; GetDirListing( "Announcers\\*.*", as1, true, true ); GetDirListing( "Themes\\*.*", as1, true, true ); GetDirListing( "BGAnimations\\*.*", as1, true, true ); GetDirListing( "RandomMovies\\*.avi", as1, false, true ); GetDirListing( "RandomMovies\\*.mpg", as1, false, true ); GetDirListing( "RandomMovies\\*.mpeg", as1, false, true ); GetDirListing( "Visualizations\\*.avi", as1, false, true ); GetDirListing( "Visualizations\\*.mpg", as1, false, true ); GetDirListing( "Visualizations\\*.mpeg", as1, false, true ); for( int i=0; i', ',', '?', '/' }; for( int i=0; i 0 ) { GetDirListing( asDirectoriesToExplore[0] + "\\*.*", asPathToFilesOut, false, true ); GetDirListing( asDirectoriesToExplore[0] + "\\*.*", asDirectoriesToExplore, true, true ); asDirectoriesToExplore.RemoveAt( 0 ); } } bool ExportPackage( CString sPackageName, const CStringArray& asDirectoriesToExport ) { CZipArchive zip; const CString sDesktopPath = CString(getenv("USERPROFILE")) + "/Desktop/"; // // Create the package zip file // const CString sPackagePath = sDesktopPath + sPackageName; try { zip.Open( sPackagePath, CZipArchive::zipCreate ); } catch( CException* e ) { AfxMessageBox( ssprintf("Error creating zip file '%s'", sPackagePath) ); zip.Close(); e->Delete(); return false; } // // Add files to zip // for( int i=0; iDelete(); return false; } } } /* CStringArray arrayFiles; GetDirListing( sSongDir + "\\*.*", arrayFiles ); //m_zip.AddNewFile( sRelPathToSelectedSong, 0, true ); // add the directory m_zip.AddNewFile( "Songs", 0, true ); m_zip.AddNewFile( sGroupDir, 0, true ); m_zip.AddNewFile( sSongDir, 0, true ); for( i=0; iDelete(); return; } } */ zip.Close(); return true; } void CSmpackageDlg::OnButtonExportAsOne() { // TODO: Add your control notification handler code here ASSERT( m_listBox.GetSelCount() != LB_ERR ); if( m_listBox.GetSelCount() == 1 ) { OnButtonExportAsIndividual(); return; } int i; // Generate a package name CString sPackageName; int iNumNameTries = 0; try_another_name: iNumNameTries++; sPackageName = ReplaceInvalidFileNameChars( ssprintf("New Package %d.smzip",iNumNameTries) ); CStringArray asFilesOnDesktop; const CString sDesktopPath = CString(getenv("USERPROFILE")) + "\\Desktop"; GetDirListing( sDesktopPath + "\\*.*", asFilesOnDesktop ); for( i=0; i 0 ) sMessage += ssprintf(" The packages %s failed to export.", join(", ",asFailedPackages) ); AfxMessageBox( sMessage ); } void CSmpackageDlg::OnButtonPlay() { // TODO: Add your control notification handler code here PROCESS_INFORMATION pi; STARTUPINFO si; ZeroMemory( &si, sizeof(si) ); CreateProcess( NULL, // pointer to name of executable module "stepmania.exe", // pointer to command line string NULL, // process security attributes NULL, // thread security attributes false, // handle inheritance flag 0, // creation flags NULL, // pointer to new environment block NULL, // pointer to current directory name &si, // pointer to STARTUPINFO &pi // pointer to PROCESS_INFORMATION ); }