diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index df427e5c0..b2580c0a2 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -3,9 +3,15 @@ #include "YBaseLib/Log.h" #include "YBaseLib/Timer.h" #include "bios.h" +#include "cdrom.h" #include "common/audio_stream.h" +#include "dma.h" +#include "gpu.h" #include "host_display.h" +#include "mdec.h" +#include "spu.h" #include "system.h" +#include "timers.h" #include Log_SetChannel(HostInterface); @@ -98,6 +104,73 @@ void HostInterface::ReportMessage(const char* message) Log_InfoPrintf(message); } +void HostInterface::DrawFPSWindow() +{ + const bool show_fps = true; + const bool show_vps = true; + const bool show_speed = true; + + if (!(show_fps | show_vps | show_speed)) + return; + + ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x - 175.0f, 0.0f), ImGuiCond_Always); + ImGui::SetNextWindowSize(ImVec2(175.0f, 16.0f)); + + if (!ImGui::Begin("FPSWindow", nullptr, + ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | + ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMouseInputs | + ImGuiWindowFlags_NoBringToFrontOnFocus)) + { + ImGui::End(); + return; + } + + bool first = true; + if (show_fps) + { + ImGui::Text("%.2f", m_fps); + first = false; + } + if (show_vps) + { + if (first) + { + first = false; + } + else + { + ImGui::SameLine(); + ImGui::Text("/"); + ImGui::SameLine(); + } + + ImGui::Text("%.2f", m_vps); + } + if (show_speed) + { + if (first) + { + first = false; + } + else + { + ImGui::SameLine(); + ImGui::Text("/"); + ImGui::SameLine(); + } + + const u32 rounded_speed = static_cast(std::round(m_speed)); + if (m_speed < 90.0f) + ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), "%u%%", rounded_speed); + else if (m_speed < 110.0f) + ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 1.0f), "%u%%", rounded_speed); + else + ImGui::TextColored(ImVec4(0.4f, 1.0f, 0.4f, 1.0f), "%u%%", rounded_speed); + } + + ImGui::End(); +} + void HostInterface::AddOSDMessage(const char* message, float duration /*= 2.0f*/) { OSDMessage msg; @@ -150,6 +223,22 @@ void HostInterface::DrawOSDMessages() } } +void HostInterface::DrawDebugWindows() +{ + const Settings::DebugSettings& debug_settings = m_system->GetSettings().debugging; + + if (debug_settings.show_gpu_state) + m_system->GetGPU()->DrawDebugStateWindow(); + if (debug_settings.show_cdrom_state) + m_system->GetCDROM()->DrawDebugWindow(); + if (debug_settings.show_timers_state) + m_system->GetTimers()->DrawDebugStateWindow(); + if (debug_settings.show_spu_state) + m_system->GetSPU()->DrawDebugStateWindow(); + if (debug_settings.show_mdec_state) + m_system->GetMDEC()->DrawDebugStateWindow(); +} + void HostInterface::ClearImGuiFocus() { ImGui::SetWindowFocus(nullptr); diff --git a/src/core/host_interface.h b/src/core/host_interface.h index 14391fd34..4f27b8bf0 100644 --- a/src/core/host_interface.h +++ b/src/core/host_interface.h @@ -65,7 +65,9 @@ protected: void UpdateSpeedLimiterState(); + void DrawFPSWindow(); void DrawOSDMessages(); + void DrawDebugWindows(); void ClearImGuiFocus(); void UpdatePerformanceCounters(); diff --git a/src/duckstation/sdl_host_interface.cpp b/src/duckstation/sdl_host_interface.cpp index 50ebca9e6..fb6246add 100644 --- a/src/duckstation/sdl_host_interface.cpp +++ b/src/duckstation/sdl_host_interface.cpp @@ -1,23 +1,18 @@ #include "sdl_host_interface.h" -#include "sdl_settings_interface.h" #include "YBaseLib/AutoReleasePtr.h" #include "YBaseLib/ByteStream.h" #include "YBaseLib/Error.h" #include "YBaseLib/Log.h" #include "common/null_audio_stream.h" -#include "core/cdrom.h" -#include "core/dma.h" +#include "core/controller.h" #include "core/gpu.h" #include "core/host_display.h" -#include "core/mdec.h" -#include "core/memory_card.h" -#include "core/spu.h" #include "core/system.h" -#include "core/timers.h" #include "icon.h" #include "imgui_styles.h" #include "opengl_host_display.h" #include "sdl_audio_stream.h" +#include "sdl_settings_interface.h" #include #include #include @@ -1412,22 +1407,6 @@ void SDLHostInterface::DrawAboutWindow() ImGui::EndPopup(); } -void SDLHostInterface::DrawDebugWindows() -{ - const Settings::DebugSettings& debug_settings = m_system->GetSettings().debugging; - - if (debug_settings.show_gpu_state) - m_system->GetGPU()->DrawDebugStateWindow(); - if (debug_settings.show_cdrom_state) - m_system->GetCDROM()->DrawDebugWindow(); - if (debug_settings.show_timers_state) - m_system->GetTimers()->DrawDebugStateWindow(); - if (debug_settings.show_spu_state) - m_system->GetSPU()->DrawDebugStateWindow(); - if (debug_settings.show_mdec_state) - m_system->GetMDEC()->DrawDebugStateWindow(); -} - bool SDLHostInterface::DrawFileChooser(const char* label, std::string* path, const char* filter /* = nullptr */) { ImGui::SetNextItemWidth(ImGui::CalcItemWidth() - 50.0f); diff --git a/src/duckstation/sdl_host_interface.h b/src/duckstation/sdl_host_interface.h index f98db99ed..b546da092 100644 --- a/src/duckstation/sdl_host_interface.h +++ b/src/duckstation/sdl_host_interface.h @@ -124,7 +124,6 @@ private: void DrawPoweredOffWindow(); void DrawSettingsWindow(); void DrawAboutWindow(); - void DrawDebugWindows(); bool DrawFileChooser(const char* label, std::string* path, const char* filter = nullptr); SDL_Window* m_window = nullptr;