diff --git a/source/main/gui/panels/GUI_SimActorStats.cpp b/source/main/gui/panels/GUI_SimActorStats.cpp index d038cbc6f6..d660a6e0fe 100644 --- a/source/main/gui/panels/GUI_SimActorStats.cpp +++ b/source/main/gui/panels/GUI_SimActorStats.cpp @@ -40,6 +40,7 @@ void SimActorStats::Draw(RoR::GfxActor* actorx) ImGuiWindowFlags flags = ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar; ImGui::SetNextWindowPos(ImVec2(theme.screen_edge_padding.x, (theme.screen_edge_padding.y + 150))); + ImGui::PushStyleColor(ImGuiCol_WindowBg, theme.semitransparent_window_bg); ImGui::Begin("SimActorStats", nullptr, flags); RoR::ImTextWrappedColorMarked(actorx->GetActor()->getTruckName()); @@ -221,6 +222,7 @@ void SimActorStats::Draw(RoR::GfxActor* actorx) ImGui::NewLine(); ImGui::End(); + ImGui::PopStyleColor(1); // WindowBg } void SimActorStats::UpdateStats(float dt, Actor* actor) diff --git a/source/main/gui/panels/GUI_SimPerfStats.cpp b/source/main/gui/panels/GUI_SimPerfStats.cpp index e857984c77..3b186cdef2 100644 --- a/source/main/gui/panels/GUI_SimPerfStats.cpp +++ b/source/main/gui/panels/GUI_SimPerfStats.cpp @@ -24,6 +24,7 @@ #include "AppContext.h" #include "GUIManager.h" #include "Language.h" +#include #include #include @@ -42,10 +43,20 @@ void SimPerfStats::Draw() ImGui::Begin("FPS", &m_is_visible, flags); const Ogre::RenderTarget::FrameStats& stats = App::GetAppContext()->GetRenderWindow()->getStatistics(); - ImGui::Text("%s%.2f", _LC("SimPerfStats", "Current FPS: "), stats.lastFPS); - ImGui::Text("%s%.2f", _LC("SimPerfStats", "Average FPS: "), stats.avgFPS); - ImGui::Text("%s%.2f", _LC("SimPerfStats", "Worst FPS: "), stats.worstFPS); - ImGui::Text("%s%.2f", _LC("SimPerfStats", "Best FPS: "), stats.bestFPS); + + std::string title = "FPS"; + ImGui::SetCursorPosX((ImGui::GetWindowSize().x - ImGui::CalcTextSize(title.c_str()).x) * 0.5f); + ImGui::Text(title.c_str()); + ImGui::Text("%s", _LC("SimPerfStats", " Current Average Worst Best")); + + ImGui::PlotHistogram("", &stats.lastFPS, 1, 0, this->Convert(stats.lastFPS).c_str(), 0.f, 300.f, ImVec2(60, 35)); + ImGui::SameLine(); + ImGui::PlotHistogram("", &stats.avgFPS, 1, 0, this->Convert(stats.avgFPS).c_str(), 0.f, 300.f, ImVec2(60, 35)); + ImGui::SameLine(); + ImGui::PlotHistogram("", &stats.worstFPS, 1, 0, this->Convert(stats.worstFPS).c_str(), 0.f, 300.f, ImVec2(60, 35)); + ImGui::SameLine(); + ImGui::PlotHistogram("", &stats.bestFPS, 1, 0, this->Convert(stats.bestFPS).c_str(), 0.f, 300.f, ImVec2(60, 35)); + ImGui::Separator(); ImGui::Text("%s%zu", _LC("SimPerfStats", "Triangle count: "), stats.triangleCount); ImGui::Text("%s%zu", _LC("SimPerfStats", "Batch count: "), stats.batchCount); @@ -53,3 +64,10 @@ void SimPerfStats::Draw() ImGui::End(); ImGui::PopStyleColor(1); // WindowBg } + +std::string SimPerfStats::Convert(const float f) +{ + std::stringstream s; + s << std::fixed << std::setprecision(2) << f; + return s.str(); +} \ No newline at end of file diff --git a/source/main/gui/panels/GUI_SimPerfStats.h b/source/main/gui/panels/GUI_SimPerfStats.h index 70c98a5fd2..b64ba4e48c 100644 --- a/source/main/gui/panels/GUI_SimPerfStats.h +++ b/source/main/gui/panels/GUI_SimPerfStats.h @@ -34,6 +34,7 @@ class SimPerfStats private: bool m_is_visible = false; + std::string Convert(const float f); // converts const float to std::string with precision }; } // namespace GUI