diff options
-rw-r--r-- | .github/workflows/push-test.yml | 6 | ||||
-rw-r--r-- | .github/workflows/release.yml | 8 | ||||
-rw-r--r-- | src-tauri/src/lib.rs | 26 | ||||
-rw-r--r-- | src-tauri/src/main.rs | 11 | ||||
-rw-r--r-- | src-vue/src/components/PlayButton.vue | 2 | ||||
-rw-r--r-- | src-vue/src/plugins/store.ts | 54 | ||||
-rw-r--r-- | src-vue/src/views/DeveloperView.vue | 32 | ||||
-rw-r--r-- | src-vue/src/views/SettingsView.vue | 36 |
8 files changed, 102 insertions, 73 deletions
diff --git a/.github/workflows/push-test.yml b/.github/workflows/push-test.yml index a2007885..c2189421 100644 --- a/.github/workflows/push-test.yml +++ b/.github/workflows/push-test.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: # Ensure version numbers in various places match up ensure-same-version: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 - name: install dependencies @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-20.04, windows-latest] + platform: [ubuntu-22.04, windows-latest] runs-on: ${{ matrix.platform }} steps: @@ -34,7 +34,7 @@ jobs: with: toolchain: stable - name: install dependencies (ubuntu only) - if: matrix.platform == 'ubuntu-20.04' + if: matrix.platform == 'ubuntu-22.04' run: | sudo apt-get update sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 48ac5348..f62b4f34 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: jobs: # Ensure version numbers in various places match up ensure-same-version: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 - name: install dependencies @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-20.04, windows-latest] + platform: [ubuntu-22.04, windows-latest] runs-on: ${{ matrix.platform }} steps: @@ -35,7 +35,7 @@ jobs: with: toolchain: stable - name: install dependencies (ubuntu only) - if: matrix.platform == 'ubuntu-20.04' + if: matrix.platform == 'ubuntu-22.04' run: | sudo apt-get update sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf @@ -65,7 +65,7 @@ jobs: create-release-file: needs: build - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 - uses: actions/download-artifact@v3 diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 38acf069..b249d519 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -46,17 +46,25 @@ pub fn check_mod_version_number(path_to_mod_folder: String) -> Result<String, an // for now tho it only checks `ldd --version` // - salmon -pub fn linux_checks_librs() -> bool { - let mut linux_compatible: bool = true; // a variable that starts true and will be set to false if any of the checks arent met +pub fn linux_checks_librs() -> Result<(), String> { + // Perform various checks in terms of Linux compatibility + // Return early with error message if a check fails // check `ldd --version` to see if glibc is up to date for northstar proton + let min_required_ldd_version = 2.33; let lddv = linux::check_glibc_v(); - if lddv < 2.33 { linux_compatible = false }; + if lddv < min_required_ldd_version { + return Err(format!( + "GLIBC is not version {} or greater", + min_required_ldd_version + ) + .to_string()); + }; - return linux_compatible; + // All checks passed + Ok(()) } - /// Attempts to find the game install location pub fn find_game_install_location() -> Result<GameInstall, anyhow::Error> { // Attempt parsing Steam library directly @@ -267,7 +275,8 @@ pub fn launch_northstar(game_install: GameInstall) -> Result<String, String> { // Explicetly fail early certain (currently) unsupported install setups if host_os != "windows" || !(matches!(game_install.install_type, InstallType::STEAM) - || matches!(game_install.install_type, InstallType::ORIGIN)) + || matches!(game_install.install_type, InstallType::ORIGIN) + || matches!(game_install.install_type, InstallType::UNKNOWN)) { return Err(format!( "Not yet implemented for \"{}\" with Titanfall2 installed via \"{:?}\"", @@ -294,7 +303,8 @@ pub fn launch_northstar(game_install: GameInstall) -> Result<String, String> { // Only Windows with Steam or Origin are supported at the moment if host_os == "windows" && (matches!(game_install.install_type, InstallType::STEAM) - || matches!(game_install.install_type, InstallType::ORIGIN)) + || matches!(game_install.install_type, InstallType::ORIGIN) + || matches!(game_install.install_type, InstallType::UNKNOWN)) { let _output = std::process::Command::new(format!("{}/NorthstarLauncher.exe", game_install.game_path)) @@ -338,7 +348,7 @@ 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") + version_number.replace("-rc", "0").replace("00", "") } /// Checks if installed FlightCore version is up-to-date diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index a33f836c..411e75c9 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -120,12 +120,13 @@ fn is_debug_mode() -> bool { #[tauri::command] /// Returns true if linux compatible -fn linux_checks() -> bool { - if get_host_os() == "windows" { - false - } else { - linux_checks_librs() +fn linux_checks() -> Result<(), String> { + // Early return if Windows + if get_host_os() == "windows" { + return Err("Not available on Windows".to_string()); } + + linux_checks_librs() } #[tauri::command] diff --git a/src-vue/src/components/PlayButton.vue b/src-vue/src/components/PlayButton.vue index 8e0b4149..ff57e706 100644 --- a/src-vue/src/components/PlayButton.vue +++ b/src-vue/src/components/PlayButton.vue @@ -13,7 +13,7 @@ export default defineComponent({ switch(this.$store.state.northstar_state) { case NorthstarState.GAME_NOT_FOUND: - return "Titanfall2 not found"; + return "Select Titanfall2 game folder"; case NorthstarState.INSTALL: return "Install"; case NorthstarState.INSTALLING: diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts index 4fa7328b..4fdf50a3 100644 --- a/src-vue/src/plugins/store.ts +++ b/src-vue/src/plugins/store.ts @@ -5,8 +5,10 @@ import { InstallType } from "../utils/InstallType"; import { invoke } from "@tauri-apps/api"; import { GameInstall } from "../utils/GameInstall"; import { ReleaseCanal } from "../utils/ReleaseCanal"; -import { ElNotification } from 'element-plus'; +import { ElNotification, NotificationHandle } from 'element-plus'; import { NorthstarState } from '../utils/NorthstarState'; +import { appDir } from '@tauri-apps/api/path'; +import { open } from '@tauri-apps/api/dialog'; import { Store } from 'tauri-plugin-store-api'; import {router} from "../main"; @@ -28,6 +30,8 @@ export interface FlightCoreStore { origin_is_running: boolean } +let notification_handle: NotificationHandle; + export const store = createStore<FlightCoreStore>({ state (): FlightCoreStore { return { @@ -65,6 +69,48 @@ export const store = createStore<FlightCoreStore>({ updateCurrentTab(state: any, newTab: Tabs) { router.push({path: newTab}); }, + async updateGamePath(state: FlightCoreStore) { + // Open a selection dialog for directories + const selected = await open({ + directory: true, + multiple: false, + defaultPath: await appDir(), + }); + if (Array.isArray(selected)) { + // user selected multiple directories + alert("Please only select a single directory"); + } else if (selected === null) { + // user cancelled the selection + } else { + // user selected a single directory + + // Verify if valid Titanfall2 install location + let is_valid_titanfall2_install = await invoke("verify_install_location", { gamePath: selected }) as boolean; + if (is_valid_titanfall2_install) { + state.game_path = selected; + ElNotification({ + title: 'New game folder', + message: "Game folder was successfully updated.", + type: 'success', + position: 'bottom-right' + }); + notification_handle.close(); + state.install_type = InstallType.UNKNOWN; + + // Check for Northstar install + store.commit('checkNorthstarUpdates'); + } + else { + // Not valid Titanfall2 install + ElNotification({ + title: 'Wrong folder', + message: "Selected folder is not a valid Titanfall2 install.", + type: 'error', + position: 'bottom-right' + }); + } + } + }, async launchGame(state: any) { // TODO update installation if release track was switched switch (state.northstar_state) { @@ -130,6 +176,10 @@ export const store = createStore<FlightCoreStore>({ alert(error); }); break; + + case NorthstarState.GAME_NOT_FOUND: + store.commit('updateGamePath'); + break; } } } @@ -162,7 +212,7 @@ async function _initializeApp(state: any) { .catch((err) => { // Gamepath not found or other error console.error(err); - ElNotification({ + notification_handle = ElNotification({ title: 'Titanfall2 not found!', message: "Please manually select install location", type: 'error', diff --git a/src-vue/src/views/DeveloperView.vue b/src-vue/src/views/DeveloperView.vue index 71e09e30..dcc0c477 100644 --- a/src-vue/src/views/DeveloperView.vue +++ b/src-vue/src/views/DeveloperView.vue @@ -50,22 +50,24 @@ export default defineComponent({ }); }, async checkLinuxCompatibility() { - let LinuxCompatible = await invoke("linux_checks"); - if (!LinuxCompatible) { - ElNotification({ - title: 'Not linux compatible', - message: 'GLIBC is not version 2.33 or greater', - type: 'error', - position: 'bottom-right' - }); - } else { - ElNotification({ - title: 'Linux compatible', - message: 'No error reported', - type: 'success', - position: 'bottom-right' + await invoke("linux_checks") + .then(() => { + ElNotification({ + title: 'Linux compatible', + message: 'All checks passed', + type: 'success', + position: 'bottom-right' + }); + }) + .catch((error) => { + ElNotification({ + title: 'Not linux compatible', + message: error, + type: 'error', + position: 'bottom-right' + }); + console.error(error); }); - } }, async toggleReleaseCandidate() { // Flip between RELEASE and RELEASE_CANDIDATE diff --git a/src-vue/src/views/SettingsView.vue b/src-vue/src/views/SettingsView.vue index ec63bd6e..0b0e52e4 100644 --- a/src-vue/src/views/SettingsView.vue +++ b/src-vue/src/views/SettingsView.vue @@ -21,11 +21,7 @@ </template> <script lang="ts"> -import { open } from '@tauri-apps/api/dialog'; -import { appDir } from '@tauri-apps/api/path'; -import { invoke } from "@tauri-apps/api"; import { defineComponent } from "vue"; -import { ElNotification } from 'element-plus'; export default defineComponent({ name: "SettingsView", @@ -36,37 +32,7 @@ export default defineComponent({ }, methods: { async updateGamePath() { - // Open a selection dialog for directories - const selected = await open({ - directory: true, - multiple: false, - defaultPath: await appDir(), - }); - if (Array.isArray(selected)) { - // user selected multiple directories - alert("Please only select a single directory"); - } else if (selected === null) { - // user cancelled the selection - } else { - // user selected a single directory - - // Verify if valid Titanfall2 install location - let is_valid_titanfall2_install = await invoke("verify_install_location", { gamePath: selected }) as boolean; - if (is_valid_titanfall2_install) { - this.$store.state.game_path = selected; - // Check for Northstar install - this.$store.commit('checkNorthstarUpdates'); - } - else { - // Not valid Titanfall2 install - ElNotification({ - title: 'Wrong folder', - message: "Selected folder is not a valid Titanfall2 install.", - type: 'error', - position: 'bottom-right' - }); - } - } + this.$store.commit('updateGamePath'); } }, mounted() { |