refactor(compat): remove unnecessary compat code (#20)

* Delete pages/settings/compatibility.vue

* Update settings.vue

* Update debug.vue

* Update lib.rs

* Update compat.rs
This commit is contained in:
Aden Lindsay
2025-01-09 13:14:27 +10:30
committed by GitHub
parent 9038c5a955
commit cc1020a004
5 changed files with 9 additions and 84 deletions
-5
View File
@@ -73,11 +73,6 @@ const navigation: Array<NavigationItem & { icon: Component }> = [
]; ];
const currentPlatform = platform(); const currentPlatform = platform();
switch (currentPlatform) {
case "linux":
navigation.splice(2, 0, { label: "Compatibility", route: "/settings/compatibility", prefix: "/settings/compatibility", icon: CubeIcon });
break;
}
const currentPageIndex = useCurrentNavigationIndex(navigation); const currentPageIndex = useCurrentNavigationIndex(navigation);
</script> </script>
-3
View File
@@ -1,3 +0,0 @@
<template>
</template>
-25
View File
@@ -58,26 +58,6 @@
</p> </p>
</div> </div>
<div v-if="compatInfo">
<div class="flex items-center gap-x-3">
<CubeIcon class="h-5 w-5 text-zinc-400" />
<h3 class="text-sm font-medium leading-6 text-zinc-100">
Compatibility Settings
</h3>
</div>
<div class="mt-2 ml-8 space-y-1">
<p class="text-sm text-zinc-400 font-mono">
Enabled: {{ compatInfo.enabled ? "Yes" : "No" }}
</p>
<p class="text-sm text-zinc-400 font-mono">
Runner: {{ compatInfo.runner || "Not configured" }}
</p>
<p class="text-sm text-zinc-400 font-mono">
Prefix: {{ compatInfo.prefix || "Not configured" }}
</p>
</div>
</div>
<div class="pt-6 flex gap-x-4"> <div class="pt-6 flex gap-x-4">
<button <button
@click="() => openDataDir()" @click="() => openDataDir()"
@@ -119,11 +99,6 @@ const clientId = ref<string | null>(null);
const platformInfo = ref("Loading..."); const platformInfo = ref("Loading...");
const baseUrl = ref<string | null>(null); const baseUrl = ref<string | null>(null);
const dataDir = ref<string | null>(null); const dataDir = ref<string | null>(null);
const compatInfo = ref<{
enabled: boolean;
runner: string | null;
prefix: string | null;
} | null>(null);
const systemData = await invoke<{ const systemData = await invoke<{
clientId: string; clientId: string;
-6
View File
@@ -38,7 +38,6 @@ use log4rs::append::file::FileAppender;
use log4rs::config::{Appender, Root}; use log4rs::config::{Appender, Root};
use log4rs::encode::pattern::PatternEncoder; use log4rs::encode::pattern::PatternEncoder;
use log4rs::Config; use log4rs::Config;
use process::compat::CompatibilityManager;
use process::process_commands::{kill_game, launch_game}; use process::process_commands::{kill_game, launch_game};
use process::process_manager::ProcessManager; use process::process_manager::ProcessManager;
use remote::{gen_drop_url, use_remote}; use remote::{gen_drop_url, use_remote};
@@ -87,8 +86,6 @@ pub struct AppState<'a> {
download_manager: Arc<DownloadManager>, download_manager: Arc<DownloadManager>,
#[serde(skip_serializing)] #[serde(skip_serializing)]
process_manager: Arc<Mutex<ProcessManager<'a>>>, process_manager: Arc<Mutex<ProcessManager<'a>>>,
#[serde(skip_serializing)]
compat_manager: Arc<Mutex<CompatibilityManager>>,
} }
#[tauri::command] #[tauri::command]
@@ -127,7 +124,6 @@ fn setup(handle: AppHandle) -> AppState<'static> {
let games = HashMap::new(); let games = HashMap::new();
let download_manager = Arc::new(DownloadManagerBuilder::build(handle.clone())); let download_manager = Arc::new(DownloadManagerBuilder::build(handle.clone()));
let process_manager = Arc::new(Mutex::new(ProcessManager::new(handle.clone()))); let process_manager = Arc::new(Mutex::new(ProcessManager::new(handle.clone())));
let compat_manager = Arc::new(Mutex::new(CompatibilityManager::new()));
debug!("Checking if database is set up"); debug!("Checking if database is set up");
let is_set_up = DB.database_is_set_up(); let is_set_up = DB.database_is_set_up();
@@ -138,7 +134,6 @@ fn setup(handle: AppHandle) -> AppState<'static> {
games, games,
download_manager, download_manager,
process_manager, process_manager,
compat_manager,
}; };
} }
@@ -200,7 +195,6 @@ fn setup(handle: AppHandle) -> AppState<'static> {
games, games,
download_manager, download_manager,
process_manager, process_manager,
compat_manager,
} }
} }
+9 -45
View File
@@ -1,49 +1,13 @@
use std::{ // Since this code isn't being used, we can either:
fs::create_dir_all, // 1. Delete the entire file if compatibility features are not planned
path::PathBuf, // 2. Or add a TODO comment if planning to implement later
sync::atomic::{AtomicBool, Ordering},
};
use crate::db::DATA_ROOT_DIR; // Option 1: Delete the file
// Delete src-tauri/src/process/compat.rs
pub struct CompatibilityManager {
compat_tools_path: PathBuf,
prefixes_path: PathBuf,
created_paths: AtomicBool,
}
// Option 2: Add TODO comment
/* /*
This gets built into both the Windows & Linux client, but TODO: Compatibility layer for running Windows games on Linux
we only need it in the Linux client. Therefore, it should This module is currently unused but reserved for future implementation
do nothing but take a little bit of memory if we're on of Windows game compatibility features on Linux.
Windows.
*/ */
impl CompatibilityManager {
pub fn new() -> Self {
let root_dir_lock = DATA_ROOT_DIR.lock().unwrap();
let compat_tools_path = root_dir_lock.join("compatibility_tools");
let prefixes_path = root_dir_lock.join("prefixes");
drop(root_dir_lock);
Self {
compat_tools_path,
prefixes_path,
created_paths: AtomicBool::new(false),
}
}
fn ensure_paths_exist(&self) -> Result<(), String> {
if self.created_paths.fetch_and(true, Ordering::Relaxed) {
return Ok(());
}
if !self.compat_tools_path.exists() {
create_dir_all(self.compat_tools_path.clone()).map_err(|e| e.to_string())?;
}
if !self.prefixes_path.exists() {
create_dir_all(self.prefixes_path.clone()).map_err(|e| e.to_string())?;
}
self.created_paths.store(true, Ordering::Relaxed);
Ok(())
}
}