moved controller support to UIScene and abstract it

uses focus for keyboard and controller
added Keyboard support
Show key hint for buttons
added voice line for dialogs
fixed missing items rewards
fixed some maps
adjusted pile decks
This commit is contained in:
Grimm
2022-09-26 01:15:49 +02:00
parent 7bf3b2a9ef
commit b0b77f4c88
101 changed files with 6262 additions and 2500 deletions

View File

@@ -11,6 +11,7 @@ import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Null;
@@ -46,7 +47,7 @@ public class Controls {
{
public TextButtonFix(@Null String text)
{
super(text, Controls.getSkin(),Controls.getTextraFont()) ;
super(text==null?"NULL":text, Controls.getSkin(),Controls.getTextraFont()) ;
}
@Override
@@ -84,8 +85,8 @@ public class Controls {
return getBoundingRect(actor).contains(point);
}
static public SelectBox newComboBox(String[] text, String item, Function<Object, Void> func) {
SelectBox ret = new SelectBox<String>(getSkin());
static public SelectBox<String> newComboBox(String[] text, String item, Function<Object, Void> func) {
SelectBox<String> ret = newComboBox();
ret.getStyle().listStyle.selection.setTopHeight(4);
ret.setItems(text);
ret.addListener(new ChangeListener() {
@@ -105,8 +106,8 @@ public class Controls {
return ret;
}
static public SelectBox newComboBox(Array<String> text, String item, Function<Object, Void> func) {
SelectBox ret = new SelectBox<String>(getSkin());
static public SelectBox<String> newComboBox(Array<String> text, String item, Function<Object, Void> func) {
SelectBox<String> ret = newComboBox();
ret.getStyle().listStyle.selection.setTopHeight(4);
ret.setItems(text);
ret.addListener(new ChangeListener() {
@@ -125,8 +126,25 @@ public class Controls {
ret.setAlignment(Align.right);
return ret;
}
static public SelectBox newComboBox(Float[] text, float item, Function<Object, Void> func) {
SelectBox ret = new SelectBox<Float>(getSkin());
static public<T> SelectBox newComboBox()
{
return new SelectBox<T>(getSkin())
{
@Null
protected Drawable getBackgroundDrawable() {
if (this.isDisabled() && this.getStyle().backgroundDisabled != null) {
return this.getStyle().backgroundDisabled;
} else if (this.getScrollPane().hasParent() && this.getStyle().backgroundOpen != null) {
return this.getStyle().backgroundOpen;
} else {
return (this.isOver() || hasKeyboardFocus()) && this.getStyle().backgroundOver != null ? this.getStyle().backgroundOver : this.getStyle().background;
}
}
};
}
static public SelectBox<Float> newComboBox(Float[] text, float item, Function<Object, Void> func) {
SelectBox<Float> ret = newComboBox();
ret.getStyle().listStyle.selection.setTopHeight(4);
ret.setItems(text);
ret.addListener(new ChangeListener() {
@@ -183,7 +201,20 @@ public class Controls {
}
static public Slider newSlider(float min, float max, float step, boolean vertical) {
Slider ret = new Slider(min, max, step, vertical, getSkin());
Slider ret = new Slider(min, max, step, vertical, getSkin())
{
@Override
protected Drawable getBackgroundDrawable() {
SliderStyle style = (SliderStyle)super.getStyle();
if (this.isDisabled() && style.disabledBackground != null) {
return style.disabledBackground;
} else if (this.isDragging() && style.backgroundDown != null) {
return style.backgroundDown;
} else {
return (this.isOver() || hasKeyboardFocus()) && style.backgroundOver != null ? style.backgroundOver : style.background;
}
}
};
return ret;
}
@@ -341,6 +372,16 @@ public class Controls {
}
static Font textraFont=null;
static Font keysFont=null;
static public Font getKeysFont()
{
if(keysFont==null)
{
keysFont=new Font(getSkin().getFont("default"));
keysFont.addAtlas(Config.instance().getAtlas(Paths.KEYS_ATLAS));
}
return keysFont;
}
static public Font getTextraFont()
{
if(textraFont==null)