aboutsummaryrefslogtreecommitdiff
path: root/src-vue/src
diff options
context:
space:
mode:
Diffstat (limited to 'src-vue/src')
-rw-r--r--src-vue/src/utils/GameInstall.ts5
-rw-r--r--src-vue/src/utils/NorthstarState.ts8
-rw-r--r--src-vue/src/utils/ReleaseCanal.ts4
-rw-r--r--src-vue/src/utils/SortOptions.d.ts8
-rw-r--r--src-vue/src/utils/Tabs.ts8
-rw-r--r--src-vue/src/utils/filter.ts26
-rw-r--r--src-vue/src/utils/thunderstore/ThunderstoreModStatus.ts7
-rw-r--r--src-vue/src/utils/thunderstore/version.ts33
8 files changed, 99 insertions, 0 deletions
diff --git a/src-vue/src/utils/GameInstall.ts b/src-vue/src/utils/GameInstall.ts
new file mode 100644
index 00000000..162d2860
--- /dev/null
+++ b/src-vue/src/utils/GameInstall.ts
@@ -0,0 +1,5 @@
+export interface GameInstall {
+ game_path: string;
+ profile: string,
+ install_type: string;
+}
diff --git a/src-vue/src/utils/NorthstarState.ts b/src-vue/src/utils/NorthstarState.ts
new file mode 100644
index 00000000..2c8756b1
--- /dev/null
+++ b/src-vue/src/utils/NorthstarState.ts
@@ -0,0 +1,8 @@
+export enum NorthstarState {
+ GAME_NOT_FOUND = "GAME_NOT_FOUND",
+ INSTALL = "INSTALL",
+ INSTALLING = "INSTALLING",
+ MUST_UPDATE = "MUST_UPDATE",
+ UPDATING = "UPDATING",
+ READY_TO_PLAY = "READY_TO_PLAY"
+} \ No newline at end of file
diff --git a/src-vue/src/utils/ReleaseCanal.ts b/src-vue/src/utils/ReleaseCanal.ts
new file mode 100644
index 00000000..9363aa25
--- /dev/null
+++ b/src-vue/src/utils/ReleaseCanal.ts
@@ -0,0 +1,4 @@
+export enum ReleaseCanal {
+ RELEASE = <any>'Northstar',
+ RELEASE_CANDIDATE = <any>'NorthstarReleaseCandidate'
+}
diff --git a/src-vue/src/utils/SortOptions.d.ts b/src-vue/src/utils/SortOptions.d.ts
new file mode 100644
index 00000000..b6f180d2
--- /dev/null
+++ b/src-vue/src/utils/SortOptions.d.ts
@@ -0,0 +1,8 @@
+export enum SortOptions {
+ NAME_ASC = 'name_asc',
+ NAME_DESC = 'name_desc',
+ DATE_ASC = 'date_asc',
+ DATE_DESC = 'date_desc',
+ MOST_DOWNLOADED = 'most_downloaded',
+ TOP_RATED = 'top_rated'
+}
diff --git a/src-vue/src/utils/Tabs.ts b/src-vue/src/utils/Tabs.ts
new file mode 100644
index 00000000..5d31379c
--- /dev/null
+++ b/src-vue/src/utils/Tabs.ts
@@ -0,0 +1,8 @@
+export enum Tabs {
+ PLAY = '/',
+ CHANGELOG = '/changelog',
+ SETTINGS = '/settings',
+ DEV = '/dev',
+ MODS = '/mods',
+ REPAIR = '/repair',
+}
diff --git a/src-vue/src/utils/filter.ts b/src-vue/src/utils/filter.ts
new file mode 100644
index 00000000..b85b9623
--- /dev/null
+++ b/src-vue/src/utils/filter.ts
@@ -0,0 +1,26 @@
+/**
+ * Implements a fuzzy filter
+ * Iterates through chars of `search_term` and checks if each char exists in consecutive order in `text`.
+ * For example, this means that `text="Gecko"` and `search_term="geo"` will return `true`
+ * but using `text="Gecko"` and `search_term="goe"` will return `false`
+ *
+ * Implements a subset of "fuzzy string searching"
+ * https://en.wikipedia.org/wiki/Approximate_string_matching
+ */
+function fuzzy_filter(text: string, search_term: string): boolean {
+ const lowercase_text = text.toLowerCase();
+ const lowercase_search_term = search_term.toLowerCase();
+
+ let previousIndex = -1;
+ for (let i = 0; i < lowercase_search_term.length; i++) {
+ const char = lowercase_search_term[i];
+ const currentIndex = lowercase_text.indexOf(char, previousIndex + 1);
+ if (currentIndex === -1) {
+ return false;
+ }
+ previousIndex = currentIndex;
+ }
+
+ return true;
+}
+export { fuzzy_filter };
diff --git a/src-vue/src/utils/thunderstore/ThunderstoreModStatus.ts b/src-vue/src/utils/thunderstore/ThunderstoreModStatus.ts
new file mode 100644
index 00000000..f2351226
--- /dev/null
+++ b/src-vue/src/utils/thunderstore/ThunderstoreModStatus.ts
@@ -0,0 +1,7 @@
+export enum ThunderstoreModStatus {
+ INSTALLED,
+ BEING_INSTALLED,
+ BEING_UPDATED,
+ NOT_INSTALLED,
+ OUTDATED
+}
diff --git a/src-vue/src/utils/thunderstore/version.ts b/src-vue/src/utils/thunderstore/version.ts
new file mode 100644
index 00000000..a111e08c
--- /dev/null
+++ b/src-vue/src/utils/thunderstore/version.ts
@@ -0,0 +1,33 @@
+import {ThunderstoreMod} from "../../../../src-tauri/bindings/ThunderstoreMod";
+import {NorthstarMod} from "../../../../src-tauri/bindings/NorthstarMod";
+import {store} from "../../plugins/store";
+
+/**
+ * Strips off a Thunderstore dependency string from its version
+ * (e.g. "taskinoz-WallrunningTitans-1.0.0" to
+ * "taskinoz-WallrunningTitans").
+ **/
+function getThunderstoreDependencyStringPrefix(dependency: string): string {
+ const dependencyStringMembers = dependency.split('-');
+ return `${dependencyStringMembers[0]}-${dependencyStringMembers[1]}`;
+}
+
+function isThunderstoreModOutdated(mod: ThunderstoreMod): boolean {
+ // Ensure mod is up-to-date.
+ const tsModPrefix = getThunderstoreDependencyStringPrefix(mod.versions[0].full_name);
+ const matchingMods: NorthstarMod[] = store.state.installed_mods.filter((mod: NorthstarMod) => {
+ if (!mod.thunderstore_mod_string) return false;
+ return getThunderstoreDependencyStringPrefix(mod.thunderstore_mod_string!) === tsModPrefix;
+ });
+ if (matchingMods.length !== 0) {
+ // There shouldn't be several mods with same dependency string, but we never know...
+ const matchingMod = matchingMods[0];
+ // A mod is outdated if its dependency strings differs from Thunderstore dependency string
+ // (no need for semver check here).
+ // This assumes mod versions list is sorted from newest to oldest version.
+ return matchingMod.thunderstore_mod_string !== mod.versions[0].full_name;
+ }
+ return false;
+}
+
+export { isThunderstoreModOutdated };