|
|
|
@ -1,6 +1,13 @@
|
|
|
|
|
#include <spdlog/spdlog.h>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <functional>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#include "overlay.h"
|
|
|
|
|
#include "overlay_params.h"
|
|
|
|
|
#include "hud_elements.h"
|
|
|
|
|
#include "logging.h"
|
|
|
|
|
#include "battery.h"
|
|
|
|
|
#include "cpu.h"
|
|
|
|
|
#include "memory.h"
|
|
|
|
|
#include "mesa/util/macros.h"
|
|
|
|
@ -48,6 +55,20 @@ ImVec4 LinearToSRGB(ImVec4 col)
|
|
|
|
|
return col;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T, typename R = float>
|
|
|
|
|
R format_units(T value, const char*& unit)
|
|
|
|
|
{
|
|
|
|
|
static const char* const units[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB"};
|
|
|
|
|
size_t u = 0;
|
|
|
|
|
R out_value = value;
|
|
|
|
|
while (out_value > 1023 && u < ARRAY_SIZE(units)) {
|
|
|
|
|
out_value /= 1024;
|
|
|
|
|
++u;
|
|
|
|
|
}
|
|
|
|
|
unit = units[u];
|
|
|
|
|
return out_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HudElements::convert_colors(struct overlay_params& params)
|
|
|
|
|
{
|
|
|
|
|
HUDElements.colors.update = false;
|
|
|
|
@ -273,6 +294,7 @@ void HudElements::core_load(){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HudElements::io_stats(){
|
|
|
|
|
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_io_read] || HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_io_write]){
|
|
|
|
|
ImGui::TableNextRow(); ImGui::TableNextColumn();
|
|
|
|
@ -324,6 +346,7 @@ void HudElements::vram(){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HudElements::ram(){
|
|
|
|
|
#ifdef __gnu_linux__
|
|
|
|
|
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_ram]){
|
|
|
|
@ -335,7 +358,7 @@ void HudElements::ram(){
|
|
|
|
|
ImGui::PushFont(HUDElements.sw_stats->font1);
|
|
|
|
|
ImGui::Text("GiB");
|
|
|
|
|
ImGui::PopFont();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_ram] && HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_swap]){
|
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
@ -348,6 +371,45 @@ void HudElements::ram(){
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HudElements::procmem()
|
|
|
|
|
{
|
|
|
|
|
const char* unit = nullptr;
|
|
|
|
|
if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_procmem])
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ImGui::TableNextRow(); ImGui::TableNextColumn();
|
|
|
|
|
ImGui::TextColored(HUDElements.colors.ram, "PMEM");
|
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
|
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%.1f", format_units(proc_mem.resident, unit));
|
|
|
|
|
ImGui::SameLine(0,1.0f);
|
|
|
|
|
ImGui::PushFont(HUDElements.sw_stats->font1);
|
|
|
|
|
ImGui::Text("%s", unit);
|
|
|
|
|
ImGui::PopFont();
|
|
|
|
|
|
|
|
|
|
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_procmem_shared]){
|
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
|
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%.1f", format_units(proc_mem.shared, unit));
|
|
|
|
|
ImGui::SameLine(0,1.0f);
|
|
|
|
|
ImGui::PushFont(HUDElements.sw_stats->font1);
|
|
|
|
|
ImGui::Text("%s", unit);
|
|
|
|
|
ImGui::PopFont();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_procmem_shared] && HUDElements.params->table_columns < 4){
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_procmem_virt]){
|
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
|
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%.1f", format_units(proc_mem.virt, unit));
|
|
|
|
|
ImGui::SameLine(0,1.0f);
|
|
|
|
|
ImGui::PushFont(HUDElements.sw_stats->font1);
|
|
|
|
|
ImGui::Text("%s", unit);
|
|
|
|
|
ImGui::PopFont();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HudElements::fps(){
|
|
|
|
|
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_fps]){
|
|
|
|
|
ImGui::TableNextRow(); ImGui::TableNextColumn();
|
|
|
|
@ -540,7 +602,7 @@ void HudElements::show_fps_limit(){
|
|
|
|
|
void HudElements::custom_text_center(){
|
|
|
|
|
ImGui::TableNextRow(); ImGui::TableNextColumn();
|
|
|
|
|
ImGui::PushFont(HUDElements.sw_stats->font1);
|
|
|
|
|
std::string value = HUDElements.ordered_functions[HUDElements.place].second;
|
|
|
|
|
const std::string& value = HUDElements.ordered_functions[HUDElements.place].second;
|
|
|
|
|
center_text(value);
|
|
|
|
|
ImGui::TextColored(HUDElements.colors.text, "%s",value.c_str());
|
|
|
|
|
ImGui::NewLine();
|
|
|
|
@ -550,13 +612,13 @@ void HudElements::custom_text_center(){
|
|
|
|
|
void HudElements::custom_text(){
|
|
|
|
|
ImGui::TableNextRow(); ImGui::TableNextColumn();
|
|
|
|
|
ImGui::PushFont(HUDElements.sw_stats->font1);
|
|
|
|
|
std::string value = HUDElements.ordered_functions[HUDElements.place].second;
|
|
|
|
|
const std::string& value = HUDElements.ordered_functions[HUDElements.place].second;
|
|
|
|
|
ImGui::TextColored(HUDElements.colors.text, "%s",value.c_str());
|
|
|
|
|
ImGui::PopFont();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HudElements::_exec(){
|
|
|
|
|
std::string value = HUDElements.ordered_functions[HUDElements.place].second;
|
|
|
|
|
//const std::string& value = HUDElements.ordered_functions[HUDElements.place].second;
|
|
|
|
|
ImGui::PushFont(HUDElements.sw_stats->font1);
|
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
|
for (auto& item : HUDElements.exec_list){
|
|
|
|
@ -633,7 +695,7 @@ void HudElements::battery(){
|
|
|
|
|
void HudElements::graphs(){
|
|
|
|
|
ImGui::TableNextRow(); ImGui::TableNextColumn();
|
|
|
|
|
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
|
|
|
|
|
std::string value = HUDElements.ordered_functions[HUDElements.place].second;
|
|
|
|
|
const std::string& value = HUDElements.ordered_functions[HUDElements.place].second;
|
|
|
|
|
std::vector<float> arr(50, 0);
|
|
|
|
|
|
|
|
|
|
ImGui::PushFont(HUDElements.sw_stats->font1);
|
|
|
|
@ -765,6 +827,7 @@ void HudElements::sort_elements(const std::pair<std::string, std::string>& optio
|
|
|
|
|
if (param == "io_stats") { ordered_functions.push_back({io_stats, value}); }
|
|
|
|
|
if (param == "vram") { ordered_functions.push_back({vram, value}); }
|
|
|
|
|
if (param == "ram") { ordered_functions.push_back({ram, value}); }
|
|
|
|
|
if (param == "procmem") { ordered_functions.push_back({procmem, value}); }
|
|
|
|
|
if (param == "fps") { ordered_functions.push_back({fps, value}); }
|
|
|
|
|
if (param == "engine_version") { ordered_functions.push_back({engine_version, value}); }
|
|
|
|
|
if (param == "gpu_name") { ordered_functions.push_back({gpu_name, value}); }
|
|
|
|
@ -790,7 +853,9 @@ void HudElements::sort_elements(const std::pair<std::string, std::string>& optio
|
|
|
|
|
if (find(permitted_params.begin(), permitted_params.end(), value) != permitted_params.end())
|
|
|
|
|
ordered_functions.push_back({graphs, value});
|
|
|
|
|
else
|
|
|
|
|
printf("MANGOHUD: Unrecognized graph type: %s\n", value.c_str());
|
|
|
|
|
{
|
|
|
|
|
spdlog::info("Unrecognized graph type: {}", value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|