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; import io.anuke.ucore.scene.ui.layout.Unit;
public class Vars{ 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 //shorthand for whether or not this is running on android
public static final boolean android = (Gdx.app.getType() == ApplicationType.Android) || testAndroid; public static final boolean android = (Gdx.app.getType() == ApplicationType.Android) || testAndroid;
//shorthand for whether or not this is running on GWT //shorthand for whether or not this is running on GWT

View File

@@ -37,6 +37,8 @@ public class HudFragment implements Fragment{
aleft(); aleft();
new table(){{ new table(){{
new table() {{
left(); left();
float dsize = 58; float dsize = 58;
defaults().size(dsize).left(); defaults().size(dsize).left();
@@ -45,17 +47,17 @@ public class HudFragment implements Fragment{
menu = new imagebutton("icon-menu", isize, ui.paused::show).get(); menu = new imagebutton("icon-menu", isize, ui.paused::show).get();
flip = new imagebutton("icon-arrow-up", isize, () -> { flip = new imagebutton("icon-arrow-up", isize, () -> {
if(wavetable.getActions().size != 0) return; if (wavetable.getActions().size != 0) return;
float dur = 0.3f; float dur = 0.3f;
Interpolation in = Interpolation.pow3Out; Interpolation in = Interpolation.pow3Out;
flip.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up"); flip.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up");
if(shown){ if (shown) {
blockfrag.toggle(false, dur, in); blockfrag.toggle(false, dur, in);
wavetable.actions(Actions.translateBy(0, wavetable.getHeight() + dsize, dur, in), Actions.call(() -> shown = false)); wavetable.actions(Actions.translateBy(0, wavetable.getHeight() + dsize, dur, in), Actions.call(() -> shown = false));
}else{ } else {
shown = true; shown = true;
blockfrag.toggle(true, dur, in); blockfrag.toggle(true, dur, in);
wavetable.actions(Actions.translateBy(0, -wavetable.getTranslation().y, dur, in)); wavetable.actions(Actions.translateBy(0, -wavetable.getTranslation().y, dur, in));
@@ -64,19 +66,15 @@ public class HudFragment implements Fragment{
}).get(); }).get();
new imagebutton("icon-pause", isize, () -> { new imagebutton("icon-pause", isize, () -> {
if(Net.active() && Vars.android){ if (Net.active() && Vars.android) {
if(ui.chatfrag.chatOpen()){ ui.listfrag.visible = !ui.listfrag.visible;
ui.chatfrag.hide(); } else {
}else{
ui.chatfrag.toggle();
}
}else {
GameState.set(GameState.is(State.paused) ? State.playing : State.paused); GameState.set(GameState.is(State.paused) ? State.playing : State.paused);
} }
}).update(i -> { }).update(i -> {
if(Net.active() && Vars.android){ if (Net.active() && Vars.android) {
i.getStyle().imageUp = Core.skin.getDrawable("icon-chat"); i.getStyle().imageUp = Core.skin.getDrawable("icon-players");
}else { } else {
i.setDisabled(Net.active()); i.setDisabled(Net.active());
i.getStyle().imageUp = Core.skin.getDrawable(GameState.is(State.paused) ? "icon-play" : "icon-pause"); i.getStyle().imageUp = Core.skin.getDrawable(GameState.is(State.paused) ? "icon-play" : "icon-pause");
} }
@@ -86,7 +84,7 @@ public class HudFragment implements Fragment{
row(); row();
new table(){{ new table() {{
touchable(Touchable.enabled); touchable(Touchable.enabled);
visible(() -> shown); visible(() -> shown);
addWaveTable(); addWaveTable();
@@ -94,15 +92,25 @@ public class HudFragment implements Fragment{
row(); row();
visible(()->!GameState.is(State.menu)); visible(() -> !GameState.is(State.menu));
Label fps = new Label(()->(Settings.getBool("fps") ? (Gdx.graphics.getFramesPerSecond() + " FPS") + Label fps = new Label(() -> (Settings.getBool("fps") ? (Gdx.graphics.getFramesPerSecond() + " FPS") +
(Net.active() ? " / Ping: " + Net.getPing() : ""): "")); (Net.active() ? " / Ping: " + Net.getPing() : "") : ""));
row(); row();
add(fps).size(-1); add(fps).size(-1);
}}.end(); }}.end();
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();
}}.end();
//tutorial ui table //tutorial ui table
new table(){{ new table(){{
control.getTutorial().buildUI(this); control.getTutorial().buildUI(this);

View File

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