From 8dc295232df48371fba42d078011aa7389343530 Mon Sep 17 00:00:00 2001 From: matcool <26722564+matcool@users.noreply.github.com> Date: Tue, 21 Jan 2025 20:01:55 -0300 Subject: [PATCH] copy image to path to avoid unicode error on reference-image fixes #18 --- reference-image/main.cpp | 11 +++++++++++ reference-image/mod.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/reference-image/main.cpp b/reference-image/main.cpp index 2dfc1f2..b619577 100644 --- a/reference-image/main.cpp +++ b/reference-image/main.cpp @@ -1,6 +1,7 @@ #include using namespace geode::prelude; +using namespace std::string_literals; #include class $modify(MyEditorUI, EditorUI) { @@ -20,6 +21,16 @@ class $modify(MyEditorUI, EditorUI) { m_fields->m_sprite->removeFromParent(); m_fields->m_sprite = nullptr; } + #ifdef GEODE_IS_WINDOWS + try { + (void) path.string(); + } catch (...) { + // copy file to mod temp dir, which is guaranteed to be within the codepage + auto newPath = Mod::get()->getTempDir() / ("temp_ref_img"s + path.extension().string()); + std::filesystem::copy_file(path, newPath, std::filesystem::copy_options::overwrite_existing); + path = newPath; + } + #endif auto* sprite = CCSprite::create(path.string().c_str()); if (sprite || !sprite->getUserObject("geode.texture-loader/fallback")) { m_fields->m_sprite = sprite; diff --git a/reference-image/mod.json b/reference-image/mod.json index e21504c..8a1a861 100644 --- a/reference-image/mod.json +++ b/reference-image/mod.json @@ -5,7 +5,7 @@ "android": "2.2074", "mac": "2.2074" }, - "version": "v1.1.1", + "version": "v1.1.2", "id": "mat.reference-image", "name": "Reference Image", "developer": "mat",