Skip to content

Commit

Permalink
Merge pull request #29 from anno-mods/devel/1.12-fixes
Browse files Browse the repository at this point in the history
Devel/1.12 fixes
  • Loading branch information
jakobharder authored Apr 16, 2023
2 parents 7752dc6 + 6e90e2e commit dcd6f4b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

## 1.12 Simplified Build and Deploy

- 1.12.2: Export .png for icons as well
- 1.12.1: Support hierarchy of named `Group`s (with comments) in outline
- Build and deploy is now possible with `modinfo.json` files
- Added `bundle` setting in `modinfo.json` to download sub mods in build step

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "anno-modding-tools",
"displayName": "Anno Modding Tools",
"description": "Modding tools for Anno 1800",
"version": "1.12.0",
"version": "1.12.2",
"publisher": "JakobHarder",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions src/builder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class ModBuilder {
},
{
"action": "static",
"pattern": "{banner.*,content*.txt,README.md,data/config/**/*,**/*.include.xml}"
"pattern": "{banner.*,content*.txt,README.md,data/config/**/*,**/*.include.xml,**/icon*.png}"
},
{
"action": "cf7",
Expand Down Expand Up @@ -117,7 +117,7 @@ export class ModBuilder {
{
"action": "texture",
"pattern": "{data,products,shared}/**/icon*.png",
"lods": 1
"lods": 3
},
{
"action": "assets"
Expand Down
10 changes: 4 additions & 6 deletions src/features/outline/assetsTocProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export class AssetsTocProvider {

let sectionComment: string | undefined = 'ModOps';
let groupComment: string | undefined;
let groupCommentLine: number | undefined;

let xmlContent;
try {
Expand All @@ -158,13 +157,13 @@ export class AssetsTocProvider {

const nodeStack: { depth: number, element: xmldoc.XmlNode }[] = [{ depth: 0, element: xmlContent }];
for (let top = nodeStack.pop(); top; top = nodeStack.pop()) {

if (top.element.type === 'comment' && top.depth === 1) {
if (top.element.type === 'comment') {
let comment = top.element.comment.trim();
if (comment.startsWith('#')) {
if (comment.startsWith('#') && top.depth === 1) {
comment = comment.replace(/#/g, '').trim();
if (comment) {
sectionComment = comment;
groupComment = undefined;
}
}
else if (comment) {
Expand Down Expand Up @@ -213,6 +212,7 @@ export class AssetsTocProvider {
symbol: relevantSections[top.element.name]?.symbol ?? vscode.SymbolKind.String
});
}
groupComment = undefined;
// else if (!tocRelevant && top.depth === 2) {
// // ModOps that are not Assets
// if (!toc[toc.length - 1].children) {
Expand All @@ -230,8 +230,6 @@ export class AssetsTocProvider {

// toc[toc.length - 1].children?.push(name || 'Item');
// }

groupComment = undefined;
}
else {
// ignore
Expand Down
31 changes: 31 additions & 0 deletions src/test/suite/outline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,35 @@ suite('outline tests', () => {
assert.strictEqual(toc[3].text, "Section 3");
assert.strictEqual(toc[4].text, "Include");
});

test('sub-section comments', async () => {
const text = `<ModOps>
<!-- # Lists -->
<Group>
<!-- After Coats -->
<Group />
<!-- After Furs -->
<Group />
</Group>
</ModOps>`.split('\n');

let textDocument: SkinnyTextDocument = {
uri: vscode.Uri.file('abc.xml'),
version: 0,
lineCount: text.length,
getText: () => {
return text.join('\n');
},
lineAt: (line: number) => {
return { text: text[line] };
}
};

const provider = new AssetsTocProvider(textDocument);
const toc = provider.getToc();

assert.strictEqual(toc[0].text, "Lists");
assert.strictEqual(toc[1].text, "After Coats");
assert.strictEqual(toc[2].text, "After Furs");
});
});

0 comments on commit dcd6f4b

Please sign in to comment.