Skip to content

Commit

Permalink
Merge branch 'release/0.12.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMakesGames committed Dec 5, 2024
2 parents ff3b84e + f457310 commit 2b573df
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/lib/GameState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const bypassSchema = z.object({
export type Bypass = WithId<z.infer<typeof bypassSchema>>;

const megastructureSchema = z.object({
type: z.string(),
type: z.string().optional(),
});

/**
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/src/lib/map/data/locUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,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);
Expand All @@ -110,9 +110,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
}
5 changes: 4 additions & 1 deletion src/renderer/src/lib/map/data/processLabels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -61,7 +62,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) {
Expand Down

0 comments on commit 2b573df

Please sign in to comment.