aboutsummaryrefslogtreecommitdiff
path: root/src-tauri
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri')
-rw-r--r--src-tauri/src/lib.rs40
-rw-r--r--src-tauri/src/main.rs20
-rw-r--r--src-tauri/src/platform_specific/mod.rs2
-rw-r--r--src-tauri/src/platform_specific/windows.rs40
-rw-r--r--src-tauri/src/repair_and_verify/mod.rs9
5 files changed, 72 insertions, 39 deletions
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index f19a178c..d0bc9be2 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -2,10 +2,9 @@ use std::env;
use anyhow::{anyhow, Context, Result};
+mod platform_specific;
#[cfg(target_os = "windows")]
-use powershell_script::PsScriptBuilder;
-#[cfg(target_os = "windows")]
-use regex::Regex;
+use platform_specific::windows;
use serde::{Deserialize, Serialize};
use sysinfo::SystemExt;
@@ -41,39 +40,6 @@ pub fn check_mod_version_number(path_to_mod_folder: String) -> Result<String, an
Ok(mod_version_number.to_string())
}
-#[cfg(target_os = "windows")]
-/// Runs a powershell command and parses output to get Titanfall2 install location on Origin
-fn windows_origin_install_location_detection() -> Result<String, anyhow::Error> {
- dbg!();
-
- // Run PowerShell command to get Titanfall2 Origin install path
- let ps = PsScriptBuilder::new()
- .no_profile(true)
- .non_interactive(true)
- .hidden(false)
- .print_commands(false)
- .build();
- let output = ps.run(r#"Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Respawn\Titanfall2\ -Name "Install Dir""#).unwrap();
-
- // Get command output as string
- let string = output.stdout().unwrap();
-
- // Regex the result out and return value accordingly
- let regex = Regex::new(r"(?m)Install Dir.+: (.+)\r\n").unwrap();
- let mut result = regex.captures_iter(&string);
- match result.next() {
- Some(mat) => {
- let game_path = mat.get(1).map_or("", |m| m.as_str());
- println!("{}", game_path);
- match check_is_valid_game_path(game_path) {
- Ok(()) => return Ok(game_path.to_owned()),
- Err(err) => Err(err),
- }
- }
- None => Err(anyhow!("No Origin install path found")),
- }
-}
-
/// Attempts to find the game install location
pub fn find_game_install_location() -> Result<GameInstall, anyhow::Error> {
// Attempt parsing Steam library directly
@@ -97,7 +63,7 @@ pub fn find_game_install_location() -> Result<GameInstall, anyhow::Error> {
// (On Windows only) try parsing Windows registry for Origin install path
#[cfg(target_os = "windows")]
- match windows_origin_install_location_detection() {
+ match windows::origin_install_location_detection() {
Ok(game_path) => {
let game_install = GameInstall {
game_path: game_path,
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 536acbe5..025b6863 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -15,6 +15,10 @@ use app::{
get_host_os, get_log_list, get_northstar_version_number, install_northstar, launch_northstar,
GameInstall,
};
+
+mod repair_and_verify;
+use repair_and_verify::verify_game_files;
+
use tauri::Manager;
use tokio::time::sleep;
use tauri_plugin_store::PluginBuilder;
@@ -78,7 +82,8 @@ fn main() {
update_northstar_caller,
launch_northstar_caller,
check_is_flightcore_outdated_caller,
- get_log_list_caller
+ get_log_list_caller,
+ verify_game_files_caller
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
@@ -106,7 +111,13 @@ fn force_panic() {
/// Returns the current version number as a string
fn get_version_number() -> String {
let version = env!("CARGO_PKG_VERSION");
- format!("v{}", version)
+ if cfg!(debug_assertions) {
+ // Debugging enabled
+ format!("v{} (debug mode)", version)
+ } else {
+ // Debugging disabled
+ format!("v{}", version)
+ }
}
#[tauri::command]
@@ -240,3 +251,8 @@ fn launch_northstar_caller(game_install: GameInstall) -> Result<String, String>
fn get_log_list_caller(game_install: GameInstall) -> Result<Vec<std::path::PathBuf>, String> {
get_log_list(game_install)
}
+
+#[tauri::command]
+fn verify_game_files_caller(game_install: GameInstall) -> Result<String, String> {
+ verify_game_files(game_install)
+}
diff --git a/src-tauri/src/platform_specific/mod.rs b/src-tauri/src/platform_specific/mod.rs
new file mode 100644
index 00000000..581af77f
--- /dev/null
+++ b/src-tauri/src/platform_specific/mod.rs
@@ -0,0 +1,2 @@
+#[cfg(target_os = "windows")]
+pub mod windows;
diff --git a/src-tauri/src/platform_specific/windows.rs b/src-tauri/src/platform_specific/windows.rs
new file mode 100644
index 00000000..7627fe4f
--- /dev/null
+++ b/src-tauri/src/platform_specific/windows.rs
@@ -0,0 +1,40 @@
+/// Windows specific code
+
+use powershell_script::PsScriptBuilder;
+use regex::Regex;
+
+use anyhow::{anyhow, Result};
+
+use crate::check_is_valid_game_path;
+
+/// Runs a powershell command and parses output to get Titanfall2 install location on Origin
+pub fn origin_install_location_detection() -> Result<String, anyhow::Error> {
+ dbg!();
+
+ // Run PowerShell command to get Titanfall2 Origin install path
+ let ps = PsScriptBuilder::new()
+ .no_profile(true)
+ .non_interactive(true)
+ .hidden(false)
+ .print_commands(false)
+ .build();
+ let output = ps.run(r#"Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Respawn\Titanfall2\ -Name "Install Dir""#).unwrap();
+
+ // Get command output as string
+ let string = output.stdout().unwrap();
+
+ // Regex the result out and return value accordingly
+ let regex = Regex::new(r"(?m)Install Dir.+: (.+)\r\n").unwrap();
+ let mut result = regex.captures_iter(&string);
+ match result.next() {
+ Some(mat) => {
+ let game_path = mat.get(1).map_or("", |m| m.as_str());
+ println!("{}", game_path);
+ match check_is_valid_game_path(game_path) {
+ Ok(()) => return Ok(game_path.to_owned()),
+ Err(err) => Err(err),
+ }
+ }
+ None => Err(anyhow!("No Origin install path found")),
+ }
+}
diff --git a/src-tauri/src/repair_and_verify/mod.rs b/src-tauri/src/repair_and_verify/mod.rs
new file mode 100644
index 00000000..e99dcbfc
--- /dev/null
+++ b/src-tauri/src/repair_and_verify/mod.rs
@@ -0,0 +1,9 @@
+/// Contains various functions to repair common issues and verifying installation
+
+use app::GameInstall;
+
+/// Verifies Titanfall2 game files
+pub fn verify_game_files(game_install: GameInstall) -> Result<String, String> {
+ dbg!(game_install);
+ Err("TODO, not yet implemented".to_string())
+}