fix bugs in metrics editor

This commit is contained in:
Chris Danford
2003-04-11 04:28:15 +00:00
parent fb27c29bee
commit d201c87897
6 changed files with 68 additions and 51 deletions
+50 -28
View File
@@ -5,6 +5,7 @@
#include "smpackage.h"
#include "EditMetricsDlg.h"
#include "IniFile.h"
#include "RageUtil.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -45,11 +46,11 @@ void EditMetricsDlg::DoDataExchange(CDataExchange* pDX)
BEGIN_MESSAGE_MAP(EditMetricsDlg, CDialog)
//{{AFX_MSG_MAP(EditMetricsDlg)
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE, OnSelchangedTree)
ON_EN_KILLFOCUS(IDC_EDIT_VALUE, OnKillfocusEditValue)
ON_BN_CLICKED(IDC_BUTTON_OVERRIDE, OnButtonOverride)
ON_BN_CLICKED(IDC_BUTTON_REMOVE, OnButtonRemove)
ON_BN_CLICKED(IDC_BUTTON_REFRESH, OnButtonRefresh)
ON_BN_CLICKED(IDC_BUTTON_SAVE, OnButtonSave)
ON_EN_CHANGE(IDC_EDIT_VALUE, OnChangeEditValue)
ON_BN_CLICKED(IDC_BUTTON_HELP, OnButtonHelp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -89,20 +90,34 @@ void EditMetricsDlg::RefreshTree()
iniCombined.SetPath( "Themes\\"+m_sTheme+"\\metrics.ini" );
iniCombined.ReadFile();
for( int i=0; i<iniCombined.names.GetSize(); i++ )
CStringArray asKeys;
asKeys.Copy( iniCombined.names );
SortCStringArray( asKeys );
for( int i=0; i<asKeys.GetSize(); i++ )
{
CString sKey = iniCombined.names[i];
CString sKey = asKeys[i];
bool bInBase = iniBase.FindKey(sKey) != -1;
bool bInTheme = iniTheme.FindKey(sKey) != -1;
HTREEITEM item1 = m_tree.InsertItem( sKey );
SET_ITEM_STYLE( item1, bInBase, bInTheme );
IniFile::key &key = iniCombined.keys[i];
for( POSITION pos=key.GetStartPosition(); pos != NULL; )
IniFile::key* pKey = iniCombined.GetKeyPointer( sKey );
CStringArray asNames;
for( POSITION pos=pKey->GetStartPosition(); pos != NULL; )
{
CString sName, sValue;
key.GetNextAssoc( pos, sName, sValue );
pKey->GetNextAssoc( pos, sName, sValue );
asNames.Add( sName );
}
SortCStringArray( asNames );
for( int j=0; j<asNames.GetSize(); j++ )
{
CString sName = asNames[j];
CString sValue = iniCombined.GetValue( sKey, sName );
CString sThrowAway;
bool bInBase = !!iniBase.GetValue( sKey, sName, sThrowAway );
@@ -165,17 +180,6 @@ void EditMetricsDlg::OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = 0;
}
void EditMetricsDlg::OnKillfocusEditValue()
{
// TODO: Add your control notification handler code here
CString sKey, sName;
GetSelectedKeyAndName( sKey, sName );
CString sText;
m_editValue.GetWindowText( sText );
iniBase.SetValue( sKey, sName, sText );
}
void EditMetricsDlg::OnButtonOverride()
{
// TODO: Add your control notification handler code here
@@ -189,6 +193,7 @@ void EditMetricsDlg::OnButtonOverride()
m_tree.RedrawWindow();
m_editValue.EnableWindow( true );
m_editValue.SetFocus();
m_buttonOverride.EnableWindow( false );
m_buttonRemove.EnableWindow( true );
@@ -213,6 +218,7 @@ void EditMetricsDlg::OnButtonRemove()
m_tree.RedrawWindow();
m_buttonOverride.EnableWindow( true );
m_buttonRemove.EnableWindow( false );
m_editValue.EnableWindow( false );
}
else
m_tree.DeleteItem( itemSel );
@@ -220,18 +226,34 @@ void EditMetricsDlg::OnButtonRemove()
iniTheme.DeleteValue( sKey, sName );
}
void EditMetricsDlg::OnButtonRefresh()
{
// TODO: Add your control notification handler code here
OnButtonSave();
RefreshTree();
m_buttonOverride.EnableWindow( false );
m_buttonRemove.EnableWindow( false );
m_editValue.EnableWindow( false );
}
void EditMetricsDlg::OnButtonSave()
{
// TODO: Add your control notification handler code here
iniTheme.WriteFile();
}
void EditMetricsDlg::OnChangeEditValue()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CString sKey, sName;
GetSelectedKeyAndName( sKey, sName );
CString sText;
m_editValue.GetWindowText( sText );
iniTheme.SetValue( sKey, sName, sText );
}
void EditMetricsDlg::OnButtonHelp()
{
// TODO: Add your control notification handler code here
AfxMessageBox(
"Bold = A metric that is overridden by the current theme (exists in both the base theme, and the current theme)\n\n"
"Not Bold = A metric that is not overridden by the current theme (exists in the base theme but not in the current theme)\n\n"
"Red = A metric that exists in the current theme but not in the base theme (check to see if the metric name is misspelled)"
);
}
+2 -2
View File
@@ -44,12 +44,12 @@ protected:
//{{AFX_MSG(EditMetricsDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnKillfocusEditValue();
afx_msg void OnButtonOverride();
afx_msg void OnButtonRemove();
afx_msg void OnButtonNew();
afx_msg void OnButtonRefresh();
afx_msg void OnButtonSave();
afx_msg void OnChangeEditValue();
afx_msg void OnButtonHelp();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
+1 -1
View File
@@ -31,7 +31,7 @@ public:
CArray<key, key> keys;
//corresponding list of keynames
CArray<CString, CString> names;
CStringArray names;
+2 -1
View File
@@ -48,6 +48,7 @@
#define IDC_BUTTON_REFRESH 1035
#define IDC_BUTTON_SAVE 1036
#define IDC_BUTTON_OVERRIDE 1037
#define IDC_BUTTON_HELP 1038
// Next default values for new objects
//
@@ -55,7 +56,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 147
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1036
#define _APS_NEXT_CONTROL_VALUE 1039
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
+10 -12
View File
@@ -13,18 +13,18 @@ Class2=CSmpackageDlg
ResourceCount=8
Resource1=IDR_MAINFRAME
Resource2=IDD_EXPORTER
Resource2=IDD_INSTALL
Class3=CSMPackageInstallDlg
Class4=CSmpackageExportDlg
Resource3=IDD_MENU
Resource3=IDD_EDIT_INSTALLATIONS
Class5=EnterName
Resource4=IDD_DIALOG_NAME
Resource4=IDD_EXPORTER
Class6=EditInsallations
Resource5=IDD_INSTALL
Resource5=IDD_CONVERT_THEME
Class7=MainMenuDlg
Resource6=IDD_EDIT_INSTALLATIONS
Resource6=IDD_DIALOG_NAME
Class8=ConvertThemeDlg
Resource7=IDD_CONVERT_THEME
Resource7=IDD_MENU
Class9=EditMetricsDlg
Resource8=IDD_EDIT_METRICS
@@ -193,7 +193,7 @@ VirtualFilter=dWC
[DLG:IDD_EDIT_METRICS]
Type=1
Class=EditMetricsDlg
ControlCount=13
ControlCount=11
Control1=IDOK,button,1342242817
Control2=IDC_STATIC,static,1342177294
Control3=IDC_EDIT_VALUE,edit,1484849220
@@ -203,10 +203,8 @@ Control6=IDC_STATIC,static,1342308352
Control7=IDC_BUTTON_OVERRIDE,button,1476460544
Control8=IDC_BUTTON_REMOVE,button,1476460544
Control9=IDC_TREE,SysTreeView32,1350631461
Control10=IDC_STATIC,static,1342308352
Control11=IDC_STATIC,static,1342308352
Control12=IDC_BUTTON_REFRESH,button,1342242816
Control13=IDC_BUTTON_SAVE,button,1342242816
Control10=IDC_BUTTON_SAVE,button,1342242816
Control11=IDC_BUTTON_HELP,button,1342242816
[CLS:EditMetricsDlg]
Type=0
@@ -215,5 +213,5 @@ ImplementationFile=EditMetricsDlg.cpp
BaseClass=CDialog
Filter=D
VirtualFilter=dWC
LastObject=EditMetricsDlg
LastObject=IDC_BUTTON_REMOVE
+3 -7
View File
@@ -101,7 +101,7 @@ 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"
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "Close",IDOK,255,215,69,14
PUSHBUTTON "Play Stepmania",IDC_BUTTON_PLAY,5,215,70,15
@@ -221,13 +221,9 @@ BEGIN
WS_DISABLED
CONTROL "Tree1",IDC_TREE,"SysTreeView32",TVS_HASBUTTONS |
TVS_LINESATROOT | TVS_SHOWSELALWAYS | WS_BORDER |
WS_TABSTOP,91,44,119,165
LTEXT "Help:\n\nBold = A metric that is overridden by the current theme (exists in both the base theme, and the current theme)",
IDC_STATIC,7,43,79,62
LTEXT "Not Bold = A metric that is not overridden by the current theme (exists in the base theme but not in the current theme)\n\nRed = A metric that exists in the current theme but not in the base theme (check to see if the metric name is misspelled)",
IDC_STATIC,7,107,78,101
PUSHBUTTON "Save and Refresh",IDC_BUTTON_REFRESH,116,213,69,14
WS_TABSTOP,7,44,203,165
PUSHBUTTON "Save",IDC_BUTTON_SAVE,203,213,56,14
PUSHBUTTON "Explanation",IDC_BUTTON_HELP,65,214,71,13
END