Migrate to Borealis (#2266)

This commit is contained in:
Luke Street
2026-08-05 07:54:31 -06:00
committed by GitHub
parent 4604304305
commit 13b3b68fe5
94 changed files with 654 additions and 14091 deletions
+2 -2
View File
@@ -16,7 +16,7 @@ std::string mod_image_source(const mods::LoadedMod& mod, std::string_view bundle
#include <SDL3/SDL_iostream.h>
#include <SDL3/SDL_surface.h>
#include <aurora/lib/logging.hpp>
#include <borealis/log.hpp>
#include <aurora/rmlui.hpp>
#include <cstddef>
@@ -34,7 +34,7 @@ std::string mod_image_source(const mods::LoadedMod& mod, std::string_view bundle
namespace dusk::ui {
namespace {
aurora::Module Log{"dusk::ui::modTexture"};
constexpr borealis::Log Log{"dusk::ui::modTexture"};
constexpr std::string_view kScheme = "mod";
constexpr std::string_view kSourcePrefix = "mod://";
+2 -2
View File
@@ -1,6 +1,6 @@
#include "overlay.hpp"
#include "aurora/lib/logging.hpp"
#include <borealis/log.hpp>
#include "controller_config.hpp"
#include "dusk/achievements.h"
#include "dusk/action_bindings.h"
@@ -24,7 +24,7 @@
namespace dusk::ui {
namespace {
aurora::Module Log{"dusk::ui::overlay"};
constexpr borealis::Log Log{"dusk::ui::overlay"};
const Rml::String kDocumentSource = R"RML(
<rml>
+60 -50
View File
@@ -1,23 +1,23 @@
#include "prelaunch.hpp"
#include "dusk/app_info.hpp"
#include "dusk/config.hpp"
#include "dusk/data.hpp"
#include "dusk/file_select.hpp"
#include "dusk/iso_validate.hpp"
#include "dusk/main.h"
#include "dusk/settings.h"
#include "dusk/update_check.hpp"
#include "modal.hpp"
#include "mods_window.hpp"
#include "preset.hpp"
#include "settings.hpp"
#include "version.h"
#include <SDL3/SDL_dialog.h>
#include <SDL3/SDL_error.h>
#include <SDL3/SDL_misc.h>
#include <aurora/lib/logging.hpp>
#include <aurora/lib/window.hpp>
#include <borealis/file_select.hpp>
#include <borealis/log.hpp>
#include <borealis/update.hpp>
#include <borealis/version.h>
#include <fmt/format.h>
#include <algorithm>
@@ -32,7 +32,7 @@
namespace dusk::ui {
namespace {
aurora::Module PrelaunchLog{"dusk::ui::prelaunch"};
constexpr borealis::Log PrelaunchLog{"dusk::ui::prelaunch"};
const Rml::String kDocumentSource = R"RML(
<rml>
@@ -72,10 +72,10 @@ const Rml::String kDocumentSource = R"RML(
</rml>
)RML";
constexpr std::array<SDL_DialogFileFilter, 2> kDiscFileFilters{{
const std::vector<borealis::file_select::Filter> kDiscFileFilters{
{"Game Disc Images", "iso;gcm;ciso;gcz;nfs;rvz;wbfs;wia;tgc"},
{"All Files", "*"},
}};
};
struct DiscVerificationResult {
std::string path;
@@ -102,7 +102,7 @@ struct DiscVerificationTask {
}
~DiscVerificationTask() {
status.shouldCancel.store(true, std::memory_order_relaxed);
status.cancelRequested.store(true, std::memory_order_relaxed);
join();
}
@@ -129,15 +129,15 @@ struct UpdateCheckTask {
UpdateCheckTask() {
worker = std::thread([this] {
try {
result = update_check::check_latest_github_release("TwilitRealm", "dusklight");
result = borealis::update::check_latest_github_release(AppInfo);
} catch (const std::exception& e) {
result = {
.status = update_check::Status::Failed,
.status = borealis::update::Status::Failed,
.message = fmt::format("Update check failed with exception: {}", e.what()),
};
} catch (...) {
result = {
.status = update_check::Status::Failed,
.status = borealis::update::Status::Failed,
.message = "Update check failed with an unknown exception",
};
}
@@ -155,13 +155,13 @@ struct UpdateCheckTask {
[[nodiscard]] bool finished() const { return done.load(std::memory_order_acquire); }
update_check::Result result;
borealis::update::Result result;
std::atomic_bool done = false;
std::thread worker;
};
std::unique_ptr<UpdateCheckTask> sUpdateCheckTask;
std::optional<update_check::Result> sUpdateCheckResult;
std::optional<borealis::update::Result> sUpdateCheckResult;
bool verification_state_allows_launch(iso::ValidationError validation) noexcept {
return validation == iso::ValidationError::Unknown ||
@@ -212,7 +212,7 @@ void begin_disc_verification(std::string path) noexcept {
return;
}
if (sDiscVerificationTask != nullptr) {
sDiscVerificationTask->status.shouldCancel.store(true, std::memory_order_relaxed);
sDiscVerificationTask->status.cancelRequested.store(true, std::memory_order_relaxed);
sDiscVerificationTask.reset();
}
sDiscVerificationTask = std::make_unique<DiscVerificationTask>(std::move(path));
@@ -244,7 +244,7 @@ void begin_update_check() {
sUpdateCheckTask = std::make_unique<UpdateCheckTask>();
}
std::optional<update_check::Result> take_finished_update_check() {
std::optional<borealis::update::Result> take_finished_update_check() {
if (sUpdateCheckTask == nullptr || !sUpdateCheckTask->finished()) {
return std::nullopt;
}
@@ -255,7 +255,7 @@ std::optional<update_check::Result> take_finished_update_check() {
return result;
}
std::string update_release_label(const update_check::Release& release) {
std::string update_release_label(const borealis::update::Release& release) {
std::string_view tagName = release.tagName;
if (!tagName.empty() && tagName.front() == 'v') {
tagName.remove_prefix(1);
@@ -265,7 +265,7 @@ std::string update_release_label(const update_check::Release& release) {
void open_update_release() {
if (!sUpdateCheckResult.has_value() ||
sUpdateCheckResult->status != update_check::Status::UpdateAvailable)
sUpdateCheckResult->status != borealis::update::Status::UpdateAvailable)
{
return;
}
@@ -438,7 +438,7 @@ private:
}
mCancelRequested = true;
sDiscVerificationTask->status.shouldCancel.store(true, std::memory_order_relaxed);
sDiscVerificationTask->status.cancelRequested.store(true, std::memory_order_relaxed);
if (mCancelButton != nullptr) {
mCancelButton->set_text("Cancelling...");
mCancelButton->set_disabled(true);
@@ -455,7 +455,7 @@ private:
}
if (mFileName != nullptr) {
std::string fileName = display_name_for_path(sDiscVerificationTask->path);
std::string fileName = borealis::file_select::display_name(sDiscVerificationTask->path);
if (fileName.empty()) {
fileName = sDiscVerificationTask->path;
}
@@ -496,12 +496,15 @@ private:
bool mFinished = false;
};
void file_dialog_callback(void*, const char* path, const char* error) {
if (path == nullptr || error != nullptr) {
void file_dialog_callback(borealis::file_select::Result result) {
if (result.status != borealis::file_select::Status::Selected || result.locations.empty()) {
if (result.status == borealis::file_select::Status::Failed) {
PrelaunchLog.warn("File selection failed: {}", result.message);
}
return;
}
begin_disc_verification(path);
begin_disc_verification(result.locations.front());
}
PrelaunchState sPrelaunchState;
@@ -649,8 +652,12 @@ void ensure_initialized() noexcept {
void open_iso_picker() noexcept {
ensure_initialized();
ShowFileSelect(&file_dialog_callback, nullptr, aurora::window::get_sdl_window(),
kDiscFileFilters.data(), kDiscFileFilters.size(), nullptr, false);
borealis::file_select::open_file(
{
.parentWindow = aurora::window::get_sdl_window(),
.filters = kDiscFileFilters,
},
&file_dialog_callback);
}
bool is_restart_pending() noexcept {
@@ -888,32 +895,35 @@ void Prelaunch::update() {
Rml::String innerRML = "";
switch (state.activeDiscInfo.platform) {
case iso::Platform::GameCube:
innerRML += "GameCube";
break;
case iso::Platform::Wii:
innerRML += "Wii";
break;
case iso::Platform::Unknown:
innerRML += "Unknown";
break;
case iso::Platform::GameCube:
innerRML += "GameCube";
break;
case iso::Platform::Wii:
innerRML += "Wii";
break;
}
innerRML += "";
switch (state.activeDiscInfo.region) {
case iso::Region::Japan:
innerRML += "JPN";
break;
case iso::Region::Europe:
innerRML += "EUR";
break;
case iso::Region::NorthAmerica:
innerRML += "USA";
break;
case iso::Region::Korea:
innerRML += "KOR";
break;
default:
innerRML += "Unknown";
break;
case iso::Region::Japan:
innerRML += "JPN";
break;
case iso::Region::Europe:
innerRML += "EUR";
break;
case iso::Region::NorthAmerica:
innerRML += "USA";
break;
case iso::Region::Korea:
innerRML += "KOR";
break;
default:
innerRML += "Unknown";
break;
}
mDiscDetail->SetInnerRML(innerRML);
} else {
@@ -921,7 +931,7 @@ void Prelaunch::update() {
}
}
if (mVersion != nullptr) {
std::string_view versionStr(DUSK_WC_DESCRIBE);
std::string_view versionStr(BOREALIS_APP_DESCRIBE);
if (versionStr[0] == 'v') {
versionStr = versionStr.substr(1);
}
@@ -929,7 +939,7 @@ void Prelaunch::update() {
}
if (mUpdateStatus != nullptr && mUpdateMessage != nullptr) {
if (auto result = take_finished_update_check()) {
if (result->status == update_check::Status::Failed) {
if (result->status == borealis::update::Status::Failed) {
PrelaunchLog.error("Failed to check for updates: {}", result->message);
}
sUpdateCheckResult = std::move(*result);
@@ -939,11 +949,11 @@ void Prelaunch::update() {
mUpdateStatus->SetAttribute("state", "checking");
mUpdateMessage->SetInnerRML("Checking for updates...");
} else if (!sUpdateCheckResult.has_value() ||
sUpdateCheckResult->status == update_check::Status::UpToDate)
sUpdateCheckResult->status == borealis::update::Status::UpToDate)
{
mUpdateStatus->RemoveAttribute("state");
mUpdateMessage->SetInnerRML("");
} else if (sUpdateCheckResult->status == update_check::Status::UpdateAvailable) {
} else if (sUpdateCheckResult->status == borealis::update::Status::UpdateAvailable) {
mUpdateStatus->SetAttribute("state", "available");
mUpdateMessage->SetInnerRML("Update available!");
if (mUpdateDownloadLabel != nullptr) {
+4 -4
View File
@@ -1,11 +1,11 @@
#if DUSK_ENABLE_SENTRY_NATIVE
#if BOREALIS_HAS_SENTRY
#include "reporting.hpp"
#include "button.hpp"
#include "dusk/crash_reporting.h"
#include "ui.hpp"
#include <borealis/sentry.hpp>
#include <dolphin/gx/GXAurora.h>
namespace dusk::ui {
@@ -45,11 +45,11 @@ CrashReportWindow::CrashReportWindow() : WindowSmall("modal", "modal-dialog") {
{"Enable",
"Send crash reports to Dusklight developers. Reports will include the information described "
"above.",
[] { crash_reporting::set_consent(true); }},
[] { borealis::sentry::set_consent(true); }},
{"Disable",
"Do not send crash reports. This may make it more difficult to resolve issues you "
"encounter.",
[] { crash_reporting::set_consent(false); }},
[] { borealis::sentry::set_consent(false); }},
};
for (const auto& option : kOptions) {
+1 -1
View File
@@ -1,6 +1,6 @@
#pragma once
#if DUSK_ENABLE_SENTRY_NATIVE
#if BOREALIS_HAS_SENTRY
#include "component.hpp"
#include "window.hpp"
+65 -56
View File
@@ -6,13 +6,14 @@
#include "dusk/app_info.hpp"
#include "dusk/audio/DuskAudioSystem.h"
#include "dusk/audio/DuskDsp.hpp"
#include "dusk/android_frame_rate.hpp"
#include "dusk/config.hpp"
#include "dusk/hotkeys.h"
#include "dusk/data.hpp"
#include "dusk/file_select.hpp"
#include "dusk/imgui/ImGuiEngine.hpp"
#include "dusk/io.hpp"
#include "dusk/presentation.hpp"
#include <borealis/io.hpp>
#include <borealis/file_select.hpp>
#include "dusk/livesplit.h"
#include "dusk/discord_presence.hpp"
#include "dusk/speedrun.h"
@@ -31,8 +32,8 @@
#include <SDL3/SDL_filesystem.h>
#include <fmt/format.h>
#if DUSK_ENABLE_SENTRY_NATIVE
#include "dusk/crash_reporting.h"
#if BOREALIS_HAS_SENTRY
#include <borealis/sentry.hpp>
#endif
#include <algorithm>
@@ -225,7 +226,7 @@ Rml::String configured_data_path_display_name() {
return "(none)";
}
auto display = display_name_for_path(path);
auto display = borealis::file_select::display_name(path);
if (display.empty()) {
return path;
}
@@ -274,17 +275,17 @@ void show_data_folder_error_modal(std::string_view message) {
}
}
void data_folder_dialog_callback(void*, const char* path, const char* error) {
if (error != nullptr) {
show_data_folder_error_modal(error);
void data_folder_dialog_callback(borealis::file_select::Result result) {
if (result.status == borealis::file_select::Status::Canceled) {
return;
}
if (path == nullptr) {
if (result.status != borealis::file_select::Status::Selected || result.locations.empty()) {
show_data_folder_error_modal("Dusklight could not open the folder picker.");
return;
}
std::string dataPathError;
if (data::set_custom_data_path(path, &dataPathError)) {
if (data::set_custom_data_path(result.locations.front(), &dataPathError)) {
mDoAud_seStartMenu(kSoundItemChange);
return;
}
@@ -487,7 +488,7 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
if (path.empty()) {
display = "(none)";
} else {
display = display_name_for_path(path);
display = borealis::file_select::display_name(path);
if (display.empty()) {
display = path;
}
@@ -506,49 +507,56 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
pane.add_rml("Set the disc image that Dusklight uses to launch the game.<br/><br/>"
"Changes require a restart.");
});
#if DUSK_CAN_CHANGE_DATA_FOLDER
leftPane.register_control(
leftPane.add_select_button({
.key = "Data Folder",
.getValue = [] { return configured_data_path_display_name(); },
.isModified = [] { return data::is_data_path_restart_pending(); },
}),
rightPane, [](Pane& pane) {
pane.add_text("The data folder is where Dusklight stores settings, saves, "
"logs, texture replacements, and other app data.");
pane.add_child<DataFolderPathText>();
if (data::manager().capabilities().canChangeLocation &&
borealis::file_select::capabilities().canOpenFolder)
{
leftPane.register_control(
leftPane.add_select_button({
.key = "Data Folder",
.getValue = [] { return configured_data_path_display_name(); },
.isModified = [] { return data::is_data_path_restart_pending(); },
}),
rightPane, [](Pane& pane) {
pane.add_text("The data folder is where Dusklight stores settings, saves, "
"logs, texture replacements, and other app data.");
pane.add_child<DataFolderPathText>();
#if DUSK_CAN_OPEN_DATA_FOLDER
pane.add_button("Open Data Folder").on_pressed([] {
if (data::open_data_path()) {
mDoAud_seStartMenu(kSoundClick);
}
});
pane.add_button("Open Data Folder").on_pressed([] {
if (data::open_data_path()) {
mDoAud_seStartMenu(kSoundClick);
}
});
#endif
pane.add_button("Change Data Folder").on_pressed([] {
const auto defaultLocation =
io::fs_path_to_string(data::configured_data_path());
ShowFolderSelect(&data_folder_dialog_callback, nullptr,
aurora::window::get_sdl_window(),
defaultLocation.empty() ? nullptr : defaultLocation.c_str());
});
pane.add_button("Change Data Folder").on_pressed([] {
const auto defaultLocation =
borealis::io::fs_path_to_string(data::configured_data_path());
borealis::file_select::open_folder(
{
.parentWindow = aurora::window::get_sdl_window(),
.defaultLocation = defaultLocation,
},
&data_folder_dialog_callback);
});
#if defined(_WIN32)
pane.add_button("Portable Mode").on_pressed([] {
if (data::set_portable_data_path()) {
mDoAud_seStartMenu(kSoundItemChange);
}
});
pane.add_button("Portable Mode").on_pressed([] {
if (data::set_portable_data_path()) {
mDoAud_seStartMenu(kSoundItemChange);
}
});
#endif
pane.add_button({
.text = "Reset to Default",
.isDisabled = [] { return data::is_default_data_path(); },
}).on_pressed([] {
if (data::reset_data_path()) {
mDoAud_seStartMenu(kSoundItemChange);
}
pane.add_button(
{
.text = "Reset to Default",
.isDisabled = [] { return data::is_default_data_path(); },
})
.on_pressed([] {
if (data::reset_data_path()) {
mDoAud_seStartMenu(kSoundItemChange);
}
});
pane.add_rml("Data will be migrated automatically on restart.");
});
pane.add_rml("Data will be migrated automatically on restart.");
});
#endif
}
leftPane.register_control(
leftPane.add_select_button({
.key = "Language",
@@ -857,7 +865,7 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
.on_pressed([i] {
mDoAud_seStartMenu(kSoundItemChange);
getSettings().game.enableFrameInterpolation.setValue(static_cast<FrameInterpMode>(i));
android::update_surface_frame_rate();
presentation::update_frame_rate_preference();
config::save();
});
}
@@ -866,7 +874,7 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
config_int_select(leftPane, rightPane, getSettings().video.maxFrameRate,
"Framerate Cap", "Limit the framerate to the specified value.", 30, 540, 1,
[] { return getSettings().game.enableFrameInterpolation.getValue() != FrameInterpMode::Capped; },
[](int) { android::update_surface_frame_rate(); });
[](int) { presentation::update_frame_rate_preference(); });
config_bool_select(leftPane, rightPane, getSettings().game.enableMapBackground,
{
.key = "Enable Mini-Map Shadows",
@@ -1415,15 +1423,16 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
});
pane.add_rml("<br/>Choose which notifications can be displayed.");
});
#if DUSK_ENABLE_SENTRY_NATIVE
#if BOREALIS_HAS_SENTRY
auto& crashReporting = leftPane.add_child<BoolButton>(BoolButton::Props{
.key = "Crash Reporting",
.getValue =
[] { return crash_reporting::get_consent() == crash_reporting::Consent::Given; },
.setValue = [](bool enabled) { crash_reporting::set_consent(enabled); },
[] { return borealis::sentry::get_consent() == borealis::sentry::Consent::Given; },
.setValue = [](bool enabled) { borealis::sentry::set_consent(enabled); },
.isDisabled =
[] {
return crash_reporting::get_consent() == crash_reporting::Consent::Unavailable;
return borealis::sentry::get_consent() ==
borealis::sentry::Consent::Unavailable;
},
.isModified = [] { return false; },
});
@@ -1447,7 +1456,7 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
.helpText = "Checks GitHub releases for a new Dusklight version on startup.<br/><br/>"
"No personal information is transmitted or collected.",
});
#ifdef DUSK_DISCORD
#if BOREALIS_HAS_DISCORD
config_bool_select(leftPane, rightPane, getSettings().game.enableDiscordPresence,
{
.key = "Enable Discord Rich Presence",
+2 -1
View File
@@ -17,6 +17,7 @@
#include "aurora/lib/window.hpp"
#include "dusk/config.hpp"
#include "dusk/io.hpp"
#include <borealis/io.hpp>
#include "icon_provider.hpp"
#include "input.hpp"
#include "mod_texture_provider.hpp"
@@ -27,7 +28,7 @@ namespace dusk::ui {
namespace {
void load_font(const char* filename, bool fallback = false) {
Rml::LoadFontFace(io::fs_path_to_string(resource_path(filename)), fallback);
Rml::LoadFontFace(borealis::io::fs_path_to_string(resource_path(filename)), fallback);
}
bool sInitialized = false;