Add setMaxIcons to UIIconBar
*/
package org.terasology.rendering.nui.widgets;
-import org.terasology.math.geom.Rect2i;
import org.terasology.math.TeraMath;
+import org.terasology.math.geom.Rect2i;
import org.terasology.math.geom.Vector2i;
import org.terasology.rendering.assets.texture.TextureRegion;
import org.terasology.rendering.nui.Canvas;
@@ -78,7 +78,8 @@ public void onDraw(Canvas canvas) {
halfSize.x /= 2;
halfSize.y /= 2;
canvas.drawTexture(icon,
- Rect2i.createFromMinAndSize(new Vector2i(offset.x + halfSize.x / 2, offset.y + halfSize.y / 2), halfSize));
+ Rect2i.createFromMinAndSize(new Vector2i(offset.x + halfSize.x / 2,
+ offset.y + halfSize.y / 2), halfSize));
break;
case SPLIT:
canvas.drawTextureRaw(icon,
@@ -107,7 +108,8 @@ public Vector2i getPreferredContentSize(Canvas canvas, Vector2i sizeHint) {
int maxHorizontalIcons = sizeHint.x / iconSize.x;
int rows = ((maxIcons - 1) / maxHorizontalIcons) + 1;
int columns = Math.min(maxIcons, maxHorizontalIcons);
- return new Vector2i(columns * iconSize.x + (columns - 1) * spacing, rows * iconSize.y + (rows - 1) * spacing);
+ return new Vector2i(columns * iconSize.x + (columns - 1) * spacing,
+ rows * iconSize.y + (rows - 1) * spacing);
} else {
return Vector2i.zero();
}
@@ -183,6 +185,13 @@ public void setMaxValue(float val) {
maxValue.set(val);
}
+ /**
+ * @param newValue The new max value for the number of icons.
+ */
+ public void setMaxIcons(int newValue) {
+ this.maxIcons = newValue;
+ }
+
/**
* @return The current HalfIconMode used.
*/
@@ -202,6 +211,4 @@ public void setHalfIconMode(HalfIconMode halfIconMode) {
SPLIT,
SHRINK,
}
-
-
}
