[commit] r1645 - trunk/GME/Gme

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Tue Oct 18 11:40:29 CDT 2011


Author: ksmyth
Date: Tue Oct 18 11:40:28 2011
New Revision: 1645

Log:
Use common file dialog with default extension. Fixes problem with File>Save As "Version1.0" getting saved without .mga extension

Modified:
   trunk/GME/Gme/GMEApp.cpp
   trunk/GME/Gme/MgaOpenDlg.cpp
   trunk/GME/Gme/MgaOpenDlg.h

Modified: trunk/GME/Gme/GMEApp.cpp
==============================================================================
--- trunk/GME/Gme/GMEApp.cpp	Fri Oct 14 16:32:50 2011	(r1644)
+++ trunk/GME/Gme/GMEApp.cpp	Tue Oct 18 11:40:28 2011	(r1645)
@@ -1884,18 +1884,7 @@
 
 void CGMEApp::OnFileSaveAs() {
 	CMgaOpenDlg dlg(CMgaOpenDlg::SaveAsDialog);
-	CString spec_ext;
-	if( currentConnection.Left(4) == _T("MGA=")) // if MGA format
-	{
-		int rps = currentConnection.ReverseFind('.');
-		if( rps != -1 && rps < currentConnection.GetLength())
-		{
-			spec_ext = currentConnection.Mid( rps + 1);
-			if( spec_ext.CompareNoCase( _T("mga")) == 0)    // oh, just the plain 'mga' extension
-				spec_ext = _T("");                          // we need not have specific behaviour
-		}
-	}
-	CString conn = dlg.AskMGAConnectionString( spec_ext);
+	CString conn = dlg.AskMGAConnectionString();
 
 	CGMEEventLogger::LogGMEEvent(_T("CGMEApp::OnFileSaveAs ")+conn+_T("\r\n"));
 

Modified: trunk/GME/Gme/MgaOpenDlg.cpp
==============================================================================
--- trunk/GME/Gme/MgaOpenDlg.cpp	Fri Oct 14 16:32:50 2011	(r1644)
+++ trunk/GME/Gme/MgaOpenDlg.cpp	Tue Oct 18 11:40:28 2011	(r1645)
@@ -90,24 +90,15 @@
 static TCHAR xmemgafilter[] = _T("GME Model Files (*.mga;*.xme;*.mgx)|*.mga; *.xme; *.mgx|MGA Files (*.mga)|*.mga|Exported Files (*.xme;*.xml)|*.xme; *.xml|")
 	_T("Multi-user files (*.mgx)|*.mgx|All files (*.*)|*.*||");
 
-static TCHAR mgaonlyfilter[] = _T("MGA Files (*.mga)|*.mga||");
+static TCHAR mgaonlyfilter[] = _T("MGA Files (*.mga)|*.mga|All files (*.*)|*.*||");
 
 static TCHAR metafilter[] = _T("MGA Meta Files (*.mta)|*.mta|XML Paradigm Files (*.xmp)|*.xmp|")
 	_T("All files (*.*)|*.*||");
 
 
-CString CMgaOpenDlg::AskMGAConnectionString(const CString& spec_ext)
+CString CMgaOpenDlg::AskMGAConnectionString()
 {
 	CString filters = mgaonlyfilter;
-	if( !spec_ext.IsEmpty())
-	{
-		CString SPEC_EXT = spec_ext; SPEC_EXT.MakeUpper();
-		CString spec_filter;
-		// as "MGA Files (*.mga)|*.mga|"
-		spec_filter.Format( _T("%s Files (*.%s)|*.%s|"), SPEC_EXT, spec_ext, spec_ext);
-		// insert this filter at the beginning (thus preferred)
-		filters.Insert( 0, spec_filter);
-	}
 
 	CString file, dir;
 	if (theApp.isMgaProj() && theApp.mgaProject)
@@ -116,7 +107,7 @@
 	}
 
 	CString conn;
-	CFileDialog dlg(flag_isopen ? TRUE : FALSE, NULL, (file == _T("")) ? NULL : (LPCTSTR)file, 
+	CFileDialog dlg(flag_isopen ? TRUE : FALSE, _T("mga"), (file == _T("")) ? NULL : (LPCTSTR)file, 
 			OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | 
 			0, filters);
 
@@ -125,14 +116,6 @@
 
 	if( dlg.DoModal() == IDOK )	{
 		conn = CString(_T("MGA=")) + dlg.GetPathName();
-		if(dlg.GetFileExt() == _T("")) // no extension specified by the user
-		{
-			conn += _T(".");
-			// if spec_ext is NOT empty then 
-			// filterindex = 1 stands for special extension
-			//             = 2 is the MGA
-			conn += dlg.m_ofn.nFilterIndex == 1 && !spec_ext.IsEmpty() ? spec_ext:_T("mga");
-		}
 	}
 	return conn;
 }

Modified: trunk/GME/Gme/MgaOpenDlg.h
==============================================================================
--- trunk/GME/Gme/MgaOpenDlg.h	Fri Oct 14 16:32:50 2011	(r1644)
+++ trunk/GME/Gme/MgaOpenDlg.h	Tue Oct 18 11:40:28 2011	(r1645)
@@ -32,7 +32,7 @@
 	bool pressed_back;
 
 	CString AskConnectionString(bool allowXme);
-	CString AskMGAConnectionString(const CString& spec_ext = "");
+	CString AskMGAConnectionString();
 private:
 	CString PruneConnectionString(const CString& conn);
 	CString FilterInvalidCharacters(const CString& path, bool isPath = false);


More information about the gme-commit mailing list