Merge branch 'main' of https://github.com/TwilitRealm/dusk into randomizer

This commit is contained in:
gymnast86
2026-05-10 09:56:06 -07:00
17 changed files with 220 additions and 47 deletions
+3 -1
View File
@@ -314,7 +314,9 @@ namespace dusk {
ImGui::PopFont();
}
ImGui::PushFont(ImGuiEngine::fontLarge);
ImGuiTextCenter("Failed to initialize any graphics backend");
ImGuiTextCenter("Failed to initialize any graphics backend.");
ImGuiTextCenter("\nYour system may be misconfigured, or your hardware may not support the required versions of any of the available backends.");
ImGuiTextCenter("\nA clean reinstall of Dusk may help. For further assistance, please visit #tech-support on the Twilit Realm Discord server.");
const auto& style = ImGui::GetStyle();
const auto retrySize = ImGui::CalcTextSize("Retry (Auto backend)");
const auto quitSize = ImGui::CalcTextSize("Quit");
+5 -6
View File
@@ -48,19 +48,18 @@ void ImGuiStateShare::onMergeFileSelected(void* userdata, const char* path, cons
static std::string GetStatesFilePath() {
return (dusk::ConfigPath / STATES_FILENAME).string();
static std::filesystem::path GetStatesFilePath() {
return ConfigPath / STATES_FILENAME;
}
void ImGuiStateShare::loadStatesFile() {
m_loaded = true;
const std::filesystem::path filePath = dusk::ConfigPath / STATES_FILENAME;
const std::filesystem::path filePath = GetStatesFilePath();
if (!std::filesystem::exists(filePath)) {
return;
}
try {
const std::string pathStr = filePath.string();
auto data = io::FileStream::ReadAllBytes(pathStr.c_str());
auto data = io::FileStream::ReadAllBytes(filePath);
auto j = json::parse(data);
if (!j.is_array()) {
return;
@@ -85,7 +84,7 @@ void ImGuiStateShare::saveStatesFile() {
j.push_back(json{{"name", s.name}, {"data", s.encoded}});
}
try {
io::FileStream::WriteAllText(GetStatesFilePath().c_str(), j.dump(2));
io::FileStream::WriteAllText(GetStatesFilePath(), j.dump(2));
} catch (const std::exception& e) {
m_statusMsg = fmt::format("Failed to save states: {}", e.what());
}
+2 -2
View File
@@ -208,7 +208,7 @@ void dusk::InitializeFileLogging(const std::filesystem::path& configDir, AuroraL
std::filesystem::create_directories(logsDir, ec);
if (ec) {
std::fprintf(stderr, "[WARNING | dusk] Failed to create log directory '%s': %s\n",
logsDir.string().c_str(), ec.message().c_str());
io::fs_path_to_string(logsDir).c_str(), ec.message().c_str());
return;
}
@@ -216,7 +216,7 @@ void dusk::InitializeFileLogging(const std::filesystem::path& configDir, AuroraL
g_logState.file = io::FileStream::Create(logPath).ToInner();
if (g_logState.file == nullptr) {
std::fprintf(stderr, "[WARNING | dusk] Failed to open log file '%s'\n",
logPath.string().c_str());
io::fs_path_to_string(logPath).c_str());
return;
}
+2 -1
View File
@@ -6,6 +6,7 @@
#include <aurora/main.h>
#include "dusk/main.h"
#include "dusk/io.hpp"
#include <algorithm>
#include <array>
@@ -91,7 +92,7 @@ bool RestartProcess(int argc, char* argv[]) {
std::vector<std::string> args;
args.reserve(static_cast<size_t>(std::max(argc, 1)));
args.push_back(executablePath.string());
args.push_back(dusk::io::fs_path_to_string(executablePath));
for (int i = 1; i < argc; ++i) {
args.emplace_back(argv[i] != nullptr ? argv[i] : "");
}
+2 -1
View File
@@ -11,6 +11,7 @@
#include <ranges>
#include "aurora/lib/window.hpp"
#include "dusk/io.hpp"
#include "input.hpp"
#include "prelaunch.hpp"
#include "window.hpp"
@@ -19,7 +20,7 @@ namespace dusk::ui {
namespace {
void load_font(const char* filename, bool fallback = false) {
Rml::LoadFontFace(resource_path(filename).string(), fallback);
Rml::LoadFontFace(io::fs_path_to_string(resource_path(filename)), fallback);
}
bool sInitialized = false;
+7
View File
@@ -740,6 +740,8 @@ static void fapGm_AfterRecord() {
fapGm_After();
}
BOOL isRecording = false;
static void duskExecute() {
handleGamepadColor();
updateAutoSave();
@@ -747,6 +749,11 @@ static void duskExecute() {
if (dusk::getSettings().game.recordingMode) {
Z2GetSoundMgr()->getSeqMgr()->getParams()->moveVolume(0.0f, 0);
Z2GetSoundMgr()->getStreamMgr()->getParams()->moveVolume(0.0f, 0);
isRecording = true;
} else if (isRecording) {
Z2GetSoundMgr()->getSeqMgr()->getParams()->moveVolume(1.0f, 0);
Z2GetSoundMgr()->getStreamMgr()->getParams()->moveVolume(1.0f, 0);
isRecording = false;
}
if (mDoCPd_c::getHoldR(PAD_1) && mDoCPd_c::getTrigX(PAD_1)) {
+75 -17
View File
@@ -71,6 +71,7 @@
#include <dolphin/dvd.h>
#include "SDL3/SDL_filesystem.h"
#include "SDL3/SDL_iostream.h"
#include "SDL3/SDL_misc.h"
#include "cxxopts.hpp"
#include "d/actor/d_a_movie_player.h"
@@ -78,6 +79,7 @@
#include "dusk/audio/DuskDsp.hpp"
#include "dusk/config.hpp"
#include "dusk/settings.h"
#include "dusk/io.hpp"
#include "dusk/version.hpp"
#include "dusk/discord_presence.hpp"
#include "tracy/Tracy.hpp"
@@ -129,7 +131,7 @@ bool dusk::OpenDataFolder() {
std::filesystem::path path = std::filesystem::absolute(ConfigPath, ec);
if (ec) {
DuskLog.warn("Failed to resolve absolute data folder path '{}': {}",
ConfigPath.string(), ec.message());
io::fs_path_to_string(ConfigPath), ec.message());
path = ConfigPath;
}
@@ -139,7 +141,8 @@ bool dusk::OpenDataFolder() {
const std::string url = "file://" + path.generic_string();
#endif
if (!SDL_OpenURL(url.c_str())) {
DuskLog.warn("Failed to open data folder '{}': {}", path.string(), SDL_GetError());
DuskLog.warn(
"Failed to open data folder '{}': {}", io::fs_path_to_string(path), SDL_GetError());
return false;
}
return true;
@@ -509,16 +512,21 @@ static void EnsureInitialPipelineCache(const std::filesystem::path& configDir) {
return;
}
const char* basePath = SDL_GetBasePath();
if (basePath == nullptr) {
DuskLog.warn("Unable to resolve base path while seeding pipeline cache: {}", SDL_GetError());
return;
}
std::string sourcePathString;
SDL_IOStream* source = nullptr;
const std::filesystem::path initialPipelineCachePath =
std::filesystem::path(basePath) / "initial_pipeline_cache.db";
if (!std::filesystem::exists(initialPipelineCachePath)) {
DuskLog.info("No bundled initial pipeline cache found at '{}'", initialPipelineCachePath.string());
const char* basePath = SDL_GetBasePath();
if (basePath != nullptr) {
sourcePathString = dusk::io::fs_path_to_string(
std::filesystem::path(basePath) / "initial_pipeline_cache.db");
source = SDL_IOFromFile(sourcePathString.c_str(), "rb");
}
if (source == nullptr) {
sourcePathString = "initial_pipeline_cache.db";
source = SDL_IOFromFile(sourcePathString.c_str(), "rb");
}
if (source == nullptr) {
DuskLog.info("No bundled initial pipeline cache found");
return;
}
@@ -526,18 +534,68 @@ static void EnsureInitialPipelineCache(const std::filesystem::path& configDir) {
std::filesystem::create_directories(configDir, ec);
if (ec) {
DuskLog.warn("Failed to create config directory '{}' for pipeline cache: {}",
configDir.string(), ec.message());
dusk::io::fs_path_to_string(configDir), ec.message());
SDL_CloseIO(source);
return;
}
std::filesystem::copy_file(initialPipelineCachePath, pipelineCachePath, std::filesystem::copy_options::none, ec);
if (ec) {
DuskLog.warn("Failed to seed pipeline cache from '{}' to '{}': {}",
initialPipelineCachePath.string(), pipelineCachePath.string(), ec.message());
const auto pipelineCacheString = dusk::io::fs_path_to_string(pipelineCachePath);
SDL_IOStream* destination = SDL_IOFromFile(pipelineCacheString.c_str(), "wb");
if (destination == nullptr) {
DuskLog.warn("Failed to open '{}' for seeded pipeline cache: {}", pipelineCacheString,
SDL_GetError());
SDL_CloseIO(source);
return;
}
DuskLog.info("Seeded pipeline cache from '{}'", initialPipelineCachePath.string());
bool copied = true;
std::array<char, 64 * 1024> buffer{};
while (true) {
const size_t bytesRead = SDL_ReadIO(source, buffer.data(), buffer.size());
if (bytesRead > 0) {
size_t bytesWritten = 0;
while (bytesWritten < bytesRead) {
const size_t written = SDL_WriteIO(
destination, buffer.data() + bytesWritten, bytesRead - bytesWritten);
if (written == 0) {
DuskLog.warn("Failed to write seeded pipeline cache '{}': {}",
pipelineCacheString, SDL_GetError());
copied = false;
break;
}
bytesWritten += written;
}
}
if (!copied) {
break;
}
if (bytesRead < buffer.size()) {
if (SDL_GetIOStatus(source) == SDL_IO_STATUS_EOF) {
break;
}
DuskLog.warn(
"Failed to read bundled pipeline cache '{}': {}", sourcePathString, SDL_GetError());
copied = false;
break;
}
}
if (!SDL_CloseIO(destination)) {
DuskLog.warn("Failed to close seeded pipeline cache '{}': {}",
dusk::io::fs_path_to_string(pipelineCachePath), SDL_GetError());
copied = false;
}
SDL_CloseIO(source);
if (!copied) {
std::filesystem::remove(pipelineCachePath, ec);
return;
}
DuskLog.info("Seeded pipeline cache from '{}'", sourcePathString);
}
static constexpr PADDefaultMapping defaultPadMapping = {