Skip to content

Commit 51c47a1

Browse files
committed
fix: external icons - battle screen
1 parent 01a69fd commit 51c47a1

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8151,7 +8151,7 @@
81518151
<script defer src="modules/ui/regiments-overview.js?v=1.107.0"></script>
81528152
<script defer src="modules/ui/markers-overview.js?v=1.107.0"></script>
81538153
<script defer src="modules/ui/regiment-editor.js?v=1.107.0"></script>
8154-
<script defer src="modules/ui/battle-screen.js?v=1.99.00"></script>
8154+
<script defer src="modules/ui/battle-screen.js?v=1.107.2"></script>
81558155
<script defer src="modules/ui/emblems-editor.js?v=1.99.00"></script>
81568156
<script defer src="modules/ui/markers-editor.js?v=1.107.0"></script>
81578157
<script defer src="modules/ui/3d.js?v=1.99.00"></script>

modules/ui/battle-screen.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ class Battle {
131131

132132
for (const u of options.military) {
133133
const label = capitalize(u.name.replace(/_/g, " "));
134-
headers += `<th data-tip="${label}">${u.icon}</th>`;
134+
const isExternal = u.icon.startsWith("http");
135+
const iconHTML = isExternal ? `<img src="${u.icon}" width="15" height="15">` : u.icon;
136+
headers += `<th data-tip="${label}">${iconHTML}</th>`;
135137
}
136138

137139
headers += "<th data-tip='Total military''>Total</th></tr></thead>";
@@ -145,9 +147,13 @@ class Battle {
145147
const state = pack.states[regiment.state];
146148
const distance = (Math.hypot(this.y - regiment.by, this.x - regiment.bx) * distanceScale) | 0; // distance between regiment and its base
147149
const color = state.color[0] === "#" ? state.color : "#999";
150+
151+
const isExternal = regiment.icon.startsWith("http");
152+
const iconHtml = isExternal
153+
? `<image href="${regiment.icon}" x="0.1em" y="0.1em" width="1.2em" height="1.2em"></image>`
154+
: `<text x="50%" y="1em" style="text-anchor: middle">${regiment.icon}</text>`;
148155
const icon = `<svg width="1.4em" height="1.4em" style="margin-bottom: -.6em; stroke: #333">
149-
<rect x="0" y="0" width="100%" height="100%" fill="${color}"></rect>
150-
<text x="0" y="1.04em" style="">${regiment.icon}</text></svg>`;
156+
<rect x="0" y="0" width="100%" height="100%" fill="${color}"></rect>${iconHtml}</svg>`;
151157
const body = `<tbody id="battle${state.i}-${regiment.i}">`;
152158

153159
let initial = `<tr class="battleInitial"><td>${icon}</td><td class="regiment" data-tip="${

versioning.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Example: 1.102.2 -> Major version 1, Minor version 102, Patch version 2
1414
*/
1515

16-
const VERSION = "1.107.1";
16+
const VERSION = "1.107.2";
1717
if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function");
1818

1919
{

0 commit comments

Comments
 (0)