Skip to content

Commit

Permalink
[MPQEditor] Implement handleLoadVisqFile
Browse files Browse the repository at this point in the history
This commit implements processing of 'loadVisqFile' message and 'showVisqCircleModelGraph' function needed for that.

ONE-vscode-DCO-1.0-Signed-off-by: s.malakhov <[email protected]>
  • Loading branch information
stamalakhov committed May 11, 2023
1 parent fae6d95 commit 855dbe1
Showing 1 changed file with 56 additions and 4 deletions.
60 changes: 56 additions & 4 deletions src/MPQEditor/MPQEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
MPQSelectionCmdCloseArgs,
MPQSelectionCmdOpenArgs,
MPQSelectionCmdLayersChangedArgs,
MPQVisqData,
} from "./MPQCircleSelector";

export class MPQEditorProvider
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
});
}

/**
Expand Down Expand Up @@ -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);
}
});
}
}

0 comments on commit 855dbe1

Please sign in to comment.