Skip to content

Commit

Permalink
[MPQEditor] Implement UI messages
Browse files Browse the repository at this point in the history
This commit implements 'removeVisqFile' and 'VisqInputPathChanged' messages.

ONE-vscode-DCO-1.0-Signed-off-by: s.malakhov <[email protected]>
  • Loading branch information
stamalakhov committed May 3, 2023
1 parent 8600429 commit 74ef4b0
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion src/MPQEditor/MPQEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ export class MPQEditorProvider
case "toggleCircleGraphIsShown":
this.toggleCircleGraphIsShown(e.show, document, webviewPanel);
break;
case "removeVisqFile":
this.removeVisqFile(document, webviewPanel);
break;
case "VisqInputPathChanged":
this.handleVisqInputPathChanged(e.path, document, webviewPanel);
break;
default:
break;
}
Expand Down Expand Up @@ -651,9 +657,63 @@ export class MPQEditorProvider
webviewPanel: vscode.WebviewPanel
) {
if (show) {
this.showCircleModelGraph(document, webviewPanel);
const docUri = document.uri.toString();
const visqPath = this._mpqDataMap[docUri].visqPath;
if (visqPath.length < 1) {
this.showCircleModelGraph(document, webviewPanel);
} else {
this.showVisqCircleModelGraph(visqPath, document, webviewPanel);
}
} else {
this.closeModelGraphView(document);
}
}

/**
* @brief Called when it's needed to show visq data in circle-graph
*/
private showVisqCircleModelGraph(
_visqPath: string,
_document: vscode.TextDocument,
_webviewPanel: vscode.WebviewPanel
) {
// TODO
}

/**
* @brief Called when visq path was changed in UI
*/
private handleVisqInputPathChanged(
path: string,
document: vscode.TextDocument,
webviewPanel: vscode.WebviewPanel
): void {
if (
(path === "" || !path.endsWith(".visq.json")) &&
this._mpqDataMap[document.uri.toString()].visqPath.length > 0
) {
// remove invalid path
this.removeVisqFile(document, webviewPanel);
} else if (path.endsWith(".visq.json")) {
// reload visq
this._mpqDataMap[document.uri.toString()].visqPath = path;
this.closeModelGraphView(document);
this.showVisqCircleModelGraph(path, document, webviewPanel);
}
}

/**
* @brief Called when visq path was cleared in UI
*/
private removeVisqFile(
document: vscode.TextDocument,
webviewPanel: vscode.WebviewPanel
) {
if (this._mpqDataMap[document.uri.toString()].visqPath !== "") {
this._mpqDataMap[document.uri.toString()].visqPath = ""; // clear visqPath

this.closeModelGraphView(document);
this.showCircleModelGraph(document, webviewPanel);
}
}
}

0 comments on commit 74ef4b0

Please sign in to comment.