Implemented player menu with kick option (untested)
This commit is contained in:
@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Colors;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
@@ -21,6 +22,11 @@ public class BorderImage extends Image{
|
||||
super(texture);
|
||||
thickness = thick;
|
||||
}
|
||||
|
||||
public BorderImage(TextureRegion region, float thick){
|
||||
super(region);
|
||||
thickness = thick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float alpha){
|
||||
|
||||
@@ -62,7 +62,7 @@ public class MenuDialog extends FloatingDialog{
|
||||
}else {
|
||||
ui.showHostServer();
|
||||
}
|
||||
}).disabled(b -> Net.active() || (Net.active() && !Net.server()));
|
||||
}).disabled(b -> Net.active());
|
||||
|
||||
content().row();
|
||||
|
||||
@@ -96,7 +96,14 @@ public class MenuDialog extends FloatingDialog{
|
||||
|
||||
new imagebutton("icon-load", isize, () -> load.show()).text("$text.load").padTop(4f).disabled(Net.active());
|
||||
|
||||
new imagebutton("icon-host", isize, () -> ui.showHostServer()).text("$text.host").padTop(4f);
|
||||
new imagebutton("icon-host", isize, () -> {
|
||||
if(Vars.world.getMap().custom){
|
||||
ui.showError("$text.nohost");
|
||||
}else {
|
||||
ui.showHostServer();
|
||||
}
|
||||
}).text("$text.host")
|
||||
.disabled(b -> Net.active()).padTop(4f);
|
||||
|
||||
new imagebutton("icon-quit", isize, () -> {
|
||||
Vars.ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.ui.BorderImage;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
public class PlayerListFragment implements Fragment{
|
||||
Table content = new Table();
|
||||
|
||||
@Override
|
||||
public void build(){
|
||||
new table(){{
|
||||
new table("pane"){{
|
||||
new label(() -> Bundles.format("text.players", Vars.control.playerGroup.amount()));
|
||||
row();
|
||||
add(content).grow();
|
||||
}}.end();
|
||||
}}.end();
|
||||
|
||||
rebuild();
|
||||
}
|
||||
|
||||
public void rebuild(){
|
||||
if(!Net.active()) return;
|
||||
content.clear();
|
||||
|
||||
float h = 80f;
|
||||
|
||||
for(Player player : Vars.control.playerGroup.all()){
|
||||
Table button = new Table("button");
|
||||
button.left();
|
||||
button.margin(0);
|
||||
BorderImage image = new BorderImage(Draw.region(player.isAndroid ? "ship-standard" : "mech-standard"), 3f);
|
||||
button.add(image).size(h);
|
||||
button.add(player.name).pad(10);
|
||||
|
||||
if(Net.server() && !player.isLocal){
|
||||
button.add().growY();
|
||||
button.addIButton("icon-cancel", 14*3, () ->
|
||||
Net.kickConnection(player.clientid)
|
||||
).size(h);
|
||||
}
|
||||
|
||||
content.add(button).padBottom(-5).width(250f);
|
||||
content.row();
|
||||
}
|
||||
|
||||
content.marginBottom(5);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user