added running flag to SessionData
parent
34695f1132
commit
c5debe13e8
@ -0,0 +1,53 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.actors;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.List;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public abstract class IconList<T> extends List<T> {
|
||||
@Getter
|
||||
@Setter
|
||||
private float iconWidth = -1;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private float iconPadding = 8;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public IconList(Skin skin) {
|
||||
super(skin);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public IconList(Skin skin, String styleName) {
|
||||
super(skin, styleName);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public IconList(ListStyle style) {
|
||||
super(style);
|
||||
}
|
||||
|
||||
public abstract Drawable getIcon(T item);
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setAlignment(int alignment) {}
|
||||
|
||||
@Override
|
||||
protected GlyphLayout drawItem(Batch batch, BitmapFont font, int index, T item, float x, float y, float width) {
|
||||
var text = toString(item);
|
||||
var icon = getIcon(item);
|
||||
var height = font.getCapHeight();
|
||||
var iconWidth = this.iconWidth < 0 ? height : this.iconWidth;
|
||||
|
||||
icon.draw(batch, x, y - height, iconWidth, height);
|
||||
return font.draw(batch, text, x + iconWidth + iconPadding, y, 0, text.length(), width - iconWidth - iconPadding, Align.left, false, "...");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue