Skip to content

Commit

Permalink
Made use of team colors for selection screen
Browse files Browse the repository at this point in the history
  • Loading branch information
David52920 committed Mar 12, 2021
1 parent 986e1a5 commit dd537f1
Show file tree
Hide file tree
Showing 18 changed files with 360 additions and 266 deletions.
7 changes: 7 additions & 0 deletions client-core/src/com/benberi/cadesim/BlockadeSimulator.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.benberi.cadesim;

import java.awt.Window;
import java.util.Arrays;
import java.util.Timer;

import javax.swing.JWindow;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.benberi.cadesim.util.ScreenEnum;
Expand All @@ -17,6 +21,9 @@ public class BlockadeSimulator extends Game{

@Override
public void create () {
Arrays.asList(Window.getWindows()).stream()
.filter(window -> window instanceof JWindow)
.forEach(window -> window.setVisible(false));
VisUI.setSkipGdxVersionCheck(true);
VisUI.load();
context = new GameContext(this);
Expand Down
57 changes: 39 additions & 18 deletions client-core/src/com/benberi/cadesim/GameContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ public void setTurnDuration(int value) {
public List<String> admins;
public Map<Integer, String> serverInfo = new HashMap<Integer, String>();
public String currentServerRoom = "";
public String userName;
public String accountName;
public String accountName = "";
public String hostURL;
public int myVesselType;
public Team myTeam;
Expand Down Expand Up @@ -355,7 +354,6 @@ public void sendLoginPacket(String accountName, String display, int ship, int te
packet.setName(display);
packet.setShip(ship);
packet.setTeam(team);
System.out.println("Login:" + display);
sendPacket(packet);
shipId = ship;
}
Expand Down Expand Up @@ -452,14 +450,37 @@ public String handleLoginResponse(int response) {
case LoginResponsePacket.BAD_VERSION:
return "Outdated client.";
case LoginResponsePacket.NAME_IN_USE:
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
ScreenManager.getInstance().showScreen(ScreenEnum.SELECTION, context);
}

});
return "Display name already in use.";
case LoginResponsePacket.BAD_SHIP:
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
ScreenManager.getInstance().showScreen(ScreenEnum.SELECTION, context);
}

});
return "The selected ship is not allowed.";
case LoginResponsePacket.SERVER_FULL:
ScreenManager.getInstance().showScreen(ScreenEnum.LOGIN, context);
return "The server is full.";
case LoginResponsePacket.BAD_NAME:
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
ScreenManager.getInstance().showScreen(ScreenEnum.SELECTION, context);
}

});
return "That ship name is not allowed.";
default:
ScreenManager.getInstance().showScreen(ScreenEnum.LOGIN, context);
return "Unknown login failure.";
}

Expand Down Expand Up @@ -602,7 +623,7 @@ public void disconnect() {
setConnected(false);
setIsInLobby(true);
getServerChannel().disconnect();
ScreenManager.getInstance().showScreen(ScreenEnum.LOGIN, this);
ScreenManager.getInstance().showScreen(ScreenEnum.SELECTION, this);
Gdx.graphics.setTitle("GC:" + Constants.VERSION);
System.out.println("Client disconnected.");
getLobbyScreen().setStatusMessage("Client: " + "Client Disconnected.");
Expand Down Expand Up @@ -641,16 +662,16 @@ public void handleServersideDisconnect() {
getServerChannel().disconnect();
getLobbyScreen().setStatusMessage("Server: " + "Server Disconnected.");
}

Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
ScreenManager.getInstance().showScreen(ScreenEnum.LOGIN, context);
graphics.setResizable(true);
getLobbyScreen().setStatusMessage("Server: " + "Server Disconnected.");
graphics.setTitle("GC: v" + Constants.VERSION);
}
});
//
// Gdx.app.postRunnable(new Runnable() {
// @Override
// public void run() {
// ScreenManager.getInstance().showScreen(ScreenEnum.LOGIN, context);
// graphics.setResizable(true);
// getLobbyScreen().setStatusMessage("Server: " + "Server Disconnected.");
// graphics.setTitle("GC: v" + Constants.VERSION);
// }
// });
}

public GameAssetManager getAssetObject() {
Expand Down Expand Up @@ -814,12 +835,12 @@ public int getTeam() {
return this.myTeam.getID();
}

public void setUserName(String name) {
userName = name;
public void setVesselName(String name) {
myVessel = name;
}

public String getUserName() {
return userName;
public String getVesselName() {
return myVessel;
}

public void setAccountName(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ protected void initChannel(SocketChannel socketChannel) throws Exception {
}
});
ChannelFuture future = connect(ip,Constants.PROTOCOL_PORT);
System.out.println(Constants.PROTOCOL_PORT);
future.addListener(new ChannelFutureListener() {
@Override public void operationComplete(ChannelFuture future) throws Exception{
if(!future.isSuccess()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void render(float delta) {
if (connectTask != null && connectTask.isDone() && context.getManager().update() && !isConnected) {
isConnected = true;
try {
context.connect(context.getAccountName(), context.getUserName(), context.getHostURL(), context.getVesselType(), context.getTeam());
context.connect(context.getAccountName(), context.getVesselName(), context.getHostURL(), context.getVesselType(), context.getTeam());
} catch (UnknownHostException e) {
e.printStackTrace();
}
Expand Down
Loading

0 comments on commit dd537f1

Please sign in to comment.