From ed0c7a344d7c9893f96bdb90c9eba03e016c3db3 Mon Sep 17 00:00:00 2001 From: Alessandro Toia Date: Sun, 29 Nov 2020 16:10:56 -0800 Subject: [PATCH] Add new param 'core_load_change' to change colors of cpu core load depending on load % --- README.md | 1 + bin/MangoHud.conf | 1 + src/hud_elements.cpp | 26 ++++++++++++++++++++++---- src/overlay_params.cpp | 1 + src/overlay_params.h | 1 + 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 39726e85..74eec24b 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,7 @@ Parameters that are enabled by default have to be explicitly disabled. These (cu | `cpu_load_change` | Changes the color of the CPU load depending on load | | `cpu_load_color` | Set the colors for the gpu load change low,medium and high. e.g `cpu_load_color=0000FF,00FFFF,FF00FF` | | `cpu_load_value` | Set the values for medium and high load e.g `cpu_load_value=50,90` | +| `core_load_change` | Changes the colors of cpu core loads, uses the same data from `cpu_load_value` and `cpu_load_change` | | `cellpadding_y` | Set the vertical cellpadding, default is `-0.085` | | `frametime` | Display frametime next to fps text | | `table_columns` | Set the number of table columns for ImGui, defaults to 3 | diff --git a/bin/MangoHud.conf b/bin/MangoHud.conf index 94eb5f9a..be1bd8c9 100644 --- a/bin/MangoHud.conf +++ b/bin/MangoHud.conf @@ -85,6 +85,7 @@ position=top-left ### Display the current CPU load & frequency for each core # core_load +# core_load_change ### IO read and write for the app (not system) # io_read diff --git a/src/hud_elements.cpp b/src/hud_elements.cpp index 658b5b16..4841bbdc 100644 --- a/src/hud_elements.cpp +++ b/src/hud_elements.cpp @@ -231,10 +231,28 @@ void HudElements::core_load(){ ImGui::TextColored(HUDElements.colors.cpu,"%i", i); ImGui::PopFont(); ImGui::TableNextCell(); - right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%i", int(cpuData.percent)); - ImGui::SameLine(0, 1.0f); - ImGui::Text("%%"); - ImGui::TableNextCell(); + auto text_color = HUDElements.colors.text; + if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_core_load_change]){ + int cpu_load_percent = int(cpuData.percent); + struct LOAD_DATA cpu_data = { + HUDElements.colors.cpu_load_low, + HUDElements.colors.cpu_load_med, + HUDElements.colors.cpu_load_high, + 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, "%%"); + ImGui::TableNextCell(); + } + else { + right_aligned_text(text_color, HUDElements.ralign_width, "%i", int(cpuData.percent)); + ImGui::SameLine(0, 1.0f); + ImGui::Text("%%"); + ImGui::TableNextCell(); + } right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%i", cpuData.mhz); ImGui::SameLine(0, 1.0f); ImGui::PushFont(HUDElements.sw_stats->font1); diff --git a/src/overlay_params.cpp b/src/overlay_params.cpp index e1435229..cec6e3d9 100644 --- a/src/overlay_params.cpp +++ b/src/overlay_params.cpp @@ -536,6 +536,7 @@ parse_overlay_config(struct overlay_params *params, 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_core_load_change] = false; params->enabled[OVERLAY_PARAM_ENABLED_legacy_layout] = true; params->enabled[OVERLAY_PARAM_ENABLED_frametime] = true; params->fps_sampling_period = 500000; /* 500ms */ diff --git a/src/overlay_params.h b/src/overlay_params.h index 521d30bf..d60447d4 100644 --- a/src/overlay_params.h +++ b/src/overlay_params.h @@ -54,6 +54,7 @@ typedef unsigned long KeySym; OVERLAY_PARAM_BOOL(wine) \ OVERLAY_PARAM_BOOL(gpu_load_change) \ OVERLAY_PARAM_BOOL(cpu_load_change) \ + OVERLAY_PARAM_BOOL(core_load_change) \ OVERLAY_PARAM_BOOL(graphs) \ OVERLAY_PARAM_BOOL(legacy_layout) \ OVERLAY_PARAM_BOOL(cpu_mhz) \