From: <sag...@us...> - 2011-08-01 22:47:51
|
Revision: 954 http://modplug.svn.sourceforge.net/modplug/?rev=954&view=rev Author: saga-games Date: 2011-08-01 22:47:44 +0000 (Mon, 01 Aug 2011) Log Message: ----------- [Imp] Macros are now sanitized and cleared after first null char before saving them to a module file. [Imp] When saving a file loaded from a template for the first time, the extension of the proposed filename is not duplicated anymore. [Ref] Some more related save code refactoring. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-08-01 16:21:19 UTC (rev 953) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-08-01 22:47:44 UTC (rev 954) @@ -481,6 +481,9 @@ 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? + CChildFrame *pMDIActive = (CChildFrame *)MDIGetActive(); BeginWaitCursor(); @@ -2177,6 +2180,14 @@ ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CModDoc)) == TRUE); CModDoc* pModDoc = static_cast<CModDoc*>(pDoc); pModDoc->ClearFilePath(); // Clear path so that saving will not take place in templates/examples folder. + // Remove extension from title, so that saving the file will not suggest a filename like f.e. "template.mptm.mptm". + const CString title = pModDoc->GetTitle(); + const int dotPos = title.ReverseFind('.'); + if(dotPos >= 0) + { + pModDoc->SetTitle(title.Left(dotPos)); + } + if (bTemplateFile) { pModDoc->GetFileHistory()->clear(); // Reset edit history for template files @@ -2362,7 +2373,7 @@ { case kcViewTree: OnBarCheck(IDD_TREEVIEW); break; case kcViewOptions: OnViewOptions(); break; - case kcViewMain: OnBarCheck(59392); break; + case kcViewMain: OnBarCheck(59392 /* MAINVIEW */); break; case kcFileImportMidiLib: OnImportMidiLib(); break; case kcFileAddSoundBank: OnAddDlsBank(); break; case kcPauseSong: OnPlayerPause(); break; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-08-01 16:21:19 UTC (rev 953) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-08-01 22:47:44 UTC (rev 954) @@ -436,13 +436,11 @@ //-------------------------------------------------------------------------- { static int greccount = 0; - TCHAR fext[_MAX_EXT] = _T(""); UINT dwPacking = 0; BOOL bOk = FALSE; m_SndFile.m_dwLastSavedWithVersion = MptVersion::num; if (!lpszPathName) return FALSE; - _tsplitpath(lpszPathName, NULL, NULL, NULL, fext); MODTYPE type = m_SndFile.GetType(); // CModSpecifications::ExtensionToType(fext); if (type == MOD_TYPE_NONE && !greccount) @@ -460,17 +458,21 @@ case MOD_TYPE_MOD: bOk = m_SndFile.SaveMod(lpszPathName, dwPacking); break; case MOD_TYPE_S3M: bOk = m_SndFile.SaveS3M(lpszPathName, dwPacking); break; case MOD_TYPE_XM: bOk = m_SndFile.SaveXM(lpszPathName, dwPacking); break; - case MOD_TYPE_IT: bOk = (m_SndFile.m_dwSongFlags & SONG_ITPROJECT || !lstrcmpi(fext, _T(".itp"))) ? m_SndFile.SaveITProject(lpszPathName) : m_SndFile.SaveIT(lpszPathName, dwPacking); break; + case MOD_TYPE_IT: bOk = (m_SndFile.m_dwSongFlags & SONG_ITPROJECT) ? m_SndFile.SaveITProject(lpszPathName) : m_SndFile.SaveIT(lpszPathName, dwPacking); break; case MOD_TYPE_MPT: bOk = m_SndFile.SaveIT(lpszPathName, dwPacking); break; } EndWaitCursor(); if (bOk) { - if (type == m_SndFile.GetType() && !bTemplateFile) + if (!bTemplateFile) + { + // Set new path for this file, unless we are saving a template, in which case we want to keep the old file path. SetPathName(lpszPathName); + } ShowLog(); if (bTemplateFile) { + // Update template menu. CMainFrame* const pMainFrame = CMainFrame::GetMainFrame(); if (pMainFrame) pMainFrame->CreateTemplateModulesMenu(); @@ -491,7 +493,8 @@ BOOL CModDoc::SaveModified() //-------------------------- { - if((m_SndFile.m_nType & MOD_TYPE_IT) && m_SndFile.m_dwSongFlags & SONG_ITPROJECT && !(m_SndFile.m_dwSongFlags & SONG_ITPEMBEDIH)){ + if((m_SndFile.m_nType & MOD_TYPE_IT) && m_SndFile.m_dwSongFlags & SONG_ITPROJECT && !(m_SndFile.m_dwSongFlags & SONG_ITPEMBEDIH)) + { bool unsavedInstrument = false; @@ -506,8 +509,10 @@ if(unsavedInstrument && ::MessageBox(NULL,"Do you want to save modified instruments?",NULL,MB_ICONQUESTION | MB_YESNO | MB_APPLMODAL) == IDYES){ - for(INSTRUMENTINDEX i = 0 ; i < m_SndFile.m_nInstruments ; i++){ - if(m_SndFile.m_szInstrumentPath[i][0] != '\0'){ + for(INSTRUMENTINDEX i = 0 ; i < m_SndFile.m_nInstruments ; i++) + { + if(m_SndFile.m_szInstrumentPath[i][0] != '\0') + { int size = strlen(m_SndFile.m_szInstrumentPath[i]); bool iti = _stricmp(&m_SndFile.m_szInstrumentPath[i][size-3],"iti") == 0; bool xi = _stricmp(&m_SndFile.m_szInstrumentPath[i][size-2],"xi") == 0; @@ -596,7 +601,7 @@ if ((!lpszPathName) || (!lpszPathName[0]) || m_ShowSavedialog) { _splitpath(m_strPathName, drive, path, fname, NULL); - if (!fname[0]) strcpy(fname, m_strTitle); + if (!fname[0]) strcpy(fname, GetTitle()); strcpy(s, drive); strcat(s, path); strcat(s, fname); @@ -1787,15 +1792,10 @@ if ((!pMainFrm) || (!m_SndFile.GetType())) return; switch (type) { - /*case MOD_TYPE_XM: - ext = "xm"; - pattern = "Fast Tracker Files (*.xm)|*.xm||"; - break;*/ case MOD_TYPE_MOD: - ext = ModSpecs::mod.fileExtension; pattern = FileFilterMOD; if( AfxMessageBox(GetStrI18N(TEXT( - "Compared to regular MOD save, compatibility export adjust the beginning of oneshot samples " + "Compared to regular MOD save, compatibility export adjusts the beginning of oneshot samples " "in order to make the file compatible with ProTracker and other Amiga-based trackers. " "Note that this feature does not remove effects \"invented\" by other PC-based trackers (f.e. panning commands)." "\n\n Proceed?")), MB_ICONINFORMATION|MB_YESNO) != IDYES @@ -1803,12 +1803,10 @@ return; break; case MOD_TYPE_IT: - ext = ModSpecs::it.fileExtension; pattern = FileFilterIT; ::MessageBox(NULL,"Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning.",MB_ICONINFORMATION | MB_OK); break; case MOD_TYPE_XM: - ext = ModSpecs::xm.fileExtension; pattern = FileFilterXM; ::MessageBox(NULL,"Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning.",MB_ICONINFORMATION | MB_OK); break; @@ -1816,6 +1814,7 @@ ::MessageBox(NULL,"Compatibility export is currently only available for MOD, XM and IT modules.", "Can't do compatibility export.",MB_ICONINFORMATION | MB_OK); return; } + ext = m_SndFile.GetModSpecifications().fileExtension; _splitpath(GetPathName(), drive, path, fname, NULL); filename = drive; @@ -3951,11 +3950,14 @@ FixNullString(m_SndFile.ChnSettings[nChn].szName); } + // Macros + m_SndFile.SanitizeMacros(); + // Pattern names - // Halp, this is currently not possible. Is it even needed? + // Those are CStrings and don't need to be fixed. // Sequence names. - // Not needed? + // Those are CStrings and don't need to be fixed. } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-08-01 16:21:19 UTC (rev 953) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-08-01 22:47:44 UTC (rev 954) @@ -940,15 +940,15 @@ { for(size_t i = 0; i < CountOf(m_MidiCfg.szMidiGlb); i++) { - SetNullTerminator(m_MidiCfg.szMidiGlb[i]); + FixNullString(m_MidiCfg.szMidiGlb[i]); } for(size_t i = 0; i < CountOf(m_MidiCfg.szMidiSFXExt); i++) { - SetNullTerminator(m_MidiCfg.szMidiSFXExt[i]); + FixNullString(m_MidiCfg.szMidiSFXExt[i]); } for(size_t i = 0; i < CountOf(m_MidiCfg.szMidiZXXExt); i++) { - SetNullTerminator(m_MidiCfg.szMidiZXXExt[i]); + FixNullString(m_MidiCfg.szMidiZXXExt[i]); } } @@ -2662,9 +2662,9 @@ MemsetZero(m_defaultInstrument); m_defaultInstrument.nResampling = SRCMODE_DEFAULT; m_defaultInstrument.nFilterMode = FLTMODE_UNCHANGED; - m_defaultInstrument.nPPC = 5*12; - m_defaultInstrument.nGlobalVol=64; - m_defaultInstrument.nPan = 0x20 << 2; + m_defaultInstrument.nPPC = 5 * 12; + m_defaultInstrument.nGlobalVol = 64; + m_defaultInstrument.nPan = 32 * 4; //m_defaultInstrument.nIFC = 0xFF; m_defaultInstrument.PanEnv.nReleaseNode=ENV_RELEASE_NODE_UNSET; m_defaultInstrument.PitchEnv.nReleaseNode=ENV_RELEASE_NODE_UNSET; @@ -2942,4 +2942,3 @@ FixMIDIConfigString(midiCfg.szMidiZXXExt[i]); } } - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |