diff --git a/src/decomp/type-searcher/type-searcher.ts b/src/decomp/type-searcher/type-searcher.ts index 9b41d83..c2593c4 100644 --- a/src/decomp/type-searcher/type-searcher.ts +++ b/src/decomp/type-searcher/type-searcher.ts @@ -60,7 +60,7 @@ function getWebviewContent() { function search(evt) { let parentName = document.getElementById("parent-name").value; - let typeSize = parseInt(document.getElementById("type-size").value); + let typeSize = document.getElementById("type-size").value; let methodId = parseInt(document.getElementById("method-id").value); let gameName = document.getElementById("game-name").value; @@ -94,12 +94,14 @@ function getWebviewContent() { const nameColumn = document.createElement("div"); nameColumn.className = "column column-25"; const nameField = document.createElement("sl-input"); + nameField.className = "field-name"; nameField.label = "Field Type Name?"; nameColumn.appendChild(nameField); const offsetColumn = document.createElement("div"); offsetColumn.className = "column column-25"; const offsetField = document.createElement("sl-input"); + offsetField.className = "field-offset"; offsetField.label = "Offset?"; offsetField.type = "number"; offsetColumn.appendChild(offsetField); @@ -121,18 +123,25 @@ function getWebviewContent() { window.addEventListener('message', event => { document.getElementById("results").innerHTML = ""; const message = event.data; + document.getElementById("command").innerHTML = JSON.stringify(message.args); if (message.command === "search") { if (message.data instanceof Array && message.data.length <= 0) { const column = document.createElement("div"); - column.className = "column column-20"; + column.className = "column"; const content = document.createTextNode("No Results"); column.appendChild(content); document.getElementById("results").appendChild(column); + } else if (message.data.length === 1) { + const column = document.createElement("div"); + column.className = "column"; + const content = document.createTextNode(message.data[0]); + column.appendChild(content); + document.getElementById("results").appendChild(column); } else { - for (const name of message.data) { + for (const val of message.data) { const column = document.createElement("div"); column.className = "column column-20"; - const content = document.createTextNode(name); + const content = document.createTextNode(val); column.appendChild(content); document.getElementById("results").appendChild(column); } @@ -141,50 +150,63 @@ function getWebviewContent() { });
-

General Filters

-
-
- -
-
-
-
- -
-
-
- -
-
-
-
- - Jak 1 - Jak 2 - Jak 3 - Jak X - +
+

General Filters

+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ + Jak 1 + Jak 2 + Jak 3 + Jak X + +
+
-
-

Field Type Filters

-
-
-
- +
+

Field Type Filters

+
+
+
+ +
+
+ +
+
-
- +
+
+ Add Another Field +
- Add Another Field Search Clear
+
+
+

Results

No Results
@@ -210,7 +232,7 @@ const execFileAsync = util.promisify(execFile); let projectRoot: vscode.Uri | undefined = undefined; let currentPanel: vscode.WebviewPanel | undefined = undefined; -async function searchForTypes(message: any): Promise { +async function searchForTypes(message: any): Promise { if (projectRoot === undefined) { projectRoot = getWorkspaceFolderByName("jak-project"); if (projectRoot === undefined) { @@ -241,7 +263,7 @@ async function searchForTypes(message: any): Promise { args.push(`--parent`); args.push(message.parentName); } - if ("typeSize" in message && message.typeSize !== null) { + if ("typeSize" in message && message.typeSize !== "") { args.push(`--size`); args.push(message.typeSize); } @@ -280,10 +302,17 @@ async function searchForTypes(message: any): Promise { ); // Parse the file const result = readFileSync(searchFile, { encoding: "utf-8" }); - return JSON.parse(result); + return { + results: JSON.parse(result), + args: args, + }; } catch (error: any) { console.log(error); - return [`error - ${error}`]; + return { + error: true, + results: [`error - ${error}`], + args: args, + }; } } @@ -307,7 +336,8 @@ async function openPanel() { const result = await searchForTypes(message); currentPanel?.webview.postMessage({ command: "search", - data: result, + data: result.results, + args: result.args, }); } },