diff --git a/Common/System/OSD.cpp b/Common/System/OSD.cpp index 83ddf6f45f..f293a61849 100644 --- a/Common/System/OSD.cpp +++ b/Common/System/OSD.cpp @@ -47,11 +47,11 @@ std::vector OnScreenDisplay::Entries() { return entries_; // makes a copy. } -void OnScreenDisplay::NudgeSidebar() { +void OnScreenDisplay::NudgeIngameNotifications() { sideBarShowTime_ = time_now_d(); } -float OnScreenDisplay::SidebarAlpha() const { +float OnScreenDisplay::IngameAlpha() const { double timeSinceNudge = time_now_d() - sideBarShowTime_; // Fade out in 1/4 second, 0.1s after the last nudge. diff --git a/Common/System/OSD.h b/Common/System/OSD.h index da8dd5cd34..36e871c373 100644 --- a/Common/System/OSD.h +++ b/Common/System/OSD.h @@ -82,8 +82,8 @@ public: void RemoveProgressBar(std::string_view id, bool success, float delay_s); // Call every frame to keep the sidebar visible. Otherwise it'll fade out. - void NudgeSidebar(); - float SidebarAlpha() const; + void NudgeIngameNotifications(); + float IngameAlpha() const; // Fades out everything related to achievements. Should be used on game shutdown. void ClearAchievementStuff(); diff --git a/UI/DeveloperToolsScreen.cpp b/UI/DeveloperToolsScreen.cpp index 0d43ad237e..322b82716a 100644 --- a/UI/DeveloperToolsScreen.cpp +++ b/UI/DeveloperToolsScreen.cpp @@ -375,6 +375,8 @@ void DeveloperToolsScreen::CreateUITab(UI::LinearLayout *list) { list->Add(new ItemHeader(si->T("Slider test"))); list->Add(new Slider(&testSliderValue_, 0, 100, 1, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT))); + static const char *positions[] = {"Bottom Left", "Bottom Center", "Bottom Right", "Top Left", "Top Center", "Top Right", "Center Left", "Center Right", "None"}; + list->Add(new ItemHeader(si->T("Notification tests"))); list->Add(new Choice(si->T("Error")))->OnClick.Add([&](UI::EventParams &) { std::string str = "Error " + CodepointToUTF8(0x1F41B) + CodepointToUTF8(0x1F41C) + CodepointToUTF8(0x1F914); @@ -425,10 +427,10 @@ void DeveloperToolsScreen::CreateUITab(UI::LinearLayout *list) { g_OSD.ShowLeaderboardTracker(1, "", false); }); - static const char *positions[] = {"Bottom Left", "Bottom Center", "Bottom Right", "Top Left", "Top Center", "Top Right", "Center Left", "Center Right", "None"}; - list->Add(new ItemHeader(ac->T("Notifications"))); - list->Add(new PopupMultiChoice(&g_Config.iAchievementsLeaderboardTrackerPos, ac->T("Leaderboard tracker"), positions, 0, ARRAY_SIZE(positions), I18NCat::DIALOG, screenManager()))->SetEnabledPtr(&g_Config.bAchievementsEnable); + list->Add(new PopupMultiChoice(&g_Config.iNotificationPos, "General notifications", positions, 0, ARRAY_SIZE(positions), I18NCat::DIALOG, screenManager())); + list->Add(new PopupMultiChoice(&g_Config.iAchievementsLeaderboardTrackerPos, ac->T("Leaderboard tracker"), positions, 0, ARRAY_SIZE(positions), I18NCat::DIALOG, screenManager())); + list->Add(new CheckBox(&pretendIngame_, ac->T("Pretend to be in-game (for testing)"))); #ifdef _DEBUG // Untranslated string because this is debug mode only, only for PPSSPP developers. @@ -714,6 +716,11 @@ void DeveloperToolsScreen::update() { UIBaseDialogScreen::update(); allowDebugger_ = !WebServerStopped(WebServerFlags::DEBUGGER); canAllowDebugger_ = !WebServerStopping(WebServerFlags::DEBUGGER); + + // For the UI tab's notification tests. + if (pretendIngame_) { + g_OSD.NudgeIngameNotifications(); + } } void DeveloperToolsScreen::MemoryMapTest() { diff --git a/UI/DeveloperToolsScreen.h b/UI/DeveloperToolsScreen.h index 009963da40..2952aee591 100644 --- a/UI/DeveloperToolsScreen.h +++ b/UI/DeveloperToolsScreen.h @@ -57,4 +57,5 @@ private: UI::InfoItem* MIPSTracerPath = nullptr; int testSliderValue_ = 0; + bool pretendIngame_ = false; }; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index e691364e64..0a83cf902b 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1605,7 +1605,7 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { framebufferBound = true; } - g_OSD.NudgeSidebar(); + g_OSD.NudgeIngameNotifications(); if (mode & ScreenRenderMode::TOP) { System_Notify(SystemNotification::KEEP_SCREEN_AWAKE); diff --git a/UI/OnScreenDisplay.cpp b/UI/OnScreenDisplay.cpp index 3b6521f0c1..e6fbbcfb70 100644 --- a/UI/OnScreenDisplay.cpp +++ b/UI/OnScreenDisplay.cpp @@ -269,12 +269,11 @@ void OnScreenMessagesView::Draw(UIContext &dc) { const float fadeinCoef = 1.0f / OnScreenDisplay::FadeinTime(); const float fadeoutCoef = 1.0f / OnScreenDisplay::FadeoutTime(); - float sidebarAlpha = g_OSD.SidebarAlpha(); + float ingameAlpha = g_OSD.IngameAlpha(); struct LayoutEdge { float height; float maxWidth; - float alpha; }; struct MeasuredEntry { @@ -293,19 +292,20 @@ void OnScreenMessagesView::Draw(UIContext &dc) { std::vector measuredEntries; measuredEntries.resize(entries.size()); - // Indexed by the enum ScreenEdgePosition. - LayoutEdge edges[(size_t)ScreenEdgePosition::VALUE_COUNT]{}; - for (size_t i = 0; i < (size_t)ScreenEdgePosition::VALUE_COUNT; i++) { - edges[i].alpha = sidebarAlpha; - } - edges[(size_t)ScreenEdgePosition::TOP_CENTER].alpha = 1.0f; - + float typeAlpha[(size_t)OSDType::VALUE_COUNT]{}; ScreenEdgePosition typeEdges[(size_t)OSDType::VALUE_COUNT]{}; // Default to the configured position. for (int i = 0; i < (size_t)OSDType::VALUE_COUNT; i++) { + typeAlpha[i] = ingameAlpha; typeEdges[i] = (ScreenEdgePosition)g_Config.iNotificationPos; } + // These types can always show, independent of whether we're in the menu or not. + static const OSDType fullAlphaTypes[] = {OSDType::MESSAGE_ERROR, OSDType::MESSAGE_INFO, OSDType::MESSAGE_WARNING, OSDType::MESSAGE_SUCCESS, OSDType::MESSAGE_FILE_LINK, OSDType::PROGRESS_BAR, OSDType::MESSAGE_CENTERED_ERROR, OSDType::MESSAGE_CENTERED_WARNING}; + for (auto type : fullAlphaTypes) { + typeAlpha[(int)type] = 1.0f; + } + typeEdges[(size_t)OSDType::ACHIEVEMENT_CHALLENGE_INDICATOR] = (ScreenEdgePosition)g_Config.iAchievementsChallengePos; typeEdges[(size_t)OSDType::ACHIEVEMENT_PROGRESS] = (ScreenEdgePosition)g_Config.iAchievementsProgressPos; typeEdges[(size_t)OSDType::LEADERBOARD_TRACKER] = (ScreenEdgePosition)g_Config.iAchievementsLeaderboardTrackerPos; @@ -320,6 +320,9 @@ void OnScreenMessagesView::Draw(UIContext &dc) { dc.SetFontStyle(dc.GetTheme().uiFont); dc.SetFontScale(1.0f, 1.0f); + // Indexed by the enum ScreenEdgePosition. + LayoutEdge edges[(size_t)ScreenEdgePosition::VALUE_COUNT]{}; + // First pass: Measure all the sides. for (size_t i = 0; i < entries.size(); i++) { const auto &entry = entries[i]; @@ -435,7 +438,7 @@ void OnScreenMessagesView::Draw(UIContext &dc) { continue; } auto &measuredEntry = measuredEntries[j]; - float alpha = measuredEntry.alpha * edges[i].alpha; + float alpha = measuredEntry.alpha * typeAlpha[(size_t)entry.type]; Bounds b(padding, y, measuredEntry.w, measuredEntry.h); diff --git a/UI/SystemInfoScreen.cpp b/UI/SystemInfoScreen.cpp index 524e7ce43b..09cbc399ad 100644 --- a/UI/SystemInfoScreen.cpp +++ b/UI/SystemInfoScreen.cpp @@ -29,7 +29,7 @@ void SystemInfoScreen::update() { UITabbedBaseDialogScreen::update(); - g_OSD.NudgeSidebar(); + g_OSD.NudgeIngameNotifications(); } // TODO: How can we de-duplicate this and SystemInfoScreen::CreateTabs?