aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-tauri/bindings/ParsedLogResults.ts3
-rw-r--r--src-tauri/bindings/ParsedModFromLog.ts3
-rw-r--r--src-tauri/src/repair_and_verify/log_handling.rs60
-rw-r--r--src-vue/src/views/DeveloperView.vue22
4 files changed, 79 insertions, 9 deletions
diff --git a/src-tauri/bindings/ParsedLogResults.ts b/src-tauri/bindings/ParsedLogResults.ts
index 5352fc7e..7bc3239e 100644
--- a/src-tauri/bindings/ParsedLogResults.ts
+++ b/src-tauri/bindings/ParsedLogResults.ts
@@ -1,3 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
+import type { ParsedModFromLog } from "./ParsedModFromLog";
-export interface ParsedLogResults { northstar_launcher_version: string, installed_mods: Array<string>, } \ No newline at end of file
+export interface ParsedLogResults { northstar_launcher_version: string, installed_mods: Array<ParsedModFromLog>, } \ No newline at end of file
diff --git a/src-tauri/bindings/ParsedModFromLog.ts b/src-tauri/bindings/ParsedModFromLog.ts
new file mode 100644
index 00000000..f71ed83d
--- /dev/null
+++ b/src-tauri/bindings/ParsedModFromLog.ts
@@ -0,0 +1,3 @@
+// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
+
+export interface ParsedModFromLog { mod_name: string, enabled: boolean, } \ No newline at end of file
diff --git a/src-tauri/src/repair_and_verify/log_handling.rs b/src-tauri/src/repair_and_verify/log_handling.rs
index e272d056..33e634cb 100644
--- a/src-tauri/src/repair_and_verify/log_handling.rs
+++ b/src-tauri/src/repair_and_verify/log_handling.rs
@@ -4,15 +4,24 @@ use ts_rs::TS;
#[derive(Serialize, Deserialize, Debug, Clone, TS)]
#[ts(export)]
+pub struct ParsedModFromLog {
+ mod_name: String,
+ enabled: bool,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone, TS)]
+#[ts(export)]
pub struct ParsedLogResults {
northstar_launcher_version: String,
- installed_mods: Vec<String>,
+ installed_mods: Vec<ParsedModFromLog>,
}
/// Parse logs for installed mods
-fn parse_given_log_text_for_installed_mods(log_text: String) -> Result<Vec<String>, String> {
- // Regex to capture mod loading
- let regex = Regex::new(r"(?m)Loaded mod (.*) successfully\n").unwrap();
+fn parse_given_log_text_for_installed_mods(
+ log_text: String,
+) -> Result<Vec<ParsedModFromLog>, String> {
+ // Regex to capture mod loading and whether enabled/disabled
+ let regex = Regex::new(r"(?m)Loaded mod (.*) successfully\n.*\[NORTHSTAR\] \[info\] Mod (.*) is (enabled|disabled)\n").unwrap();
// Run regex, result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(&log_text);
@@ -20,12 +29,47 @@ fn parse_given_log_text_for_installed_mods(log_text: String) -> Result<Vec<Strin
let mut mods = Vec::new();
for mat in result {
// Get the captured string, which is the first and only capturing group in the regex
- match mat.get(1) {
- Some(mod_name) => {
- mods.push(mod_name.as_str().to_string());
+ let mod_name = match mat.get(1) {
+ Some(mod_name) => mod_name.as_str().to_string(),
+ None => {
+ println!("Failed parsing {:?}", mat); // log on failure
+ continue;
+ }
+ };
+ let mod_name_copy = match mat.get(2) {
+ Some(mod_name) => mod_name.as_str().to_string(),
+ None => {
+ println!("Failed parsing {:?}", mat); // log on failure
+ continue;
}
- None => println!("Failed parsing {:?}", mat), // log on failure
};
+ let enabled_disabled = match mat.get(3) {
+ Some(mod_name) => mod_name.as_str().to_string(),
+ None => {
+ println!("Failed parsing {:?}", mat); // log on failure
+ continue;
+ }
+ };
+ println!("{}, {}, {}", mod_name, mod_name_copy, enabled_disabled);
+ if mod_name != mod_name_copy {
+ return Err("Mod names don't match up".to_string());
+ }
+
+ // TODO improve checking
+ let mod_enabled;
+ if enabled_disabled == "enabled" {
+ mod_enabled = true;
+ } else {
+ mod_enabled = false;
+ }
+
+ let parsed_mod_from_log = ParsedModFromLog {
+ mod_name,
+ enabled: mod_enabled,
+ };
+
+ // Add mod to list
+ mods.push(parsed_mod_from_log);
}
// Return the captured mod names
diff --git a/src-vue/src/views/DeveloperView.vue b/src-vue/src/views/DeveloperView.vue
index d8423450..dea0e1e3 100644
--- a/src-vue/src/views/DeveloperView.vue
+++ b/src-vue/src/views/DeveloperView.vue
@@ -64,6 +64,25 @@
placeholder="Paste log content here"
/>
+ <div>
+ <el-table :data="logResults">
+ <el-table-column prop="northstar_launcher_version"
+ label="Northstar Launcher Version"></el-table-column>
+ <el-table-column prop="installed_mods" label="Installed and enabled/disabled Mods">
+ <template v-slot="{ row }">
+ <ul>
+ <li v-for="mod in row.installed_mods">
+ <el-icon class="no-inherit">
+ <Select v-if="mod.enabled" />
+ <Close v-else />
+ </el-icon>
+ {{ mod.mod_name }}
+ </li>
+ </ul>
+ </template>
+ </el-table-column>
+ </el-table>
+ </div>
</el-scrollbar>
</div>
</template>
@@ -75,6 +94,7 @@ import { ElNotification } from "element-plus";
import { GameInstall } from "../utils/GameInstall";
import { Store } from 'tauri-plugin-store-api';
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({
@@ -83,6 +103,7 @@ export default defineComponent({
return {
mod_to_install_field_string : "",
log_content : "",
+ logResults: [] as ParsedLogResults[]
}
},
methods: {
@@ -228,6 +249,7 @@ export default defineComponent({
await invoke<[ParsedLogResults]>("parse_given_log_text", { logText: current_log_content })
.then((message) => {
console.log(message); // TODO present better here
+ this.logResults.push(message);
// Show user notification if task completed.
ElNotification({
title: `Done`,