diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 6237e2a..3203e86 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -10,11 +10,12 @@
-
-
+
+
+
+
-
@@ -22,17 +23,35 @@
+
+
+
+
+
-
+
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -44,7 +63,7 @@
-
+
com.texttwist.client.*
@@ -55,11 +74,11 @@
-
-
+
+
-
-
+
+
@@ -67,11 +86,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -80,96 +175,25 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -186,36 +210,36 @@
- getWords
- ge
- getWindow
- getWindows
- getWindowsP
- getWindowsPo
- getWindowsPos
- getWindowsPosi
- A
- App.app
- App.ap
- ap
- app
- Wai
- Waito
- Wait
- WaitF
- WaitFor
- WaitForP
- WaitForPla
- waitForP
- waitForPl
- waitForPla
- w
- waitForS
- waitForSc
- waitForScor
- waitForScore
- waitFor
- rank
+ multicastSock
+ multicastSocke
+ multicastSocket
+ T
+ TTC
+ TTCi
+ TTCir
+ TTCirclC
+ TTCircl
+ TTCircle
+ TTCircleC
+ C
+ Callab
+ Callable
+ Callable<
+ isPartia
+ highscoresPa
+ j
+ joinT
+ joinTimeou
+ jo
+ joinTim
+ joinTime
+ joinTimeo
+ joinTimeout
+ joinTimeoutjoin
+ TI
+ TIMEOUT
+ letters
+ words
C:\Users\loke\TextTwist\out\production
@@ -354,57 +378,57 @@
@@ -424,10 +448,10 @@
-
-
-
-
+
+
+
+
@@ -935,8 +959,12 @@
-
-
+
+
+
+
+
+
@@ -946,12 +974,8 @@
-
-
-
-
-
-
+
+
@@ -1447,47 +1471,47 @@
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
@@ -1498,7 +1522,7 @@
-
+
@@ -1507,142 +1531,160 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1655,196 +1697,295 @@
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1853,78 +1994,30 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/Client/src/com/texttwist/client/App.java b/Client/src/com/texttwist/client/App.java
index b9e9398..de9185d 100644
--- a/Client/src/com/texttwist/client/App.java
+++ b/Client/src/com/texttwist/client/App.java
@@ -3,6 +3,10 @@ package com.texttwist.client;
import com.texttwist.client.services.GameService;
import com.texttwist.client.services.AuthService;
import com.texttwist.client.pages.HomePage;
+import com.texttwist.client.services.NotificationClientService;
+import constants.Config;
+import interfaces.INotificationClient;
+import interfaces.INotificationServer;
import models.Session;
import utilities.Logger;
import javax.swing.*;
@@ -10,6 +14,16 @@ import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.MulticastSocket;
+import java.nio.channels.DatagramChannel;
+import java.nio.channels.SocketChannel;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
/**
* Author: Lorenzo Iovino on 13/06/2017.
@@ -17,12 +31,22 @@ import java.lang.management.ManagementFactory;
* Here is possible to declare services globally accessible.
*/
public class App extends JFrame {
+
+ private static InetSocketAddress clientTCPSocketAddress = new InetSocketAddress(Config.GameServerURI, Config.GameServerPort);
+ public static InetSocketAddress clientUDPSocketAddress = new InetSocketAddress(Config.WordsReceiverServerURI, Config.WordsReceiverServerPort);
+ private static InetAddress clientMulticastSocketAddress;
+
public static AuthService authService;
public static GameService gameService;
public static Logger logger;
public static Session session;
public static JFrame app;
+ public static INotificationClient notificationStub;
+ public static MulticastSocket clientMulticast;
+ public static SocketChannel clientTCP;
+ public static DatagramChannel clientUDP;
+
public App() throws IOException {
setPreferredSize( new Dimension( 640, 480 ));
setSize(new Dimension(640,480));
@@ -53,6 +77,54 @@ public class App extends JFrame {
new HomePage(this);
}
+ public static void registerForNotifications() throws RemoteException, NotBoundException {
+
+ Registry registry = LocateRegistry.getRegistry(Config.NotificationServerStubPort);
+ INotificationClient callbackObj = new NotificationClientService();
+ notificationStub = (INotificationClient) UnicastRemoteObject.exportObject(callbackObj, 0);
+ INotificationServer notificationServer = (INotificationServer) registry.lookup(Config.NotificationServerName);
+ notificationServer.registerForCallback(notificationStub);
+ }
+
+ public static void openClientTCPSocket(){
+ try {
+ clientTCP = SocketChannel.open(clientTCPSocketAddress);
+ clientTCP.configureBlocking(false);
+ } catch (IOException e) {
+ logger.write("APP: Can't open client TCP socket!");
+ }
+ }
+
+ public static void openClientMulticastSocket(Integer multicastId){
+ try {
+ App.gameService.setMulticastId(multicastId);
+ clientMulticastSocketAddress = InetAddress.getByName(Config.ScoreMulticastServerURI);
+ clientMulticast = new MulticastSocket(gameService.multicastId);
+ clientMulticast.joinGroup(clientMulticastSocketAddress);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void closeClientMulticastSocket(){
+ //Leave group and close multicast socket
+ try {
+ App.clientMulticast.leaveGroup(InetAddress.getByName(Config.ScoreMulticastServerURI));
+ App.clientMulticast.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void openClientUDPSocket(){
+ try {
+ clientUDP = DatagramChannel.open();
+ clientUDP.bind(null);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
public static Point getWindowsPosition(){
return new Point(app.getX(), app.getY());
}
diff --git a/Client/src/com/texttwist/client/controllers/GameController.java b/Client/src/com/texttwist/client/controllers/GameController.java
index b70eeb0..f184279 100644
--- a/Client/src/com/texttwist/client/controllers/GameController.java
+++ b/Client/src/com/texttwist/client/controllers/GameController.java
@@ -3,10 +3,13 @@ package com.texttwist.client.controllers;
import com.texttwist.client.App;
import com.texttwist.client.pages.GamePage;
import com.texttwist.client.tasks.SendWords;
-import com.texttwist.client.tasks.StartGame;
import com.texttwist.client.tasks.WaitForPlayers;
import com.texttwist.client.tasks.WaitForScore;
+
import javax.swing.*;
+import java.util.concurrent.Callable;
+
+import static com.texttwist.client.App.gameService;
/**
* Author: Lorenzo Iovino on 27/06/2017.
@@ -14,26 +17,42 @@ import javax.swing.*;
*/
public class GameController {
- private GamePage game;
-
- public GameController(GamePage game){
- this.game = game;
- }
-
- public SwingWorker waitForPlayers(SwingWorker callback) {
- return new WaitForPlayers(callback);
- }
+ private GamePage gamePage;
private SwingWorker waitForScore(SwingWorker callback){
return new WaitForScore(callback);
}
- public SwingWorker sendWords(SwingWorker callback){
- return new SendWords(App.gameService.words, waitForScore(callback));
+ private SwingWorker sendWords(SwingWorker callback){
+ return new SendWords(gameService.words, waitForScore(callback));
}
- public SwingWorker startGame() {
- return new StartGame(App.gameService.letters, game);
+ public GameController(GamePage gamePage){
+ this.gamePage = gamePage;
}
+ public SwingWorker waitForPlayers(Callable callback) {
+ return new WaitForPlayers(callback);
+ }
+
+ public Callable startGame = new Callable() {
+ @Override
+ public Void call() throws Exception {
+ App.gameService.start();
+ gamePage.showGameIsReadyAlert();
+ return null;
+ }
+ };
+
+ public DefaultListModel getLetters() {
+ return gameService.getLetters();
+ }
+
+ public SwingWorker timeIsOver(SwingWorker callback) {
+ return sendWords(callback);
+ }
+
+ public DefaultListModel getWords(){
+ return gameService.getWords();
+ }
}
diff --git a/Client/src/com/texttwist/client/controllers/HighscoresController.java b/Client/src/com/texttwist/client/controllers/HighscoresController.java
index dc3e12d..275faed 100644
--- a/Client/src/com/texttwist/client/controllers/HighscoresController.java
+++ b/Client/src/com/texttwist/client/controllers/HighscoresController.java
@@ -1,10 +1,13 @@
package com.texttwist.client.controllers;
-import com.texttwist.client.App;
import com.texttwist.client.pages.HighscoresPage;
import com.texttwist.client.tasks.FetchHighscore;
import javafx.util.Pair;
import javax.swing.*;
+import java.io.ObjectOutput;
+import java.util.concurrent.Callable;
+
+import static com.texttwist.client.App.gameService;
/**
* Author: Lorenzo Iovino on 27/06/2017.
@@ -12,18 +15,12 @@ import javax.swing.*;
*/
public class HighscoresController {
- private HighscoresPage highscoresPage;
-
- public HighscoresController(HighscoresPage highscoresPage){
- this.highscoresPage = highscoresPage;
- }
-
- public SwingWorker fetchHighscores () {
- return new FetchHighscore(highscoresPage);
+ public SwingWorker fetchHighscores(Callable callback) {
+ return new FetchHighscore(callback);
}
public DefaultListModel> getRanks(Boolean isPartialRank) {
- return isPartialRank ? App.gameService.ranks : App.gameService.globalRanks;
+ return isPartialRank ? gameService.ranks : gameService.globalRanks;
}
}
diff --git a/Client/src/com/texttwist/client/controllers/HomeController.java b/Client/src/com/texttwist/client/controllers/HomeController.java
index 0c7b67b..2197bbd 100644
--- a/Client/src/com/texttwist/client/controllers/HomeController.java
+++ b/Client/src/com/texttwist/client/controllers/HomeController.java
@@ -7,6 +7,7 @@ import models.User;
import java.net.MalformedURLException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
+import static com.texttwist.client.App.authService;
/**
* Author: Lorenzo Iovino on 20/06/2017.
@@ -15,7 +16,7 @@ import java.rmi.RemoteException;
public class HomeController {
public Response login(String userName, String password) throws RemoteException, NotBoundException, MalformedURLException {
- Response res = App.authService.login(userName,password);
+ Response res = authService.login(userName,password);
if (res.code == 200){
App.session = (new Session(new User(userName,password,0), res.data.get("token").toString()));
}
diff --git a/Client/src/com/texttwist/client/controllers/MatchRequestController.java b/Client/src/com/texttwist/client/controllers/MatchRequestController.java
new file mode 100644
index 0000000..f2d797a
--- /dev/null
+++ b/Client/src/com/texttwist/client/controllers/MatchRequestController.java
@@ -0,0 +1,19 @@
+package com.texttwist.client.controllers;
+
+import com.texttwist.client.App;
+import javax.swing.*;
+
+/**
+ * Author: Lorenzo Iovino on 13/072017.
+ * Description: Controller of the Match Request Page
+ */
+public class MatchRequestController {
+
+ public DefaultListModel getPendingList(){
+ return App.gameService.pendingList;
+ }
+
+ public void joinMatch(String matchName){
+ App.gameService.joinMatch(matchName);
+ }
+}
diff --git a/Client/src/com/texttwist/client/controllers/MatchSetupController.java b/Client/src/com/texttwist/client/controllers/MatchSetupController.java
index d0aee9d..bf47bb0 100644
--- a/Client/src/com/texttwist/client/controllers/MatchSetupController.java
+++ b/Client/src/com/texttwist/client/controllers/MatchSetupController.java
@@ -1,8 +1,7 @@
package com.texttwist.client.controllers;
-import com.texttwist.client.App;
import javax.swing.*;
-import java.io.IOException;
+import static com.texttwist.client.App.gameService;
/**
* Author: Lorenzo Iovino on 18/06/2017.
@@ -10,12 +9,7 @@ import java.io.IOException;
*/
public class MatchSetupController {
- public Object play(DefaultListModel userNames) {
- try {
- return App.gameService.play(userNames);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return null;
+ public void play(DefaultListModel userNames) {
+ gameService.beginMatch(userNames);
}
}
diff --git a/Client/src/com/texttwist/client/controllers/MenuController.java b/Client/src/com/texttwist/client/controllers/MenuController.java
index 7eb9a0e..fafca6a 100644
--- a/Client/src/com/texttwist/client/controllers/MenuController.java
+++ b/Client/src/com/texttwist/client/controllers/MenuController.java
@@ -1,11 +1,13 @@
package com.texttwist.client.controllers;
import com.texttwist.client.App;
-import interfaces.INotificationClient;
import models.Response;
+import models.Session;
+
import java.net.MalformedURLException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
+import static com.texttwist.client.App.authService;
/**
* Author: Lorenzo Iovino on 17/06/2017.
@@ -13,10 +15,14 @@ import java.rmi.RemoteException;
*/
public class MenuController {
- public void logout(String userName, INotificationClient stub) throws RemoteException, NotBoundException, MalformedURLException {
- Response res = App.authService.logout(userName, stub);
+ public void logout() throws RemoteException, NotBoundException, MalformedURLException {
+ Response res = authService.logout(App.session.account.userName, App.notificationStub);
if (res.code == 200){
App.session = null;
}
}
+
+ public Session getSession(){
+ return App.session;
+ }
}
diff --git a/Client/src/com/texttwist/client/controllers/RegisterController.java b/Client/src/com/texttwist/client/controllers/RegisterController.java
index 26cf6ba..6c928a1 100644
--- a/Client/src/com/texttwist/client/controllers/RegisterController.java
+++ b/Client/src/com/texttwist/client/controllers/RegisterController.java
@@ -1,10 +1,10 @@
package com.texttwist.client.controllers;
-import com.texttwist.client.App;
import models.Response;
import java.net.MalformedURLException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
+import static com.texttwist.client.App.authService;
/**
* Author: Lorenzo Iovino on 17/06/2017.
@@ -13,6 +13,6 @@ import java.rmi.RemoteException;
public class RegisterController {
public Response register(String userName, String password) throws RemoteException, NotBoundException, MalformedURLException {
- return App.authService.register(userName,password);
+ return authService.register(userName,password);
}
}
diff --git a/Client/src/com/texttwist/client/pages/GamePage.java b/Client/src/com/texttwist/client/pages/GamePage.java
index d8bda51..cf5afe3 100644
--- a/Client/src/com/texttwist/client/pages/GamePage.java
+++ b/Client/src/com/texttwist/client/pages/GamePage.java
@@ -1,4 +1,5 @@
package com.texttwist.client.pages;
+
import com.texttwist.client.controllers.GameController;
import constants.Config;
import constants.Palette;
@@ -8,10 +9,9 @@ import java.awt.*;
import java.io.IOException;
import java.util.concurrent.*;
-import static com.texttwist.client.App.gameService;
-
/**
- * GamePage Page
+ * Author: Lorenzo Iovino on 27/06/2017.
+ * Description: Game Page
*/
public class GamePage extends Page {
@@ -19,24 +19,28 @@ public class GamePage extends Page {
private GameController gameController;
public Timer timer;
- /*Spawning points fixed and not modifiable*/
+ //All the spawning points
private final DefaultListModel letterSpawningPoints = setLetterSpawningPoint();
-
- /*Available spawning points*/
+ //Available spawning points
private DefaultListModel availableLetterSpawningPoint = new DefaultListModel<>();
public GamePage(JFrame window) throws IOException {
super(window);
gameController = new GameController(this);
+
+ //Reset and set spawning point for letters
availableLetterSpawningPoint.clear();
availableLetterSpawningPoint = letterSpawningPoints;
- gameController.waitForPlayers(gameController.startGame()).execute();
+
+ //Wait for players, then when all players joined start the game
+ gameController.waitForPlayers(gameController.startGame).execute();
+
createUIComponents();
window.setVisible(true);
}
+ /*Occupy a random position of the available spawning points, if positions ends (can't happen) use position (0,0)*/
private Point occupyRandomPosition(){
-
if(availableLetterSpawningPoint.size() > 1) {
int index = ThreadLocalRandom.current().nextInt(0, letterSpawningPoints.size() - 1);
Point placeholder = letterSpawningPoints.get(index);
@@ -47,18 +51,6 @@ public class GamePage extends Page {
return new Point(0,0);
}
-
- private SwingWorker timeIsOver() {
- return gameController.sendWords(new SwingWorker() {
- @Override
- protected Object doInBackground() throws Exception {
- new HighscoresPage(window,true);
- return null;
- }
- }
- );
- }
-
private DefaultListModel setLetterSpawningPoint(){
DefaultListModel l = new DefaultListModel<>();
@@ -90,7 +82,7 @@ public class GamePage extends Page {
public void showLetters(){
/* Place letters in an available random spawning point */
- DefaultListModel letters = gameService.getLetters();
+ DefaultListModel letters = gameController.getLetters();
for(int i = 0; i < letters.size()-1; i++){
new TTLetter(
occupyRandomPosition(),
@@ -103,6 +95,19 @@ public class GamePage extends Page {
window.revalidate();
}
+ public void showGameIsReadyAlert(){
+ //Mostra pannello di conferma che le lettere sono tutte arrivate
+ new TTDialog("success", "GameService is ready. Press OK to start!",
+ new Callable() {
+ @Override
+ public Object call() throws Exception {
+ showLetters();
+ timer.start();
+ return null;
+ }
+ }, null);
+ }
+
@Override
public void createUIComponents() throws IOException {
@@ -120,7 +125,7 @@ public class GamePage extends Page {
new Point(150, 90),
new Dimension(250, 40),
"Insert word and Press ENTER!",
- gameService.getWords(),
+ gameController.getWords(),
gameContainer
);
@@ -129,7 +134,13 @@ public class GamePage extends Page {
timer = addTimer(
footer,
new Font(Palette.inputBox_font.getFontName(), Font.BOLD, 40),
- timeIsOver(),
+ gameController.timeIsOver(new SwingWorker() {
+ @Override
+ protected Object doInBackground() throws Exception {
+ new HighscoresPage(window,true);
+ return null;
+ }
+ }),
Config.timeoutGame
);
}
diff --git a/Client/src/com/texttwist/client/pages/HighscoresPage.java b/Client/src/com/texttwist/client/pages/HighscoresPage.java
index 1848ebb..6a18566 100644
--- a/Client/src/com/texttwist/client/pages/HighscoresPage.java
+++ b/Client/src/com/texttwist/client/pages/HighscoresPage.java
@@ -9,7 +9,8 @@ import java.io.IOException;
import java.util.concurrent.Callable;
/**
- * Highscores Page
+ * Author: Lorenzo Iovino on 22/06/2017.
+ * Description: Highscores Page
*/
public class HighscoresPage extends Page{
@@ -18,26 +19,31 @@ public class HighscoresPage extends Page{
public JFrame window;
private HighscoresController highscoreController;
- public HighscoresPage(JFrame window, Boolean isPartialScore) throws IOException {
+ HighscoresPage(JFrame window, Boolean isPartialScore) throws IOException {
super(window);
this.window = window;
this.isPartialScore = isPartialScore;
- highscoreController = new HighscoresController(this);
- highscoreController.fetchHighscores().execute();
+
+ highscoreController = new HighscoresController();
+ highscoreController.fetchHighscores(showHighscoreList).execute();
createUIComponents();
window.setVisible(true);
}
- public void showHighscoreList(){
- new TTScrollList(
- new Point(20, 60),
- new Dimension(515, 142),
- highscoreController.getRanks(isPartialScore),
- highscoreContainer
- );
- window.revalidate();
- window.repaint();
- }
+ public Callable showHighscoreList = new Callable() {
+ @Override
+ public Void call() throws Exception {
+ new TTScrollList(
+ new Point(20, 60),
+ new Dimension(515, 142),
+ highscoreController.getRanks(isPartialScore),
+ highscoreContainer
+ );
+ window.revalidate();
+ window.repaint();
+ return null;
+ }
+ };
@Override
public void createUIComponents() throws IOException {
@@ -51,7 +57,7 @@ public class HighscoresPage extends Page{
root
);
- TTLabel title = new TTLabel(
+ new TTLabel(
this.isPartialScore ? new Point(150,0) : new Point(200,0),
new Dimension(350,50),
this.isPartialScore ? "Scores of the match" : "Highscores",
diff --git a/Client/src/com/texttwist/client/pages/HomePage.java b/Client/src/com/texttwist/client/pages/HomePage.java
index 8011a45..738f11a 100644
--- a/Client/src/com/texttwist/client/pages/HomePage.java
+++ b/Client/src/com/texttwist/client/pages/HomePage.java
@@ -1,4 +1,5 @@
package com.texttwist.client.pages;
+
import com.texttwist.client.controllers.HomeController;
import constants.Palette;
import com.texttwist.client.ui.*;
@@ -8,6 +9,10 @@ import javax.swing.*;
import java.awt.*;
import java.util.concurrent.Callable;
+/**
+ * Author: Lorenzo Iovino on 23/06/2017.
+ * Description: Home Page
+ */
public class HomePage extends Page {
private HomeController homeController;
diff --git a/Client/src/com/texttwist/client/pages/MatchRequestsPage.java b/Client/src/com/texttwist/client/pages/MatchRequestsPage.java
index 0aed817..462441d 100644
--- a/Client/src/com/texttwist/client/pages/MatchRequestsPage.java
+++ b/Client/src/com/texttwist/client/pages/MatchRequestsPage.java
@@ -1,6 +1,6 @@
package com.texttwist.client.pages;
-import com.texttwist.client.App;
+import com.texttwist.client.controllers.MatchRequestController;
import constants.Palette;
import com.texttwist.client.ui.*;
import javax.swing.*;
@@ -11,13 +11,16 @@ import java.io.IOException;
import java.util.concurrent.Callable;
/**
- * MatchRequest Page
+ * Author: Lorenzo Iovino on 27/06/2017.
+ * Description: MatchRequest Page
*/
public class MatchRequestsPage extends Page{
- public TTContainer matchsContainer;
+ private MatchRequestController matchRequestController;
+
MatchRequestsPage(JFrame window) throws IOException {
super(window);
+ matchRequestController = new MatchRequestController();
createUIComponents();
window.setVisible(true);
}
@@ -25,9 +28,9 @@ public class MatchRequestsPage extends Page{
@Override
public void createUIComponents() throws IOException {
addLogo(root);
- matchsContainer = new TTContainer(
+ TTContainer matchsContainer = new TTContainer(
null,
- new Dimension(1150,220),
+ new Dimension(1150, 220),
Palette.root_backgroundColor,
-1,
root
@@ -45,7 +48,7 @@ public class MatchRequestsPage extends Page{
TTScrollList pendingMatches = new TTScrollList(
new Point(20, 60),
new Dimension(520, 142),
- App.gameService.pendingList,
+ matchRequestController.getPendingList(),
matchsContainer
);
@@ -56,7 +59,7 @@ public class MatchRequestsPage extends Page{
JList thisList = (JList)evt.getSource();
if (evt.getClickCount() == 2) {
int index = thisList.locationToIndex(evt.getPoint());
- App.gameService.joinMatch(App.gameService.pendingList.get(index));
+ matchRequestController.joinMatch(matchRequestController.getPendingList().get(index));
}
}
});
diff --git a/Client/src/com/texttwist/client/pages/MatchSetupPage.java b/Client/src/com/texttwist/client/pages/MatchSetupPage.java
index c608e95..016dce5 100644
--- a/Client/src/com/texttwist/client/pages/MatchSetupPage.java
+++ b/Client/src/com/texttwist/client/pages/MatchSetupPage.java
@@ -8,7 +8,8 @@ import java.awt.*;
import java.util.concurrent.Callable;
/**
- * MatchSetup Page
+ * Author: Lorenzo Iovino on 27/06/2017.
+ * Description: MatchSetup Page
*/
public class MatchSetupPage extends Page{
@@ -56,9 +57,10 @@ public class MatchSetupPage extends Page{
"Play!",
new Callable