Skip to content

Commit 6db26e0

Browse files
committed
Merge PR #1939 by @msteiger - scaling text
2 parents 6d61633 + e34544c commit 6db26e0

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

engine/src/main/java/org/terasology/logic/nameTags/NameTagClientSystem.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ private void createOrUpdateNameTagFor(EntityRef entity, NameTagComponent nameTag
6868
FloatingTextComponent floatingText = nameTag.getComponent(FloatingTextComponent.class);
6969
floatingText.text = nameTagComponent.text;
7070
floatingText.textColor = nameTagComponent.textColor;
71+
floatingText.scale = nameTagComponent.scale;
7172
nameTag.saveComponent(floatingText);
7273
LocationComponent nameTagLoc = nameTag.getComponent(LocationComponent.class);
7374
nameTagLoc.setLocalPosition(offset);
@@ -80,6 +81,7 @@ private void createOrUpdateNameTagFor(EntityRef entity, NameTagComponent nameTag
8081
nameTagBuilder.addComponent(locationComponent);
8182
floatingTextComponent.text = nameTagComponent.text;
8283
floatingTextComponent.textColor = nameTagComponent.textColor;
84+
floatingTextComponent.scale = nameTagComponent.scale;
8385
nameTagBuilder.setOwner(entity);
8486
nameTagBuilder.setPersistent(false);
8587

engine/src/main/java/org/terasology/logic/nameTags/NameTagComponent.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.terasology.logic.nameTags;
1717

1818
import org.terasology.entitySystem.Component;
19+
import org.terasology.module.sandbox.API;
1920
import org.terasology.rendering.nui.Color;
2021

2122
/**
@@ -25,6 +26,7 @@
2526
*
2627
* The color of the name tag is based on the {@link org.terasology.network.ColorComponent} of this entity
2728
*/
29+
@API
2830
public class NameTagComponent implements Component {
2931

3032
public float yOffset = 0.3f;
@@ -33,4 +35,5 @@ public class NameTagComponent implements Component {
3335

3436
public Color textColor = Color.WHITE;
3537

38+
public float scale = 1f;
3639
}

engine/src/main/java/org/terasology/rendering/logic/FloatingTextComponent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ public class FloatingTextComponent implements Component {
2525
public String text;
2626
public Color textColor = Color.WHITE;
2727
public Color textShadowColor = Color.BLACK;
28+
public float scale = 1f;
2829
}

engine/src/main/java/org/terasology/rendering/logic/FloatingTextRenderer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,11 @@ private void render(Iterable<EntityRef> floatingTextEntities) {
116116
}
117117
glPushMatrix();
118118

119+
float scale = METER_PER_PIXEL * floatingText.scale;
119120

120121
glTranslated(worldPos.x - cameraPosition.x, worldPos.y - cameraPosition.y, worldPos.z - cameraPosition.z);
121122
OpenGLUtil.applyBillboardOrientation();
122-
glScaled(METER_PER_PIXEL, -METER_PER_PIXEL, METER_PER_PIXEL);
123+
glScaled(scale, -scale, scale);
123124
glTranslated(-textWidth / 2.0, 0.0, 0.0);
124125
for (Map.Entry<Material, Mesh> meshMapEntry : meshMap.entrySet()) {
125126
Mesh mesh = meshMapEntry.getValue();

0 commit comments

Comments
 (0)