mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Working tournament
This commit is contained in:
@@ -117,7 +117,9 @@ public final class Server {
|
||||
return;
|
||||
}
|
||||
|
||||
primary = new ServerView(user, this::sendChallenge, clientId);
|
||||
primary = new ServerView(user, this::sendChallenge, () -> {
|
||||
GlobalEventBus.get().post(new NetworkEvents.SendCommand(clientId, "tournament", "start", "tic-tac-toe"));
|
||||
}, clientId);
|
||||
WidgetContainer.getCurrentView().transitionNextCustom(primary, "disconnect", this::disconnect);
|
||||
|
||||
a.unsubscribe("connecting");
|
||||
|
||||
@@ -6,6 +6,7 @@ import javafx.scene.control.ComboBox;
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Consumer;
|
||||
@@ -20,15 +21,17 @@ import org.toop.framework.networking.connection.events.NetworkEvents;
|
||||
public final class ServerView extends ViewWidget {
|
||||
private final String user;
|
||||
private final Consumer<String> onPlayerClicked;
|
||||
private final Runnable tournamentRequest;
|
||||
private final long clientId;
|
||||
|
||||
private final ComboBox<String> gameList;
|
||||
private final ListView<Button> listView;
|
||||
private Button subscribeButton;
|
||||
|
||||
public ServerView(String user, Consumer<String> onPlayerClicked, long clientId) {
|
||||
public ServerView(String user, Consumer<String> onPlayerClicked, Runnable tournamentRequest, long clientId) {
|
||||
this.user = user;
|
||||
this.onPlayerClicked = onPlayerClicked;
|
||||
this.tournamentRequest = tournamentRequest;
|
||||
this.clientId = clientId;
|
||||
|
||||
this.gameList = new ComboBox<>();
|
||||
@@ -58,6 +61,17 @@ public final class ServerView extends ViewWidget {
|
||||
|
||||
add(Pos.CENTER, playerListSection);
|
||||
|
||||
var tournamentButton = Primitive.vbox(
|
||||
Primitive.button(
|
||||
"tournament",
|
||||
tournamentRequest,
|
||||
false,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
add(Pos.BOTTOM_CENTER, tournamentButton);
|
||||
|
||||
var disconnectButton = Primitive.button(
|
||||
"disconnect", () -> transitionPrevious(), false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user