Skip to content

Commit

Permalink
copy image to path to avoid unicode error on reference-image
Browse files Browse the repository at this point in the history
fixes #18
  • Loading branch information
matcool committed Jan 21, 2025
1 parent e68b89d commit 8dc2952
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions reference-image/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <Geode/Geode.hpp>

using namespace geode::prelude;
using namespace std::string_literals;

#include <Geode/modify/EditorUI.hpp>
class $modify(MyEditorUI, EditorUI) {
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion reference-image/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 8dc2952

Please sign in to comment.