Disabled mangohud if gamescope is enabled

This commit is contained in:
Observer KRypt0n_ 2022-08-04 00:13:24 +02:00
parent d135ef691c
commit 116b31fbdb
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
2 changed files with 17 additions and 7 deletions

View file

@ -2,6 +2,8 @@ use std::collections::HashMap;
use serde::{Serialize, Deserialize};
use super::Config;
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum HUD {
None,
@ -40,15 +42,23 @@ impl Into<u32> for HUD {
impl HUD {
/// Get environment variables corresponding to used wine hud
pub fn get_env_vars(&self) -> HashMap<&str, &str> {
pub fn get_env_vars(&self, config: &Config) -> HashMap<&str, &str> {
match self {
Self::None => HashMap::new(),
Self::DXVK => HashMap::from([
("DXVK_HUD", "fps,frametimes,version,gpuload")
]),
Self::MangoHUD => HashMap::from([
Self::MangoHUD => {
// Don't show mangohud if gamescope is enabled
// otherwise it'll be doubled
if config.game.enhancements.gamescope.enabled {
HashMap::new()
} else {
HashMap::from([
("MANGOHUD", "1")
])
}
}
}
}
}

View file

@ -103,7 +103,7 @@ pub fn run(debug: bool) -> std::io::Result<()> {
bash_chain = format!("{gamescope} -- {bash_chain}");
}
let bash_chain = match config.game.command {
let bash_chain = match &config.game.command {
Some(command) => command.replace("%command%", &bash_chain),
None => bash_chain
};
@ -119,14 +119,14 @@ pub fn run(debug: bool) -> std::io::Result<()> {
command.env("WINEPREFIX", &config.game.wine.prefix);
// Add DXVK_ASYNC=1 for dxvk-async builds automatically
if let Some(dxvk) = config.game.dxvk.selected {
if let Some(dxvk) = &config.game.dxvk.selected {
if dxvk.contains("async") {
command.env("DXVK_ASYNC", "1");
}
}
command.envs(config.game.wine.sync.get_env_vars());
command.envs(config.game.enhancements.hud.get_env_vars());
command.envs(config.game.enhancements.hud.get_env_vars(&config));
command.envs(config.game.enhancements.fsr.get_env_vars());
command.envs(config.game.wine.language.get_env_vars());