From 2ef039cfd0223358f0ec8506c17c0a1415dd37cd Mon Sep 17 00:00:00 2001 From: Michael Moore Date: Sat, 30 Nov 2024 11:47:35 -0600 Subject: [PATCH 1/3] fix: gracefully handle megastructures missing `type` --- package-lock.json | 4 ++-- src/renderer/src/lib/GameState.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1aa46b8..d2d1b79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "stellarmaps", - "version": "0.12.0", + "version": "0.12.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "stellarmaps", - "version": "0.12.0", + "version": "0.12.2", "dependencies": { "@electron-toolkit/preload": "^3.0.1", "@electron-toolkit/utils": "^3.0.0", diff --git a/src/renderer/src/lib/GameState.ts b/src/renderer/src/lib/GameState.ts index 35d153d..8a054b9 100644 --- a/src/renderer/src/lib/GameState.ts +++ b/src/renderer/src/lib/GameState.ts @@ -130,7 +130,7 @@ const bypassSchema = z.object({ export type Bypass = WithId>; const megastructureSchema = z.object({ - type: z.string(), + type: z.string().optional(), }); /** From 289ffc8f9c5a5dba2070001979bfe560743118be Mon Sep 17 00:00:00 2001 From: Michael Moore Date: Sat, 30 Nov 2024 12:01:45 -0600 Subject: [PATCH 2/3] fix: handle color and icon codes in player names --- .vscode/settings.json | 4 +--- src/renderer/src/lib/map/data/locUtils.ts | 8 ++++---- src/renderer/src/lib/map/data/processLabels.ts | 5 ++++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 022f9a0..de7e23f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -27,7 +27,5 @@ "editor.defaultFormatter": "rust-lang.rust-analyzer" }, "eslint.run": "onType", - "editor.codeActionsOnSave": { - "source.organizeImports": "explicit" - } + "editor.codeActionsOnSave": {} } diff --git a/src/renderer/src/lib/map/data/locUtils.ts b/src/renderer/src/lib/map/data/locUtils.ts index 3d15e61..5402640 100644 --- a/src/renderer/src/lib/map/data/locUtils.ts +++ b/src/renderer/src/lib/map/data/locUtils.ts @@ -45,7 +45,7 @@ export function localizeTextSync( } } let value = loc[text.key]; - if (value == null) return removeColorCodes(text.key); + if (value == null) return removeColorAndIconCodes(text.key); if (text.variables) { text.variables.forEach((variable) => { const localizedVariable = localizeTextSync(variable.value, loc); @@ -55,9 +55,9 @@ export function localizeTextSync( .replace(`<${variable.key}>`, localizedVariable); }); } - return removeColorCodes(value); + return removeColorAndIconCodes(value); } -function removeColorCodes(text: string): string { - return text.replace(/[\u0011§]./g, ''); // eslint-disable-line no-control-regex +export function removeColorAndIconCodes(text: string): string { + return text.replace(/[\u0011§].?/g, '').replace(/\u0013\w*/g, ''); // eslint-disable-line no-control-regex } diff --git a/src/renderer/src/lib/map/data/processLabels.ts b/src/renderer/src/lib/map/data/processLabels.ts index 0c13ed2..34d8a08 100644 --- a/src/renderer/src/lib/map/data/processLabels.ts +++ b/src/renderer/src/lib/map/data/processLabels.ts @@ -3,6 +3,7 @@ import polylabel from 'polylabel'; import type { GameState } from '../../GameState'; import type { MapSettings } from '../../settings'; +import { removeColorAndIconCodes } from './locUtils'; import type processBorders from './processBorders'; import type processSystemOwnership from './processSystemOwnership'; import type processTerraIncognita from './processTerraIncognita'; @@ -58,7 +59,9 @@ export default function processLabels( ); const labels = idGeojsonPairs.map(([countryId, geojson]) => { const countryName = countryNames[countryId] ?? ''; - const playerName = gameState.player.find((player) => player.country === countryId)?.name ?? ''; + const playerName = removeColorAndIconCodes( + gameState.player.find((player) => player.country === countryId)?.name ?? '', + ); let primaryName = ''; let secondaryName = ''; switch (settings.countryNamesType) { From f457310f5d51d7ffb061e9fe5ab87891275d8d91 Mon Sep 17 00:00:00 2001 From: Michael Moore Date: Sat, 30 Nov 2024 12:03:15 -0600 Subject: [PATCH 3/3] chore: bump version and generate changelog --- CHANGELOG.md | 7 +++++++ package.json | 2 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 2 +- src/renderer/src/lib/constants.ts | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb57078..4521e8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +## [0.12.3](https://github.com/MichaelMakesGames/stellarmaps/compare/stellarmaps-v0.12.2...stellarmaps-v0.12.3) (2024-11-30) + +### Bug Fixes + +- gracefully handle megastructures missing `type` ([2ef039c](https://github.com/MichaelMakesGames/stellarmaps/commit/2ef039cfd0223358f0ec8506c17c0a1415dd37cd)) +- handle color and icon codes in player names ([289ffc8](https://github.com/MichaelMakesGames/stellarmaps/commit/289ffc8f9c5a5dba2070001979bfe560743118be)) + ## [0.12.2](https://github.com/MichaelMakesGames/stellarmaps/compare/stellarmaps-v0.12.1...stellarmaps-v0.12.2) (2024-09-18) ### Bug Fixes diff --git a/package.json b/package.json index 2035929..1f4a0ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stellarmaps", - "version": "0.12.2", + "version": "0.12.3", "private": true, "type": "module", "scripts": { diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 31a5a9c..6806048 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3254,7 +3254,7 @@ dependencies = [ [[package]] name = "stellarmaps" -version = "0.12.2" +version = "0.12.3" dependencies = [ "anyhow", "assert-json-diff", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index c12d349..ebc38cf 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stellarmaps" -version = "0.12.2" +version = "0.12.3" description = "Stellaris map renderer" authors = ["Michael Moore"] license = "" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 885d9ca..f525ee5 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "StellarMaps", - "version": "0.12.2" + "version": "0.12.3" }, "tauri": { "allowlist": { diff --git a/src/renderer/src/lib/constants.ts b/src/renderer/src/lib/constants.ts index 9133293..241cba3 100644 --- a/src/renderer/src/lib/constants.ts +++ b/src/renderer/src/lib/constants.ts @@ -1,4 +1,4 @@ -export const VERSION = '0.12.2'; +export const VERSION = '0.12.3'; export const SYSTEM_FONTS = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';