#include "prelaunch.hpp" #include "dusk/config.hpp" #include "dusk/file_select.hpp" #include "dusk/iso_validate.hpp" #include "dusk/main.h" #include "dusk/ui/prelaunch_options.hpp" #include "version.h" #include #include #include namespace dusk::ui { namespace { const Rml::String kDocumentSource = R"RML(
Twilit Realm presents
Version
Update available! Download
)RML"; constexpr std::array kDiscFileFilters{{ {"Game Disc Images", "iso;gcm;ciso;gcz;nfs;rvz;wbfs;wia;tgc"}, {"All Files", "*"}, }}; void file_dialog_callback(void*, const char* path, const char* error) { auto& state = prelaunch_state(); if (error != nullptr) { return; } if (path == nullptr) { return; } state.selectedIsoPath = path; state.errorString.clear(); refresh_path_state(); getSettings().backend.isoPath.setValue(state.selectedIsoPath); config::Save(); } } // namespace PrelaunchState sPrelaunchState; PrelaunchState& prelaunch_state() noexcept { return sPrelaunchState; } void refresh_path_state() noexcept { auto& state = prelaunch_state(); state.isPal = !state.selectedIsoPath.empty() && iso::isPal(state.selectedIsoPath.c_str()); } void ensure_initialized() noexcept { auto& state = prelaunch_state(); if (state.initialized) { return; } state.selectedIsoPath = getSettings().backend.isoPath; state.initialGraphicsBackend = getSettings().backend.graphicsBackend; state.errorString.clear(); state.initialized = true; refresh_path_state(); } bool is_selected_path_valid() noexcept { return !prelaunch_state().selectedIsoPath.empty() && SDL_GetPathInfo(prelaunch_state().selectedIsoPath.c_str(), nullptr); } void open_iso_picker() noexcept { ensure_initialized(); ShowFileSelect(&file_dialog_callback, nullptr, aurora::window::get_sdl_window(), kDiscFileFilters.data(), static_cast(kDiscFileFilters.size()), nullptr, false); } void apply_intro_animation(Rml::Element* element, const char* delay_class) { if (element == nullptr || delay_class == nullptr) { return; } element->SetClass("intro-item", true); element->SetClass(delay_class, true); } Prelaunch::Prelaunch() : Document(kDocumentSource), mRoot(mDocument->GetElementById("root")) { ensure_initialized(); if (auto* menuList = mDocument->GetElementById("menu-list")) { const bool hasValidPath = is_selected_path_valid(); mMenuButtons.push_back( std::make_unique