Skip to content

Commit 75bfa24

Browse files
Show Alliance Color in Nametags [AARD-2020] (#1238)
Co-authored-by: Zach Rutman <92497727+rutmanz@users.noreply.github.com>
2 parents 4a893bd + 337c975 commit 75bfa24

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

fission/src/mirabuf/MirabufSceneObject.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
491491
/** Updates the position of the nametag relative to the robots position */
492492
private updateNameTag() {
493493
if (this._nameTag && PreferencesSystem.getGlobalPreference("RenderSceneTags")) {
494+
this._nameTag.color = this._alliance
494495
const boundingBox = this.computeBoundingBox()
495496
this._nameTag.position = World.sceneRenderer.worldToPixelSpace(
496497
new THREE.Vector3(

fission/src/ui/components/SceneOverlay.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const SceneOverlay: React.FC = () => {
3838
position: "absolute",
3939
left: x.position[0],
4040
top: x.position[1],
41-
backgroundColor: "rgba(0, 0, 0, 0.5)",
41+
backgroundColor: x.getCSSColor(),
4242
borderRadius: "8px",
4343
padding: "8px",
4444
whiteSpace: "nowrap",

fission/src/ui/components/SceneOverlayEvents.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Alliance } from "@/systems/preferences/PreferenceTypes.ts"
2+
13
let nextTagId = 0
24

35
/* Coordinates for tags in world space */
@@ -22,28 +24,42 @@ export const enum SceneOverlayEventKey {
2224
* @param text The text to display
2325
* @param position The position of the tag in screen space (default: [0,0])
2426
*/
27+
2528
export class SceneOverlayTag {
2629
private _id: number
2730
public text: () => string
31+
public color?: Alliance
2832
public position: PixelSpaceCoord // Screen Space
2933

3034
public get id() {
3135
return this._id
3236
}
3337

3438
/** Create a new tag */
35-
public constructor(text: () => string, position?: PixelSpaceCoord) {
39+
public constructor(text: () => string, position?: PixelSpaceCoord, color?: Alliance) {
3640
this._id = nextTagId++
3741

3842
this.text = text
3943
this.position = position ?? [0, 0]
44+
this.color = color
4045
new SceneOverlayTagEvent(SceneOverlayTagEventKey.ADD, this)
4146
}
4247

4348
/** Removing the tag */
4449
public dispose() {
4550
new SceneOverlayTagEvent(SceneOverlayTagEventKey.REMOVE, this)
4651
}
52+
53+
public getCSSColor(): string {
54+
switch (this.color) {
55+
case "red":
56+
return "rgba(166,22,27,0.5)"
57+
case "blue":
58+
return "rgba(0,74,129,0.5)"
59+
default:
60+
return "rgba(0,0,0,0.5)"
61+
}
62+
}
4763
}
4864

4965
/** Event handler for events that use a SceneOverlayTag as a parameter */

0 commit comments

Comments
 (0)