Added i18n factory method to create instances with resolved string id

This commit is contained in:
Collin Smith 2020-07-04 01:18:08 -07:00
parent 475018e6f6
commit fba74adb74

View File

@ -3,6 +3,7 @@ package com.riiablo.widget;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.riiablo.Riiablo;
import com.riiablo.graphics.PaletteIndexedBatch;
@ -24,11 +25,24 @@ public class LabelButton extends Label {
init();
}
public LabelButton(String text, BitmapFont font, Color color) {
super(text, font, color);
init();
}
public LabelButton(BitmapFont font) {
super(font);
init();
}
public static LabelButton i18n(String id, BitmapFont font) {
return new LabelButton(Riiablo.string.lookup(id), font);
}
public static LabelButton i18n(String id, BitmapFont font, Color color) {
return new LabelButton(Riiablo.string.lookup(id), font, color);
}
private void init() {
addListener(clickListener = new ClickListener());
}