From: <sag...@us...> - 2014-01-19 22:03:03
|
Revision: 3583 http://sourceforge.net/p/modplug/code/3583 Author: saga-games Date: 2014-01-19 22:02:56 +0000 (Sun, 19 Jan 2014) Log Message: ----------- [New] Added hidden setting for loading a default template (DefaultTemplate in [Paths] section, can be either a full path or just a filename that can be found in the template folder). [Mod] OpenMPT: Version is now 1.22.07.15 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-01-17 21:33:18 UTC (rev 3582) +++ trunk/OpenMPT/common/versionNumber.h 2014-01-19 22:02:56 UTC (rev 3583) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 07 -#define VER_MINORMINOR 14 +#define VER_MINORMINOR 15 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-01-17 21:33:18 UTC (rev 3582) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-01-19 22:02:56 UTC (rev 3583) @@ -2137,29 +2137,8 @@ const bool bAvailable = Util::sdOs::IsPathFileAvailable(sPath, Util::sdOs::FileModeRead); if (bAvailable) { - CDocument* pDoc = theApp.OpenDocumentFile(sPath, bTemplateFile ? FALSE : TRUE); - if (pDoc != nullptr) - { - 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 e.g. "template.mptm.mptm". - const CString title = pModDoc->GetTitle(); - const int dotPos = title.ReverseFind('.'); - if(dotPos >= 0) - { - pModDoc->SetTitle(title.Left(dotPos)); - } - - if (bTemplateFile) - { - pModDoc->GetSoundFile()->GetFileHistory().clear(); // Reset edit history for template files - pModDoc->GetSoundFile()->m_dwCreatedWithVersion = MptVersion::num; - pModDoc->GetSoundFile()->m_dwLastSavedWithVersion = 0; - } - } - } - else + theApp.GetModDocTemplate()->OpenTemplateFile(sPath, !bTemplateFile); + } else { const bool bExists = Util::sdOs::IsPathFileAvailable(sPath, Util::sdOs::FileModeExists); Reporting::Notification(L"The file '" + sPath.ToWide() + L"' " + (bExists ? L"exists but can't be read" : L"does not exist")); @@ -2460,7 +2439,6 @@ } //end rewbs.VSTTimeInfo -//rewbs.customKeys // We have swicthed focus to a new module - might need to update effect keys to reflect module type bool CMainFrame::UpdateEffectKeys() //--------------------------------- @@ -2473,10 +2451,8 @@ return false; } -//end rewbs.customKeys -//rewbs.fix3116 void CMainFrame::OnKillFocus(CWnd* pNewWnd) //----------------------------------------- { @@ -2484,10 +2460,9 @@ //rewbs: ensure modifiers are reset when we leave the window (e.g. alt-tab) CMainFrame::GetMainFrame()->GetInputHandler()->SetModifierMask(0); - //end rewbs } -//end rewbs.fix3116 + void CMainFrame::OnShowWindow(BOOL bShow, UINT /*nStatus*/) //--------------------------------------------------------- { @@ -2542,7 +2517,7 @@ void CMainFrame::OnHelp() //----------------------- { - mpt::PathString helpFile = theApp.GetAppDirPath() + MPT_PATHSTRING("OpenMPT Manual.pdf"); + const mpt::PathString helpFile = theApp.GetAppDirPath() + MPT_PATHSTRING("OpenMPT Manual.pdf"); if(!theApp.OpenFile(helpFile)) { Reporting::Error(L"Could not find help file:\n" + helpFile.ToWide()); @@ -2687,7 +2662,7 @@ for(size_t i = 0; i < TrackerSettings::Instance().mruFiles.size(); i++) { - std::wstring s = StringifyW(i + 1) + L" "; + std::wstring s = mpt::ToWString(i + 1) + L" "; // Add mnemonics if(i < 9) { Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2014-01-17 21:33:18 UTC (rev 3582) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2014-01-19 22:02:56 UTC (rev 3583) @@ -111,6 +111,41 @@ } +CDocument* CModDocTemplate::OpenTemplateFile(const mpt::PathString &filename, bool isExampleTune) +//----------------------------------------------------------------------------------------------- +{ + CDocument *doc = OpenDocumentFile(filename, isExampleTune ? TRUE : FALSE, TRUE); + if(doc) + { + CModDoc *modDoc = static_cast<CModDoc *>(doc); + // Clear path so that saving will not take place in templates/examples folder. + modDoc->ClearFilePath(); + if(!isExampleTune) + { + CMultiDocTemplate::SetDefaultTitle(modDoc); + m_nUntitledCount++; + // Name has changed... + CMainFrame::GetMainFrame()->UpdateTree(modDoc, HINT_MODGENERAL); + + // Reset edit history for template files + modDoc->GetrSoundFile().GetFileHistory().clear(); + modDoc->GetrSoundFile().m_dwCreatedWithVersion = MptVersion::num; + modDoc->GetrSoundFile().m_dwLastSavedWithVersion = 0; + } else + { + // Remove extension from title, so that saving the file will not suggest a filename like e.g. "example.it.it". + const CString title = modDoc->GetTitle(); + const int dotPos = title.ReverseFind('.'); + if(dotPos >= 0) + { + modDoc->SetTitle(title.Left(dotPos)); + } + } + } + return doc; +} + + #ifdef _DEBUG #define DDEDEBUG #endif @@ -986,6 +1021,24 @@ { if (!m_bInitialized) return; + // Build from template + const mpt::PathString templateFile = TrackerSettings::Instance().defaultTemplateFile; + if(!templateFile.empty()) + { + const mpt::PathString dirs[] = { GetConfigPath(), GetAppDirPath(), mpt::PathString() }; + for(size_t i = 0; i < CountOf(dirs); i++) + { + if(Util::sdOs::IsPathFileAvailable(dirs[i] + templateFile, Util::sdOs::FileModeExists)) + { + if(m_pModTemplate->OpenTemplateFile(dirs[i] + templateFile) != nullptr) + { + return; + } + } + } + } + + // Default module type MODTYPE nNewType = TrackerSettings::Instance().defaultModType; bool bIsProject = false; Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2014-01-17 21:33:18 UTC (rev 3582) +++ trunk/OpenMPT/mptrack/Mptrack.h 2014-01-19 22:02:56 UTC (rev 3583) @@ -118,6 +118,7 @@ CMultiDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass) {} CDocument* OpenDocumentFile(const mpt::PathString &filename, BOOL addToMru = TRUE, BOOL makeVisible = TRUE); + CDocument* OpenTemplateFile(const mpt::PathString &filename, bool isExampleTune = false); // inherited members, overload them all #if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0) Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-01-17 21:33:18 UTC (rev 3582) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-01-19 22:02:56 UTC (rev 3583) @@ -197,6 +197,8 @@ , m_MayNormalizeSamplesOnLoad(conf, "Sample Editor", "MayNormalizeSamplesOnLoad", true) // Export , ExportDefaultToSoundcardSamplerate(conf, "Export", "DefaultToSoundcardSamplerate", true) + // Default template + , defaultTemplateFile(conf, "Paths", "DefaultTemplate", mpt::PathString()) // MRU List , mruListLength(conf, "Misc", "MRUListLength", 10) { Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2014-01-17 21:33:18 UTC (rev 3582) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2014-01-19 22:02:56 UTC (rev 3583) @@ -362,6 +362,8 @@ // Paths mpt::PathString m_szKbdFile; + // Default template + Setting<mpt::PathString> defaultTemplateFile; Setting<uint32> mruListLength; std::vector<mpt::PathString> mruFiles; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |