metrics editor mostly working

This commit is contained in:
Chris Danford
2003-03-30 00:45:35 +00:00
parent 3ceec51ef3
commit f2a88c4eea
5 changed files with 193 additions and 58 deletions
+137 -16
View File
@@ -12,6 +12,11 @@
static char THIS_FILE[] = __FILE__;
#endif
#define BLACK RGB(0,0,0)
#define RED RGB(255,0,0)
#define SET_ITEM_STYLE(item,bInBase,bInTheme) {m_tree.SetItemColor(item,bInBase?BLACK:RED);m_tree.SetItemBold(item,bInTheme);}
/////////////////////////////////////////////////////////////////////////////
// EditMetricsDlg dialog
@@ -28,9 +33,10 @@ void EditMetricsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(EditMetricsDlg)
DDX_Control(pDX, IDC_EDIT_VALUE, m_editValue);
DDX_Control(pDX, IDC_EDIT_DEFAULT, m_editDefault);
DDX_Control(pDX, IDC_BUTTON_REMOVE, m_buttonRemove);
DDX_Control(pDX, IDC_BUTTON_OVERRIDE, m_buttonOverride);
DDX_Control(pDX, IDC_BUTTON_NEW, m_buttonNew);
DDX_Control(pDX, IDC_TREE, m_tree);
//}}AFX_DATA_MAP
}
@@ -38,6 +44,12 @@ 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)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -59,19 +71,6 @@ BOOL EditMetricsDlg::OnInitDialog()
IniFile iniBase;
IniFile iniTheme;
unsigned long GetColor( bool bInBase, bool bInTheme )
{
if( bInBase && bInTheme )
return RGB(0,0,0);
else if( bInBase && !bInTheme )
return RGB(127,127,127);
else if( !bInBase && bInTheme )
return RGB(255,0,0);
else
ASSERT(0);
return RGB(0,0,0);
}
void EditMetricsDlg::RefreshTree()
{
m_tree.DeleteAllItems();
@@ -97,7 +96,7 @@ void EditMetricsDlg::RefreshTree()
bool bInTheme = iniTheme.FindKey(sKey) != -1;
HTREEITEM item1 = m_tree.InsertItem( sKey );
m_tree.SetItemColor( item1, GetColor(bInBase,bInTheme) );
SET_ITEM_STYLE( item1, bInBase, bInTheme );
IniFile::key &key = iniCombined.keys[i];
for( POSITION pos=key.GetStartPosition(); pos != NULL; )
@@ -110,7 +109,129 @@ void EditMetricsDlg::RefreshTree()
bool bInTheme = !!iniTheme.GetValue( sKey, sName, sThrowAway );
HTREEITEM item2 = m_tree.InsertItem( sName, item1 );
m_tree.SetItemColor( item2, GetColor(bInBase,bInTheme) );
SET_ITEM_STYLE( item2, bInBase, bInTheme );
}
}
}
void EditMetricsDlg::GetSelectedKeyAndName( CString& sKeyOut, CString& sNameOut )
{
sKeyOut = "";
sNameOut = "";
HTREEITEM itemSel = m_tree.GetSelectedItem();
if( itemSel == NULL )
return;
HTREEITEM itemParent = m_tree.GetParentItem( itemSel );
if( itemParent == NULL )
{
sKeyOut = m_tree.GetItemText( itemSel );
return;
}
sKeyOut = m_tree.GetItemText( itemParent );
sNameOut = m_tree.GetItemText( itemSel );
}
void EditMetricsDlg::OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
CString sKey, sName;
GetSelectedKeyAndName( sKey, sName );
if( sName == "" )
{
m_buttonOverride.EnableWindow( false );
m_buttonRemove.EnableWindow( false );
m_editValue.EnableWindow( false );
m_editValue.SetWindowText( "" );
m_editDefault.SetWindowText( "" );
return;
}
CString sThrowAway;
bool bInBase = !!iniBase.GetValue( sKey, sName, sThrowAway );
bool bInTheme = !!iniTheme.GetValue( sKey, sName, sThrowAway );
m_buttonOverride.EnableWindow( bInBase && !bInTheme );
m_buttonRemove.EnableWindow( bInTheme );
m_editValue.EnableWindow( bInTheme );
m_editValue.SetWindowText( bInTheme ? iniTheme.GetValue(sKey,sName) : "" );
m_editDefault.SetWindowText( bInBase ? iniBase.GetValue(sKey,sName) : "" );
*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
CString sKey, sName;
GetSelectedKeyAndName( sKey, sName );
HTREEITEM itemSel = m_tree.GetSelectedItem();
HTREEITEM itemParent = m_tree.GetParentItem( itemSel );
SET_ITEM_STYLE( itemSel, true, true );
m_tree.RedrawWindow();
m_editValue.EnableWindow( true );
m_buttonOverride.EnableWindow( false );
m_buttonRemove.EnableWindow( true );
iniTheme.SetValue( sKey, sName, "" );
}
void EditMetricsDlg::OnButtonRemove()
{
// TODO: Add your control notification handler code here
CString sKey, sName;
GetSelectedKeyAndName( sKey, sName );
HTREEITEM itemSel = m_tree.GetSelectedItem();
CString sThrowAway;
bool bInBase = !!iniBase.GetValue( sKey, sName, sThrowAway );
if( bInBase )
{
m_tree.SetItemColor( itemSel, BLACK );
m_tree.SetItemBold( itemSel, false );
m_tree.RedrawWindow();
m_buttonOverride.EnableWindow( true );
m_buttonRemove.EnableWindow( false );
}
else
m_tree.DeleteItem( itemSel );
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();
}
+10 -1
View File
@@ -21,9 +21,10 @@ public:
// Dialog Data
//{{AFX_DATA(EditMetricsDlg)
enum { IDD = IDD_EDIT_METRICS };
CEdit m_editValue;
CEdit m_editDefault;
CButton m_buttonRemove;
CButton m_buttonOverride;
CButton m_buttonNew;
CTreeCtrlEx m_tree;
//}}AFX_DATA
@@ -42,10 +43,18 @@ protected:
// Generated message map functions
//{{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
DECLARE_MESSAGE_MAP()
void RefreshTree();
void GetSelectedKeyAndName( CString& sKeyOut, CString& sNameOut );
};
//{{AFX_INSERT_LOCATION}}
+3 -2
View File
@@ -45,8 +45,9 @@
#define IDC_BUTTON_ANALYZE_METRICS 1027
#define IDC_EDIT_VALUE 1028
#define IDC_EDIT_DEFAULT 1029
#define IDC_BUTTON_REFRESH 1035
#define IDC_BUTTON_SAVE 1036
#define IDC_BUTTON_OVERRIDE 1037
#define IDC_BUTTON_NEW 1039
// Next default values for new objects
//
@@ -54,7 +55,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 147
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1035
#define _APS_NEXT_CONTROL_VALUE 1036
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
+15 -14
View File
@@ -13,18 +13,18 @@ Class2=CSmpackageDlg
ResourceCount=8
Resource1=IDR_MAINFRAME
Resource2=IDD_INSTALL
Resource2=IDD_EXPORTER
Class3=CSMPackageInstallDlg
Class4=CSmpackageExportDlg
Resource3=IDD_EDIT_INSTALLATIONS
Resource3=IDD_CONVERT_THEME
Class5=EnterName
Resource4=IDD_MENU
Resource4=IDD_DIALOG_NAME
Class6=EditInsallations
Resource5=IDD_CONVERT_THEME
Resource5=IDD_INSTALL
Class7=MainMenuDlg
Resource6=IDD_DIALOG_NAME
Resource6=IDD_EDIT_INSTALLATIONS
Class8=ConvertThemeDlg
Resource7=IDD_EXPORTER
Resource7=IDD_MENU
Class9=EditMetricsDlg
Resource8=IDD_EDIT_METRICS
@@ -193,19 +193,20 @@ VirtualFilter=dWC
[DLG:IDD_EDIT_METRICS]
Type=1
Class=EditMetricsDlg
ControlCount=12
ControlCount=13
Control1=IDOK,button,1342242817
Control2=IDC_STATIC,static,1342177294
Control3=IDC_EDIT_VALUE,edit,1350631552
Control3=IDC_EDIT_VALUE,edit,1484849220
Control4=IDC_STATIC,static,1342308352
Control5=IDC_EDIT_DEFAULT,edit,1350633600
Control5=IDC_EDIT_DEFAULT,edit,1350633540
Control6=IDC_STATIC,static,1342308352
Control7=IDC_BUTTON_OVERRIDE,button,1342242816
Control8=IDC_BUTTON_REMOVE,button,1342242816
Control9=IDC_BUTTON_NEW,button,1342242816
Control10=IDC_TREE,SysTreeView32,1350631461
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_STATIC,static,1342308352
Control12=IDC_BUTTON_REFRESH,button,1342242816
Control13=IDC_BUTTON_SAVE,button,1342242816
[CLS:EditMetricsDlg]
Type=0
+28 -25
View File
@@ -174,32 +174,32 @@ BEGIN
IDC_STATIC,103,168,215,35
END
IDD_CONVERT_THEME DIALOG DISCARDABLE 0, 0, 332, 262
IDD_CONVERT_THEME DIALOG DISCARDABLE 0, 0, 332, 258
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Theme Elements"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "Close",IDOK,275,241,50,14
DEFPUSHBUTTON "Close",IDOK,275,237,50,14
CONTROL 144,IDC_STATIC,"Static",SS_BITMAP,0,0,332,38
LISTBOX IDC_LIST_THEMES,7,44,88,192,LBS_SORT |
LISTBOX IDC_LIST_THEMES,7,44,88,186,LBS_SORT |
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Convert from 3.0 to 4.0",IDC_BUTTON_CONVERT,170,51,95,
15,WS_DISABLED
LTEXT "This will convert the element names in a SM 3.0 theme to the SM 4.0 theme naming scheme. 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. (This tool will not convert theme metrics)",
IDC_STATIC,110,71,210,40
GROUPBOX "Elements",IDC_STATIC,105,41,220,106
LTEXT "This will convert the element names in a SM 3.0 theme to the SM 4.0 theme names. A converted theme will no longer be compatible with StepMania 3.0, so make a backup. This tool does not convert theme metrics.",
IDC_STATIC,110,71,210,33
GROUPBOX "Elements",IDC_STATIC,105,41,220,100
LTEXT "Check for redundant or possibly midnamed theme elements.",
IDC_STATIC,110,135,210,10
PUSHBUTTON "Analyze Elements",IDC_BUTTON_ANALYZE,165,115,95,15,
IDC_STATIC,110,127,210,11
PUSHBUTTON "Analyze Elements",IDC_BUTTON_ANALYZE,165,107,95,15,
WS_DISABLED
GROUPBOX "Metrics",IDC_STATIC,105,153,220,83
GROUPBOX "Metrics",IDC_STATIC,105,149,220,81
LTEXT "Edit theme metrics with a user-friendly interface.",
IDC_STATIC,110,183,210,10
PUSHBUTTON "Edit Metrics",IDC_BUTTON_EDIT_METRICS,165,163,95,15,
IDC_STATIC,110,179,210,10
PUSHBUTTON "Edit Metrics",IDC_BUTTON_EDIT_METRICS,165,159,95,15,
WS_DISABLED
LTEXT "Check for redundant or possibly midnamed theme metrics.",
IDC_STATIC,109,223,210,10
PUSHBUTTON "Analyze Metrics",IDC_BUTTON_ANALYZE_METRICS,165,203,95,
IDC_STATIC,109,217,210,10
PUSHBUTTON "Analyze Metrics",IDC_BUTTON_ANALYZE_METRICS,165,197,95,
15,WS_DISABLED
END
@@ -210,21 +210,24 @@ FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "Close",IDOK,275,213,50,14
CONTROL 146,IDC_STATIC,"Static",SS_BITMAP,0,0,332,38
EDITTEXT IDC_EDIT_VALUE,217,116,108,38,ES_AUTOHSCROLL
LTEXT "Value",IDC_STATIC,218,105,88,9
EDITTEXT IDC_EDIT_DEFAULT,217,170,108,40,ES_AUTOHSCROLL |
ES_READONLY
LTEXT "Default Value",IDC_STATIC,218,159,88,9
PUSHBUTTON "Override",IDC_BUTTON_OVERRIDE,217,45,60,14
PUSHBUTTON "Remove Override",IDC_BUTTON_REMOVE,217,63,60,14
PUSHBUTTON "New Metric",IDC_BUTTON_NEW,217,81,60,14
EDITTEXT IDC_EDIT_VALUE,217,95,108,50,ES_MULTILINE |
ES_AUTOVSCROLL | WS_DISABLED
LTEXT "Value",IDC_STATIC,218,83,88,9
EDITTEXT IDC_EDIT_DEFAULT,217,161,108,48,ES_MULTILINE |
ES_AUTOVSCROLL | ES_READONLY
LTEXT "Default Value",IDC_STATIC,218,148,88,9
PUSHBUTTON "Override",IDC_BUTTON_OVERRIDE,217,45,60,14,WS_DISABLED
PUSHBUTTON "Remove Override",IDC_BUTTON_REMOVE,217,64,60,14,
WS_DISABLED
CONTROL "Tree1",IDC_TREE,"SysTreeView32",TVS_HASBUTTONS |
TVS_LINESATROOT | TVS_SHOWSELALWAYS | WS_BORDER |
WS_TABSTOP,91,44,119,165
LTEXT "Help:\n\nGray = A metric that is not overridden by the current theme (exists in the base theme but not in the current theme)",
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 "Black = A metric that is overridden by the current theme (exists in both the base theme, and 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,106,78,103
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
PUSHBUTTON "Save",IDC_BUTTON_SAVE,203,213,56,14
END
@@ -324,7 +327,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 325
TOPMARGIN, 7
BOTTOMMARGIN, 255
BOTTOMMARGIN, 251
END
IDD_EDIT_METRICS, DIALOG