diff --git a/README.md b/README.md index 02472d91..b4238855 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,7 @@ Parameters that are enabled by default have to be explicitly disabled. These (cu | `table_columns` | Set the number of table columns for ImGui, defaults to 3 | | `blacklist` | Add a program to the blacklist. e.g `blacklist=vkcube,WatchDogs2.exe` | | `resolution` | Display the current resolution | +| `show_fps_limit` | Display the current fps limit | Example: `MANGOHUD_CONFIG=cpu_temp,gpu_temp,position=top-right,height=500,font_size=32` Because comma is also used as option delimiter and needs to be escaped for values with a backslash, you can use `+` like `MANGOHUD_CONFIG=fps_limit=60+30+0` instead. diff --git a/bin/MangoHud.conf b/bin/MangoHud.conf index 04082f46..5fe53482 100644 --- a/bin/MangoHud.conf +++ b/bin/MangoHud.conf @@ -59,6 +59,10 @@ frame_timing ### Display the current resolution # resolution +### Show current fps limit +# show_fps_limit + + ### Time formatting examples # time_format = %H:%M # time_format = [ %T %F ] diff --git a/src/hud_elements.cpp b/src/hud_elements.cpp index 3e8bfa5b..72e9c82d 100644 --- a/src/hud_elements.cpp +++ b/src/hud_elements.cpp @@ -482,6 +482,20 @@ void HudElements::resolution(){ ImGui::PopFont(); } +void HudElements::show_fps_limit(){ + int fps = 0; + double frame_time = (double)fps_limit_stats.targetFrameTime.count()/1000000; + if (frame_time > 0.0){ + fps = (1 / frame_time) *1000; + } + ImGui::TableNextRow(); + ImGui::PushFont(HUDElements.sw_stats->font1); + ImGui::TextColored(HUDElements.colors.engine, "%s","FPS limit"); + ImGui::TableNextCell(); + right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%i", fps); + ImGui::PopFont(); +} + void HudElements::graphs(){ ImGui::TableNextRow(); ImGui::Dummy(ImVec2(0.0f, real_font_size.y)); @@ -621,7 +635,8 @@ void HudElements::sort_elements(std::pair option){ 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 == "resolution") { ordered_functions.push_back({resolution, value}); } + if (param == "resolution") { ordered_functions.push_back({resolution, value}); } + if (param == "show_fps_limit") { ordered_functions.push_back({show_fps_limit, value}); } if (param == "graphs"){ if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_graphs]) HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_graphs] = true; diff --git a/src/hud_elements.h b/src/hud_elements.h index 227a98b4..fae7a381 100644 --- a/src/hud_elements.h +++ b/src/hud_elements.h @@ -40,6 +40,7 @@ class HudElements{ static void frame_timing(); static void media_player(); static void resolution(); + static void show_fps_limit(); static void graphs(); void convert_colors(struct overlay_params& params); diff --git a/src/overlay_params.h b/src/overlay_params.h index 25d0b359..36f4ba3d 100644 --- a/src/overlay_params.h +++ b/src/overlay_params.h @@ -60,6 +60,7 @@ typedef unsigned long KeySym; OVERLAY_PARAM_BOOL(cpu_mhz) \ OVERLAY_PARAM_BOOL(frametime) \ OVERLAY_PARAM_BOOL(resolution) \ + OVERLAY_PARAM_BOOL(show_fps_limit) \ OVERLAY_PARAM_CUSTOM(fps_sampling_period) \ OVERLAY_PARAM_CUSTOM(output_folder) \ OVERLAY_PARAM_CUSTOM(output_file) \