Initial refactor of GUI
This commit is contained in:
@@ -5,6 +5,7 @@ import it.polimi.ingsw.gc14.Model.Game;
|
||||
import it.polimi.ingsw.gc14.Model.MiniModel;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvent;
|
||||
import it.polimi.ingsw.gc14.Network.RMI.Common.IClientCallback;
|
||||
import javafx.application.Platform;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.rmi.RemoteException;
|
||||
@@ -39,8 +40,10 @@ public class ClientCallbackImpl extends UnicastRemoteObject implements IClientCa
|
||||
*/
|
||||
@Override
|
||||
public void onGameInit(MiniModel model) throws RemoteException {
|
||||
clientController.setModel(model);
|
||||
clientController.view.render();
|
||||
Platform.runLater(() -> {
|
||||
clientController.setModel(model);
|
||||
clientController.view.render();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +60,10 @@ public class ClientCallbackImpl extends UnicastRemoteObject implements IClientCa
|
||||
if(event.getIsError()) {
|
||||
clientController.view.showError(event.toString());
|
||||
} else {
|
||||
clientController.view.applyAndRender(event);
|
||||
Platform.runLater(() -> {
|
||||
event.apply(clientController.miniModel);
|
||||
clientController.view.render();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import it.polimi.ingsw.gc14.Model.MiniModel;
|
||||
import it.polimi.ingsw.gc14.Network.IClient;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvent;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvents.*;
|
||||
import javafx.application.Platform;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
@@ -163,14 +164,17 @@ public class TCPClient implements IClient {
|
||||
if (event.getIsError()) {
|
||||
controller.view.showError(event.toString());
|
||||
} else {
|
||||
controller.view.applyAndRender(event);
|
||||
Platform.runLater(() -> {
|
||||
event.apply(controller.miniModel);
|
||||
controller.view.render();
|
||||
});
|
||||
}
|
||||
|
||||
} else if (read instanceof MiniModel model) {
|
||||
synchronized (controller) {
|
||||
Platform.runLater(() -> {
|
||||
controller.setModel(model);
|
||||
controller.view.render();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
||||
Reference in New Issue
Block a user