Added names for multiplayer

This commit is contained in:
Anuken
2018-01-02 22:31:12 -05:00
parent 2c056cbdda
commit 086652a9dc
6 changed files with 30 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.resource.Weapon;
import io.anuke.mindustry.world.*;
import io.anuke.ucore.UCore;
import io.anuke.ucore.core.*;
import io.anuke.ucore.core.Inputs.Axis;
import io.anuke.ucore.core.Inputs.DeviceType;
@@ -189,7 +190,8 @@ public class Control extends Module{
Settings.defaultList(
"ip", "localhost",
"port", Vars.port+""
"port", Vars.port+"",
"name", Vars.android ? "player" : UCore.getProperty("user.name")
);
Settings.loadAll("io.anuke.moment");
@@ -199,6 +201,7 @@ public class Control extends Module{
}
player = new Player();
player.name = Settings.getString("name");
player.isAndroid = Vars.android;
player.isLocal = true;

View File

@@ -51,7 +51,7 @@ public class NetClient extends Module {
});
ConnectPacket c = new ConnectPacket();
c.name = UCore.getProperty("user.name");
c.name = Vars.player.name;
c.android = Vars.android;
Net.send(c, SendMode.tcp);

View File

@@ -196,6 +196,8 @@ public class Renderer extends RendererModule{
if(pixelate)
Graphics.flushSurface();
drawPlayerNames();
batch.end();
}
@@ -211,6 +213,16 @@ public class Renderer extends RendererModule{
blocks.clearTiles();
}
void drawPlayerNames(){
Draw.tscl(0.25f/2);
for(Player player : Vars.control.playerGroup.all()){
if(!player.isLocal){
Draw.text(player.name, player.x, player.y - 8);
}
}
Draw.tscl(Vars.fontscale);
}
void drawEnemyMarkers(){
Graphics.surface(indicatorSurface);
Draw.color(Color.RED);

View File

@@ -97,7 +97,7 @@ public class Player extends DestructibleEntity implements Syncable{
String part = isAndroid ? "ship" : "mech";
if(Vars.snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate")){
if(Vars.snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate") && isLocal){
Draw.rect(part+"-"+mech.name(), (int)x, (int)y, angle-90);
}else{
Draw.rect(part+"-"+mech.name(), x, y, angle-90);

View File

@@ -63,6 +63,17 @@ public class JoinDialog extends FloatingDialog {
void setup(){
hosts.background("button");
content().clear();
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().add(hosts).width(w).pad(0);
content().row();
content().addButton("$text.joingame.byip", "clear", join::show).width(w).height(80f);