mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-04-28 13:27:58 +03:00
reddog: implemented FPS counter
This commit is contained in:
parent
dbdf020218
commit
d5ca843716
8 changed files with 43 additions and 17 deletions
|
@ -27,6 +27,7 @@
|
|||
#include <ui/options_menu.h>
|
||||
#include <ui/sdl_listener.h>
|
||||
#include <ui/game_window.h>
|
||||
#include <ui/imgui_utils.h>
|
||||
#include <user/config.h>
|
||||
#include <xxHashMap.h>
|
||||
|
||||
|
@ -2005,6 +2006,25 @@ void Video::DrawCounter()
|
|||
ImGui::Text("SDL Video Driver: %s", sdlVideoDriver);
|
||||
}
|
||||
|
||||
void Video::DrawFPS(ImFont* font)
|
||||
{
|
||||
if (!Config::ShowFPS)
|
||||
return;
|
||||
|
||||
auto drawList = ImGui::GetBackgroundDrawList();
|
||||
|
||||
auto fmt = fmt::format("FPS: {:.2f}", 1000.0 / g_presentProfiler.value.load());
|
||||
auto fontSize = Scale(12.0f);
|
||||
auto textSize = font->CalcTextSizeA(fontSize, FLT_MAX, 0, fmt.c_str());
|
||||
|
||||
ImVec2 min = { Scale(40), Scale(30) };
|
||||
ImVec2 max = { min.x + std::max(Scale(75), textSize.x + Scale(10)), min.y + Scale(15) };
|
||||
ImVec2 textPos = { min.x + Scale(2), CENTRE_TEXT_VERT(min, max, textSize) - Scale(0.5f) };
|
||||
|
||||
drawList->AddRectFilled(min, max, IM_COL32(0, 0, 0, 255));
|
||||
drawList->AddText(font, fontSize, textPos, IM_COL32_WHITE, fmt.c_str());
|
||||
}
|
||||
|
||||
static void DrawImGui()
|
||||
{
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
|
|
|
@ -21,6 +21,7 @@ struct Video
|
|||
static void StartPipelinePrecompilation();
|
||||
static void WaitForGPU();
|
||||
static void DrawCounter();
|
||||
static void DrawFPS(ImFont* font);
|
||||
};
|
||||
|
||||
struct GuestSamplerState
|
||||
|
|
|
@ -128,13 +128,6 @@ bool Reddog::Checkbox(const char* label, bool* v)
|
|||
return isPressed;
|
||||
}
|
||||
|
||||
void Reddog::Separator(float upperPadding, float lowerPadding)
|
||||
{
|
||||
ImGui::Dummy(ImVec2(0.0f, upperPadding));
|
||||
ImGui::Separator();
|
||||
ImGui::Dummy(ImVec2(0.0f, lowerPadding));
|
||||
}
|
||||
|
||||
bool Reddog::ExplicitButton(const char* label, EButtonTextAlignment textAlignment, const ImVec2& size, float fontScale)
|
||||
{
|
||||
auto window = ImGui::GetCurrentWindow();
|
||||
|
@ -187,3 +180,10 @@ bool Reddog::ExplicitButton(const char* label, EButtonTextAlignment textAlignmen
|
|||
|
||||
return isActive;
|
||||
}
|
||||
|
||||
void Reddog::Separator(float upperPadding, float lowerPadding)
|
||||
{
|
||||
ImGui::Dummy(ImVec2(0.0f, upperPadding));
|
||||
ImGui::Separator();
|
||||
ImGui::Dummy(ImVec2(0.0f, lowerPadding));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "reddog_manager.h"
|
||||
#include <gpu/imgui/imgui_snapshot.h>
|
||||
#include <gpu/video.h>
|
||||
#include <ui/reddog/windows/window_list.h>
|
||||
#include <ui/reddog/reddog_controls.h>
|
||||
|
@ -19,6 +20,7 @@ static bool g_isWindowListVisible = false;
|
|||
|
||||
void Reddog::Manager::Init()
|
||||
{
|
||||
s_font = ImFontAtlasSnapshot::GetFont("micross.ttf");
|
||||
g_upDebugIcon = LoadTexture(g_debug_icon, sizeof(g_debug_icon));
|
||||
|
||||
Reddog::InitControlsResources();
|
||||
|
@ -43,6 +45,8 @@ void Reddog::Manager::Draw()
|
|||
|
||||
g_isReddogToggled = isReddogToggled;
|
||||
|
||||
Video::DrawFPS(s_font);
|
||||
|
||||
if (!s_isVisible)
|
||||
return;
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace Reddog
|
|||
public:
|
||||
static inline bool s_isVisible = false;
|
||||
|
||||
static inline ImFont* s_font{ nullptr };
|
||||
|
||||
static void Init();
|
||||
static void Draw();
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#include "reddog_window.h"
|
||||
|
||||
#include <gpu/imgui/imgui_snapshot.h>
|
||||
#include <gpu/video.h>
|
||||
#include <ui/reddog/reddog_manager.h>
|
||||
#include <ui/game_window.h>
|
||||
|
@ -27,9 +25,7 @@ static std::unique_ptr<GuestTexture> g_upCommonIcon;
|
|||
static std::unique_ptr<GuestTexture> g_upTitleBar;
|
||||
static std::unique_ptr<GuestTexture> g_upWindowFrame;
|
||||
|
||||
ImFont* g_font;
|
||||
float g_defaultFontScale;
|
||||
|
||||
ImGuiStyle g_defaultStyle;
|
||||
|
||||
static std::vector<Reddog::IWindow*>& Reddog::GetWindows()
|
||||
|
@ -40,8 +36,7 @@ static std::vector<Reddog::IWindow*>& Reddog::GetWindows()
|
|||
|
||||
void Reddog::InitWindowResources()
|
||||
{
|
||||
g_font = ImFontAtlasSnapshot::GetFont("micross.ttf");
|
||||
g_defaultFontScale = g_font->Scale;
|
||||
g_defaultFontScale = Reddog::Manager::s_font->Scale;
|
||||
|
||||
auto& style = ImGui::GetStyle();
|
||||
g_defaultStyle = style;
|
||||
|
@ -58,9 +53,9 @@ void Reddog::InitWindowResources()
|
|||
|
||||
void Reddog::Window::BeginStyle()
|
||||
{
|
||||
g_font->Scale = ImGui::GetDefaultFont()->FontSize / g_font->FontSize;
|
||||
Reddog::Manager::s_font->Scale = ImGui::GetDefaultFont()->FontSize / Reddog::Manager::s_font->FontSize;
|
||||
|
||||
ImGui::PushFont(g_font);
|
||||
ImGui::PushFont(Reddog::Manager::s_font);
|
||||
|
||||
UpdateStyle();
|
||||
}
|
||||
|
@ -108,7 +103,7 @@ void Reddog::Window::EndStyle()
|
|||
{
|
||||
ImGui::PopFont();
|
||||
|
||||
g_font->Scale = g_defaultFontScale;
|
||||
Reddog::Manager::s_font->Scale = g_defaultFontScale;
|
||||
|
||||
ImGui::GetStyle() = g_defaultStyle;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "view_window.h"
|
||||
#include <gpu/video.h>
|
||||
#include <kernel/memory.h>
|
||||
#include <ui/reddog/reddog_controls.h>
|
||||
#include <ui/game_window.h>
|
||||
|
@ -10,6 +11,7 @@ void ViewWindow::Draw()
|
|||
{
|
||||
if (Begin())
|
||||
{
|
||||
Reddog::Checkbox("Render FPS", &Config::ShowFPS.Value);
|
||||
Reddog::Checkbox("Render HUD (F8)", (bool*)g_memory.Translate(0x8328BB26));
|
||||
Reddog::Separator();
|
||||
|
||||
|
|
|
@ -596,7 +596,7 @@ public:
|
|||
CONFIG_DEFINE_LOCALISED("System", bool, ControlTutorial, true);
|
||||
CONFIG_DEFINE_LOCALISED("System", bool, AchievementNotifications, true);
|
||||
CONFIG_DEFINE_ENUM_LOCALISED("System", ETimeOfDayTransition, TimeOfDayTransition, ETimeOfDayTransition::Xbox);
|
||||
CONFIG_DEFINE("System", bool, Debug, false);
|
||||
CONFIG_DEFINE_HIDDEN("System", bool, Debug, false);
|
||||
|
||||
CONFIG_DEFINE_LOCALISED("Input", bool, InvertCameraX, false);
|
||||
CONFIG_DEFINE_LOCALISED("Input", bool, InvertCameraY, false);
|
||||
|
@ -664,6 +664,8 @@ public:
|
|||
CONFIG_DEFINE_LOCALISED("Video", bool, XboxColorCorrection, false);
|
||||
CONFIG_DEFINE_ENUM_LOCALISED("Video", EUIScaleMode, UIScaleMode, EUIScaleMode::Edge);
|
||||
|
||||
CONFIG_DEFINE_HIDDEN("Debug", bool, ShowFPS, false);
|
||||
|
||||
CONFIG_DEFINE_HIDDEN("Exports", bool, AllowCancellingUnleash, false);
|
||||
CONFIG_DEFINE_HIDDEN("Exports", bool, DisableAutoSaveWarning, false);
|
||||
CONFIG_DEFINE_HIDDEN("Exports", bool, DisableDLCIcon, false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue