aboutsummaryrefslogtreecommitdiff
path: root/src-vue/src
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2023-03-02 23:58:08 +0100
committerGeckoEidechse <gecko.eidechse+git@pm.me>2023-03-02 23:58:08 +0100
commitc800dd31355064be8d3de8a74326b1c2b974c78e (patch)
treec22d9c1a83fafe009f16483bc88a96bbdd49dba0 /src-vue/src
parentc60b7b606dd0b4bc7108f9a768a4545f0781730c (diff)
parent441b81ef0f46062713f618a57e0d297c8a7a70d3 (diff)
downloadFlightCore-c800dd31355064be8d3de8a74326b1c2b974c78e.tar.gz
FlightCore-c800dd31355064be8d3de8a74326b1c2b974c78e.zip
Merge branch 'main' into feat/basic-log-parsingfeat/basic-log-parsing
Diffstat (limited to 'src-vue/src')
-rw-r--r--src-vue/src/components/PullRequestsSelector.vue103
-rw-r--r--src-vue/src/components/ThunderstoreModCard.vue4
-rw-r--r--src-vue/src/plugins/modules/pull_requests.ts112
-rw-r--r--src-vue/src/plugins/store.ts27
-rw-r--r--src-vue/src/utils/thunderstore/ThunderstoreMod.d.ts12
-rw-r--r--src-vue/src/utils/thunderstore/ThunderstoreModVersion.d.ts9
-rw-r--r--src-vue/src/views/DeveloperView.vue54
-rw-r--r--src-vue/src/views/PlayView.vue17
-rw-r--r--src-vue/src/views/mods/ThunderstoreModsView.vue4
9 files changed, 308 insertions, 34 deletions
diff --git a/src-vue/src/components/PullRequestsSelector.vue b/src-vue/src/components/PullRequestsSelector.vue
new file mode 100644
index 00000000..58a355f4
--- /dev/null
+++ b/src-vue/src/components/PullRequestsSelector.vue
@@ -0,0 +1,103 @@
+<template>
+ <div>
+ <el-collapse @change="onChange">
+ <el-collapse-item title="Launcher PRs" name="1">
+ <p v-if="pull_requests_launcher.length === 0">
+ <el-progress
+ :show-text="false"
+ :percentage="100"
+ status="warning"
+ :indeterminate="true"
+ :duration="1"
+ style="margin: 15px"
+ />
+ </p>
+ <el-card v-else shadow="hover" v-for="pull_request in pull_requests_launcher"
+ v-bind:key="pull_request.url">
+ <el-button type="primary" @click="installLauncherPR(pull_request)">Install</el-button>
+ <a target="_blank" :href="pull_request.html_url">
+ {{ pull_request.number }}: {{ pull_request.title }}
+ </a>
+ </el-card>
+ </el-collapse-item>
+
+ <el-collapse-item title="Mods PRs" name="2">
+ <div style="margin: 15px">
+ <el-alert title="Warning" type="warning" :closable="false" show-icon>
+ Mod PRs are installed into a separate profile. Make sure to launch via
+ 'r2ns-launch-mod-pr-version.bat' or via '-profile=R2Northstar-PR-test-managed-folder' to actually
+ run the PR version!
+ </el-alert>
+ </div>
+ <p v-if="pull_requests_mods.length === 0">
+ <el-progress
+ :show-text="false"
+ :percentage="100"
+ status="warning"
+ :indeterminate="true"
+ :duration="1"
+ style="margin: 15px"
+ />
+ </p>
+ <el-card v-else shadow="hover" v-for="pull_request in pull_requests_mods" v-bind:key="pull_request.url">
+ <el-button type="primary" @click="installModsPR(pull_request)">Install</el-button>
+ <a target="_blank" :href="pull_request.html_url">
+ {{ pull_request.number }}: {{ pull_request.title }}
+ </a>
+ </el-card>
+ </el-collapse-item>
+ </el-collapse>
+ </div>
+</template>
+
+<script lang="ts">
+import { defineComponent } from 'vue'
+import { PullRequestType } from '../../../src-tauri/bindings/PullRequestType';
+import { PullsApiResponseElement } from '../../../src-tauri/bindings/PullsApiResponseElement';
+import { invoke } from "@tauri-apps/api";
+import { ElNotification } from "element-plus";
+
+export default defineComponent({
+ name: 'PullRequestsSelector',
+ computed: {
+ pull_requests_launcher(): PullsApiResponseElement[] {
+ return this.$store.state.pullrequests.pull_requests_launcher;
+ },
+ pull_requests_mods(): PullsApiResponseElement[] {
+ return this.$store.state.pullrequests.pull_requests_mods;
+ },
+ },
+ methods: {
+ onChange(e: Object) {
+ const openedCollapseNames = Object.values(e);
+ if (openedCollapseNames.includes('1') && this.pull_requests_launcher.length === 0) {
+ this.getPullRequests('LAUNCHER');
+ }
+ if (openedCollapseNames.includes('2') && this.pull_requests_mods.length === 0) {
+ this.getPullRequests('MODS');
+ }
+ },
+ async getPullRequests(pull_request_type: PullRequestType) {
+ this.$store.commit('getPullRequests', pull_request_type);
+ },
+ async installLauncherPR(pull_request: PullsApiResponseElement) {
+ this.$store.commit('installLauncherPR', pull_request);
+ },
+ async installModsPR(pull_request: PullsApiResponseElement) {
+ this.$store.commit('installModsPR', pull_request);
+ },
+ }
+})
+</script>
+
+<style scoped>
+.el-collapse {
+ border-radius: var(--el-border-radius-base);
+ overflow: hidden;
+}
+
+:deep(.el-collapse-item__header) {
+ padding-left: 10px;
+ font-size: 14px;
+}
+</style>
diff --git a/src-vue/src/components/ThunderstoreModCard.vue b/src-vue/src/components/ThunderstoreModCard.vue
index d125e9f5..c9f6768c 100644
--- a/src-vue/src/components/ThunderstoreModCard.vue
+++ b/src-vue/src/components/ThunderstoreModCard.vue
@@ -66,8 +66,8 @@
<script lang="ts">
import {defineComponent} from "vue";
-import {ThunderstoreMod} from "../utils/thunderstore/ThunderstoreMod";
-import {ThunderstoreModVersion} from "../utils/thunderstore/ThunderstoreModVersion";
+import {ThunderstoreMod} from "../../../src-tauri/bindings/ThunderstoreMod";
+import {ThunderstoreModVersion} from "../../../src-tauri/bindings/ThunderstoreModVersion";
import {invoke, shell} from "@tauri-apps/api";
import {ThunderstoreModStatus} from "../utils/thunderstore/ThunderstoreModStatus";
import {NorthstarMod} from "../../../src-tauri/bindings/NorthstarMod";
diff --git a/src-vue/src/plugins/modules/pull_requests.ts b/src-vue/src/plugins/modules/pull_requests.ts
new file mode 100644
index 00000000..e64703d3
--- /dev/null
+++ b/src-vue/src/plugins/modules/pull_requests.ts
@@ -0,0 +1,112 @@
+import { ElNotification } from "element-plus";
+import { invoke } from "@tauri-apps/api";
+import { PullsApiResponseElement } from "../../../../src-tauri/bindings/PullsApiResponseElement";
+import { PullRequestType } from '../../../../src-tauri/bindings/PullRequestType';
+import { store } from "../store";
+
+interface PullRequestStoreState {
+ searchValue: string,
+ pull_requests_launcher: PullsApiResponseElement[],
+ pull_requests_mods: PullsApiResponseElement[],
+}
+
+export const pullRequestModule = {
+ state: () => ({
+ pull_requests_launcher: [],
+ pull_requests_mods: [],
+ }),
+ mutations: {
+ async getPullRequests(state: PullRequestStoreState, pull_request_type: PullRequestType) {
+ await invoke<PullsApiResponseElement[]>("get_pull_requests_wrapper", { installType: pull_request_type })
+ .then((message) => {
+ switch (pull_request_type) {
+ case "MODS":
+ state.pull_requests_mods = message;
+ break;
+
+ case "LAUNCHER":
+ state.pull_requests_launcher = message;
+ break;
+
+ default:
+ console.error("We should never end up here");
+ }
+ })
+ .catch((error) => {
+ ElNotification({
+ title: 'Error',
+ message: error,
+ type: 'error',
+ position: 'bottom-right'
+ });
+ });
+ },
+ async installLauncherPR(state: PullRequestStoreState, pull_request: PullsApiResponseElement) {
+ // Send notification telling the user to wait for the process to finish
+ const notification = ElNotification({
+ title: `Installing launcher PR ${pull_request.number}`,
+ message: 'Please wait',
+ duration: 0,
+ type: 'info',
+ position: 'bottom-right'
+ });
+
+ await invoke("apply_launcher_pr", { pullRequest: pull_request, gameInstallPath: store.state.game_path })
+ .then((message) => {
+ console.log(message);
+ // Show user notification if mod install completed.
+ ElNotification({
+ title: `Done`,
+ message: `Installed ${pull_request.number}: "${pull_request.title}"`,
+ type: 'success',
+ position: 'bottom-right'
+ });
+ })
+ .catch((error) => {
+ ElNotification({
+ title: 'Error',
+ message: error,
+ type: 'error',
+ position: 'bottom-right'
+ });
+ })
+ .finally(() => {
+ // Clear old notification
+ notification.close();
+ });
+ },
+ async installModsPR(state: PullRequestStoreState, pull_request: PullsApiResponseElement) {
+ // Send notification telling the user to wait for the process to finish
+ const notification = ElNotification({
+ title: `Installing mods PR ${pull_request.number}`,
+ message: 'Please wait',
+ duration: 0,
+ type: 'info',
+ position: 'bottom-right'
+ });
+
+ await invoke("apply_mods_pr", { pullRequest: pull_request, gameInstallPath: store.state.game_path })
+ .then((message) => {
+ // Show user notification if mod install completed.
+ ElNotification({
+ title: `Done`,
+ message: `Installed ${pull_request.number}: "${pull_request.title}"\nMake sure to launch via batch file or by specifying correct profile!`,
+ type: 'success',
+ position: 'bottom-right'
+ });
+ })
+ .catch((error) => {
+ ElNotification({
+ title: 'Error',
+ message: error,
+ type: 'error',
+ position: 'bottom-right'
+ });
+ })
+ .finally(() => {
+ // Clear old notification
+ notification.close();
+ });
+ },
+ }
+}
diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts
index d4371fb8..8671d12b 100644
--- a/src-vue/src/plugins/store.ts
+++ b/src-vue/src/plugins/store.ts
@@ -13,9 +13,11 @@ import { open } from '@tauri-apps/api/dialog';
import { Store } from 'tauri-plugin-store-api';
import { router } from "../main";
import { ReleaseInfo } from "../../../src-tauri/bindings/ReleaseInfo";
-import { ThunderstoreMod } from '../utils/thunderstore/ThunderstoreMod';
+import { ThunderstoreMod } from "../../../src-tauri/bindings/ThunderstoreMod";
import { NorthstarMod } from "../../../src-tauri/bindings/NorthstarMod";
import { searchModule } from './modules/search';
+import { pullRequestModule } from './modules/pull_requests';
+import { PullsApiResponseElement } from "../../../src-tauri/bindings/PullsApiResponseElement";
const persistentStore = new Store('flight-core-settings.json');
@@ -51,7 +53,8 @@ let notification_handle: NotificationHandle;
export const store = createStore<FlightCoreStore>({
modules: {
- search: searchModule
+ search: searchModule,
+ pullrequests: pullRequestModule,
},
state(): FlightCoreStore {
return {
@@ -242,14 +245,22 @@ export const store = createStore<FlightCoreStore>({
await store.commit('loadInstalledMods');
if (state.thunderstoreMods.length !== 0) return;
- const response = await fetch('https://northstar.thunderstore.io/api/v1/package/');
- let mods = JSON.parse(await (await response.blob()).text());
+ let mods: ThunderstoreMod[] = [];
+ await invoke<ThunderstoreMod[]>("query_thunderstore_packages_api")
+ .then((message) => {
+ mods = message;
+ })
+ .catch((error) => {
+ console.error(error);
+ return;
+ });
+
+ if (mods == undefined) {
+ return;
+ }
// Remove some mods from listing
- const removedMods = ['Northstar', 'NorthstarReleaseCandidate', 'r2modman'];
- state.thunderstoreMods = mods.filter((mod: ThunderstoreMod) => {
- return !removedMods.includes(mod.name) && !mod.is_deprecated;
- });
+ state.thunderstoreMods = mods;
// Retrieve categories from mods
state.thunderstoreModsCategories = mods
diff --git a/src-vue/src/utils/thunderstore/ThunderstoreMod.d.ts b/src-vue/src/utils/thunderstore/ThunderstoreMod.d.ts
deleted file mode 100644
index 6387c47e..00000000
--- a/src-vue/src/utils/thunderstore/ThunderstoreMod.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { ThunderstoreModVersion } from "./ThunderstoreModVersion";
-
-export interface ThunderstoreMod {
- name: string;
- owner: string;
- date_updated: string;
- rating_score: number;
- package_url: string;
- is_deprecated: boolean;
- versions: ThunderstoreModVersion[];
- categories: string[];
-}
diff --git a/src-vue/src/utils/thunderstore/ThunderstoreModVersion.d.ts b/src-vue/src/utils/thunderstore/ThunderstoreModVersion.d.ts
deleted file mode 100644
index f53f0362..00000000
--- a/src-vue/src/utils/thunderstore/ThunderstoreModVersion.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export interface ThunderstoreModVersion {
- full_name: string;
- description: string;
- icon: string;
- version_number: string;
- download_url: string;
- downloads: number;
- date_created: string;
-}
diff --git a/src-vue/src/views/DeveloperView.vue b/src-vue/src/views/DeveloperView.vue
index 23410c23..c73aef6a 100644
--- a/src-vue/src/views/DeveloperView.vue
+++ b/src-vue/src/views/DeveloperView.vue
@@ -40,6 +40,10 @@
Disable all but core mods
</el-button>
+ <el-button type="primary" @click="forceInstallNorthstar">
+ Force reinstall Northstar
+ </el-button>
+
<el-button type="primary" @click="getInstalledMods">
Get installed mods
</el-button>
@@ -51,7 +55,6 @@
<el-button type="primary" @click="clearFlightCorePersistentStore">
Delete FlightCore persistent store
</el-button>
-
<h3>Tech support</h3>
<el-button type="primary" @click="parseGivenLogTextForMods">
@@ -88,6 +91,9 @@
</el-table-column>
</el-table>
</div>
+
+ <h3>Testing</h3>
+ <pull-requests-selector />
</el-scrollbar>
</div>
</template>
@@ -98,12 +104,17 @@ import { invoke } from "@tauri-apps/api";
import { ElNotification } from "element-plus";
import { GameInstall } from "../utils/GameInstall";
import { Store } from 'tauri-plugin-store-api';
+import { ReleaseCanal } from "../utils/ReleaseCanal";
+import PullRequestsSelector from "../components/PullRequestsSelector.vue";
import { ParsedLogResults } from "../../../src-tauri/bindings/ParsedLogResults";
import { ParsedModFromLog } from "../../../src-tauri/bindings/ParsedModFromLog";
const persistentStore = new Store('flight-core-settings.json');
export default defineComponent({
name: "DeveloperView",
+ components: {
+ PullRequestsSelector
+ },
data() {
return {
mod_to_install_field_string : "",
@@ -249,6 +260,47 @@ export default defineComponent({
// ...and save
await persistentStore.save();
},
+ async forceInstallNorthstar() {
+ let game_install = {
+ game_path: this.$store.state.game_path,
+ install_type: this.$store.state.install_type
+ } as GameInstall;
+
+ // Send notification telling the user to wait for the process to finish
+ const notification = ElNotification({
+ title: 'Force reinstalling Northstar',
+ message: 'Please wait',
+ duration: 0,
+ type: 'info',
+ position: 'bottom-right'
+ });
+
+ let install_northstar_result = invoke("install_northstar_caller", { gamePath: game_install.game_path, northstarPackageName: ReleaseCanal.RELEASE });
+ await install_northstar_result
+ .then((message) => {
+ // Send notification
+ ElNotification({
+ title: `Done`,
+ message: `Successfully reinstalled Northstar`,
+ type: 'success',
+ position: 'bottom-right'
+ });
+ this.$store.commit('checkNorthstarUpdates');
+ })
+ .catch((error) => {
+ ElNotification({
+ title: 'Error',
+ message: error,
+ type: 'error',
+ position: 'bottom-right'
+ });
+ console.error(error);
+ })
+ .finally(() => {
+ // Clear old notification
+ notification.close();
+ });
+ },
async parseGivenLogTextForMods() {
let current_log_content = this.log_content;
await invoke<[ParsedLogResults]>("parse_given_log_text", { logText: current_log_content })
diff --git a/src-vue/src/views/PlayView.vue b/src-vue/src/views/PlayView.vue
index 670d8395..beca6724 100644
--- a/src-vue/src/views/PlayView.vue
+++ b/src-vue/src/views/PlayView.vue
@@ -15,6 +15,12 @@ export default defineComponent({
northstarVersion(): string {
return this.$store.state.installed_northstar_version;
},
+ playerCount(): number {
+ return this.$store.state.player_count;
+ },
+ serverCount(): number {
+ return this.$store.state.server_count;
+ },
},
methods: {
showChangelogPage() {
@@ -32,6 +38,13 @@ export default defineComponent({
<div v-if="northstarVersion !== ''" class="fc_changelog__link" @click="showChangelogPage">
(see patch notes)
</div>
+ <div v-if="playerCount >= 0" class="fc-stats__container">
+ {{ playerCount }} players,
+ {{ serverCount }} servers
+ </div>
+ <div v-else="playerCount >= 0" class="fc-stats__container">
+ Unable to load playercount
+ </div>
</div>
<div>
<PlayButton />
@@ -69,6 +82,10 @@ export default defineComponent({
color: rgb(168, 168, 168);
}
+.fc-stats__container {
+ margin-top: 3px;
+}
+
.fc_northstar__version, .fc_changelog__link {
display: inline-block;
}
diff --git a/src-vue/src/views/mods/ThunderstoreModsView.vue b/src-vue/src/views/mods/ThunderstoreModsView.vue
index aaf15220..19809f3e 100644
--- a/src-vue/src/views/mods/ThunderstoreModsView.vue
+++ b/src-vue/src/views/mods/ThunderstoreModsView.vue
@@ -46,11 +46,11 @@
<script lang="ts">
import { defineComponent, ref } from 'vue';
-import { ThunderstoreMod } from "../../utils/thunderstore/ThunderstoreMod";
+import { ThunderstoreMod } from "../../../../src-tauri/bindings/ThunderstoreMod";
import ThunderstoreModCard from "../../components/ThunderstoreModCard.vue";
import { ElScrollbar, ScrollbarInstance } from "element-plus";
import { SortOptions } from "../../utils/SortOptions.d";
-import { ThunderstoreModVersion } from '../../utils/thunderstore/ThunderstoreModVersion';
+import { ThunderstoreModVersion } from "../../../../src-tauri/bindings/ThunderstoreModVersion";
export default defineComponent({
name: "ThunderstoreModsView",