Skip to content

Commit

Permalink
Config option to filter out certain extensions. #156
Browse files Browse the repository at this point in the history
  • Loading branch information
micheldebree committed Feb 20, 2022
1 parent 183eb11 commit 1ce07b1
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 52 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
50 changes: 26 additions & 24 deletions SIDFactoryII/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
//
Expand All @@ -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

Expand Down
50 changes: 26 additions & 24 deletions SIDFactoryII/config/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
//
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Editor

auto user_folders = GetConfigurationValues<ConfigValueString>(inConfigFile, "Disk.UserFolders", {});
auto user_folders_alias = GetConfigurationValues<ConfigValueString>(inConfigFile, "Disk.UserFolders.Aliases", {});
m_ExtensionFilter = GetConfigurationValues<ConfigValueString>(inConfigFile, "Disk.Hide.Extensions", {});

const size_t user_folder_count = user_folders.size();
const bool has_aliases = user_folders_alias.size() == user_folder_count;
Expand All @@ -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();
}

Expand Down Expand Up @@ -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()))
{
Expand Down Expand Up @@ -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);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace Editor
const Utility::ConfigFile& m_ConfigFile;

std::vector<Drive> m_Drives;
std::vector<std::string> m_ExtensionFilter;

bool m_HasFileSelection;
int m_SelectedFileIndex;
Expand Down
5 changes: 5 additions & 0 deletions dist/documentation/user.default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1ce07b1

Please sign in to comment.