diff --git a/README.md b/README.md index db89453..71f9244 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,9 @@ Please report issues in our [issue tracker](https://github.com/issues). ## Changelog +- Added: Configuration option `Disk.Hide.Extensions` to hide files with certain + extensions in the file browser. Default values are `.sid` and `.prg`. + ### Build 20211230 - Added: You can now add labels for song list rows. Left-click to edit a label. diff --git a/SIDFactoryII/config.ini b/SIDFactoryII/config.ini index 4102224..86bc65a 100644 --- a/SIDFactoryII/config.ini +++ b/SIDFactoryII/config.ini @@ -210,6 +210,11 @@ Key.Track.SetOrderlistLoopPoint = @l:shift:control Key.OrderListOverview.Copy = @c:control Key.OrderListOverview.Paste = @v:control +// Hide files with these extensions from the file browser. +// Use += to add to a list, or = to add the first element and disregard previously added elements +Disk.Hide.Extensions = ".sid" +Disk.Hide.Extensions += ".prg" + [windows] // Applies to the windows platform only // Disk.Startup.Folder = "" // Uncomment and enter the absolute path to the folder that should @@ -239,29 +244,6 @@ Disk.UserFolders.Aliases += "Desktop" Disk.UserFolders += "/Volumes" Disk.UserFolders.Aliases += "External Volumes" - - -Disk.Startup.Folder = "~" // The folder that should open by default in the file browser. - -// Favorite folders to show in the file browser. -// There are two lists; -// Disk.UserFolders for the folders -// Disk.UserFolders.Aliases for corresponding aliases (the name shown in the browser) -// Make sure the number of folders and the number of aliases are equal - -Disk.UserFolders += "~" -Disk.UserFolders.Aliases += "Home (~)" -Disk.UserFolders += "~/Music" -Disk.UserFolders.Aliases += "Music" -Disk.UserFolders += "~/Documents" -Disk.UserFolders.Aliases += "Documents" -Disk.UserFolders += "~/Desktop" -Disk.UserFolders.Aliases += "Desktop" -Disk.UserFolders += "/mnt" -Disk.UserFolders.Aliases += "/mnt" -Disk.UserFolders += "/Media" -Disk.UserFolders.Aliases += "/Media" - // // KEY OVERRIDES FOR MAC VERSION ONLY // @@ -287,8 +269,28 @@ Key.OrderListOverview.Paste = @v:cmd [linux] // Applies to the linux platform only -#include "~/.config/sidfactory2/user.ini" +Disk.Startup.Folder = "~" // The folder that should open by default in the file browser. + +// Favorite folders to show in the file browser. +// There are two lists; +// Disk.UserFolders for the folders +// Disk.UserFolders.Aliases for corresponding aliases (the name shown in the browser) +// Make sure the number of folders and the number of aliases are equal +Disk.UserFolders += "~" +Disk.UserFolders.Aliases += "Home (~)" +Disk.UserFolders += "~/Music" +Disk.UserFolders.Aliases += "Music" +Disk.UserFolders += "~/Documents" +Disk.UserFolders.Aliases += "Documents" +Disk.UserFolders += "~/Desktop" +Disk.UserFolders.Aliases += "Desktop" +Disk.UserFolders += "/mnt" +Disk.UserFolders.Aliases += "/mnt" +Disk.UserFolders += "/Media" +Disk.UserFolders.Aliases += "/Media" + +#include "~/.config/sidfactory2/user.ini" [debug] // Applies to debug builds only diff --git a/SIDFactoryII/config/config.ini b/SIDFactoryII/config/config.ini index 4102224..86bc65a 100644 --- a/SIDFactoryII/config/config.ini +++ b/SIDFactoryII/config/config.ini @@ -210,6 +210,11 @@ Key.Track.SetOrderlistLoopPoint = @l:shift:control Key.OrderListOverview.Copy = @c:control Key.OrderListOverview.Paste = @v:control +// Hide files with these extensions from the file browser. +// Use += to add to a list, or = to add the first element and disregard previously added elements +Disk.Hide.Extensions = ".sid" +Disk.Hide.Extensions += ".prg" + [windows] // Applies to the windows platform only // Disk.Startup.Folder = "" // Uncomment and enter the absolute path to the folder that should @@ -239,29 +244,6 @@ Disk.UserFolders.Aliases += "Desktop" Disk.UserFolders += "/Volumes" Disk.UserFolders.Aliases += "External Volumes" - - -Disk.Startup.Folder = "~" // The folder that should open by default in the file browser. - -// Favorite folders to show in the file browser. -// There are two lists; -// Disk.UserFolders for the folders -// Disk.UserFolders.Aliases for corresponding aliases (the name shown in the browser) -// Make sure the number of folders and the number of aliases are equal - -Disk.UserFolders += "~" -Disk.UserFolders.Aliases += "Home (~)" -Disk.UserFolders += "~/Music" -Disk.UserFolders.Aliases += "Music" -Disk.UserFolders += "~/Documents" -Disk.UserFolders.Aliases += "Documents" -Disk.UserFolders += "~/Desktop" -Disk.UserFolders.Aliases += "Desktop" -Disk.UserFolders += "/mnt" -Disk.UserFolders.Aliases += "/mnt" -Disk.UserFolders += "/Media" -Disk.UserFolders.Aliases += "/Media" - // // KEY OVERRIDES FOR MAC VERSION ONLY // @@ -287,8 +269,28 @@ Key.OrderListOverview.Paste = @v:cmd [linux] // Applies to the linux platform only -#include "~/.config/sidfactory2/user.ini" +Disk.Startup.Folder = "~" // The folder that should open by default in the file browser. + +// Favorite folders to show in the file browser. +// There are two lists; +// Disk.UserFolders for the folders +// Disk.UserFolders.Aliases for corresponding aliases (the name shown in the browser) +// Make sure the number of folders and the number of aliases are equal +Disk.UserFolders += "~" +Disk.UserFolders.Aliases += "Home (~)" +Disk.UserFolders += "~/Music" +Disk.UserFolders.Aliases += "Music" +Disk.UserFolders += "~/Documents" +Disk.UserFolders.Aliases += "Documents" +Disk.UserFolders += "~/Desktop" +Disk.UserFolders.Aliases += "Desktop" +Disk.UserFolders += "/mnt" +Disk.UserFolders.Aliases += "/mnt" +Disk.UserFolders += "/Media" +Disk.UserFolders.Aliases += "/Media" + +#include "~/.config/sidfactory2/user.ini" [debug] // Applies to debug builds only diff --git a/SIDFactoryII/source/runtime/editor/datasources/datasource_directory.cpp b/SIDFactoryII/source/runtime/editor/datasources/datasource_directory.cpp index e484c45..a08063e 100644 --- a/SIDFactoryII/source/runtime/editor/datasources/datasource_directory.cpp +++ b/SIDFactoryII/source/runtime/editor/datasources/datasource_directory.cpp @@ -23,6 +23,7 @@ namespace Editor auto user_folders = GetConfigurationValues(inConfigFile, "Disk.UserFolders", {}); auto user_folders_alias = GetConfigurationValues(inConfigFile, "Disk.UserFolders.Aliases", {}); + m_ExtensionFilter = GetConfigurationValues(inConfigFile, "Disk.Hide.Extensions", {}); const size_t user_folder_count = user_folders.size(); const bool has_aliases = user_folders_alias.size() == user_folder_count; @@ -35,7 +36,7 @@ namespace Editor if (is_directory(user_folder_path)) m_Drives.push_back({ user_folder, has_aliases ? user_folders_alias[i] : "" }); } - + GenerateData(); } @@ -80,7 +81,7 @@ namespace Editor bool DataSourceDirectory::Back() { std::error_code error_code; - + std::string current_path_string = current_path().string(); if (m_Platform->Storage_SetCurrentPath(current_path().parent_path().string())) { @@ -158,8 +159,27 @@ namespace Editor std::error_code error_code; if (is_directory(path, error_code)) m_List.push_back({ DirectoryEntry::Folder, path }); - else if (is_regular_file(path, error_code)) - files.push_back(path); + else if (is_regular_file(path, error_code)) { + std::string extension = fs::path(path).extension(); + + // filter out files with extensions on the hide list + bool showFile = true; + for (size_t i = 0; i < m_ExtensionFilter.size(); ++i) { + if (extension.compare(m_ExtensionFilter[i]) == 0) { + showFile = false; + } + } + + // TODO: more optimal, but crashes when extensionFilter is empty + // size_t i = 0; + // while (showFile && (i < m_ExtensionFilter.size())) { + // showFile = showFile && (extension.compare(m_ExtensionFilter[i++]) != 0); + // } + + if (showFile) { + files.push_back(path); + } + } } } diff --git a/SIDFactoryII/source/runtime/editor/datasources/datasource_directory.h b/SIDFactoryII/source/runtime/editor/datasources/datasource_directory.h index f0223ea..faec1f1 100644 --- a/SIDFactoryII/source/runtime/editor/datasources/datasource_directory.h +++ b/SIDFactoryII/source/runtime/editor/datasources/datasource_directory.h @@ -68,6 +68,7 @@ namespace Editor const Utility::ConfigFile& m_ConfigFile; std::vector m_Drives; + std::vector m_ExtensionFilter; bool m_HasFileSelection; int m_SelectedFileIndex; diff --git a/dist/documentation/user.default.ini b/dist/documentation/user.default.ini index aa2ed47..73c680c 100644 --- a/dist/documentation/user.default.ini +++ b/dist/documentation/user.default.ini @@ -59,6 +59,11 @@ Window.Scaling.Smooth = 1 // If you set this to 1, scaling Show.Overlay = 0 // If you set this to 1, the overlay will be shown when starting the editor. // Note that you can always toggle the overlay on and off with the F12 hotkey. +// Hide files with these extensions from the file browser. +// Use += to add to a list, or = to add the first element and disregard previously added elements +Disk.Hide.Extensions = ".sid" +Disk.Hide.Extensions += ".prg" + [windows] // Applies to the windows platform only // Disk.Startup.Folder = "" // Uncomment and enter the absolute path to the folder that should