Add new param custom_header

pull/430/head
Alessandro Toia 4 years ago
parent d54409b6b5
commit b77517501c

@ -427,7 +427,7 @@ void HudElements::frame_timing(){
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.colors.engine, "%s", "Frametime");
for (size_t i = 0; i < HUDElements.params->table_columns - 1; i++)
ImGui::TableNextCell();
ImGui::TableNextCell();
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width * 1.3, "%.1f ms", 1000 / HUDElements.sw_stats->fps);
ImGui::PopFont();
@ -451,7 +451,7 @@ void HudElements::frame_timing(){
ImVec2(ImGui::GetContentRegionAvailWidth() * HUDElements.params->table_columns, 50));
}
ImGui::PopStyleColor();
}
}
@ -497,6 +497,17 @@ void HudElements::show_fps_limit(){
ImGui::PopFont();
}
void HudElements::custom_header(){
ImGui::TableAutoHeaders();
ImGui::TableNextRow();
std::string text = HUDElements.params->custom_header;
center_text(text);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::TextColored(HUDElements.colors.text, "%s",text.c_str());
ImGui::PopFont();
ImGui::NewLine();
}
void HudElements::graphs(){
ImGui::TableNextRow();
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
@ -639,6 +650,7 @@ void HudElements::sort_elements(std::pair<std::string, std::string> option){
if (param == "media_player") { ordered_functions.push_back({media_player, 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 == "custom_header") { ordered_functions.push_back({custom_header, value}); }
if (param == "graphs"){
if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_graphs])
HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_graphs] = true;

@ -40,7 +40,9 @@ class HudElements{
static void frame_timing();
static void media_player();
static void resolution();
static void custom_text();
static void show_fps_limit();
static void custom_header();
static void graphs();
void convert_colors(struct overlay_params& params);

@ -218,6 +218,13 @@ void right_aligned_text(ImVec4& col, float off_x, const char *fmt, ...)
ImGui::TextColored(col,"%s",buffer);
}
void center_text(std::string& text)
{
float font_size = ImGui::GetFontSize() * text.size() / 2;
ImGui::SameLine(ImGui::GetWindowSize().x / 2 -font_size + (font_size /1.4));
}
float get_ticker_limited_pos(float pos, float tw, float& left_limit, float& right_limit)
{
//float cw = ImGui::GetContentRegionAvailWidth() * 3; // only table cell worth of width

@ -99,6 +99,7 @@ void get_device_name(int32_t vendorID, int32_t deviceID, struct swapchain_stats&
void calculate_benchmark_data(void *params_void);
void create_fonts(const overlay_params& params, ImFont*& small_font, ImFont*& text_font);
void right_aligned_text(ImVec4& col, float off_x, const char *fmt, ...);
void center_text(std::string& text);
ImVec4 change_on_load_temp(LOAD_DATA& data, unsigned current);
float get_time_stat(void *_data, int _idx);

@ -397,6 +397,8 @@ parse_font_glyph_ranges(const char *str)
#define parse_gpu_load_value(s) parse_load_value(s)
#define parse_cpu_load_value(s) parse_load_value(s)
#define parse_blacklist(s) parse_str_tokenize(s)
#define parse_custom_header(s) parse_str(s)
static bool
parse_help(const char *str)

@ -122,6 +122,7 @@ typedef unsigned long KeySym;
OVERLAY_PARAM_CUSTOM(table_columns) \
OVERLAY_PARAM_CUSTOM(blacklist) \
OVERLAY_PARAM_CUSTOM(autostart_log) \
OVERLAY_PARAM_CUSTOM(custom_header) \
enum overlay_param_position {
LAYER_POSITION_TOP_LEFT,
@ -210,6 +211,7 @@ struct overlay_params {
std::string font_file, font_file_text;
uint32_t font_glyph_ranges;
std::string custom_header;
std::string config_file_path;
std::unordered_map<std::string,std::string> options;
int permit_upload;

Loading…
Cancel
Save