diff --git a/CHANGELOG.md b/CHANGELOG.md index e012390..a6eec63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,12 @@ All notable changes to the "hoi4modutilities" extension will be documented in th Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. -## [0.11.0] - 2023/11/17 - Latest +## [0.11.1] - 2023/11/17 - Latest + +### Fixed +* Preview world map will stuck if resource icons are not available. + +## [0.11.0] - 2023/11/17 ### Added * Preview map shows X and Z from HOI4 coordinate system. diff --git a/README.md b/README.md index 4288f62..421919f 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ For feature details and user manual, please refer to [HOI4 Mod Utilities Wiki](h * Edge lines on world map not alway fit edge of colors. * Event tree preview will duplicate events even they are same event if they are from different option. -## Release Notes - [0.11.0] +## Release Notes - [0.11.1] ### Added * Preview map shows X and Z from HOI4 coordinate system. diff --git a/package.json b/package.json index 4826bf5..4fc99d1 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "hoi4modutilities", "displayName": "%hoi4modutilities.displayName%", "description": "Utilities for Heart of Iron IV mods developers", - "version": "0.11.0", + "version": "0.11.1", "author": "Chaofan Yang", "publisher": "chaofan", "icon": "icon.png", diff --git a/webviewsrc/worldmap/renderer.ts b/webviewsrc/worldmap/renderer.ts index ab999b4..e809131 100644 --- a/webviewsrc/worldmap/renderer.ts +++ b/webviewsrc/worldmap/renderer.ts @@ -50,7 +50,7 @@ export class Renderer extends Subscriber { private cursorX = 0; private cursorY = 0; - private static resourceImages: Record = {}; + private static resourceImages: Record = {}; constructor(private mainCanvas: HTMLCanvasElement, private viewPoint: ViewPoint, private loader: Loader, private topBar: TopBar) { super(); @@ -908,6 +908,9 @@ ${worldMap.getSupplyAreaWarnings(supplyArea).map(v => '|r|' + v).join('\n')}`); if (image) { maxHeight = Math.max(maxHeight, image.naturalHeight * scale); fullWidth += image.naturalWidth * scale; + } else { + maxHeight = Math.max(maxHeight, 24 * scale) + fullWidth += 24 * scale; } fullWidth += labelWidth; } @@ -924,9 +927,16 @@ ${worldMap.getSupplyAreaWarnings(supplyArea).map(v => '|r|' + v).join('\n')}`); } const image = Renderer.resourceImages[resource]; - context.drawImage(image, x, y, image.naturalWidth * scale, image.naturalHeight * scale); - context.fillText(resourceNumber.toString(), x + (image?.naturalWidth ?? 0) * scale + labelWidth / 2, y + Math.max(0, image?.naturalHeight ?? 0) * scale / 2); - x += (image?.naturalWidth ?? 0) * scale + labelWidth; + if (image) { + context.drawImage(image, x, y, image.naturalWidth * scale, image.naturalHeight * scale); + context.fillText(resourceNumber.toString(), x + (image?.naturalWidth ?? 0) * scale + labelWidth / 2, y + Math.max(0, image?.naturalHeight ?? 0) * scale / 2); + x += (image?.naturalWidth ?? 0) * scale + labelWidth; + } else { + context.fillStyle = 'gray'; + context.fillRect(x, y, 24 * scale, 24 * scale); + context.fillText(resourceNumber.toString(), x + 24 * scale + labelWidth / 2, y + 24 * scale / 2); + x += 24 * scale + labelWidth; + } } } }