From: <sv...@op...> - 2024-12-28 15:52:33
|
Author: sagamusix Date: Sat Dec 28 16:52:26 2024 New Revision: 22631 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22631 Log: [Ref] Add CTrackApp::GetUserTemplatesPath and CTrackApp::GetExampleSongsPath. Modified: trunk/OpenMPT/mptrack/GeneralConfigDlg.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/GeneralConfigDlg.cpp ============================================================================== --- trunk/OpenMPT/mptrack/GeneralConfigDlg.cpp Sat Dec 28 16:40:46 2024 (r22630) +++ trunk/OpenMPT/mptrack/GeneralConfigDlg.cpp Sat Dec 28 16:52:26 2024 (r22631) @@ -123,7 +123,7 @@ } } - const mpt::PathString basePath = theApp.GetConfigPath() + P_("TemplateModules\\"); + const mpt::PathString basePath = theApp.GetUserTemplatesPath(); FolderScanner scanner(basePath, FolderScanner::kOnlyFiles | FolderScanner::kFindInSubDirectories); mpt::PathString file; while(scanner.Next(file)) @@ -207,7 +207,7 @@ void COptionsGeneral::OnBrowseTemplate() { - mpt::PathString basePath = theApp.GetConfigPath() + P_("TemplateModules\\"); + mpt::PathString basePath = theApp.GetUserTemplatesPath(); mpt::PathString defaultFile = mpt::PathString::FromCString(GetWindowTextString(m_defaultTemplate)); if(defaultFile.empty()) defaultFile = TrackerSettings::Instance().defaultTemplateFile; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp ============================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp Sat Dec 28 16:40:46 2024 (r22630) +++ trunk/OpenMPT/mptrack/MainFrm.cpp Sat Dec 28 16:52:26 2024 (r22631) @@ -2383,7 +2383,7 @@ { MPT_ASSERT(nId == UINT(isTemplateFile ? ID_FILE_OPENTEMPLATE_LASTINRANGE : ID_EXAMPLE_MODULES_LASTINRANGE)); FileDialog::PathList files; - theApp.OpenModulesDialog(files, isTemplateFile ? theApp.GetConfigPath() + P_("TemplateModules") : theApp.GetInstallPath() + P_("ExampleSongs")); + theApp.OpenModulesDialog(files, isTemplateFile ? theApp.GetUserTemplatesPath() : theApp.GetExampleSongsPath()); for(const auto &file : files) { theApp.OpenDocumentFile(file.ToCString()); Modified: trunk/OpenMPT/mptrack/Moddoc.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp Sat Dec 28 16:40:46 2024 (r22630) +++ trunk/OpenMPT/mptrack/Moddoc.cpp Sat Dec 28 16:52:26 2024 (r22631) @@ -3112,7 +3112,7 @@ void CModDoc::OnSaveTemplateModule() { // Create template folder if doesn't exist already. - const mpt::PathString templateFolder = TrackerSettings::Instance().PathUserTemplates.GetDefaultDir(); + const mpt::PathString templateFolder = theApp.GetUserTemplatesPath(); if (!mpt::native_fs{}.is_directory(templateFolder)) { if (!CreateDirectory(templateFolder.AsNative().c_str(), nullptr)) Modified: trunk/OpenMPT/mptrack/Mptrack.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp Sat Dec 28 16:40:46 2024 (r22630) +++ trunk/OpenMPT/mptrack/Mptrack.cpp Sat Dec 28 16:52:26 2024 (r22631) @@ -1018,7 +1018,7 @@ void CTrackApp::CreatePaths() { - // Create missing diretories + // Create missing directories if(!IsPortableMode()) { if(!mpt::native_fs{}.is_directory(m_ConfigPath)) @@ -1048,7 +1048,18 @@ RemoveDirectory(oldTunings.AsNative().c_str()); } } +} + +mpt::PathString CTrackApp::GetUserTemplatesPath() const +{ + return GetConfigPath() + P_("TemplateModules\\"); +} + + +mpt::PathString CTrackApp::GetExampleSongsPath() const +{ + return GetInstallPath() + P_("ExampleSongs\\"); } @@ -1669,7 +1680,7 @@ if(TrackerSettings::Instance().defaultNewFileAction == nfDefaultTemplate && !templateFile.empty()) { // Template file can be either a filename inside one of the preset and user TemplateModules folders, or a full path. - const mpt::PathString dirs[] = { GetConfigPath() + P_("TemplateModules\\"), GetInstallPath() + P_("TemplateModules\\"), mpt::PathString() }; + const mpt::PathString dirs[] = { GetUserTemplatesPath(), GetInstallPath() + P_("TemplateModules\\"), mpt::PathString() }; for(const auto &dir : dirs) { if(mpt::native_fs{}.is_file(dir + templateFile)) Modified: trunk/OpenMPT/mptrack/Mptrack.h ============================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h Sat Dec 28 16:40:46 2024 (r22630) +++ trunk/OpenMPT/mptrack/Mptrack.h Sat Dec 28 16:52:26 2024 (r22631) @@ -294,6 +294,8 @@ /// Returns path to config folder including trailing '\'. mpt::PathString GetConfigPath() const { return m_ConfigPath; } + mpt::PathString GetUserTemplatesPath() const; + mpt::PathString GetExampleSongsPath() const; void SetupPaths(bool overridePortable); void CreatePaths(); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp ============================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp Sat Dec 28 16:40:46 2024 (r22630) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp Sat Dec 28 16:52:26 2024 (r22631) @@ -329,7 +329,6 @@ , PathPluginPresets(conf, UL_("Paths"), UL_("Plugin_Presets_Directory"), mpt::PathString()) , PathExport(conf, UL_("Paths"), UL_("Export_Directory"), mpt::PathString()) , PathTunings(theApp.GetConfigPath() + P_("tunings\\")) - , PathUserTemplates(theApp.GetConfigPath() + P_("TemplateModules\\")) // Default template , defaultTemplateFile(conf, UL_("Paths"), UL_("DefaultTemplate"), mpt::PathString()) , defaultArtist(conf, UL_("Misc"), UL_("DefaultArtist"), mpt::getenv(UL_("USERNAME")).value_or(UL_(""))) Modified: trunk/OpenMPT/mptrack/TrackerSettings.h ============================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h Sat Dec 28 16:40:46 2024 (r22630) +++ trunk/OpenMPT/mptrack/TrackerSettings.h Sat Dec 28 16:52:26 2024 (r22631) @@ -909,7 +909,6 @@ ConfigurableDirectory PathPluginPresets; ConfigurableDirectory PathExport; DefaultAndWorkingDirectory PathTunings; - DefaultAndWorkingDirectory PathUserTemplates; mpt::PathString m_szKbdFile; // Default template |