bbbbbbbbbbbbbbbbb

This commit is contained in:
2025-12-13 22:43:32 -05:00
parent b9b0fb9974
commit 8fa103d0b7
3 changed files with 14 additions and 11 deletions

View File

@@ -12,8 +12,6 @@
namespace anm2ed::anm2 namespace anm2ed::anm2
{ {
constexpr auto NO_PATH = "[No Path]";
struct Reference struct Reference
{ {
int animationIndex{-1}; int animationIndex{-1};

View File

@@ -9,8 +9,11 @@
#include "toast.h" #include "toast.h"
#endif #endif
#include <cstdlib>
#include <format> #include <format>
#include "filesystem_.h"
namespace anm2ed::dialog namespace anm2ed::dialog
{ {
static void callback(void* userData, const char* const* filelist, int filter) static void callback(void* userData, const char* const* filelist, int filter)
@@ -28,6 +31,7 @@ namespace anm2ed::dialog
} }
using namespace anm2ed::dialog; using namespace anm2ed::dialog;
namespace filesystem = anm2ed::util::filesystem;
namespace anm2ed namespace anm2ed
{ {
@@ -60,10 +64,12 @@ namespace anm2ed
void Dialog::file_explorer_open(const std::filesystem::path& path) void Dialog::file_explorer_open(const std::filesystem::path& path)
{ {
if (path.empty()) return;
#ifdef _WIN32 #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__ #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 #else
toasts.push(localize.get(TOAST_NOT_SUPPORTED)); toasts.push(localize.get(TOAST_NOT_SUPPORTED));
logger.warning(localize.get(TOAST_NOT_SUPPORTED, anm2ed::ENGLISH)); logger.warning(localize.get(TOAST_NOT_SUPPORTED, anm2ed::ENGLISH));

View File

@@ -47,7 +47,7 @@ namespace anm2ed::imgui
for (auto& id : unused) for (auto& id : unused)
{ {
anm2::Spritesheet& spritesheet = anm2.content.spritesheets[id]; 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))); 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), logger.info(std::vformat(localize.get(TOAST_REMOVE_SPRITESHEET, anm2ed::ENGLISH),
std::make_format_args(id, pathString))); std::make_format_args(id, pathString)));
@@ -69,7 +69,7 @@ namespace anm2ed::imgui
{ {
anm2::Spritesheet& spritesheet = anm2.content.spritesheets[id]; anm2::Spritesheet& spritesheet = anm2.content.spritesheets[id];
spritesheet.reload(document.directory_get()); 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))); 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), logger.info(std::vformat(localize.get(TOAST_RELOAD_SPRITESHEET, anm2ed::ENGLISH),
std::make_format_args(id, pathString))); std::make_format_args(id, pathString)));
@@ -88,7 +88,7 @@ namespace anm2ed::imgui
auto& id = *selection.begin(); auto& id = *selection.begin();
anm2::Spritesheet& spritesheet = anm2.content.spritesheets[id]; anm2::Spritesheet& spritesheet = anm2.content.spritesheets[id];
spritesheet = anm2::Spritesheet(document.directory_get(), path); 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))); 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), logger.info(std::vformat(localize.get(TOAST_REPLACE_SPRITESHEET, anm2ed::ENGLISH),
std::make_format_args(id, pathString))); std::make_format_args(id, pathString)));
@@ -104,7 +104,7 @@ namespace anm2ed::imgui
for (auto& id : selection) for (auto& id : selection)
{ {
anm2::Spritesheet& spritesheet = anm2.content.spritesheets[id]; 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())) if (spritesheet.save(document.directory_get()))
{ {
toasts.push(std::vformat(localize.get(TOAST_SAVE_SPRITESHEET), std::make_format_args(id, pathString))); 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{}; std::string errorString{};
document.snapshot(localize.get(EDIT_PASTE_SPRITESHEETS)); document.snapshot(localize.get(EDIT_PASTE_SPRITESHEETS));
if (anm2.spritesheets_deserialize(clipboard.get(), document.directory_get(), merge::APPEND, if (anm2.spritesheets_deserialize(clipboard.get(), document.directory_get(), merge::APPEND, &errorString))
&errorString))
document.change(Document::SPRITESHEETS); document.change(Document::SPRITESHEETS);
else else
{ {
@@ -227,7 +226,7 @@ namespace anm2ed::imgui
bool isValid = spritesheet.texture.is_valid(); bool isValid = spritesheet.texture.is_valid();
auto& texture = isValid ? spritesheet.texture : resources.icons[icon::NONE]; 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 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(); auto pathCStr = pathString.c_str();
ImGui::SetNextItemSelectionUserData(id); ImGui::SetNextItemSelectionUserData(id);