Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@tailwindcss/vite": "^4.1.18",
"@tauri-apps/api": "^2.10.1",
"@tauri-apps/plugin-dialog": "^2.6.0",
"@tauri-apps/plugin-fs": "^2.4.5",
"@tauri-apps/plugin-opener": "^2.5.3",
"@tauri-apps/plugin-os": "~2.3.2",
"reka-ui": "^2.8.0",
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
tauri-build = { version = "2", features = [] }

[dependencies]
tauri = { version = "2.10.1", features = [] }
tauri = { version = "2.10.1", features = ["protocol-asset"] }
tauri-plugin-opener = "2"
tauri-plugin-dialog = "2.6.0"
serde = { version = "1", features = ["derive"] }
Expand All @@ -22,3 +22,4 @@ colog = "1.4.0"
serini = "0.2.2"
tauri-plugin-decorum = "1.1.1"
tauri-plugin-os = "2"
tauri-plugin-fs = "2"
9 changes: 4 additions & 5 deletions src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": [
"main"
],
"windows": ["main"],
"permissions": [
"core:default",
"opener:default",
Expand All @@ -20,6 +18,7 @@
"core:window:allow-start-dragging",
"core:window:allow-toggle-maximize",
"decorum:allow-show-snap-overlay",
"os:default"
"os:default",
"fs:default"
]
}
}
42 changes: 39 additions & 3 deletions src-tauri/src/engines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub struct EngineContext {
pub folder_path: String,
pub exe_path: String,
pub engine_kind: EngineKind,
pub exe_type: ExecutableType,
}

/// Acesss the registery using:
Expand Down Expand Up @@ -75,6 +76,7 @@ impl EngineRegistery {
folder_path: string_path.clone(),
exe_path: string_path,
engine_kind: EngineKind::Executable,
exe_type: ExecutableType::Platform,
};

for (engine_kind, detector) in &self.detectors {
Expand All @@ -86,8 +88,9 @@ impl EngineRegistery {
// Sort by engine kind, the highest one wins if we have multiple
found_kinds.sort_by_key(|a| *a.0);

if let Some((final_kind, exe_kind)) = found_kinds.last() {
if let Some((final_kind, exe_type)) = found_kinds.last() {
base_context.engine_kind = **final_kind;
base_context.exe_type = *exe_type;

// Update any context properties that may change from detector to detector
// Executable detector sets the exe_path internally due to the nature of how it detects
Expand All @@ -98,7 +101,7 @@ impl EngineRegistery {
// Manually set the exe_path for other engines

if base_context.engine_kind != EngineKind::Executable {
let exe_extenstion = if exe_kind == &ExecutableType::Platform {
let exe_extenstion = if base_context.exe_type == ExecutableType::Platform {
EXE_EXTENSION
} else {
WINDOWS_EXE_EXTENSION
Expand Down Expand Up @@ -202,8 +205,9 @@ impl EngineDetector for ExecutableDetector {
let folder_path = Path::new(&context.folder_path);
let mut exe_filename = "".to_owned();

if let Some((_, exe_path)) = check_for_any_executable(folder_path) {
if let Some((exe_type, exe_path)) = check_for_any_executable(folder_path) {
context.exe_path = exe_path.to_string_lossy().to_string();
context.exe_type = exe_type;
exe_filename = exe_path.file_stem().unwrap().to_string_lossy().to_string();
}

Expand Down Expand Up @@ -472,6 +476,8 @@ pub struct EngineCanonInfo {

pub canonical_icon_path: Option<String>,
pub canonical_banner_path: Option<String>,
pub canonical_launch_args: Option<String>,
pub canonical_command: Option<String>,
}

#[tauri::command]
Expand Down Expand Up @@ -511,6 +517,13 @@ pub fn get_engine_contexts_internal(context_store: &ContextStore) -> Vec<EngineC
let canonical_icon_path = detector.detect_icon();
let canonical_banner_path = detector.detect_banner();

let canonical_command = if context.exe_type == ExecutableType::WindowsOnUnix {
// FIXME: Detectors should be able to specify/override this launch command
Some("wine".to_string())
} else {
None
};

EngineCanonInfo {
context: context.clone(),

Expand All @@ -524,6 +537,8 @@ pub fn get_engine_contexts_internal(context_store: &ContextStore) -> Vec<EngineC

canonical_icon_path,
canonical_banner_path,
canonical_launch_args: None, // FIXME: Detectors should be able to specify launch args
canonical_command,
}
})
})
Expand Down Expand Up @@ -589,3 +604,24 @@ pub fn add_engine_context_internal(
}
})
}

#[tauri::command]
pub fn remove_engine_context(
context_store: State<Mutex<ContextStore>>,
folder_path: String,
) -> Result<(), String> {
let mut store = context_store.lock().unwrap();
remove_engine_context_internal(&mut store, folder_path)
}

pub fn remove_engine_context_internal(
context_store: &mut ContextStore,
folder_path: String,
) -> Result<(), String> {
if let Some(_) = context_store.engine_list.remove(&folder_path) {
context_store.mods_list.remove(&folder_path);
Ok(())
} else {
Err("No engine found at the specified folder!".to_string())
}
}
1 change: 1 addition & 0 deletions src-tauri/src/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub struct EditableInstanceInfo {
pub color_hex: Option<String>,
pub icon_path: Option<String>,
pub banner_path: Option<String>,
pub launch_command: Option<String>,
pub launch_args: Option<String>,
}

Expand Down
8 changes: 6 additions & 2 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ struct InstanceStore {
json_save_path: String,
instance_list: InstanceList,
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
colog::init();

tauri::Builder::default()
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_decorum::init())
Expand Down Expand Up @@ -86,9 +86,13 @@ pub fn run() {
.invoke_handler(tauri::generate_handler![
// utils.rs
utils::show_main_window,
utils::get_dir_size,
utils::launch_executable,
utils::has_non_directory_path,
// engines.rs
engines::get_engine_contexts,
engines::add_engine_context,
engines::remove_engine_context,
// mods.rs
mods::get_mod_contexts_in_folder,
// instances.rs
Expand All @@ -98,7 +102,7 @@ pub fn run() {
instances::add_child_instance,
instances::remove_child_instance,
instances::edit_instance,
instances::remove_instance,
instances::remove_instance
])
.plugin(tauri_plugin_opener::init())
.run(tauri::generate_context!())
Expand Down
Loading
Loading