Skip to content

Commit 0f4dddb

Browse files
committed
Add setting to disable vmt texture path validation
1 parent 9e03ccb commit 0f4dddb

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,11 @@
378378
"type": "boolean",
379379
"default": true,
380380
"description": "Whether to put { on a newline after the key"
381+
},
382+
"sourceEngine.vmt.validateTexturePaths": {
383+
"type": "boolean",
384+
"default": true,
385+
"description": "Warn when the file of a texture property can't be found"
381386
}
382387
}
383388
},

src/language/VmtSemanticTokenProvider.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Token, isFloatValue, isScalarValue } from "@sourcelib/kv";
77
import { shaderParams, internalTextures } from "@sourcelib/vmt";
88
import { KvSemanticProcessor, KvSemanticProcessorParams } from "./KvSemanticProcessor";
99
import { KvPair } from "../Kv";
10+
import * as main from "../main";
1011
import fs from "fs";
1112
import path from "path";
1213

@@ -113,11 +114,14 @@ export class VmtSemanticTokenProvider extends KvTokensProviderBase {
113114
tokensBuilder.push(range, "keyword");
114115
return;
115116
}
116-
const materialDir = getParentDocumentDirectory(kvDoc.document.uri.fsPath, "materials");
117-
if (materialDir != null) {
118-
const materialPath: string = path.join(materialDir, kv.value.content + ".vtf");
119-
if (!fs.existsSync(materialPath)) {
120-
this.diagnostics.push(new vscode.Diagnostic(range, "Texture not found on disk", vscode.DiagnosticSeverity.Warning));
117+
const validationEnabled = main.config.get<boolean>("vmt.validateTexturePaths");
118+
if(validationEnabled) {
119+
const materialDir = getParentDocumentDirectory(kvDoc.document.uri.fsPath, "materials");
120+
if (materialDir != null) {
121+
const materialPath: string = path.join(materialDir, kv.value.content + ".vtf");
122+
if (!fs.existsSync(materialPath)) {
123+
this.diagnostics.push(new vscode.Diagnostic(range, "Texture not found on disk", vscode.DiagnosticSeverity.Warning));
124+
}
121125
}
122126
}
123127

0 commit comments

Comments
 (0)