From 3dcadf29bea060dd43465047edccedeb7d9bc992 Mon Sep 17 00:00:00 2001 From: PCSX2 Bot Date: Tue, 10 Nov 2026 00:01:25 +0000 Subject: [PATCH] [ci skip] Qt: Update Base Translation. --- pcsx2-qt/Translations/pcsx2-qt_en.ts | 630 ++++---- pcsx2/ImGui/FullscreenUI.cpp | 2189 +------------------------- 2 files changed, 297 insertions(+), 2522 deletions(-) diff --git a/pcsx2-qt/Translations/pcsx2-qt_en.ts b/pcsx2-qt/Translations/pcsx2-qt_en.ts index 3d7c5b1ad3..c45169930a 100644 --- a/pcsx2-qt/Translations/pcsx2-qt_en.ts +++ b/pcsx2-qt/Translations/pcsx2-qt_en.ts @@ -7493,7 +7493,7 @@ The URL was: %1 FullscreenUI - + Could not find any CD/DVD-ROM devices. Please ensure you have a drive connected and sufficient permissions to access it. @@ -7568,37 +7568,37 @@ The URL was: %1 - + No save present in this slot. - + No save states found. - + Failed to delete save state. - + Failed to copy text to clipboard. - + This game has no achievements. - + This game has no leaderboards. - + Reset System @@ -7609,22 +7609,22 @@ The URL was: %1 - + Launch a game from images scanned from your game directories. - + Launch a game by selecting a file/disc image. - + Start the console without any disc inserted. - + Start a game from a disc in your PC's DVD drive. @@ -7669,7 +7669,7 @@ The URL was: %1 - + Options @@ -8609,7 +8609,7 @@ Enter the name for the new input profile: - + Failed to Save State @@ -8681,7 +8681,7 @@ Supported formats: PNG, JPG, JPEG, BMP. - + {0} Slot {1} @@ -8884,44 +8884,44 @@ Please check your username and password, and try again. - + Change Selection - + Select - + Parent Directory - + Enter Value - + About - + Toggle Fullscreen - + Navigate - + Load Global State @@ -8931,27 +8931,27 @@ Please check your username and password, and try again. - + Return To Game - + Select State - + Select Game - + Change View - + Launch Options @@ -8996,53 +8996,53 @@ Please check your username and password, and try again. - + Start Game - + Launch a game from a file, disc, or starts the console without any disc inserted. - + Changes settings for the application. - + Return to desktop mode, or exit the application. - + Back - + Return to the previous menu. - + Exit PCSX2 - + Completely exits the application, returning you to your desktop. - + Desktop Mode - + Exits Big Picture mode, returning to the desktop interface. @@ -9332,7 +9332,7 @@ Please check your username and password, and try again. - + Settings @@ -9468,7 +9468,7 @@ Please check your username and password, and try again. - + Load State @@ -9618,84 +9618,84 @@ Please check your username and password, and try again. - + Save State - + Load Resume State - + A resume save state created at %s was found. Do you want to load this save and continue? - + Region: - + Compatibility: - + No Game Selected - + Search Directories - + Adds a new directory to the game search list. - + Scanning Subdirectories - + Not Scanning Subdirectories - + List Settings - + Sets which view the game list will open to. - + Determines which field the game list will be sorted by. - + Reverses the game list sort order from the default (usually ascending to descending). - + Only displays games marked as favorites in the list and grid. - + Operations @@ -9706,27 +9706,27 @@ Do you want to load this save and continue? - + Identifies any new files added to the game directories. - + Forces a full rescan of all games previously identified. - + About PCSX2 - + PCSX2 is a free and open-source PlayStation 2 (PS2) emulator. Its purpose is to emulate the PS2's hardware, using a combination of MIPS CPU Interpreters, Recompilers and a Virtual Machine which manages hardware states and PS2 system memory. This allows you to play PS2 games on your PC, with many additional features and benefits. - + PlayStation 2 and PS2 are registered trademarks of Sony Interactive Entertainment. This application is not affiliated in any way with Sony Interactive Entertainment. @@ -9751,7 +9751,7 @@ Do you want to load this save and continue? - + Error @@ -9906,19 +9906,19 @@ Do you want to load this save and continue? - + An error occurred while deleting empty game settings: {} - + An error occurred while saving game settings: {} - + {} is not a valid disc image. @@ -10003,62 +10003,62 @@ Do you want to load this save and continue? - + This Session: {} - + All Time: {} - + Save Slot {0} - + Saved {} - + {} does not exist. - + {} deleted. - + Failed to delete {}. - + File: {} - + CRC: {:08X} - + Time Played: {} - + Last Played: {} - + Size: {:.2f} MB @@ -10372,7 +10372,7 @@ Do you want to load this save and continue? - + Your memory card is still saving data. WARNING: Shutting down now can IRREVERSIBLY CORRUPT YOUR MEMORY CARD. @@ -10443,12 +10443,12 @@ Do you want to shutdown anyway and IRREVERSIBLY CORRUPT YOUR MEMORY CARD? - + empty title - + no serial @@ -10698,7 +10698,7 @@ Do you want to shutdown anyway and IRREVERSIBLY CORRUPT YOUR MEMORY CARD? - + Shows Titles for Games when in Game Grid View Mode @@ -10740,7 +10740,7 @@ Your password will not be saved in PCSX2, an access token will be generated and - + Are you sure you want to reset the play time for '{}' ({})? Your current play time is {}. @@ -10749,17 +10749,17 @@ This action cannot be undone. - + Failed to Load State From Backup Slot {} - + Failed to Load State From Slot {} - + Failed to Save State To Slot {} @@ -11916,17 +11916,17 @@ which produces much nicer sound during fast-forward/slowdown. - + Load/Save State - + Startup Error - + WARNING: Memory Card Busy @@ -11996,7 +11996,7 @@ which produces much nicer sound during fast-forward/slowdown. - + Full Boot @@ -12621,106 +12621,106 @@ which produces much nicer sound during fast-forward/slowdown. - + Game Grid - + Game List - + Scanning for new games... - + Recording - + Game List Settings - + Capture - + Type - + Serial - + Title - + File Title - + CRC - + Time Played - + Last Played - + Size - + Select Disc Image - + Select Disc Drive - + Start File - + Start BIOS - + Start Disc - + Exit @@ -12875,7 +12875,7 @@ which produces much nicer sound during fast-forward/slowdown. - + Fast Boot @@ -12896,7 +12896,7 @@ which produces much nicer sound during fast-forward/slowdown. - + Cancel @@ -13182,87 +13182,92 @@ which produces much nicer sound during fast-forward/slowdown. - + Resume Game - + Toggle Frame Limit - + Achievements - + Save Screenshot - + Switch To Software Renderer - + Switch To Hardware Renderer - + Change Disc - + Close Game - + Exit Without Saving - + Back To Pause Menu - + Exit And Save State - + Leaderboards - + + Game Properties + + + + Delete Save - + Close Menu - + Delete State - + Default Boot - + Download Failed @@ -13282,27 +13287,27 @@ which produces much nicer sound during fast-forward/slowdown. - + PCSX2 can automatically download covers for games which do not currently have a cover set. We do not host any cover images, the user must provide their own source for images. - + Enter one or more cover image URL templates below. Variables such as ${serial} and ${title} are supported. See the Qt Cover Downloader for more information. - + URLs: - + Saves covers using the game's title instead of serial number. - + Downloading covers... @@ -13312,17 +13317,17 @@ which produces much nicer sound during fast-forward/slowdown. - + Version: {} - + Error: {} - + Warning: {} @@ -13338,172 +13343,152 @@ which produces much nicer sound during fast-forward/slowdown. - + Cover Downloader - + Refresh List - + Emulation - + Stop Recording - + Start Recording - + Global Settings - - Game Properties (Edit) - - - - - Game Properties (New) - - - - + Remove from Favorites - + Add to Favorites - - Default Boot (Custom settings) - - - - - Default Boot (Global settings) - - - - + Reset Play Time - + Confirm Reset - + Add Search Directory - + Open in File Browser - + Disable Subdirectory Scanning - + Enable Subdirectory Scanning - + Remove From List - + Default View - + Sort By - + Sort Reversed - + Show Titles - + Favorites Only - + Scan For New Games - + Rescan All Games - + Website - + Support Forums - + GitHub Repository - + License - + Close - + Use Title File Names - + Stop - + Start @@ -13523,7 +13508,7 @@ which produces much nicer sound during fast-forward/slowdown. - + Failed to Load State @@ -14641,7 +14626,6 @@ accuracy, but this may increase system requirements. - %n hours @@ -14650,7 +14634,6 @@ accuracy, but this may increase system requirements. - %n minutes @@ -14667,52 +14650,52 @@ accuracy, but this may increase system requirements. GameListModel - + Type - + Code - + Title - + File Title - + CRC - + Time Played - + Last Played - + Size - + Region - + Compatibility @@ -20225,13 +20208,13 @@ Right click to clear binding - - + + Change Disc - + Load State @@ -20704,7 +20687,7 @@ Right click to clear binding - + Start Big Picture &Mode @@ -20773,7 +20756,6 @@ Right click to clear binding - Game &Properties @@ -20824,7 +20806,7 @@ Right click to clear binding - + Big Picture In Toolbar @@ -20996,15 +20978,15 @@ Are you sure you want to continue? - - - - - - - - - + + + + + + + + + Error @@ -21014,294 +20996,304 @@ Are you sure you want to continue? - + + Properties... + + + + Set Cover Image... - + Create Game Shortcut... - + Exclude From List - + Remove from Favorites - + Add to Favorites - + Reset Play Time - + Check Wiki Page - + Open Memory Card Folder - + Open Texture Dump/Replacement Folder - + Open Video Capture Folder - + + Default Boot + + + + Fast Boot - + Full Boot - + Boot and Debug - + Add Search Directory... - + Start File - + Start Disc - + Select Disc Image - + Updater Error - + <p>Sorry, you are trying to update a PCSX2 version which is not an official GitHub release. To prevent incompatibilities, the auto-updater is only enabled on official builds.</p><p>To obtain an official build, please download from the link below:</p><p><a href="https://pcsx2.net/downloads/">https://pcsx2.net/downloads/</a></p> - + Automatic updating is not supported on the current platform. - + Downloading Controller Tester - + Confirm File Creation - + The pnach file '%1' does not currently exist. Do you want to create it? - + Failed to create '%1'. - + Input Recording Failed - + Failed to create file: {} - + Select a File - + Input Recording Files (*.p2m2) - + Input Playback Failed - + Failed to open file: {} - + Paused - + Load State Failed - + Cannot load a save state without a running VM. - + The new ELF cannot be loaded without resetting the virtual machine. Do you want to reset the virtual machine now? - + Cannot change from game to GS dump without shutting down first. - + Failed to get window info from widget - + Stop Big Picture Mode - + Exit Big Picture In Toolbar - + Game Properties - + Game properties is unavailable for the current game. - + Could not find any CD/DVD-ROM devices. Please ensure you have a drive connected and sufficient permissions to access it. - + Select disc drive: - + This save state does not exist. - + Select Cover Image - + Cover Already Exists - + A cover image for this game already exists, do you wish to replace it? - - - - + + + + Copy Error - + Failed to remove existing cover '%1' - + Failed to copy '%1' to '%2' - + Failed to remove '%1' - - + + Confirm Reset - + Open Snapshots Folder - + All Cover Image Types (*.jpg *.jpeg *.png *.webp) - + You must select a different file to the current cover image. - + Failed to create snapshots directory '%1' Opening default directory. - + Load Resume State - + A resume save state was found for this game, saved at: %1. @@ -21310,43 +21302,43 @@ Do you want to load this state, or start from a fresh boot? - + Fresh Boot - + Delete And Boot - + Failed to delete save state file '%1'. - + Load State File... - + Load From File... - - + + Select Save State File - + Load Backup Slot %1 (%2) - + %n save states deleted. @@ -21354,12 +21346,12 @@ Do you want to load this state, or start from a fresh boot? - + Save States (*.p2s) - + Delete Save States... @@ -21374,27 +21366,7 @@ Do you want to load this state, or start from a fresh boot? - - Properties... (Edit) - - - - - Properties... (New) - - - - - Default Boot (Custom settings) - - - - - Default Boot (Global settings) - - - - + Are you sure you want to reset the play time for '%1' (%2)? Your current play time is %3. @@ -21403,104 +21375,94 @@ This action cannot be undone. - + empty title - + no serial - + Failed to create game texture directory '%1' Opening default directory. - + Failed to open memory card directory. - + Failed to create game video capture directory '%1' Opening default directory. - + Save States (*.p2s *.p2s.backup) - + Resume (%2) - + Load Slot %1 (%2) + - Delete Save States - + Are you sure you want to delete all save states for %1? The saves will not be recoverable. - + Save To File... - + Empty - + Save Slot %1 (%2) - - Game &Properties (Edit) - - - - - Game &Properties (New) - - - - + Confirm Disc Change - + Do you want to swap discs or boot the new image (via system reset)? - + Swap Disc - + Reset diff --git a/pcsx2/ImGui/FullscreenUI.cpp b/pcsx2/ImGui/FullscreenUI.cpp index cf4bde98d5..f6a3212b81 100644 --- a/pcsx2/ImGui/FullscreenUI.cpp +++ b/pcsx2/ImGui/FullscreenUI.cpp @@ -4365,2201 +4365,14 @@ TRANSLATE_NOOP("FullscreenUI", "Toggle Frame Limit"); TRANSLATE_NOOP("FullscreenUI", "Switch To Software Renderer"); TRANSLATE_NOOP("FullscreenUI", "Switch To Hardware Renderer"); TRANSLATE_NOOP("FullscreenUI", "Change Disc"); -TRANSLATE_NOOP("FullscreenUI", "ICON_FA_WRENCH, game_properties_string.c_str()) : - FSUI_ICONSTR(ICON_FA_SLIDERS, )), - ImGui::GetCurrentWindow()); - - if (ActiveButton(FSUI_ICONSTR(ICON_PF_BACKWARD, ), false) || WantsToCloseMenu()) - { - OpenPauseSubMenu(PauseSubMenu::None); - break; - } - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_WRENCH, game_properties_string.c_str()), false, can_change_game_settings)) - SwitchToGameSettings(); - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_SLIDERS, ), false)) - SwitchToSettings(); - } - break; - } - - EndMenuButtons(); - - if (!ImGui::IsPopupOpen(0u, ImGuiPopupFlags_AnyPopup)) - ImGui::NavMoveRequestTryWrapping(ImGui::GetCurrentWindow(), ImGuiNavMoveFlags_LoopY); - - // Draw achievements before ending the window so they stay below the header. - if (Achievements::HasAchievementsOrLeaderboards()) - Achievements::DrawPauseMenuOverlays(); - - EndFullscreenWindow(); - } - - const std::string_view back_text = (submenu == PauseSubMenu::None) ? FSUI_VSTR() : FSUI_VSTR(); - if (IsGamepadInputSource()) - { - const bool circleOK = ImGui::GetIO().ConfigNavSwapGamepadButtons; - const auto glyphs = GetGamepadGlyphs(); - SetFullscreenFooterText(std::array{ - std::make_pair(glyphs.dpad_ud, FSUI_VSTR()), - std::make_pair(glyphs.confirm(circleOK), FSUI_VSTR()), - std::make_pair(glyphs.cancel(circleOK), back_text), - }); - } - else - { - SetFullscreenFooterText(std::array{ - std::make_pair(ICON_PF_ARROW_UP ICON_PF_ARROW_DOWN, FSUI_VSTR()), - std::make_pair(ICON_PF_ENTER, FSUI_VSTR()), - std::make_pair(ICON_PF_ESC, back_text), - }); - } -} - -void FullscreenUI::InitializePlaceholderSaveStateListEntry(SaveStateListEntry* li, s32 slot) -{ - li->title = fmt::format(, TinyString::from_format(FSUI_FSTR(), slot), slot); - li->summary = FSUI_STR(); - li->path = {}; - li->timestamp = 0; - li->slot = slot; - li->preview_texture = {}; -} - -bool FullscreenUI::InitializeSaveStateListEntry( - SaveStateListEntry* li, const std::string& title, const std::string& serial, u32 crc, s32 slot, bool backup) -{ - std::string filename(VMManager::GetSaveStateFileName(serial.c_str(), crc, slot, backup)); - FILESYSTEM_STAT_DATA sd; - if (filename.empty() || !FileSystem::StatFile(filename.c_str(), &sd)) - { - InitializePlaceholderSaveStateListEntry(li, slot); - return false; - } - - li->title = fmt::format(, TinyString::from_format(FSUI_FSTR(), backup ? : , slot), slot); - li->summary = fmt::format(FSUI_FSTR(), TimeToPrintableString(sd.ModificationTime)); - li->slot = slot; - li->timestamp = sd.ModificationTime; - li->path = std::move(filename); - - li->preview_texture.reset(); - - u32 screenshot_width, screenshot_height; - std::vector screenshot_pixels; - if (SaveState_ReadScreenshot(li->path, &screenshot_width, &screenshot_height, &screenshot_pixels)) - { - li->preview_texture = - std::unique_ptr(g_gs_device->CreateTexture(screenshot_width, screenshot_height, 1, GSTexture::Format::Color)); - if (!li->preview_texture || !li->preview_texture->Update(GSVector4i(0, 0, screenshot_width, screenshot_height), - screenshot_pixels.data(), sizeof(u32) * screenshot_width)) - { - Console.Error(); - if (li->preview_texture) - g_gs_device->Recycle(li->preview_texture.release()); - } - } - - return true; -} - -void FullscreenUI::ClearSaveStateEntryList() -{ - for (SaveStateListEntry& entry : s_save_state_selector_slots) - { - if (entry.preview_texture) - s_cleanup_textures.push_back(std::move(entry.preview_texture)); - } - s_save_state_selector_slots.clear(); -} - -u32 FullscreenUI::PopulateSaveStateListEntries(const std::string& title, const std::string& serial, u32 crc) -{ - ClearSaveStateEntryList(); - - for (s32 i = 1; i <= VMManager::NUM_SAVE_STATE_SLOTS; i++) - { - SaveStateListEntry li; - if (InitializeSaveStateListEntry(&li, title, serial, crc, i) || !s_save_state_selector_loading) - s_save_state_selector_slots.push_back(std::move(li)); - - if (s_save_state_selector_loading) - { - SaveStateListEntry bli; - if (InitializeSaveStateListEntry(&bli, title, serial, crc, i, true)) - s_save_state_selector_slots.push_back(std::move(bli)); - } - } - - return static_cast(s_save_state_selector_slots.size()); -} - -bool FullscreenUI::OpenLoadStateSelectorForGame(const std::string& game_path) -{ - auto lock = GameList::GetLock(); - const GameList::Entry* entry = GameList::GetEntryForPath(game_path.c_str()); - if (entry) - { - s_save_state_selector_loading = true; - if (PopulateSaveStateListEntries(entry->title.c_str(), entry->serial.c_str(), entry->crc) > 0) - { - s_save_state_selector_open = true; - s_save_state_selector_resuming = false; - s_save_state_selector_game_path = game_path; - return true; - } - } - - ShowToast(ICON_FA_FLOPPY_DISK, FSUI_STR(), 5.0f); - return false; -} - -bool FullscreenUI::OpenSaveStateSelector(bool is_loading) -{ - s_save_state_selector_game_path = {}; - s_save_state_selector_loading = is_loading; - s_save_state_selector_resuming = false; - if (PopulateSaveStateListEntries(s_current_game_title.c_str(), s_current_disc_serial.c_str(), s_current_disc_crc) > 0) - { - s_save_state_selector_open = true; - return true; - } - - ShowToast(ICON_FA_FLOPPY_DISK, FSUI_STR(), 5.0f); - return false; -} - -void FullscreenUI::CloseSaveStateSelector() -{ - ClearSaveStateEntryList(); - s_save_state_selector_open = false; - s_save_state_selector_submenu_index = -1; - s_save_state_selector_loading = false; - s_save_state_selector_resuming = false; - s_save_state_selector_game_path = {}; -} - -void FullscreenUI::DrawSaveStateSelector(bool is_loading) -{ - ImGuiIO& io = ImGui::GetIO(); - const float title_line_height = GetLineHeight(g_large_font); - const float summary_line_height = GetLineHeight(g_medium_font); - - ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f)); - ImGui::SetNextWindowSize(io.DisplaySize - LayoutScale(0.0f, LAYOUT_FOOTER_HEIGHT)); - - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); - ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); - ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 0.0f); - ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f); - - const char* window_title = is_loading ? FSUI_CSTR() : FSUI_CSTR(); - ImGui::OpenPopup(window_title); - - bool is_open = true; - const bool valid = ImGui::BeginPopupModal(window_title, &is_open, - ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | - ImGuiWindowFlags_NoBackground); - if (!valid || !is_open) - { - if (valid) - ImGui::EndPopup(); - - ImGui::PopStyleVar(5); - if (!is_open) - { - CloseSaveStateSelector(); - ReturnToPreviousWindow(); - } - return; - } - - const ImVec2 heading_size = - ImVec2(io.DisplaySize.x, title_line_height + - (LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f)); - - ImGui::PushStyleColor(ImGuiCol_ChildBg, ModAlpha(UIPrimaryColor, 0.9f)); - - if (ImGui::BeginChild(, heading_size, ImGuiChildFlags_NavFlattened, 0)) - { - BeginNavBar(); - if (NavButton(ICON_PF_BACKWARD, true, true)) - { - CloseSaveStateSelector(); - ReturnToPreviousWindow(); - } - - NavTitle(is_loading ? FSUI_CSTR() : FSUI_CSTR()); - EndNavBar(); - ImGui::EndChild(); - } - - ImGui::PopStyleColor(); - ImGui::PushStyleColor(ImGuiCol_ChildBg, ModAlpha(UIBackgroundColor, VMManager::HasValidVM() ? 0.0f : 0.9f)); - ImGui::SetCursorPos(ImVec2(0.0f, heading_size.y)); - - bool close_handled = false; - if (s_save_state_selector_open && - ImGui::BeginChild(, ImVec2(io.DisplaySize.x, io.DisplaySize.y - LayoutScale(LAYOUT_FOOTER_HEIGHT) - heading_size.y), - ImGuiChildFlags_NavFlattened, 0)) - { - BeginMenuButtons(); - - const ImGuiStyle& style = ImGui::GetStyle(); - - const float title_spacing = LayoutScale(10.0f); - const float summary_spacing = LayoutScale(4.0f); - const float item_spacing = LayoutScale(20.0f); - const float item_width_with_spacing = std::floor(LayoutScale(LAYOUT_SCREEN_WIDTH / 4.0f)); - const float item_width = item_width_with_spacing - item_spacing; - const float image_width = item_width - (style.FramePadding.x * 2.0f); - const float image_height = image_width / 1.33f; - const ImVec2 image_size(image_width, image_height); - const float item_height = (style.FramePadding.y * 2.0f) + image_height + title_spacing + title_line_height + summary_spacing + - summary_line_height; - const ImVec2 item_size(item_width, item_height); - const u32 grid_count_x = std::floor(ImGui::GetWindowWidth() / item_width_with_spacing); - const float start_x = - (static_cast(ImGui::GetWindowWidth()) - (item_width_with_spacing * static_cast(grid_count_x))) * 0.5f; - - u32 grid_x = 0; - for (u32 i = 0; i < s_save_state_selector_slots.size();) - { - if (i == 0) - ResetFocusHere(); - - if (static_cast(i) == s_save_state_selector_submenu_index) - { - SaveStateListEntry& entry = s_save_state_selector_slots[i]; - - // can't use a choice dialog here, because we're already in a modal... - ImGuiFullscreen::PushResetLayout(); - ImGui::PushFont(g_large_font.first, g_large_font.second); - ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING, LAYOUT_MENU_BUTTON_Y_PADDING)); - ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); - ImGui::PushStyleColor(ImGuiCol_Text, UIPrimaryTextColor); - ImGui::PushStyleColor(ImGuiCol_TitleBg, UIPrimaryDarkColor); - ImGui::PushStyleColor(ImGuiCol_TitleBgActive, UIPrimaryColor); - ImGui::PushStyleColor(ImGuiCol_PopupBg, UIPopupBackgroundColor); - - const float width = LayoutScale(600.0f); - const float title_height = - ImGui::GetFrameHeight() + ImGui::GetStyle().WindowPadding.y * 2.0f; - // Use the same rounding and padding as the menu buttons. - const float button_height = LayoutScale(ImGuiFullscreen::LayoutUnscale(title_line_height)) + - LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f; - const float height = title_height + button_height * 3.0f; - ImGui::SetNextWindowSize(ImVec2(width, height)); - ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); - ImGui::OpenPopup(entry.title.c_str()); - - // don't let the back button flow through to the main window - bool submenu_open = !WantsToCloseMenu(); - close_handled ^= submenu_open; - - bool closed = false; - if (ImGui::BeginPopupModal( - entry.title.c_str(), &is_open, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove)) - { - ImGui::PushStyleColor(ImGuiCol_Text, UIBackgroundTextColor); - - BeginMenuButtons(); - - if (ActiveButton( - is_loading ? FSUI_ICONSTR(ICON_FA_FOLDER_OPEN, ) : FSUI_ICONSTR(ICON_FA_FOLDER_OPEN, ), - false, is_loading ? !Achievements::IsHardcoreModeActive() : true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY)) - { - if (is_loading) - DoLoadState(std::move(entry.path), entry.slot, false); - else - DoSaveState(entry.slot); - - CloseSaveStateSelector(); - ReturnToMainWindow(); - closed = true; - } - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_TRASH, ), false, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY)) - { - if (!FileSystem::FileExists(entry.path.c_str())) - { - ShowToast(ICON_FA_TRIANGLE_EXCLAMATION, fmt::format(FSUI_FSTR(), ImGuiFullscreen::RemoveHash(entry.title))); - is_open = true; - } - else if (FileSystem::DeleteFilePath(entry.path.c_str())) - { - ShowToast(ICON_FA_TRASH, fmt::format(FSUI_FSTR(), ImGuiFullscreen::RemoveHash(entry.title))); - if (s_save_state_selector_loading) - s_save_state_selector_slots.erase(s_save_state_selector_slots.begin() + i); - else - InitializePlaceholderSaveStateListEntry(&entry, entry.slot); - - // Close if this was the last state. - if (s_save_state_selector_slots.empty()) - { - CloseSaveStateSelector(); - ReturnToMainWindow(); - closed = true; - } - else - { - is_open = false; - } - } - else - { - ShowToast(ICON_FA_TRIANGLE_EXCLAMATION, fmt::format(FSUI_FSTR(), ImGuiFullscreen::RemoveHash(entry.title))); - is_open = false; - } - } - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_SQUARE_XMARK, ), false, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY)) - { - is_open = false; - } - - EndMenuButtons(); - - ImGui::PopStyleColor(); - ImGui::EndPopup(); - } - if (!is_open) - { - s_save_state_selector_submenu_index = -1; - if (!closed) - QueueResetFocus(FocusResetType::WindowChanged); - } - - ImGui::PopStyleColor(4); - ImGui::PopStyleVar(3); - ImGui::PopFont(); - ImGuiFullscreen::PopResetLayout(); - - if (closed || i >= s_save_state_selector_slots.size()) - break; - } - - ImGuiWindow* window = ImGui::GetCurrentWindow(); - if (window->SkipItems) - { - i++; - continue; - } - - if (grid_x == grid_count_x) - { - grid_x = 0; - ImGui::SetCursorPosX(start_x); - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + item_spacing); - } - else - { - ImGui::SameLine(start_x + static_cast(grid_x) * (item_width + item_spacing)); - } - - const SaveStateListEntry& entry = s_save_state_selector_slots[i]; - const ImGuiID id = window->GetID(static_cast(i)); - const ImVec2 pos(window->DC.CursorPos); - ImRect bb(pos, pos + item_size); - ImGui::ItemSize(item_size); - if (ImGui::ItemAdd(bb, id)) - { - bool held; - bool hovered; - bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held, 0); - if (hovered) - { - const ImU32 col = ImGui::GetColorU32(held ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered, 0.7f); - - const float t = std::min(std::abs(std::sin(ImGui::GetTime() * 0.75) * 1.1), 1.0f); - ImGui::PushStyleColor(ImGuiCol_Border, ImGui::GetColorU32(ImGuiCol_Border, t)); - - ImGuiFullscreen::DrawMenuButtonFrame(bb.Min, bb.Max, col, true, 0.0f); - - ImGui::PopStyleColor(); - } - - bb.Min += style.FramePadding; - bb.Max -= style.FramePadding; - - const GSTexture* const screenshot = entry.preview_texture ? entry.preview_texture.get() : GetPlaceholderTexture().get(); - const ImRect image_rect(CenterImage(ImRect(bb.Min, bb.Min + image_size), - ImVec2(static_cast(screenshot->GetWidth()), static_cast(screenshot->GetHeight())))); - - ImGui::GetWindowDrawList()->AddImage(reinterpret_cast(screenshot->GetNativeHandle()), - image_rect.Min, image_rect.Max, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), - entry.preview_texture ? IM_COL32_WHITE : ImGui::GetColorU32(UIBackgroundTextColor)); - - const ImVec2 title_pos(bb.Min.x, bb.Min.y + image_height + title_spacing); - const ImRect title_bb(title_pos, ImVec2(bb.Max.x, title_pos.y + title_line_height)); - ImGui::PushFont(g_large_font.first, g_large_font.second); - ImGuiFullscreen::RenderTextClippedWithShadow( - title_bb.Min, title_bb.Max, entry.title.c_str(), nullptr, nullptr, ImVec2(0.0f, 0.0f), &title_bb); - ImGui::PopFont(); - - if (!entry.summary.empty()) - { - const ImVec2 summary_pos(bb.Min.x, title_bb.Max.y + summary_spacing); - const ImRect summary_bb(summary_pos, ImVec2(bb.Max.x, summary_pos.y + summary_line_height)); - ImGui::PushFont(g_medium_font.first, g_medium_font.second); - ImGuiFullscreen::RenderTextClippedWithShadow( - summary_bb.Min, summary_bb.Max, entry.summary.c_str(), nullptr, nullptr, ImVec2(0.0f, 0.0f), &summary_bb); - ImGui::PopFont(); - } - - if (pressed) - { - if (is_loading) - DoLoadState(entry.path, entry.slot, false); - else - DoSaveState(entry.slot); - - CloseSaveStateSelector(); - ReturnToMainWindow(); - break; - } - else if (hovered && (ImGui::IsItemClicked(ImGuiMouseButton_Right) || ImGui::Shortcut(ImGuiKey_NavGamepadMenu) || - ImGui::Shortcut(ImGuiKey_F1))) - { - s_save_state_selector_submenu_index = static_cast(i); - } - } - - grid_x++; - i++; - } - - EndMenuButtons(); - ImGui::EndChild(); - } - - ImGui::PopStyleColor(); - - ImGui::EndPopup(); - ImGui::PopStyleVar(5); - - if (!close_handled && WantsToCloseMenu()) - { - CloseSaveStateSelector(); - ReturnToPreviousWindow(); - } - else - { - if (IsGamepadInputSource()) - { - const bool circleOK = ImGui::GetIO().ConfigNavSwapGamepadButtons; - const bool swapNorthWest = ImGuiManager::IsGamepadNorthWestSwapped(); - const auto glyphs = GetGamepadGlyphs(); - SetFullscreenFooterText(std::array{ - std::make_pair(glyphs.dpad, FSUI_VSTR()), - std::make_pair(swapNorthWest ? glyphs.north : glyphs.west, FSUI_VSTR()), - std::make_pair(glyphs.confirm(circleOK), FSUI_VSTR()), - std::make_pair(glyphs.cancel(circleOK), FSUI_VSTR()), - }); - } - else - { - SetFullscreenFooterText(std::array{ - std::make_pair(ICON_PF_ARROW_UP ICON_PF_ARROW_DOWN ICON_PF_ARROW_LEFT ICON_PF_ARROW_RIGHT, FSUI_VSTR()), - std::make_pair(ICON_PF_F1, FSUI_VSTR()), - std::make_pair(ICON_PF_ENTER, FSUI_VSTR()), - std::make_pair(ICON_PF_ESC, FSUI_VSTR()), - }); - } - } -} - -bool FullscreenUI::OpenLoadStateSelectorForGameResume(const GameList::Entry* entry) -{ - SaveStateListEntry slentry; - if (!InitializeSaveStateListEntry(&slentry, entry->title, entry->serial, entry->crc, -1)) - return false; - - CloseSaveStateSelector(); - s_save_state_selector_slots.push_back(std::move(slentry)); - s_save_state_selector_game_path = entry->path; - s_save_state_selector_loading = true; - s_save_state_selector_open = true; - s_save_state_selector_resuming = true; - return true; -} - -void FullscreenUI::DrawResumeStateSelector() -{ - ImGui::SetNextWindowSize(LayoutScale(800.0f, 600.0f)); - ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); - ImGui::OpenPopup(FSUI_CSTR()); - - ImGui::PushFont(g_large_font.first, g_large_font.second); - ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, LayoutScale(20.0f, 20.0f)); - - bool is_open = true; - if (ImGui::BeginPopupModal(FSUI_CSTR(), &is_open, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar)) - { - const SaveStateListEntry& entry = s_save_state_selector_slots.front(); - ImGui::TextWrapped(FSUI_CSTR(), - TimeToPrintableString(entry.timestamp).c_str()); - - const GSTexture* image = entry.preview_texture ? entry.preview_texture.get() : GetPlaceholderTexture().get(); - const float image_height = LayoutScale(250.0f); - const float image_width = image_height * (static_cast(image->GetWidth()) / static_cast(image->GetHeight())); - const ImVec2 pos(ImGui::GetCursorScreenPos() + - ImVec2((ImGui::GetCurrentWindow()->WorkRect.GetWidth() - image_width) * 0.5f, LayoutScale(20.0f))); - const ImRect image_bb(pos, pos + ImVec2(image_width, image_height)); - ImGui::GetWindowDrawList()->AddImage(reinterpret_cast(image->GetNativeHandle()), image_bb.Min, image_bb.Max, - ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), entry.preview_texture ? IM_COL32_WHITE : ImGui::GetColorU32(UIBackgroundTextColor)); - - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + image_height + LayoutScale(40.0f)); - - BeginMenuButtons(); - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_PLAY, ), false)) - { - DoStartPath(s_save_state_selector_game_path, -1); - is_open = false; - } - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_COMPACT_DISC, ), false)) - { - DoStartPath(s_save_state_selector_game_path); - is_open = false; - } - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_TRASH, ), false)) - { - if (FileSystem::DeleteFilePath(entry.path.c_str())) - { - DoStartPath(s_save_state_selector_game_path); - is_open = false; - } - else - { - ShowToast(ICON_FA_TRIANGLE_EXCLAMATION, FSUI_STR()); - } - } - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_SQUARE_XMARK, ), false) || WantsToCloseMenu()) - { - ImGui::CloseCurrentPopup(); - is_open = false; - } - EndMenuButtons(); - - ImGui::EndPopup(); - } - - ImGui::PopStyleVar(2); - ImGui::PopFont(); - - if (!is_open) - { - ClearSaveStateEntryList(); - s_save_state_selector_open = false; - s_save_state_selector_loading = false; - s_save_state_selector_resuming = false; - s_save_state_selector_game_path = {}; - } - else - { - SetStandardSelectionFooterText(false); - } -} - -void FullscreenUI::DoLoadState(std::string path, std::optional slot, bool backup) -{ - std::string boot_path = s_save_state_selector_game_path; - Host::RunOnCPUThread([boot_path = std::move(boot_path), path = std::move(path), slot, backup]() { - if (VMManager::HasValidVM()) - { - Error error; - if (!VMManager::LoadState(path.c_str(), &error)) - { - ReportStateLoadError(error.GetDescription(), slot, backup); - return; - } - - if (!boot_path.empty() && VMManager::GetDiscPath() != boot_path) - VMManager::ChangeDisc(CDVD_SourceType::Iso, std::move(boot_path)); - } - else - { - VMBootParameters params; - params.filename = std::move(boot_path); - params.save_state = std::move(path); - DoVMInitialize(params, false); - } - }); -} - -void FullscreenUI::DoSaveState(s32 slot) -{ - Host::RunOnCPUThread([slot]() { - VMManager::SaveStateToSlot(slot, true, [slot](const std::string& error) { - ReportStateSaveError(error, slot); - }); - }); -} - -void FullscreenUI::PopulateGameListEntryList() -{ - const int sort = Host::GetBaseIntSettingValue(, , 0); - const bool reverse = Host::GetBaseBoolSettingValue(, , false); - const bool favorites_only = Host::GetBaseBoolSettingValue(, , false); - static int s_last_sort = -1; - static bool s_last_reverse = false; - static bool s_last_prefer_eng = false; - static bool s_last_favorites_only = false; - - // Sort can be expensive, try to avoid when possible - const u32 count = GameList::GetEntryCount(); - bool needs_update = s_game_list_needs_sort || sort != s_last_sort || reverse != s_last_reverse || - s_last_prefer_eng != s_prefer_english_titles || favorites_only != s_last_favorites_only; - needs_update |= count != s_last_unsorted_entries.size(); - if (!needs_update) - { - for (u32 i = 0; i < count; i++) - { - if (GameList::GetEntryByIndex(i) != s_last_unsorted_entries[i]) - { - needs_update = true; - break; - } - } - } - - if (!needs_update) - return; - s_game_list_needs_sort = false; - - s_last_sort = sort; - s_last_reverse = reverse; - s_last_prefer_eng = s_prefer_english_titles; - s_last_favorites_only = favorites_only; - - s_game_list_sorted_entries.resize(count); - s_last_unsorted_entries.resize(count); - for (u32 i = 0; i < count; i++) - { - s_game_list_sorted_entries[i] = GameList::GetEntryByIndex(i); - s_last_unsorted_entries[i] = s_game_list_sorted_entries[i]; - } - if (favorites_only) - { - s_game_list_sorted_entries.erase( - std::remove_if(s_game_list_sorted_entries.begin(), s_game_list_sorted_entries.end(), - [](const GameList::Entry* entry) { return !entry->is_favorite; }), - s_game_list_sorted_entries.end()); - } - - std::sort(s_game_list_sorted_entries.begin(), s_game_list_sorted_entries.end(), - [sort, reverse](const GameList::Entry* lhs, const GameList::Entry* rhs) { - if (lhs->is_favorite != rhs->is_favorite) - return lhs->is_favorite; - - switch (sort) - { - case 0: // Type - { - if (lhs->type != rhs->type) - return reverse ? (lhs->type > rhs->type) : (lhs->type < rhs->type); - } - break; - - case 1: // Serial - { - if (lhs->serial != rhs->serial) - return reverse ? (lhs->serial > rhs->serial) : (lhs->serial < rhs->serial); - } - break; - - case 2: // Title - break; - - case 3: // File Title - { - const std::string_view lhs_title(Path::GetFileTitle(lhs->path)); - const std::string_view rhs_title(Path::GetFileTitle(rhs->path)); - const int res = - StringUtil::Strncasecmp(lhs_title.data(), rhs_title.data(), std::min(lhs_title.size(), rhs_title.size())); - if (res != 0) - return reverse ? (res > 0) : (res < 0); - } - break; - - case 4: // CRC - { - if (lhs->crc != rhs->crc) - return reverse ? (lhs->crc > rhs->crc) : (lhs->crc < rhs->crc); - } - break; - - case 5: // Time Played - { - if (lhs->total_played_time != rhs->total_played_time) - { - return reverse ? (lhs->total_played_time > rhs->total_played_time) : - (lhs->total_played_time < rhs->total_played_time); - } - } - break; - - case 6: // Last Played (reversed by default) - { - if (lhs->last_played_time != rhs->last_played_time) - { - return reverse ? (lhs->last_played_time < rhs->last_played_time) : (lhs->last_played_time > rhs->last_played_time); - } - } - break; - - case 7: // Size - { - if (lhs->total_size != rhs->total_size) - { - return reverse ? (lhs->total_size > rhs->total_size) : (lhs->total_size < rhs->total_size); - } - } - break; - } - - // fallback to title when all else is equal - const int res = Host::LocaleSensitiveCompare(lhs->GetTitleSort(s_prefer_english_titles), rhs->GetTitleSort(s_prefer_english_titles)); - return reverse ? (res > 0) : (res < 0); - }); -} - -void FullscreenUI::DrawGameListWindow() -{ - auto game_list_lock = GameList::GetLock(); - PopulateGameListEntryList(); - - ImGuiIO& io = ImGui::GetIO(); - const ImVec2 heading_size = - ImVec2(io.DisplaySize.x, GetLineHeight(g_large_font) + - (LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f)); - - const float bg_alpha = VMManager::HasValidVM() ? 0.90f : 1.0f; - - if (BeginFullscreenWindow(ImVec2(0.0f, 0.0f), heading_size, , MulAlpha(UIPrimaryColor, bg_alpha))) - { - static constexpr float ITEM_WIDTH = 25.0f; - static constexpr const char* icons[] = {ICON_FA_BORDER_ALL, ICON_FA_LIST}; - static constexpr const char* titles[] = {FSUI_NSTR(), FSUI_NSTR()}; - static constexpr u32 count = std::size(titles); - - BeginNavBar(); - - if (NavButton(ICON_PF_BACKWARD, true, true)) - SwitchToLanding(); - - NavTitle(Host::TranslateToCString(TR_CONTEXT, titles[static_cast(s_game_list_view)])); - RightAlignNavButtons(count, ITEM_WIDTH, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY); - - for (u32 i = 0; i < count; i++) - { - if (NavButton(icons[i], static_cast(i) == s_game_list_view, true, ITEM_WIDTH, - LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY)) - { - s_game_list_view = static_cast(i); - } - } - - EndNavBar(); - } - - EndFullscreenWindow(); - - if (ImGui::IsKeyPressed(ImGuiKey_NavGamepadContextMenu, false) || ImGui::IsKeyPressed(ImGuiKey_F1, false)) - { - s_game_list_view = (s_game_list_view == GameListView::Grid) ? GameListView::List : GameListView::Grid; - } - else if (ImGui::IsKeyPressed(ImGuiKey_GamepadStart, false) || ImGui::IsKeyPressed(ImGuiKey_F2)) - { - s_current_main_window = MainWindowType::GameListSettings; - QueueResetFocus(FocusResetType::WindowChanged); - } - else if (ImGui::IsKeyPressed(ImGuiKey_GamepadBack, false) || ImGui::IsKeyPressed(ImGuiKey_F4, false)) - { - OpenCoverDownloaderWindow(); - } - else if (ImGui::IsKeyPressed(ImGuiKey_GamepadL2, false) || ImGui::IsKeyPressed(ImGuiKey_F5, false)) - { - ShowToast(std::string(), FSUI_STR(), 4.0f); - Host::RefreshGameListAsync(false); - } - - switch (s_game_list_view) - { - case GameListView::Grid: - DrawGameGrid(heading_size); - break; - case GameListView::List: - DrawGameList(heading_size); - break; - default: - break; - } - - if (VMManager::GetState() != VMState::Shutdown) - { - // Dummy window to prevent interacting with the game list while loading. - ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); - ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize); - ImGui::SetNextWindowPos(ImVec2(0, 0)); - ImGui::SetNextWindowBgAlpha(0.25f); - ImGui::Begin(, nullptr, ImGuiWindowFlags_NoDecoration); - ImGui::End(); - ImGui::PopStyleColor(); - } - - if (IsGamepadInputSource()) - { - const bool circleOK = ImGui::GetIO().ConfigNavSwapGamepadButtons; - const bool swapNorthWest = ImGuiManager::IsGamepadNorthWestSwapped(); - const auto glyphs = GetGamepadGlyphs(); - SetFullscreenFooterText(std::array{ - std::make_pair(glyphs.dpad, FSUI_VSTR()), - std::make_pair(glyphs.select, FSUI_VSTR()), - std::make_pair(glyphs.start, FSUI_VSTR()), - std::make_pair(ICON_PF_LEFT_TRIGGER_L2, FSUI_VSTR()), - std::make_pair(swapNorthWest ? glyphs.west : glyphs.north, FSUI_VSTR()), - std::make_pair(swapNorthWest ? glyphs.north : glyphs.west, FSUI_VSTR()), - std::make_pair(glyphs.confirm(circleOK), FSUI_VSTR()), - std::make_pair(glyphs.cancel(circleOK), FSUI_VSTR()), - }); - } - else - { - SetFullscreenFooterText(std::array{ - std::make_pair(ICON_PF_ARROW_UP ICON_PF_ARROW_DOWN ICON_PF_ARROW_LEFT ICON_PF_ARROW_RIGHT, FSUI_VSTR()), - std::make_pair(ICON_PF_F1, FSUI_VSTR()), - std::make_pair(ICON_PF_F2, FSUI_VSTR()), - std::make_pair(ICON_PF_F3, FSUI_VSTR()), - std::make_pair(ICON_PF_F4, FSUI_VSTR()), - std::make_pair(ICON_PF_F5, FSUI_VSTR()), - std::make_pair(ICON_PF_ENTER, FSUI_VSTR()), - std::make_pair(ICON_PF_ESC, FSUI_VSTR()), - }); - } -} - -std::string_view FullscreenUI::TrimString(const std::pair& font, std::string_view str, float available_space) -{ - const char* beg = str.data(); - const char* end = beg + str.size(); - float full_width = font.first->CalcTextSizeA(font.second, INFINITY, 0, beg, end).x; - if (full_width <= available_space) - return str; - float ellipsis_width = font.first->CalcTextSizeA(font.second, INFINITY, 0.0f, g_ellipsis).x; - const char* trimmed = end; - font.first->CalcTextSizeA(font.second, available_space - ellipsis_width, 0, beg, end, &trimmed); - return std::string_view(beg, trimmed); -} - -void FullscreenUI::DrawGameList(const ImVec2& heading_size) -{ - ImGui::PushStyleColor(ImGuiCol_WindowBg, UIBackgroundColor); - - if (!BeginFullscreenColumns(nullptr, heading_size.y, true, true)) - { - EndFullscreenColumns(); - ImGui::PopStyleColor(); - return; - } - - if (!AreAnyDialogsOpen() && WantsToCloseMenu()) - SwitchToLanding(); - - const GameList::Entry* selected_entry = nullptr; - - if (BeginFullscreenColumnWindow(0.0f, -530.0f, )) - { - const float title_height = GetLineHeight(g_large_font); - const float spacing = LayoutScale(4.0f); - const ImVec2 image_size(LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT * 0.68f, LAYOUT_MENU_BUTTON_HEIGHT)); - const float item_height = std::max(LAYOUT_MENU_BUTTON_HEIGHT, - ImGuiFullscreen::LayoutUnscale(title_height + spacing + GetLineHeight(g_medium_font))); - - ResetFocusHere(); - - BeginMenuButtons(); - - // TODO: replace with something not heap allocating - std::string summary; - - for (const GameList::Entry* entry : s_game_list_sorted_entries) - { - ImRect bb; - bool visible, hovered; - bool pressed = MenuButtonFrame(entry->path.c_str(), true, item_height, &visible, &hovered, &bb.Min, &bb.Max); - if (!visible) - continue; - - summary.clear(); - if (entry->serial.empty()) - fmt::format_to(std::back_inserter(summary), , GameList::RegionToString(entry->region, true)); - else - fmt::format_to(std::back_inserter(summary), , entry->serial, GameList::RegionToString(entry->region, true)); - - const std::string_view filename(Path::GetFileName(entry->path)); - summary.append(filename); - - DrawGameCover(entry, ImGui::GetWindowDrawList(), bb.Min, bb.Min + image_size); - - const float midpoint = bb.Min.y + title_height + spacing; - const float text_start_x = bb.Min.x + image_size.x + LayoutScale(15.0f); - const ImRect title_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint)); - const ImRect summary_bb(ImVec2(text_start_x, midpoint), bb.Max); - const std::string& title = entry->GetTitle(s_prefer_english_titles); - - ImGui::PushFont(g_large_font.first, g_large_font.second); - const bool is_favorite = entry->is_favorite; - const bool has_custom_settings = entry->has_custom_settings; - const float icon_size = GetLineHeight(g_large_font) * 0.75f; - const float icon_margin = LayoutScale(8.0f); - ImRect visible_title_bb(title_bb); - if (is_favorite || has_custom_settings) - visible_title_bb.Max.x -= icon_size * 2.0f + icon_margin * 3.0f; - ImGui::RenderTextClipped(visible_title_bb.Min, visible_title_bb.Max, title.c_str(), title.c_str() + title.size(), nullptr, - ImVec2(0.0f, 0.0f), &visible_title_bb); - if (is_favorite) - { - const ImVec2 star_pos(title_bb.Max.x - icon_size - icon_margin, - title_bb.Min.y + (GetLineHeight(g_large_font) - icon_size) * 0.5f); - ImGui::GetWindowDrawList()->AddText(g_large_font.first, icon_size, - ImVec2(star_pos.x + LayoutScale(1.0f), star_pos.y + LayoutScale(1.0f)), IM_COL32(0, 0, 0, 200), ICON_PF_STAR); - ImGui::GetWindowDrawList()->AddText(g_large_font.first, icon_size, - star_pos, IM_COL32(255, 196, 0, 255), ICON_PF_STAR); - } - if (has_custom_settings) - { - const ImVec2 gear_pos(title_bb.Max.x - 2.0f * icon_size - 2.0f * icon_margin, - title_bb.Min.y + (GetLineHeight(g_large_font) - icon_size) * 0.5f); - ImGui::GetWindowDrawList()->AddText(g_large_font.first, icon_size, - ImVec2(gear_pos.x + LayoutScale(1.0f), gear_pos.y + LayoutScale(1.0f)), IM_COL32(0, 0, 0, 200), ICON_FA_GEAR); - ImGui::GetWindowDrawList()->AddText(g_large_font.first, icon_size, - gear_pos, IM_COL32(87, 181, 255, 255), ICON_FA_GEAR); - } - ImGui::PopFont(); - - if (!summary.empty()) - { - ImGui::PushFont(g_medium_font.first, g_medium_font.second); - ImGui::RenderTextClipped( - summary_bb.Min, summary_bb.Max, summary.c_str(), nullptr, nullptr, ImVec2(0.0f, 0.0f), &summary_bb); - ImGui::PopFont(); - } - - if (pressed) - HandleGameListActivate(entry); - - if (hovered) - selected_entry = entry; - - if (selected_entry && - (ImGui::IsItemClicked(ImGuiMouseButton_Right) || ImGui::Shortcut(ImGuiKey_NavGamepadMenu) || - ImGui::Shortcut(ImGuiKey_F3))) - { - HandleGameListOptions(selected_entry); - } - } - - EndMenuButtons(); - } - EndFullscreenColumnWindow(); - - if (BeginFullscreenColumnWindow(-530.0f, 0.0f, , UIPrimaryDarkColor)) - { - const float img_padding_y = LayoutScale(20.0f); - // Spacing between each text item - const float text_spacing_y = LayoutScale(8.0f); - // Space between title/serial and details, is in addition to text_spacing_y - const float title_padding_below_y = LayoutScale(12.0f); - const ImGuiWindow* window = ImGui::GetCurrentWindow(); - const float work_width = window->WorkRect.GetWidth(); - const float start_x = LayoutScale(50.0f); - const float wrap_pos = LayoutScale(490.0f); - const std::string_view full_title = selected_entry ? std::string_view(selected_entry->GetTitle(s_prefer_english_titles)) : - std::string_view(FSUI_CSTR()); - const std::string_view trimmed_title = TrimString(g_large_font, full_title, work_width); - const SmallString title = SmallString::from_format(, trimmed_title, trimmed_title.size() == full_title.size() ? : g_ellipsis); - const ImVec2 title_size = g_large_font.first->CalcTextSizeA(g_large_font.second, FLT_MAX, 0.0f, title.c_str()); - // Measure wrapping from the title's centered position. - const float title_wrap_width = std::max(1.0f, wrap_pos - (work_width - title_size.x) * 0.5f); - const float title_height = - g_large_font.first->CalcTextSizeA(g_large_font.second, FLT_MAX, title_wrap_width, title.c_str()).y; - // The filename can take more than one line. - const SmallString file_text = selected_entry ? SmallString::from_format(FSUI_FSTR(), Path::GetFileName(selected_entry->path)) : SmallString(); - const float file_wrap_width = std::max(1.0f, wrap_pos - start_x); - const float file_height = - g_medium_font.first->CalcTextSizeA(g_medium_font.second, FLT_MAX, file_wrap_width, file_text.c_str()).y; - const float summary_line_height = GetLineHeight(g_medium_font); - - // Leave room for the text below the cover. - const float title_detail_height = - title_height + text_spacing_y + // Title - summary_line_height + text_spacing_y + // Serial - title_padding_below_y + - file_height + text_spacing_y + // File - 6.0f * (summary_line_height + text_spacing_y) + // CRC, Region, Compat, Time/Last Played, Size - LayoutScale(12.0f); // Extra padding - - // Limit cover height to avoid pushing text off the screen - // Based on ImGui code for WorkRect, with scrolling logic removed - const float window_height = std::trunc(window->InnerRect.GetHeight() - 2.0f * std::max(window->WindowPadding.y, window->WindowBorderSize)); - - const float free_height = window_height - title_detail_height; - const float img_height = std::clamp(free_height - 2.0f * img_padding_y, 0.0f, LayoutScale(400.0f)); - - const ImVec2 image_size = ImVec2(LayoutScale(275.0f), img_height); - ImGui::SetCursorPos(ImVec2(LayoutScale(128.0f), img_padding_y)); - - if (selected_entry) - DrawGameCover(selected_entry, image_size); - else - DrawFallbackCover(image_size); - - const float text_y = img_height + 2.0f * img_padding_y; - float text_width; - - PushPrimaryColor(); - ImGui::SetCursorPos(ImVec2(start_x, text_y)); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, text_spacing_y)); - ImGui::PushTextWrapPos(wrap_pos); - ImGui::BeginGroup(); - - if (selected_entry) - { - // title - ImGui::PushFont(g_large_font.first, g_large_font.second); - ImGui::SetCursorPosX((work_width - title_size.x) / 2.0f); - ImGui::TextWrapped(, title.c_str()); - ImGui::PopFont(); - - ImGui::PushFont(g_medium_font.first, g_medium_font.second); - - // code - text_width = ImGui::CalcTextSize(selected_entry->serial.c_str(), nullptr, false, work_width).x; - ImGui::SetCursorPosX((work_width - text_width) / 2.0f); - ImGui::TextWrapped(, selected_entry->serial.c_str()); - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + title_padding_below_y); - - // file tile - ImGui::TextWrapped(, file_text.c_str()); - - // crc - ImGui::TextUnformatted(TinyString::from_format(FSUI_FSTR(), selected_entry->crc)); - - // region - { - std::string flag_texture(fmt::format(, GameList::RegionToFlagFilename(selected_entry->region))); - ImGui::TextUnformatted(FSUI_CSTR()); - ImGui::SameLine(); - DrawCachedSvgTextureAsync(flag_texture, LayoutScale(23.0f, 16.0f), SvgScaling::Fit); - ImGui::SameLine(); - ImGui::Text("); +TRANSLATE_NOOP("FullscreenUI", "Game Properties"); TRANSLATE_NOOP("FullscreenUI", "Global Settings"); -TRANSLATE_NOOP("FullscreenUI", "ICON_FA_WRENCH, game_properties_string.c_str()), false, can_change_game_settings)) - SwitchToGameSettings(); - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_SLIDERS, ), false)) - SwitchToSettings(); - } - break; - } - - EndMenuButtons(); - - if (!ImGui::IsPopupOpen(0u, ImGuiPopupFlags_AnyPopup)) - ImGui::NavMoveRequestTryWrapping(ImGui::GetCurrentWindow(), ImGuiNavMoveFlags_LoopY); - - // Draw achievements before ending the window so they stay below the header. - if (Achievements::HasAchievementsOrLeaderboards()) - Achievements::DrawPauseMenuOverlays(); - - EndFullscreenWindow(); - } - - const std::string_view back_text = (submenu == PauseSubMenu::None) ? FSUI_VSTR() : FSUI_VSTR(); - if (IsGamepadInputSource()) - { - const bool circleOK = ImGui::GetIO().ConfigNavSwapGamepadButtons; - const auto glyphs = GetGamepadGlyphs(); - SetFullscreenFooterText(std::array{ - std::make_pair(glyphs.dpad_ud, FSUI_VSTR()), - std::make_pair(glyphs.confirm(circleOK), FSUI_VSTR()), - std::make_pair(glyphs.cancel(circleOK), back_text), - }); - } - else - { - SetFullscreenFooterText(std::array{ - std::make_pair(ICON_PF_ARROW_UP ICON_PF_ARROW_DOWN, FSUI_VSTR()), - std::make_pair(ICON_PF_ENTER, FSUI_VSTR()), - std::make_pair(ICON_PF_ESC, back_text), - }); - } -} - -void FullscreenUI::InitializePlaceholderSaveStateListEntry(SaveStateListEntry* li, s32 slot) -{ - li->title = fmt::format(, TinyString::from_format(FSUI_FSTR(), slot), slot); - li->summary = FSUI_STR(); - li->path = {}; - li->timestamp = 0; - li->slot = slot; - li->preview_texture = {}; -} - -bool FullscreenUI::InitializeSaveStateListEntry( - SaveStateListEntry* li, const std::string& title, const std::string& serial, u32 crc, s32 slot, bool backup) -{ - std::string filename(VMManager::GetSaveStateFileName(serial.c_str(), crc, slot, backup)); - FILESYSTEM_STAT_DATA sd; - if (filename.empty() || !FileSystem::StatFile(filename.c_str(), &sd)) - { - InitializePlaceholderSaveStateListEntry(li, slot); - return false; - } - - li->title = fmt::format(, TinyString::from_format(FSUI_FSTR(), backup ? : , slot), slot); - li->summary = fmt::format(FSUI_FSTR(), TimeToPrintableString(sd.ModificationTime)); - li->slot = slot; - li->timestamp = sd.ModificationTime; - li->path = std::move(filename); - - li->preview_texture.reset(); - - u32 screenshot_width, screenshot_height; - std::vector screenshot_pixels; - if (SaveState_ReadScreenshot(li->path, &screenshot_width, &screenshot_height, &screenshot_pixels)) - { - li->preview_texture = - std::unique_ptr(g_gs_device->CreateTexture(screenshot_width, screenshot_height, 1, GSTexture::Format::Color)); - if (!li->preview_texture || !li->preview_texture->Update(GSVector4i(0, 0, screenshot_width, screenshot_height), - screenshot_pixels.data(), sizeof(u32) * screenshot_width)) - { - Console.Error(); - if (li->preview_texture) - g_gs_device->Recycle(li->preview_texture.release()); - } - } - - return true; -} - -void FullscreenUI::ClearSaveStateEntryList() -{ - for (SaveStateListEntry& entry : s_save_state_selector_slots) - { - if (entry.preview_texture) - s_cleanup_textures.push_back(std::move(entry.preview_texture)); - } - s_save_state_selector_slots.clear(); -} - -u32 FullscreenUI::PopulateSaveStateListEntries(const std::string& title, const std::string& serial, u32 crc) -{ - ClearSaveStateEntryList(); - - for (s32 i = 1; i <= VMManager::NUM_SAVE_STATE_SLOTS; i++) - { - SaveStateListEntry li; - if (InitializeSaveStateListEntry(&li, title, serial, crc, i) || !s_save_state_selector_loading) - s_save_state_selector_slots.push_back(std::move(li)); - - if (s_save_state_selector_loading) - { - SaveStateListEntry bli; - if (InitializeSaveStateListEntry(&bli, title, serial, crc, i, true)) - s_save_state_selector_slots.push_back(std::move(bli)); - } - } - - return static_cast(s_save_state_selector_slots.size()); -} - -bool FullscreenUI::OpenLoadStateSelectorForGame(const std::string& game_path) -{ - auto lock = GameList::GetLock(); - const GameList::Entry* entry = GameList::GetEntryForPath(game_path.c_str()); - if (entry) - { - s_save_state_selector_loading = true; - if (PopulateSaveStateListEntries(entry->title.c_str(), entry->serial.c_str(), entry->crc) > 0) - { - s_save_state_selector_open = true; - s_save_state_selector_resuming = false; - s_save_state_selector_game_path = game_path; - return true; - } - } - - ShowToast(ICON_FA_FLOPPY_DISK, FSUI_STR(), 5.0f); - return false; -} - -bool FullscreenUI::OpenSaveStateSelector(bool is_loading) -{ - s_save_state_selector_game_path = {}; - s_save_state_selector_loading = is_loading; - s_save_state_selector_resuming = false; - if (PopulateSaveStateListEntries(s_current_game_title.c_str(), s_current_disc_serial.c_str(), s_current_disc_crc) > 0) - { - s_save_state_selector_open = true; - return true; - } - - ShowToast(ICON_FA_FLOPPY_DISK, FSUI_STR(), 5.0f); - return false; -} - -void FullscreenUI::CloseSaveStateSelector() -{ - ClearSaveStateEntryList(); - s_save_state_selector_open = false; - s_save_state_selector_submenu_index = -1; - s_save_state_selector_loading = false; - s_save_state_selector_resuming = false; - s_save_state_selector_game_path = {}; -} - -void FullscreenUI::DrawSaveStateSelector(bool is_loading) -{ - ImGuiIO& io = ImGui::GetIO(); - const float title_line_height = GetLineHeight(g_large_font); - const float summary_line_height = GetLineHeight(g_medium_font); - - ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f)); - ImGui::SetNextWindowSize(io.DisplaySize - LayoutScale(0.0f, LAYOUT_FOOTER_HEIGHT)); - - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); - ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); - ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 0.0f); - ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f); - - const char* window_title = is_loading ? FSUI_CSTR() : FSUI_CSTR(); - ImGui::OpenPopup(window_title); - - bool is_open = true; - const bool valid = ImGui::BeginPopupModal(window_title, &is_open, - ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | - ImGuiWindowFlags_NoBackground); - if (!valid || !is_open) - { - if (valid) - ImGui::EndPopup(); - - ImGui::PopStyleVar(5); - if (!is_open) - { - CloseSaveStateSelector(); - ReturnToPreviousWindow(); - } - return; - } - - const ImVec2 heading_size = - ImVec2(io.DisplaySize.x, title_line_height + - (LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f)); - - ImGui::PushStyleColor(ImGuiCol_ChildBg, ModAlpha(UIPrimaryColor, 0.9f)); - - if (ImGui::BeginChild(, heading_size, ImGuiChildFlags_NavFlattened, 0)) - { - BeginNavBar(); - if (NavButton(ICON_PF_BACKWARD, true, true)) - { - CloseSaveStateSelector(); - ReturnToPreviousWindow(); - } - - NavTitle(is_loading ? FSUI_CSTR() : FSUI_CSTR()); - EndNavBar(); - ImGui::EndChild(); - } - - ImGui::PopStyleColor(); - ImGui::PushStyleColor(ImGuiCol_ChildBg, ModAlpha(UIBackgroundColor, VMManager::HasValidVM() ? 0.0f : 0.9f)); - ImGui::SetCursorPos(ImVec2(0.0f, heading_size.y)); - - bool close_handled = false; - if (s_save_state_selector_open && - ImGui::BeginChild(, ImVec2(io.DisplaySize.x, io.DisplaySize.y - LayoutScale(LAYOUT_FOOTER_HEIGHT) - heading_size.y), - ImGuiChildFlags_NavFlattened, 0)) - { - BeginMenuButtons(); - - const ImGuiStyle& style = ImGui::GetStyle(); - - const float title_spacing = LayoutScale(10.0f); - const float summary_spacing = LayoutScale(4.0f); - const float item_spacing = LayoutScale(20.0f); - const float item_width_with_spacing = std::floor(LayoutScale(LAYOUT_SCREEN_WIDTH / 4.0f)); - const float item_width = item_width_with_spacing - item_spacing; - const float image_width = item_width - (style.FramePadding.x * 2.0f); - const float image_height = image_width / 1.33f; - const ImVec2 image_size(image_width, image_height); - const float item_height = (style.FramePadding.y * 2.0f) + image_height + title_spacing + title_line_height + summary_spacing + - summary_line_height; - const ImVec2 item_size(item_width, item_height); - const u32 grid_count_x = std::floor(ImGui::GetWindowWidth() / item_width_with_spacing); - const float start_x = - (static_cast(ImGui::GetWindowWidth()) - (item_width_with_spacing * static_cast(grid_count_x))) * 0.5f; - - u32 grid_x = 0; - for (u32 i = 0; i < s_save_state_selector_slots.size();) - { - if (i == 0) - ResetFocusHere(); - - if (static_cast(i) == s_save_state_selector_submenu_index) - { - SaveStateListEntry& entry = s_save_state_selector_slots[i]; - - // can't use a choice dialog here, because we're already in a modal... - ImGuiFullscreen::PushResetLayout(); - ImGui::PushFont(g_large_font.first, g_large_font.second); - ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING, LAYOUT_MENU_BUTTON_Y_PADDING)); - ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); - ImGui::PushStyleColor(ImGuiCol_Text, UIPrimaryTextColor); - ImGui::PushStyleColor(ImGuiCol_TitleBg, UIPrimaryDarkColor); - ImGui::PushStyleColor(ImGuiCol_TitleBgActive, UIPrimaryColor); - ImGui::PushStyleColor(ImGuiCol_PopupBg, UIPopupBackgroundColor); - - const float width = LayoutScale(600.0f); - const float title_height = - ImGui::GetFrameHeight() + ImGui::GetStyle().WindowPadding.y * 2.0f; - // Use the same rounding and padding as the menu buttons. - const float button_height = LayoutScale(ImGuiFullscreen::LayoutUnscale(title_line_height)) + - LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f; - const float height = title_height + button_height * 3.0f; - ImGui::SetNextWindowSize(ImVec2(width, height)); - ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); - ImGui::OpenPopup(entry.title.c_str()); - - // don't let the back button flow through to the main window - bool submenu_open = !WantsToCloseMenu(); - close_handled ^= submenu_open; - - bool closed = false; - if (ImGui::BeginPopupModal( - entry.title.c_str(), &is_open, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove)) - { - ImGui::PushStyleColor(ImGuiCol_Text, UIBackgroundTextColor); - - BeginMenuButtons(); - - if (ActiveButton( - is_loading ? FSUI_ICONSTR(ICON_FA_FOLDER_OPEN, ) : FSUI_ICONSTR(ICON_FA_FOLDER_OPEN, ), - false, is_loading ? !Achievements::IsHardcoreModeActive() : true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY)) - { - if (is_loading) - DoLoadState(std::move(entry.path), entry.slot, false); - else - DoSaveState(entry.slot); - - CloseSaveStateSelector(); - ReturnToMainWindow(); - closed = true; - } - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_TRASH, ), false, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY)) - { - if (!FileSystem::FileExists(entry.path.c_str())) - { - ShowToast(ICON_FA_TRIANGLE_EXCLAMATION, fmt::format(FSUI_FSTR(), ImGuiFullscreen::RemoveHash(entry.title))); - is_open = true; - } - else if (FileSystem::DeleteFilePath(entry.path.c_str())) - { - ShowToast(ICON_FA_TRASH, fmt::format(FSUI_FSTR(), ImGuiFullscreen::RemoveHash(entry.title))); - if (s_save_state_selector_loading) - s_save_state_selector_slots.erase(s_save_state_selector_slots.begin() + i); - else - InitializePlaceholderSaveStateListEntry(&entry, entry.slot); - - // Close if this was the last state. - if (s_save_state_selector_slots.empty()) - { - CloseSaveStateSelector(); - ReturnToMainWindow(); - closed = true; - } - else - { - is_open = false; - } - } - else - { - ShowToast(ICON_FA_TRIANGLE_EXCLAMATION, fmt::format(FSUI_FSTR(), ImGuiFullscreen::RemoveHash(entry.title))); - is_open = false; - } - } - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_SQUARE_XMARK, ), false, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY)) - { - is_open = false; - } - - EndMenuButtons(); - - ImGui::PopStyleColor(); - ImGui::EndPopup(); - } - if (!is_open) - { - s_save_state_selector_submenu_index = -1; - if (!closed) - QueueResetFocus(FocusResetType::WindowChanged); - } - - ImGui::PopStyleColor(4); - ImGui::PopStyleVar(3); - ImGui::PopFont(); - ImGuiFullscreen::PopResetLayout(); - - if (closed || i >= s_save_state_selector_slots.size()) - break; - } - - ImGuiWindow* window = ImGui::GetCurrentWindow(); - if (window->SkipItems) - { - i++; - continue; - } - - if (grid_x == grid_count_x) - { - grid_x = 0; - ImGui::SetCursorPosX(start_x); - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + item_spacing); - } - else - { - ImGui::SameLine(start_x + static_cast(grid_x) * (item_width + item_spacing)); - } - - const SaveStateListEntry& entry = s_save_state_selector_slots[i]; - const ImGuiID id = window->GetID(static_cast(i)); - const ImVec2 pos(window->DC.CursorPos); - ImRect bb(pos, pos + item_size); - ImGui::ItemSize(item_size); - if (ImGui::ItemAdd(bb, id)) - { - bool held; - bool hovered; - bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held, 0); - if (hovered) - { - const ImU32 col = ImGui::GetColorU32(held ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered, 0.7f); - - const float t = std::min(std::abs(std::sin(ImGui::GetTime() * 0.75) * 1.1), 1.0f); - ImGui::PushStyleColor(ImGuiCol_Border, ImGui::GetColorU32(ImGuiCol_Border, t)); - - ImGuiFullscreen::DrawMenuButtonFrame(bb.Min, bb.Max, col, true, 0.0f); - - ImGui::PopStyleColor(); - } - - bb.Min += style.FramePadding; - bb.Max -= style.FramePadding; - - const GSTexture* const screenshot = entry.preview_texture ? entry.preview_texture.get() : GetPlaceholderTexture().get(); - const ImRect image_rect(CenterImage(ImRect(bb.Min, bb.Min + image_size), - ImVec2(static_cast(screenshot->GetWidth()), static_cast(screenshot->GetHeight())))); - - ImGui::GetWindowDrawList()->AddImage(reinterpret_cast(screenshot->GetNativeHandle()), - image_rect.Min, image_rect.Max, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), - entry.preview_texture ? IM_COL32_WHITE : ImGui::GetColorU32(UIBackgroundTextColor)); - - const ImVec2 title_pos(bb.Min.x, bb.Min.y + image_height + title_spacing); - const ImRect title_bb(title_pos, ImVec2(bb.Max.x, title_pos.y + title_line_height)); - ImGui::PushFont(g_large_font.first, g_large_font.second); - ImGuiFullscreen::RenderTextClippedWithShadow( - title_bb.Min, title_bb.Max, entry.title.c_str(), nullptr, nullptr, ImVec2(0.0f, 0.0f), &title_bb); - ImGui::PopFont(); - - if (!entry.summary.empty()) - { - const ImVec2 summary_pos(bb.Min.x, title_bb.Max.y + summary_spacing); - const ImRect summary_bb(summary_pos, ImVec2(bb.Max.x, summary_pos.y + summary_line_height)); - ImGui::PushFont(g_medium_font.first, g_medium_font.second); - ImGuiFullscreen::RenderTextClippedWithShadow( - summary_bb.Min, summary_bb.Max, entry.summary.c_str(), nullptr, nullptr, ImVec2(0.0f, 0.0f), &summary_bb); - ImGui::PopFont(); - } - - if (pressed) - { - if (is_loading) - DoLoadState(entry.path, entry.slot, false); - else - DoSaveState(entry.slot); - - CloseSaveStateSelector(); - ReturnToMainWindow(); - break; - } - else if (hovered && (ImGui::IsItemClicked(ImGuiMouseButton_Right) || ImGui::Shortcut(ImGuiKey_NavGamepadMenu) || - ImGui::Shortcut(ImGuiKey_F1))) - { - s_save_state_selector_submenu_index = static_cast(i); - } - } - - grid_x++; - i++; - } - - EndMenuButtons(); - ImGui::EndChild(); - } - - ImGui::PopStyleColor(); - - ImGui::EndPopup(); - ImGui::PopStyleVar(5); - - if (!close_handled && WantsToCloseMenu()) - { - CloseSaveStateSelector(); - ReturnToPreviousWindow(); - } - else - { - if (IsGamepadInputSource()) - { - const bool circleOK = ImGui::GetIO().ConfigNavSwapGamepadButtons; - const bool swapNorthWest = ImGuiManager::IsGamepadNorthWestSwapped(); - const auto glyphs = GetGamepadGlyphs(); - SetFullscreenFooterText(std::array{ - std::make_pair(glyphs.dpad, FSUI_VSTR()), - std::make_pair(swapNorthWest ? glyphs.north : glyphs.west, FSUI_VSTR()), - std::make_pair(glyphs.confirm(circleOK), FSUI_VSTR()), - std::make_pair(glyphs.cancel(circleOK), FSUI_VSTR()), - }); - } - else - { - SetFullscreenFooterText(std::array{ - std::make_pair(ICON_PF_ARROW_UP ICON_PF_ARROW_DOWN ICON_PF_ARROW_LEFT ICON_PF_ARROW_RIGHT, FSUI_VSTR()), - std::make_pair(ICON_PF_F1, FSUI_VSTR()), - std::make_pair(ICON_PF_ENTER, FSUI_VSTR()), - std::make_pair(ICON_PF_ESC, FSUI_VSTR()), - }); - } - } -} - -bool FullscreenUI::OpenLoadStateSelectorForGameResume(const GameList::Entry* entry) -{ - SaveStateListEntry slentry; - if (!InitializeSaveStateListEntry(&slentry, entry->title, entry->serial, entry->crc, -1)) - return false; - - CloseSaveStateSelector(); - s_save_state_selector_slots.push_back(std::move(slentry)); - s_save_state_selector_game_path = entry->path; - s_save_state_selector_loading = true; - s_save_state_selector_open = true; - s_save_state_selector_resuming = true; - return true; -} - -void FullscreenUI::DrawResumeStateSelector() -{ - ImGui::SetNextWindowSize(LayoutScale(800.0f, 600.0f)); - ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); - ImGui::OpenPopup(FSUI_CSTR()); - - ImGui::PushFont(g_large_font.first, g_large_font.second); - ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, LayoutScale(20.0f, 20.0f)); - - bool is_open = true; - if (ImGui::BeginPopupModal(FSUI_CSTR(), &is_open, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar)) - { - const SaveStateListEntry& entry = s_save_state_selector_slots.front(); - ImGui::TextWrapped(FSUI_CSTR(), - TimeToPrintableString(entry.timestamp).c_str()); - - const GSTexture* image = entry.preview_texture ? entry.preview_texture.get() : GetPlaceholderTexture().get(); - const float image_height = LayoutScale(250.0f); - const float image_width = image_height * (static_cast(image->GetWidth()) / static_cast(image->GetHeight())); - const ImVec2 pos(ImGui::GetCursorScreenPos() + - ImVec2((ImGui::GetCurrentWindow()->WorkRect.GetWidth() - image_width) * 0.5f, LayoutScale(20.0f))); - const ImRect image_bb(pos, pos + ImVec2(image_width, image_height)); - ImGui::GetWindowDrawList()->AddImage(reinterpret_cast(image->GetNativeHandle()), image_bb.Min, image_bb.Max, - ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), entry.preview_texture ? IM_COL32_WHITE : ImGui::GetColorU32(UIBackgroundTextColor)); - - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + image_height + LayoutScale(40.0f)); - - BeginMenuButtons(); - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_PLAY, ), false)) - { - DoStartPath(s_save_state_selector_game_path, -1); - is_open = false; - } - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_COMPACT_DISC, ), false)) - { - DoStartPath(s_save_state_selector_game_path); - is_open = false; - } - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_TRASH, ), false)) - { - if (FileSystem::DeleteFilePath(entry.path.c_str())) - { - DoStartPath(s_save_state_selector_game_path); - is_open = false; - } - else - { - ShowToast(ICON_FA_TRIANGLE_EXCLAMATION, FSUI_STR()); - } - } - - if (ActiveButton(FSUI_ICONSTR(ICON_FA_SQUARE_XMARK, ), false) || WantsToCloseMenu()) - { - ImGui::CloseCurrentPopup(); - is_open = false; - } - EndMenuButtons(); - - ImGui::EndPopup(); - } - - ImGui::PopStyleVar(2); - ImGui::PopFont(); - - if (!is_open) - { - ClearSaveStateEntryList(); - s_save_state_selector_open = false; - s_save_state_selector_loading = false; - s_save_state_selector_resuming = false; - s_save_state_selector_game_path = {}; - } - else - { - SetStandardSelectionFooterText(false); - } -} - -void FullscreenUI::DoLoadState(std::string path, std::optional slot, bool backup) -{ - std::string boot_path = s_save_state_selector_game_path; - Host::RunOnCPUThread([boot_path = std::move(boot_path), path = std::move(path), slot, backup]() { - if (VMManager::HasValidVM()) - { - Error error; - if (!VMManager::LoadState(path.c_str(), &error)) - { - ReportStateLoadError(error.GetDescription(), slot, backup); - return; - } - - if (!boot_path.empty() && VMManager::GetDiscPath() != boot_path) - VMManager::ChangeDisc(CDVD_SourceType::Iso, std::move(boot_path)); - } - else - { - VMBootParameters params; - params.filename = std::move(boot_path); - params.save_state = std::move(path); - DoVMInitialize(params, false); - } - }); -} - -void FullscreenUI::DoSaveState(s32 slot) -{ - Host::RunOnCPUThread([slot]() { - VMManager::SaveStateToSlot(slot, true, [slot](const std::string& error) { - ReportStateSaveError(error, slot); - }); - }); -} - -void FullscreenUI::PopulateGameListEntryList() -{ - const int sort = Host::GetBaseIntSettingValue(, , 0); - const bool reverse = Host::GetBaseBoolSettingValue(, , false); - const bool favorites_only = Host::GetBaseBoolSettingValue(, , false); - static int s_last_sort = -1; - static bool s_last_reverse = false; - static bool s_last_prefer_eng = false; - static bool s_last_favorites_only = false; - - // Sort can be expensive, try to avoid when possible - const u32 count = GameList::GetEntryCount(); - bool needs_update = s_game_list_needs_sort || sort != s_last_sort || reverse != s_last_reverse || - s_last_prefer_eng != s_prefer_english_titles || favorites_only != s_last_favorites_only; - needs_update |= count != s_last_unsorted_entries.size(); - if (!needs_update) - { - for (u32 i = 0; i < count; i++) - { - if (GameList::GetEntryByIndex(i) != s_last_unsorted_entries[i]) - { - needs_update = true; - break; - } - } - } - - if (!needs_update) - return; - s_game_list_needs_sort = false; - - s_last_sort = sort; - s_last_reverse = reverse; - s_last_prefer_eng = s_prefer_english_titles; - s_last_favorites_only = favorites_only; - - s_game_list_sorted_entries.resize(count); - s_last_unsorted_entries.resize(count); - for (u32 i = 0; i < count; i++) - { - s_game_list_sorted_entries[i] = GameList::GetEntryByIndex(i); - s_last_unsorted_entries[i] = s_game_list_sorted_entries[i]; - } - if (favorites_only) - { - s_game_list_sorted_entries.erase( - std::remove_if(s_game_list_sorted_entries.begin(), s_game_list_sorted_entries.end(), - [](const GameList::Entry* entry) { return !entry->is_favorite; }), - s_game_list_sorted_entries.end()); - } - - std::sort(s_game_list_sorted_entries.begin(), s_game_list_sorted_entries.end(), - [sort, reverse](const GameList::Entry* lhs, const GameList::Entry* rhs) { - if (lhs->is_favorite != rhs->is_favorite) - return lhs->is_favorite; - - switch (sort) - { - case 0: // Type - { - if (lhs->type != rhs->type) - return reverse ? (lhs->type > rhs->type) : (lhs->type < rhs->type); - } - break; - - case 1: // Serial - { - if (lhs->serial != rhs->serial) - return reverse ? (lhs->serial > rhs->serial) : (lhs->serial < rhs->serial); - } - break; - - case 2: // Title - break; - - case 3: // File Title - { - const std::string_view lhs_title(Path::GetFileTitle(lhs->path)); - const std::string_view rhs_title(Path::GetFileTitle(rhs->path)); - const int res = - StringUtil::Strncasecmp(lhs_title.data(), rhs_title.data(), std::min(lhs_title.size(), rhs_title.size())); - if (res != 0) - return reverse ? (res > 0) : (res < 0); - } - break; - - case 4: // CRC - { - if (lhs->crc != rhs->crc) - return reverse ? (lhs->crc > rhs->crc) : (lhs->crc < rhs->crc); - } - break; - - case 5: // Time Played - { - if (lhs->total_played_time != rhs->total_played_time) - { - return reverse ? (lhs->total_played_time > rhs->total_played_time) : - (lhs->total_played_time < rhs->total_played_time); - } - } - break; - - case 6: // Last Played (reversed by default) - { - if (lhs->last_played_time != rhs->last_played_time) - { - return reverse ? (lhs->last_played_time < rhs->last_played_time) : (lhs->last_played_time > rhs->last_played_time); - } - } - break; - - case 7: // Size - { - if (lhs->total_size != rhs->total_size) - { - return reverse ? (lhs->total_size > rhs->total_size) : (lhs->total_size < rhs->total_size); - } - } - break; - } - - // fallback to title when all else is equal - const int res = Host::LocaleSensitiveCompare(lhs->GetTitleSort(s_prefer_english_titles), rhs->GetTitleSort(s_prefer_english_titles)); - return reverse ? (res > 0) : (res < 0); - }); -} - -void FullscreenUI::DrawGameListWindow() -{ - auto game_list_lock = GameList::GetLock(); - PopulateGameListEntryList(); - - ImGuiIO& io = ImGui::GetIO(); - const ImVec2 heading_size = - ImVec2(io.DisplaySize.x, GetLineHeight(g_large_font) + - (LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f)); - - const float bg_alpha = VMManager::HasValidVM() ? 0.90f : 1.0f; - - if (BeginFullscreenWindow(ImVec2(0.0f, 0.0f), heading_size, , MulAlpha(UIPrimaryColor, bg_alpha))) - { - static constexpr float ITEM_WIDTH = 25.0f; - static constexpr const char* icons[] = {ICON_FA_BORDER_ALL, ICON_FA_LIST}; - static constexpr const char* titles[] = {FSUI_NSTR(), FSUI_NSTR()}; - static constexpr u32 count = std::size(titles); - - BeginNavBar(); - - if (NavButton(ICON_PF_BACKWARD, true, true)) - SwitchToLanding(); - - NavTitle(Host::TranslateToCString(TR_CONTEXT, titles[static_cast(s_game_list_view)])); - RightAlignNavButtons(count, ITEM_WIDTH, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY); - - for (u32 i = 0; i < count; i++) - { - if (NavButton(icons[i], static_cast(i) == s_game_list_view, true, ITEM_WIDTH, - LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY)) - { - s_game_list_view = static_cast(i); - } - } - - EndNavBar(); - } - - EndFullscreenWindow(); - - if (ImGui::IsKeyPressed(ImGuiKey_NavGamepadContextMenu, false) || ImGui::IsKeyPressed(ImGuiKey_F1, false)) - { - s_game_list_view = (s_game_list_view == GameListView::Grid) ? GameListView::List : GameListView::Grid; - } - else if (ImGui::IsKeyPressed(ImGuiKey_GamepadStart, false) || ImGui::IsKeyPressed(ImGuiKey_F2)) - { - s_current_main_window = MainWindowType::GameListSettings; - QueueResetFocus(FocusResetType::WindowChanged); - } - else if (ImGui::IsKeyPressed(ImGuiKey_GamepadBack, false) || ImGui::IsKeyPressed(ImGuiKey_F4, false)) - { - OpenCoverDownloaderWindow(); - } - else if (ImGui::IsKeyPressed(ImGuiKey_GamepadL2, false) || ImGui::IsKeyPressed(ImGuiKey_F5, false)) - { - ShowToast(std::string(), FSUI_STR(), 4.0f); - Host::RefreshGameListAsync(false); - } - - switch (s_game_list_view) - { - case GameListView::Grid: - DrawGameGrid(heading_size); - break; - case GameListView::List: - DrawGameList(heading_size); - break; - default: - break; - } - - if (VMManager::GetState() != VMState::Shutdown) - { - // Dummy window to prevent interacting with the game list while loading. - ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); - ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize); - ImGui::SetNextWindowPos(ImVec2(0, 0)); - ImGui::SetNextWindowBgAlpha(0.25f); - ImGui::Begin(, nullptr, ImGuiWindowFlags_NoDecoration); - ImGui::End(); - ImGui::PopStyleColor(); - } - - if (IsGamepadInputSource()) - { - const bool circleOK = ImGui::GetIO().ConfigNavSwapGamepadButtons; - const bool swapNorthWest = ImGuiManager::IsGamepadNorthWestSwapped(); - const auto glyphs = GetGamepadGlyphs(); - SetFullscreenFooterText(std::array{ - std::make_pair(glyphs.dpad, FSUI_VSTR()), - std::make_pair(glyphs.select, FSUI_VSTR()), - std::make_pair(glyphs.start, FSUI_VSTR()), - std::make_pair(ICON_PF_LEFT_TRIGGER_L2, FSUI_VSTR()), - std::make_pair(swapNorthWest ? glyphs.west : glyphs.north, FSUI_VSTR()), - std::make_pair(swapNorthWest ? glyphs.north : glyphs.west, FSUI_VSTR()), - std::make_pair(glyphs.confirm(circleOK), FSUI_VSTR()), - std::make_pair(glyphs.cancel(circleOK), FSUI_VSTR()), - }); - } - else - { - SetFullscreenFooterText(std::array{ - std::make_pair(ICON_PF_ARROW_UP ICON_PF_ARROW_DOWN ICON_PF_ARROW_LEFT ICON_PF_ARROW_RIGHT, FSUI_VSTR()), - std::make_pair(ICON_PF_F1, FSUI_VSTR()), - std::make_pair(ICON_PF_F2, FSUI_VSTR()), - std::make_pair(ICON_PF_F3, FSUI_VSTR()), - std::make_pair(ICON_PF_F4, FSUI_VSTR()), - std::make_pair(ICON_PF_F5, FSUI_VSTR()), - std::make_pair(ICON_PF_ENTER, FSUI_VSTR()), - std::make_pair(ICON_PF_ESC, FSUI_VSTR()), - }); - } -} - -std::string_view FullscreenUI::TrimString(const std::pair& font, std::string_view str, float available_space) -{ - const char* beg = str.data(); - const char* end = beg + str.size(); - float full_width = font.first->CalcTextSizeA(font.second, INFINITY, 0, beg, end).x; - if (full_width <= available_space) - return str; - float ellipsis_width = font.first->CalcTextSizeA(font.second, INFINITY, 0.0f, g_ellipsis).x; - const char* trimmed = end; - font.first->CalcTextSizeA(font.second, available_space - ellipsis_width, 0, beg, end, &trimmed); - return std::string_view(beg, trimmed); -} - -void FullscreenUI::DrawGameList(const ImVec2& heading_size) -{ - ImGui::PushStyleColor(ImGuiCol_WindowBg, UIBackgroundColor); - - if (!BeginFullscreenColumns(nullptr, heading_size.y, true, true)) - { - EndFullscreenColumns(); - ImGui::PopStyleColor(); - return; - } - - if (!AreAnyDialogsOpen() && WantsToCloseMenu()) - SwitchToLanding(); - - const GameList::Entry* selected_entry = nullptr; - - if (BeginFullscreenColumnWindow(0.0f, -530.0f, )) - { - const float title_height = GetLineHeight(g_large_font); - const float spacing = LayoutScale(4.0f); - const ImVec2 image_size(LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT * 0.68f, LAYOUT_MENU_BUTTON_HEIGHT)); - const float item_height = std::max(LAYOUT_MENU_BUTTON_HEIGHT, - ImGuiFullscreen::LayoutUnscale(title_height + spacing + GetLineHeight(g_medium_font))); - - ResetFocusHere(); - - BeginMenuButtons(); - - // TODO: replace with something not heap allocating - std::string summary; - - for (const GameList::Entry* entry : s_game_list_sorted_entries) - { - ImRect bb; - bool visible, hovered; - bool pressed = MenuButtonFrame(entry->path.c_str(), true, item_height, &visible, &hovered, &bb.Min, &bb.Max); - if (!visible) - continue; - - summary.clear(); - if (entry->serial.empty()) - fmt::format_to(std::back_inserter(summary), , GameList::RegionToString(entry->region, true)); - else - fmt::format_to(std::back_inserter(summary), , entry->serial, GameList::RegionToString(entry->region, true)); - - const std::string_view filename(Path::GetFileName(entry->path)); - summary.append(filename); - - DrawGameCover(entry, ImGui::GetWindowDrawList(), bb.Min, bb.Min + image_size); - - const float midpoint = bb.Min.y + title_height + spacing; - const float text_start_x = bb.Min.x + image_size.x + LayoutScale(15.0f); - const ImRect title_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint)); - const ImRect summary_bb(ImVec2(text_start_x, midpoint), bb.Max); - const std::string& title = entry->GetTitle(s_prefer_english_titles); - - ImGui::PushFont(g_large_font.first, g_large_font.second); - const bool is_favorite = entry->is_favorite; - const bool has_custom_settings = entry->has_custom_settings; - const float icon_size = GetLineHeight(g_large_font) * 0.75f; - const float icon_margin = LayoutScale(8.0f); - ImRect visible_title_bb(title_bb); - if (is_favorite || has_custom_settings) - visible_title_bb.Max.x -= icon_size * 2.0f + icon_margin * 3.0f; - ImGui::RenderTextClipped(visible_title_bb.Min, visible_title_bb.Max, title.c_str(), title.c_str() + title.size(), nullptr, - ImVec2(0.0f, 0.0f), &visible_title_bb); - if (is_favorite) - { - const ImVec2 star_pos(title_bb.Max.x - icon_size - icon_margin, - title_bb.Min.y + (GetLineHeight(g_large_font) - icon_size) * 0.5f); - ImGui::GetWindowDrawList()->AddText(g_large_font.first, icon_size, - ImVec2(star_pos.x + LayoutScale(1.0f), star_pos.y + LayoutScale(1.0f)), IM_COL32(0, 0, 0, 200), ICON_PF_STAR); - ImGui::GetWindowDrawList()->AddText(g_large_font.first, icon_size, - star_pos, IM_COL32(255, 196, 0, 255), ICON_PF_STAR); - } - if (has_custom_settings) - { - const ImVec2 gear_pos(title_bb.Max.x - 2.0f * icon_size - 2.0f * icon_margin, - title_bb.Min.y + (GetLineHeight(g_large_font) - icon_size) * 0.5f); - ImGui::GetWindowDrawList()->AddText(g_large_font.first, icon_size, - ImVec2(gear_pos.x + LayoutScale(1.0f), gear_pos.y + LayoutScale(1.0f)), IM_COL32(0, 0, 0, 200), ICON_FA_GEAR); - ImGui::GetWindowDrawList()->AddText(g_large_font.first, icon_size, - gear_pos, IM_COL32(87, 181, 255, 255), ICON_FA_GEAR); - } - ImGui::PopFont(); - - if (!summary.empty()) - { - ImGui::PushFont(g_medium_font.first, g_medium_font.second); - ImGui::RenderTextClipped( - summary_bb.Min, summary_bb.Max, summary.c_str(), nullptr, nullptr, ImVec2(0.0f, 0.0f), &summary_bb); - ImGui::PopFont(); - } - - if (pressed) - HandleGameListActivate(entry); - - if (hovered) - selected_entry = entry; - - if (selected_entry && - (ImGui::IsItemClicked(ImGuiMouseButton_Right) || ImGui::Shortcut(ImGuiKey_NavGamepadMenu) || - ImGui::Shortcut(ImGuiKey_F3))) - { - HandleGameListOptions(selected_entry); - } - } - - EndMenuButtons(); - } - EndFullscreenColumnWindow(); - - if (BeginFullscreenColumnWindow(-530.0f, 0.0f, , UIPrimaryDarkColor)) - { - const float img_padding_y = LayoutScale(20.0f); - // Spacing between each text item - const float text_spacing_y = LayoutScale(8.0f); - // Space between title/serial and details, is in addition to text_spacing_y - const float title_padding_below_y = LayoutScale(12.0f); - const ImGuiWindow* window = ImGui::GetCurrentWindow(); - const float work_width = window->WorkRect.GetWidth(); - const float start_x = LayoutScale(50.0f); - const float wrap_pos = LayoutScale(490.0f); - const std::string_view full_title = selected_entry ? std::string_view(selected_entry->GetTitle(s_prefer_english_titles)) : - std::string_view(FSUI_CSTR()); - const std::string_view trimmed_title = TrimString(g_large_font, full_title, work_width); - const SmallString title = SmallString::from_format(, trimmed_title, trimmed_title.size() == full_title.size() ? : g_ellipsis); - const ImVec2 title_size = g_large_font.first->CalcTextSizeA(g_large_font.second, FLT_MAX, 0.0f, title.c_str()); - // Measure wrapping from the title's centered position. - const float title_wrap_width = std::max(1.0f, wrap_pos - (work_width - title_size.x) * 0.5f); - const float title_height = - g_large_font.first->CalcTextSizeA(g_large_font.second, FLT_MAX, title_wrap_width, title.c_str()).y; - // The filename can take more than one line. - const SmallString file_text = selected_entry ? SmallString::from_format(FSUI_FSTR(), Path::GetFileName(selected_entry->path)) : SmallString(); - const float file_wrap_width = std::max(1.0f, wrap_pos - start_x); - const float file_height = - g_medium_font.first->CalcTextSizeA(g_medium_font.second, FLT_MAX, file_wrap_width, file_text.c_str()).y; - const float summary_line_height = GetLineHeight(g_medium_font); - - // Leave room for the text below the cover. - const float title_detail_height = - title_height + text_spacing_y + // Title - summary_line_height + text_spacing_y + // Serial - title_padding_below_y + - file_height + text_spacing_y + // File - 6.0f * (summary_line_height + text_spacing_y) + // CRC, Region, Compat, Time/Last Played, Size - LayoutScale(12.0f); // Extra padding - - // Limit cover height to avoid pushing text off the screen - // Based on ImGui code for WorkRect, with scrolling logic removed - const float window_height = std::trunc(window->InnerRect.GetHeight() - 2.0f * std::max(window->WindowPadding.y, window->WindowBorderSize)); - - const float free_height = window_height - title_detail_height; - const float img_height = std::clamp(free_height - 2.0f * img_padding_y, 0.0f, LayoutScale(400.0f)); - - const ImVec2 image_size = ImVec2(LayoutScale(275.0f), img_height); - ImGui::SetCursorPos(ImVec2(LayoutScale(128.0f), img_padding_y)); - - if (selected_entry) - DrawGameCover(selected_entry, image_size); - else - DrawFallbackCover(image_size); - - const float text_y = img_height + 2.0f * img_padding_y; - float text_width; - - PushPrimaryColor(); - ImGui::SetCursorPos(ImVec2(start_x, text_y)); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, text_spacing_y)); - ImGui::PushTextWrapPos(wrap_pos); - ImGui::BeginGroup(); - - if (selected_entry) - { - // title - ImGui::PushFont(g_large_font.first, g_large_font.second); - ImGui::SetCursorPosX((work_width - title_size.x) / 2.0f); - ImGui::TextWrapped(, title.c_str()); - ImGui::PopFont(); - - ImGui::PushFont(g_medium_font.first, g_medium_font.second); - - // code - text_width = ImGui::CalcTextSize(selected_entry->serial.c_str(), nullptr, false, work_width).x; - ImGui::SetCursorPosX((work_width - text_width) / 2.0f); - ImGui::TextWrapped(, selected_entry->serial.c_str()); - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + title_padding_below_y); - - // file tile - ImGui::TextWrapped(, file_text.c_str()); - - // crc - ImGui::TextUnformatted(TinyString::from_format(FSUI_FSTR(), selected_entry->crc)); - - // region - { - std::string flag_texture(fmt::format(, GameList::RegionToFlagFilename(selected_entry->region))); - ImGui::TextUnformatted(FSUI_CSTR()); - ImGui::SameLine(); - DrawCachedSvgTextureAsync(flag_texture, LayoutScale(23.0f, 16.0f), SvgScaling::Fit); - ImGui::SameLine(); - ImGui::Text("); TRANSLATE_NOOP("FullscreenUI", "Delete Save"); TRANSLATE_NOOP("FullscreenUI", "Close Menu"); TRANSLATE_NOOP("FullscreenUI", "Default Boot"); TRANSLATE_NOOP("FullscreenUI", "Delete State"); -TRANSLATE_NOOP("FullscreenUI", "Game Properties (Edit)"); -TRANSLATE_NOOP("FullscreenUI", "Game Properties (New)"); TRANSLATE_NOOP("FullscreenUI", "Remove from Favorites"); TRANSLATE_NOOP("FullscreenUI", "Add to Favorites"); -TRANSLATE_NOOP("FullscreenUI", "Default Boot (Custom settings)"); -TRANSLATE_NOOP("FullscreenUI", "Default Boot (Global settings)"); TRANSLATE_NOOP("FullscreenUI", "Fast Boot"); TRANSLATE_NOOP("FullscreenUI", "Full Boot"); TRANSLATE_NOOP("FullscreenUI", "Reset Play Time");