Skip to content

Commit 32f924e

Browse files
authored
Merge pull request #40 from anno-mods/devel/1.12-fixes2
minor fixes
2 parents 0726717 + a6dfe62 commit 32f924e

File tree

5 files changed

+56
-4
lines changed

5 files changed

+56
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
66

77
## 1.12 Simplified Build and Deploy
88

9+
- 1.12.11: Rename bundled mods to ModID to avoid confusion
10+
- 1.12.10: Disable xmltest for documents not starting with `<ModOps>`
911
- 1.12.9: Support local bundles
1012
- 1.12.8: Treat icon LOD generation under `data/ui` differently
1113
- 1.12.7: Updated xmltest, annodiff to GU17.1

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "anno-modding-tools",
33
"displayName": "Anno Modding Tools",
44
"description": "Modding tools for Anno 1800",
5-
"version": "1.12.9",
5+
"version": "1.12.11",
66
"publisher": "JakobHarder",
77
"repository": {
88
"type": "git",

src/builder/index.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ export class ModBuilder {
164164
this._downloadBundle(bundle, cache, outFolder);
165165
}
166166
}
167+
168+
this._renameModFolders(outFolder);
167169
}
168170

169171
for (const sourceFolder of sourceFolders) {
@@ -206,15 +208,15 @@ export class ModBuilder {
206208
return;
207209
}
208210

209-
const modName = this._getModName(modinfoPath, modinfo.modinfo);
210-
const targetFolder = path.join(outFolder, modName);
211+
// const modName = this._getModName(modinfoPath, modinfo.modinfo);
212+
const targetFolder = path.join(outFolder, path.basename(bundle));
211213

212214
await this.build(modinfoPath, targetFolder);
213215
}
214216

215217
private _downloadBundle(bundle: string, cache: string, outFolder: string) {
216218
const fileName = path.basename(bundle);
217-
const version = path.basename(path.dirname(bundle)).replace(/[^\w\-]/g, '');
219+
const version = path.basename(path.dirname(bundle)).replace(/[^\w\-\.]/g, '');
218220
const targetPath = path.join(cache, 'downloads', utils.insertEnding(fileName, '-' + version));
219221
if (!fs.existsSync(targetPath)) {
220222
this._logger.log(` * download ${version}/${fileName}`);
@@ -227,6 +229,26 @@ export class ModBuilder {
227229
utils.extractZip(targetPath, outFolder, this._logger);
228230
}
229231

232+
private _renameModFolders(modsPath: string) {
233+
const modinfoPaths = glob.sync("*/modinfo.json", { cwd: modsPath, nodir: true });
234+
for (var modinfoPath of modinfoPaths) {
235+
const namedModPath = path.join(modsPath, path.dirname(modinfoPath));
236+
const modinfo = utils.readModinfo(namedModPath);
237+
if (!modinfo) {
238+
continue;
239+
}
240+
241+
if (!modinfo.modinfo.ModID) {
242+
continue;
243+
}
244+
245+
const idModPath = path.join(path.dirname(namedModPath), modinfo.modinfo.ModID);
246+
if (namedModPath != idModPath) {
247+
fs.renameSync(namedModPath, idModPath);
248+
}
249+
}
250+
}
251+
230252
private _getOutFolder(filePath: string, modJson: any) {
231253
let outFolder = modJson.out ?? '${annoMods}/${modName}';
232254
outFolder = outFolder.replace('${modName}', this._getModName(filePath, modJson.modinfo ?? modJson));

src/features/assetsActionProvider.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,28 @@ export function clearDiagnostics(context: vscode.ExtensionContext, doc: vscode.T
6767
vscode.window.activeTextEditor?.setDecorations(performanceDecorationType, []);
6868
}
6969

70+
function checkRootTag(doc: vscode.TextDocument, tag: string): boolean {
71+
for (var index = 0; index < doc.lineCount; index++) {
72+
const line = doc.lineAt(index);
73+
const match = /<(\w+)/.exec(line.text);
74+
if (match) {
75+
return match[1] == tag;
76+
}
77+
}
78+
return false;
79+
}
80+
7081
export function refreshDiagnostics(context: vscode.ExtensionContext, doc: vscode.TextDocument, collection: vscode.DiagnosticCollection): void {
7182
if (doc.lineCount > 10000 || !minimatch(doc.fileName, ASSETS_FILENAME_PATTERN)) {
7283
// ignore large files and non-assets.xmls
7384
return;
7485
}
7586

87+
if (!checkRootTag(doc, "ModOps")) {
88+
// not a ModOps document
89+
return;
90+
}
91+
7692
const config = vscode.workspace.getConfiguration('anno', doc.uri);
7793
const checkFileNames = config.get('checkFileNames');
7894
const annoRda: string | undefined = config.get('rdaFolder');

src/other/utils.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ export function hasGraphicsFile(modPaths: string[], filePath: string, annoRda?:
294294
if (fs.existsSync(path.join(modPath, folderPath, path.basename(fileName, '.psd') + '.png'))) {
295295
return [];
296296
}
297+
298+
if (fs.existsSync(path.join(modPath, folderPath, path.basename(fileName, '_norm.psd') + '_rga.png'))) {
299+
return [];
300+
}
297301
checked.push(path.join(folderPath, path.basename(fileName, '.psd') + '_0.dds'));
298302
checked.push(path.join(folderPath, path.basename(fileName, '.psd') + '.png'));
299303
}
@@ -330,6 +334,14 @@ export function hasGraphicsFile(modPaths: string[], filePath: string, annoRda?:
330334
}
331335
checked.push(path.join(folderPath, path.basename(fileName, '.png') + '_0.dds'));
332336
}
337+
338+
// try .rdp.xml
339+
if (fileName.endsWith('.rdp')) {
340+
if (fs.existsSync(path.join(modPath, folderPath, fileName + '.xml'))) {
341+
return [];
342+
}
343+
checked.push(path.join(modPath, folderPath, fileName + '.xml'));
344+
}
333345
}
334346

335347
return checked;

0 commit comments

Comments
 (0)