Commit 942d79d7 authored by Guillaume Hocquet's avatar Guillaume Hocquet

Merge remote-tracking branch 'origin/master'

parents c1bcdfc1 6dfd5c4a
......@@ -50,7 +50,7 @@ public class GameContent implements Serializable{
* Relayer dmr = Relayers.addNewRelayer(2,AItest,this);
* AIControler.add(gameContent,dmr);
*/
System.out.println("One gameContent created");
System.out.println("GameContent class: One gameContent created");
}
public Map getMap() {
......
......@@ -23,10 +23,9 @@ public class GameStarter {
static public void startGameSinglePlayer()
{
NetworkConnection<NetworkObject>[] localConnections= LocalConnection.initiate();
NetworkConnection<NetworkObject>[] localConnections= LocalConnection.createNew();
NetworkConnection<NetworkObject> serverConnection = localConnections[0];
NetworkConnection<NetworkObject> clientConnection = localConnections[1];
ServerLoop dummyServerLoop=new ServerLoop(serverConnection);
DummyLocalGameLoop.getInstance().setNetworkConnection(clientConnection);
......@@ -36,6 +35,7 @@ public class GameStarter {
if (!DummyLocalGameLoop.getInstance().startedBefore())
DummyLocalGameLoop.getInstance().start();
//this is start and not run like in the DummyServer, because here we are dealing with a thread
ServerLoop dummyServerLoop=new ServerLoop(serverConnection);
dummyServerLoop.start();
//let the loop run now!
DummyLocalGameLoop.getInstance().startGame();
......
......@@ -35,7 +35,9 @@ public abstract class GraphicsMasterAbstraction {
SINGLEPLAYER_GAME_CREATION,
MULTIPLAYER_CHARACTER_CHOICE,
SINGLEPLAYER_CHARACTER_CHOICE,
GAME_OVER}
GAME_OVER,
LOST_CONNECTION
}
//This map indicates to graphicsMaster which guiPanel is associated to each GUIState, it is filled in Graphicsmaster's constructor
protected HashMap<GUIStates, PanelAbstraction> mapGUIStatesToGUIPanel = new HashMap<>();
//The current state of the GUI
......
......@@ -11,5 +11,6 @@ public interface LoungePanelAbstraction extends MenuPanelAbstraction {
public void chooseCharacterButtonAction();
public void backButtonAction();
public void playButtonAction();
}
......@@ -24,5 +24,6 @@ public class LoungePanelAbstractionController extends MenuPanelAbstractionContro
public void backButtonPressed(){
this.lounge_panel.backButtonAction();
}
public void playButtonPressed(){this.lounge_panel.playButtonAction();}
}
......@@ -54,6 +54,7 @@ public class GraphicsMaster extends GraphicsMasterAbstraction {
mapGUIStatesToGUIPanel.put(GUIStates.SINGLEPLAYER_GAME_CREATION, new SinglePlayer_GameCreationPanel(this));
mapGUIStatesToGUIPanel.put(GUIStates.SINGLEPLAYER_CHARACTER_CHOICE, new SinglePlayer_CharacterChoicePanel(this));
mapGUIStatesToGUIPanel.put(GUIStates.SINGLEPLAYER_LOADGAME, new SinglePlayer_LoadGamePanel(this));
mapGUIStatesToGUIPanel.put(GUIStates.LOST_CONNECTION, new LostConnectionPanel(this));
mapGUIStatesToGUIPanel.put(GUIStates.GAME_OVER, new GameOverPanel(this));
}
......
package graphics.guiSkeleton.guiPanel.menuPanel;
import graphics.guiSkeleton.GUIColorsAndFonts;
import graphics.guiSkeleton.GraphicsMaster;
import graphics.guiSkeleton.guiPanel.menuPanel.facilities.ButtonMaker;
import graphics.guiSkeleton.guiPanel.menuPanel.facilities.MenuPanel;
import graphics.ingame_input_listener.Input;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by bogdanbear on 02/01/2016.
*/
public class LostConnectionPanel extends MenuPanel{
public LostConnectionPanel(GraphicsMaster graphicsMaster) {
super(graphicsMaster);
JLabel sorryLabel = new JLabel("Connection Lost...");
sorryLabel.setFont(GUIColorsAndFonts.smallFont1);
sorryLabel.setForeground(GUIColorsAndFonts.fontColor1);
setTitlePanel("Connection Lost");
addToCentralColumn(sorryLabel,1,1);
addToCentralColumn(ButtonMaker.makeButton("Return to main menu", returnButtonActionListener),1,1);
}
private ActionListener returnButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
getGraphicsMaster().changeGUIStateTo(GraphicsMaster.GUIStates.MAIN_MENU);
}
};
@Override
public void initialise() {
}
@Override
public void finalise() {
}
@Override
public void keyPressedHandler(Input e) {
}
@Override
public void keyReleasedHandler(Input e) {
}
@Override
public void keyTypedHandler(Input e) {
}
}
package graphics.guiSkeleton.guiPanel.menuPanel.loungePanel;
import graphics.graphical_abstraction.GraphicsMasterAbstraction;
import graphics.graphical_abstraction.panel.menu.loungePanel.LoungePanelAbstraction;
import graphics.graphical_abstraction.panel.menu.loungePanel.LoungePanelAbstractionController;
import graphics.guiSkeleton.guiPanel.menuPanel.facilities.ButtonMaker;
......@@ -31,6 +32,7 @@ public class LoungePanel extends MenuPanel implements LoungePanelAbstraction {
addToCentralColumn(new PlayerInformationList_SubPanel(lounge), 1, 1);
addToCentralColumn(ButtonMaker.makeButton("Choose Character", chooseCharacterButton_ActionListener), 1, 1);
addToCentralColumn(ButtonMaker.makeButton("Play", playButton_ActionListener), 1, 1);
addToCentralColumn(ButtonMaker.makeButton("back", backButton_ActionListener), 1, 1);
lounge.addPlayer(new PlayerInformation("YourName"));
......@@ -50,6 +52,13 @@ public class LoungePanel extends MenuPanel implements LoungePanelAbstraction {
}
};
private ActionListener playButton_ActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
controller.playButtonPressed();
}
};
@Override
public void keyPressedHandler(Input e) {
......@@ -84,4 +93,10 @@ public class LoungePanel extends MenuPanel implements LoungePanelAbstraction {
public void backButtonAction() {
getGraphicsMaster().changeGUIStateTo(GraphicsMaster.GUIStates.MULTIPLAYER_MENU);
}
@Override
public void playButtonAction() {
getGraphicsMaster().changeGUIStateTo(GraphicsMaster.GUIStates.LOST_CONNECTION);
}
}
......@@ -25,4 +25,9 @@ public class LoungePanelTerminal extends MenuPanelTerminal implements LoungePane
public void backButtonAction() {
}
@Override
public void playButtonAction() {
}
}
......@@ -84,7 +84,7 @@ public class LocalConnection<E extends NetworkObject> extends NetworkConnection<
* Will create two objects LocalConnection : one for the server part and one for the client part.
* @return the two LocalConnection, the first is the server one and the second is the client one.
*/
public static NetworkConnection<NetworkObject>[] initiate() {
public static NetworkConnection<NetworkObject>[] createNew() {
LocalConnection<NetworkObject>[] bothConnections = new LocalConnection[2];
BlockingDeque<NetworkObject> incomingForServer = new LinkedBlockingDeque<>();
BlockingDeque<NetworkObject> incomingForClient = new LinkedBlockingDeque<>();
......
......@@ -11,14 +11,14 @@ import static org.junit.Assert.assertEquals;
/**
* Class for JUnits Test for the class LocalConnection.
* Created by mymi on 19/12/15.
* To begin, we use LocalConnection.initiate() to create a server and a client.
* To begin, we use LocalConnection.createNew() to create a server and a client.
* Then we test sendEvent on the server side and receiveEvent on the client side.
* The second function will do the opposite.
* Finally, we will test initiateConnectionEnd (TODO)
*/
@SuppressWarnings("unchecked")
public class LocalConnectionTest{
NetworkConnection[] localConnections= LocalConnection.initiate();
NetworkConnection[] localConnections= LocalConnection.createNew();
private NetworkConnection serverConnection = localConnections[0];
private NetworkConnection clientConnection = localConnections[1];
private NetworkObject event = new ObjectForTest();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment