mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
fix: correct argument typo and path/error handling
Fix --enable-consolelog flag, screenshot filter bug, paths to C APIs, add includes and gitignore entries, and improve ShellExecuteW failure detection.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -14,6 +14,7 @@
|
||||
*.pch
|
||||
*.sbr
|
||||
build/
|
||||
build_debug/
|
||||
Build/
|
||||
bin/
|
||||
Debug/
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <tbb/concurrent_hash_map.h>
|
||||
#include <tbb/concurrent_queue.h>
|
||||
#include <tbb/concurrent_vector.h>
|
||||
#include <variant>
|
||||
namespace Cubed {
|
||||
class ServerWorld;
|
||||
class Session;
|
||||
|
||||
@@ -17,9 +17,18 @@ namespace Cubed::Tools {
|
||||
|
||||
inline void open_file_manager(const std::filesystem::path& path) {
|
||||
#ifdef _WIN32
|
||||
|
||||
ShellExecuteW(nullptr, L"open", path.wstring().c_str(), nullptr, nullptr,
|
||||
SW_SHOWNORMAL);
|
||||
auto abs_path = std::filesystem::absolute(path);
|
||||
if (!std::filesystem::exists(abs_path)) {
|
||||
Logger::warn("Path does not exist: {}", abs_path.string());
|
||||
return;
|
||||
}
|
||||
HINSTANCE result =
|
||||
ShellExecuteW(nullptr, L"open", abs_path.wstring().c_str(), nullptr,
|
||||
nullptr, SW_SHOWNORMAL);
|
||||
if ((INT_PTR)result <= 32) {
|
||||
Logger::warn("ShellExecuteW failed for path: {}, error code: {}",
|
||||
path.string(), (int)(INT_PTR)result);
|
||||
}
|
||||
|
||||
#elif __linux__
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace Cubed {
|
||||
class SensitiveFilter {
|
||||
public:
|
||||
|
||||
@@ -187,7 +187,7 @@ void App::handle_argument(int argc, char** argv) {
|
||||
}},
|
||||
{"--enable-filelog",
|
||||
[&](ArgParser&) { m_argument.enable_filelog = true; }},
|
||||
{"--enale-consolelog",
|
||||
{"--enable-consolelog",
|
||||
[&](ArgParser&) { m_argument.enable_consolelog = true; }},
|
||||
{"--direct-enter",
|
||||
[&](ArgParser&) { m_argument.direct_enter = true; }}
|
||||
|
||||
@@ -88,7 +88,7 @@ ModelManager::Handle ModelManager::load_model(std::string_view model_name) {
|
||||
auto model = m_loader.load(path);
|
||||
fs::path anim_path = path;
|
||||
anim_path = anim_path.parent_path() / "animation.json";
|
||||
load_anim_config(model, anim_path);
|
||||
load_anim_config(model, anim_path.string());
|
||||
ModelMap::accessor acc;
|
||||
if (m_models.insert(acc, m_next++)) {
|
||||
acc->second = std::move(model);
|
||||
|
||||
@@ -311,11 +311,11 @@ void Renderer::handle_screenshot() {
|
||||
fs::create_directories(path);
|
||||
fs::path image =
|
||||
path / std::format("screenshot {}.png", Tools::get_time_date_str());
|
||||
if (!stbi_write_png(image.c_str(), width, height, 4, flipped_pixels.data(),
|
||||
width * 4)) {
|
||||
Logger::error("Failed to write {} image", image.c_str());
|
||||
if (!stbi_write_png(image.string().c_str(), width, height, 4,
|
||||
flipped_pixels.data(), width * 4)) {
|
||||
Logger::error("Failed to write {} image", image.string());
|
||||
} else {
|
||||
Logger::info("save {} success!", image.c_str());
|
||||
Logger::info("save {} success!", image.string());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ ImageData load_image_data(const std::string& tex_image_path, bool check_exist,
|
||||
path = ASSETS_PATH + tex_image_path;
|
||||
}
|
||||
if (check_exist) {
|
||||
ASSERT_MSG(fs::is_regular_file(path), path.c_str());
|
||||
ASSERT_MSG(fs::is_regular_file(path), path.string().c_str());
|
||||
}
|
||||
unsigned char* data = nullptr;
|
||||
int width, height, channels;
|
||||
|
||||
@@ -54,7 +54,8 @@ void ScreenshotUI::update_layout(int width, int height) {
|
||||
if (!fs::is_regular_file(entry)) {
|
||||
continue;
|
||||
}
|
||||
if (!std::ranges::find(IMAGE_EXT, entry.path().extension())) {
|
||||
if (std::ranges::find(IMAGE_EXT, entry.path().extension()) ==
|
||||
IMAGE_EXT.end()) {
|
||||
continue;
|
||||
}
|
||||
ImageInfo info;
|
||||
|
||||
Reference in New Issue
Block a user