aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dist/index.html4
-rw-r--r--src-tauri/src/lib.rs25
-rw-r--r--src-tauri/src/main.rs38
-rw-r--r--src-ui/src/main.ts19
4 files changed, 73 insertions, 13 deletions
diff --git a/dist/index.html b/dist/index.html
index 14592dff..2d4d1acb 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -26,6 +26,10 @@
<!-- This button is solely for testing purposes. It force crashes the application to check crash logging -->
<panic-button>Panic Button</panic-button>
+ <!-- Button to allow switching to installing release candidate -->
+ <!-- Should be switched to dropdown menu later -->
+ Use release candidate? <input type="checkbox" id="use-release-candidate-checkbox" />
+
<!-- This showcases ping activity between frontend and backend. Should be hidden in non-dev/debug mode -->
<backend-ping class="server"></backend-ping>
</body>
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 63f57cd4..c74579d7 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -232,8 +232,20 @@ async fn do_install(nmod: &thermite::model::Mod, game_path: &std::path::Path) ->
Ok(())
}
-pub async fn install_northstar(game_path: &str) -> Result<String> {
- let northstar_package_name = "Northstar".to_lowercase();
+pub async fn install_northstar(
+ game_path: &str,
+ northstar_package_name: Option<String>,
+) -> Result<String> {
+ let northstar_package_name = match northstar_package_name {
+ Some(northstar_package_name) => {
+ if northstar_package_name.len() <= 1 {
+ "Northstar".to_string()
+ } else {
+ northstar_package_name
+ }
+ }
+ None => "Northstar".to_string(),
+ };
let index = thermite::api::get_package_index().await.unwrap().to_vec();
let nmod = index
@@ -321,3 +333,12 @@ pub fn check_origin_running() -> bool {
}
false
}
+
+/// Helps with converting release candidate numbers which are different on Thunderstore
+/// due to restrictions imposed by the platform
+pub fn convert_release_candidate_number(version_number: String) -> String {
+ // This simply converts `-rc` to `0`
+ // Works as intended for RCs < 10, e.g. `v1.9.2-rc1` -> `v1.9.201`
+ // Doesn't work for larger numbers, e.g. `v1.9.2-rc11` -> `v1.9.2011` (should be `v1.9.211`)
+ version_number.replace("-rc", "0")
+}
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 85082774..a59e24e0 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -10,8 +10,9 @@ use std::{
};
use app::{
- check_is_valid_game_path, check_origin_running, find_game_install_location, get_host_os,
- get_northstar_version_number, install_northstar, launch_northstar, GameInstall,
+ check_is_valid_game_path, check_origin_running, convert_release_candidate_number,
+ find_game_install_location, get_host_os, get_northstar_version_number, install_northstar,
+ launch_northstar, GameInstall,
};
use tauri::{Manager, State};
use tokio::time::sleep;
@@ -124,8 +125,20 @@ fn get_northstar_version_number_caller(game_path: String) -> String {
/// Checks if installed Northstar version is up-to-date
/// false -> Northstar install is up-to-date
/// true -> Northstar install is outdated
-async fn check_is_northstar_outdated(game_path: String) -> Result<bool, String> {
- let northstar_package_name = "Northstar".to_lowercase();
+async fn check_is_northstar_outdated(
+ game_path: String,
+ northstar_package_name: Option<String>,
+) -> Result<bool, String> {
+ let northstar_package_name = match northstar_package_name {
+ Some(northstar_package_name) => {
+ if northstar_package_name.len() <= 1 {
+ "Northstar".to_string()
+ } else {
+ northstar_package_name
+ }
+ }
+ None => "Northstar".to_string(),
+ };
let index = thermite::api::get_package_index().await.unwrap().to_vec();
let nmod = index
@@ -145,6 +158,9 @@ async fn check_is_northstar_outdated(game_path: String) -> Result<bool, String>
}
};
+ // Release candidate version numbers are different between `mods.json` and Thunderstore
+ let version_number = convert_release_candidate_number(version_number);
+
if version_number != nmod.version {
println!("Installed Northstar version outdated");
Ok(true)
@@ -174,9 +190,12 @@ fn get_host_os_caller() -> String {
#[tauri::command]
/// Installs Northstar to the given path
-async fn install_northstar_caller(game_path: String) -> Result<bool, String> {
+async fn install_northstar_caller(
+ game_path: String,
+ northstar_package_name: Option<String>,
+) -> Result<bool, String> {
println!("Running");
- match install_northstar(&game_path).await {
+ match install_northstar(&game_path, northstar_package_name).await {
Ok(_) => Ok(true),
Err(err) => {
println!("{}", err);
@@ -187,11 +206,14 @@ async fn install_northstar_caller(game_path: String) -> Result<bool, String> {
#[tauri::command]
/// Update Northstar install in the given path
-async fn update_northstar_caller(game_path: String) -> Result<bool, String> {
+async fn update_northstar_caller(
+ game_path: String,
+ northstar_package_name: Option<String>,
+) -> Result<bool, String> {
println!("Updating");
// Simply re-run install with up-to-date version for upate
- match install_northstar(&game_path).await {
+ match install_northstar(&game_path, northstar_package_name).await {
Ok(_) => Ok(true),
Err(err) => {
println!("{}", err);
diff --git a/src-ui/src/main.ts b/src-ui/src/main.ts
index 8d08560c..ba45b20c 100644
--- a/src-ui/src/main.ts
+++ b/src-ui/src/main.ts
@@ -21,6 +21,7 @@ interface GameInstall {
var globalState = {
gamepath: "",
installed_northstar_version: "",
+ northstar_package_name: "Northstar",
current_view: "" // Note sure if this is the right way to do it
}
@@ -34,7 +35,7 @@ async function get_northstar_version_number_and_set_button_accordingly(omniButto
northstarVersionHolderEl.textContent = `Installed Northstar version: v${globalState.installed_northstar_version}`;
omniButtonEl.textContent = button_play_string;
- await invoke("check_is_northstar_outdated", { gamePath: globalState.gamepath })
+ await invoke("check_is_northstar_outdated", { gamePath: globalState.gamepath, northstarPackageName: globalState.northstar_package_name })
.then((message) => {
console.log(message);
if (message) {
@@ -97,6 +98,18 @@ document.addEventListener("DOMContentLoaded", async function () {
let omniButtonEl = document.getElementById("omni-button") as HTMLElement;
let originRunningHolderEl = $("origin-running-holder") as HTMLElement;
let northstarVersionHolderEl = $("northstar-version-holder") as HTMLElement;
+ let useReleaseCandidateCheckboxEl = document.getElementById("use-release-candidate-checkbox") as HTMLInputElement;
+
+ useReleaseCandidateCheckboxEl.addEventListener('change', function () {
+ // Switch between main release and release candidates
+ if (this.checked) {
+ globalState.northstar_package_name = "NorthstarReleaseCandidate"
+ } else {
+ globalState.northstar_package_name = "Northstar";
+ }
+ // Update the button
+ get_northstar_version_number_and_set_button_accordingly(omniButtonEl);
+ });
// listen backend-ping event (from Tauri Rust App)
listen("backend-ping", function (evt: TauriEvent<any>) {
@@ -130,7 +143,7 @@ document.addEventListener("DOMContentLoaded", async function () {
// Install Northstar
case button_install_string:
- let install_northstar_result = invoke("install_northstar_caller", { gamePath: globalState.gamepath });
+ let install_northstar_result = invoke("install_northstar_caller", { gamePath: globalState.gamepath, northstarPackageName: globalState.northstar_package_name });
// Update button while installl process is run
omniButtonEl.textContent = button_in_install_string;
@@ -148,7 +161,7 @@ document.addEventListener("DOMContentLoaded", async function () {
// Update Northstar
case button_update_string:
- let update_northstar_result = invoke("update_northstar_caller", { gamePath: globalState.gamepath });
+ let update_northstar_result = invoke("update_northstar_caller", { gamePath: globalState.gamepath, northstarPackageName: globalState.northstar_package_name });
// Update button while update process is run
omniButtonEl.textContent = button_in_update_string;