Hud elements exec function

pull/443/head
FlightlessMango 4 years ago
parent c4925ac83e
commit c54f8bec5d

@ -533,6 +533,17 @@ void HudElements::custom_text(){
ImGui::PopFont();
}
void HudElements::_exec(){
std::string value = HUDElements.ordered_functions[HUDElements.place].second;
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TableNextCell();
for (auto& item : HUDElements.exec_list){
if (item.pos == HUDElements.place)
ImGui::Text("%s", item.ret.c_str());
}
ImGui::PopFont();
}
void HudElements::graphs(){
ImGui::TableNextRow();
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
@ -680,6 +691,8 @@ void HudElements::sort_elements(std::pair<std::string, std::string> option){
if (param == "show_fps_limit") { ordered_functions.push_back({show_fps_limit, value}); }
if (param == "custom_text") { ordered_functions.push_back({custom_text, value}); }
if (param == "custom_text_center") { ordered_functions.push_back({custom_text_center, value}); }
if (param == "exec") { ordered_functions.push_back({_exec, value});
exec_list.push_back({ordered_functions.size() - 1, value}); }
if (param == "graphs"){
if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_graphs])
HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_graphs] = true;
@ -716,4 +729,9 @@ void HudElements::legacy_elements(){
ordered_functions.push_back({media_player, value});
}
void HudElements::update_exec(){
for(auto& item : exec_list)
item.ret = exec(item.value);
}
HudElements HUDElements;

@ -4,16 +4,23 @@
#include <functional>
#include <map>
#include <sstream>
#include <logging.h>
class HudElements{
public:
struct swapchain_stats *sw_stats;
struct overlay_params *params;
struct exec_list {
int pos;
std::string value;
std::string ret;
};
float ralign_width;
float old_scale;
float res_width, res_height;
bool is_vulkan;
int place;
Clock::time_point last_exec;
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;
@ -21,8 +28,10 @@ class HudElements{
"gpu_load", "cpu_load", "gpu_core_clock", "gpu_mem_clock",
"vram", "ram", "cpu_temp", "gpu_temp"
};
std::vector<exec_list> exec_list;
void sort_elements(std::pair<std::string, std::string> option);
void legacy_elements();
void update_exec();
static void version();
static void time();
static void gpu_stats();
@ -44,6 +53,7 @@ class HudElements{
static void custom_text_center();
static void custom_text();
static void graphs();
static void _exec();
void convert_colors(struct overlay_params& params);
void convert_colors(bool do_conv, struct overlay_params& params);
@ -70,6 +80,7 @@ class HudElements{
fps_value_med,
fps_value_high;
} colors {};
};
extern HudElements HUDElements;

@ -87,6 +87,7 @@ 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) {
HUDElements.update_exec();
std::thread(update_hw_info, std::ref(sw_stats), std::ref(params), vendorID).detach();
sw_stats.fps = fps;

@ -611,6 +611,7 @@ parse_overlay_config(struct overlay_params *params,
#endif
HUDElements.ordered_functions.clear();
HUDElements.exec_list.clear();
// first pass with env var
if (env)
parse_overlay_env(params, env);

@ -64,6 +64,7 @@ typedef unsigned long KeySym;
OVERLAY_PARAM_BOOL(fps_color_change) \
OVERLAY_PARAM_BOOL(custom_text_center) \
OVERLAY_PARAM_BOOL(custom_text) \
OVERLAY_PARAM_BOOL(exec) \
OVERLAY_PARAM_CUSTOM(fps_sampling_period) \
OVERLAY_PARAM_CUSTOM(output_folder) \
OVERLAY_PARAM_CUSTOM(output_file) \

Loading…
Cancel
Save