Merge pull request #379 from flightlessmango/sort_elements

Sorting hud elements
pull/392/head
flightlessmango 4 years ago committed by GitHub
commit 182d3d2137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,7 +6,7 @@
#include "config.h"
#include "file_utils.h"
#include "string_utils.h"
#include "hud_elements.h"
std::string program_name;
void parseConfigLine(std::string line, std::unordered_map<std::string,std::string>& options) {
@ -24,8 +24,10 @@ void parseConfigLine(std::string line, std::unordered_map<std::string,std::strin
param = line.substr(0, equal);
trim(param);
trim(value);
if (!param.empty())
if (!param.empty()){
HUDElements.options.push_back({param, value});
options[param] = value;
}
}
void enumerate_config_files(std::vector<std::string>& paths)
@ -67,6 +69,7 @@ void enumerate_config_files(std::vector<std::string>& paths)
}
void parseConfigFile(overlay_params& params) {
HUDElements.options.clear();
params.options.clear();
std::vector<std::string> paths;
const char *cfg_file = getenv("MANGOHUD_CONFIGFILE");

@ -0,0 +1,529 @@
#include <algorithm>
#include "hud_elements.h"
#include "cpu.h"
#include "memory.h"
#include "mesa/util/macros.h"
void HudElements::time(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_time]){
ImGui::TableNextRow();
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 1.00f), "%s", HUDElements.sw_stats->time.c_str());
}
}
void HudElements::version(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_version]){
ImGui::TableNextRow();
ImGui::Text("%s", MANGOHUD_VERSION);
}
}
void HudElements::gpu_stats(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_stats]){
ImGui::TableNextRow();
const char* gpu_text;
if (HUDElements.params->gpu_text.empty())
gpu_text = "GPU";
else
gpu_text = HUDElements.params->gpu_text.c_str();
ImGui::TextColored(HUDElements.sw_stats->colors.gpu, "%s", gpu_text);
ImGui::TableNextCell();
auto text_color = HUDElements.sw_stats->colors.text;
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_load_change]){
struct LOAD_DATA gpu_data = {HUDElements.sw_stats->colors.gpu_load_high,
HUDElements.sw_stats->colors.gpu_load_med,
HUDElements.sw_stats->colors.gpu_load_low,
HUDElements.params->gpu_load_value[0],
HUDElements.params->gpu_load_value[1]
};
auto load_color = change_on_load_temp(gpu_data, gpu_info.load);
right_aligned_text(load_color, HUDElements.ralign_width, "%i", gpu_info.load);
ImGui::SameLine(0, 1.0f);
ImGui::TextColored(load_color,"%%");
}
else {
right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.load);
ImGui::SameLine(0, 1.0f);
ImGui::TextColored(text_color,"%%");
// ImGui::SameLine(150);
// ImGui::Text("%s", "%");
}
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_temp]){
ImGui::TableNextCell();
right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.temp);
ImGui::SameLine(0, 1.0f);
ImGui::Text("°C");
}
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_core_clock] || HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_power])
ImGui::TableNextRow();
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_core_clock]){
ImGui::TableNextCell();
right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.CoreClock);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("MHz");
ImGui::PopFont();
}
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_power]) {
ImGui::TableNextCell();
right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.powerUsage);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("W");
ImGui::PopFont();
}
}
}
void HudElements::cpu_stats(){
if(HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_cpu_stats]){
ImGui::TableNextRow();
const char* cpu_text;
if (HUDElements.params->cpu_text.empty())
cpu_text = "CPU";
else
cpu_text = HUDElements.params->cpu_text.c_str();
ImGui::TextColored(HUDElements.sw_stats->colors.cpu, "%s", cpu_text);
ImGui::TableNextCell();
auto text_color = HUDElements.sw_stats->colors.text;
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_cpu_load_change]){
int cpu_load_percent = int(cpuStats.GetCPUDataTotal().percent);
struct LOAD_DATA cpu_data = {HUDElements.sw_stats->colors.cpu_load_high,
HUDElements.sw_stats->colors.cpu_load_med,
HUDElements.sw_stats->colors.cpu_load_low,
HUDElements.params->cpu_load_value[0],
HUDElements.params->cpu_load_value[1]
};
auto load_color = change_on_load_temp(cpu_data, cpu_load_percent);
right_aligned_text(load_color, HUDElements.ralign_width, "%d", cpu_load_percent);
ImGui::SameLine(0, 1.0f);
ImGui::TextColored(load_color, "%%");
}
else {
right_aligned_text(text_color, HUDElements.ralign_width, "%d", int(cpuStats.GetCPUDataTotal().percent));
ImGui::SameLine(0, 1.0f);
ImGui::Text("%%");
}
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_cpu_temp]){
ImGui::TableNextCell();
right_aligned_text(HUDElements.sw_stats->colors.text, HUDElements.ralign_width, "%i", cpuStats.GetCPUDataTotal().temp);
ImGui::SameLine(0, 1.0f);
ImGui::Text("°C");
}
}
}
void HudElements::core_load(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_core_load]){
int i = 0;
for (const CPUData &cpuData : cpuStats.GetCPUData())
{
ImGui::TableNextRow();
ImGui::TextColored(HUDElements.sw_stats->colors.cpu, "CPU");
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.sw_stats->colors.cpu,"%i", i);
ImGui::PopFont();
ImGui::TableNextCell();
right_aligned_text(HUDElements.sw_stats->colors.text, HUDElements.ralign_width, "%i", int(cpuData.percent));
ImGui::SameLine(0, 1.0f);
ImGui::Text("%%");
ImGui::TableNextCell();
right_aligned_text(HUDElements.sw_stats->colors.text, HUDElements.ralign_width, "%i", cpuData.mhz);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("MHz");
ImGui::PopFont();
i++;
}
}
}
void HudElements::io_stats(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_io_read] || HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_io_write]){
auto sampling = HUDElements.params->fps_sampling_period;
ImGui::TableNextRow();
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_io_read] && !HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_io_write])
ImGui::TextColored(HUDElements.sw_stats->colors.io, "IO RD");
else if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_io_read] && HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_io_write])
ImGui::TextColored(HUDElements.sw_stats->colors.io, "IO RW");
else if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_io_write] && !HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_io_read])
ImGui::TextColored(HUDElements.sw_stats->colors.io, "IO WR");
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_io_read]){
ImGui::TableNextCell();
float val = HUDElements.sw_stats->io.diff.read * 1000000 / sampling;
right_aligned_text(HUDElements.sw_stats->colors.text, HUDElements.ralign_width, val < 100 ? "%.1f" : "%.f", val);
ImGui::SameLine(0,1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("MiB/s");
ImGui::PopFont();
}
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_io_write]){
ImGui::TableNextCell();
float val = HUDElements.sw_stats->io.diff.write * 1000000 / sampling;
right_aligned_text(HUDElements.sw_stats->colors.text, HUDElements.ralign_width, val < 100 ? "%.1f" : "%.f", val);
ImGui::SameLine(0,1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("MiB/s");
ImGui::PopFont();
}
}
}
void HudElements::vram(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_vram]){
ImGui::TableNextRow();
ImGui::TextColored(HUDElements.sw_stats->colors.vram, "VRAM");
ImGui::TableNextCell();
right_aligned_text(HUDElements.sw_stats->colors.text, HUDElements.ralign_width, "%.1f", gpu_info.memoryUsed);
ImGui::SameLine(0,1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("GiB");
ImGui::PopFont();
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_mem_clock]){
ImGui::TableNextCell();
right_aligned_text(HUDElements.sw_stats->colors.text, HUDElements.ralign_width, "%i", gpu_info.MemClock);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("MHz");
ImGui::PopFont();
}
}
}
void HudElements::ram(){
#ifdef __gnu_linux__
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_ram]){
ImGui::TableNextRow();
ImGui::TextColored(HUDElements.sw_stats->colors.ram, "RAM");
ImGui::TableNextCell();
right_aligned_text(HUDElements.sw_stats->colors.text, HUDElements.ralign_width, "%.1f", memused);
ImGui::SameLine(0,1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("GiB");
ImGui::PopFont();
}
#endif
}
void HudElements::fps(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_fps]){
ImGui::TableNextRow();
if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_fps] && HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_engine_version]){
ImGui::TextColored(HUDElements.sw_stats->colors.engine, "%s", HUDElements.is_vulkan ? HUDElements.sw_stats->engineName.c_str() : "OpenGL");
}
ImGui::TextColored(HUDElements.sw_stats->colors.engine, "%s", HUDElements.is_vulkan ? HUDElements.sw_stats->engineName.c_str() : "OpenGL");
ImGui::TableNextCell();
right_aligned_text(HUDElements.sw_stats->colors.text, HUDElements.ralign_width, "%.0f", HUDElements.sw_stats->fps);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("FPS");
ImGui::PopFont();
ImGui::TableNextCell();
right_aligned_text(HUDElements.sw_stats->colors.text, HUDElements.ralign_width, "%.1f", 1000 / HUDElements.sw_stats->fps);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("ms");
ImGui::PopFont();
}
}
void HudElements::gpu_name(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_name] && !HUDElements.sw_stats->gpuName.empty()){
ImGui::TableNextRow();
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.sw_stats->colors.engine,
"%s", HUDElements.sw_stats->gpuName.c_str());
ImGui::PopFont();
}
}
void HudElements::engine_version(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_engine_version]){
ImGui::TableNextRow();
ImGui::PushFont(HUDElements.sw_stats->font1);
if (HUDElements.is_vulkan) {
if ((HUDElements.sw_stats->engineName == "DXVK" || HUDElements.sw_stats->engineName == "VKD3D")){
ImGui::TextColored(HUDElements.sw_stats->colors.engine,
"%s/%d.%d.%d", HUDElements.sw_stats->engineVersion.c_str(),
HUDElements.sw_stats->version_vk.major,
HUDElements.sw_stats->version_vk.minor,
HUDElements.sw_stats->version_vk.patch);
} else {
ImGui::TextColored(HUDElements.sw_stats->colors.engine,
"%d.%d.%d",
HUDElements.sw_stats->version_vk.major,
HUDElements.sw_stats->version_vk.minor,
HUDElements.sw_stats->version_vk.patch);
}
} else {
ImGui::TextColored(HUDElements.sw_stats->colors.engine,
"%d.%d%s", HUDElements.sw_stats->version_gl.major, HUDElements.sw_stats->version_gl.minor,
HUDElements.sw_stats->version_gl.is_gles ? " ES" : "");
}
ImGui::PopFont();
}
}
void HudElements::vulkan_driver(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_vulkan_driver] && !HUDElements.sw_stats->driverName.empty()){
ImGui::TableNextRow();
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.sw_stats->colors.engine,
"%s", HUDElements.sw_stats->driverName.c_str());
ImGui::PopFont();
}
}
void HudElements::arch(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_arch]){
ImGui::TableNextRow();
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.sw_stats->colors.engine, "%s", "" MANGOHUD_ARCH);
ImGui::PopFont();
}
}
void HudElements::wine(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_wine]){
ImGui::TableNextRow();
if (!wineVersion.empty()){
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.sw_stats->colors.wine, "%s", wineVersion.c_str());
ImGui::PopFont();
}
}
}
void HudElements::frame_timing(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_frame_timing]){
ImGui::TableNextRow();
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.sw_stats->colors.engine, "%s", "Frametime");
ImGui::PopFont();
ImGui::TableNextRow();
char hash[40];
snprintf(hash, sizeof(hash), "##%s", overlay_param_names[OVERLAY_PARAM_ENABLED_frame_timing]);
HUDElements.sw_stats->stat_selector = OVERLAY_PLOTS_frame_timing;
HUDElements.sw_stats->time_dividor = 1000.0f;
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
double min_time = 0.0f;
double max_time = 50.0f;
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_histogram]){
ImGui::PlotHistogram(hash, get_time_stat, HUDElements.sw_stats,
ARRAY_SIZE(HUDElements.sw_stats->frames_stats), 0,
NULL, min_time, max_time,
ImVec2(ImGui::GetContentRegionAvailWidth() * 2.5, 50));
} else {
ImGui::PlotLines(hash, get_time_stat, HUDElements.sw_stats,
ARRAY_SIZE(HUDElements.sw_stats->frames_stats), 0,
NULL, min_time, max_time,
ImVec2(ImGui::GetContentRegionAvailWidth() * 2.5, 50));
}
ImGui::PopStyleColor();
ImGui::SameLine(0,1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("%.1f ms", 1000 / HUDElements.sw_stats->fps); //frame_timing / 1000.f);
ImGui::PopFont();
}
}
void HudElements::media_player(){
#ifdef HAVE_DBUS
ImGui::TableNextRow();
uint32_t f_idx = (HUDElements.sw_stats->n_frames - 1) % ARRAY_SIZE(HUDElements.sw_stats->frames_stats);
uint64_t frame_timing = HUDElements.sw_stats->frames_stats[f_idx].stats[OVERLAY_PLOTS_frame_timing];
ImFont scaled_font = *HUDElements.sw_stats->font_text;
scaled_font.Scale = HUDElements.params->font_scale_media_player;
ImGui::PushFont(&scaled_font);
{
std::lock_guard<std::mutex> lck(main_metadata.mtx);
render_mpris_metadata(*HUDElements.params, main_metadata, frame_timing, true);
}
ImGui::PopFont();
#endif
}
void HudElements::graphs(){
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
std::string value = HUDElements.ordered_functions[HUDElements.place].second;
std::vector<float> arr;
for (size_t i = 0; i < 50; i++)
{
arr.push_back(0);
}
if (value == "cpu_load"){
for (auto& it : graph_data){
arr.push_back(float(it.cpu_load));
arr.erase(arr.begin());
}
HUDElements.max = 100; HUDElements.min = 0;
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.sw_stats->colors.engine, "%s", "CPU Load");
ImGui::PopFont();
}
if (value == "gpu_load"){
for (auto& it : graph_data){
arr.push_back(float(it.gpu_load));
arr.erase(arr.begin());
}
HUDElements.max = 100; HUDElements.min = 0;
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.sw_stats->colors.engine, "%s", "GPU Load");
ImGui::PopFont();
}
if (value == "cpu_temp"){
if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_cpu_temp])
HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_cpu_temp] = true;
for (auto& it : graph_data){
arr.push_back(float(it.cpu_temp));
arr.erase(arr.begin());
}
if (int(arr.back()) > HUDElements.cpu_temp_max)
HUDElements.cpu_temp_max = arr.back();
HUDElements.max = HUDElements.cpu_temp_max;
HUDElements.min = 0;
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.sw_stats->colors.engine, "%s", "CPU Temp");
ImGui::PopFont();
}
if (value == "gpu_temp"){
if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_temp])
HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_temp] = true;
for (auto& it : graph_data){
arr.push_back(float(it.gpu_temp));
arr.erase(arr.begin());
}
if (int(arr.back()) > HUDElements.gpu_temp_max)
HUDElements.gpu_temp_max = arr.back();
HUDElements.max = HUDElements.gpu_temp_max;
HUDElements.min = 0;
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.sw_stats->colors.engine, "%s", "GPU Temp");
ImGui::PopFont();
}
if (value == "gpu_core_clock"){
for (auto& it : graph_data){
arr.push_back(float(it.gpu_core_clock));
arr.erase(arr.begin());
}
if (int(arr.back()) > HUDElements.gpu_core_max)
HUDElements.gpu_core_max = arr.back();
HUDElements.max = HUDElements.gpu_core_max;
HUDElements.min = 0;
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.sw_stats->colors.engine, "%s", "GPU Core Clock");
ImGui::PopFont();
}
if (value == "gpu_mem_clock"){
for (auto& it : graph_data){
arr.push_back(float(it.gpu_mem_clock));
arr.erase(arr.begin());
}
if (int(arr.back()) > HUDElements.gpu_mem_max)
HUDElements.gpu_mem_max = arr.back();
HUDElements.max = HUDElements.gpu_mem_max;
HUDElements.min = 0;
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.sw_stats->colors.engine, "%s", "GPU Mem Clock");
ImGui::PopFont();
}
if (value == "vram"){
for (auto& it : graph_data){
arr.push_back(float(it.gpu_vram_used));
arr.erase(arr.begin());
}
HUDElements.max = gpu_info.memoryTotal;
HUDElements.min = 0;
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.sw_stats->colors.engine, "%s", "VRAM");
ImGui::PopFont();
}
if (value == "ram"){
if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_ram])
HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_ram] = true;
for (auto& it : graph_data){
arr.push_back(float(it.ram_used));
arr.erase(arr.begin());
}
HUDElements.max = memmax;
HUDElements.min = 0;
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.sw_stats->colors.engine, "%s", "RAM");
ImGui::PopFont();
}
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
ImGui::TableNextRow();
ImGui::PlotLines("", arr.data(),
arr.size(), 0,
NULL, HUDElements.min, HUDElements.max,
ImVec2(ImGui::GetContentRegionAvailWidth() * 2.5, 50));
ImGui::PopStyleColor(1);
}
void HudElements::sort_elements(std::pair<std::string, std::string> option){
auto param = option.first;
auto value = option.second;
if (param == "version") { ordered_functions.push_back({version, value}); }
if (param == "time") { ordered_functions.push_back({time, value}); }
if (param == "gpu_stats") { ordered_functions.push_back({gpu_stats, value}); }
if (param == "cpu_stats") { ordered_functions.push_back({cpu_stats, value}); }
if (param == "core_load") { ordered_functions.push_back({core_load, value}); }
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 == "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}); }
if (param == "vulkan_driver") { ordered_functions.push_back({vulkan_driver, value}); }
if (param == "arch") { ordered_functions.push_back({arch, value}); }
if (param == "wine") { ordered_functions.push_back({wine, value}); }
if (param == "frame_timing") { ordered_functions.push_back({frame_timing, value}); }
if (param == "media_player") { ordered_functions.push_back({media_player, value}); }
if (param == "graphs"){
stringstream ss; ss << value;
while (getline(ss, value, '+')) {
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());
}
}
return;
}
void HudElements::legacy_elements(){
string value = "NULL";
ordered_functions.push_back({time, value});
ordered_functions.push_back({version, value});
ordered_functions.push_back({gpu_stats, value});
ordered_functions.push_back({cpu_stats, value});
ordered_functions.push_back({core_load, value});
ordered_functions.push_back({io_stats, value});
ordered_functions.push_back({vram, value});
ordered_functions.push_back({ram, value});
ordered_functions.push_back({fps, value});
ordered_functions.push_back({engine_version, value});
ordered_functions.push_back({gpu_name, value});
ordered_functions.push_back({vulkan_driver, value});
ordered_functions.push_back({arch, value});
ordered_functions.push_back({wine, value});
ordered_functions.push_back({frame_timing, value});
ordered_functions.push_back({media_player, value});
}
HudElements HUDElements;

@ -0,0 +1,44 @@
#pragma once
#include "overlay.h"
#include "overlay_params.h"
#include <functional>
#include <map>
#include <sstream>
class HudElements{
public:
struct swapchain_stats *sw_stats;
struct overlay_params *params;
float ralign_width;
float old_scale;
bool is_vulkan;
int place;
std::vector<std::pair<std::string, std::string>> options;
std::vector<std::pair<void(*)(), std::string >> ordered_functions;
int min, max, gpu_core_max, gpu_mem_max, cpu_temp_max, gpu_temp_max;
std::vector<std::string> permitted_params = {
"gpu_load", "cpu_load", "gpu_core_clock", "gpu_mem_clock",
"vram", "ram", "cpu_temp", "gpu_temp"
};
void sort_elements(std::pair<std::string, std::string> option);
void legacy_elements();
static void version();
static void time();
static void gpu_stats();
static void cpu_stats();
static void core_load();
static void io_stats();
static void vram();
static void ram();
static void fps();
static void engine_version();
static void gpu_name();
static void vulkan_driver();
static void arch();
static void wine();
static void frame_timing();
static void media_player();
static void graphs();
};
extern HudElements HUDElements;

@ -27,6 +27,7 @@ foreach s : ['overlay.frag', 'overlay.vert']
endforeach
vklayer_files = files(
'hud_elements.cpp',
'overlay.cpp',
'overlay_params.cpp',
'font.cpp',

@ -14,6 +14,7 @@
struct benchmark_stats benchmark;
struct fps_limit fps_limit_stats {};
ImVec2 real_font_size;
std::vector<logData> graph_data;
void update_hw_info(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID)
{
@ -55,7 +56,11 @@ void update_hw_info(struct swapchain_stats& sw_stats, struct overlay_params& par
currentLogData.cpu_load = cpuStats.GetCPUDataTotal().percent;
currentLogData.cpu_temp = cpuStats.GetCPUDataTotal().temp;
// Save data for graphs
if (graph_data.size() > 50)
graph_data.erase(graph_data.begin());
graph_data.push_back({0, 0, cpuStats.GetCPUDataTotal().percent, gpu_info.load, cpuStats.GetCPUDataTotal().temp,
gpu_info.temp, gpu_info.CoreClock, gpu_info.MemClock, gpu_info.memoryUsed, memused});
logger->notify_data_valid();
}
@ -63,7 +68,6 @@ void update_hud_info(struct swapchain_stats& sw_stats, struct overlay_params& pa
if(not logger) logger = std::make_unique<Logger>(&params);
uint32_t f_idx = sw_stats.n_frames % ARRAY_SIZE(sw_stats.frames_stats);
uint64_t now = os_time_get(); /* us */
double elapsed = (double)(now - sw_stats.last_fps_update); /* us */
fps = 1000000.0f * sw_stats.n_frames_since_update / elapsed;
if (logger->is_active())
@ -76,7 +80,6 @@ void update_hud_info(struct swapchain_stats& sw_stats, struct overlay_params& pa
frametime = now - sw_stats.last_present_time;
if (elapsed >= params.fps_sampling_period) {
std::thread(update_hw_info, std::ref(sw_stats), std::ref(params), vendorID).detach();
sw_stats.fps = fps;

@ -9,7 +9,14 @@
#include "overlay_params.h"
#include "iostats.h"
#include "timing.hpp"
#include "hud_elements.h"
#include "version.h"
#include "gpu.h"
#include "logging.h"
#ifdef HAVE_DBUS
#include "dbus_info.h"
extern float g_overflow;
#endif
struct frame_stat {
uint64_t stats[OVERLAY_PLOTS_MAX];
};
@ -94,6 +101,8 @@ extern int32_t deviceID;
extern struct benchmark_stats benchmark;
extern ImVec2 real_font_size;
extern std::string wineVersion;
extern std::vector<logData> graph_data;
void position_layer(struct swapchain_stats& data, struct overlay_params& params, ImVec2 window_size);
void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, bool is_vulkan);
@ -108,5 +117,12 @@ void get_device_name(int32_t vendorID, int32_t deviceID, struct swapchain_stats&
void calculate_benchmark_data(void *params_void);
void create_fonts(const overlay_params& params, ImFont*& small_font, ImFont*& text_font);
void convert_colors(bool do_conv, struct swapchain_stats& sw_stats, struct overlay_params& params);
void right_aligned_text(ImVec4& col, float off_x, const char *fmt, ...);
ImVec4 change_on_load_temp (struct LOAD_DATA& data, int current);
float get_time_stat(void *_data, int _idx);
#ifdef HAVE_DBUS
void render_mpris_metadata(struct overlay_params& params, mutexed_metadata& meta, uint64_t frame_timing, bool is_main);
#endif
#endif //MANGOHUD_OVERLAY_H

@ -20,6 +20,7 @@
#include "overlay.h"
#include "config.h"
#include "string_utils.h"
#include "hud_elements.h"
#include "mesa/util/os_socket.h"
@ -440,6 +441,7 @@ parse_overlay_env(struct overlay_params *params,
char key[256], value[256];
while ((num = parse_string(env, key, value)) != 0) {
env += num;
HUDElements.sort_elements({key, value});
if (!strcmp("full", key)) {
bool read_cfg = params->enabled[OVERLAY_PARAM_ENABLED_read_cfg];
#define OVERLAY_PARAM_BOOL(name) \
@ -491,9 +493,11 @@ parse_overlay_config(struct overlay_params *params,
params->enabled[OVERLAY_PARAM_ENABLED_read_cfg] = false;
params->enabled[OVERLAY_PARAM_ENABLED_io_read] = false;
params->enabled[OVERLAY_PARAM_ENABLED_io_write] = false;
params->enabled[OVERLAY_PARAM_ENABLED_io_stats] = false;
params->enabled[OVERLAY_PARAM_ENABLED_wine] = false;
params->enabled[OVERLAY_PARAM_ENABLED_gpu_load_change] = false;
params->enabled[OVERLAY_PARAM_ENABLED_cpu_load_change] = false;
params->enabled[OVERLAY_PARAM_ENABLED_legacy_layout] = true;
params->fps_sampling_period = 500000; /* 500ms */
params->width = 0;
params->height = 140;
@ -557,7 +561,7 @@ parse_overlay_config(struct overlay_params *params,
#define parse_reload_cfg(x) params->reload_cfg
#endif
HUDElements.ordered_functions.clear();
// first pass with env var
if (env)
parse_overlay_env(params, env);
@ -598,8 +602,8 @@ parse_overlay_config(struct overlay_params *params,
}
// second pass, override config file settings with MANGOHUD_CONFIG
if (env && read_cfg)
parse_overlay_env(params, env);
// if (env && read_cfg)
// parse_overlay_env(params, env);
if (params->font_scale_media_player <= 0.f)
params->font_scale_media_player = 0.55f;
@ -668,4 +672,11 @@ parse_overlay_config(struct overlay_params *params,
printf("MANGOHUD: output_file is Deprecated, use output_folder instead\n");
auto real_size = params->font_size * params->font_scale;
real_font_size = ImVec2(real_size, real_size / 2);
HUDElements.params = params;
if (params->enabled[OVERLAY_PARAM_ENABLED_legacy_layout]){
HUDElements.legacy_elements();
} else {
for (auto& option : HUDElements.options)
HUDElements.sort_elements(option);
}
}

@ -39,6 +39,7 @@ typedef unsigned long KeySym;
OVERLAY_PARAM_BOOL(read_cfg) \
OVERLAY_PARAM_BOOL(io_read) \
OVERLAY_PARAM_BOOL(io_write) \
OVERLAY_PARAM_BOOL(io_stats) \
OVERLAY_PARAM_BOOL(gpu_mem_clock) \
OVERLAY_PARAM_BOOL(gpu_core_clock) \
OVERLAY_PARAM_BOOL(gpu_power) \
@ -52,6 +53,8 @@ typedef unsigned long KeySym;
OVERLAY_PARAM_BOOL(wine) \
OVERLAY_PARAM_BOOL(gpu_load_change) \
OVERLAY_PARAM_BOOL(cpu_load_change) \
OVERLAY_PARAM_BOOL(graphs) \
OVERLAY_PARAM_BOOL(legacy_layout) \
OVERLAY_PARAM_CUSTOM(fps_sampling_period) \
OVERLAY_PARAM_CUSTOM(output_folder) \
OVERLAY_PARAM_CUSTOM(output_file) \
@ -91,7 +94,7 @@ typedef unsigned long KeySym;
OVERLAY_PARAM_CUSTOM(background_color) \
OVERLAY_PARAM_CUSTOM(io_color) \
OVERLAY_PARAM_CUSTOM(text_color) \
OVERLAY_PARAM_CUSTOM (wine_color) \
OVERLAY_PARAM_CUSTOM(wine_color) \
OVERLAY_PARAM_CUSTOM(alpha) \
OVERLAY_PARAM_CUSTOM(log_duration) \
OVERLAY_PARAM_CUSTOM(pci_dev) \
@ -106,9 +109,8 @@ typedef unsigned long KeySym;
OVERLAY_PARAM_CUSTOM(help) \
OVERLAY_PARAM_CUSTOM(gpu_load_value) \
OVERLAY_PARAM_CUSTOM(cpu_load_value) \
OVERLAY_PARAM_CUSTOM(gpu_load_color) \
OVERLAY_PARAM_CUSTOM(cpu_load_color)
OVERLAY_PARAM_CUSTOM(gpu_load_color) \
OVERLAY_PARAM_CUSTOM(cpu_load_color) \
enum overlay_param_position {
LAYER_POSITION_TOP_LEFT,
@ -159,7 +161,7 @@ struct overlay_params {
bool help;
bool no_display;
bool full;
bool io_read, io_write;
bool io_read, io_write, io_stats;
unsigned width;
unsigned height;
int offset_x, offset_y;

@ -61,12 +61,10 @@
#include "memory.h"
#include "notify.h"
#include "blacklist.h"
#include "version.h"
#include "pci_ids.h"
#include "timing.hpp"
#ifdef HAVE_DBUS
#include "dbus_info.h"
float g_overflow = 50.f /* 3333ms * 0.5 / 16.6667 / 2 (to edge and back) */;
#endif
@ -689,7 +687,7 @@ static void snapshot_swapchain_frame(struct swapchain_data *data)
// }
}
static float get_time_stat(void *_data, int _idx)
float get_time_stat(void *_data, int _idx)
{
struct swapchain_stats *data = (struct swapchain_stats *) _data;
if ((ARRAY_SIZE(data->frames_stats) - _idx) > data->n_frames)
@ -740,7 +738,7 @@ void position_layer(struct swapchain_stats& data, struct overlay_params& params,
}
}
static void right_aligned_text(ImVec4& col, float off_x, const char *fmt, ...)
void right_aligned_text(ImVec4& col, float off_x, const char *fmt, ...)
{
ImVec2 pos = ImGui::GetCursorPos();
char buffer[32] {};
@ -777,7 +775,7 @@ float get_ticker_limited_pos(float pos, float tw, float& left_limit, float& righ
}
#ifdef HAVE_DBUS
static void render_mpris_metadata(struct overlay_params& params, mutexed_metadata& meta, uint64_t frame_timing, bool is_main)
void render_mpris_metadata(struct overlay_params& params, mutexed_metadata& meta, uint64_t frame_timing, bool is_main)
{
if (meta.meta.valid) {
auto color = ImGui::ColorConvertU32ToFloat4(params.media_player_color);
@ -937,330 +935,29 @@ ImVec4 change_on_load_temp (struct LOAD_DATA& data, int current) {
void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, bool is_vulkan)
{
HUDElements.sw_stats = &data; HUDElements.params = &params;
HUDElements.is_vulkan = is_vulkan;
ImGui::GetIO().FontGlobalScale = params.font_scale;
if(not logger) logger = std::make_unique<Logger>(&params);
uint32_t f_idx = (data.n_frames - 1) % ARRAY_SIZE(data.frames_stats);
uint64_t frame_timing = data.frames_stats[f_idx].stats[OVERLAY_PLOTS_frame_timing];
static float ralign_width = 0, old_scale = 0;
window_size = ImVec2(params.width, params.height);
unsigned height = ImGui::GetIO().DisplaySize.y;
auto now = Clock::now();
if (old_scale != params.font_scale) {
ralign_width = ImGui::CalcTextSize("A").x * 4 /* characters */;
HUDElements.ralign_width = ralign_width = ImGui::CalcTextSize("A").x * 4 /* characters */;
old_scale = params.font_scale;
}
if (!params.no_display){
ImGui::Begin("Main", &open, ImGuiWindowFlags_NoDecoration);
ImGui::BeginTable("hud", params.tableCols, ImGuiTableFlags_NoClipX);
if (params.enabled[OVERLAY_PARAM_ENABLED_version]){
ImGui::TableNextCell();
ImGui::Text("%s", MANGOHUD_VERSION);
}
if (params.enabled[OVERLAY_PARAM_ENABLED_time]){
ImGui::TableNextRow();
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 1.00f), "%s", data.time.c_str());
}
if (params.enabled[OVERLAY_PARAM_ENABLED_gpu_stats]){
ImGui::TableNextRow();
const char* gpu_text;
if (params.gpu_text.empty())
gpu_text = "GPU";
else
gpu_text = params.gpu_text.c_str();
ImGui::TextColored(data.colors.gpu, "%s", gpu_text);
ImGui::TableNextCell();
auto text_color = data.colors.text;
if (params.enabled[OVERLAY_PARAM_ENABLED_gpu_load_change]){
struct LOAD_DATA gpu_data = {data.colors.gpu_load_high,
data.colors.gpu_load_med,
data.colors.gpu_load_low,
params.gpu_load_value[0],
params.gpu_load_value[1]
};
auto load_color = change_on_load_temp(gpu_data, gpu_info.load);
right_aligned_text(load_color, ralign_width, "%i", gpu_info.load);
ImGui::SameLine(0, 1.0f);
ImGui::TextColored(load_color,"%%");
}
else {
right_aligned_text(text_color, ralign_width, "%i", gpu_info.load);
ImGui::SameLine(0, 1.0f);
ImGui::TextColored(text_color,"%%");
// ImGui::SameLine(150);
// ImGui::Text("%s", "%");
}
if (params.enabled[OVERLAY_PARAM_ENABLED_gpu_temp]){
ImGui::TableNextCell();
right_aligned_text(text_color, ralign_width, "%i", gpu_info.temp);
ImGui::SameLine(0, 1.0f);
ImGui::Text("°C");
}
if (params.enabled[OVERLAY_PARAM_ENABLED_gpu_core_clock] || params.enabled[OVERLAY_PARAM_ENABLED_gpu_power])
ImGui::TableNextRow();
if (params.enabled[OVERLAY_PARAM_ENABLED_gpu_core_clock]){
ImGui::TableNextCell();
right_aligned_text(text_color, ralign_width, "%i", gpu_info.CoreClock);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(data.font1);
ImGui::Text("MHz");
ImGui::PopFont();
}
if (params.enabled[OVERLAY_PARAM_ENABLED_gpu_power]) {
ImGui::TableNextCell();
right_aligned_text(text_color, ralign_width, "%i", gpu_info.powerUsage);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(data.font1);
ImGui::Text("W");
ImGui::PopFont();
}
}
if(params.enabled[OVERLAY_PARAM_ENABLED_cpu_stats]){
ImGui::TableNextRow();
const char* cpu_text;
if (params.cpu_text.empty())
cpu_text = "CPU";
else
cpu_text = params.cpu_text.c_str();
ImGui::TextColored(data.colors.cpu, "%s", cpu_text);
ImGui::TableNextCell();
auto text_color = data.colors.text;
if (params.enabled[OVERLAY_PARAM_ENABLED_cpu_load_change]){
int cpu_load_percent = int(cpuStats.GetCPUDataTotal().percent);
struct LOAD_DATA cpu_data = {data.colors.cpu_load_high,
data.colors.cpu_load_med,
data.colors.cpu_load_low,
params.cpu_load_value[0],
params.cpu_load_value[1]
};
auto load_color = change_on_load_temp(cpu_data, cpu_load_percent);
right_aligned_text(load_color, ralign_width, "%d", cpu_load_percent);
ImGui::SameLine(0, 1.0f);
ImGui::TextColored(load_color, "%%");
}
else {
right_aligned_text(text_color, ralign_width, "%d", int(cpuStats.GetCPUDataTotal().percent));
ImGui::SameLine(0, 1.0f);
ImGui::Text("%%");
}
// ImGui::SameLine(150);
// ImGui::Text("%s", "%");
if (params.enabled[OVERLAY_PARAM_ENABLED_cpu_temp]){
ImGui::TableNextCell();
right_aligned_text(data.colors.text, ralign_width, "%i", cpuStats.GetCPUDataTotal().temp);
ImGui::SameLine(0, 1.0f);
ImGui::Text("°C");
}
}
if (params.enabled[OVERLAY_PARAM_ENABLED_core_load]){
int i = 0;
for (const CPUData &cpuData : cpuStats.GetCPUData())
{
ImGui::TableNextRow();
ImGui::TextColored(data.colors.cpu, "CPU");
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(data.font1);
ImGui::TextColored(data.colors.cpu,"%i", i);
ImGui::PopFont();
ImGui::TableNextCell();
right_aligned_text(data.colors.text, ralign_width, "%i", int(cpuData.percent));
ImGui::SameLine(0, 1.0f);
ImGui::Text("%%");
ImGui::TableNextCell();
right_aligned_text(data.colors.text, ralign_width, "%i", cpuData.mhz);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(data.font1);
ImGui::Text("MHz");
ImGui::PopFont();
i++;
}
}
if (params.enabled[OVERLAY_PARAM_ENABLED_io_read] || params.enabled[OVERLAY_PARAM_ENABLED_io_write]){
auto sampling = params.fps_sampling_period;
ImGui::TableNextRow();
if (params.enabled[OVERLAY_PARAM_ENABLED_io_read] && !params.enabled[OVERLAY_PARAM_ENABLED_io_write])
ImGui::TextColored(data.colors.io, "IO RD");
else if (params.enabled[OVERLAY_PARAM_ENABLED_io_read] && params.enabled[OVERLAY_PARAM_ENABLED_io_write])
ImGui::TextColored(data.colors.io, "IO RW");
else if (params.enabled[OVERLAY_PARAM_ENABLED_io_write] && !params.enabled[OVERLAY_PARAM_ENABLED_io_read])
ImGui::TextColored(data.colors.io, "IO WR");
if (params.enabled[OVERLAY_PARAM_ENABLED_io_read]){
ImGui::TableNextCell();
float val = data.io.diff.read * 1000000 / sampling;
right_aligned_text(data.colors.text, ralign_width, val < 100 ? "%.1f" : "%.f", val);
ImGui::SameLine(0,1.0f);
ImGui::PushFont(data.font1);
ImGui::Text("MiB/s");
ImGui::PopFont();
}
if (params.enabled[OVERLAY_PARAM_ENABLED_io_write]){
ImGui::TableNextCell();
float val = data.io.diff.write * 1000000 / sampling;
right_aligned_text(data.colors.text, ralign_width, val < 100 ? "%.1f" : "%.f", val);
ImGui::SameLine(0,1.0f);
ImGui::PushFont(data.font1);
ImGui::Text("MiB/s");
ImGui::PopFont();
}
}
if (params.enabled[OVERLAY_PARAM_ENABLED_vram]){
ImGui::TableNextRow();
ImGui::TextColored(data.colors.vram, "VRAM");
ImGui::TableNextCell();
right_aligned_text(data.colors.text, ralign_width, "%.1f", gpu_info.memoryUsed);
ImGui::SameLine(0,1.0f);
ImGui::PushFont(data.font1);
ImGui::Text("GiB");
ImGui::PopFont();
if (params.enabled[OVERLAY_PARAM_ENABLED_gpu_mem_clock]){
ImGui::TableNextCell();
right_aligned_text(data.colors.text, ralign_width, "%i", gpu_info.MemClock);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(data.font1);
ImGui::Text("MHz");
ImGui::PopFont();
}
}
#ifdef __gnu_linux__
if (params.enabled[OVERLAY_PARAM_ENABLED_ram]){
ImGui::TableNextRow();
ImGui::TextColored(data.colors.ram, "RAM");
ImGui::TableNextCell();
right_aligned_text(data.colors.text, ralign_width, "%.1f", memused);
ImGui::SameLine(0,1.0f);
ImGui::PushFont(data.font1);
ImGui::Text("GiB");
ImGui::PopFont();
}
#endif
if (params.enabled[OVERLAY_PARAM_ENABLED_fps]){
ImGui::TableNextRow();
ImGui::TextColored(data.colors.engine, "%s", is_vulkan ? data.engineName.c_str() : "OpenGL");
ImGui::TableNextCell();
right_aligned_text(data.colors.text, ralign_width, "%.0f", data.fps);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(data.font1);
ImGui::Text("FPS");
ImGui::PopFont();
ImGui::TableNextCell();
right_aligned_text(data.colors.text, ralign_width, "%.1f", 1000 / data.fps);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(data.font1);
ImGui::Text("ms");
ImGui::PopFont();
}
if (!params.enabled[OVERLAY_PARAM_ENABLED_fps] && params.enabled[OVERLAY_PARAM_ENABLED_engine_version]){
ImGui::TableNextRow();
ImGui::TextColored(data.colors.engine, "%s", is_vulkan ? data.engineName.c_str() : "OpenGL");
HUDElements.place = 0;
for (auto& func : HUDElements.ordered_functions){
func.first();
HUDElements.place += 1;
}
ImGui::EndTable();
if (params.enabled[OVERLAY_PARAM_ENABLED_engine_version]){
ImGui::PushFont(data.font1);
ImGui::Dummy(ImVec2(0, 8.0f));
if (is_vulkan) {
if ((data.engineName == "DXVK" || data.engineName == "VKD3D")){
ImGui::TextColored(data.colors.engine,
"%s/%d.%d.%d", data.engineVersion.c_str(),
data.version_vk.major,
data.version_vk.minor,
data.version_vk.patch);
} else {
ImGui::TextColored(data.colors.engine,
"%d.%d.%d",
data.version_vk.major,
data.version_vk.minor,
data.version_vk.patch);
}
} else {
ImGui::TextColored(data.colors.engine,
"%d.%d%s", data.version_gl.major, data.version_gl.minor,
data.version_gl.is_gles ? " ES" : "");
}
// ImGui::SameLine();
ImGui::PopFont();
}
if (params.enabled[OVERLAY_PARAM_ENABLED_gpu_name] && !data.gpuName.empty()){
ImGui::PushFont(data.font1);
ImGui::Dummy(ImVec2(0.0,5.0f));
ImGui::TextColored(data.colors.engine,
"%s", data.gpuName.c_str());
ImGui::PopFont();
}
if (params.enabled[OVERLAY_PARAM_ENABLED_vulkan_driver] && !data.driverName.empty()){
ImGui::PushFont(data.font1);
ImGui::Dummy(ImVec2(0.0,5.0f));
ImGui::TextColored(data.colors.engine,
"%s", data.driverName.c_str());
ImGui::PopFont();
}
if (params.enabled[OVERLAY_PARAM_ENABLED_arch]){
ImGui::PushFont(data.font1);
ImGui::Dummy(ImVec2(0.0,5.0f));
ImGui::TextColored(data.colors.engine, "%s", "" MANGOHUD_ARCH);
ImGui::PopFont();
}
if (params.enabled[OVERLAY_PARAM_ENABLED_wine]){
if (!wineVersion.empty()){
//ImGui::TextColored(data.colors.wine, "%s", "WINE");
ImGui::PushFont(data.font1);
ImGui::Dummy(ImVec2(0.0,5.0f));
ImGui::TextColored(data.colors.wine, "%s", wineVersion.c_str());
ImGui::PopFont();
}
}
if (params.enabled[OVERLAY_PARAM_ENABLED_frame_timing]){
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
ImGui::PushFont(data.font1);
ImGui::TextColored(data.colors.engine, "%s", "Frametime");
ImGui::PopFont();
char hash[40];
snprintf(hash, sizeof(hash), "##%s", overlay_param_names[OVERLAY_PARAM_ENABLED_frame_timing]);
data.stat_selector = OVERLAY_PLOTS_frame_timing;
data.time_dividor = 1000.0f;
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
double min_time = 0.0f;
double max_time = 50.0f;
if (params.enabled[OVERLAY_PARAM_ENABLED_histogram]){
ImGui::PlotHistogram(hash, get_time_stat, &data,
ARRAY_SIZE(data.frames_stats), 0,
NULL, min_time, max_time,
ImVec2(ImGui::GetContentRegionAvailWidth() - real_font_size.x * 2.2, 50));
} else {
ImGui::PlotLines(hash, get_time_stat, &data,
ARRAY_SIZE(data.frames_stats), 0,
NULL, min_time, max_time,
ImVec2(ImGui::GetContentRegionAvailWidth() - real_font_size.x * 2.2, 50));
}
ImGui::PopStyleColor();
}
if (params.enabled[OVERLAY_PARAM_ENABLED_frame_timing]){
ImGui::SameLine(0,1.0f);
ImGui::PushFont(data.font1);
ImGui::Text("%.1f ms", 1000 / data.fps); //frame_timing / 1000.f);
ImGui::PopFont();
}
#ifdef HAVE_DBUS
ImFont scaled_font = *data.font_text;
scaled_font.Scale = params.font_scale_media_player;
ImGui::PushFont(&scaled_font);
{
std::lock_guard<std::mutex> lck(main_metadata.mtx);
render_mpris_metadata(params, main_metadata, frame_timing, true);
}
//render_mpris_metadata(params, generic_mpris, frame_timing, false);
ImGui::PopFont();
#endif
if(logger->is_active())
ImGui::GetWindowDrawList()->AddCircleFilled(ImVec2(data.main_window_pos.x + window_size.x - 15, data.main_window_pos.y + 15), 10, params.engine_color, 20);

Loading…
Cancel
Save