Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix graphicPacks load failed if use utf8 exe path #1010

Closed
Closed
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
7 changes: 4 additions & 3 deletions src/Cafe/GraphicPack/GraphicPack2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "util/helpers/StringHelpers.h"
#include "Cafe/CafeSystem.h"
#include <cinttypes>
#include "gui/wxHelper.h"

std::vector<GraphicPackPtr> GraphicPack2::s_graphic_packs;
std::vector<GraphicPackPtr> GraphicPack2::s_active_graphic_packs;
Expand Down Expand Up @@ -89,12 +90,12 @@ bool GraphicPack2::LoadGraphicPack(const std::string& filename, IniParser& rules
const auto& config_entries = g_config.data().graphic_pack_entries;

// legacy absolute path checking for not breaking compatibility
auto file = gp->GetFilename2();
auto file = wxHelper::MakeFSPath(gp->GetFilename());
auto it = config_entries.find(file.lexically_normal());
if (it == config_entries.cend())
{
// check for relative path
it = config_entries.find(MakeRelativePath(ActiveSettings::GetUserDataPath(), gp->GetFilename2()).lexically_normal());
it = config_entries.find(MakeRelativePath(ActiveSettings::GetUserDataPath(), wxHelper::FromUtf8(gp->GetFilename()).ToStdString()).lexically_normal());
}

if (it != config_entries.cend())
Expand Down Expand Up @@ -650,7 +651,7 @@ bool GraphicPack2::SetActivePreset(std::string_view category, std::string_view n

void GraphicPack2::LoadShaders()
{
fs::path path(m_filename);
fs::path path(wxHelper::FromUtf8(m_filename).ToStdString());
for (auto& it : fs::directory_iterator(path.remove_filename()))
{
if (!is_regular_file(it))
Expand Down
1 change: 1 addition & 0 deletions src/gui/wxHelper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <wx/string.h>
#include <wx/colour.h>

namespace wxHelper
{
Expand Down