ui: Moved FPS counter to footer
This commit is contained in:
parent
7007fb53e7
commit
e0112472d6
@ -17,6 +17,10 @@ namespace ImGui {
|
||||
|
||||
void Header(const char *label, bool firstEntry = false);
|
||||
|
||||
inline bool HasSecondPassed() {
|
||||
return static_cast<ImU32>(ImGui::GetTime() * 100) % 100 <= static_cast<ImU32>(ImGui::GetIO().DeltaTime * 100);
|
||||
}
|
||||
|
||||
std::tuple<ImTextureID, int, int> LoadImageFromPath(const char *path);
|
||||
void UnloadImage(ImTextureID texture);
|
||||
|
||||
|
@ -12,6 +12,7 @@ add_library(${PROJECT_NAME} SHARED
|
||||
source/content/settings_entries.cpp
|
||||
source/content/tools_entries.cpp
|
||||
source/content/data_processor_nodes.cpp
|
||||
source/content/footer_items.cpp
|
||||
|
||||
source/math_evaluator.cpp
|
||||
|
||||
|
21
plugins/builtin/source/content/footer_items.cpp
Normal file
21
plugins/builtin/source/content/footer_items.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include <hex/plugin.hpp>
|
||||
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
void addFooterItems() {
|
||||
|
||||
ContentRegistry::Interface::addFooterItem([] {
|
||||
static float framerate = 0;
|
||||
if (ImGui::HasSecondPassed()) {
|
||||
framerate = ImGui::GetIO().Framerate;
|
||||
}
|
||||
|
||||
ImGui::TextUnformatted(hex::format("FPS {0:.2f}", framerate).c_str());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -9,6 +9,8 @@ namespace hex::plugin::builtin {
|
||||
void registerSettings();
|
||||
void registerDataProcessorNodes();
|
||||
|
||||
void addFooterItems();
|
||||
|
||||
void registerLanguageEnUS();
|
||||
void registerLanguageDeDE();
|
||||
void registerLanguageItIT();
|
||||
@ -26,6 +28,8 @@ IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
|
||||
registerSettings();
|
||||
registerDataProcessorNodes();
|
||||
|
||||
addFooterItems();
|
||||
|
||||
registerLanguageEnUS();
|
||||
registerLanguageDeDE();
|
||||
registerLanguageItIT();
|
||||
|
@ -22,7 +22,7 @@ namespace hex::plugin::windows {
|
||||
ContentRegistry::Interface::addFooterItem([] {
|
||||
static float cpuUsage = 0.0F;
|
||||
|
||||
if (ImGui::GetFrameCount() % 60 == 0) {
|
||||
if (ImGui::HasSecondPassed()) {
|
||||
static ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU;
|
||||
static u32 numProcessors;
|
||||
static HANDLE self = GetCurrentProcess();
|
||||
@ -62,14 +62,14 @@ namespace hex::plugin::windows {
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::TextUnformatted(hex::format(ICON_FA_TACHOMETER_ALT " {0:.3}%", cpuUsage * 100).c_str());
|
||||
ImGui::TextUnformatted(hex::format(ICON_FA_TACHOMETER_ALT " {0:.2f}%", cpuUsage * 100).c_str());
|
||||
});
|
||||
|
||||
ContentRegistry::Interface::addFooterItem([] {
|
||||
static MEMORYSTATUSEX memInfo;
|
||||
static PROCESS_MEMORY_COUNTERS_EX pmc;
|
||||
|
||||
if (ImGui::GetFrameCount() % 60 == 0) {
|
||||
if (ImGui::HasSecondPassed()) {
|
||||
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
GlobalMemoryStatusEx(&memInfo);
|
||||
GetProcessMemoryInfo(GetCurrentProcess(), reinterpret_cast<PROCESS_MEMORY_COUNTERS*>(&pmc), sizeof(pmc));
|
||||
|
@ -339,26 +339,18 @@ namespace hex {
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("hex.menu.view"_lang)) {
|
||||
ImGui::Separator();
|
||||
ImGui::MenuItem("hex.menu.view.fps"_lang, "", &this->m_fpsVisible);
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG)
|
||||
ImGui::Separator();
|
||||
ImGui::MenuItem("hex.menu.view.demo"_lang, "", &this->m_demoWindowOpen);
|
||||
#endif
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (this->m_fpsVisible) {
|
||||
std::string fps = hex::format("{:.1f} FPS ", ImGui::GetIO().Framerate);
|
||||
#if defined(DEBUG)
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(ImGui::GetWindowWidth() - fps.length() * ImGui::GetFontSize());
|
||||
ImGui::TextUnformatted(fps.c_str());
|
||||
} else {
|
||||
#if defined(DEBUG)
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(ImGui::GetWindowWidth() - 2 * ImGui::GetFontSize());
|
||||
ImGui::TextUnformatted(ICON_FA_BUG);
|
||||
#endif
|
||||
}
|
||||
ImGui::SetCursorPosX(ImGui::GetWindowWidth() - 2 * ImGui::GetFontSize());
|
||||
ImGui::TextUnformatted(ICON_FA_BUG);
|
||||
#endif
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user