Merge branch 'main' into feat/impassable-terrain

This commit is contained in:
FloPinguin
2026-06-18 23:32:27 +02:00
committed by GitHub
5 changed files with 48 additions and 0 deletions
+8
View File
@@ -525,6 +525,14 @@ async function createClientGame(
{ signal: graphicsListenerAbort.signal },
);
// Re-resolve names drawn on the map when the anonymous-names setting toggles
// so they switch live, like the leaderboard.
globalThis.addEventListener(
`${USER_SETTINGS_CHANGED_EVENT}:settings.anonymousNames`,
() => webglBuilder.refreshNames(gameView),
{ signal: graphicsListenerAbort.signal },
);
// Re-resolve settings and copy them onto the renderer's live object in
// place (passes hold a reference to it, so they pick the change up).
const regenerateRenderSettings = (): void => {
+16
View File
@@ -70,6 +70,19 @@ export class WebGLFrameBuilder {
this.view.updatePalette(this.palette);
}
/**
* Re-resolve every player's display name (e.g. after toggling the
* anonymous-names setting) and push it to the renderer so the names drawn on
* the map switch live, matching the leaderboard.
*/
refreshNames(gameView: GameView): void {
const displayNames = new Map<string, string>();
for (const p of gameView.players()) {
displayNames.set(p.id(), p.displayName());
}
this.view.refreshNames(displayNames);
}
update(gameView: GameView): void {
this.syncPlayers(gameView);
this.syncPlayerSpawns(gameView);
@@ -224,6 +237,9 @@ export class WebGLFrameBuilder {
newPlayers.push({
...p.static,
// displayName() honors the anonymous-names setting; static.displayName
// is always the real name.
displayName: p.displayName(),
flag: flagUrl,
color: p.territoryColor().toHex(),
});
+3
View File
@@ -163,6 +163,9 @@ export class MapRenderer {
): void {
this.renderer?.updateNames(names, players, snap, statusData);
}
refreshNames(displayNames: Map<string, string>): void {
this.renderer?.refreshNames(displayNames);
}
updateRelations(data: Uint8Array, size: number): void {
this.renderer?.updateRelations(data, size);
}
+5
View File
@@ -779,6 +779,11 @@ export class GPURenderer {
}
}
/** Re-resolve player name strings live (e.g. anonymous-names toggle). */
refreshNames(displayNames: Map<string, string>): void {
this.namePass.refreshNames(displayNames);
}
updateRelations(data: Uint8Array, size: number): void {
this.borderPass.updateRelations(data, size);
this.affiliationPalette.updateRelations(data, size);
@@ -244,6 +244,22 @@ export class NamePass {
}
}
/**
* Replace cached name strings (e.g. after the anonymous-names setting toggles)
* and force a re-upload on the next updateNames pass. slot.static is the same
* object as the playerByID entry, so updating displayName here is what the
* nameLen === 0 re-upload branch reads.
*/
refreshNames(displayNames: Map<string, string>): void {
for (const [id, name] of displayNames) {
const p = this.playerByID.get(id);
if (p === undefined) continue;
p.displayName = name;
const slot = this.slots.get(id);
if (slot !== undefined) slot.nameLen = 0;
}
}
/**
* Request the texture layer for a slot's flag (called once at slot creation).
* If the image is already loaded the layer index is set immediately; otherwise