Re-added host dialog, fixed join dialog UI error
This commit is contained in:
@@ -14,6 +14,7 @@ text.joingame=Join Game
|
|||||||
text.quit=Quit
|
text.quit=Quit
|
||||||
text.about.button=About
|
text.about.button=About
|
||||||
text.name=Name:
|
text.name=Name:
|
||||||
|
text.public=Public
|
||||||
text.players={0} players online
|
text.players={0} players online
|
||||||
text.players.single={0} player online
|
text.players.single={0} player online
|
||||||
text.server.kicked.kick=You have been kicked from the server!
|
text.server.kicked.kick=You have been kicked from the server!
|
||||||
@@ -23,6 +24,7 @@ text.server.disconnected={0} has disconnected.
|
|||||||
text.nohost=Can't host server on a custom map!
|
text.nohost=Can't host server on a custom map!
|
||||||
text.hostserver=Host Server
|
text.hostserver=Host Server
|
||||||
text.host=Host
|
text.host=Host
|
||||||
|
text.hosting=[accent]Opening server...
|
||||||
text.hosts.refresh=Refresh
|
text.hosts.refresh=Refresh
|
||||||
text.hosts.discovering=Discovering LAN games
|
text.hosts.discovering=Discovering LAN games
|
||||||
text.hosts.none=[lightgray]No games found!
|
text.hosts.none=[lightgray]No games found!
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ public class Renderer extends RendererModule{
|
|||||||
Draw.tscl(0.25f/2);
|
Draw.tscl(0.25f/2);
|
||||||
for(Player player : Vars.control.playerGroup.all()){
|
for(Player player : Vars.control.playerGroup.all()){
|
||||||
if(!player.isLocal){
|
if(!player.isLocal){
|
||||||
Draw.text(player.name, player.x, player.y + 6);
|
Draw.text(player.name, player.x, player.y + 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Draw.tscl(Vars.fontscale);
|
Draw.tscl(Vars.fontscale);
|
||||||
|
|||||||
@@ -1,12 +1,46 @@
|
|||||||
package io.anuke.mindustry.ui.dialogs;
|
package io.anuke.mindustry.ui.dialogs;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.Vars;
|
||||||
|
import io.anuke.mindustry.net.Net;
|
||||||
|
import io.anuke.ucore.core.Settings;
|
||||||
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.scene.ui.Dialog;
|
import io.anuke.ucore.scene.ui.Dialog;
|
||||||
|
import io.anuke.ucore.util.Bundles;
|
||||||
|
import io.anuke.ucore.util.Strings;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
public class HostDialog extends Dialog{
|
public class HostDialog extends Dialog{
|
||||||
|
float w = 300;
|
||||||
|
|
||||||
public HostDialog(){
|
public HostDialog(){
|
||||||
super("$text.hostserver", "dialog");
|
super("$text.hostserver", "dialog");
|
||||||
|
|
||||||
|
content().table(t -> {
|
||||||
|
t.add("$text.name").padRight(10);
|
||||||
|
t.addField(Settings.getString("name"), text -> {
|
||||||
|
if(text.isEmpty()) return;
|
||||||
|
Vars.player.name = text;
|
||||||
|
Settings.put("name", text);
|
||||||
|
Settings.save();
|
||||||
|
}).grow().pad(8);
|
||||||
|
}).width(w).height(70f).pad(4);
|
||||||
|
|
||||||
|
content().row();
|
||||||
|
|
||||||
|
content().addButton("Host", () -> {
|
||||||
|
Vars.ui.loadfrag.show("$text.hosting");
|
||||||
|
Timers.runTask(5f, () -> {
|
||||||
|
try{
|
||||||
|
Net.host(Vars.port);
|
||||||
|
}catch (IOException e){
|
||||||
|
Vars.ui.showError(Bundles.format("text.server.error", Strings.parseException(e, false)));
|
||||||
|
}
|
||||||
|
Vars.ui.loadfrag.hide();
|
||||||
|
hide();
|
||||||
|
});
|
||||||
|
}).width(w).height(70f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
join.buttons().addButton("$text.cancel", join::hide);
|
join.buttons().addButton("$text.cancel", join::hide);
|
||||||
join.buttons().addButton("$text.ok", () ->
|
join.buttons().addButton("$text.ok", () ->
|
||||||
connect(Settings.getString("ip"), Strings.parseInt(Settings.getString("port")))
|
connect(Settings.getString("ip"), Strings.parseInt(Settings.getString("port")))
|
||||||
).disabled(b -> Settings.getString("ip").isEmpty() || Strings.parseInt(Settings.getString("port")) == Integer.MIN_VALUE);
|
).disabled(b -> Settings.getString("ip").isEmpty() || Strings.parseInt(Settings.getString("port")) == Integer.MIN_VALUE || Net.active());
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
@@ -110,6 +110,8 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
Timers.runTask(2f, () -> {
|
Timers.runTask(2f, () -> {
|
||||||
try{
|
try{
|
||||||
Net.connect(ip, port);
|
Net.connect(ip, port);
|
||||||
|
hide();
|
||||||
|
join.hide();
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
Throwable t = e;
|
Throwable t = e;
|
||||||
while(t.getCause() != null){
|
while(t.getCause() != null){
|
||||||
|
|||||||
Reference in New Issue
Block a user