added tree control interface to smpackage
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// EnterName.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "smpackage.h"
|
||||
#include "EnterName.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// EnterName dialog
|
||||
|
||||
|
||||
EnterName::EnterName(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(EnterName::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(EnterName)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void EnterName::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(EnterName)
|
||||
DDX_Control(pDX, IDC_EDIT, m_edit);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(EnterName, CDialog)
|
||||
//{{AFX_MSG_MAP(EnterName)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// EnterName message handlers
|
||||
|
||||
void EnterName::OnOK()
|
||||
{
|
||||
// TODO: Add extra validation here
|
||||
|
||||
m_edit.GetWindowText( m_sEnteredName );
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#if !defined(AFX_ENTERNAME_H__0AB99274_EB79_4A25_B95C_627E0A99C6BA__INCLUDED_)
|
||||
#define AFX_ENTERNAME_H__0AB99274_EB79_4A25_B95C_627E0A99C6BA__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// EnterName.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// EnterName dialog
|
||||
|
||||
class EnterName : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
EnterName(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
CString m_sEnteredName;
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(EnterName)
|
||||
enum { IDD = IDD_DIALOG_NAME };
|
||||
CEdit m_edit;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(EnterName)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(EnterName)
|
||||
virtual void OnOK();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_ENTERNAME_H__0AB99274_EB79_4A25_B95C_627E0A99C6BA__INCLUDED_)
|
||||
@@ -500,7 +500,10 @@ bool IsAFile( const CString &sPath )
|
||||
bool IsADirectory( const CString &sPath )
|
||||
{
|
||||
DWORD dwAttr = GetFileAttributes( sPath );
|
||||
return (dwAttr & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
if( dwAttr == 0xFFFFFFFF ) // failed
|
||||
return false;
|
||||
else
|
||||
return (dwAttr & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,447 @@
|
||||
// SmpackageExportDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "smpackage.h"
|
||||
#include "SmpackageExportDlg.h"
|
||||
#include "RageUtil.h"
|
||||
#include "ZipArchive\ZipArchive.h"
|
||||
#include "EnterName.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSmpackageExportDlg dialog
|
||||
|
||||
|
||||
CSmpackageExportDlg::CSmpackageExportDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CSmpackageExportDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CSmpackageExportDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CSmpackageExportDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CSmpackageExportDlg)
|
||||
DDX_Control(pDX, IDC_BUTTON_EXPORT_AS_INDIVIDUAL, m_buttonExportAsIndividual);
|
||||
DDX_Control(pDX, IDC_BUTTON_EXPORT_AS_ONE, m_buttonExportAsOne);
|
||||
DDX_Control(pDX, IDC_TREE, m_tree);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CSmpackageExportDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CSmpackageExportDlg)
|
||||
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()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSmpackageExportDlg message handlers
|
||||
|
||||
BOOL CSmpackageExportDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
//
|
||||
|
||||
// Add announcers
|
||||
{
|
||||
CStringArray as1;
|
||||
HTREEITEM item1 = m_tree.InsertItem( "Announcers" );
|
||||
GetDirListing( "Announcers\\*.*", as1, true, false );
|
||||
for( int i=0; i<as1.GetSize(); i++ )
|
||||
m_tree.InsertItem( as1[i], item1 );
|
||||
}
|
||||
|
||||
// Add themes
|
||||
{
|
||||
CStringArray as1;
|
||||
HTREEITEM item1 = m_tree.InsertItem( "Themes" );
|
||||
GetDirListing( "Themes\\*.*", as1, true, false );
|
||||
for( int i=0; i<as1.GetSize(); i++ )
|
||||
m_tree.InsertItem( as1[i], item1 );
|
||||
}
|
||||
|
||||
// Add BGAnimations
|
||||
{
|
||||
CStringArray as1;
|
||||
HTREEITEM item1 = m_tree.InsertItem( "BGAnimations" );
|
||||
GetDirListing( "BGAnimations\\*.*", as1, true, false );
|
||||
for( int i=0; i<as1.GetSize(); i++ )
|
||||
m_tree.InsertItem( as1[i], item1 );
|
||||
}
|
||||
|
||||
// Add RandomMovies
|
||||
{
|
||||
CStringArray as1;
|
||||
HTREEITEM item1 = m_tree.InsertItem( "RandomMovies" );
|
||||
GetDirListing( "RandomMovies\\*.avi", as1, false, false );
|
||||
GetDirListing( "RandomMovies\\*.mpg", as1, false, false );
|
||||
GetDirListing( "RandomMovies\\*.mpeg", as1, false, false );
|
||||
for( int i=0; i<as1.GetSize(); i++ )
|
||||
m_tree.InsertItem( as1[i], item1 );
|
||||
}
|
||||
|
||||
// Add visualizations
|
||||
{
|
||||
CStringArray as1;
|
||||
HTREEITEM item1 = m_tree.InsertItem( "Visualizations" );
|
||||
GetDirListing( "Visualizations\\*.avi", as1, false, false );
|
||||
GetDirListing( "Visualizations\\*.mpg", as1, false, false );
|
||||
GetDirListing( "Visualizations\\*.mpeg", as1, false, false );
|
||||
for( int i=0; i<as1.GetSize(); i++ )
|
||||
m_tree.InsertItem( as1[i], item1 );
|
||||
}
|
||||
|
||||
// Add courses
|
||||
{
|
||||
CStringArray as1;
|
||||
HTREEITEM item1 = m_tree.InsertItem( "Courses" );
|
||||
GetDirListing( "Courses\\*.crs", as1, false, false );
|
||||
for( int i=0; i<as1.GetSize(); i++ )
|
||||
{
|
||||
as1[i] = as1[i].Left(as1[i].GetLength()-4); // strip off ".crs"
|
||||
m_tree.InsertItem( as1[i], item1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Add NoteSkins
|
||||
//
|
||||
{
|
||||
CStringArray as1;
|
||||
HTREEITEM item1 = m_tree.InsertItem( "NoteSkins" );
|
||||
GetDirListing( "NoteSkins\\*.*", as1, true, false );
|
||||
for( int i=0; i<as1.GetSize(); i++ )
|
||||
{
|
||||
CStringArray as2;
|
||||
HTREEITEM item2 = m_tree.InsertItem( as1[i], item1 );
|
||||
GetDirListing( "NoteSkins\\" + as1[i] + "\\*.*", as2, true, false );
|
||||
for( int j=0; j<as2.GetSize(); j++ )
|
||||
m_tree.InsertItem( as2[j], item2 );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Add Songs
|
||||
//
|
||||
{
|
||||
CStringArray as1;
|
||||
HTREEITEM item1 = m_tree.InsertItem( "Songs" );
|
||||
GetDirListing( "Songs\\*.*", as1, true, false );
|
||||
for( int i=0; i<as1.GetSize(); i++ )
|
||||
{
|
||||
CStringArray as2;
|
||||
HTREEITEM item2 = m_tree.InsertItem( as1[i], item1 );
|
||||
GetDirListing( "Songs\\" + as1[i] + "\\*.*", as2, true, false );
|
||||
for( int j=0; j<as2.GetSize(); j++ )
|
||||
m_tree.InsertItem( as2[j], item2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Strip out any "CVS" items
|
||||
CArray<HTREEITEM,HTREEITEM> aItems;
|
||||
GetTreeItems( aItems );
|
||||
for( int i=0; i<aItems.GetSize(); i++ )
|
||||
if( m_tree.GetItemText(aItems[i]).CompareNoCase("CVS")==0 )
|
||||
m_tree.DeleteItem( aItems[i] );
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
}
|
||||
|
||||
CString ReplaceInvalidFileNameChars( CString sOldFileName )
|
||||
{
|
||||
CString sNewFileName = sOldFileName;
|
||||
const char charsToReplace[] = {
|
||||
' ', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
|
||||
'+', '=', '[', ']', '{', '}', '|', ':', '\"', '\\',
|
||||
'<', '>', ',', '?', '/'
|
||||
};
|
||||
for( int i=0; i<sizeof(charsToReplace); i++ )
|
||||
sNewFileName.Replace( charsToReplace[i], '_' );
|
||||
return sNewFileName;
|
||||
}
|
||||
|
||||
void GetFilePaths( CString sDirOrFile, CStringArray& asPathToFilesOut )
|
||||
{
|
||||
CStringArray asDirectoriesToExplore;
|
||||
|
||||
// HACK:
|
||||
// Must use backslashes in the path, or else WinZip and WinRAR don't see the files.
|
||||
// Not sure if this is ZipArchive's fault.
|
||||
|
||||
if( IsADirectory(sDirOrFile) && sDirOrFile.Right(1) != "\\" )
|
||||
sDirOrFile += "\\";
|
||||
|
||||
sDirOrFile += "*.*";
|
||||
|
||||
GetDirListing( sDirOrFile, asPathToFilesOut, false, true );
|
||||
GetDirListing( sDirOrFile, asDirectoriesToExplore, true, true );
|
||||
while( asDirectoriesToExplore.GetSize() > 0 )
|
||||
{
|
||||
GetDirListing( asDirectoriesToExplore[0] + "\\*.*", asPathToFilesOut, false, true );
|
||||
GetDirListing( asDirectoriesToExplore[0] + "\\*.*", asDirectoriesToExplore, true, true );
|
||||
asDirectoriesToExplore.RemoveAt( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
CString GetDesktopPath()
|
||||
{
|
||||
static TCHAR strNull[2] = _T("");
|
||||
static TCHAR strPath[MAX_PATH];
|
||||
DWORD dwType;
|
||||
DWORD dwSize = MAX_PATH;
|
||||
HKEY hKey;
|
||||
|
||||
// Open the appropriate registry key
|
||||
LONG lResult = RegOpenKeyEx( HKEY_CURRENT_USER,
|
||||
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"),
|
||||
0, KEY_READ, &hKey );
|
||||
if( ERROR_SUCCESS != lResult )
|
||||
return strNull;
|
||||
|
||||
lResult = RegQueryValueEx( hKey, _T("Desktop"), NULL,
|
||||
&dwType, (BYTE*)strPath, &dwSize );
|
||||
RegCloseKey( hKey );
|
||||
|
||||
if( ERROR_SUCCESS != lResult )
|
||||
return strNull;
|
||||
|
||||
return strPath;
|
||||
}
|
||||
|
||||
bool ExportPackage( CString sPackageName, const CStringArray& asDirectoriesToExport )
|
||||
{
|
||||
CZipArchive zip;
|
||||
|
||||
//
|
||||
// Create the package zip file
|
||||
//
|
||||
const CString sPackagePath = GetDesktopPath() + "\\" + sPackageName;
|
||||
try
|
||||
{
|
||||
zip.Open( sPackagePath, CZipArchive::zipCreate );
|
||||
}
|
||||
catch( CException* e )
|
||||
{
|
||||
e->ReportError();
|
||||
zip.Close();
|
||||
e->Delete();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Add files to zip
|
||||
//
|
||||
for( int i=0; i<asDirectoriesToExport.GetSize(); i++ )
|
||||
{
|
||||
CStringArray asFilePaths;
|
||||
asFilePaths.Add( asDirectoriesToExport[i] );
|
||||
GetFilePaths( asDirectoriesToExport[i], asFilePaths );
|
||||
|
||||
for( int j=0; j<asFilePaths.GetSize(); j++ )
|
||||
{
|
||||
CString sFilePath = asFilePaths[j];
|
||||
|
||||
// don't export "thumbs.db" files or "CVS" folders
|
||||
CString sDir, sFName, sExt;
|
||||
splitrelpath( sFilePath, sDir, sFName, sExt );
|
||||
if( sFName.CompareNoCase("CVS")==0 )
|
||||
continue; // skip
|
||||
if( sFName.CompareNoCase("thumbs")==0 )
|
||||
continue; // skip
|
||||
|
||||
try
|
||||
{
|
||||
zip.AddNewFile( sFilePath, Z_BEST_COMPRESSION, true );
|
||||
}
|
||||
catch (CException* e)
|
||||
{
|
||||
AfxMessageBox( ssprintf("Error adding file '%s'.", sFilePath) );
|
||||
zip.Close();
|
||||
e->Delete();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zip.Close();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CSmpackageExportDlg::OnButtonExportAsOne()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
|
||||
CStringArray asPaths;
|
||||
GetCheckedPaths( asPaths );
|
||||
|
||||
if( asPaths.GetSize() == 0 )
|
||||
{
|
||||
AfxMessageBox( "No items are checked" );
|
||||
return;
|
||||
}
|
||||
else if( asPaths.GetSize() == 1 )
|
||||
{
|
||||
OnButtonExportAsIndividual();
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate a package name
|
||||
CString sPackageName;
|
||||
EnterName nameDlg;
|
||||
int nResponse = nameDlg.DoModal();
|
||||
if( nResponse != IDOK )
|
||||
return; // cancelled
|
||||
sPackageName = nameDlg.m_sEnteredName;
|
||||
sPackageName = ReplaceInvalidFileNameChars( sPackageName+".smzip" );
|
||||
|
||||
if( ExportPackage( sPackageName, asPaths ) )
|
||||
AfxMessageBox( ssprintf("Successfully exported package '%s' to your Desktop.",sPackageName) );
|
||||
}
|
||||
|
||||
void CSmpackageExportDlg::OnButtonExportAsIndividual()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
|
||||
CStringArray asPaths;
|
||||
GetCheckedPaths( asPaths );
|
||||
|
||||
if( asPaths.GetSize() == 0 )
|
||||
{
|
||||
AfxMessageBox( "No items are checked" );
|
||||
return;
|
||||
}
|
||||
|
||||
bool bAllSucceeded = true;
|
||||
CStringArray asExportedPackages;
|
||||
CStringArray asFailedPackages;
|
||||
for( int i=0; i<asPaths.GetSize(); i++ )
|
||||
{
|
||||
// Generate a package name for every path
|
||||
CString sPath = asPaths[i];
|
||||
|
||||
CString sPackageName;
|
||||
CStringArray asPathBits;
|
||||
split( sPath, "\\", asPathBits, true );
|
||||
sPackageName = asPathBits[ asPathBits.GetSize()-1 ] + ".smzip";
|
||||
sPackageName = ReplaceInvalidFileNameChars( sPackageName );
|
||||
|
||||
CStringArray asPathsToExport;
|
||||
asPathsToExport.Add( sPath );
|
||||
|
||||
if( ExportPackage( sPackageName, asPathsToExport ) )
|
||||
asExportedPackages.Add( sPackageName );
|
||||
else
|
||||
asFailedPackages.Add( sPackageName );
|
||||
}
|
||||
|
||||
CString sMessage;
|
||||
if( asFailedPackages.GetSize() == 0 )
|
||||
sMessage = ssprintf("Successfully exported the package%s '%s' to your Desktop.", asFailedPackages.GetSize()>1?"s":"", join("', '",asExportedPackages) );
|
||||
else
|
||||
sMessage = ssprintf(" The packages %s failed to export.", join(", ",asFailedPackages) );
|
||||
AfxMessageBox( sMessage );
|
||||
}
|
||||
|
||||
void CSmpackageExportDlg::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
|
||||
);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void CSmpackageExportDlg::GetTreeItems( CArray<HTREEITEM,HTREEITEM>& aItemsOut )
|
||||
{
|
||||
CArray<HTREEITEM,HTREEITEM> aRootsToExplore;
|
||||
|
||||
// add all top-level roots
|
||||
HTREEITEM item = m_tree.GetRootItem();
|
||||
while( item != NULL )
|
||||
{
|
||||
aRootsToExplore.Add( item );
|
||||
item = m_tree.GetNextSiblingItem( item );
|
||||
}
|
||||
|
||||
while( aRootsToExplore.GetSize() > 0 )
|
||||
{
|
||||
HTREEITEM item = aRootsToExplore[0];
|
||||
aRootsToExplore.RemoveAt( 0 );
|
||||
aItemsOut.Add( item );
|
||||
|
||||
HTREEITEM child = m_tree.GetChildItem( item );
|
||||
while( child != NULL )
|
||||
{
|
||||
aRootsToExplore.Add( child );
|
||||
child = m_tree.GetNextSiblingItem( child );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSmpackageExportDlg::GetCheckedTreeItems( CArray<HTREEITEM,HTREEITEM>& aCheckedItemsOut )
|
||||
{
|
||||
CArray<HTREEITEM,HTREEITEM> aItems;
|
||||
|
||||
GetTreeItems( aItems );
|
||||
for( int i=0; i<aItems.GetSize(); i++ )
|
||||
if( m_tree.GetCheck(aItems[i]) )
|
||||
aCheckedItemsOut.Add( aItems[i] );
|
||||
}
|
||||
|
||||
void CSmpackageExportDlg::GetCheckedPaths( CStringArray& aPathsOut )
|
||||
{
|
||||
CArray<HTREEITEM,HTREEITEM> aItems;
|
||||
|
||||
GetCheckedTreeItems( aItems );
|
||||
for( int i=0; i<aItems.GetSize(); i++ )
|
||||
{
|
||||
HTREEITEM item = aItems[i];
|
||||
|
||||
CString sPath;
|
||||
|
||||
while( item )
|
||||
{
|
||||
sPath = m_tree.GetItemText(item) + '\\' + sPath;
|
||||
item = m_tree.GetParentItem(item);
|
||||
}
|
||||
|
||||
sPath.TrimRight('\\'); // strip off last slash
|
||||
|
||||
aPathsOut.Add( sPath );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#if !defined(AFX_SMPACKAGEEXPORTDLG_H__3E19CBFB_E8F6_4C18_B0A4_636979B80A4D__INCLUDED_)
|
||||
#define AFX_SMPACKAGEEXPORTDLG_H__3E19CBFB_E8F6_4C18_B0A4_636979B80A4D__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "afxtempl.h"
|
||||
|
||||
// SmpackageExportDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSmpackageExportDlg dialog
|
||||
|
||||
class CSmpackageExportDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CSmpackageExportDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CSmpackageExportDlg)
|
||||
enum { IDD = IDD_EXPORTER };
|
||||
CButton m_buttonExportAsIndividual;
|
||||
CButton m_buttonExportAsOne;
|
||||
CTreeCtrl m_tree;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CSmpackageExportDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
void GetTreeItems( CArray<HTREEITEM,HTREEITEM>& aItemsOut );
|
||||
void GetCheckedTreeItems( CArray<HTREEITEM,HTREEITEM>& aCheckedItemsOut );
|
||||
void GetCheckedPaths( CStringArray& aCheckedItemsOut );
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CSmpackageExportDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnButtonExportAsOne();
|
||||
afx_msg void OnButtonExportAsIndividual();
|
||||
afx_msg void OnButtonPlay();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_SMPACKAGEEXPORTDLG_H__3E19CBFB_E8F6_4C18_B0A4_636979B80A4D__INCLUDED_)
|
||||
@@ -6,8 +6,10 @@
|
||||
#define IDD_MANAGER 102
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDD_INSTALL 129
|
||||
#define IDD_EXPORTER 130
|
||||
#define INSTALL 133
|
||||
#define MANAGE 135
|
||||
#define IDD_DIALOG_NAME 137
|
||||
#define IDC_LIST_SONGS 1000
|
||||
#define IDC_LIST 1000
|
||||
#define IDC_BUTTON_PLAY 1001
|
||||
@@ -18,14 +20,16 @@
|
||||
#define IDC_EDIT_MESSAGE1 1005
|
||||
#define IDC_EDIT_MESSAGE3 1006
|
||||
#define IDC_EDIT_MESSAGE2 1007
|
||||
#define IDC_TREE 1011
|
||||
#define IDC_EDIT 1012
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 137
|
||||
#define _APS_NEXT_RESOURCE_VALUE 138
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#define _APS_NEXT_CONTROL_VALUE 1009
|
||||
#define _APS_NEXT_CONTROL_VALUE 1013
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -2,20 +2,23 @@
|
||||
|
||||
[General Info]
|
||||
Version=1
|
||||
LastClass=CSmpackageDlg
|
||||
LastClass=EnterName
|
||||
LastTemplate=CDialog
|
||||
NewFileInclude1=#include "stdafx.h"
|
||||
NewFileInclude2=#include "smpackage.h"
|
||||
|
||||
ClassCount=3
|
||||
ClassCount=5
|
||||
Class1=CSmpackageApp
|
||||
Class2=CSmpackageDlg
|
||||
|
||||
ResourceCount=3
|
||||
ResourceCount=4
|
||||
Resource1=IDR_MAINFRAME
|
||||
Resource2=IDD_INSTALL
|
||||
Class3=CSMPackageInstallDlg
|
||||
Resource3=IDD_MANAGER
|
||||
Class4=CSmpackageExportDlg
|
||||
Resource3=IDD_EXPORTER
|
||||
Class5=EnterName
|
||||
Resource4=IDD_DIALOG_NAME
|
||||
|
||||
[CLS:CSmpackageApp]
|
||||
Type=0
|
||||
@@ -37,17 +40,6 @@ VirtualFilter=dWC
|
||||
|
||||
|
||||
|
||||
[DLG:IDD_MANAGER]
|
||||
Type=1
|
||||
Class=CSmpackageDlg
|
||||
ControlCount=6
|
||||
Control1=IDOK,button,1342242817
|
||||
Control2=IDC_LIST,listbox,1352728843
|
||||
Control3=IDC_BUTTON_PLAY,button,1342242816
|
||||
Control4=IDC_BUTTON_EXPORT_AS_ONE,button,1476460544
|
||||
Control5=IDC_STATIC,static,1342177294
|
||||
Control6=IDC_BUTTON_EXPORT_AS_INDIVIDUAL,button,1476460544
|
||||
|
||||
[DLG:IDD_INSTALL]
|
||||
Type=1
|
||||
Class=CSMPackageInstallDlg
|
||||
@@ -69,3 +61,42 @@ Filter=D
|
||||
LastObject=CSMPackageInstallDlg
|
||||
VirtualFilter=dWC
|
||||
|
||||
[DLG:IDD_EXPORTER]
|
||||
Type=1
|
||||
Class=CSmpackageExportDlg
|
||||
ControlCount=6
|
||||
Control1=IDOK,button,1342242817
|
||||
Control2=IDC_BUTTON_PLAY,button,1342242816
|
||||
Control3=IDC_BUTTON_EXPORT_AS_ONE,button,1342242816
|
||||
Control4=IDC_STATIC,static,1342177294
|
||||
Control5=IDC_BUTTON_EXPORT_AS_INDIVIDUAL,button,1342242816
|
||||
Control6=IDC_TREE,SysTreeView32,1350631687
|
||||
|
||||
[CLS:CSmpackageExportDlg]
|
||||
Type=0
|
||||
HeaderFile=SmpackageExportDlg.h
|
||||
ImplementationFile=SmpackageExportDlg.cpp
|
||||
BaseClass=CDialog
|
||||
Filter=D
|
||||
LastObject=CSmpackageExportDlg
|
||||
VirtualFilter=dWC
|
||||
|
||||
[DLG:IDD_DIALOG_NAME]
|
||||
Type=1
|
||||
Class=EnterName
|
||||
ControlCount=5
|
||||
Control1=IDC_STATIC,static,1342308352
|
||||
Control2=IDC_EDIT,edit,1350631552
|
||||
Control3=IDOK,button,1342242817
|
||||
Control4=IDCANCEL,button,1342242816
|
||||
Control5=IDC_STATIC,static,1342308352
|
||||
|
||||
[CLS:EnterName]
|
||||
Type=0
|
||||
HeaderFile=EnterName.h
|
||||
ImplementationFile=EnterName.cpp
|
||||
BaseClass=CDialog
|
||||
Filter=D
|
||||
VirtualFilter=dWC
|
||||
LastObject=IDC_EDIT
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "smpackage.h"
|
||||
#include "smpackageDlg.h"
|
||||
#include "smpackageExportDlg.h"
|
||||
#include "smpackageInstallDlg.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
@@ -111,7 +111,7 @@ BOOL CSmpackageApp::InitInstance()
|
||||
|
||||
|
||||
// Show the Manager Dialog
|
||||
CSmpackageDlg dlg;
|
||||
CSmpackageExportDlg dlg;
|
||||
int nResponse = dlg.DoModal();
|
||||
// if (nResponse == IDOK)
|
||||
|
||||
|
||||
@@ -88,6 +88,14 @@ LINK32=link.exe
|
||||
# Name "smpackage - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\EnterName.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\EnterName.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\install.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -136,11 +144,11 @@ SOURCE=.\res\smpackage.rc2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\smpackageDlg.cpp
|
||||
SOURCE=.\SmpackageExportDlg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\smpackageDlg.h
|
||||
SOURCE=.\SmpackageExportDlg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
||||
@@ -73,24 +73,6 @@ IDR_MAINFRAME ICON DISCARDABLE "smpackage.ICO"
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_MANAGER DIALOGEX 0, 0, 332, 234
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE |
|
||||
WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_APPWINDOW
|
||||
CAPTION "Stepmania Package Manager"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Close",IDOK,255,215,69,14
|
||||
LISTBOX IDC_LIST,5,45,244,160,LBS_SORT | LBS_MULTIPLESEL |
|
||||
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Play Stepmania",IDC_BUTTON_PLAY,5,215,70,15
|
||||
PUSHBUTTON "Export As One",IDC_BUTTON_EXPORT_AS_ONE,255,75,69,15,
|
||||
WS_DISABLED
|
||||
CONTROL 135,IDC_STATIC,"Static",SS_BITMAP,0,0,332,38
|
||||
PUSHBUTTON "Export As Individual",IDC_BUTTON_EXPORT_AS_INDIVIDUAL,
|
||||
255,108,69,15,WS_DISABLED
|
||||
END
|
||||
|
||||
IDD_INSTALL DIALOG DISCARDABLE 0, 0, 332, 234
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION
|
||||
CAPTION "Stepmania Package Manager"
|
||||
@@ -111,6 +93,38 @@ BEGIN
|
||||
WS_TABSTOP
|
||||
END
|
||||
|
||||
IDD_EXPORTER DIALOGEX 0, 0, 332, 234
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE |
|
||||
WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_APPWINDOW
|
||||
CAPTION "Stepmania Package Manager"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Close",IDOK,255,215,69,14
|
||||
PUSHBUTTON "Play Stepmania",IDC_BUTTON_PLAY,5,215,70,15
|
||||
PUSHBUTTON "Export As One",IDC_BUTTON_EXPORT_AS_ONE,255,75,69,15
|
||||
CONTROL 135,IDC_STATIC,"Static",SS_BITMAP,0,0,332,38
|
||||
PUSHBUTTON "Export As Individual",IDC_BUTTON_EXPORT_AS_INDIVIDUAL,
|
||||
255,108,69,15
|
||||
CONTROL "Tree2",IDC_TREE,"SysTreeView32",TVS_HASBUTTONS |
|
||||
TVS_HASLINES | TVS_LINESATROOT | TVS_CHECKBOXES |
|
||||
WS_BORDER | WS_TABSTOP,7,41,239,167
|
||||
END
|
||||
|
||||
IDD_DIALOG_NAME DIALOG DISCARDABLE 0, 0, 261, 58
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Name Your Package"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "Please enter a name for your new package:",IDC_STATIC,7,
|
||||
7,179,12
|
||||
EDITTEXT IDC_EDIT,17,20,178,13,ES_AUTOHSCROLL
|
||||
DEFPUSHBUTTON "OK",IDOK,204,7,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,204,24,50,14
|
||||
LTEXT "NOTE: (leave off the "".smzip"" extension)",IDC_STATIC,
|
||||
18,38,179,12
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -163,7 +177,15 @@ END
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_MANAGER, DIALOG
|
||||
IDD_INSTALL, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 325
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 227
|
||||
END
|
||||
|
||||
IDD_EXPORTER, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 324
|
||||
@@ -171,12 +193,12 @@ BEGIN
|
||||
BOTTOMMARGIN, 227
|
||||
END
|
||||
|
||||
IDD_INSTALL, DIALOG
|
||||
IDD_DIALOG_NAME, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 325
|
||||
RIGHTMARGIN, 254
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 227
|
||||
BOTTOMMARGIN, 51
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
@@ -1,438 +0,0 @@
|
||||
// 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<as1.GetSize(); i++ )
|
||||
m_listBox.AddString( as1[i] );
|
||||
}
|
||||
|
||||
m_listBox.AddString( "Courses\\" );
|
||||
|
||||
//
|
||||
// Add NoteSkins
|
||||
//
|
||||
{
|
||||
CStringArray as1;
|
||||
GetDirListing( "NoteSkins\\*.*", as1, true, true );
|
||||
for( int i=0; i<as1.GetSize(); i++ )
|
||||
{
|
||||
CStringArray as2;
|
||||
GetDirListing( as1[i] + "\\*.*", as2, true, true );
|
||||
for( int j=0; j<as2.GetSize(); j++ )
|
||||
m_listBox.AddString( as2[j] );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Add Songs
|
||||
//
|
||||
{
|
||||
CStringArray as1;
|
||||
GetDirListing( "Songs\\*.*", as1, true, true );
|
||||
for( int i=0; i<as1.GetSize(); i++ )
|
||||
{
|
||||
CStringArray as2;
|
||||
GetDirListing( as1[i] + "\\*.*", as2, true, true );
|
||||
for( int j=0; j<as2.GetSize(); j++ )
|
||||
m_listBox.AddString( as2[j] );
|
||||
}
|
||||
}
|
||||
|
||||
// Strip out "CVS"
|
||||
for( int i=m_listBox.GetCount()-1; i>=0; i-- )
|
||||
{
|
||||
CString sItemName;
|
||||
m_listBox.GetText( i, sItemName );
|
||||
if( -1!=sItemName.Find("CVS") )
|
||||
m_listBox.DeleteString( i );
|
||||
}
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
}
|
||||
|
||||
// If you add a minimize button to your dialog, you will need the code below
|
||||
// to draw the icon. For MFC applications using the document/view model,
|
||||
// this is automatically done for you by the framework.
|
||||
|
||||
void CSmpackageDlg::OnPaint()
|
||||
{
|
||||
if (IsIconic())
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
|
||||
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
|
||||
|
||||
// Center icon in client rectangle
|
||||
int cxIcon = GetSystemMetrics(SM_CXICON);
|
||||
int cyIcon = GetSystemMetrics(SM_CYICON);
|
||||
CRect rect;
|
||||
GetClientRect(&rect);
|
||||
int x = (rect.Width() - cxIcon + 1) / 2;
|
||||
int y = (rect.Height() - cyIcon + 1) / 2;
|
||||
|
||||
// Draw the icon
|
||||
dc.DrawIcon(x, y, m_hIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
CDialog::OnPaint();
|
||||
}
|
||||
}
|
||||
|
||||
// The system calls this to obtain the cursor to display while the user drags
|
||||
// the minimized window.
|
||||
HCURSOR CSmpackageDlg::OnQueryDragIcon()
|
||||
{
|
||||
return (HCURSOR) m_hIcon;
|
||||
}
|
||||
|
||||
void CSmpackageDlg::OnSelchangeList()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
|
||||
if( m_listBox.GetSelCount() == LB_ERR ) // no song is selected
|
||||
{
|
||||
m_buttonExportAsOne.EnableWindow( false );
|
||||
m_buttonExportAsIndividual.EnableWindow( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonExportAsOne.EnableWindow( true );
|
||||
m_buttonExportAsIndividual.EnableWindow( true );
|
||||
}
|
||||
}
|
||||
|
||||
CString ReplaceInvalidFileNameChars( CString sOldFileName )
|
||||
{
|
||||
CString sNewFileName = sOldFileName;
|
||||
const char charsToReplace[] = {
|
||||
' ', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
|
||||
'+', '=', '[', ']', '{', '}', '|', ':', '\"', '\\',
|
||||
'<', '>', ',', '?', '/'
|
||||
};
|
||||
for( int i=0; i<sizeof(charsToReplace); i++ )
|
||||
sNewFileName.Replace( charsToReplace[i], '_' );
|
||||
return sNewFileName;
|
||||
}
|
||||
|
||||
void GetFilePathsInDirectory( CString sDir, CStringArray& asPathToFilesOut )
|
||||
{
|
||||
CStringArray asDirectoriesToExplore;
|
||||
|
||||
// HACK:
|
||||
// Must use backslashes in the path, or else WinZip and WinRAR don't see the files.
|
||||
// Not sure if this is ZipArchive's fault.
|
||||
|
||||
GetDirListing( sDir + "\\*.*", asPathToFilesOut, false, true );
|
||||
GetDirListing( sDir + "\\*.*", asDirectoriesToExplore, true, true );
|
||||
while( asDirectoriesToExplore.GetSize() > 0 )
|
||||
{
|
||||
GetDirListing( asDirectoriesToExplore[0] + "\\*.*", asPathToFilesOut, false, true );
|
||||
GetDirListing( asDirectoriesToExplore[0] + "\\*.*", asDirectoriesToExplore, true, true );
|
||||
asDirectoriesToExplore.RemoveAt( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
CString GetDesktopPath()
|
||||
{
|
||||
static TCHAR strNull[2] = _T("");
|
||||
static TCHAR strPath[MAX_PATH];
|
||||
DWORD dwType;
|
||||
DWORD dwSize = MAX_PATH;
|
||||
HKEY hKey;
|
||||
|
||||
// Open the appropriate registry key
|
||||
LONG lResult = RegOpenKeyEx( HKEY_CURRENT_USER,
|
||||
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"),
|
||||
0, KEY_READ, &hKey );
|
||||
if( ERROR_SUCCESS != lResult )
|
||||
return strNull;
|
||||
|
||||
lResult = RegQueryValueEx( hKey, _T("Desktop"), NULL,
|
||||
&dwType, (BYTE*)strPath, &dwSize );
|
||||
RegCloseKey( hKey );
|
||||
|
||||
if( ERROR_SUCCESS != lResult )
|
||||
return strNull;
|
||||
|
||||
return strPath;
|
||||
}
|
||||
|
||||
bool ExportPackage( CString sPackageName, const CStringArray& asDirectoriesToExport )
|
||||
{
|
||||
CZipArchive zip;
|
||||
|
||||
// const CString sDesktopPath = CString(getenv("USERPROFILE")) + "/Desktop/";
|
||||
|
||||
//
|
||||
// Create the package zip file
|
||||
//
|
||||
const CString sPackagePath = GetDesktopPath() + "\\" + 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; i<asDirectoriesToExport.GetSize(); i++ )
|
||||
{
|
||||
CStringArray asFilePaths;
|
||||
asFilePaths.Add( asDirectoriesToExport[i] );
|
||||
GetFilePathsInDirectory( asDirectoriesToExport[i], asFilePaths );
|
||||
|
||||
for( int j=0; j<asFilePaths.GetSize(); j++ )
|
||||
{
|
||||
CString sFilePath = asFilePaths[j];
|
||||
|
||||
// don't export "thumbs.db" files or "CVS" folders
|
||||
CString sDir, sFName, sExt;
|
||||
splitrelpath( sFilePath, sDir, sFName, sExt );
|
||||
if( sFName.CompareNoCase("thumbs.db")==0 )
|
||||
continue; // skip
|
||||
if( sFName.CompareNoCase("thumbs.db")==0 )
|
||||
continue; // skip
|
||||
|
||||
try
|
||||
{
|
||||
zip.AddNewFile( sFilePath, Z_BEST_COMPRESSION, true );
|
||||
}
|
||||
catch (CException* e)
|
||||
{
|
||||
AfxMessageBox( ssprintf("Error adding file '%s'.", sFilePath) );
|
||||
zip.Close();
|
||||
e->Delete();
|
||||
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; i<arrayFiles.GetSize(); i++ )
|
||||
{
|
||||
CString sFileName = arrayFiles[i];
|
||||
CString sFilePath = sSongDir + "/" + sFileName;
|
||||
try
|
||||
{
|
||||
m_zip.AddNewFile( sFilePath, 9, true );
|
||||
}
|
||||
catch (CException* e)
|
||||
{
|
||||
MessageBox( ssprintf("Error adding file '%s'.", sFilePath), "", MB_OK );
|
||||
m_zip.Close();
|
||||
e->Delete();
|
||||
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<asFilesOnDesktop.GetSize(); i++ )
|
||||
if( stricmp(asFilesOnDesktop[i],sPackageName) == 0 )
|
||||
goto try_another_name;
|
||||
|
||||
|
||||
CStringArray asPathsToExport;
|
||||
int iSelectedItems[200];
|
||||
int iNumSelectedItems = m_listBox.GetSelItems( 200, iSelectedItems );
|
||||
for( i=0; i<iNumSelectedItems; i++ )
|
||||
{
|
||||
CString sPath;
|
||||
m_listBox.GetText( iSelectedItems[i], sPath );
|
||||
asPathsToExport.Add( sPath );
|
||||
}
|
||||
|
||||
if( ExportPackage( sPackageName, asPathsToExport ) )
|
||||
AfxMessageBox( ssprintf("Successfully exported package '%s' to your Desktop.",sPackageName) );
|
||||
|
||||
m_listBox.SetSel( -1, FALSE );
|
||||
}
|
||||
|
||||
void CSmpackageDlg::OnButtonExportAsIndividual()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
|
||||
ASSERT( m_listBox.GetSelCount() != LB_ERR );
|
||||
|
||||
|
||||
int iSelectedItems[200];
|
||||
int iNumSelectedItems = m_listBox.GetSelItems( 200, iSelectedItems );
|
||||
bool bAllSucceeded = true;
|
||||
CStringArray asExportedPackages;
|
||||
CStringArray asFailedPackages;
|
||||
for( int i=0; i<iNumSelectedItems; i++ )
|
||||
{
|
||||
// Generate a package name for every path
|
||||
CString sPath;
|
||||
m_listBox.GetText( iSelectedItems[i], sPath );
|
||||
|
||||
CString sPackageName;
|
||||
CStringArray asPathBits;
|
||||
split( sPath, "/", asPathBits, true );
|
||||
sPackageName = asPathBits[ asPathBits.GetSize()-1 ] + ".smzip";
|
||||
sPackageName = ReplaceInvalidFileNameChars( sPackageName );
|
||||
|
||||
CStringArray asPathsToExport;
|
||||
asPathsToExport.Add( sPath );
|
||||
|
||||
if( ExportPackage( sPackageName, asPathsToExport ) )
|
||||
asExportedPackages.Add( sPackageName );
|
||||
else
|
||||
asFailedPackages.Add( sPackageName );
|
||||
}
|
||||
|
||||
CString sMessage;
|
||||
if( asFailedPackages.GetSize() == 0 )
|
||||
sMessage = ssprintf("Successfully exported the packages %s to your Desktop.", join(", ",asExportedPackages) );
|
||||
else
|
||||
sMessage = ssprintf(" The packages %s failed to export.", join(", ",asFailedPackages) );
|
||||
AfxMessageBox( sMessage );
|
||||
|
||||
m_listBox.SetSel( -1, FALSE );
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
// smpackageDlg.h : header file
|
||||
//
|
||||
|
||||
#if !defined(AFX_SMPACKAGEDLG_H__E60DA2DD_D8D6_42BC_9049_631EAFBAA1F6__INCLUDED_)
|
||||
#define AFX_SMPACKAGEDLG_H__E60DA2DD_D8D6_42BC_9049_631EAFBAA1F6__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSmpackageDlg dialog
|
||||
|
||||
|
||||
class CSmpackageDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CSmpackageDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CSmpackageDlg)
|
||||
enum { IDD = IDD_SMPACKAGE_DIALOG };
|
||||
CButton m_buttonExportAsOne;
|
||||
CButton m_buttonExportAsIndividual;
|
||||
CListBox m_listBox;
|
||||
//}}AFX_DATA
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CSmpackageDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
HICON m_hIcon;
|
||||
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CSmpackageDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnPaint();
|
||||
afx_msg HCURSOR OnQueryDragIcon();
|
||||
afx_msg void OnSelchangeList();
|
||||
afx_msg void OnButtonExportAsOne();
|
||||
afx_msg void OnButtonExportAsIndividual();
|
||||
afx_msg void OnButtonPlay();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_SMPACKAGEDLG_H__E60DA2DD_D8D6_42BC_9049_631EAFBAA1F6__INCLUDED_)
|
||||
Reference in New Issue
Block a user