From e89595cbeaf8b30709e434290474475be1528730 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 28 Mar 2003 21:34:40 +0000 Subject: [PATCH] Added theme metrics analysis Working on metrics editor --- stepmania/src/smpackage/ColorListBox.cpp | 275 +++++++++++++++++++++ stepmania/src/smpackage/ColorListBox.h | 65 +++++ stepmania/src/smpackage/EditMetricsDlg.cpp | 46 ++++ stepmania/src/smpackage/EditMetricsDlg.h | 52 ++++ stepmania/src/smpackage/IniFile.cpp | 275 +++++++++++++++++++++ stepmania/src/smpackage/IniFile.h | 111 +++++++++ stepmania/src/smpackage/editmetrics.bmp | Bin 31404 -> 31578 bytes stepmania/src/smpackage/onvertThemeDlg.cpp | 193 ++++++++++++--- stepmania/src/smpackage/onvertThemeDlg.h | 4 + stepmania/src/smpackage/resource.h | 13 +- stepmania/src/smpackage/smpackage.clw | 61 +++-- stepmania/src/smpackage/smpackage.dsp | 32 +++ stepmania/src/smpackage/smpackage.rc | 76 ++++-- 13 files changed, 1124 insertions(+), 79 deletions(-) create mode 100644 stepmania/src/smpackage/ColorListBox.cpp create mode 100644 stepmania/src/smpackage/ColorListBox.h create mode 100644 stepmania/src/smpackage/EditMetricsDlg.cpp create mode 100644 stepmania/src/smpackage/EditMetricsDlg.h create mode 100644 stepmania/src/smpackage/IniFile.cpp create mode 100644 stepmania/src/smpackage/IniFile.h 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 f78567aec8a0fc5acfba50ec7ebc861c75a7501d..d571f4244156c19c4b0f3495450f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