Fixed many crashes with B14, added color customization
This commit is contained in:
@@ -4,9 +4,11 @@
|
|||||||
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.world.Tile" />
|
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.world.Tile" />
|
||||||
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.io.Maps" />
|
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.io.Maps" />
|
||||||
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.entities.Player" />
|
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.entities.Player" />
|
||||||
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.entities.types.Enemy" />
|
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.entities.enemies.Enemy" />
|
||||||
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.world.Map" />
|
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.world.Map" />
|
||||||
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.game.EnemySpawn" />
|
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.game.EnemySpawn" />
|
||||||
|
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.core.GameState" />
|
||||||
|
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.game.EventType" />
|
||||||
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.io.SaveFileVersion" />
|
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.io.SaveFileVersion" />
|
||||||
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.resource.Recipe" />
|
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.resource.Recipe" />
|
||||||
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.net.Packets" />
|
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.net.Packets" />
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.anuke.mindustry;
|
|||||||
import com.badlogic.gdx.Application.ApplicationType;
|
import com.badlogic.gdx.Application.ApplicationType;
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import io.anuke.mindustry.core.*;
|
import io.anuke.mindustry.core.*;
|
||||||
import io.anuke.mindustry.entities.Bullet;
|
import io.anuke.mindustry.entities.Bullet;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
@@ -80,6 +81,25 @@ public class Vars{
|
|||||||
|
|
||||||
public static final int tilesize = 8;
|
public static final int tilesize = 8;
|
||||||
|
|
||||||
|
public static final Color[] playerColors = {
|
||||||
|
Color.valueOf("82759a"),
|
||||||
|
Color.valueOf("c0c1c5"),
|
||||||
|
Color.valueOf("fff0e7"),
|
||||||
|
Color.valueOf("7d2953"),
|
||||||
|
Color.valueOf("ff074e"),
|
||||||
|
Color.valueOf("ff072a"),
|
||||||
|
Color.valueOf("ff76a6"),
|
||||||
|
Color.valueOf("a95238"),
|
||||||
|
Color.valueOf("ffa108"),
|
||||||
|
Color.valueOf("feeb2c"),
|
||||||
|
Color.valueOf("ffcaa8"),
|
||||||
|
Color.valueOf("008551"),
|
||||||
|
Color.valueOf("00e339"),
|
||||||
|
Color.valueOf("222e53"),
|
||||||
|
Color.valueOf("4b5ef1"),
|
||||||
|
Color.valueOf("2cabfe"),
|
||||||
|
};
|
||||||
|
|
||||||
//server port
|
//server port
|
||||||
public static final int port = 6567;
|
public static final int port = 6567;
|
||||||
public static final int webPort = 6568;
|
public static final int webPort = 6568;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.core;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input.Buttons;
|
import com.badlogic.gdx.Input.Buttons;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.input.DefaultKeybinds;
|
import io.anuke.mindustry.input.DefaultKeybinds;
|
||||||
@@ -111,7 +112,8 @@ public class Control extends Module{
|
|||||||
"ip", "localhost",
|
"ip", "localhost",
|
||||||
"port", port+"",
|
"port", port+"",
|
||||||
"name", android || gwt ? "player" : UCore.getProperty("user.name"),
|
"name", android || gwt ? "player" : UCore.getProperty("user.name"),
|
||||||
"servers", ""
|
"servers", "",
|
||||||
|
"color", Color.rgba8888(playerColors[9])
|
||||||
);
|
);
|
||||||
|
|
||||||
KeyBinds.load();
|
KeyBinds.load();
|
||||||
@@ -123,6 +125,7 @@ public class Control extends Module{
|
|||||||
player = new Player();
|
player = new Player();
|
||||||
player.name = Settings.getString("name");
|
player.name = Settings.getString("name");
|
||||||
player.isAndroid = android;
|
player.isAndroid = android;
|
||||||
|
player.color.set(Settings.getInt("color"));
|
||||||
player.isLocal = true;
|
player.isLocal = true;
|
||||||
|
|
||||||
saves.load();
|
saves.load();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.anuke.mindustry.core;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.utils.IntSet;
|
import com.badlogic.gdx.utils.IntSet;
|
||||||
import com.badlogic.gdx.utils.TimeUtils;
|
import com.badlogic.gdx.utils.TimeUtils;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
@@ -57,6 +58,7 @@ public class NetClient extends Module {
|
|||||||
ConnectPacket c = new ConnectPacket();
|
ConnectPacket c = new ConnectPacket();
|
||||||
c.name = player.name;
|
c.name = player.name;
|
||||||
c.android = android;
|
c.android = android;
|
||||||
|
c.color = Color.rgba8888(player.color);
|
||||||
Net.send(c, SendMode.tcp);
|
Net.send(c, SendMode.tcp);
|
||||||
|
|
||||||
Timers.runTask(dataTimeout, () -> {
|
Timers.runTask(dataTimeout, () -> {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package io.anuke.mindustry.core;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.net.Net.SendMode;
|
import io.anuke.mindustry.net.Net.SendMode;
|
||||||
@@ -16,9 +15,6 @@ import io.anuke.ucore.modules.Module;
|
|||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class NetCommon extends Module {
|
public class NetCommon extends Module {
|
||||||
public static final Color[] colorArray = {Color.ORANGE, Color.SCARLET, Color.LIME, Color.PURPLE,
|
|
||||||
Color.GOLD, Color.PINK, Color.SKY, Color.GOLD, Color.VIOLET,
|
|
||||||
Color.GREEN, Color.CORAL, Color.CYAN, Color.CHARTREUSE};
|
|
||||||
|
|
||||||
public NetCommon(){
|
public NetCommon(){
|
||||||
|
|
||||||
@@ -86,6 +82,8 @@ public class NetCommon extends Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String colorizeName(int id, String name){
|
public String colorizeName(int id, String name){
|
||||||
return name == null ? null : "[#" + colorArray[id % colorArray.length].toString().toUpperCase() + "]" + name;
|
Player player = playerGroup.getByID(id);
|
||||||
|
if(name == null || player == null) return null;
|
||||||
|
return "[#" + player.color.toString().toUpperCase() + "]" + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class NetServer extends Module{
|
|||||||
player.set(world.getSpawnX(), world.getSpawnY());
|
player.set(world.getSpawnX(), world.getSpawnY());
|
||||||
player.interpolator.last.set(player.x, player.y);
|
player.interpolator.last.set(player.x, player.y);
|
||||||
player.interpolator.target.set(player.x, player.y);
|
player.interpolator.target.set(player.x, player.y);
|
||||||
|
player.color.set(packet.color);
|
||||||
connections.put(id, player);
|
connections.put(id, player);
|
||||||
|
|
||||||
if(world.getMap().custom){
|
if(world.getMap().custom){
|
||||||
|
|||||||
@@ -243,9 +243,9 @@ public class Renderer extends RendererModule{
|
|||||||
void drawEnemyMarkers(){
|
void drawEnemyMarkers(){
|
||||||
Graphics.surface(indicatorSurface);
|
Graphics.surface(indicatorSurface);
|
||||||
Draw.color(Color.RED);
|
Draw.color(Color.RED);
|
||||||
for(Enemy enemy : enemyGroup.all()){
|
for(Enemy enemy : enemyGroup.all()) {
|
||||||
|
|
||||||
if(Tmp.r1.setSize(camera.viewportWidth, camera.viewportHeight).setCenter(camera.position.x, camera.position.y).overlaps(enemy.hitbox.getRect(enemy.x, enemy.y))){
|
if (Tmp.r1.setSize(camera.viewportWidth, camera.viewportHeight).setCenter(camera.position.x, camera.position.y).overlaps(enemy.hitbox.getRect(enemy.x, enemy.y))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,6 +253,7 @@ public class Renderer extends RendererModule{
|
|||||||
Angles.translation(angle, Unit.dp.scl(20f));
|
Angles.translation(angle, Unit.dp.scl(20f));
|
||||||
Draw.rect("enemyarrow", camera.position.x + Angles.x(), camera.position.y + Angles.y(), angle);
|
Draw.rect("enemyarrow", camera.position.x + Angles.x(), camera.position.y + Angles.y(), angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.color();
|
Draw.color();
|
||||||
Draw.alpha(0.4f);
|
Draw.alpha(0.4f);
|
||||||
Graphics.flushSurface();
|
Graphics.flushSurface();
|
||||||
@@ -374,6 +375,9 @@ public class Renderer extends RendererModule{
|
|||||||
for(SpawnPoint spawn : world.getSpawns()){
|
for(SpawnPoint spawn : world.getSpawns()){
|
||||||
Lines.dashCircle(spawn.start.worldx(), spawn.start.worldy(), enemyspawnspace);
|
Lines.dashCircle(spawn.start.worldx(), spawn.start.worldy(), enemyspawnspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Draw.color(Color.LIME);
|
||||||
|
Lines.poly(world.getSpawnX(), world.getSpawnY(), 4, 6f, Timers.time()*2f);
|
||||||
|
|
||||||
if(input.breakMode == PlaceMode.holdDelete)
|
if(input.breakMode == PlaceMode.holdDelete)
|
||||||
input.breakMode.draw(tilex, tiley, 0, 0);
|
input.breakMode.draw(tilex, tiley, 0, 0);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package io.anuke.mindustry.entities;
|
package io.anuke.mindustry.entities;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import io.anuke.mindustry.core.NetCommon;
|
|
||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.graphics.Shaders;
|
import io.anuke.mindustry.graphics.Shaders;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
@@ -27,18 +26,18 @@ public class Player extends SyncEntity{
|
|||||||
|
|
||||||
public String name = "name";
|
public String name = "name";
|
||||||
public boolean isAndroid;
|
public boolean isAndroid;
|
||||||
|
public Color color = new Color();
|
||||||
|
|
||||||
//TODO send these.
|
public Weapon weaponLeft = Weapon.blaster;
|
||||||
public transient Weapon weaponLeft = Weapon.blaster;
|
public Weapon weaponRight = Weapon.blaster;
|
||||||
public transient Weapon weaponRight = Weapon.blaster;
|
public Mech mech = Mech.standard;
|
||||||
public transient Mech mech = Mech.standard;
|
|
||||||
|
|
||||||
public float angle;
|
public float angle;
|
||||||
public transient float targetAngle = 0f;
|
public float targetAngle = 0f;
|
||||||
public transient boolean dashing = false;
|
public boolean dashing = false;
|
||||||
|
|
||||||
public transient int clientid;
|
public int clientid;
|
||||||
public transient boolean isLocal = false;
|
public boolean isLocal = false;
|
||||||
|
|
||||||
public Player(){
|
public Player(){
|
||||||
hitbox.setSize(5);
|
hitbox.setSize(5);
|
||||||
@@ -137,11 +136,20 @@ public class Player extends SyncEntity{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
if(!isLocal || isAndroid || ui.chatfrag.chatOpen()){
|
if(!isLocal || isAndroid){
|
||||||
if(!isLocal) interpolate();
|
if(!isLocal) interpolate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tile tile = world.tileWorld(x, y);
|
||||||
|
|
||||||
|
//if player is in solid block
|
||||||
|
if(tile != null && ((tile.floor().liquid && tile.block() == Blocks.air) || tile.solid())){
|
||||||
|
damage(health+1); //die instantly
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ui.chatfrag.chatOpen()) return;
|
||||||
|
|
||||||
dashing = Inputs.keyDown("dash");
|
dashing = Inputs.keyDown("dash");
|
||||||
|
|
||||||
float speed = dashing ? (debug ? Player.dashSpeed * 5f : Player.dashSpeed) : Player.speed;
|
float speed = dashing ? (debug ? Player.dashSpeed * 5f : Player.dashSpeed) : Player.speed;
|
||||||
@@ -150,13 +158,6 @@ public class Player extends SyncEntity{
|
|||||||
health ++;
|
health ++;
|
||||||
|
|
||||||
health = Mathf.clamp(health, -1, maxhealth);
|
health = Mathf.clamp(health, -1, maxhealth);
|
||||||
|
|
||||||
Tile tile = world.tileWorld(x, y);
|
|
||||||
|
|
||||||
//if player is in solid block
|
|
||||||
if(tile != null && ((tile.floor().liquid && tile.block() == Blocks.air) || tile.solid())){
|
|
||||||
damage(health+1); //die instantly
|
|
||||||
}
|
|
||||||
|
|
||||||
vector.set(0, 0);
|
vector.set(0, 0);
|
||||||
|
|
||||||
@@ -219,6 +220,7 @@ public class Player extends SyncEntity{
|
|||||||
buffer.put(weaponLeft.id);
|
buffer.put(weaponLeft.id);
|
||||||
buffer.put(weaponRight.id);
|
buffer.put(weaponRight.id);
|
||||||
buffer.put(isAndroid ? 1 : (byte)0);
|
buffer.put(isAndroid ? 1 : (byte)0);
|
||||||
|
buffer.putInt(Color.rgba8888(color));
|
||||||
buffer.putFloat(x);
|
buffer.putFloat(x);
|
||||||
buffer.putFloat(y);
|
buffer.putFloat(y);
|
||||||
}
|
}
|
||||||
@@ -232,6 +234,7 @@ public class Player extends SyncEntity{
|
|||||||
weaponLeft = (Weapon) Upgrade.getByID(buffer.get());
|
weaponLeft = (Weapon) Upgrade.getByID(buffer.get());
|
||||||
weaponRight = (Weapon) Upgrade.getByID(buffer.get());
|
weaponRight = (Weapon) Upgrade.getByID(buffer.get());
|
||||||
isAndroid = buffer.get() == 1;
|
isAndroid = buffer.get() == 1;
|
||||||
|
color.set(buffer.getInt());
|
||||||
x = buffer.getFloat();
|
x = buffer.getFloat();
|
||||||
y = buffer.getFloat();
|
y = buffer.getFloat();
|
||||||
}
|
}
|
||||||
@@ -282,6 +285,6 @@ public class Player extends SyncEntity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Color getColor(){
|
public Color getColor(){
|
||||||
return NetCommon.colorArray[id % NetCommon.colorArray.length];
|
return color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
|
|
||||||
Tile tile = world.tile(x, y);
|
Tile tile = world.tile(x, y);
|
||||||
|
|
||||||
if(tile == null) return false;
|
if(tile == null || (isSpawnPoint(tile) && (type.solidifes || type.solid))) return false;
|
||||||
|
|
||||||
if(!type.isMultiblock() && control.tutorial().active() &&
|
if(!type.isMultiblock() && control.tutorial().active() &&
|
||||||
control.tutorial().showBlock()){
|
control.tutorial().showBlock()){
|
||||||
@@ -142,7 +142,7 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
for(int dx = 0; dx < type.width; dx ++){
|
for(int dx = 0; dx < type.width; dx ++){
|
||||||
for(int dy = 0; dy < type.height; dy ++){
|
for(int dy = 0; dy < type.height; dy ++){
|
||||||
Tile other = world.tile(x + dx + offsetx, y + dy + offsety);
|
Tile other = world.tile(x + dx + offsetx, y + dy + offsety);
|
||||||
if(other == null || other.block() != Blocks.air){
|
if(other == null || other.block() != Blocks.air || isSpawnPoint(other)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,9 +152,13 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
if(tile.block() != type && type.canReplace(tile.block()) && tile.block().isMultiblock() == type.isMultiblock()){
|
if(tile.block() != type && type.canReplace(tile.block()) && tile.block().isMultiblock() == type.isMultiblock()){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return tile != null && tile.block() == Blocks.air;
|
return tile.block() == Blocks.air;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSpawnPoint(Tile tile){
|
||||||
|
return tile != null && tile.x == world.getCore().x && tile.y == world.getCore().y - 2;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean validBreak(int x, int y){
|
public boolean validBreak(int x, int y){
|
||||||
Tile tile = world.tile(x, y);
|
Tile tile = world.tile(x, y);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import java.io.IOException;
|
|||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Net{
|
public class Net{
|
||||||
public static final int version = 14;
|
public static final int version = 15;
|
||||||
|
|
||||||
private static boolean server;
|
private static boolean server;
|
||||||
private static boolean active;
|
private static boolean active;
|
||||||
@@ -94,6 +94,11 @@ public class Net{
|
|||||||
public static Array<NetConnection> getConnections(){
|
public static Array<NetConnection> getConnections(){
|
||||||
return (Array<NetConnection>)serverProvider.getConnections();
|
return (Array<NetConnection>)serverProvider.getConnections();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**Returns a connection by ID*/
|
||||||
|
public static NetConnection getConnection(int id){
|
||||||
|
return serverProvider.getByID(id);
|
||||||
|
}
|
||||||
|
|
||||||
/**Send an object to all connected clients, or to the server if this is a client.*/
|
/**Send an object to all connected clients, or to the server if this is a client.*/
|
||||||
public static void send(Object object, SendMode mode){
|
public static void send(Object object, SendMode mode){
|
||||||
@@ -261,6 +266,8 @@ public class Net{
|
|||||||
void close();
|
void close();
|
||||||
/**Return all connected users.*/
|
/**Return all connected users.*/
|
||||||
Array<? extends NetConnection> getConnections();
|
Array<? extends NetConnection> getConnections();
|
||||||
|
/**Returns a connection by ID.*/
|
||||||
|
NetConnection getByID(int id);
|
||||||
/**Kick a certain connection.*/
|
/**Kick a certain connection.*/
|
||||||
void kick(int connection, KickReason reason);
|
void kick(int connection, KickReason reason);
|
||||||
/**Returns the ping for a certain connection.*/
|
/**Returns the ping for a certain connection.*/
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public class Packets {
|
|||||||
public int version;
|
public int version;
|
||||||
public String name;
|
public String name;
|
||||||
public boolean android;
|
public boolean android;
|
||||||
|
public int color;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuffer buffer) {
|
public void write(ByteBuffer buffer) {
|
||||||
@@ -59,6 +60,7 @@ public class Packets {
|
|||||||
buffer.put((byte)name.getBytes().length);
|
buffer.put((byte)name.getBytes().length);
|
||||||
buffer.put(name.getBytes());
|
buffer.put(name.getBytes());
|
||||||
buffer.put(android ? (byte)1 : 0);
|
buffer.put(android ? (byte)1 : 0);
|
||||||
|
buffer.putInt(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -69,6 +71,7 @@ public class Packets {
|
|||||||
buffer.get(bytes);
|
buffer.get(bytes);
|
||||||
name = new String(bytes);
|
name = new String(bytes);
|
||||||
android = buffer.get() == 1;
|
android = buffer.get() == 1;
|
||||||
|
color = buffer.getInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ public class ServerDebug {
|
|||||||
build.append(player.clientid);
|
build.append(player.clientid);
|
||||||
build.append(" / player '");
|
build.append(" / player '");
|
||||||
build.append(player.name);
|
build.append(player.name);
|
||||||
|
build.append(" android: ");
|
||||||
|
build.append(player.isAndroid);
|
||||||
build.append("'\n");
|
build.append("'\n");
|
||||||
|
|
||||||
for(Class<?> type : map.orderedKeys()){
|
for(Class<?> type : map.orderedKeys()){
|
||||||
|
|||||||
44
core/src/io/anuke/mindustry/ui/dialogs/ColorPickDialog.java
Normal file
44
core/src/io/anuke/mindustry/ui/dialogs/ColorPickDialog.java
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package io.anuke.mindustry.ui.dialogs;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import io.anuke.ucore.function.Consumer;
|
||||||
|
import io.anuke.ucore.scene.ui.Dialog;
|
||||||
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.player;
|
||||||
|
import static io.anuke.mindustry.Vars.playerColors;
|
||||||
|
|
||||||
|
public class ColorPickDialog extends Dialog{
|
||||||
|
private Consumer<Color> cons;
|
||||||
|
|
||||||
|
public ColorPickDialog(){
|
||||||
|
super("", "dialog");
|
||||||
|
build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void build(){
|
||||||
|
Table table = new Table();
|
||||||
|
content().add(table);
|
||||||
|
|
||||||
|
for(int i = 0; i < playerColors.length; i ++){
|
||||||
|
Color color = playerColors[i];
|
||||||
|
|
||||||
|
ImageButton button = table.addImageButton("white", "toggle", 34, () -> {
|
||||||
|
cons.accept(color);
|
||||||
|
hide();
|
||||||
|
}).size(44, 48).pad(0).padBottom(-5.1f).get();
|
||||||
|
button.setChecked(player.getColor().equals(color));
|
||||||
|
button.getStyle().imageUpColor = color;
|
||||||
|
|
||||||
|
if(i%4 == 3){
|
||||||
|
table.row();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show(Consumer<Color> cons){
|
||||||
|
this.cons = cons;
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,17 @@
|
|||||||
package io.anuke.mindustry.ui.dialogs;
|
package io.anuke.mindustry.ui.dialogs;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.ucore.core.Settings;
|
import io.anuke.ucore.core.Settings;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
import io.anuke.ucore.util.Bundles;
|
import io.anuke.ucore.util.Bundles;
|
||||||
import io.anuke.ucore.util.Strings;
|
import io.anuke.ucore.util.Strings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.player;
|
||||||
import static io.anuke.mindustry.Vars.ui;
|
import static io.anuke.mindustry.Vars.ui;
|
||||||
|
|
||||||
//TODO add port specification
|
//TODO add port specification
|
||||||
@@ -29,6 +32,15 @@ public class HostDialog extends FloatingDialog{
|
|||||||
Settings.save();
|
Settings.save();
|
||||||
ui.listfrag.rebuild();
|
ui.listfrag.rebuild();
|
||||||
}).grow().pad(8);
|
}).grow().pad(8);
|
||||||
|
|
||||||
|
ImageButton button = t.addImageButton("white", 40, () -> {
|
||||||
|
new ColorPickDialog().show(color -> {
|
||||||
|
player.color.set(color);
|
||||||
|
Settings.putInt("color", Color.rgba8888(color));
|
||||||
|
Settings.save();;
|
||||||
|
});
|
||||||
|
}).size(50f, 54f).get();
|
||||||
|
button.update(() -> button.getStyle().imageUpColor = player.getColor());
|
||||||
}).width(w).height(70f).pad(4);
|
}).width(w).height(70f).pad(4);
|
||||||
|
|
||||||
content().row();
|
content().row();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.anuke.mindustry.ui.dialogs;
|
package io.anuke.mindustry.ui.dialogs;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.io.Platform;
|
import io.anuke.mindustry.io.Platform;
|
||||||
@@ -9,6 +10,7 @@ import io.anuke.ucore.core.Settings;
|
|||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.scene.style.Drawable;
|
import io.anuke.ucore.scene.style.Drawable;
|
||||||
import io.anuke.ucore.scene.ui.Dialog;
|
import io.anuke.ucore.scene.ui.Dialog;
|
||||||
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||||
import io.anuke.ucore.scene.ui.TextButton;
|
import io.anuke.ucore.scene.ui.TextButton;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
@@ -16,6 +18,7 @@ import io.anuke.ucore.util.Bundles;
|
|||||||
import io.anuke.ucore.util.Log;
|
import io.anuke.ucore.util.Log;
|
||||||
import io.anuke.ucore.util.Strings;
|
import io.anuke.ucore.util.Strings;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.player;
|
||||||
import static io.anuke.mindustry.Vars.ui;
|
import static io.anuke.mindustry.Vars.ui;
|
||||||
|
|
||||||
public class JoinDialog extends FloatingDialog {
|
public class JoinDialog extends FloatingDialog {
|
||||||
@@ -40,7 +43,7 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
Platform.instance.addDialog(add.content().addField(Settings.getString("ip"), text ->{
|
Platform.instance.addDialog(add.content().addField(Settings.getString("ip"), text ->{
|
||||||
Settings.putString("ip", text);
|
Settings.putString("ip", text);
|
||||||
Settings.save();
|
Settings.save();
|
||||||
}).size(340f, 54f).get(), 100);
|
}).size(320f, 54f).get(), 100);
|
||||||
|
|
||||||
add.content().row();
|
add.content().row();
|
||||||
add.buttons().defaults().size(140f, 60f).pad(4f);
|
add.buttons().defaults().size(140f, 60f).pad(4f);
|
||||||
@@ -173,6 +176,16 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
Settings.put("name", text);
|
Settings.put("name", text);
|
||||||
Settings.save();
|
Settings.save();
|
||||||
}).grow().pad(8);
|
}).grow().pad(8);
|
||||||
|
|
||||||
|
ImageButton button = t.addImageButton("white", 40, () -> {
|
||||||
|
new ColorPickDialog().show(color -> {
|
||||||
|
player.color.set(color);
|
||||||
|
Settings.putInt("color", Color.rgba8888(color));
|
||||||
|
Settings.save();
|
||||||
|
});
|
||||||
|
}).size(50f, 54f).get();
|
||||||
|
button.update(() -> button.getStyle().imageUpColor = player.getColor());
|
||||||
|
|
||||||
}).width(w).height(70f).pad(4);
|
}).width(w).height(70f).pad(4);
|
||||||
content().row();
|
content().row();
|
||||||
content().add(pane).width(w).pad(0);
|
content().add(pane).width(w).pad(0);
|
||||||
|
|||||||
@@ -114,9 +114,25 @@ public class KryoServer implements ServerProvider {
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KryoConnection getByID(int id){
|
||||||
|
for(int i = 0; i < connections.size(); i ++){
|
||||||
|
KryoConnection con = connections.get(i);
|
||||||
|
if(con.id == id){
|
||||||
|
return con;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void kick(int connection, KickReason reason) {
|
public void kick(int connection, KickReason reason) {
|
||||||
KryoConnection con = getByID(connection);
|
KryoConnection con = getByID(connection);
|
||||||
|
if(con == null){
|
||||||
|
Log.err("Cannot kick unknown player!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
KickPacket p = new KickPacket();
|
KickPacket p = new KickPacket();
|
||||||
p.reason = reason;
|
p.reason = reason;
|
||||||
@@ -277,17 +293,6 @@ public class KryoServer implements ServerProvider {
|
|||||||
Gdx.app.postRunnable(() -> { throw new RuntimeException(e);});
|
Gdx.app.postRunnable(() -> { throw new RuntimeException(e);});
|
||||||
}
|
}
|
||||||
|
|
||||||
KryoConnection getByID(int id){
|
|
||||||
for(int i = 0; i < connections.size(); i ++){
|
|
||||||
KryoConnection con = connections.get(i);
|
|
||||||
if(con.id == id){
|
|
||||||
return con;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
KryoConnection getByKryoID(int id){
|
KryoConnection getByKryoID(int id){
|
||||||
for(int i = 0; i < connections.size(); i ++){
|
for(int i = 0; i < connections.size(); i ++){
|
||||||
KryoConnection con = connections.get(i);
|
KryoConnection con = connections.get(i);
|
||||||
@@ -407,7 +412,7 @@ public class KryoServer implements ServerProvider {
|
|||||||
if (k == null) return;
|
if (k == null) return;
|
||||||
|
|
||||||
if(message.equals("_ping_")){
|
if(message.equals("_ping_")){
|
||||||
conn.send("---" + connections.size() + "|" + Vars.player.name);
|
conn.send("---" + Vars.playerGroup.size() + "|" + (Vars.headless ? "Server" : Vars.player.name));
|
||||||
connections.remove(k);
|
connections.remove(k);
|
||||||
}else {
|
}else {
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class ServerControl extends Module {
|
|||||||
if(shuffle) {
|
if(shuffle) {
|
||||||
Map previous = world.getMap();
|
Map previous = world.getMap();
|
||||||
Map map = previous;
|
Map map = previous;
|
||||||
while(map == previous) map = world.maps().getDefaultMaps().random();
|
while(map == previous || !map.visible) map = world.maps().getDefaultMaps().random();
|
||||||
|
|
||||||
info("Selected next map to be {0}.", map.name);
|
info("Selected next map to be {0}.", map.name);
|
||||||
state.set(State.playing);
|
state.set(State.playing);
|
||||||
@@ -172,7 +172,7 @@ public class ServerControl extends Module {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
netCommon.sendMessage("[pink][[Server]:[] " + arg[0]);
|
netCommon.sendMessage("[DARK_GRAY][[Server]:[] " + arg[0]);
|
||||||
info("&lyServer: &lb{0}", arg[0]);
|
info("&lyServer: &lb{0}", arg[0]);
|
||||||
}).mergeArgs();
|
}).mergeArgs();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user