diff --git a/src/components/dxvk.rs b/src/components/dxvk.rs index d4a850a..6a00d0d 100644 --- a/src/components/dxvk.rs +++ b/src/components/dxvk.rs @@ -32,7 +32,7 @@ impl Group { } } -#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct Features { /// Standard environment variables that are applied when you launch the game /// @@ -42,7 +42,19 @@ pub struct Features { /// - `%temp%` - path to temp folder specified in config file /// - `%launcher%` - path to launcher folder /// - `%game%` - path to the game - pub env: HashMap + pub env: HashMap, + + pub recommended: bool +} + +impl Default for Features { + #[inline] + fn default() -> Self { + Self { + env: HashMap::new(), + recommended: true + } + } } impl From<&JsonValue> for Features { @@ -65,6 +77,11 @@ impl From<&JsonValue> for Features { default.env }, None => default.env + }, + + recommended: match value.get("recommended") { + Some(value) => value.as_bool().unwrap_or(default.recommended), + None => default.recommended } } } diff --git a/src/components/wine.rs b/src/components/wine.rs index f5211f2..1358f65 100644 --- a/src/components/wine.rs +++ b/src/components/wine.rs @@ -64,17 +64,21 @@ pub struct Features { /// - `%temp%` - path to temp folder specified in config file /// - `%launcher%` - path to launcher folder /// - `%game%` - path to the game - pub env: HashMap + pub env: HashMap, + + pub recommended: bool } impl Default for Features { + #[inline] fn default() -> Self { Self { bundle: None, need_dxvk: true, compact_launch: false, command: None, - env: HashMap::new() + env: HashMap::new(), + recommended: true } } } @@ -125,6 +129,11 @@ impl From<&JsonValue> for Features { } None => default.env + }, + + recommended: match value.get("recommended") { + Some(value) => value.as_bool().unwrap_or(default.recommended), + None => default.recommended } } } @@ -140,6 +149,7 @@ pub struct Version { } impl Version { + #[inline] /// Get latest recommended wine version pub fn latest>(components: T) -> anyhow::Result { Ok(get_groups(components)?[0].versions[0].clone()) @@ -171,14 +181,14 @@ impl Version { Ok(None) } - /// Check is current wine downloaded in specified folder #[inline] + /// Check is current wine downloaded in specified folder pub fn is_downloaded_in>(&self, folder: T) -> bool { folder.into().join(&self.name).exists() } - /// Return this version's features #[inline] + /// Return this version's features pub fn version_features(&self) -> Option { self.features.clone() } @@ -191,7 +201,7 @@ impl Version { } else { - group.features.as_ref().map(|features| features.to_owned()) + group.features.clone() } } @@ -213,7 +223,6 @@ impl Version { /// Convert current wine struct to one from `wincompatlib` /// /// `wine_folder` should point to the folder with wine binaries, so e.g. `/path/to/runners/wine-proton-ge-7.11` - #[inline] pub fn to_wine>(&self, components: T, wine_folder: Option) -> WincompatlibWine { let wine_folder = wine_folder.map(|folder| folder.into()).unwrap_or_default(); @@ -269,18 +278,21 @@ pub enum WincompatlibWine { } impl From for WincompatlibWine { + #[inline] fn from(wine: Wine) -> Self { Self::Default(wine) } } impl From for WincompatlibWine { + #[inline] fn from(proton: Proton) -> Self { Self::Proton(proton) } } impl WineWithExt for WincompatlibWine { + #[inline] fn with_prefix>(self, prefix: T) -> Self { match self { Self::Default(wine) => Self::Default(wine.with_prefix(prefix)), @@ -288,6 +300,7 @@ impl WineWithExt for WincompatlibWine { } } + #[inline] fn with_arch(self, arch: WineArch) -> Self { match self { Self::Default(wine) => Self::Default(wine.with_arch(arch)), @@ -295,6 +308,7 @@ impl WineWithExt for WincompatlibWine { } } + #[inline] fn with_boot(self, boot: WineBoot) -> Self { match self { Self::Default(wine) => Self::Default(wine.with_boot(boot)), @@ -302,6 +316,7 @@ impl WineWithExt for WincompatlibWine { } } + #[inline] fn with_server>(self, server: T) -> Self { match self { Self::Default(wine) => Self::Default(wine.with_server(server)), @@ -309,6 +324,7 @@ impl WineWithExt for WincompatlibWine { } } + #[inline] fn with_loader(self, loader: WineLoader) -> Self { match self { Self::Default(wine) => Self::Default(wine.with_loader(loader)), @@ -318,6 +334,7 @@ impl WineWithExt for WincompatlibWine { } impl WineBootExt for WincompatlibWine { + #[inline] fn wineboot_command(&self) -> std::process::Command { match self { Self::Default(wine) => wine.wineboot_command(), @@ -325,6 +342,7 @@ impl WineBootExt for WincompatlibWine { } } + #[inline] fn update_prefix>(&self, path: Option) -> Result { match self { Self::Default(wine) => wine.update_prefix(path), @@ -332,6 +350,7 @@ impl WineBootExt for WincompatlibWine { } } + #[inline] fn stop_processes(&self, force: bool) -> Result { match self { Self::Default(wine) => wine.stop_processes(force), @@ -339,6 +358,7 @@ impl WineBootExt for WincompatlibWine { } } + #[inline] fn restart(&self) -> Result { match self { Self::Default(wine) => wine.restart(), @@ -346,6 +366,7 @@ impl WineBootExt for WincompatlibWine { } } + #[inline] fn shutdown(&self) -> Result { match self { Self::Default(wine) => wine.shutdown(), @@ -353,6 +374,7 @@ impl WineBootExt for WincompatlibWine { } } + #[inline] fn end_session(&self) -> Result { match self { Self::Default(wine) => wine.end_session(), @@ -361,6 +383,7 @@ impl WineBootExt for WincompatlibWine { } } +#[inline] pub fn get_groups>(components: T) -> anyhow::Result> { ComponentsLoader::new(components).get_wine_versions() } diff --git a/src/game.rs b/src/game.rs index 89fa9c9..bdc1ea7 100644 --- a/src/game.rs +++ b/src/game.rs @@ -189,6 +189,8 @@ pub fn run() -> anyhow::Result<()> { } } + // TODO: fix mangohud + command.envs(config.game.wine.sync.get_env_vars()); command.envs(config.game.enhancements.hud.get_env_vars(&config)); command.envs(config.game.enhancements.fsr.get_env_vars());