Make StringTextIconRenderer work with more generic TextureRegion.
Reasoning: This makes it possible to use atlas icon URLs like
engine:items#whiteRecipe with the StringTextIconRenderer.
Since TextureREgion is a interface implemented by Texture this shouldn't
break anything: A StringTextIconRenderer sub class is still allowed
to return a Texture instead of a TextureRegion.
import org.terasology.math.geom.Rect2i;
import org.terasology.math.geom.Vector2i;
import org.terasology.rendering.assets.font.Font;
-import org.terasology.rendering.assets.texture.Texture;
+import org.terasology.rendering.assets.texture.TextureRegion;
import org.terasology.rendering.nui.Canvas;
import org.terasology.rendering.nui.TextLineBuilder;
@@ -49,7 +49,7 @@ protected StringTextIconRenderer(int marginTop, int marginBottom, int marginLeft
@Override
public void draw(T value, Canvas canvas) {
// Drawing the icon
- Texture texture = getTexture(value);
+ TextureRegion texture = getTexture(value);
if (texture != null) {
if (marginTop + texture.getHeight() + marginBottom > canvas.size().y) {
@@ -82,7 +82,7 @@ public Vector2i getPreferredSize(T value, Canvas canvas) {
Font font = canvas.getCurrentStyle().getFont();
String text = getString(value);
- Texture texture = getTexture(value);
+ TextureRegion texture = getTexture(value);
if (texture == null) {
List<String> lines = TextLineBuilder.getLines(font, text, canvas.size().x);
return font.getSize(lines);
@@ -95,5 +95,5 @@ public Vector2i getPreferredSize(T value, Canvas canvas) {
public abstract String getString(T value);
- public abstract Texture getTexture(T value);
+ public abstract TextureRegion getTexture(T value);
}
