Format spoken player coordinates to 2 decimals
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
// Maintainer-controlled web client version.
|
// Maintainer-controlled web client version.
|
||||||
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
||||||
window.CHGRID_WEB_VERSION = "2026.02.22 R195";
|
window.CHGRID_WEB_VERSION = "2026.02.22 R196";
|
||||||
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
||||||
window.CHGRID_TIME_ZONE = "America/Detroit";
|
window.CHGRID_TIME_ZONE = "America/Detroit";
|
||||||
|
|||||||
@@ -1100,6 +1100,12 @@ function distanceDirectionPhrase(px: number, py: number, tx: number, ty: number)
|
|||||||
return `${distance} ${squareWord(distance)} ${direction}`;
|
return `${distance} ${squareWord(distance)} ${direction}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Formats a coordinate with up to 2 decimals while trimming trailing zeros. */
|
||||||
|
function formatCoordinate(value: number): string {
|
||||||
|
if (!Number.isFinite(value)) return '0';
|
||||||
|
return value.toFixed(2).replace(/\.?0+$/, '');
|
||||||
|
}
|
||||||
|
|
||||||
/** Persists current local player coordinates for reconnect/refresh restore. */
|
/** Persists current local player coordinates for reconnect/refresh restore. */
|
||||||
function persistPlayerPosition(): void {
|
function persistPlayerPosition(): void {
|
||||||
try {
|
try {
|
||||||
@@ -1629,7 +1635,7 @@ function handleNormalModeInput(code: string, shiftKey: boolean): void {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case 'speakCoordinates':
|
case 'speakCoordinates':
|
||||||
updateStatus(`${state.player.x}, ${state.player.y}`);
|
updateStatus(`${formatCoordinate(state.player.x)}, ${formatCoordinate(state.player.y)}`);
|
||||||
audio.sfxUiBlip();
|
audio.sfxUiBlip();
|
||||||
return;
|
return;
|
||||||
case 'openMicGainEdit':
|
case 'openMicGainEdit':
|
||||||
|
|||||||
Reference in New Issue
Block a user