Added names for multiplayer
This commit is contained in:
@@ -12,6 +12,7 @@ text.savegame=Save Game
|
|||||||
text.loadgame=Load Game
|
text.loadgame=Load Game
|
||||||
text.joingame=Join Game
|
text.joingame=Join Game
|
||||||
text.quit=Quit
|
text.quit=Quit
|
||||||
|
text.name=Name:
|
||||||
text.server.connected=A player has joined.
|
text.server.connected=A player has joined.
|
||||||
text.server.disconnected={0} has disconnected.
|
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!
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import io.anuke.mindustry.resource.Item;
|
|||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
import io.anuke.mindustry.resource.Weapon;
|
import io.anuke.mindustry.resource.Weapon;
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
|
import io.anuke.ucore.UCore;
|
||||||
import io.anuke.ucore.core.*;
|
import io.anuke.ucore.core.*;
|
||||||
import io.anuke.ucore.core.Inputs.Axis;
|
import io.anuke.ucore.core.Inputs.Axis;
|
||||||
import io.anuke.ucore.core.Inputs.DeviceType;
|
import io.anuke.ucore.core.Inputs.DeviceType;
|
||||||
@@ -189,7 +190,8 @@ public class Control extends Module{
|
|||||||
|
|
||||||
Settings.defaultList(
|
Settings.defaultList(
|
||||||
"ip", "localhost",
|
"ip", "localhost",
|
||||||
"port", Vars.port+""
|
"port", Vars.port+"",
|
||||||
|
"name", Vars.android ? "player" : UCore.getProperty("user.name")
|
||||||
);
|
);
|
||||||
|
|
||||||
Settings.loadAll("io.anuke.moment");
|
Settings.loadAll("io.anuke.moment");
|
||||||
@@ -199,6 +201,7 @@ public class Control extends Module{
|
|||||||
}
|
}
|
||||||
|
|
||||||
player = new Player();
|
player = new Player();
|
||||||
|
player.name = Settings.getString("name");
|
||||||
player.isAndroid = Vars.android;
|
player.isAndroid = Vars.android;
|
||||||
player.isLocal = true;
|
player.isLocal = true;
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class NetClient extends Module {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ConnectPacket c = new ConnectPacket();
|
ConnectPacket c = new ConnectPacket();
|
||||||
c.name = UCore.getProperty("user.name");
|
c.name = Vars.player.name;
|
||||||
c.android = Vars.android;
|
c.android = Vars.android;
|
||||||
Net.send(c, SendMode.tcp);
|
Net.send(c, SendMode.tcp);
|
||||||
|
|
||||||
|
|||||||
@@ -197,6 +197,8 @@ public class Renderer extends RendererModule{
|
|||||||
if(pixelate)
|
if(pixelate)
|
||||||
Graphics.flushSurface();
|
Graphics.flushSurface();
|
||||||
|
|
||||||
|
drawPlayerNames();
|
||||||
|
|
||||||
batch.end();
|
batch.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,6 +213,16 @@ public class Renderer extends RendererModule{
|
|||||||
blocks.clearTiles();
|
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(){
|
void drawEnemyMarkers(){
|
||||||
Graphics.surface(indicatorSurface);
|
Graphics.surface(indicatorSurface);
|
||||||
Draw.color(Color.RED);
|
Draw.color(Color.RED);
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class Player extends DestructibleEntity implements Syncable{
|
|||||||
|
|
||||||
String part = isAndroid ? "ship" : "mech";
|
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);
|
Draw.rect(part+"-"+mech.name(), (int)x, (int)y, angle-90);
|
||||||
}else{
|
}else{
|
||||||
Draw.rect(part+"-"+mech.name(), x, y, angle-90);
|
Draw.rect(part+"-"+mech.name(), x, y, angle-90);
|
||||||
|
|||||||
@@ -63,6 +63,17 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
void setup(){
|
void setup(){
|
||||||
hosts.background("button");
|
hosts.background("button");
|
||||||
content().clear();
|
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().add(hosts).width(w).pad(0);
|
||||||
content().row();
|
content().row();
|
||||||
content().addButton("$text.joingame.byip", "clear", join::show).width(w).height(80f);
|
content().addButton("$text.joingame.byip", "clear", join::show).width(w).height(80f);
|
||||||
|
|||||||
Reference in New Issue
Block a user