From: <sag...@us...> - 2011-08-04 19:56:32
|
Revision: 958 http://modplug.svn.sourceforge.net/modplug/?rev=958&view=rev Author: saga-games Date: 2011-08-04 19:56:25 +0000 (Thu, 04 Aug 2011) Log Message: ----------- [New] Instead of multiple modal message boxes, a single dialog with a list of unsaved files is now shown when closing the main window. The old behaviour can be restored by setting "NoModifiedDocumentsDialog=1" in [Misc] in mptrack.ini. [Mod] OpenMPT: Version is now 1.20.00.03 Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/mptrack.vcproj trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/mptrack/version.h Added Paths: ----------- trunk/OpenMPT/mptrack/CloseMainDialog.cpp trunk/OpenMPT/mptrack/CloseMainDialog.h Added: trunk/OpenMPT/mptrack/CloseMainDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/CloseMainDialog.cpp (rev 0) +++ trunk/OpenMPT/mptrack/CloseMainDialog.cpp 2011-08-04 19:56:25 UTC (rev 958) @@ -0,0 +1,168 @@ +/* + * + * CloseMainDialog.cpp + * ------------------- + * Purpose: Code for displaying a dialog with a list of unsaved documents, and the ability to choose which documents should be saved or not. + * Notes : (currently none) + * Authors: OpenMPT Devs + */ + + +#include "stdafx.h" +#include "Mptrack.h" +#include "Mainfrm.h" +#include "Moddoc.h" +#include "CloseMainDialog.h" + + +BEGIN_MESSAGE_MAP(CloseMainDialog, CDialog) + ON_LBN_SELCHANGE(IDC_LIST1, OnSelectionChanged) + ON_COMMAND(IDC_BUTTON1, OnSwitchSelection) + ON_COMMAND(IDC_CHECK1, OnSwitchFullPaths) +END_MESSAGE_MAP() + + +void CloseMainDialog::DoDataExchange(CDataExchange* pDX) +//------------------------------------------------------ +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(DoDataExchange) + DDX_Control(pDX, IDC_LIST1, m_List); + //}}AFX_DATA_MAP +} + + +// Format a list entry string +CString CloseMainDialog::FormatTitle(const CModDoc *pModDoc, bool fullPath) +//------------------------------------------------------------------------- +{ + const CString &path = (!fullPath || pModDoc->GetPathName().IsEmpty()) ? pModDoc->GetTitle() : pModDoc->GetPathName(); + return pModDoc->GetSoundFile()->GetTitle() + CString(" (") + path + CString(")"); +} + + +BOOL CloseMainDialog::OnInitDialog() +//---------------------------------- +{ + CDialog::OnInitDialog(); + + CMainFrame::GetInputHandler()->Bypass(true); + + // Create list of unsaved documents + m_List.ResetContent(); + + CheckDlgButton(IDC_CHECK1, BST_CHECKED); + + CDocTemplate *pDocTmpl = theApp.GetModDocTemplate(); + if(pDocTmpl) + { + POSITION pos = pDocTmpl->GetFirstDocPosition(); + CDocument *pDoc; + while((pos != NULL) && ((pDoc = pDocTmpl->GetNextDoc(pos)) != NULL)) + { + CModDoc *pModDoc = (CModDoc *)pDoc; + if(pModDoc->IsModified()) + { + int item = m_List.AddString(FormatTitle(pModDoc, true)); + m_List.SetItemDataPtr(item, pModDoc); + m_List.SetSel(item, TRUE); + } + } + } + + if(m_List.GetCount() == 0) + { + // No modified documents... + OnOK(); + } else + { + UpdateSwitchButtonState(); + } + + return TRUE; +} + + +void CloseMainDialog::OnOK() +//-------------------------- +{ + const int count = m_List.GetCount(); + for(int i = 0; i < count; i++) + { + CModDoc *pModDoc = (CModDoc *)m_List.GetItemDataPtr(i); + ASSERT(pModDoc != nullptr); + if(m_List.GetSel(i)) + { + pModDoc->ActivateWindow(); + if(pModDoc->DoFileSave() == FALSE) + { + // If something went wrong, or if the user decided to cancel saving (when using "Save As"), we'll better not proceed... + OnCancel(); + return; + } + } else + { + pModDoc->SetModified(FALSE); + } + } + + CDialog::OnOK(); + CMainFrame::GetInputHandler()->Bypass(false); + +} + + +void CloseMainDialog::OnCancel() +//------------------------------ +{ + CDialog::OnCancel(); + CMainFrame::GetInputHandler()->Bypass(false); +} + + +void CloseMainDialog::OnSelectionChanged() +//---------------------------------------- +{ + UpdateSwitchButtonState(); +} + + +// Switch between save all/none +void CloseMainDialog::OnSwitchSelection() +//--------------------------------------- +{ + const int count = m_List.GetCount(); + // If all items are selected, deselect them all; Else, select all items. + const BOOL action = (m_List.GetSelCount() == count) ? FALSE : TRUE; + for(int i = 0; i < count; i++) + { + m_List.SetSel(i, action); + } + UpdateSwitchButtonState(); +} + + +// Update Select none/all button +void CloseMainDialog::UpdateSwitchButtonState() +//--------------------------------------------- +{ + const CString text = (m_List.GetSelCount() == m_List.GetCount()) ? "&Select none" : "&Select all"; + ((CButton *)GetDlgItem(IDC_BUTTON1))->SetWindowText(text); +} + + +// Switch between full path / filename only display +void CloseMainDialog::OnSwitchFullPaths() +//--------------------------------------- +{ + const int count = m_List.GetCount(); + const bool fullPath = (IsDlgButtonChecked(IDC_CHECK1) == BST_CHECKED); + for(int i = 0; i < count; i++) + { + CModDoc *pModDoc = (CModDoc *)m_List.GetItemDataPtr(i); + int item = m_List.InsertString(i + 1, FormatTitle(pModDoc, fullPath)); + m_List.SetItemDataPtr(item, pModDoc); + m_List.SetSel(item, m_List.GetSel(i)); + m_List.DeleteString(i); + } +} Added: trunk/OpenMPT/mptrack/CloseMainDialog.h =================================================================== --- trunk/OpenMPT/mptrack/CloseMainDialog.h (rev 0) +++ trunk/OpenMPT/mptrack/CloseMainDialog.h 2011-08-04 19:56:25 UTC (rev 958) @@ -0,0 +1,42 @@ +/* + * CloseMainDialog.h + * ----------------- + * Purpose: Header file for unsaved documents dialog. + * Notes : (currently none) + * Authors: OpenMPT Devs + */ + +#ifndef CLOSEMAINDIALOG_H +#define CLOSEMAINDIALOG_H +#pragma once + +//=================================== +class CloseMainDialog: public CDialog +//=================================== +{ +protected: + + CListBox m_List; + + CString FormatTitle(const CModDoc *pModDoc, bool fullPath); + void UpdateSwitchButtonState(); + +public: + CloseMainDialog() : CDialog(IDD_CLOSEDOCUMENTS) { }; + + +protected: + virtual void DoDataExchange(CDataExchange* pDX); + virtual BOOL OnInitDialog(); + virtual void OnOK(); + virtual void OnCancel(); + + afx_msg void OnSelectionChanged(); + afx_msg void OnSwitchSelection(); + afx_msg void OnSwitchFullPaths(); + + DECLARE_MESSAGE_MAP() + +}; + +#endif // CLOSEMAINDIALOG_H \ No newline at end of file Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-08-04 19:39:53 UTC (rev 957) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-08-04 19:56:25 UTC (rev 958) @@ -25,6 +25,7 @@ #include "version.h" #include "ctrl_pat.h" #include "UpdateCheck.h" +#include "CloseMainDialog.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -481,8 +482,15 @@ void CMainFrame::OnClose() //------------------------ { - // TODO: Here we could add a custom dialog that lists all modified files, and the user could select which should be saved. - // How do we get all files? Does the document manager help here? + if(GetPrivateProfileLong("Misc", "NoModifiedDocumentsDialog", 0, theApp.GetConfigFileName()) == 0) + { + // Show modified documents window + CloseMainDialog dlg; + if(dlg.DoModal() != IDOK) + { + return; + } + } CChildFrame *pMDIActive = (CChildFrame *)MDIGetActive(); Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2011-08-04 19:39:53 UTC (rev 957) +++ trunk/OpenMPT/mptrack/mptrack.rc 2011-08-04 19:56:25 UTC (rev 958) @@ -209,6 +209,19 @@ END +IDD_CLOSEDOCUMENTS DIALOGEX 0, 0, 370, 233 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Save modified files" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "&OK",IDOK,300,174,66,14 + PUSHBUTTON "&Cancel",IDCANCEL,300,193,66,14 + LISTBOX IDC_LIST1,6,6,288,204,LBS_SORT | LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + CONTROL "Show &full paths",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,216,252,12 + PUSHBUTTON "&Select none",IDC_BUTTON1,300,12,66,14 +END + + ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO @@ -296,6 +309,14 @@ TOPMARGIN, 7 BOTTOMMARGIN, 274 END + + IDD_CLOSEDOCUMENTS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 363 + TOPMARGIN, 7 + BOTTOMMARGIN, 226 + END END #endif // APSTUDIO_INVOKED @@ -2152,17 +2173,33 @@ STRINGTABLE BEGIN + IDS_TUNING_IMPORT_LIMIT "-Failed to load file %1%2: maximum number(=%3!u!) of temporary tunings is already open.\n" + IDS_TUNING_IMPORT_UNKNOWN_FAILURE + "-Unable to import file ""%1%2"": unknown reason.\n" + IDS_TUNING_IMPORT_UNRECOGNIZED_FILE_EXT + "-Unable to load ""%1%2"": unrecognized file extension.\n" + IDS_TUNING_IMPORT_UNKNOWN_TC_FAILURE + "-Unable to import tuning collection ""%1%2"": unrecognized file.\n" + IDS_TUNING_IMPORT_SCL_FAILURE "-Unable to import ""%1%2"": %3.\n" + IDS_TUNING_IMPORT_UNRECOGNIZED_FILE + "-Unable to import file ""%1%2"": unrecognized file.\n" + IDS_SOUNDTOUCH_LOADFAILURE "Unable to load OpenMPT_soundtouch_i16.dll." + IDS_UNABLE_TO_CREATE_USER_TEMPLATE_FOLDER + """Error: Unable to create template folder '%1'""" + IDS_FILE_DOES_NOT_EXIST "The file '%1' does not exist" + IDS_FILE_EXISTS_BUT_IS_NOT_READABLE + "The file '%1' exists but can't be read" IDS_ERR_FILEOPEN "Unable to open file." IDS_ERR_FILETYPE "Unsupported file type" IDS_ERR_SAVEINS "Unable to save instrument" IDS_ERR_OUTOFMEMORY "Not enough memory" IDS_ERR_TOOMANYINS "Too many instruments!" IDS_ERR_SAVESONG "Unable to save song!" - IDS_ERR_TOOMANYPAT "Too many patterns!" END STRINGTABLE BEGIN + IDS_ERR_TOOMANYPAT "Too many patterns!" IDS_ERR_TOOMANYSMP "Too many samples!" IDS_ERR_SAVESMP "Unable to save sample" END @@ -2175,10 +2212,19 @@ ID_INDICATOR_SCRL "SCRL" ID_INDICATOR_OVR "OVR" ID_INDICATOR_REC "REC" +END + +STRINGTABLE +BEGIN ID_INDICATOR_TIME "00:00:00 [100] 200ch" +END + +STRINGTABLE +BEGIN ID_INDICATOR_USER "Row 000, Col 000" ID_INDICATOR_INFO "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ID_INDICATOR_XINFO "123456789|123456789|123456789|123456789|" + ID_VIEW_MIDIMAPPING "Configure the MIDI Mapping" END STRINGTABLE @@ -2474,28 +2520,12 @@ STRINGTABLE BEGIN - IDS_TUNING_IMPORT_LIMIT "-Failed to load file %1%2: maximum number(=%3!u!) of temporary tunings is already open.\n" - IDS_TUNING_IMPORT_UNKNOWN_FAILURE - "-Unable to import file ""%1%2"": unknown reason.\n" - IDS_TUNING_IMPORT_UNRECOGNIZED_FILE_EXT - "-Unable to load ""%1%2"": unrecognized file extension.\n" - IDS_TUNING_IMPORT_UNKNOWN_TC_FAILURE - "-Unable to import tuning collection ""%1%2"": unrecognized file.\n" - IDS_TUNING_IMPORT_SCL_FAILURE "-Unable to import ""%1%2"": %3.\n" - IDS_TUNING_IMPORT_UNRECOGNIZED_FILE - "-Unable to import file ""%1%2"": unrecognized file.\n" - IDS_SOUNDTOUCH_LOADFAILURE "Unable to load OpenMPT_soundtouch_i16.dll." - IDS_UNABLE_TO_CREATE_USER_TEMPLATE_FOLDER - """Error: Unable to create template folder '%1'""" - IDS_FILE_DOES_NOT_EXIST "The file '%1' does not exist" - IDS_FILE_EXISTS_BUT_IS_NOT_READABLE - "The file '%1' exists but can't be read" + ID_PANIC "Kill all VSTi and sample voices\nStop all hanging VSTi and sample voices" + ID_VIEW_EDITHISTORY "View the edit history of this module" END STRINGTABLE BEGIN - ID_PANIC "Kill all VSTi and sample voices\nStop all hanging VSTi and sample voices" - ID_VIEW_EDITHISTORY "View the edit history of this module" ID_FILE_SAVEASTEMPLATE "Save the active document as template module\nSave as Template" END @@ -2506,11 +2536,6 @@ STRINGTABLE BEGIN - ID_VIEW_MIDIMAPPING "Configure the MIDI Mapping" -END - -STRINGTABLE -BEGIN ID_CHANNEL_MANAGER "Add, remove, mute and manage channels" ID_PLUGIN_SETUP "Register plugins and add them to the current module" END Modified: trunk/OpenMPT/mptrack/mptrack.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack.vcproj 2011-08-04 19:39:53 UTC (rev 957) +++ trunk/OpenMPT/mptrack/mptrack.vcproj 2011-08-04 19:56:25 UTC (rev 958) @@ -193,6 +193,9 @@ RelativePath=".\CleanupSong.cpp"> </File> <File + RelativePath=".\CloseMainDialog.cpp"> + </File> + <File RelativePath=".\ColourEdit.cpp"> </File> <File @@ -669,6 +672,9 @@ RelativePath=".\CleanupSong.h"> </File> <File + RelativePath=".\CloseMainDialog.h"> + </File> + <File RelativePath=".\ColourEdit.h"> </File> <File Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2011-08-04 19:39:53 UTC (rev 957) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2011-08-04 19:56:25 UTC (rev 958) @@ -261,6 +261,10 @@ > </File> <File + RelativePath=".\CloseMainDialog.cpp" + > + </File> + <File RelativePath=".\ColourEdit.cpp" > </File> @@ -887,6 +891,10 @@ > </File> <File + RelativePath=".\CloseMainDialog.h" + > + </File> + <File RelativePath=".\ColourEdit.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2011-08-04 19:39:53 UTC (rev 957) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2011-08-04 19:56:25 UTC (rev 958) @@ -171,6 +171,7 @@ <ClCompile Include="ChannelManagerDlg.cpp" /> <ClCompile Include="ChildFrm.cpp" /> <ClCompile Include="CleanupSong.cpp" /> + <ClCompile Include="CloseMainDialog.cpp" /> <ClCompile Include="ColourEdit.cpp" /> <ClCompile Include="CommandSet.cpp" /> <ClCompile Include="CreditStatic.cpp" /> @@ -334,6 +335,7 @@ <ClInclude Include="ChannelManagerDlg.h" /> <ClInclude Include="ChildFrm.h" /> <ClInclude Include="CleanupSong.h" /> + <ClInclude Include="CloseMainDialog.h" /> <ClInclude Include="ColourEdit.h" /> <ClInclude Include="CommandSet.h" /> <ClInclude Include="CreditStatic.h" /> Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2011-08-04 19:39:53 UTC (rev 957) +++ trunk/OpenMPT/mptrack/resource.h 2011-08-04 19:56:25 UTC (rev 958) @@ -151,6 +151,7 @@ #define IDD_SAMPLE_GRID_SIZE 527 #define IDD_SAMPLE_XFADE 528 #define IDD_OPTIONS_UPDATE 529 +#define IDD_CLOSEDOCUMENTS 530 #define IDC_BUTTON1 1001 #define IDC_BUTTON2 1002 #define IDC_BUTTON3 1003 @@ -1198,7 +1199,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 530 +#define _APS_NEXT_RESOURCE_VALUE 531 #define _APS_NEXT_COMMAND_VALUE 40461 #define _APS_NEXT_CONTROL_VALUE 2436 #define _APS_NEXT_SYMED_VALUE 901 Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-08-04 19:39:53 UTC (rev 957) +++ trunk/OpenMPT/mptrack/version.h 2011-08-04 19:56:25 UTC (rev 958) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 02 +#define VER_MINORMINOR 03 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |