inprogress: compat
This commit is contained in:
@@ -58,12 +58,14 @@ impl DatabaseImpls for DatabaseInterface {
|
||||
let games_base_dir = data_root_dir.join("games");
|
||||
let logs_root_dir = data_root_dir.join("logs");
|
||||
let cache_dir = data_root_dir.join("cache");
|
||||
let pfx_dir = data_root_dir.join("pfx");
|
||||
|
||||
debug!("creating data directory at {:?}", data_root_dir);
|
||||
create_dir_all(data_root_dir.clone()).unwrap();
|
||||
create_dir_all(&games_base_dir).unwrap();
|
||||
create_dir_all(&logs_root_dir).unwrap();
|
||||
create_dir_all(&cache_dir).unwrap();
|
||||
create_dir_all(&pfx_dir).unwrap();
|
||||
|
||||
let exists = fs::exists(db_path.clone()).unwrap();
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ pub mod data {
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub type GameVersion = v1::GameVersion;
|
||||
pub type Database = v1::Database;
|
||||
pub type Database = v2::Database;
|
||||
pub type Settings = v1::Settings;
|
||||
pub type DatabaseAuth = v1::DatabaseAuth;
|
||||
|
||||
@@ -11,6 +11,8 @@ pub mod data {
|
||||
pub type ApplicationTransientStatus = v1::ApplicationTransientStatus;
|
||||
pub type DownloadableMetadata = v1::DownloadableMetadata;
|
||||
pub type DownloadType = v1::DownloadType;
|
||||
pub type DatabaseApplications = v1::DatabaseApplications;
|
||||
pub type DatabaseCompatInfo = v2::DatabaseCompatInfo;
|
||||
|
||||
pub mod v1 {
|
||||
use crate::process::process_manager::Platform;
|
||||
@@ -157,8 +159,46 @@ pub mod data {
|
||||
pub prev_database: Option<PathBuf>,
|
||||
pub cache_dir: PathBuf,
|
||||
}
|
||||
}
|
||||
|
||||
pub mod v2 {
|
||||
use std::{collections::HashMap, io::ErrorKind, path::PathBuf, process::Command};
|
||||
|
||||
use crate::process::process_manager::UMU_LAUNCHER_EXECUTABLE;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[native_model(id = 1, version = 2)]
|
||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||
pub struct Database {
|
||||
#[serde(default)]
|
||||
pub settings: Settings,
|
||||
pub auth: Option<DatabaseAuth>,
|
||||
pub base_url: String,
|
||||
pub applications: DatabaseApplications,
|
||||
pub prev_database: Option<PathBuf>,
|
||||
pub cache_dir: PathBuf,
|
||||
pub compat_info: Option<DatabaseCompatInfo>,
|
||||
}
|
||||
|
||||
#[native_model(id = 8, version = 2)]
|
||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||
|
||||
pub struct DatabaseCompatInfo {
|
||||
umu_installed: bool,
|
||||
}
|
||||
|
||||
impl Database {
|
||||
fn create_new_compat_info() -> Option<DatabaseCompatInfo> {
|
||||
#[cfg(target_os = "windows")]
|
||||
return None;
|
||||
|
||||
let has_umu_installed = Command::new(UMU_LAUNCHER_EXECUTABLE).spawn().is_ok();
|
||||
Some(DatabaseCompatInfo {
|
||||
umu_installed: has_umu_installed,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn new<T: Into<PathBuf>>(
|
||||
games_base_dir: T,
|
||||
prev_database: Option<PathBuf>,
|
||||
@@ -177,6 +217,21 @@ pub mod data {
|
||||
auth: None,
|
||||
settings: Settings::default(),
|
||||
cache_dir,
|
||||
compat_info: Database::create_new_compat_info(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<v1::Database> for Database {
|
||||
fn from(value: v1::Database) -> Self {
|
||||
Self {
|
||||
settings: value.settings,
|
||||
auth: value.auth,
|
||||
base_url: value.base_url,
|
||||
applications: value.applications,
|
||||
prev_database: value.prev_database,
|
||||
cache_dir: value.cache_dir,
|
||||
compat_info: Database::create_new_compat_info(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ pub fn run() {
|
||||
],
|
||||
)?;
|
||||
|
||||
TrayIconBuilder::new()
|
||||
let trayicon_result = TrayIconBuilder::new()
|
||||
.icon(app.default_window_icon().unwrap().clone())
|
||||
.menu(&menu)
|
||||
.on_menu_event(|app, event| match event.id.as_ref() {
|
||||
@@ -345,8 +345,11 @@ pub fn run() {
|
||||
warn!("menu event not handled: {:?}", event.id);
|
||||
}
|
||||
})
|
||||
.build(app)
|
||||
.expect("error while setting up tray menu");
|
||||
.build(app);
|
||||
|
||||
if let Err(trayicon_error) = trayicon_result {
|
||||
warn!("failed to set up tray icon: {}", trayicon_error.to_string())
|
||||
}
|
||||
|
||||
{
|
||||
let mut db_handle = borrow_db_mut_checked();
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// Since this code isn't being used, we can either:
|
||||
// 1. Delete the entire file if compatibility features are not planned
|
||||
// 2. Or add a TODO comment if planning to implement later
|
||||
|
||||
// Option 1: Delete the file
|
||||
// Delete src-tauri/src/process/compat.rs
|
||||
|
||||
// Option 2: Add TODO comment
|
||||
/*
|
||||
TODO: Compatibility layer for running Windows games on Linux
|
||||
This module is currently unused but reserved for future implementation
|
||||
of Windows game compatibility features on Linux.
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod commands;
|
||||
#[cfg(target_os = "linux")]
|
||||
pub mod compat;
|
||||
pub mod process_manager;
|
||||
|
||||
@@ -358,7 +358,7 @@ impl ProcessHandler for NativeGameLauncher {
|
||||
}
|
||||
}
|
||||
|
||||
const UMU_LAUNCHER_EXECUTABLE: &str = "umu-run";
|
||||
pub const UMU_LAUNCHER_EXECUTABLE: &str = "umu-run";
|
||||
struct UMULauncher;
|
||||
impl ProcessHandler for UMULauncher {
|
||||
fn create_launch_process(
|
||||
|
||||
Reference in New Issue
Block a user