From de914d25f0bc01c930314488081c2475a53d2977 Mon Sep 17 00:00:00 2001 From: moonpower Date: Sat, 4 Apr 2026 05:45:59 +0200 Subject: [PATCH] fix state --- src/panda_sdl/frontend_sdl.cpp | 10 +++++-- src/panda_sdl/panda_fsui.cpp | 54 ++++++++++++++++++++++++++++++++++ third_party/fsui | 2 +- 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/src/panda_sdl/frontend_sdl.cpp b/src/panda_sdl/frontend_sdl.cpp index f9832475..8112745b 100644 --- a/src/panda_sdl/frontend_sdl.cpp +++ b/src/panda_sdl/frontend_sdl.cpp @@ -292,8 +292,6 @@ void FrontendSDL::initialize(SDL_Window* existingWindow, SDL_GLContext existingC imgui->setExitToSelectorCallback([this]() { returnToSelector = true; programRunning = false; - emu.reset(Emulator::ReloadOption::NoReload); - emu.romType = ROMType::None; }); #endif } @@ -749,6 +747,14 @@ bool FrontendSDL::consumeReturnToSelector() { return false; } returnToSelector = false; + emu.reset(Emulator::ReloadOption::NoReload); + emu.romType = ROMType::None; + emuPaused = false; +#ifdef IMGUI_FRONTEND + if (imgui) { + imgui->setPaused(false); + } +#endif return true; } #endif diff --git a/src/panda_sdl/panda_fsui.cpp b/src/panda_sdl/panda_fsui.cpp index 7d11308f..11618c48 100644 --- a/src/panda_sdl/panda_fsui.cpp +++ b/src/panda_sdl/panda_fsui.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -19,6 +20,7 @@ #include "IconsFontAwesome5.h" #include "IconsPromptFont.h" +#include "helpers.hpp" #include "config.hpp" #include "emulator.hpp" #include "frontend_settings.hpp" @@ -113,6 +115,56 @@ namespace return value; } + std::string percentEncodeUrl(std::string_view value) + { + std::string encoded; + encoded.reserve(value.size()); + for (unsigned char c : value) { + const bool unreserved = + (c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (c >= '0' && c <= '9') || + c == '-' || c == '_' || c == '.' || c == '~' || c == '/' || c == ':'; + if (unreserved) { + encoded.push_back(static_cast(c)); + } else { + static constexpr char hex[] = "0123456789ABCDEF"; + encoded.push_back('%'); + encoded.push_back(hex[c >> 4]); + encoded.push_back(hex[c & 0x0F]); + } + } + return encoded; + } + + std::string fileUrlForPath(const std::filesystem::path& path) + { + std::error_code ec; + const std::filesystem::path absolute = std::filesystem::absolute(path, ec); + const std::string generic = (ec || absolute.empty()) ? path.generic_string() : absolute.generic_string(); + std::string url = "file://"; + #ifdef _WIN32 + url.push_back('/'); + #endif + url += percentEncodeUrl(generic); + return url; + } + + bool openUrl(std::string_view url) + { + const std::string url_string(url); + if (SDL_OpenURL(url_string.c_str()) != 0) { + Helpers::warn("Failed to open URL %s: %s", url_string.c_str(), SDL_GetError()); + return false; + } + return true; + } + + bool openPathInBrowser(const std::filesystem::path& path) + { + return openUrl(fileUrlForPath(path)); + } + const char* windowIconFilename(FrontendSettings::WindowIcon icon) { switch (icon) { @@ -1332,6 +1384,8 @@ bool PandaFsuiAdapter::initialize(const fsui::FontStack& fonts) }; fsuiContext.host.detect_prompt_icon_pack = []() { return fsui::DetectPromptIconPackFromSDL(); }; fsuiContext.host.detect_swap_north_west_gamepad_buttons = []() { return false; }; + fsuiContext.host.open_file_browser = [this](const std::filesystem::path& path) { openPathInBrowser(path); }; + fsuiContext.host.open_url = [](std::string_view url) { openUrl(url); }; fsuiContext.host.runtime_overlay_options = fsui::RuntimeOverlayOptions{ .show_inputs = true, .show_settings = true, diff --git a/third_party/fsui b/third_party/fsui index 31ca34f5..199f7422 160000 --- a/third_party/fsui +++ b/third_party/fsui @@ -1 +1 @@ -Subproject commit 31ca34f55626d8932d3cd4fd7887a48ef896e23d +Subproject commit 199f7422032f48dbdd51574884ee6c8496035bba