From d4a79ba9db2424e95384f305e18ed69f40cef4c8 Mon Sep 17 00:00:00 2001 From: MistEO Date: Tue, 9 Sep 2025 00:19:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=B3=8A=E4=B8=80=E4=B8=8B=20debug=5Fde?= =?UTF-8?q?mo=20=E8=B5=84=E6=BA=90=E8=B7=AF=E5=BE=84=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Cpp/main.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Cpp/main.cpp b/src/Cpp/main.cpp index fb17cdec17..2dc11abadd 100644 --- a/src/Cpp/main.cpp +++ b/src/Cpp/main.cpp @@ -8,13 +8,24 @@ int main([[maybe_unused]] int argc, char** argv) { - const auto cur_path = std::filesystem::path(argv[0]).parent_path(); + auto working_path = std::filesystem::path(argv[0]).parent_path(); + +#ifdef ASST_DEBUG + if (!std::filesystem::exists(working_path / "resource")) { + working_path = working_path.parent_path().parent_path().parent_path(); + } +#endif + + if (!std::filesystem::exists(working_path / "resource")) { + std::cerr << "resource folder not found!" << std::endl; + return -1; + } // 可以将日志、调试图片等存到别的目录下,需要在最一开始调用。不调用默认保存到资源同目录 - // AsstSetUserDir(cur_path.c_str()); + // AsstSetUserDir(working_path.c_str()); // 这里默认读取的是可执行文件同目录下 resource 文件夹里的资源 - if (!AsstLoadResource(cur_path.string().c_str())) { + if (!AsstLoadResource(working_path.string().c_str())) { std::cerr << "-------- load resource failed: official --------" << std::endl; return -1; } @@ -29,7 +40,7 @@ int main([[maybe_unused]] int argc, char** argv) else { std::cout << "load overseas_type: " << arg << std::endl; - const auto overseas_path = cur_path / "resource" / "global" / arg; + const auto overseas_path = working_path / "resource" / "global" / arg; if (!AsstLoadResource(overseas_path.string().c_str())) { std::cerr << "-------- load resource failed: " << arg << " --------" << std::endl; return -1;