Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/opengl/main/generic_combo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,7 @@ class GenericCombo
// want, outside or inside your objects
if (std::ranges::empty(string))
{
return;
continue;
}
const char *c_str_value = std::ranges::data(string);
{
Expand Down
7 changes: 4 additions & 3 deletions src/opengl/main/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ void gui::hovered_tiles_panel()
}
void gui::combo_coo()
{
bool remaster = m_field->is_remaster_from_fl_paths();
bool remaster = m_field && m_field->is_remaster_from_fl_paths();
if (!remaster)
{
return;
Expand Down Expand Up @@ -2447,7 +2447,7 @@ void gui::file_menu()
{
return;
}
bool remaster = m_field->is_remaster_from_fl_paths();
bool remaster = m_field && m_field->is_remaster_from_fl_paths();
if (remaster && ImGui::BeginMenu(gui_labels::language.data()))
{
const auto end_menu1 = glengine::ScopeGuard(&ImGui::EndMenu);
Expand Down Expand Up @@ -4245,7 +4245,8 @@ gui::gui(GLFWwindow *const window)
});

m_filter_window.register_is_remaster_callback(
[this]() -> bool { return m_field->is_remaster_from_fl_paths(); });
[this]() -> bool
{ return m_field && m_field->is_remaster_from_fl_paths(); });

if (m_field)
{
Expand Down
41 changes: 38 additions & 3 deletions src/opengl/main/utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,47 @@ concept erasable_range = std::ranges::range<R> && requires(R &r) {
} -> std::same_as<typename R::iterator>;
};

inline std::filesystem::path
normalize_for_compare(const std::filesystem::path &p)
{
auto norm = p.lexically_normal();

#if defined(_WIN32)

// Windows: case-insensitive
auto s = norm.native();
std::ranges::transform(
s,
s.begin(),
[](const auto ch)
{
return static_cast<std::remove_cvref_t<decltype(ch)>>(
std::tolower(ch));
});
return std::filesystem::path{ s };
#else
// Linux / others: case-sensitive
return norm;
#endif
}

template<erasable_range... R>
constexpr inline bool sort_and_remove_duplicates(R &...ranges) noexcept
{
bool changed = false;
const auto projection
= [](const auto &values) { return std::get<0>(values); };
bool changed = false;
const auto projection = [](const auto &values)
{
using value_t = std::remove_cvref_t<decltype(std::get<0>(values))>;

if constexpr (std::is_same_v<value_t, std::filesystem::path>)
{
return normalize_for_compare(std::get<0>(values));
}
else
{
return std::get<0>(values);
}
};
auto zip_view = std::ranges::views::zip(ranges...);
if (!std::ranges::is_sorted(zip_view, {}, projection))
{
Expand Down