Implemented player list for android

This commit is contained in:
Anuken 2018-01-16 15:37:38 -05:00
parent 6ba1f117bd
commit c5211121cd
7 changed files with 249 additions and 227 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 826 B

View File

@ -10,7 +10,7 @@ import io.anuke.ucore.UCore;
import io.anuke.ucore.scene.ui.layout.Unit;
public class Vars{
public static final boolean testAndroid = false;
public static final boolean testAndroid = true;
//shorthand for whether or not this is running on android
public static final boolean android = (Gdx.app.getType() == ApplicationType.Android) || testAndroid;
//shorthand for whether or not this is running on GWT

View File

@ -35,72 +35,80 @@ public class HudFragment implements Fragment{
new table(){{
atop();
aleft();
new table(){{
left();
float dsize = 58;
defaults().size(dsize).left();
float isize = 40;
menu = new imagebutton("icon-menu", isize, ui.paused::show).get();
new table() {{
left();
float dsize = 58;
defaults().size(dsize).left();
float isize = 40;
flip = new imagebutton("icon-arrow-up", isize, () -> {
if(wavetable.getActions().size != 0) return;
menu = new imagebutton("icon-menu", isize, ui.paused::show).get();
float dur = 0.3f;
Interpolation in = Interpolation.pow3Out;
flip = new imagebutton("icon-arrow-up", isize, () -> {
if (wavetable.getActions().size != 0) return;
flip.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up");
float dur = 0.3f;
Interpolation in = Interpolation.pow3Out;
if(shown){
blockfrag.toggle(false, dur, in);
wavetable.actions(Actions.translateBy(0, wavetable.getHeight() + dsize, dur, in), Actions.call(() -> shown = false));
}else{
shown = true;
blockfrag.toggle(true, dur, in);
wavetable.actions(Actions.translateBy(0, -wavetable.getTranslation().y, dur, in));
}
flip.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up");
}).get();
new imagebutton("icon-pause", isize, () -> {
if(Net.active() && Vars.android){
if(ui.chatfrag.chatOpen()){
ui.chatfrag.hide();
}else{
ui.chatfrag.toggle();
if (shown) {
blockfrag.toggle(false, dur, in);
wavetable.actions(Actions.translateBy(0, wavetable.getHeight() + dsize, dur, in), Actions.call(() -> shown = false));
} else {
shown = true;
blockfrag.toggle(true, dur, in);
wavetable.actions(Actions.translateBy(0, -wavetable.getTranslation().y, dur, in));
}
}else {
GameState.set(GameState.is(State.paused) ? State.playing : State.paused);
}
}).update(i -> {
if(Net.active() && Vars.android){
i.getStyle().imageUp = Core.skin.getDrawable("icon-chat");
}else {
i.setDisabled(Net.active());
i.getStyle().imageUp = Core.skin.getDrawable(GameState.is(State.paused) ? "icon-play" : "icon-pause");
}
}).get();
}).get();
new imagebutton("icon-pause", isize, () -> {
if (Net.active() && Vars.android) {
ui.listfrag.visible = !ui.listfrag.visible;
} else {
GameState.set(GameState.is(State.paused) ? State.playing : State.paused);
}
}).update(i -> {
if (Net.active() && Vars.android) {
i.getStyle().imageUp = Core.skin.getDrawable("icon-players");
} else {
i.setDisabled(Net.active());
i.getStyle().imageUp = Core.skin.getDrawable(GameState.is(State.paused) ? "icon-play" : "icon-pause");
}
}).get();
}}.end();
row();
new table() {{
touchable(Touchable.enabled);
visible(() -> shown);
addWaveTable();
}}.fillX().end();
row();
visible(() -> !GameState.is(State.menu));
Label fps = new Label(() -> (Settings.getBool("fps") ? (Gdx.graphics.getFramesPerSecond() + " FPS") +
(Net.active() ? " / Ping: " + Net.getPing() : "") : ""));
row();
add(fps).size(-1);
}}.end();
row();
new table(){{
touchable(Touchable.enabled);
visible(() -> shown);
addWaveTable();
}}.fillX().end();
row();
new imagebutton("icon-chat", 40f, () -> {
if (ui.chatfrag.chatOpen()) {
ui.chatfrag.hide();
} else {
ui.chatfrag.toggle();
}
}).visible(() -> Net.active() && android).top().left().size(58f).get();
visible(()->!GameState.is(State.menu));
Label fps = new Label(()->(Settings.getBool("fps") ? (Gdx.graphics.getFramesPerSecond() + " FPS") +
(Net.active() ? " / Ping: " + Net.getPing() : ""): ""));
row();
add(fps).size(-1);
}}.end();
//tutorial ui table

View File

@ -15,6 +15,7 @@ import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Bundles;
public class PlayerListFragment implements Fragment{
public boolean visible = false;
Table content = new Table();
int last = 0;
@ -41,13 +42,19 @@ public class PlayerListFragment implements Fragment{
}}.end();
update(t -> {
if(Vars.control.playerGroup.amount() != last){
rebuild();
last = Vars.control.playerGroup.amount();
}
if(!Vars.android){
visible = Inputs.keyDown("player_list");
}
if(!(Net.active() && !GameState.is(State.menu))){
visible = false;
}
if(Vars.control.playerGroup.amount() != last){
rebuild();
last = Vars.control.playerGroup.amount();
}
});
visible(() -> Inputs.keyDown("player_list") && Net.active() && !GameState.is(State.menu));
visible(() -> visible);
}}.end();
rebuild();