From 855dbe1d401a071d46511bb87aefeda652030d93 Mon Sep 17 00:00:00 2001 From: "s.malakhov" Date: Thu, 11 May 2023 09:45:27 +0300 Subject: [PATCH 1/3] [MPQEditor] Implement `handleLoadVisqFile` This commit implements processing of 'loadVisqFile' message and 'showVisqCircleModelGraph' function needed for that. ONE-vscode-DCO-1.0-Signed-off-by: s.malakhov --- src/MPQEditor/MPQEditor.ts | 60 +++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/src/MPQEditor/MPQEditor.ts b/src/MPQEditor/MPQEditor.ts index f35a6f77..4348ff05 100644 --- a/src/MPQEditor/MPQEditor.ts +++ b/src/MPQEditor/MPQEditor.ts @@ -31,6 +31,7 @@ import { MPQSelectionCmdCloseArgs, MPQSelectionCmdOpenArgs, MPQSelectionCmdLayersChangedArgs, + MPQVisqData, } from "./MPQCircleSelector"; export class MPQEditorProvider @@ -334,6 +335,9 @@ export class MPQEditorProvider case "toggleCircleGraphIsShown": this.toggleCircleGraphIsShown(e.show, document, webviewPanel); break; + case "loadVisqFile": + this.handleLoadVisqFile(document, webviewPanel); + break; case "removeVisqFile": this.removeVisqFile(document, webviewPanel); break; @@ -673,11 +677,31 @@ export class MPQEditorProvider * @brief Called when it's needed to show visq data in circle-graph */ private showVisqCircleModelGraph( - _visqPath: string, - _document: vscode.TextDocument, - _webviewPanel: vscode.WebviewPanel + visqPath: string, + document: vscode.TextDocument, + webviewPanel: vscode.WebviewPanel ) { - // TODO + const args: MPQSelectionCmdOpenArgs = { + modelPath: this.getModelFilePath(document), + document: document, + names: this._mpqDataMap[document.uri.toString()].getLayers(), + panel: webviewPanel, + }; + + const visqData: MPQVisqData = { + visqPath: visqPath, + }; + vscode.commands.executeCommand( + MPQSelectionPanel.cmdOpenVisq, + args, + visqData, + this + ); + + webviewPanel.webview.postMessage({ + type: "VisqFileLoaded", + visqFile: visqPath, + }); } /** @@ -716,4 +740,32 @@ export class MPQEditorProvider this.showCircleModelGraph(document, webviewPanel); } } + + /** + * @brief Called when user requests to load visq file from UI + */ + private handleLoadVisqFile( + document: vscode.TextDocument, + webviewPanel: vscode.WebviewPanel + ) { + const dialogOptions = { + canSelectMany: false, + canSelectFolders: false, + openLabel: "Open", + filters: { "target files": ["visq.json"], "all files": ["*"] }, + }; + + vscode.window.showOpenDialog(dialogOptions).then((fileUri) => { + if (fileUri && fileUri[0]) { + const visqPath = fileUri[0].fsPath.toString(); + + let docUri = document.uri.toString(); + this._mpqDataMap[docUri].visqPath = visqPath; + // close previous view if any + this.closeModelGraphView(document); + // open new view + this.showVisqCircleModelGraph(visqPath, document, webviewPanel); + } + }); + } } From c0646eb03ead84d7b498f5e20356c7b54728f2ae Mon Sep 17 00:00:00 2001 From: stamalakhov <112689352+stamalakhov@users.noreply.github.com> Date: Thu, 11 May 2023 12:00:55 +0300 Subject: [PATCH 2/3] [MPQEditor] Apply suggestions from code review Apply suggestions from code review. Co-authored-by: Jiyoung Giuliana Yun --- src/MPQEditor/MPQEditor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MPQEditor/MPQEditor.ts b/src/MPQEditor/MPQEditor.ts index 4348ff05..4b19e1f0 100644 --- a/src/MPQEditor/MPQEditor.ts +++ b/src/MPQEditor/MPQEditor.ts @@ -759,7 +759,7 @@ export class MPQEditorProvider if (fileUri && fileUri[0]) { const visqPath = fileUri[0].fsPath.toString(); - let docUri = document.uri.toString(); + const docUri = document.uri.toString(); this._mpqDataMap[docUri].visqPath = visqPath; // close previous view if any this.closeModelGraphView(document); From 102ae079226bd7591b287fb6b2598931930d2cf8 Mon Sep 17 00:00:00 2001 From: "s.malakhov" Date: Fri, 12 May 2023 08:24:54 +0300 Subject: [PATCH 3/3] [MPQEditor] Apply suggestions from code review Apply suggestions from code review. Co-authored-by: Dayoung Lee ONE-vscode-DCO-1.0-Signed-off-by: s.malakhov --- src/MPQEditor/MPQEditor.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MPQEditor/MPQEditor.ts b/src/MPQEditor/MPQEditor.ts index 4b19e1f0..b9d74b5b 100644 --- a/src/MPQEditor/MPQEditor.ts +++ b/src/MPQEditor/MPQEditor.ts @@ -753,6 +753,7 @@ export class MPQEditorProvider canSelectFolders: false, openLabel: "Open", filters: { "target files": ["visq.json"], "all files": ["*"] }, + title: "Open VISQ File", }; vscode.window.showOpenDialog(dialogOptions).then((fileUri) => {