From 906a8cde23a67562e45e739a14e5a0dbbf36d175 Mon Sep 17 00:00:00 2001 From: FlightlessMango Date: Tue, 10 Mar 2020 06:30:37 +0100 Subject: [PATCH] added param frametime_color --- src/gl/inject.cpp | 4 ++-- src/overlay.cpp | 13 +++++++------ src/overlay.h | 2 +- src/overlay_params.cpp | 7 +++++-- src/overlay_params.h | 3 ++- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/gl/inject.cpp b/src/gl/inject.cpp index 0feb8ab7..1a883fe1 100644 --- a/src/gl/inject.cpp +++ b/src/gl/inject.cpp @@ -80,8 +80,8 @@ void imgui_create(void *ctx) // Setup Dear ImGui style ImGui::StyleColorsDark(); //ImGui::StyleColorsClassic(); - imgui_custom_style(); - + imgui_custom_style(params); + GLint vp [4]; glGetIntegerv (GL_VIEWPORT, vp); printf("viewport %d %d %d %d\n", vp[0], vp[1], vp[2], vp[3]); ImGui::GetIO().IniFilename = NULL; diff --git a/src/overlay.cpp b/src/overlay.cpp index 7e8652a8..6e0b06a5 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -1225,7 +1225,7 @@ void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& s == OVERLAY_PARAM_ENABLED_fps || s == OVERLAY_PARAM_ENABLED_frame) continue; - + char hash[40]; snprintf(hash, sizeof(hash), "##%s", overlay_param_names[s]); data.stat_selector = (enum overlay_param_enabled) s; @@ -1943,15 +1943,16 @@ static void setup_swapchain_data_pipeline(struct swapchain_data *data) write_desc[0].pImageInfo = desc_image; device_data->vtable.UpdateDescriptorSets(device_data->device, 1, write_desc, 0, NULL); } -void imgui_custom_style(){ + +void imgui_custom_style(struct overlay_params& params){ ImGuiStyle& style = ImGui::GetStyle(); - style.Colors[ImGuiCol_PlotLines] = ImVec4(0.0f, 1.0f, 0.0f, 1.00f); + style.Colors[ImGuiCol_PlotLines] = ImGui::ColorConvertU32ToFloat4(params.frametime_color); style.Colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 1.0f); style.CellPadding.y = -2; } static void setup_swapchain_data(struct swapchain_data *data, - const VkSwapchainCreateInfoKHR *pCreateInfo) + const VkSwapchainCreateInfoKHR *pCreateInfo, struct overlay_params& params) { data->width = pCreateInfo->imageExtent.width; data->height = pCreateInfo->imageExtent.height; @@ -1962,7 +1963,7 @@ static void setup_swapchain_data(struct swapchain_data *data, ImGui::GetIO().IniFilename = NULL; ImGui::GetIO().DisplaySize = ImVec2((float)data->width, (float)data->height); - imgui_custom_style(); + imgui_custom_style(params); struct device_data *device_data = data->device; @@ -2149,7 +2150,7 @@ static VkResult overlay_CreateSwapchainKHR( VkResult result = device_data->vtable.CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain); if (result != VK_SUCCESS) return result; struct swapchain_data *swapchain_data = new_swapchain_data(*pSwapchain, device_data); - setup_swapchain_data(swapchain_data, pCreateInfo); + setup_swapchain_data(swapchain_data, pCreateInfo, device_data->instance->params); return result; } diff --git a/src/overlay.h b/src/overlay.h index 7f290ffd..f45dd590 100644 --- a/src/overlay.h +++ b/src/overlay.h @@ -41,4 +41,4 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params); void check_keybinds(struct overlay_params& params); void init_system_info(void); void FpsLimiter(struct fps_limit& stats); -void imgui_custom_style(void); \ No newline at end of file +void imgui_custom_style(struct overlay_params& params); \ No newline at end of file diff --git a/src/overlay_params.cpp b/src/overlay_params.cpp index 940074ee..692d1164 100644 --- a/src/overlay_params.cpp +++ b/src/overlay_params.cpp @@ -158,6 +158,7 @@ parse_str(const char *str) #define parse_ram_color(s) parse_color(s) #define parse_engine_color(s) parse_color(s) #define parse_io_color(s) parse_color(s) +#define parse_frametime_color(s) parse_color(s) static bool parse_help(const char *str) @@ -309,6 +310,7 @@ parse_overlay_config(struct overlay_params *params, params->ram_color = strtol("c26693", NULL, 16); params->engine_color = strtol("eb5b5b", NULL, 16); params->io_color = strtol("a491d3", NULL, 16); + params->frametime_color = strtol("00ff00", NULL, 16); // first pass with env var if (env) @@ -357,14 +359,15 @@ parse_overlay_config(struct overlay_params *params, // Command buffer gets reused and timestamps cause hangs for some reason, force off for now params->enabled[OVERLAY_PARAM_ENABLED_gpu_timing] = false; // Convert from 0xRRGGBB to ImGui's format - std::array colors = { + std::array colors = { ¶ms->crosshair_color, ¶ms->cpu_color, ¶ms->gpu_color, ¶ms->vram_color, ¶ms->ram_color, ¶ms->engine_color, - ¶ms->io_color + ¶ms->io_color, + ¶ms->frametime_color }; for (auto color : colors){ diff --git a/src/overlay_params.h b/src/overlay_params.h index afb0ebe1..07a0ad9d 100644 --- a/src/overlay_params.h +++ b/src/overlay_params.h @@ -88,6 +88,7 @@ extern "C" { OVERLAY_PARAM_CUSTOM(vram_color) \ OVERLAY_PARAM_CUSTOM(ram_color) \ OVERLAY_PARAM_CUSTOM(engine_color) \ + OVERLAY_PARAM_CUSTOM(frametime_color) \ OVERLAY_PARAM_CUSTOM(io_color) \ OVERLAY_PARAM_CUSTOM(help) @@ -124,7 +125,7 @@ struct overlay_params { unsigned offset_x; unsigned offset_y; unsigned vsync; - unsigned crosshair_color, cpu_color, gpu_color, vram_color, ram_color, engine_color, io_color; + unsigned crosshair_color, cpu_color, gpu_color, vram_color, ram_color, engine_color, io_color, frametime_color; unsigned tableCols; float font_size; float background_alpha;