diff --git a/stepmania/src/smpackage/ColorListBox.cpp b/stepmania/src/smpackage/ColorListBox.cpp new file mode 100644 index 0000000000..67291689c2 --- /dev/null +++ b/stepmania/src/smpackage/ColorListBox.cpp @@ -0,0 +1,275 @@ +// ColorListBox.cpp : implementation file + +//------------------------------------------------------------------- +// +// CColorListBox class - +// A CListBox-derived class with optional colored items. +// +// Version: 1.0 01/10/1998 Copyright © Patrice Godard +// +// Version: 2.0 09/17/1999 Copyright © Paul M. Meidinger +// +//------------------------------------------------------------------- + +#include "stdafx.h" +#include "ColorListBox.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CColorListBox + +//------------------------------------------------------------------- +// +CColorListBox::CColorListBox() +// +// Return Value: None. +// +// Parameters : None. +// +// Remarks : Standard constructor. +// +{ +} // CColorListBox + +//------------------------------------------------------------------- +// +CColorListBox::~CColorListBox() +// +// Return Value: None. +// +// Parameters : None. +// +// Remarks : Destructor. +// +{ +} // ~CColorListBox() + + +BEGIN_MESSAGE_MAP(CColorListBox, CListBox) + //{{AFX_MSG_MAP(CColorListBox) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CColorListBox message handlers + +//------------------------------------------------------------------- +// +void CColorListBox::DrawItem(LPDRAWITEMSTRUCT lpDIS) +// +// Return Value: None. +// +// Parameters : lpDIS - A long pointer to a DRAWITEMSTRUCT structure +// that contains information about the type of drawing required. +// +// Remarks : Called by the framework when a visual aspect of +// an owner-draw list box changes. +// +{ + if ((int)lpDIS->itemID < 0) + return; + + CDC* pDC = CDC::FromHandle(lpDIS->hDC); + + COLORREF crText; + CString sText; + COLORREF crNorm = (COLORREF)lpDIS->itemData; // Color information is in item data. + COLORREF crHilite = RGB(255-GetRValue(crNorm), 255-GetGValue(crNorm), 255-GetBValue(crNorm)); + + // If item has been selected, draw the highlight rectangle using the item's color. + if ((lpDIS->itemState & ODS_SELECTED) && + (lpDIS->itemAction & (ODA_SELECT | ODA_DRAWENTIRE))) + { + CBrush brush(crNorm); + pDC->FillRect(&lpDIS->rcItem, &brush); + } + + // If item has been deselected, draw the rectangle using the window color. + if (!(lpDIS->itemState & ODS_SELECTED) && (lpDIS->itemAction & ODA_SELECT)) + { + CBrush brush(::GetSysColor(COLOR_WINDOW)); + pDC->FillRect(&lpDIS->rcItem, &brush); + } + + // If item has focus, draw the focus rect. + if ((lpDIS->itemAction & ODA_FOCUS) && (lpDIS->itemState & ODS_FOCUS)) + pDC->DrawFocusRect(&lpDIS->rcItem); + + // If item does not have focus, redraw (erase) the focus rect. + if ((lpDIS->itemAction & ODA_FOCUS) && !(lpDIS->itemState & ODS_FOCUS)) + pDC->DrawFocusRect(&lpDIS->rcItem); + + + // Set the background mode to TRANSPARENT to draw the text. + int nBkMode = pDC->SetBkMode(TRANSPARENT); + + // If the item's color information is set, use the highlight color + // gray text color, or normal color for the text. + if (lpDIS->itemData) + { + if (lpDIS->itemState & ODS_SELECTED) + crText = pDC->SetTextColor(crHilite); + else if (lpDIS->itemState & ODS_DISABLED) + crText = pDC->SetTextColor(::GetSysColor(COLOR_GRAYTEXT)); + else + crText = pDC->SetTextColor(crNorm); + } + // Else the item's color information is not set, so use the + // system colors for the text. + else + { + if (lpDIS->itemState & ODS_SELECTED) + crText = pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT)); + else if (lpDIS->itemState & ODS_DISABLED) + crText = pDC->SetTextColor(::GetSysColor(COLOR_GRAYTEXT)); + else + crText = pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT)); + } + + + // Get and display item text. + GetText(lpDIS->itemID, sText); + CRect rect = lpDIS->rcItem; + + // Setup the text format. + UINT nFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER; + if (GetStyle() & LBS_USETABSTOPS) + nFormat |= DT_EXPANDTABS; + + // Calculate the rectangle size before drawing the text. + pDC->DrawText(sText, -1, &rect, nFormat | DT_CALCRECT); + pDC->DrawText(sText, -1, &rect, nFormat); + + pDC->SetTextColor(crText); + pDC->SetBkMode(nBkMode); +} // DrawItem + +//------------------------------------------------------------------- +// +void CColorListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMIS) +// +// Return Value: None. +// +// Parameters : lpMIS - A long pointer to a +// MEASUREITEMSTRUCT structure. +// +// Remarks : Called by the framework when a list box with +// an owner-draw style is created. +// +{ + // ### Is the default list box item height the same as + // the menu check height??? + lpMIS->itemHeight = ::GetSystemMetrics(SM_CYMENUCHECK); +} // MeasureItem + +//------------------------------------------------------------------- +// +int CColorListBox::AddString(LPCTSTR lpszItem) +// +// Return Value: The zero-based index to the string in the list box. +// The return value is LB_ERR if an error occurs; the +// return value is LB_ERRSPACE if insufficient space +// is available to store the new string. +// +// Parameters : lpszItem - Points to the null-terminated +// string that is to be added. +// +// Remarks : Call this member function to add a string to a list +// box. Provided because CListBox::AddString is NOT +// a virtual function. +// +{ + return ((CListBox*)this)->AddString(lpszItem); +} // AddString + +//------------------------------------------------------------------- +// +int CColorListBox::AddString(LPCTSTR lpszItem, COLORREF rgb) +// +// Return Value: The zero-based index to the string in the list box. +// The return value is LB_ERR if an error occurs; the +// return value is LB_ERRSPACE if insufficient space +// is available to store the new string. +// +// Parameters : lpszItem - Points to the null-terminated +// string that is to be added. +// rgb - Specifies the color to be associated with the item. +// +// Remarks : Call this member function to add a string to a list +// box with a custom color. +// +{ + int nItem = AddString(lpszItem); + if (nItem >= 0) + SetItemData(nItem, rgb); + return nItem; +} // AddString + +//------------------------------------------------------------------- +// +int CColorListBox::InsertString(int nIndex, LPCTSTR lpszItem) +// +// Return Value: The zero-based index of the position at which the +// string was inserted. The return value is LB_ERR if +// an error occurs; the return value is LB_ERRSPACE if +// insufficient space is available to store the new string. +// +// Parameters : nIndex - Specifies the zero-based index of the position +// to insert the string. If this parameter is –1, the string +// is added to the end of the list. +// lpszItem - Points to the null-terminated string that +// is to be inserted. +// +// Remarks : Inserts a string into the list box. Provided because +// CListBox::InsertString is NOT a virtual function. +// +{ + return ((CListBox*)this)->InsertString(nIndex, lpszItem); +} // InsertString + +//------------------------------------------------------------------- +// +int CColorListBox::InsertString(int nIndex, LPCTSTR lpszItem, COLORREF rgb) +// +// Return Value: The zero-based index of the position at which the +// string was inserted. The return value is LB_ERR if +// an error occurs; the return value is LB_ERRSPACE if +// insufficient space is available to store the new string. +// +// Parameters : nIndex - Specifies the zero-based index of the position +// to insert the string. If this parameter is –1, the string +// is added to the end of the list. +// lpszItem - Points to the null-terminated string that +// is to be inserted. +// rgb - Specifies the color to be associated with the item. +// +// Remarks : Inserts a colored string into the list box. +// +{ + int nItem = ((CListBox*)this)->InsertString(nIndex,lpszItem); + if (nItem >= 0) + SetItemData(nItem, rgb); + return nItem; +} // InsertString + +//------------------------------------------------------------------- +// +void CColorListBox::SetItemColor(int nIndex, COLORREF rgb) +// +// Return Value: None. +// +// Parameters : nIndex - Specifies the zero-based index of the item. +// rgb - Specifies the color to be associated with the item. +// +// Remarks : Sets the 32-bit value associated with the specified +// item in the list box. +// +{ + SetItemData(nIndex, rgb); + RedrawWindow(); +} // SetItemColor diff --git a/stepmania/src/smpackage/ColorListBox.h b/stepmania/src/smpackage/ColorListBox.h new file mode 100644 index 0000000000..1d5f84070b --- /dev/null +++ b/stepmania/src/smpackage/ColorListBox.h @@ -0,0 +1,65 @@ +#if !defined(AFX_COLORLISTBOX_H__5529A6B1_584A_11D2_A41A_006097BD277B__INCLUDED_) +#define AFX_COLORLISTBOX_H__5529A6B1_584A_11D2_A41A_006097BD277B__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +// ColorListBox.h : header file + +//------------------------------------------------------------------- +// +// CColorListBox class - +// A CListBox-derived class with optional colored items. +// +// Version: 1.0 01/10/1998 Copyright © Patrice Godard +// +// Version: 2.0 09/17/1999 Copyright © Paul M. Meidinger +// +//------------------------------------------------------------------- + +///////////////////////////////////////////////////////////////////////////// +// CColorListBox window + +class CColorListBox : public CListBox +{ +// Construction +public: + CColorListBox(); + +// Attributes +public: + +// Operations +public: + int AddString(LPCTSTR lpszItem); // Adds a string to the list box + int AddString(LPCTSTR lpszItem, COLORREF rgb); // Adds a colored string to the list box + int InsertString(int nIndex, LPCTSTR lpszItem); // Inserts a string to the list box + int InsertString(int nIndex, LPCTSTR lpszItem, COLORREF rgb); // Inserts a colored string to the list box + void SetItemColor(int nIndex, COLORREF rgb); // Sets the color of an item in the list box +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CColorListBox) + public: + virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); + virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CColorListBox(); + + // Generated message map functions +protected: + //{{AFX_MSG(CColorListBox) + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_COLORLISTBOX_H__5529A6B1_584A_11D2_A41A_006097BD277B__INCLUDED_) diff --git a/stepmania/src/smpackage/EditMetricsDlg.cpp b/stepmania/src/smpackage/EditMetricsDlg.cpp new file mode 100644 index 0000000000..b76f82b4d1 --- /dev/null +++ b/stepmania/src/smpackage/EditMetricsDlg.cpp @@ -0,0 +1,46 @@ +// EditMetricsDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "smpackage.h" +#include "EditMetricsDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// EditMetricsDlg dialog + + +EditMetricsDlg::EditMetricsDlg(CWnd* pParent /*=NULL*/) + : CDialog(EditMetricsDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(EditMetricsDlg) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void EditMetricsDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(EditMetricsDlg) + DDX_Control(pDX, IDC_LIST_NAME, m_listName); + DDX_Control(pDX, IDC_LIST_CLASS, m_listClass); + DDX_Control(pDX, IDC_EDIT_VALUE, m_editValue); + DDX_Control(pDX, IDC_EDIT_DEFAULT, m_editDefault); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(EditMetricsDlg, CDialog) + //{{AFX_MSG_MAP(EditMetricsDlg) + // NOTE: the ClassWizard will add message map macros here + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// EditMetricsDlg message handlers diff --git a/stepmania/src/smpackage/EditMetricsDlg.h b/stepmania/src/smpackage/EditMetricsDlg.h new file mode 100644 index 0000000000..20cc6b3834 --- /dev/null +++ b/stepmania/src/smpackage/EditMetricsDlg.h @@ -0,0 +1,52 @@ +#if !defined(AFX_EDITMETRICSDLG_H__39D944CD_BCE4_4C30_876E_0B5A0CE42931__INCLUDED_) +#define AFX_EDITMETRICSDLG_H__39D944CD_BCE4_4C30_876E_0B5A0CE42931__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// EditMetricsDlg.h : header file +// + +#include "ColorListBox.h" + +///////////////////////////////////////////////////////////////////////////// +// EditMetricsDlg dialog + +class EditMetricsDlg : public CDialog +{ +// Construction +public: + EditMetricsDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(EditMetricsDlg) + enum { IDD = IDD_EDIT_METRICS }; + CColorListBox m_listName; + CColorListBox m_listClass; + CEdit m_editValue; + CEdit m_editDefault; + //}}AFX_DATA + + CString m_sTheme; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(EditMetricsDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(EditMetricsDlg) + // NOTE: the ClassWizard will add member functions here + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_EDITMETRICSDLG_H__39D944CD_BCE4_4C30_876E_0B5A0CE42931__INCLUDED_) diff --git a/stepmania/src/smpackage/IniFile.cpp b/stepmania/src/smpackage/IniFile.cpp new file mode 100644 index 0000000000..e204b48060 --- /dev/null +++ b/stepmania/src/smpackage/IniFile.cpp @@ -0,0 +1,275 @@ +/* +----------------------------------------------------------------------------- + File: IniFile.h + + Desc: Wrapper for reading and writing an .ini file. + + Copyright (c) 2001-2002 by the persons listed below. All rights reserved. +----------------------------------------------------------------------------- +*/ + +#include "stdafx.h" +#include "IniFile.h" + + +///////////////////////////////////////////////////////////////////// +// Construction/Destruction +///////////////////////////////////////////////////////////////////// + +//default constructor +IniFile::IniFile() +{ +} + +//constructor, can specify pathname here instead of using SetPath later +IniFile::IniFile(CString inipath) +{ + path = inipath; +} + +//default destructor +IniFile::~IniFile() +{ + +} + +///////////////////////////////////////////////////////////////////// +// Public Functions +///////////////////////////////////////////////////////////////////// + +//sets path of ini file to read and write from +void IniFile::SetPath(CString newpath) +{ + path = newpath; +} + +//reads ini file specified using IniFile::SetPath() +//returns true if successful, false otherwise +BOOL IniFile::ReadFile() +{ + CStdioFile file; + if( !file.Open(path, CFile::modeRead) ) + { + error = "Unable to open ini file."; + return FALSE; + } + + CString line; + int curkey = -1, curval = -1; + CString keyname, valuename, value; + while( file.ReadString(line) ) + { + if( line != "" ) + { + if( line[0] == '[' && line[line.GetLength()-1] == ']' ) //if a section heading + { + keyname = line; + keyname.TrimLeft('['); + keyname.TrimRight(']'); + } + else //if a value + { + int iIndexOfEqual = line.Find("="); + if( iIndexOfEqual == -1 ) // this is a malformed line + continue; + valuename = line.Left( iIndexOfEqual ); + value = line.Right(line.GetLength()-valuename.GetLength()-1); + SetValue(keyname,valuename,value); + } + } + } + file.Close(); + return 1; +} + +//writes data stored in class to ini file +void IniFile::WriteFile() +{ + CStdioFile file; + if( !file.Open(path, CFile::modeCreate | CFile::modeWrite ) ) + { + error = "Unable to open ini for writing."; + return; + } + + // foreach key + for( int keynum = 0; keynum <= names.GetUpperBound(); keynum++ ) + { + CString sTemp; + sTemp.Format( "[%s]\n", names[keynum] ); + file.WriteString( sTemp ); + + CMapStringToString &map = keys[keynum]; + + // for each value_name/value pair + for( POSITION pos = map.GetStartPosition(); pos != NULL; ) + { + CString value_name; + CString value; + map.GetNextAssoc( pos, value_name, value ); + + sTemp.Format( "%s=%s\n", value_name, value ); + file.WriteString( sTemp ); + } + file.WriteString( "\n" ); + } + + file.Close(); +} + +//deletes all stored ini data +void IniFile::Reset() +{ + keys.SetSize(0); + names.SetSize(0); +} + +//returns number of keys currently in the ini +int IniFile::GetNumKeys() +{ + return keys.GetSize(); +} + +//returns a pointer to the key for direct modification +CMapStringToString* IniFile::GetKeyPointer( CString keyname ) +{ + int keynum = FindKey(keyname); + if (keynum == -1) + return NULL; + else + return &keys[keynum]; +} + +//returns number of values stored for specified key, or -1 if key not found +int IniFile::GetNumValues(CString keyname) +{ + int keynum = FindKey(keyname); + if (keynum == -1) + return -1; + else + return keys[keynum].GetCount(); +} + +//gets value of [keyname] valuename = +//overloaded to return CString, int, and double +CString IniFile::GetValue(CString keyname, CString valuename) +{ + int keynum = FindKey(keyname);//, valuenum = FindValue(keynum,valuename); + if( keynum == -1 ) + { + error = "Unable to locate specified key."; + return ""; + } + + CMapStringToString &map = keys[keynum]; + CString value; + if( !map.Lookup(valuename, value) ) + { + error = "Unable to locate specified value."; + return ""; + } + return value; +} + +//gets value of [keyname] valuename = +//overloaded to return CString, int, and double +int IniFile::GetValueI(CString keyname, CString valuename) +{ + return atoi( GetValue(keyname,valuename) ); +} + +//gets value of [keyname] valuename = +//overloaded to return CString, int, and double +double IniFile::GetValueF(CString keyname, CString valuename) +{ + return atof( GetValue(keyname, valuename) ); +} + +//sets value of [keyname] valuename =. +//specify the optional paramter as false (0) if you do not want it to create +//the key if it doesn't exist. Returns true if data entered, false otherwise +//overloaded to accept CString, int, and double +BOOL IniFile::SetValue(CString keyname, CString valuename, CString value, BOOL create) +{ + int keynum = FindKey(keyname); + + if( keynum == -1 ) //if key doesn't exist + { + if( !create ) //and user does not want to create it, + return FALSE; //stop entering this key + names.SetSize(names.GetSize()+1); + keys.SetSize(keys.GetSize()+1); + keynum = names.GetSize()-1; + names[keynum] = keyname; + } + + // insert value + CMapStringToString &map = keys[keynum]; + CString oldvalue; + if( !map.Lookup(valuename, oldvalue) && !create ) + return FALSE; + map[valuename] = value; + return TRUE; +} + +//sets value of [keyname] valuename =. +//specify the optional paramter as false (0) if you do not want it to create +//the key if it doesn't exist. Returns true if data entered, false otherwise +//overloaded to accept CString, int, and double +BOOL IniFile::SetValueI(CString keyname, CString valuename, int value, BOOL create) +{ + CString temp; + temp.Format("%d",value); + return SetValue(keyname, valuename, temp, create); +} + +//sets value of [keyname] valuename =. +//specify the optional paramter as false (0) if you do not want it to create +//the key if it doesn't exist. Returns true if data entered, false otherwise +//overloaded to accept CString, int, and double +BOOL IniFile::SetValueF(CString keyname, CString valuename, double value, BOOL create) +{ + CString temp; + temp.Format("%e",value); + return SetValue(keyname, valuename, temp, create); +} + +//deletes specified value +//returns true if value existed and deleted, false otherwise +BOOL IniFile::DeleteValue(CString keyname, CString valuename) +{ + int keynum = FindKey(keyname); + if( keynum == -1 ) + return FALSE; + + CMapStringToString &map = keys[keynum]; + return map.RemoveKey( valuename ); +} + +//deletes specified key and all values contained within +//returns true if key existed and deleted, false otherwise +BOOL IniFile::DeleteKey(CString keyname) +{ + int keynum = FindKey(keyname); + if (keynum == -1) + return 0; + keys.RemoveAt(keynum); + names.RemoveAt(keynum); + return 1; +} + +///////////////////////////////////////////////////////////////////// +// Private Functions +///////////////////////////////////////////////////////////////////// + +//returns index of specified key, or -1 if not found +int IniFile::FindKey(CString keyname) +{ + int keynum = 0; + while ( keynum < keys.GetSize() && names[keynum] != keyname) + keynum++; + if (keynum == keys.GetSize()) + return -1; + return keynum; +} + diff --git a/stepmania/src/smpackage/IniFile.h b/stepmania/src/smpackage/IniFile.h new file mode 100644 index 0000000000..9f3d8e984f --- /dev/null +++ b/stepmania/src/smpackage/IniFile.h @@ -0,0 +1,111 @@ +/* +----------------------------------------------------------------------------- + File: IniFile.h + + Desc: Wrapper for reading and writing an .ini file. + + Copyright (c) 2001-2002 by the persons listed below. All rights reserved. +----------------------------------------------------------------------------- +*/ + + +#ifndef _INIFILE_H_ +#define _INIFILE_H_ + +#include +//#include + + +class IniFile +{ + //all private variables +public: + + //stores pathname of ini file to read/write + CString path; + + //all keys are of this time + typedef CMapStringToString key; + + //list of keys in ini + CArray keys; + + //corresponding list of keynames + CArray names; + + + + //all private functions +private: + + //returns index of specified key, or -1 if not found + int FindKey(CString keyname); + + + //public variables +public: + + //will contain error info if one occurs + //ended up not using much, just in ReadFile and GetValue + CString error; + + + //public functions +public: + //default constructor + IniFile(); + + //constructor, can specify pathname here instead of using SetPath later + IniFile(CString inipath); + + //default destructor + virtual ~IniFile(); + + //sets path of ini file to read and write from + void SetPath(CString newpath); + + //reads ini file specified using IniFile::SetPath() + //returns true if successful, false otherwise + BOOL ReadFile(); + + //writes data stored in class to ini file + void WriteFile(); + + //deletes all stored ini data + void Reset(); + + //returns number of keys currently in the ini + int GetNumKeys(); + + //returns a pointer to the key for direct modification + CMapStringToString* GetKeyPointer( CString keyname ); + + //returns number of values stored for specified key + int GetNumValues( CString keyname ); + + //gets value of [keyname] valuename = + //overloaded to return CString, int, and double, + //returns "", or 0 if key/value not found. Sets error member to show problem + CString GetValue(CString keyname, CString valuename); + int GetValueI(CString keyname, CString valuename); + double GetValueF(CString keyname, CString valuename); + + //sets value of [keyname] valuename =. + //specify the optional paramter as false (0) if you do not want it to create + //the key if it doesn't exist. Returns true if data entered, false otherwise + //overloaded to accept CString, int, and double + BOOL SetValue(CString key, CString valuename, CString value, BOOL create = 1); + BOOL SetValueI(CString key, CString valuename, int value, BOOL create = 1); + BOOL SetValueF(CString key, CString valuename, double value, BOOL create = 1); + + //deletes specified value + //returns true if value existed and deleted, false otherwise + BOOL DeleteValue(CString keyname, CString valuename); + + //deletes specified key and all values contained within + //returns true if key existed and deleted, false otherwise + BOOL DeleteKey(CString keyname); +}; + + +#endif diff --git a/stepmania/src/smpackage/editmetrics.bmp b/stepmania/src/smpackage/editmetrics.bmp index f78567aec8..d571f42441 100644 Binary files a/stepmania/src/smpackage/editmetrics.bmp and b/stepmania/src/smpackage/editmetrics.bmp differ diff --git a/stepmania/src/smpackage/onvertThemeDlg.cpp b/stepmania/src/smpackage/onvertThemeDlg.cpp index 187f6d1fff..85e1a35de7 100644 --- a/stepmania/src/smpackage/onvertThemeDlg.cpp +++ b/stepmania/src/smpackage/onvertThemeDlg.cpp @@ -5,6 +5,9 @@ #include "smpackage.h" #include "onvertThemeDlg.h" #include "smpackageUtil.h" +#include "EditMetricsDlg.h" +#include "EditMetricsDlg.h" +#include "IniFile.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -29,6 +32,8 @@ void ConvertThemeDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(ConvertThemeDlg) + DDX_Control(pDX, IDC_BUTTON_ANALYZE_METRICS, m_buttonAnalyzeMetrics); + DDX_Control(pDX, IDC_BUTTON_EDIT_METRICS, m_buttonEditMetrics); DDX_Control(pDX, IDC_BUTTON_ANALYZE, m_buttonAnalyze); DDX_Control(pDX, IDC_BUTTON_CONVERT, m_buttonConvert); DDX_Control(pDX, IDC_LIST_THEMES, m_listThemes); @@ -41,6 +46,8 @@ BEGIN_MESSAGE_MAP(ConvertThemeDlg, CDialog) ON_BN_CLICKED(IDC_BUTTON_CONVERT, OnButtonConvert) ON_LBN_SELCHANGE(IDC_LIST_THEMES, OnSelchangeListThemes) ON_BN_CLICKED(IDC_BUTTON_ANALYZE, OnButtonAnalyze) + ON_BN_CLICKED(IDC_BUTTON_EDIT_METRICS, OnButtonEditMetrics) + ON_BN_CLICKED(IDC_BUTTON_ANALYZE_METRICS, OnButtonAnalyzeMetrics) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -192,6 +199,8 @@ void ConvertThemeDlg::OnSelchangeListThemes() BOOL bSomethingSelected = m_listThemes.GetCurSel() != LB_ERR; m_buttonConvert.EnableWindow( bSomethingSelected ); m_buttonAnalyze.EnableWindow( bSomethingSelected ); + m_buttonEditMetrics.EnableWindow( bSomethingSelected ); + m_buttonAnalyzeMetrics.EnableWindow( bSomethingSelected ); } bool FilesAreIdentical( CString sPath1, CString sPath2 ) @@ -225,6 +234,28 @@ CString StripExtension( CString sPath ) return sDir + sFName; } +void LaunchNotepad( CString sPathToOpen ) +{ + PROCESS_INFORMATION pi; + STARTUPINFO si; + ZeroMemory( &si, sizeof(si) ); + + char szCommand[MAX_PATH] = "notepad.exe "; + strcat( szCommand, sPathToOpen ); + CreateProcess( + NULL, // pointer to name of executable module + szCommand, // 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 + ); +} + void ConvertThemeDlg::OnButtonAnalyze() { // TODO: Add your control notification handler code here @@ -232,9 +263,9 @@ void ConvertThemeDlg::OnButtonAnalyze() CString sBaseDir = "Themes\\default\\"; int iSel = m_listThemes.GetCurSel(); - CString sThemeDir; - m_listThemes.GetText( iSel, sThemeDir ); - sThemeDir = "Themes\\"+sThemeDir+"\\"; + CString sThemeName; + m_listThemes.GetText( iSel, sThemeName ); + CString sThemeDir = "Themes\\"+sThemeName+"\\"; CStringArray asBaseFilePaths; GetDirListing( sBaseDir+"BGAnimations\\*.*", asBaseFilePaths, false, true ); @@ -250,15 +281,14 @@ void ConvertThemeDlg::OnButtonAnalyze() 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; + CStringArray asRedundant; + CStringArray asWarning; for( i=0; i