Add wine and wine colors to overlay

pull/316/head
Alessandro Toia 4 years ago committed by jackun
parent eb681427ca
commit 632f1e7000
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -78,6 +78,9 @@ position=top-left
# ram
# vram
### Display Wine version
# wine
### Disable / hide the hud by deafult
# no_display
@ -104,6 +107,7 @@ background_alpha=0.5
# frametime_color=00FF00
# background_color=020202
# media_player_color=FFFFFF
# wine_color=732010
### Show media player metadata
# media_player

@ -31,6 +31,7 @@
#include <vector>
#include <list>
#include <cmath>
#include <libgen.h>
#include <vulkan/vulkan.h>
#include <vulkan/vk_layer.h>
@ -68,7 +69,7 @@ float g_overflow = 50.f /* 3333ms * 0.5 / 16.6667 / 2 (to edge and back) */;
#endif
bool open = false;
string gpuString;
string gpuString,wineVersion,wineProcess;
float offset_x, offset_y, hudSpacing;
int hudFirstRow, hudSecondRow;
struct fps_limit fps_limit_stats {};
@ -694,6 +695,56 @@ void init_system_info(){
trim(gpu);
driver = exec("glxinfo | grep 'OpenGL version' | sed 's/^.*: //' | cut -d' ' --output-delimiter=$'\n' -f1- | grep -v '(' | grep -v ')' | tr '\n' ' ' | cut -c 1-");
trim(driver);
// Get WINE version
wineProcess = get_exe_path();
auto n = wineProcess.find_last_of('/');
string preloader = wineProcess.substr(n + 1);
if (preloader == "wine-preloader" || preloader == "wine64-preloader") {
// Check if using Proton
if (wineProcess.find("/dist/bin/wine") != std::string::npos) {
stringstream ss;
ss << dirname((char*)wineProcess.c_str()) << "/../../version";
string protonVersion = ss.str();
ss.str(""); ss.clear();
ss << read_line(protonVersion);
std::getline(ss, wineVersion, ' '); // skip first number string
std::getline(ss, wineVersion, ' ');
trim(wineVersion);
string toReplace = "proton-";
size_t pos = wineVersion.find(toReplace);
if (pos != std::string::npos) {
// If found replace
wineVersion.replace(pos, toReplace.length(), "Proton ");
}
else {
// If not found insert for non official proton builds
wineVersion.insert(0, "Proton ");
}
}
else {
char *dir = dirname((char*)wineProcess.c_str());
stringstream findVersion;
findVersion << "\"" << dir << "/wine\" --version";
bool env_exists = false;
if (getenv("WINELOADERNOEXEC")) {
static char removenoexec[] = "WINELOADERNOEXEC";
putenv(removenoexec);
env_exists = true;
}
wineVersion = exec(findVersion.str());
std::cout << "WINE VERSION = " << wineVersion << "\n";
if (env_exists) {
static char noexec[] = "WINELOADERNOEXEC=1";
putenv(noexec);
}
}
}
else {
wineVersion = "";
}
//driver = itox(device_data->properties.driverVersion);
if (ld_preload)
@ -1449,11 +1500,15 @@ void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2&
ImGui::TextColored(data.colors.engine, "%s", "" MANGOHUD_ARCH);
ImGui::PopFont();
}
if (params.log_interval == 0){
logger->try_log();
if (params.enabled[OVERLAY_PARAM_ENABLED_wine]){
if (!wineVersion.empty()){
//ImGui::TextColored(data.colors.wine, "%s", "WINE");
ImGui::PushFont(data.font1);
ImGui::Dummy(ImVec2(0.0,5.0f));
ImGui::TextColored(data.colors.wine, "%s", wineVersion.c_str());
ImGui::PopFont();
}
}
if (params.enabled[OVERLAY_PARAM_ENABLED_frame_timing]){
ImGui::Dummy(ImVec2(0.0f, params.font_size * params.font_scale / 2));
ImGui::PushFont(data.font1);
@ -1500,6 +1555,9 @@ void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2&
ImGui::PopFont();
#endif
if (params.log_interval == 0){
logger->try_log();
}
if(logger->is_active())
ImGui::GetWindowDrawList()->AddCircleFilled(ImVec2(data.main_window_pos.x + window_size.x - 15, data.main_window_pos.y + 15), 10, params.engine_color, 20);
window_size = ImVec2(window_size.x, ImGui::GetCursorPosY() + 10.0f);
@ -2310,6 +2368,7 @@ void convert_colors(bool do_conv, struct swapchain_stats& sw_stats, struct overl
sw_stats.colors.background = convert(params.background_color);
sw_stats.colors.text = convert(params.text_color);
sw_stats.colors.media_player = convert(params.media_player_color);
sw_stats.colors.wine = convert(params.wine_color);
ImGuiStyle& style = ImGui::GetStyle();
style.Colors[ImGuiCol_PlotLines] = convert(params.frametime_color);

@ -56,7 +56,8 @@ struct swapchain_stats {
frametime,
background,
text,
media_player;
media_player,
wine;
} colors;
};
@ -92,4 +93,4 @@ void calculate_benchmark_data(void *params_void);
void create_fonts(const overlay_params& params, ImFont*& small_font, ImFont*& text_font);
void convert_colors(bool do_conv, struct swapchain_stats& sw_stats, struct overlay_params& params);
#endif //MANGOHUD_OVERLAY_H
#endif //MANGOHUD_OVERLAY_H

@ -321,6 +321,7 @@ parse_font_glyph_ranges(const char *str)
#define parse_background_color(s) parse_color(s)
#define parse_text_color(s) parse_color(s)
#define parse_media_player_color(s) parse_color(s)
#define parse_wine_color(s) parse_color(s)
static bool
parse_help(const char *str)
@ -452,6 +453,7 @@ parse_overlay_config(struct overlay_params *params,
params->enabled[OVERLAY_PARAM_ENABLED_read_cfg] = false;
params->enabled[OVERLAY_PARAM_ENABLED_io_read] = false;
params->enabled[OVERLAY_PARAM_ENABLED_io_write] = false;
params->enabled[OVERLAY_PARAM_ENABLED_wine] = false;
params->fps_sampling_period = 500000; /* 500ms */
params->width = 0;
params->height = 140;
@ -476,6 +478,7 @@ parse_overlay_config(struct overlay_params *params,
params->media_player_color = 0xffffff;
params->media_player_name = "";
params->font_scale = 1.0f;
params->wine_color = 0xeb5b5b;
params->font_scale_media_player = 0.55f;
params->log_interval = 100;
params->media_player_order = { MP_ORDER_TITLE, MP_ORDER_ARTIST, MP_ORDER_ALBUM };
@ -538,7 +541,7 @@ parse_overlay_config(struct overlay_params *params,
params->font_scale_media_player = 0.55f;
// Convert from 0xRRGGBB to ImGui's format
std::array<unsigned *, 10> colors = {
std::array<unsigned *, 11> colors = {
&params->cpu_color,
&params->gpu_color,
&params->vram_color,
@ -549,6 +552,7 @@ parse_overlay_config(struct overlay_params *params,
&params->frametime_color,
&params->text_color,
&params->media_player_color,
&params->wine_color,
};
for (auto color : colors){

@ -49,6 +49,7 @@ typedef unsigned long KeySym;
OVERLAY_PARAM_BOOL(gpu_name) \
OVERLAY_PARAM_BOOL(engine_version) \
OVERLAY_PARAM_BOOL(histogram) \
OVERLAY_PARAM_BOOL(wine) \
OVERLAY_PARAM_CUSTOM(fps_sampling_period) \
OVERLAY_PARAM_CUSTOM(output_folder) \
OVERLAY_PARAM_CUSTOM(font_file) \
@ -86,6 +87,7 @@ typedef unsigned long KeySym;
OVERLAY_PARAM_CUSTOM(background_color) \
OVERLAY_PARAM_CUSTOM(io_color) \
OVERLAY_PARAM_CUSTOM(text_color) \
OVERLAY_PARAM_CUSTOM (wine_color) \
OVERLAY_PARAM_CUSTOM(alpha) \
OVERLAY_PARAM_CUSTOM(log_duration) \
OVERLAY_PARAM_CUSTOM(pci_dev) \
@ -156,7 +158,7 @@ struct overlay_params {
unsigned vsync;
int gl_vsync;
uint64_t log_duration;
unsigned cpu_color, gpu_color, vram_color, ram_color, engine_color, io_color, frametime_color, background_color, text_color;
unsigned cpu_color, gpu_color, vram_color, ram_color, engine_color, io_color, frametime_color, background_color, text_color, wine_color;
unsigned media_player_color;
unsigned tableCols;
unsigned render_mango;

Loading…
Cancel
Save