Skip to content

Commit

Permalink
Changed default filter. Code formatting. README (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
micheldebree committed Sep 12, 2023
1 parent eb04eb1 commit abf01f6
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 57 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ Please report issues in our [issue tracker](https://github.com/issues).

### Next release

![Commits since last release](https://img.shields.io/github/commits-since/chordian/sidfactory2/release-20221007)
![Commits since last
release](https://img.shields.io/github/commits-since/chordian/sidfactory2/release-20221007)

- Added: [#156](https://github.com/Chordian/sidfactory2/issues/156)
Configuration option `Disk.Hide.Extensions` to hide files with certain
extensions in the file browser. Default values are `.sid`, `.wav` and `.mp3`
- Changed: Configuration parameter `Window.Scale` now has a range from 1.0 to
10.0, so users can blow up the screen even bigger. Values below 1.0 were not
working correctly.

- Changed: Configuration parameter `Window.Scale` now has a range from 1.0 to 10.0, so users can blow up the screen even bigger.
Values below 1.0 were not working correctly.
### Build 20221007

- Fixed: [#162](https://github.com/Chordian/sidfactory2/issues/162) Crash when
Expand All @@ -76,9 +81,6 @@ Please report issues in our [issue tracker](https://github.com/issues).
- Fixed: reSID won't output a click anymore when launching SID Factory II or
loading/saving files (Thanks to Tammo Hinrichs for implementing)

- 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
5 changes: 3 additions & 2 deletions SIDFactoryII/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ 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"
Disk.Hide.Extensions = ".sid"
Disk.Hide.Extensions += ".wav"
Disk.Hide.Extensions += ".mp3"

[windows] // Applies to the windows platform only

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "datasource_directory.h"
#include "foundation/platform/iplatform.h"
#include "utils/configfile.h"
#include "utils/config/configtypes.h"
#include "utils/configfile.h"
#include <cctype>

using namespace fs;
Expand All @@ -28,7 +28,7 @@ namespace Editor
const size_t user_folder_count = user_folders.size();
const bool has_aliases = user_folders_alias.size() == user_folder_count;

for (size_t i = 0; i<user_folder_count; ++i)
for (size_t i = 0; i < user_folder_count; ++i)
{
const std::string& user_folder = inPlatform->OS_ParsePath(user_folders[i]);
path user_folder_path = path(user_folder);
Expand All @@ -48,7 +48,7 @@ namespace Editor
FOUNDATION_ASSERT(inIndex < static_cast<int>(m_List.size()));

const DirectoryEntry& entry = (*this)[inIndex];
std::error_code error_code;
std::error_code error_code;

switch (entry.m_Type)
{
Expand All @@ -58,11 +58,11 @@ namespace Editor

case DirectoryEntry::Drive:
case DirectoryEntry::Folder:
if(m_Platform->Storage_SetCurrentPath(entry.m_Path.string()))
{
GenerateData();
return SelectResult::SelectFolderSucceeded;
}
if (m_Platform->Storage_SetCurrentPath(entry.m_Path.string()))
{
GenerateData();
return SelectResult::SelectFolderSucceeded;
}

return SelectResult::SelectFolderFailed;
case DirectoryEntry::File:
Expand All @@ -80,11 +80,11 @@ namespace Editor

bool DataSourceDirectory::Back()
{
std::error_code error_code;
std::error_code error_code;

std::string current_path_string = current_path().string();
if (m_Platform->Storage_SetCurrentPath(current_path().parent_path().string()))
{
{
GenerateData();

for (size_t i = 0; i < m_List.size(); ++i)
Expand Down Expand Up @@ -146,37 +146,35 @@ namespace Editor
fs::path current_path = fs::current_path();

const bool is_root = current_path.parent_path() == current_path;
if(!is_root)
if (!is_root)
m_List.push_back({ DirectoryEntry::Back, ".." });

// Iterate entries in current directory and add folder to the list and cache files for adding afterward
directory_iterator directory_iterator(current_path);
std::vector<path> files;
for (auto& path : directory_iterator)
{
if(!m_Platform->Storage_IsSystemFile(path.path().string()))
{
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)) {
if (!m_Platform->Storage_IsSystemFile(path.path().string()))
{
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))
{
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) {
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) {
if (showFile)
{
files.push_back(path);
}
}
Expand All @@ -187,32 +185,31 @@ namespace Editor
m_List.push_back({ DirectoryEntry::File, file });

// Sort the list
std::sort(m_List.begin(), m_List.end(), [](const DirectoryEntry& inEntry1, const DirectoryEntry& inEntry2)
std::sort(m_List.begin(), m_List.end(), [](const DirectoryEntry& inEntry1, const DirectoryEntry& inEntry2) {
// If the types are the same, lets check the filenames against each other (and ignore case .. which means a transformation per comparison, not fast.. but who cares! This is disk operation stuff)
if (inEntry1.m_Type == inEntry2.m_Type)
{
// If the types are the same, lets check the filenames against each other (and ignore case .. which means a transformation per comparasin, not fast.. but who cares! This is disk operation stuff)
if (inEntry1.m_Type == inEntry2.m_Type)
if (!(inEntry1.m_DisplayName.empty() ^ inEntry2.m_DisplayName.empty()))
{
if (!(inEntry1.m_DisplayName.empty() ^ inEntry2.m_DisplayName.empty()))
{
std::string name1 = inEntry1.m_DisplayName.empty() ? inEntry1.m_Path.string() : inEntry1.m_DisplayName;
std::string name2 = inEntry2.m_DisplayName.empty() ? inEntry2.m_Path.string() : inEntry2.m_DisplayName;
std::string name1 = inEntry1.m_DisplayName.empty() ? inEntry1.m_Path.string() : inEntry1.m_DisplayName;
std::string name2 = inEntry2.m_DisplayName.empty() ? inEntry2.m_Path.string() : inEntry2.m_DisplayName;

std::transform(name1.begin(), name1.end(), name1.begin(),
[](char c) { return std::tolower(c); });
std::transform(name2.begin(), name2.end(), name2.begin(),
[](char c) { return std::tolower(c); });
std::transform(name1.begin(), name1.end(), name1.begin(),
[](char c) { return std::tolower(c); });
std::transform(name2.begin(), name2.end(), name2.begin(),
[](char c) { return std::tolower(c); });

return name1 < name2;
}
else
{
// If inEntry2 is not using the display name, entry 1 is and vice versa!
return inEntry2.m_DisplayName.empty();
}
return name1 < name2;
}
else
{
// If inEntry2 is not using the display name, entry 1 is and vice versa!
return inEntry2.m_DisplayName.empty();
}
}

// Otherwise just prefer one type over the other
return inEntry1.m_Type < inEntry2.m_Type;
});
// Otherwise just prefer one type over the other
return inEntry1.m_Type < inEntry2.m_Type;
});
}
}
5 changes: 3 additions & 2 deletions dist/documentation/user.default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ Show.Overlay = 0 // If you set this to 1, the ove

// 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"
Disk.Hide.Extensions = ".sid"
Disk.Hide.Extensions += ".wav"
Disk.Hide.Extensions += ".mp3"

[windows] // Applies to the windows platform only

Expand Down

0 comments on commit abf01f6

Please sign in to comment.