From c5ea98a243f7b76ff9d88b3f2c872e3bd645cbde Mon Sep 17 00:00:00 2001 From: FlightlessMango Date: Sat, 8 Feb 2020 03:55:39 +0100 Subject: [PATCH] Added a crosshair and params for it --- src/overlay.cpp | 22 ++++++++++++++++------ src/overlay_params.c | 7 +++++++ src/overlay_params.h | 3 +++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/overlay.cpp b/src/overlay.cpp index c1743433..169e8599 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -1135,7 +1135,7 @@ static void compute_swapchain_display(struct swapchain_data *data) if(displayHud) ImGui::Begin("Main", &open, ImGuiWindowFlags_NoDecoration); - + if(!displayHud){ ImGui::SetNextWindowBgAlpha(0.01); ImGui::Begin("Main", &open, ImGuiWindowFlags_NoDecoration); @@ -1284,11 +1284,21 @@ static void compute_swapchain_display(struct swapchain_data *data) ImGui::Text("Logging..."); ImGui::Text("Elapsed: %isec", int((elapsedLog) / 1000000)); ImGui::End(); - } - ImGui::PopStyleVar(2); - ImGui::EndFrame(); - ImGui::Render(); - + } + if (instance_data->params.enabled[OVERLAY_PARAM_ENABLED_crosshair]){ + ImGui::SetNextWindowBgAlpha(0.0); + ImGui::SetNextWindowSize(ImVec2(data->width, data->height), ImGuiCond_Always); + ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always); + ImGui::Begin("Logging", &open, ImGuiWindowFlags_NoDecoration); + ImVec2 horiz = ImVec2(data->width / 2 - (instance_data->params.crosshair_size / 2), data->height / 2); + ImVec2 vert = ImVec2(data->width / 2, data->height / 2 - (instance_data->params.crosshair_size / 2)); + ImGui::GetWindowDrawList()->AddLine(horiz, ImVec2(horiz.x + instance_data->params.crosshair_size, horiz.y + 0), IM_COL32(0, 0, 0, 255), 2.0f); + ImGui::GetWindowDrawList()->AddLine(vert, ImVec2(vert.x + 0, vert.y + instance_data->params.crosshair_size), IM_COL32(0, 0, 0, 255), 2.0f); + ImGui::End(); + } + ImGui::PopStyleVar(2); + ImGui::EndFrame(); + ImGui::Render(); } static uint32_t vk_memory_type(struct device_data *data, diff --git a/src/overlay_params.c b/src/overlay_params.c index 14272ea5..42b5fa25 100644 --- a/src/overlay_params.c +++ b/src/overlay_params.c @@ -79,6 +79,12 @@ parse_fps_sampling_period(const char *str) return strtol(str, NULL, 0) * 1000; } +static uint32_t +parse_crosshair_size(const char *str) +{ + return strtol(str, NULL, 0); +} + static bool parse_no_display(const char *str) { @@ -183,6 +189,7 @@ parse_overlay_env(struct overlay_params *params, params->width = 280; params->height = 140; params->control = -1; + params->crosshair_size = 30; if (!env) return; diff --git a/src/overlay_params.h b/src/overlay_params.h index fbcfe80a..77c2b686 100644 --- a/src/overlay_params.h +++ b/src/overlay_params.h @@ -45,6 +45,7 @@ extern "C" { OVERLAY_PARAM_BOOL(gpu_stats) \ OVERLAY_PARAM_BOOL(ram) \ OVERLAY_PARAM_BOOL(vram) \ + OVERLAY_PARAM_BOOL(crosshair) \ OVERLAY_PARAM_CUSTOM(fps_sampling_period) \ OVERLAY_PARAM_CUSTOM(output_file) \ OVERLAY_PARAM_CUSTOM(position) \ @@ -53,6 +54,7 @@ extern "C" { OVERLAY_PARAM_CUSTOM(no_display) \ OVERLAY_PARAM_CUSTOM(control) \ OVERLAY_PARAM_CUSTOM(font_size) \ + OVERLAY_PARAM_CUSTOM(crosshair_size) \ OVERLAY_PARAM_CUSTOM(help) enum overlay_param_position { @@ -77,6 +79,7 @@ struct overlay_params { FILE *output_file; int control; uint32_t fps_sampling_period; /* us */ + uint32_t crosshair_size; bool help; bool no_display; unsigned width;