diff --git a/src/anm2/anm2.h b/src/anm2/anm2.h index 71f3fbe..b48137f 100644 --- a/src/anm2/anm2.h +++ b/src/anm2/anm2.h @@ -12,8 +12,6 @@ namespace anm2ed::anm2 { - constexpr auto NO_PATH = "[No Path]"; - struct Reference { int animationIndex{-1}; diff --git a/src/dialog.cpp b/src/dialog.cpp index b32f8ac..dc3b122 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -9,8 +9,11 @@ #include "toast.h" #endif +#include #include +#include "filesystem_.h" + namespace anm2ed::dialog { static void callback(void* userData, const char* const* filelist, int filter) @@ -28,6 +31,7 @@ namespace anm2ed::dialog } using namespace anm2ed::dialog; +namespace filesystem = anm2ed::util::filesystem; namespace anm2ed { @@ -60,10 +64,12 @@ namespace anm2ed void Dialog::file_explorer_open(const std::filesystem::path& path) { + if (path.empty()) return; #ifdef _WIN32 - ShellExecuteA(NULL, "open", path.string().c_str(), NULL, NULL, SW_SHOWNORMAL); + ShellExecuteW(nullptr, L"open", path.native().c_str(), nullptr, nullptr, SW_SHOWNORMAL); #elif __unix__ - system(std::format("xdg-open \"{}\" &", path.c_str()).c_str()); + auto pathUtf8 = filesystem::path_to_utf8(path); + system(std::format("xdg-open \"{}\" &", pathUtf8).c_str()); #else toasts.push(localize.get(TOAST_NOT_SUPPORTED)); logger.warning(localize.get(TOAST_NOT_SUPPORTED, anm2ed::ENGLISH)); diff --git a/src/imgui/window/spritesheets.cpp b/src/imgui/window/spritesheets.cpp index c72c39e..f9d28c8 100644 --- a/src/imgui/window/spritesheets.cpp +++ b/src/imgui/window/spritesheets.cpp @@ -47,7 +47,7 @@ namespace anm2ed::imgui for (auto& id : unused) { anm2::Spritesheet& spritesheet = anm2.content.spritesheets[id]; - auto pathString = spritesheet.path.string(); + auto pathString = filesystem::path_to_utf8(spritesheet.path); toasts.push(std::vformat(localize.get(TOAST_REMOVE_SPRITESHEET), std::make_format_args(id, pathString))); logger.info(std::vformat(localize.get(TOAST_REMOVE_SPRITESHEET, anm2ed::ENGLISH), std::make_format_args(id, pathString))); @@ -69,7 +69,7 @@ namespace anm2ed::imgui { anm2::Spritesheet& spritesheet = anm2.content.spritesheets[id]; spritesheet.reload(document.directory_get()); - auto pathString = spritesheet.path.string(); + auto pathString = filesystem::path_to_utf8(spritesheet.path); toasts.push(std::vformat(localize.get(TOAST_RELOAD_SPRITESHEET), std::make_format_args(id, pathString))); logger.info(std::vformat(localize.get(TOAST_RELOAD_SPRITESHEET, anm2ed::ENGLISH), std::make_format_args(id, pathString))); @@ -88,7 +88,7 @@ namespace anm2ed::imgui auto& id = *selection.begin(); anm2::Spritesheet& spritesheet = anm2.content.spritesheets[id]; spritesheet = anm2::Spritesheet(document.directory_get(), path); - auto pathString = spritesheet.path.string(); + auto pathString = filesystem::path_to_utf8(spritesheet.path); toasts.push(std::vformat(localize.get(TOAST_REPLACE_SPRITESHEET), std::make_format_args(id, pathString))); logger.info(std::vformat(localize.get(TOAST_REPLACE_SPRITESHEET, anm2ed::ENGLISH), std::make_format_args(id, pathString))); @@ -104,7 +104,7 @@ namespace anm2ed::imgui for (auto& id : selection) { anm2::Spritesheet& spritesheet = anm2.content.spritesheets[id]; - auto pathString = spritesheet.path.string(); + auto pathString = filesystem::path_to_utf8(spritesheet.path); if (spritesheet.save(document.directory_get())) { toasts.push(std::vformat(localize.get(TOAST_SAVE_SPRITESHEET), std::make_format_args(id, pathString))); @@ -145,8 +145,7 @@ namespace anm2ed::imgui { std::string errorString{}; document.snapshot(localize.get(EDIT_PASTE_SPRITESHEETS)); - if (anm2.spritesheets_deserialize(clipboard.get(), document.directory_get(), merge::APPEND, - &errorString)) + if (anm2.spritesheets_deserialize(clipboard.get(), document.directory_get(), merge::APPEND, &errorString)) document.change(Document::SPRITESHEETS); else { @@ -227,7 +226,7 @@ namespace anm2ed::imgui bool isValid = spritesheet.texture.is_valid(); auto& texture = isValid ? spritesheet.texture : resources.icons[icon::NONE]; auto tintColor = !isValid ? ImVec4(1.0f, 0.25f, 0.25f, 1.0f) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f); - auto pathString = spritesheet.path.empty() ? std::string{anm2::NO_PATH} : spritesheet.path.string(); + auto pathString = filesystem::path_to_utf8(spritesheet.path); auto pathCStr = pathString.c_str(); ImGui::SetNextItemSelectionUserData(id);