mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-11-24 22:06:18 +03:00
Added wine sync support and prepared to add debug launch
This commit is contained in:
parent
8bec171c5d
commit
86de977e05
2 changed files with 64 additions and 3 deletions
|
@ -84,6 +84,25 @@ impl Config {
|
|||
None => None
|
||||
}
|
||||
}
|
||||
|
||||
/// Get environment variables corresponding to used wine sync
|
||||
pub fn get_wine_sync_env_vars(&self) -> HashMap<&str, &str> {
|
||||
match self.game.wine.sync.as_str() {
|
||||
"esync" => HashMap::from([
|
||||
("WINEESYNC", "1")
|
||||
]),
|
||||
"fsync" => HashMap::from([
|
||||
("WINEESYNC", "1"),
|
||||
("WINEFSYNC", "1")
|
||||
]),
|
||||
"futex2" => HashMap::from([
|
||||
("WINEESYNC", "1"),
|
||||
("WINEFSYNC", "1"),
|
||||
("WINEFSYNC_FUTEX2", "1")
|
||||
]),
|
||||
_ => HashMap::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
|
|
@ -4,6 +4,45 @@ use std::process::Command;
|
|||
|
||||
use super::config;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Terminal {
|
||||
GnomeTerminal,
|
||||
Konsole,
|
||||
Xfce4Terminal
|
||||
}
|
||||
|
||||
impl Terminal {
|
||||
pub fn get_command(&self) -> &str {
|
||||
match self {
|
||||
Terminal::GnomeTerminal => "gnome-terminal",
|
||||
Terminal::Konsole => "konsole",
|
||||
Terminal::Xfce4Terminal => "xfce4-terminal"
|
||||
}
|
||||
}
|
||||
|
||||
pub fn iter() -> impl Iterator<Item = Terminal> {
|
||||
[
|
||||
Terminal::GnomeTerminal,
|
||||
Terminal::Konsole,
|
||||
Terminal::Xfce4Terminal
|
||||
].into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
/// Try to get GUI terminal installed in system
|
||||
pub fn try_get_terminal() -> Option<Terminal> {
|
||||
for terminal in Terminal::iter() {
|
||||
if let Ok(output) = Command::new(terminal.get_command()).output() {
|
||||
if output.status.success() {
|
||||
return Some(terminal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
/// Try to run the game
|
||||
pub fn run() -> Result<(), Error> {
|
||||
let config = config::get()?;
|
||||
|
||||
|
@ -16,9 +55,12 @@ pub fn run() -> Result<(), Error> {
|
|||
None => return Err(Error::new(ErrorKind::Other, "Couldn't find wine executable"))
|
||||
};
|
||||
|
||||
Command::new(wine_executable)
|
||||
.env("WINEPREFIX", config.game.wine.prefix)
|
||||
.envs(config.game.environment)
|
||||
let mut command = Command::new(wine_executable);
|
||||
|
||||
command.env("WINEPREFIX", &config.game.wine.prefix);
|
||||
command.envs(config.get_wine_sync_env_vars());
|
||||
|
||||
command.envs(config.game.environment)
|
||||
.current_dir(config.game.path)
|
||||
.arg("launcher.bat")
|
||||
.spawn()?;
|
||||
|
|
Loading…
Reference in a new issue