Added theme element analysis feature to smpackage

This commit is contained in:
Chris Danford
2003-03-28 17:46:32 +00:00
parent 415f2b30da
commit 541b5fe9c2
11 changed files with 194 additions and 49 deletions
+6
View File
@@ -31,6 +31,12 @@ CHANGE: HoldNote life snaps to full when button is pressed (instead of
refilling slowly) ala DDR
NEW FEATURE: Toggle for Autogen of missing steps
NEW FEATURE: Toggle for Autogen of group Nonstop and Endless Courses
OPTIMIZATION: Turned off compression when exporting package, which makes
exporting significantly faster.
NEW FEATURE: Convert a theme from the 3.0 naming convention to the 4.0
naming convention using "Analyze Theme" in smpackage.exe.
NEW FEATURE: Check for redundant and possibly mis-named theme elements using
"Analyze Theme" in smpackage.exe.
----------------------- Version 3.01 ---------------------------
CHANGE: Simplified NoteSkin tap graphic format. Old NoteSkins will need to
+8 -8
View File
@@ -38,22 +38,15 @@ void MainMenuDlg::DoDataExchange(CDataExchange* pDX)
BEGIN_MESSAGE_MAP(MainMenuDlg, CDialog)
//{{AFX_MSG_MAP(MainMenuDlg)
ON_BN_CLICKED(IDC_CONVERT_THEME, OnConvertTheme)
ON_BN_CLICKED(IDC_EXPORT_PACKAGES, OnExportPackages)
ON_BN_CLICKED(IDC_EDIT_INSTALLATIONS, OnEditInstallations)
ON_BN_CLICKED(IDC_ANALYZE_ELEMENTS, OnAnalyzeElements)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// MainMenuDlg message handlers
void MainMenuDlg::OnConvertTheme()
{
// TODO: Add your control notification handler code here
ConvertThemeDlg dlg;
int nResponse = dlg.DoModal();
}
void MainMenuDlg::OnExportPackages()
{
// TODO: Add your control notification handler code here
@@ -68,3 +61,10 @@ void MainMenuDlg::OnEditInstallations()
EditInsallations dlg;
int nResponse = dlg.DoModal();
}
void MainMenuDlg::OnAnalyzeElements()
{
// TODO: Add your control notification handler code here
ConvertThemeDlg dlg;
int nResponse = dlg.DoModal();
}
+1
View File
@@ -38,6 +38,7 @@ protected:
afx_msg void OnConvertTheme();
afx_msg void OnExportPackages();
afx_msg void OnEditInstallations();
afx_msg void OnAnalyzeElements();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

+126 -2
View File
@@ -29,6 +29,7 @@ void ConvertThemeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(ConvertThemeDlg)
DDX_Control(pDX, IDC_BUTTON_ANALYZE, m_buttonAnalyze);
DDX_Control(pDX, IDC_BUTTON_CONVERT, m_buttonConvert);
DDX_Control(pDX, IDC_LIST_THEMES, m_listThemes);
//}}AFX_DATA_MAP
@@ -39,6 +40,7 @@ BEGIN_MESSAGE_MAP(ConvertThemeDlg, CDialog)
//{{AFX_MSG_MAP(ConvertThemeDlg)
ON_BN_CLICKED(IDC_BUTTON_CONVERT, OnButtonConvert)
ON_LBN_SELCHANGE(IDC_LIST_THEMES, OnSelchangeListThemes)
ON_BN_CLICKED(IDC_BUTTON_ANALYZE, OnButtonAnalyze)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -54,7 +56,8 @@ BOOL ConvertThemeDlg::OnInitDialog()
CStringArray asThemes;
GetDirListing( "Themes\\*.*", asThemes, true, false );
for( int i=0; i<asThemes.GetSize(); i++ )
m_listThemes.AddString( asThemes[i] );
if( asThemes[i] != "default" )
m_listThemes.AddString( asThemes[i] );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
@@ -89,7 +92,6 @@ void ConvertThemeDlg::OnButtonConvert()
{
// TODO: Add your control notification handler code here
int iSel = m_listThemes.GetCurSel();
CString sThemeDir;
m_listThemes.GetText( iSel, sThemeDir );
sThemeDir = "Themes\\" + sThemeDir;
@@ -189,4 +191,126 @@ void ConvertThemeDlg::OnSelchangeListThemes()
// TODO: Add your control notification handler code here
BOOL bSomethingSelected = m_listThemes.GetCurSel() != LB_ERR;
m_buttonConvert.EnableWindow( bSomethingSelected );
m_buttonAnalyze.EnableWindow( bSomethingSelected );
}
bool FilesAreIdentical( CString sPath1, CString sPath2 )
{
if( IsADirectory(sPath1) || IsADirectory(sPath2) )
return false;
FILE* fp1 = fopen( sPath1, "r" );
FILE* fp2 = fopen( sPath2, "r" );
if( GetFileSizeInBytes(sPath1) != GetFileSizeInBytes(sPath2) )
return false;
char buffer1[1024], buffer2[1024];
ZERO( buffer1 );
ZERO( buffer2 );
while( !feof(fp1) )
{
fread( buffer1, 1, sizeof(buffer1), fp1 );
fread( buffer2, 1, sizeof(buffer2), fp2 );
if( memcmp( buffer1, buffer2, sizeof(buffer1) ) != 0 )
return false;
}
return true;
}
CString StripExtension( CString sPath )
{
CString sDir, sFName, sExt;
splitrelpath( sPath, sDir, sFName, sExt );
return sDir + sFName;
}
void ConvertThemeDlg::OnButtonAnalyze()
{
// TODO: Add your control notification handler code here
int i;
CString sBaseDir = "Themes\\default\\";
int iSel = m_listThemes.GetCurSel();
CString sThemeDir;
m_listThemes.GetText( iSel, sThemeDir );
sThemeDir = "Themes\\"+sThemeDir+"\\";
CStringArray asBaseFilePaths;
GetDirListing( sBaseDir+"BGAnimations\\*.*", asBaseFilePaths, false, true );
GetDirListing( sBaseDir+"Fonts\\*.*", asBaseFilePaths, false, true );
GetDirListing( sBaseDir+"Graphics\\*.*", asBaseFilePaths, false, true );
GetDirListing( sBaseDir+"Numbers\\*.*", asBaseFilePaths, false, true );
GetDirListing( sBaseDir+"Sounds\\*.*", asBaseFilePaths, false, true );
CStringArray asThemeFilePaths;
GetDirListing( sThemeDir+"BGAnimations\\*.*", asThemeFilePaths, false, true );
GetDirListing( sThemeDir+"Fonts\\*.*", asThemeFilePaths, false, true );
GetDirListing( sThemeDir+"Graphics\\*.*", asThemeFilePaths, false, true );
GetDirListing( sThemeDir+"Numbers\\*.*", asThemeFilePaths, false, true );
GetDirListing( sThemeDir+"Sounds\\*.*", asThemeFilePaths, false, true );
FILE* fp = fopen( "theme_report.txt", "w" );
ASSERT( fp );
CStringArray asRedundantPaths;
CStringArray asWarningPaths;
for( i=0; i<asThemeFilePaths.GetSize(); i++ )
{
CString sThemeElement = asThemeFilePaths[i];
sThemeElement.Replace( sThemeDir, "" );
sThemeElement = StripExtension( sThemeElement );
for( int j=0; j<asBaseFilePaths.GetSize(); j++ )
{
CString sBaseElement = asBaseFilePaths[j];
sBaseElement.Replace( sBaseDir, "" );
sBaseElement = StripExtension( sBaseElement );
if( sThemeElement.CompareNoCase(sBaseElement)==0 ) // file names match
{
if( FilesAreIdentical( asThemeFilePaths[i], asBaseFilePaths[j] ) )
{
asRedundantPaths.Add( asThemeFilePaths[i] );
break;
}
else // files are not identical
{
break; // skip to next file in asThemeFilePaths
}
}
}
if( j == asBaseFilePaths.GetSize() )
asWarningPaths.Add( asThemeFilePaths[i] );
}
fprintf( fp, "The following elements are REDUNDANT.\n"
" (These elements are identical to the elements in the base theme.\n"
" They are unnecessary and should be deleted.)\n" );
for( i=0; i<asRedundantPaths.GetSize(); i++ )
fprintf( fp, asRedundantPaths[i] + "\n" );
fprintf( fp, "\n" );
fprintf( fp, "The following elements are possibly MISNAMED.\n"
" (These files do not have a corresponding element in\n"
" the base theme. This likely means that there is an error in the file name.)\n" );
for( i=0; i<asWarningPaths.GetSize(); i++ )
fprintf( fp, asWarningPaths[i] + "\n" );
fclose( fp );
// launch notepad
PROCESS_INFORMATION pi;
STARTUPINFO si;
ZeroMemory( &si, sizeof(si) );
CreateProcess(
NULL, // pointer to name of executable module
"notepad.exe theme_report.txt", // 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
);
}
+2
View File
@@ -19,6 +19,7 @@ public:
// Dialog Data
//{{AFX_DATA(ConvertThemeDlg)
enum { IDD = IDD_CONVERT_THEME };
CButton m_buttonAnalyze;
CButton m_buttonConvert;
CListBox m_listThemes;
//}}AFX_DATA
@@ -39,6 +40,7 @@ protected:
virtual BOOL OnInitDialog();
afx_msg void OnButtonConvert();
afx_msg void OnSelchangeListThemes();
afx_msg void OnButtonAnalyze();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
+6 -4
View File
@@ -14,7 +14,7 @@
#define IDD_MENU 139
#define MENU 140
#define IDD_CONVERT_THEME 142
#define CONVERTTHEME 143
#define CONVERTTHEME 144
#define IDC_LIST_SONGS 1000
#define IDC_LIST 1000
#define IDC_BUTTON_PLAY 1001
@@ -34,18 +34,20 @@
#define IDC_BUTTON_REMOVE 1019
#define IDC_BUTTON_MAKE_DEFAULT 1020
#define IDC_EXPORT_PACKAGES 1022
#define IDC_CONVERT_THEME 1023
#define IDC_LIST_THEMES 1023
#define IDC_ANALYZE_ELEMENTS 1023
#define IDC_EDIT_INSTALLATIONS 1024
#define IDC_BUTTON_CONVERT 1024
#define IDC_EDIT_METRICS 1025
#define IDC_BUTTON_ANALYZE 1025
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 144
#define _APS_NEXT_RESOURCE_VALUE 145
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1025
#define _APS_NEXT_CONTROL_VALUE 1026
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
+20 -15
View File
@@ -13,16 +13,16 @@ Class2=CSmpackageDlg
ResourceCount=7
Resource1=IDR_MAINFRAME
Resource2=IDD_DIALOG_NAME
Resource2=IDD_MENU
Class3=CSMPackageInstallDlg
Class4=CSmpackageExportDlg
Resource3=IDD_INSTALL
Resource3=IDD_EDIT_INSTALLATIONS
Class5=EnterName
Resource4=IDD_EXPORTER
Resource4=IDD_DIALOG_NAME
Class6=EditInsallations
Resource5=IDD_MENU
Resource5=IDD_EXPORTER
Class7=MainMenuDlg
Resource6=IDD_EDIT_INSTALLATIONS
Resource6=IDD_INSTALL
Class8=ConvertThemeDlg
Resource7=IDD_CONVERT_THEME
@@ -139,18 +139,20 @@ LastObject=EditInsallations
[DLG:IDD_MENU]
Type=1
Class=MainMenuDlg
ControlCount=11
ControlCount=13
Control1=IDOK,button,1342242817
Control2=IDC_STATIC,static,1342177294
Control3=IDC_EXPORT_PACKAGES,button,1342242816
Control4=IDC_STATIC,static,1342308352
Control5=IDC_STATIC,button,1342177287
Control6=IDC_STATIC,button,1342177287
Control7=IDC_CONVERT_THEME,button,1342242816
Control8=IDC_STATIC,static,1342308352
Control9=IDC_EDIT_INSTALLATIONS,button,1342242816
Control10=IDC_STATIC,static,1342308352
Control11=IDC_STATIC,button,1342177287
Control7=IDC_ANALYZE_ELEMENTS,button,1342242816
Control8=IDC_EDIT_INSTALLATIONS,button,1342242816
Control9=IDC_STATIC,static,1342308352
Control10=IDC_STATIC,button,1342177287
Control11=IDC_EDIT_METRICS,button,1342242816
Control12=IDC_STATIC,static,1342308352
Control13=IDC_STATIC,static,1342308352
[CLS:MainMenuDlg]
Type=0
@@ -164,14 +166,17 @@ LastObject=IDC_CONVERT_THEME
[DLG:IDD_CONVERT_THEME]
Type=1
Class=ConvertThemeDlg
ControlCount=7
ControlCount=10
Control1=IDOK,button,1342242817
Control2=IDC_STATIC,static,1342177294
Control3=IDC_LIST_THEMES,listbox,1352728835
Control4=IDC_BUTTON_CONVERT,button,1476460544
Control5=IDC_STATIC,button,1342177287
Control5=IDC_STATIC,static,1342308352
Control6=IDC_STATIC,static,1342308352
Control7=IDC_STATIC,static,1342308352
Control7=IDC_STATIC,button,1342177287
Control8=IDC_STATIC,button,1342177287
Control9=IDC_STATIC,static,1342308352
Control10=IDC_BUTTON_ANALYZE,button,1476460544
[CLS:ConvertThemeDlg]
Type=0
@@ -179,6 +184,6 @@ HeaderFile=onvertThemeDlg.h
ImplementationFile=onvertThemeDlg.cpp
BaseClass=CDialog
Filter=D
LastObject=IDC_LIST_THEMES
LastObject=ConvertThemeDlg
VirtualFilter=dWC
+1 -5
View File
@@ -1,5 +1,5 @@
# Microsoft Developer Studio Project File - Name="smpackage" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# Microsoft Developer Studio Generated Build File, Format Version 60000
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
@@ -88,10 +88,6 @@ LINK32=link.exe
# Name "smpackage - Win32 Debug"
# Begin Source File
SOURCE=.\converttheme.bmp
# End Source File
# Begin Source File
SOURCE=.\EditInsallations.cpp
# End Source File
# Begin Source File
+24 -15
View File
@@ -153,42 +153,51 @@ BEGIN
IDC_STATIC,18,144,196,17
END
IDD_MENU DIALOG DISCARDABLE 0, 0, 332, 234
IDD_MENU DIALOG DISCARDABLE 0, 0, 332, 263
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "StepMania Tools Main Menu"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "Close",IDOK,275,215,50,14
DEFPUSHBUTTON "Close",IDOK,275,242,50,14
CONTROL 140,IDC_STATIC,"Static",SS_BITMAP,0,0,332,38
PUSHBUTTON "Export Packages",IDC_EXPORT_PACKAGES,20,121,70,15
PUSHBUTTON "Export Packages",IDC_EXPORT_PACKAGES,20,120,70,15
LTEXT "Choose this option to create .smzip files that you can share with other StepMania and DWI users. A .smzip package can contain songs, courses, themes, background animations, and more.",
IDC_STATIC,105,115,215,25
GROUPBOX ".smzip Packages",IDC_STATIC,5,100,320,50
GROUPBOX "Themes",IDC_STATIC,5,155,320,50
PUSHBUTTON "Convert Theme",IDC_CONVERT_THEME,20,175,70,15
LTEXT "Choose this option to convert a StepMania 3.0 theme to the StepMania 4.0 theme format. This tool will not convert any theme metrics. You'll need to convert these by hand.",
IDC_STATIC,105,170,215,25
GROUPBOX "Themes",IDC_STATIC,5,155,320,82
PUSHBUTTON "Analyze Elements",IDC_ANALYZE_ELEMENTS,20,174,70,15
PUSHBUTTON "Edit Installations",IDC_EDIT_INSTALLATIONS,20,65,70,15
LTEXT "Choose this option to edit the list of locations where you have StepMania or DWI installed. When you double-click on a .smzip file, you can choose to install the package to any of these locations.",
IDC_STATIC,105,60,215,25
GROUPBOX "Installations",IDC_STATIC,5,45,320,50
PUSHBUTTON "Edit Metrics",IDC_EDIT_METRICS,19,208,70,15
LTEXT "This is a user-friendly interface for editing the metrics of a theme. It will warn you of misnamed and redundant metrics.",
IDC_STATIC,102,206,215,25
LTEXT "This function will catch mistakes in theme element naming. Also, it gives you the option to convert a StepMania 3.0 theme to the StepMania 4.0 naming scheme.",
IDC_STATIC,103,168,215,25
END
IDD_CONVERT_THEME DIALOG DISCARDABLE 0, 0, 332, 234
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Convert Theme"
CAPTION "Theme Elements"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "Close",IDOK,275,213,50,14
CONTROL 143,IDC_STATIC,"Static",SS_BITMAP,0,0,332,38
LISTBOX IDC_LIST_THEMES,16,58,110,137,LBS_SORT |
CONTROL 144,IDC_STATIC,"Static",SS_BITMAP,0,0,332,38
LISTBOX IDC_LIST_THEMES,7,46,110,181,LBS_SORT |
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Convert",IDC_BUTTON_CONVERT,135,70,50,15,WS_DISABLED
GROUPBOX "Themes",IDC_STATIC,7,44,318,161
PUSHBUTTON "Convert from 3.0 to 4.0",IDC_BUTTON_CONVERT,174,59,95,
15,WS_DISABLED
LTEXT "This will convert a StepMania 3.0 theme to the StepMania 4.0 theme format. After converting a theme, it will no longer be compatible with StepMania 3.0. Be sure to make a backup if this is important to you.",
IDC_STATIC,144,115,170,43
IDC_STATIC,129,82,189,34
LTEXT "This tool will not convert any theme metrics. You'll need to convert these by hand.",
IDC_STATIC,143,165,174,20
IDC_STATIC,129,123,189,19
GROUPBOX "Convert",IDC_STATIC,123,46,202,102
GROUPBOX "Analyze",IDC_STATIC,123,153,202,54
LTEXT "Check for redundant or possibly midnamed theme elements.",
IDC_STATIC,130,185,186,18
PUSHBUTTON "Analyze Elements",IDC_BUTTON_ANALYZE,173,164,95,15,
WS_DISABLED
END
@@ -280,7 +289,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 325
TOPMARGIN, 7
BOTTOMMARGIN, 227
BOTTOMMARGIN, 256
END
IDD_CONVERT_THEME, DIALOG