diff options
| author | shuffle2 <godisgovernment@gmail.com> | 2016-10-03 20:09:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-03 20:09:35 -0700 |
| commit | 5c0fa4db4fa4a2533c190825e83675f074eaf50c (patch) | |
| tree | f012c83d0f2ed32f49d2b43fa1c877d629cbdfee /Source/Core/VideoCommon | |
| parent | b8731eb8180d76b4663eaf4188f985b9c5fa6fb2 (diff) | |
| parent | fa5fa8e09473fb8750af2a21fa24dff76970a681 (diff) | |
Merge pull request #4286 from shuffle2/Aestek-clean-osd
Clean OSD messages code
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/OnScreenDisplay.cpp | 12 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/OnScreenDisplay.h | 8 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/RenderBase.cpp | 146 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/RenderBase.h | 1 |
4 files changed, 38 insertions, 129 deletions
diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index 62997cd150..d0f6f24825 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -21,18 +21,24 @@ static std::multimap<CallbackType, Callback> s_callbacks; static std::multimap<MessageType, Message> s_messages; static std::mutex s_messages_mutex; +static std::string CleanMessage(std::string message) +{ + std::replace_if(message.begin(), message.end(), [](char c) { return !std::isprint(c); }, '?'); + return message; +} + void AddTypedMessage(MessageType type, const std::string& message, u32 ms, u32 rgba) { std::lock_guard<std::mutex> lock(s_messages_mutex); s_messages.erase(type); - s_messages.emplace(type, Message(message, Common::Timer::GetTimeMs() + ms, rgba)); + s_messages.emplace(type, Message(CleanMessage(message), Common::Timer::GetTimeMs() + ms, rgba)); } void AddMessage(const std::string& message, u32 ms, u32 rgba) { std::lock_guard<std::mutex> lock(s_messages_mutex); s_messages.emplace(MessageType::Typeless, - Message(message, Common::Timer::GetTimeMs() + ms, rgba)); + Message(CleanMessage(message), Common::Timer::GetTimeMs() + ms, rgba)); } void DrawMessage(const Message& msg, int top, int left, int time_left) @@ -52,7 +58,7 @@ void DrawMessages() std::lock_guard<std::mutex> lock(s_messages_mutex); u32 now = Common::Timer::GetTimeMs(); - int left = 20, top = 35; + int left = 20, top = 20; auto it = s_messages.begin(); while (it != s_messages.end()) diff --git a/Source/Core/VideoCommon/OnScreenDisplay.h b/Source/Core/VideoCommon/OnScreenDisplay.h index a05f4058ef..cf8d66db72 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.h +++ b/Source/Core/VideoCommon/OnScreenDisplay.h @@ -22,6 +22,14 @@ struct Message enum class MessageType { + FPS, + FrameCount, + RTC, + + MovieInputCount, + MovieLag, + MovieInput, + NetPlayPing, NetPlayBuffer, diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 4f093c4ee6..67ef0d8a61 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -32,6 +32,7 @@ #include "Core/Host.h" #include "Core/Movie.h" +#include "OnScreenDisplay.h" #include "VideoCommon/AVIDump.h" #include "VideoCommon/BPMemory.h" #include "VideoCommon/CPMemory.h" @@ -48,8 +49,6 @@ // TODO: Move these out of here. int frameCount; -int OSDChoice; -static int OSDTime; std::unique_ptr<Renderer> g_renderer; @@ -106,9 +105,6 @@ Renderer::Renderer() : frame_data(), bLastFrameDumped(false) #if defined _WIN32 || defined HAVE_LIBAV bAVIDumping = false; #endif - - OSDChoice = 0; - OSDTime = 0; } Renderer::~Renderer() @@ -302,146 +298,46 @@ void Renderer::SetScreenshot(const std::string& filename) s_bScreenshot = true; } -// Create On-Screen-Messages void Renderer::DrawDebugText() { - std::string final_yellow, final_cyan; + auto draw_text = [](OSD::MessageType type, const std::string& message) { + OSD::AddTypedMessage(type, message, OSD::Duration::SHORT, OSD::Color::CYAN); + }; + + if (g_ActiveConfig.bShowFPS) + { + draw_text(OSD::MessageType::FPS, + StringFromFormat("FPS: %u", g_renderer->m_fps_counter.GetFPS())); + } - if (g_ActiveConfig.bShowFPS || SConfig::GetInstance().m_ShowFrameCount) + if (SConfig::GetInstance().m_ShowFrameCount) { - if (g_ActiveConfig.bShowFPS) - final_cyan += StringFromFormat("FPS: %u", g_renderer->m_fps_counter.GetFPS()); + draw_text(OSD::MessageType::FrameCount, + StringFromFormat("Frame: %" PRIx64, Movie::GetCurrentFrame())); - if (g_ActiveConfig.bShowFPS && SConfig::GetInstance().m_ShowFrameCount) - final_cyan += " - "; - if (SConfig::GetInstance().m_ShowFrameCount) + if (Movie::IsPlayingInput()) { - final_cyan += StringFromFormat("Frame: %llu", (unsigned long long)Movie::GetCurrentFrame()); - if (Movie::IsPlayingInput()) - final_cyan += StringFromFormat("\nInput: %llu / %llu", - (unsigned long long)Movie::GetCurrentInputCount(), - (unsigned long long)Movie::GetTotalInputCount()); + draw_text(OSD::MessageType::MovieInputCount, + StringFromFormat("Input: %" PRIx64 " / %" PRIx64, Movie::GetCurrentInputCount(), + Movie::GetTotalInputCount())); } - - final_cyan += "\n"; - final_yellow += "\n"; } if (SConfig::GetInstance().m_ShowLag) { - final_cyan += StringFromFormat("Lag: %" PRIu64 "\n", Movie::GetCurrentLagCount()); - final_yellow += "\n"; + draw_text(OSD::MessageType::MovieLag, + StringFromFormat("Lag: %" PRIu64 "\n", Movie::GetCurrentLagCount())); } if (SConfig::GetInstance().m_ShowInputDisplay) { - final_cyan += Movie::GetInputDisplay(); - final_yellow += "\n"; + draw_text(OSD::MessageType::MovieInput, Movie::GetInputDisplay()); } if (SConfig::GetInstance().m_ShowRTC) { - final_cyan += Movie::GetRTCDisplay(); - final_yellow += "\n"; + draw_text(OSD::MessageType::RTC, Movie::GetRTCDisplay()); } - - // OSD Menu messages - if (OSDChoice > 0) - { - OSDTime = Common::Timer::GetTimeMs() + 3000; - OSDChoice = -OSDChoice; - } - - if ((u32)OSDTime > Common::Timer::GetTimeMs()) - { - std::string res_text; - switch (g_ActiveConfig.iEFBScale) - { - case SCALE_AUTO: - res_text = "Auto (fractional)"; - break; - case SCALE_AUTO_INTEGRAL: - res_text = "Auto (integral)"; - break; - case SCALE_1X: - res_text = "Native"; - break; - case SCALE_1_5X: - res_text = "1.5x"; - break; - case SCALE_2X: - res_text = "2x"; - break; - case SCALE_2_5X: - res_text = "2.5x"; - break; - default: - res_text = StringFromFormat("%dx", g_ActiveConfig.iEFBScale - 3); - break; - } - const char* ar_text = ""; - switch (g_ActiveConfig.iAspectRatio) - { - case ASPECT_AUTO: - ar_text = "Auto"; - break; - case ASPECT_STRETCH: - ar_text = "Stretch"; - break; - case ASPECT_ANALOG: - ar_text = "Force 4:3"; - break; - case ASPECT_ANALOG_WIDE: - ar_text = "Force 16:9"; - } - - const char* const efbcopy_text = g_ActiveConfig.bSkipEFBCopyToRam ? "to Texture" : "to RAM"; - - // The rows - const std::string lines[] = { - std::string("Internal Resolution: ") + res_text, - std::string("Aspect Ratio: ") + ar_text + (g_ActiveConfig.bCrop ? " (crop)" : ""), - std::string("Copy EFB: ") + efbcopy_text, - std::string("Fog: ") + (g_ActiveConfig.bDisableFog ? "Disabled" : "Enabled"), - SConfig::GetInstance().m_EmulationSpeed <= 0 ? - "Speed Limit: Unlimited" : - StringFromFormat("Speed Limit: %li%%", - std::lround(SConfig::GetInstance().m_EmulationSpeed * 100.f)), - }; - - enum - { - lines_count = sizeof(lines) / sizeof(*lines) - }; - - // The latest changed setting in yellow - for (int i = 0; i != lines_count; ++i) - { - if (OSDChoice == -i - 1) - final_yellow += lines[i]; - final_yellow += '\n'; - } - - // The other settings in cyan - for (int i = 0; i != lines_count; ++i) - { - if (OSDChoice != -i - 1) - final_cyan += lines[i]; - final_cyan += '\n'; - } - } - - final_cyan += Common::Profiler::ToString(); - - if (g_ActiveConfig.bOverlayStats) - final_cyan += Statistics::ToString(); - - if (g_ActiveConfig.bOverlayProjStats) - final_cyan += Statistics::ToStringProj(); - - // and then the text - g_renderer->RenderText(final_cyan, 20, 20, 0xFF00FFFF); - g_renderer->RenderText(final_yellow, 20, 20, 0xFFFFFF00); } void Renderer::UpdateDrawRectangle(int backbuffer_width, int backbuffer_height) diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index b0d2ac1234..584c8dbec6 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -38,7 +38,6 @@ struct EfbPokeData // TODO: Move these out of here. extern int frameCount; -extern int OSDChoice; // Renderer really isn't a very good name for this class - it's more like "Misc". // The long term goal is to get rid of this class and replace it with others that make |
