Merge pull request #186 from 2OOP/UI

Update UI for networking
This commit is contained in:
Bas Antonius de Jong
2025-10-15 21:06:31 +02:00
committed by GitHub
69 changed files with 4286 additions and 3184 deletions

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View File

@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

View File

@@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ResourceBundleManager">
<file url="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_ar.properties" />
<file url="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_de.properties" />
<file url="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_en.properties" />
<file url="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_es.properties" />
<file url="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_fr.properties" />
<file url="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_hi.properties" />
<file url="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_it.properties" />
<file url="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_ja.properties" />
<file url="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_ko.properties" />
<file url="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_nl.properties" />
<file url="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_ru.properties" />
<file url="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_zh.properties" />
<custom-resource-bundle>
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/Localization_de.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/Localization_es.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/Localization_fr.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/Localization_it.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/Localization_nl.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/Localization_zh.properties" />
<base-name>localization</base-name>
</custom-resource-bundle>
<custom-resource-bundle>
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_ar.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_de.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_en.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_es.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_fr.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_hi.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_it.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_ja.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_ko.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_nl.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_ru.properties" />
<file value="file://$PROJECT_DIR$/app/src/main/resources/assets/localization/localization_zh.properties" />
<base-name>localization</base-name>
</custom-resource-bundle>
</component>
</project>

View File

@@ -1,15 +1,8 @@
package org.toop.app;
import java.util.Stack;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import org.toop.app.layer.Layer;
import org.toop.app.layer.layers.MainLayer;
import org.toop.app.layer.layers.QuitPopup;
import org.toop.framework.audio.VolumeControl;
import org.toop.app.view.ViewStack;
import org.toop.app.view.views.MainView;
import org.toop.app.view.views.QuitView;
import org.toop.framework.audio.events.AudioEvents;
import org.toop.framework.eventbus.EventFlow;
import org.toop.framework.resource.ResourceManager;
@@ -17,154 +10,110 @@ import org.toop.framework.resource.resources.CssAsset;
import org.toop.local.AppContext;
import org.toop.local.AppSettings;
public final class App extends Application {
private static Stage stage;
private static Scene scene;
private static StackPane root;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public final class App extends Application {
private static Stage stage;
private static Scene scene;
private static Stack<Layer> stack;
private static int height;
private static int width;
private static boolean isQuitting;
private static boolean isQuitting;
public static void run(String[] args) {
launch(args);
}
public static void run(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
@Override
public void start(Stage stage) throws Exception {
final StackPane root = new StackPane();
final Scene scene = new Scene(root);
final Scene scene = new Scene(root);
ViewStack.setup(scene);
stage.setTitle(AppContext.getString("appTitle"));
stage.setWidth(1080);
stage.setHeight(720);
stage.setTitle(AppContext.getString("app-title"));
stage.setWidth(1080);
stage.setHeight(720);
stage.setOnCloseRequest(
event -> {
event.consume();
stage.setOnCloseRequest(event -> {
event.consume();
startQuit();
});
if (!isQuitting) {
quitPopup();
}
});
stage.setScene(scene);
stage.setResizable(false);
stage.setScene(scene);
stage.setResizable(false);
stage.show();
stage.show();
App.stage = stage;
App.scene = scene;
App.stage = stage;
App.scene = scene;
App.root = root;
App.width = (int)stage.getWidth();
App.height = (int)stage.getHeight();
App.stack = new Stack<>();
App.isQuitting = false;
App.width = (int) stage.getWidth();
App.height = (int) stage.getHeight();
AppSettings.applySettings();
new EventFlow().addPostEvent(new AudioEvents.StartBackgroundMusic()).asyncPostEvent();
App.isQuitting = false;
ViewStack.push(new MainView());
}
new EventFlow().addPostEvent(new AudioEvents.StartBackgroundMusic()).postEvent();
public static void startQuit() {
if (isQuitting) {
return;
}
final AppSettings settings = new AppSettings();
settings.applySettings();
ViewStack.push(new QuitView());
isQuitting = true;
}
activate(new MainLayer());
}
public static void stopQuit() {
ViewStack.pop();
isQuitting = false;
}
public static void activate(Layer layer) {
Platform.runLater(
() -> {
popAll();
push(layer);
});
}
public static void quit() {
ViewStack.cleanup();
stage.close();
}
public static void push(Layer layer) {
Platform.runLater(
() -> {
root.getChildren().addLast(layer.getLayer());
stack.push(layer);
});
}
public static void reload() {
stage.setTitle(AppContext.getString("app-title"));
ViewStack.reload();
}
public static void pop() {
Platform.runLater(
() -> {
root.getChildren().removeLast();
stack.pop();
public static void setFullscreen(boolean fullscreen) {
stage.setFullScreen(fullscreen);
isQuitting = false;
});
}
width = (int) stage.getWidth();
height = (int) stage.getHeight();
public static void popAll() {
Platform.runLater(
() -> {
final int childrenCount = root.getChildren().size();
reload();
}
for (int i = 0; i < childrenCount; i++) {
try {
root.getChildren().removeLast();
} catch (Exception e) {
IO.println(e); // TODO: Use logger
}
}
public static void setStyle(String theme, String layoutSize) {
final int stylesCount = scene.getStylesheets().size();
stack.removeAllElements();
});
}
for (int i = 0; i < stylesCount; i++) {
scene.getStylesheets().removeLast();
}
public static void quitPopup() {
Platform.runLater(
() -> {
push(new QuitPopup());
isQuitting = true;
});
}
scene.getStylesheets().add(ResourceManager.<CssAsset>get("general.css").getUrl());
scene.getStylesheets().add(ResourceManager.<CssAsset>get(theme + ".css").getUrl());
scene.getStylesheets().add(ResourceManager.<CssAsset>get(layoutSize + ".css").getUrl());
public static void quit() {
new EventFlow().addPostEvent(new AudioEvents.StopAudioManager()).postEvent();
stage.close();
}
reload();
}
public static void reloadAll() {
stage.setTitle(AppContext.getString("appTitle"));
public static int getWidth() {
return width;
}
for (final Layer layer : stack) {
layer.reload();
}
}
public static void setFullscreen(boolean fullscreen) {
stage.setFullScreen(fullscreen);
width = (int) stage.getWidth();
height = (int) stage.getHeight();
reloadAll();
}
public static void setStyle(String theme, String layoutSize) {
final int stylesCount = scene.getStylesheets().size();
for (int i = 0; i < stylesCount; i++) {
scene.getStylesheets().removeLast();
}
scene.getStylesheets().add(ResourceManager.<CssAsset>get(theme + ".css").getUrl());
scene.getStylesheets().add(ResourceManager.<CssAsset>get(layoutSize + ".css").getUrl());
reloadAll();
}
public static int getWidth() {
return width;
}
public static int getHeight() {
return height;
}
}
public static int getHeight() {
return height;
}
}

View File

@@ -1,10 +1,41 @@
package org.toop.app;
public record GameInformation(
String[] playerName,
boolean[] isPlayerHuman,
int[] computerDifficulty,
int[] computerThinkTime,
boolean isConnectionLocal,
String serverIP,
String serverPort) {}
public class GameInformation {
public enum Type {
TICTACTOE,
REVERSI;
public static int playerCount(Type type) {
return switch (type) {
case TICTACTOE -> 2;
case REVERSI -> 2;
};
}
public static int maxDepth(Type type) {
return switch (type) {
case TICTACTOE -> 5; // Todo. 5 seems to always draw or win. could increase to 9 but that might affect performance
case REVERSI -> 10; // Todo. 10 is a guess. might be too slow or too bad.
};
}
}
public static class Player {
public String name = "";
public boolean isHuman = true;
public int computerDifficulty = 1;
public int computerThinkTime = 1;
}
public final Type type;
public final Player[] players;
public GameInformation(Type type) {
this.type = type;
players = new Player[Type.playerCount(type)];
for (int i = 0; i < players.length; i++) {
players[i] = new Player();
}
}
}

View File

@@ -0,0 +1,210 @@
package org.toop.app;
import org.toop.app.game.ReversiGame;
import org.toop.app.game.TicTacToeGame;
import org.toop.app.view.ViewStack;
import org.toop.app.view.views.ChallengeView;
import org.toop.app.view.views.ErrorView;
import org.toop.app.view.views.OnlineView;
import org.toop.app.view.views.SendChallengeView;
import org.toop.app.view.views.ServerView;
import org.toop.framework.eventbus.EventFlow;
import org.toop.framework.networking.events.NetworkEvents;
import org.toop.local.AppContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public final class Server {
private String user = "";
private long clientId = -1;
private List<String> onlinePlayers = new CopyOnWriteArrayList<String>();
private ServerView view;
private boolean isPolling = true;
public static GameInformation.Type gameToType(String game) {
if (game.equalsIgnoreCase("tic-tac-toe")) {
return GameInformation.Type.TICTACTOE;
} else if (game.equalsIgnoreCase("reversi")) {
return GameInformation.Type.REVERSI;
}
return null;
}
public Server(String ip, String port, String user) {
if (ip.split("\\.").length < 4) {
ViewStack.push(new ErrorView("\"" + ip + "\" " + AppContext.getString("is-not-a-valid-ip-address")));
return;
}
int parsedPort = -1;
try {
parsedPort = Integer.parseInt(port);
} catch (NumberFormatException _) {
ViewStack.push(new ErrorView("\"" + port + "\" " + AppContext.getString("is-not-a-valid-port")));
return;
}
if (user.isEmpty()) {
ViewStack.push(new ErrorView(AppContext.getString("invalid-username")));
return;
}
new EventFlow()
.addPostEvent(NetworkEvents.StartClient.class, ip, parsedPort)
.onResponse(NetworkEvents.StartClientResponse.class, e -> {
this.user = user;
clientId = e.clientId();
new EventFlow().addPostEvent(new NetworkEvents.SendLogin(clientId, user)).postEvent();
view = new ServerView(user, this::sendChallenge, this::disconnect);
ViewStack.push(view);
startPopulateThread();
}).postEvent();
new EventFlow().listen(this::handleReceivedChallenge);
}
private void populatePlayerList() {
new EventFlow().listen(NetworkEvents.PlayerlistResponse.class, e -> {
if (e.clientId() == clientId) {
onlinePlayers = new ArrayList<String>(List.of(e.playerlist()));
onlinePlayers.removeIf(name -> name.equalsIgnoreCase(user));
view.update(onlinePlayers);
}
});
final EventFlow sendGetPlayerList = new EventFlow().addPostEvent(new NetworkEvents.SendGetPlayerlist(clientId));
while (isPolling) {
sendGetPlayerList.postEvent();
try {
Thread.sleep(5000);
} catch (InterruptedException _) {}
}
}
private void sendChallenge(String opponent) {
if (!isPolling) {
return;
}
ViewStack.push(new SendChallengeView(this, opponent, (playerInformation, gameType) -> {
new EventFlow().addPostEvent(new NetworkEvents.SendChallenge(clientId, opponent, gameType))
.listen(NetworkEvents.GameMatchResponse.class, e -> {
if (e.clientId() == clientId) {
isPolling = false;
onlinePlayers.clear();
final GameInformation.Type type = gameToType(gameType);
final int myTurn = e.playerToMove().equalsIgnoreCase(e.opponent())? 1 : 0;
final GameInformation information = new GameInformation(type);
information.players[0] = playerInformation;
information.players[0].name = user;
information.players[1].name = opponent;
switch (type) {
case TICTACTOE: new TicTacToeGame(information, myTurn, this::forfeitGame, this::exitGame, this::sendMessage); break;
case REVERSI: new ReversiGame(information, myTurn, this::forfeitGame, this::exitGame, this::sendMessage); break;
}
}
}).postEvent();
}));
}
private void handleReceivedChallenge(NetworkEvents.ChallengeResponse response) {
if (!isPolling) {
return;
}
String challengerName = response.challengerName();
challengerName = challengerName.substring(challengerName.indexOf("\"") + 1);
challengerName = challengerName.substring(0, challengerName.indexOf("\""));
String gameType = response.gameType();
gameType = gameType.substring(gameType.indexOf("\"") + 1);
gameType = gameType.substring(0, gameType.indexOf("\""));
final String finalGameType = gameType;
ViewStack.push(new ChallengeView(challengerName, gameType, (playerInformation) -> {
final int challengeId = Integer.parseInt(response.challengeId().substring(18, response.challengeId().length() - 2));
new EventFlow().addPostEvent(new NetworkEvents.SendAcceptChallenge(clientId, challengeId)).postEvent();
ViewStack.pop();
new EventFlow().listen(NetworkEvents.GameMatchResponse.class, e -> {
if (e.clientId() == clientId) {
isPolling = false;
onlinePlayers.clear();
final GameInformation.Type type = gameToType(finalGameType);
final int myTurn = e.playerToMove().equalsIgnoreCase(e.opponent())? 1 : 0;
final GameInformation information = new GameInformation(type);
information.players[0] = playerInformation;
information.players[0].name = user;
information.players[1].name = e.opponent();
switch (type) {
case TICTACTOE: new TicTacToeGame(information, myTurn, this::forfeitGame, this::exitGame, this::sendMessage); break;
case REVERSI: new ReversiGame(information, myTurn, this::forfeitGame, this::exitGame, this::sendMessage); break;
}
}
});
}));
}
private void sendMessage(String message) {
new EventFlow().addPostEvent(new NetworkEvents.SendMessage(clientId, message)).postEvent();
}
private void disconnect() {
new EventFlow().addPostEvent(new NetworkEvents.CloseClient(clientId)).postEvent();
ViewStack.push(new OnlineView());
}
private void forfeitGame() {
new EventFlow().addPostEvent(new NetworkEvents.SendForfeit(clientId)).postEvent();
}
private void exitGame() {
forfeitGame();
ViewStack.push(view);
startPopulateThread();
}
private void startPopulateThread() {
isPolling = true;
final Thread populateThread = new Thread(this::populatePlayerList);
populateThread.setDaemon(false);
populateThread.start();
}
public List<String> getGamesList() {
final List<String> list = new ArrayList<String>();
list.add("tic-tac-toe"); // Todo: get games list from server and check if the game is supported
list.add("reversi");
new EventFlow().addPostEvent(new NetworkEvents.SendGetGamelist(clientId))
.listen(NetworkEvents.GamelistResponse.class, e -> {
System.out.println(Arrays.toString(e.gamelist()));
}).postEvent();
return list;
}
}

View File

@@ -1,130 +1,122 @@
package org.toop.app.canvas;
import java.util.function.Consumer;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.input.MouseButton;
import javafx.scene.paint.Color;
import java.util.function.Consumer;
public abstract class GameCanvas {
protected record Cell(float x, float y, float width, float height) {}
protected record Cell(float x, float y, float width, float height) {
public boolean isInside(double x, double y) {
return x >= this.x && x <= this.x + width &&
y >= this.y && y <= this.y + height;
}
}
protected final Canvas canvas;
protected final GraphicsContext graphics;
protected final Canvas canvas;
protected final GraphicsContext graphics;
protected final Color color;
protected final Color color;
protected int width;
protected int height;
protected final int width;
protected final int height;
protected final int rows;
protected final int columns;
protected final int rowSize;
protected final int columnSize;
protected final int gapSize;
protected final boolean edges;
protected final int gapSize;
protected final boolean edges;
protected final Cell[] cells;
protected final Cell[] cells;
protected GameCanvas(
Color color,
int width,
int height,
int rows,
int columns,
int gapSize,
boolean edges,
Consumer<Integer> onCellClicked) {
canvas = new Canvas(width, height);
graphics = canvas.getGraphicsContext2D();
protected GameCanvas(Color color, int width, int height, int rowSize, int columnSize, int gapSize, boolean edges, Consumer<Integer> onCellClicked) {
canvas = new Canvas(width, height);
graphics = canvas.getGraphicsContext2D();
this.color = color;
this.color = color;
this.width = width;
this.height = height;
this.width = width;
this.height = height;
this.rows = rows;
this.columns = columns;
this.rowSize = rowSize;
this.columnSize = columnSize;
this.gapSize = gapSize;
this.edges = edges;
this.gapSize = gapSize;
this.edges = edges;
cells = new Cell[rows * columns];
cells = new Cell[rowSize * columnSize];
final float cellWidth = ((float) width - (rows - 1) * gapSize) / rows;
final float cellHeight = ((float) height - (columns - 1) * gapSize) / columns;
final float cellWidth = ((float)width - gapSize * rowSize - gapSize) / rowSize;
final float cellHeight = ((float)height - gapSize * columnSize - gapSize) / columnSize;
for (int y = 0; y < columns; y++) {
final float startY = y * cellHeight + y * gapSize;
for (int y = 0; y < columnSize; y++) {
final float startY = y * cellHeight + y * gapSize + gapSize;
for (int x = 0; x < rows; x++) {
final float startX = x * cellWidth + x * gapSize;
cells[y * rows + x] = new Cell(startX, startY, cellWidth, cellHeight);
}
}
for (int x = 0; x < rowSize; x++) {
final float startX = x * cellWidth + x * gapSize + gapSize;
cells[x + y * rowSize] = new Cell(startX, startY, cellWidth, cellHeight);
}
}
canvas.setOnMouseClicked(
event -> {
if (event.getButton() != MouseButton.PRIMARY) {
return;
}
canvas.setOnMouseClicked(event -> {
if (event.getButton() != MouseButton.PRIMARY) {
return;
}
final int column = (int) ((event.getX() / width) * rows);
final int row = (int) ((event.getY() / height) * columns);
final int column = (int)((event.getX() / this.width) * rowSize);
final int row = (int)((event.getY() / this.height) * columnSize);
event.consume();
onCellClicked.accept(row * rows + column);
});
final Cell cell = cells[column + row * rowSize];
render();
}
if (cell.isInside(event.getX(), event.getY())) {
event.consume();
onCellClicked.accept(column + row * rowSize);
}
});
public void clear() {
graphics.clearRect(0, 0, width, height);
}
render();
}
public void render() {
graphics.setFill(color);
public void clear() {
graphics.clearRect(0, 0, width, height);
}
for (int x = 1; x < rows; x++) {
graphics.fillRect(cells[x].x() - gapSize, 0, gapSize, height);
}
public void render() {
graphics.setFill(color);
for (int y = 1; y < columns; y++) {
graphics.fillRect(0, cells[y * rows].y() - gapSize, width, gapSize);
}
for (int x = 0; x < rowSize - 1; x++) {
final float start = cells[x].x + cells[x].width;
graphics.fillRect(start, gapSize, gapSize, height - gapSize * 2);
}
if (edges) {
graphics.fillRect(-gapSize, 0, gapSize, height);
graphics.fillRect(0, -gapSize, width, gapSize);
for (int y = 0; y < columnSize - 1; y++) {
final float start = cells[y * rowSize].y + cells[y * rowSize].height;
graphics.fillRect(gapSize, start, width - gapSize * 2, gapSize);
}
graphics.fillRect(width - gapSize, 0, gapSize, height);
graphics.fillRect(0, height - gapSize, width, gapSize);
}
}
if (edges) {
graphics.fillRect(0, 0, width, gapSize);
graphics.fillRect(0, 0, gapSize, height);
public void draw(Color color, int cell) {
final float x = cells[cell].x() + gapSize;
final float y = cells[cell].y() + gapSize;
graphics.fillRect(width - gapSize, 0, gapSize, height);
graphics.fillRect(0, height - gapSize, width, gapSize);
}
}
final float width = cells[cell].width() - gapSize * 2;
final float height = cells[cell].height() - gapSize * 2;
public void fill(Color color, int cell) {
final float x = cells[cell].x();
final float y = cells[cell].y();
graphics.setFill(color);
graphics.fillRect(x, y, width, height);
}
final float width = cells[cell].width();
final float height = cells[cell].height();
public void resize(int width, int height) {
canvas.setWidth(width);
canvas.setHeight(height);
graphics.setFill(color);
graphics.fillRect(x, y, width, height);
}
this.width = width;
this.height = height;
clear();
render();
}
public Canvas getCanvas() {
return canvas;
}
}
public Canvas getCanvas() {
return canvas;
}
}

View File

@@ -0,0 +1,34 @@
package org.toop.app.canvas;
import javafx.scene.paint.Color;
import java.util.function.Consumer;
public final class ReversiCanvas extends GameCanvas {
public ReversiCanvas(Color color, int width, int height, Consumer<Integer> onCellClicked) {
super(color, width, height, 8, 8, 10, true, onCellClicked);
drawStartingDots();
}
public void drawDot(Color color, int cell) {
final float x = cells[cell].x() + gapSize;
final float y = cells[cell].y() + gapSize;
final float width = cells[cell].width() - gapSize * 2;
final float height = cells[cell].height() - gapSize * 2;
graphics.setFill(color);
graphics.fillOval(x, y, width, height);
}
public void drawStartingDots() {
drawDot(Color.BLACK, 28);
drawDot(Color.WHITE, 36);
drawDot(Color.BLACK, 35);
drawDot(Color.WHITE, 27);
}
public void drawLegalPosition(int cell) {
drawDot(new Color(1.0f, 0.0f, 0.0f, 0.5f), cell);
}
}

View File

@@ -1,37 +1,38 @@
package org.toop.app.canvas;
import java.util.function.Consumer;
import javafx.scene.paint.Color;
public class TicTacToeCanvas extends GameCanvas {
public TicTacToeCanvas(Color color, int width, int height, Consumer<Integer> onCellClicked) {
super(color, width, height, 3, 3, 10, false, onCellClicked);
}
import java.util.function.Consumer;
public void drawX(Color color, int cell) {
graphics.setStroke(color);
graphics.setLineWidth(gapSize);
public final class TicTacToeCanvas extends GameCanvas {
public TicTacToeCanvas(Color color, int width, int height, Consumer<Integer> onCellClicked) {
super(color, width, height, 3, 3, 30, false, onCellClicked);
}
final float x = cells[cell].x() + gapSize;
final float y = cells[cell].y() + gapSize;
public void drawX(Color color, int cell) {
graphics.setStroke(color);
graphics.setLineWidth(gapSize);
final float width = cells[cell].width() - gapSize * 2;
final float height = cells[cell].height() - gapSize * 2;
final float x = cells[cell].x() + gapSize;
final float y = cells[cell].y() + gapSize;
graphics.strokeLine(x, y, x + width, y + height);
graphics.strokeLine(x + width, y, x, y + height);
}
final float width = cells[cell].width() - gapSize * 2;
final float height = cells[cell].height() - gapSize * 2;
public void drawO(Color color, int cell) {
graphics.setStroke(color);
graphics.setLineWidth(gapSize);
graphics.strokeLine(x, y, x + width, y + height);
graphics.strokeLine(x + width, y, x, y + height);
}
final float x = cells[cell].x() + gapSize;
final float y = cells[cell].y() + gapSize;
public void drawO(Color color, int cell) {
graphics.setStroke(color);
graphics.setLineWidth(gapSize);
final float width = cells[cell].width() - gapSize * 2;
final float height = cells[cell].height() - gapSize * 2;
final float x = cells[cell].x() + gapSize;
final float y = cells[cell].y() + gapSize;
graphics.strokeOval(x, y, width, height);
}
}
final float width = cells[cell].width() - gapSize * 2;
final float height = cells[cell].height() - gapSize * 2;
graphics.strokeOval(x, y, width, height);
}
}

View File

@@ -0,0 +1,257 @@
package org.toop.app.game;
import org.toop.app.App;
import org.toop.app.GameInformation;
import org.toop.app.canvas.ReversiCanvas;
import org.toop.app.view.ViewStack;
import org.toop.app.view.views.GameView;
import org.toop.app.view.views.LocalMultiplayerView;
import org.toop.framework.eventbus.EventFlow;
import org.toop.framework.networking.events.NetworkEvents;
import org.toop.game.Game;
import org.toop.game.reversi.Reversi;
import org.toop.game.reversi.ReversiAI;
import javafx.geometry.Pos;
import javafx.scene.paint.Color;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
public final class ReversiGame {
private final GameInformation information;
private final int myTurn;
private final BlockingQueue<Game.Move> moveQueue;
private final Reversi game;
private final ReversiAI ai;
private final GameView view;
private final ReversiCanvas canvas;
private final AtomicBoolean isRunning;
public ReversiGame(GameInformation information, int myTurn, Runnable onForfeit, Runnable onExit, Consumer<String> onMessage) {
this.information = information;
this.myTurn = myTurn;
moveQueue = new LinkedBlockingQueue<Game.Move>();
game = new Reversi();
ai = new ReversiAI();
isRunning = new AtomicBoolean(true);
if (onForfeit == null || onExit == null) {
view = new GameView(null, () -> {
isRunning.set(false);
ViewStack.push(new LocalMultiplayerView(information));
}, null);
} else {
view = new GameView(onForfeit, () -> {
isRunning.set(false);
onExit.run();
}, onMessage);
}
canvas = new ReversiCanvas(Color.GRAY,
(App.getHeight() / 4) * 3, (App.getHeight() / 4) * 3,
(cell) -> {
if (onForfeit == null || onExit == null) {
if (information.players[game.getCurrentTurn()].isHuman) {
final char value = game.getCurrentTurn() == 0? 'B' : 'W';
try {
moveQueue.put(new Game.Move(cell, value));
} catch (InterruptedException _) {}
}
} else {
if (information.players[0].isHuman) {
final char value = myTurn == 0? 'B' : 'W';
try {
moveQueue.put(new Game.Move(cell, value));
} catch (InterruptedException _) {}
}
}
});
view.add(Pos.CENTER, canvas.getCanvas());
ViewStack.push(view);
if (onForfeit == null || onExit == null) {
new Thread(this::localGameThread).start();
} else {
new EventFlow()
.listen(NetworkEvents.GameMoveResponse.class, this::onMoveResponse)
.listen(NetworkEvents.YourTurnResponse.class, this::onYourTurnResponse)
.listen(NetworkEvents.ReceivedMessage.class, this::onReceivedMessage);
setGameLabels(myTurn == 0);
}
updateCanvas();
}
public ReversiGame(GameInformation information) {
this(information, 0, null, null, null);
}
private void localGameThread() {
while (isRunning.get()) {
final int currentTurn = game.getCurrentTurn();
final char currentValue = currentTurn == 0? 'B' : 'W';
final int nextTurn = (currentTurn + 1) % GameInformation.Type.playerCount(information.type);
view.nextPlayer(information.players[currentTurn].isHuman,
information.players[currentTurn].name,
String.valueOf(currentValue),
information.players[nextTurn].name);
Game.Move move = null;
if (information.players[currentTurn].isHuman) {
try {
final Game.Move wants = moveQueue.take();
final Game.Move[] legalMoves = game.getLegalMoves();
for (final Game.Move legalMove : legalMoves) {
if (legalMove.position() == wants.position() &&
legalMove.value() == wants.value()) {
move = wants;
break;
}
}
} catch (InterruptedException _) {}
} else {
final long start = System.currentTimeMillis();
move = ai.findBestMove(game, information.players[currentTurn].computerDifficulty);
if (information.players[currentTurn].computerThinkTime > 0) {
final long elapsedTime = System.currentTimeMillis() - start;
final long sleepTime = information.players[currentTurn].computerThinkTime * 1000L - elapsedTime;
try {
Thread.sleep((long) (sleepTime * Math.random()));
} catch (InterruptedException _) {}
}
}
if (move == null) {
continue;
}
final Game.State state = game.play(move);
updateCanvas();
if (state != Game.State.NORMAL) {
if (state == Game.State.WIN) {
view.gameOver(true, information.players[currentTurn].name);
} else if (state == Game.State.DRAW) {
view.gameOver(false, "");
}
isRunning.set(false);
}
}
}
private void onMoveResponse(NetworkEvents.GameMoveResponse response) {
if (!isRunning.get()) {
return;
}
char playerChar;
if (response.player().equalsIgnoreCase(information.players[0].name)) {
playerChar = myTurn == 0? 'B' : 'W';
} else {
playerChar = myTurn == 0? 'W' : 'B';
}
final Game.Move move = new Game.Move(Integer.parseInt(response.move()), playerChar);
final Game.State state = game.play(move);
if (state != Game.State.NORMAL) {
if (state == Game.State.WIN) {
if (response.player().equalsIgnoreCase(information.players[0].name)) {
view.gameOver(true, information.players[0].name);
} else {
view.gameOver(false, information.players[1].name);
}
} else if (state == Game.State.DRAW) {
view.gameOver(false, "");
}
}
updateCanvas();
setGameLabels(game.getCurrentTurn() == myTurn);
}
private void onYourTurnResponse(NetworkEvents.YourTurnResponse response) {
if (!isRunning.get()) {
return;
}
moveQueue.clear();
int position = -1;
if (information.players[0].isHuman) {
try {
position = moveQueue.take().position();
} catch (InterruptedException _) {}
} else {
final Game.Move move = ai.findBestMove(game, information.players[0].computerDifficulty);
assert move != null;
position = move.position();
}
new EventFlow().addPostEvent(new NetworkEvents.SendMove(response.clientId(), (short) position))
.postEvent();
}
private void onReceivedMessage(NetworkEvents.ReceivedMessage msg) {
if (!isRunning.get()) {
return;
}
view.updateChat(msg.message());
}
private void updateCanvas() {
// Todo: this is very inefficient. still very fast but if the grid is bigger it might cause issues. improve.
canvas.clear();
canvas.render();
for (int i = 0; i < game.board.length; i++) {
if (game.board[i] == 'B') {
canvas.drawDot(Color.BLACK, i);
} else if (game.board[i] == 'W') {
canvas.drawDot(Color.WHITE, i);
}
}
final Game.Move[] legalMoves = game.getLegalMoves();
for (final Game.Move legalMove : legalMoves) {
canvas.drawLegalPosition(legalMove.position());
}
}
private void setGameLabels(boolean isMe) {
final int currentTurn = game.getCurrentTurn();
final char currentValue = currentTurn == 0? 'B' : 'W';
view.nextPlayer(isMe,
information.players[isMe? 0 : 1].name,
String.valueOf(currentValue),
information.players[isMe? 1 : 0].name);
}
}

View File

@@ -0,0 +1,244 @@
package org.toop.app.game;
import org.toop.app.App;
import org.toop.app.GameInformation;
import org.toop.app.canvas.TicTacToeCanvas;
import org.toop.app.view.ViewStack;
import org.toop.app.view.views.GameView;
import org.toop.app.view.views.LocalMultiplayerView;
import org.toop.framework.eventbus.EventFlow;
import org.toop.framework.networking.events.NetworkEvents;
import org.toop.game.Game;
import org.toop.game.tictactoe.TicTacToe;
import org.toop.game.tictactoe.TicTacToeAI;
import javafx.geometry.Pos;
import javafx.scene.paint.Color;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
public final class TicTacToeGame {
private final GameInformation information;
private final int myTurn;
private final BlockingQueue<Game.Move> moveQueue;
private final TicTacToe game;
private final TicTacToeAI ai;
private final GameView view;
private final TicTacToeCanvas canvas;
private AtomicBoolean isRunning;
public TicTacToeGame(GameInformation information, int myTurn, Runnable onForfeit, Runnable onExit, Consumer<String> onMessage) {
this.information = information;
this.myTurn = myTurn;
moveQueue = new LinkedBlockingQueue<Game.Move>();
game = new TicTacToe();
ai = new TicTacToeAI();
isRunning = new AtomicBoolean(true);
if (onForfeit == null || onExit == null) {
view = new GameView(null, () -> {
isRunning.set(false);
ViewStack.push(new LocalMultiplayerView(information));
}, null);
} else {
view = new GameView(onForfeit, () -> {
isRunning.set(false);
onExit.run();
}, onMessage);
}
canvas = new TicTacToeCanvas(Color.GRAY,
(App.getHeight() / 4) * 3, (App.getHeight() / 4) * 3,
(cell) -> {
if (onForfeit == null || onExit == null) {
if (information.players[game.getCurrentTurn()].isHuman) {
final char value = game.getCurrentTurn() == 0? 'X' : 'O';
try {
moveQueue.put(new Game.Move(cell, value));
} catch (InterruptedException _) {}
}
} else {
if (information.players[0].isHuman) {
final char value = myTurn == 0? 'X' : 'O';
try {
moveQueue.put(new Game.Move(cell, value));
} catch (InterruptedException _) {}
}
}
});
view.add(Pos.CENTER, canvas.getCanvas());
ViewStack.push(view);
if (onForfeit == null || onExit == null) {
new Thread(this::localGameThread).start();
} else {
new EventFlow()
.listen(NetworkEvents.GameMoveResponse.class, this::onMoveResponse)
.listen(NetworkEvents.YourTurnResponse.class, this::onYourTurnResponse)
.listen(NetworkEvents.ReceivedMessage.class, this::onReceivedMessage);
setGameLabels(myTurn == 0);
}
}
public TicTacToeGame(GameInformation information) {
this(information, 0, null, null, null);
}
private void localGameThread() {
while (isRunning.get()) {
final int currentTurn = game.getCurrentTurn();
final char currentValue = currentTurn == 0? 'X' : 'O';
final int nextTurn = (currentTurn + 1) % GameInformation.Type.playerCount(information.type);
view.nextPlayer(information.players[currentTurn].isHuman,
information.players[currentTurn].name,
String.valueOf(currentValue),
information.players[nextTurn].name);
Game.Move move = null;
if (information.players[currentTurn].isHuman) {
try {
final Game.Move wants = moveQueue.take();
final Game.Move[] legalMoves = game.getLegalMoves();
for (final Game.Move legalMove : legalMoves) {
if (legalMove.position() == wants.position() &&
legalMove.value() == wants.value()) {
move = wants;
break;
}
}
} catch (InterruptedException _) {}
} else {
final long start = System.currentTimeMillis();
move = ai.findBestMove(game, information.players[currentTurn].computerDifficulty);
if (information.players[currentTurn].computerThinkTime > 0) {
final long elapsedTime = System.currentTimeMillis() - start;
final long sleepTime = information.players[currentTurn].computerThinkTime * 1000L - elapsedTime;
try {
Thread.sleep((long)(sleepTime * Math.random()));
} catch (InterruptedException _) {}
}
}
if (move == null) {
continue;
}
final Game.State state = game.play(move);
if (move.value() == 'X') {
canvas.drawX(Color.INDIANRED, move.position());
} else if (move.value() == 'O') {
canvas.drawO(Color.ROYALBLUE, move.position());
}
if (state != Game.State.NORMAL) {
if (state == Game.State.WIN) {
view.gameOver(true, information.players[currentTurn].name);
} else if (state == Game.State.DRAW) {
view.gameOver(false, "");
}
isRunning.set(false);
}
}
}
private void onMoveResponse(NetworkEvents.GameMoveResponse response) {
if (!isRunning.get()) {
return;
}
char playerChar;
if (response.player().equalsIgnoreCase(information.players[0].name)) {
playerChar = myTurn == 0? 'X' : 'O';
} else {
playerChar = myTurn == 0? 'O' : 'X';
}
final Game.Move move = new Game.Move(Integer.parseInt(response.move()), playerChar);
final Game.State state = game.play(move);
if (state != Game.State.NORMAL) {
if (state == Game.State.WIN) {
if (response.player().equalsIgnoreCase(information.players[0].name)) {
view.gameOver(true, information.players[0].name);
} else {
view.gameOver(false, information.players[1].name);
}
} else if (state == Game.State.DRAW) {
view.gameOver(false, "");
}
}
if (move.value() == 'X') {
canvas.drawX(Color.RED, move.position());
} else if (move.value() == 'O') {
canvas.drawO(Color.BLUE, move.position());
}
setGameLabels(game.getCurrentTurn() == myTurn);
}
private void onYourTurnResponse(NetworkEvents.YourTurnResponse response) {
if (!isRunning.get()) {
return;
}
moveQueue.clear();
int position = -1;
if (information.players[0].isHuman) {
try {
position = moveQueue.take().position();
} catch (InterruptedException _) {}
} else {
final Game.Move move = ai.findBestMove(game, information.players[0].computerDifficulty);
assert move != null;
position = move.position();
}
new EventFlow().addPostEvent(new NetworkEvents.SendMove(response.clientId(), (short)position))
.postEvent();
}
private void onReceivedMessage(NetworkEvents.ReceivedMessage msg) {
if (!isRunning.get()) {
return;
}
view.updateChat(msg.message());
}
private void setGameLabels(boolean isMe) {
final int currentTurn = game.getCurrentTurn();
final char currentValue = currentTurn == 0? 'X' : 'O';
view.nextPlayer(isMe,
information.players[isMe? 0 : 1].name,
String.valueOf(currentValue),
information.players[isMe? 1 : 0].name);
}
}

View File

@@ -1,12 +0,0 @@
package org.toop.app.layer;
import javafx.scene.Node;
import javafx.scene.layout.Region;
public abstract class Container {
public abstract Region getContainer();
public abstract void addNodes(Node... nodes);
public abstract void addContainer(Container container, boolean fill);
}

View File

@@ -1,86 +0,0 @@
package org.toop.app.layer;
import javafx.geometry.Pos;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import org.toop.app.App;
import org.toop.app.canvas.GameCanvas;
public abstract class Layer {
protected StackPane layer;
protected Region background;
protected Layer(String... backgroundStyles) {
layer = new StackPane();
background = new Region();
background.getStyleClass().addAll(backgroundStyles);
background.setPrefSize(Double.MAX_VALUE, Double.MAX_VALUE);
layer.getChildren().addLast(background);
}
protected void addContainer(
Container container,
Pos position,
int xOffset,
int yOffset,
int widthPercent,
int heightPercent) {
StackPane.setAlignment(container.getContainer(), position);
final double widthUnit = App.getWidth() / 100.0;
final double heightUnit = App.getHeight() / 100.0;
if (widthPercent > 0) {
container.getContainer().setMaxWidth(widthPercent * widthUnit);
} else {
container.getContainer().setMaxWidth(Region.USE_PREF_SIZE);
}
if (heightPercent > 0) {
container.getContainer().setMaxHeight(heightPercent * heightUnit);
} else {
container.getContainer().setMaxHeight(Region.USE_PREF_SIZE);
}
container.getContainer().setTranslateX(xOffset * widthUnit);
container.getContainer().setTranslateY(yOffset * heightUnit);
layer.getChildren().addLast(container.getContainer());
}
protected void addGameCanvas(GameCanvas canvas, Pos position, int xOffset, int yOffset) {
StackPane.setAlignment(canvas.getCanvas(), position);
final double widthUnit = App.getWidth() / 100.0;
final double heightUnit = App.getHeight() / 100.0;
canvas.getCanvas().setTranslateX(xOffset * widthUnit);
canvas.getCanvas().setTranslateY(yOffset * heightUnit);
layer.getChildren().addLast(canvas.getCanvas());
}
protected void pop() {
if (layer.getChildren().size() <= 1) {
return;
}
layer.getChildren().removeLast();
}
protected void popAll() {
final int containers = layer.getChildren().size();
for (int i = 1; i < containers; i++) {
layer.getChildren().removeLast();
}
}
public StackPane getLayer() {
return layer;
}
public abstract void reload();
}

View File

@@ -1,140 +0,0 @@
package org.toop.app.layer;
import java.util.function.Consumer;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.geometry.Orientation;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.text.Text;
import org.toop.framework.audio.events.AudioEvents;
import org.toop.framework.eventbus.EventFlow;
public final class NodeBuilder {
public static void addCss(Node node, String... cssClasses) {
node.getStyleClass().addAll(cssClasses);
}
public static void setCss(Node node, String... cssClasses) {
node.getStyleClass().removeAll();
node.getStyleClass().addAll(cssClasses);
}
public static Text header(String x) {
final Text element = new Text(x);
setCss(element, "text-primary", "text-header");
return element;
}
public static Text text(String x) {
final Text element = new Text(x);
setCss(element, "text-secondary", "text-normal");
return element;
}
public static Label button(String x, Runnable runnable) {
final Label element = new Label(x);
setCss(element, "button", "text-normal");
element.setOnMouseClicked(
_ -> {
new EventFlow().addPostEvent(new AudioEvents.ClickButton()).asyncPostEvent();
runnable.run();
});
return element;
}
public static Label toggle(String x1, String x2, boolean toggled, Consumer<Boolean> consumer) {
final Label element = new Label(toggled ? x2 : x1);
setCss(element, "toggle", "text-normal");
final BooleanProperty checked = new SimpleBooleanProperty(toggled);
element.setOnMouseClicked(
_ -> {
new EventFlow().addPostEvent(new AudioEvents.ClickButton()).asyncPostEvent();
checked.set(!checked.get());
if (checked.get()) {
element.setText(x1);
} else {
element.setText(x2);
}
consumer.accept(checked.get());
});
return element;
}
public static Slider slider(int max, int initial, Consumer<Integer> consumer) {
final Slider element = new Slider(0, max, initial);
setCss(element, "bg-slider-track");
element.setMinorTickCount(0);
element.setMajorTickUnit(1);
element.setBlockIncrement(1);
element.setSnapToTicks(true);
element.setShowTickLabels(true);
element.setOnMouseClicked(
_ -> {
new EventFlow().addPostEvent(new AudioEvents.ClickButton()).asyncPostEvent();
});
element.valueProperty()
.addListener(
(_, _, newValue) -> {
consumer.accept(newValue.intValue());
});
return element;
}
public static TextField input(String x, Consumer<String> consumer) {
final TextField element = new TextField(x);
setCss(element, "input", "text-normal");
element.setOnMouseClicked(
_ -> {
new EventFlow().addPostEvent(new AudioEvents.ClickButton()).asyncPostEvent();
});
element.textProperty()
.addListener(
(_, _, newValue) -> {
consumer.accept(newValue);
});
return element;
}
public static <T> ChoiceBox<T> choiceBox(Consumer<T> consumer) {
final ChoiceBox<T> element = new ChoiceBox<>();
setCss(element, "choice-box", "text-normal");
element.setOnMouseClicked(
_ -> {
new EventFlow().addPostEvent(new AudioEvents.ClickButton()).asyncPostEvent();
});
element.valueProperty()
.addListener(
(_, _, newValue) -> {
consumer.accept(newValue);
});
return element;
}
public static Separator separator() {
final Separator element = new Separator(Orientation.HORIZONTAL);
setCss(element, "separator");
return element;
}
}

View File

@@ -1,20 +0,0 @@
package org.toop.app.layer;
import org.toop.app.App;
public abstract class Popup extends Layer {
protected Popup(boolean popOnBackground, String... backgroundStyles) {
super(backgroundStyles);
if (popOnBackground) {
background.setOnMouseClicked(
_ -> {
App.pop();
});
}
}
protected Popup(boolean popOnBackground) {
this(popOnBackground, "bg-popup");
}
}

View File

@@ -1,59 +0,0 @@
package org.toop.app.layer.containers;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import org.toop.app.layer.Container;
public final class HorizontalContainer extends Container {
private final HBox container;
public HorizontalContainer(int spacing, String... cssClasses) {
container = new HBox(spacing);
container.getStyleClass().addAll(cssClasses);
}
public HorizontalContainer(int spacing) {
this(spacing, "container");
}
@Override
public Region getContainer() {
return container;
}
@Override
public void addNodes(Node... nodes) {
container.getChildren().addAll(nodes);
}
@Override
public void addContainer(Container container, boolean fill) {
if (fill) {
container.getContainer().setMinSize(0, 0);
container.getContainer().setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
HBox.setHgrow(container.getContainer(), Priority.ALWAYS);
} else {
container.getContainer().setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
}
this.container.getChildren().add(container.getContainer());
if (fill) {
balanceChildWidths();
}
}
private void balanceChildWidths() {
final ObservableList<Node> children = container.getChildren();
final double widthPerChild = container.getWidth() / children.size();
for (final Node child : children) {
if (child instanceof Region) {
((Region) child).setPrefWidth(widthPerChild);
}
}
}
}

View File

@@ -1,59 +0,0 @@
package org.toop.app.layer.containers;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import org.toop.app.layer.Container;
public final class VerticalContainer extends Container {
private final VBox container;
public VerticalContainer(int spacing, String... cssClasses) {
container = new VBox(spacing);
container.getStyleClass().addAll(cssClasses);
}
public VerticalContainer(int spacing) {
this(spacing, "container");
}
@Override
public Region getContainer() {
return container;
}
@Override
public void addNodes(Node... nodes) {
container.getChildren().addAll(nodes);
}
@Override
public void addContainer(Container container, boolean fill) {
if (fill) {
container.getContainer().setMinSize(0, 0);
container.getContainer().setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
VBox.setVgrow(container.getContainer(), Priority.ALWAYS);
} else {
container.getContainer().setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
}
this.container.getChildren().add(container.getContainer());
if (fill) {
balanceChildHeights();
}
}
private void balanceChildHeights() {
final ObservableList<Node> children = container.getChildren();
final double heightPerChild = container.getHeight() / children.size();
for (final Node child : children) {
if (child instanceof Region) {
((Region) child).setPrefHeight(heightPerChild);
}
}
}
}

View File

@@ -1,237 +0,0 @@
package org.toop.app.layer.layers;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import javafx.application.Platform;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import org.toop.app.App;
import org.toop.app.GameInformation;
import org.toop.app.layer.Container;
import org.toop.app.layer.Layer;
import org.toop.app.layer.NodeBuilder;
import org.toop.app.layer.Popup;
import org.toop.app.layer.containers.HorizontalContainer;
import org.toop.app.layer.containers.VerticalContainer;
import org.toop.app.layer.layers.game.TicTacToeLayer;
import org.toop.framework.eventbus.EventFlow;
import org.toop.framework.networking.clients.TournamentNetworkingClient;
import org.toop.framework.networking.events.NetworkEvents;
import org.toop.local.AppContext;
public final class ConnectedLayer extends Layer {
private static Timer pollTimer = new Timer();
private static class ChallengePopup extends Popup {
private final GameInformation information;
private final String challenger;
private final String game;
private final long clientID;
private final int challengeID;
public ChallengePopup(
GameInformation information,
String challenger,
String game,
long clientID,
String challengeID) {
super(false, "bg-popup");
this.information = information;
this.challenger = challenger;
this.game = game;
this.clientID = clientID;
this.challengeID =
Integer.parseInt(challengeID.substring(18, challengeID.length() - 2));
reload();
}
@Override
public void reload() {
popAll();
final var challengeText = NodeBuilder.header(AppContext.getString("challengeText"));
final var challengerNameText = NodeBuilder.header(challenger);
final var gameText = NodeBuilder.text(AppContext.getString("gameIsText"));
final var gameNameText = NodeBuilder.text(game);
final var acceptButton =
NodeBuilder.button(
AppContext.getString("accept"),
() -> {
pollTimer.cancel();
new EventFlow()
.addPostEvent(
new NetworkEvents.SendAcceptChallenge(
clientID, challengeID))
.postEvent();
App.activate(new TicTacToeLayer(information, clientID));
});
final var denyButton =
NodeBuilder.button(
AppContext.getString("deny"),
() -> {
App.pop();
});
final Container controlContainer = new HorizontalContainer(30);
controlContainer.addNodes(acceptButton, denyButton);
final Container mainContainer = new VerticalContainer(30);
mainContainer.addNodes(challengeText, challengerNameText);
mainContainer.addNodes(gameText, gameNameText);
mainContainer.addContainer(controlContainer, false);
addContainer(mainContainer, Pos.CENTER, 0, 0, 30, 30);
}
}
GameInformation information;
long clientId;
String user;
List<String> onlinePlayers = new CopyOnWriteArrayList<>();
public ConnectedLayer(GameInformation information) {
super("bg-primary");
this.information = information;
new EventFlow()
.addPostEvent(
NetworkEvents.StartClient.class,
new TournamentNetworkingClient(),
information.serverIP(),
Integer.parseInt(information.serverPort()))
.onResponse(
NetworkEvents.StartClientResponse.class,
e -> {
clientId = e.clientId();
user = information.playerName()[0].replaceAll("\\s+", "");
new EventFlow()
.addPostEvent(
new NetworkEvents.SendLogin(this.clientId, this.user))
.postEvent();
Thread popThread = new Thread(this::populatePlayerList);
popThread.setDaemon(false);
popThread.start();
})
.postEvent();
new EventFlow().listen(this::handleReceivedChallenge);
reload();
}
private void populatePlayerList() {
EventFlow sendGetPlayerList =
new EventFlow().addPostEvent(new NetworkEvents.SendGetPlayerlist(this.clientId));
new EventFlow()
.listen(
NetworkEvents.PlayerlistResponse.class,
e -> {
if (e.clientId() == this.clientId) {
List<String> playerList =
new java.util.ArrayList<>(
List.of(e.playerlist())); // TODO: Garbage,
// but works
playerList.removeIf(name -> name.equalsIgnoreCase(user));
if (this.onlinePlayers != playerList) {
this.onlinePlayers.clear();
this.onlinePlayers.addAll(playerList);
}
}
});
TimerTask task =
new TimerTask() {
public void run() {
sendGetPlayerList.postEvent();
Platform.runLater(() -> reload());
}
};
pollTimer.schedule(task, 0L, 5000L); // TODO: Block app exit, fix later
}
private void sendChallenge(String oppUsername, String gameType) {
final AtomicInteger challengeId = new AtomicInteger(-1);
if (onlinePlayers.contains(oppUsername)) {
new EventFlow()
.addPostEvent(
new NetworkEvents.SendChallenge(this.clientId, oppUsername, gameType))
.listen(
NetworkEvents.ChallengeResponse.class,
e -> {
challengeId.set(
Integer.parseInt(
e.challengeId()
.substring(
18, e.challengeId().length() - 2)));
})
.listen(
NetworkEvents.GameMatchResponse.class,
e -> {
if (e.clientId() == this.clientId) {
pollTimer.cancel();
App.activate(new TicTacToeLayer(information, this.clientId));
}
},
false)
.postEvent();
// ^
// |
// |
// |
}
}
private void handleReceivedChallenge(NetworkEvents.ChallengeResponse response) {
App.push(
new ChallengePopup(
information,
response.challengerName(),
response.gameType(),
clientId,
response.challengeId()));
}
@Override
public void reload() {
popAll();
ListView<Label> players = new ListView<>();
for (int i = 0; i < onlinePlayers.size(); i++) {
int finalI = i;
players.getItems()
.add(
NodeBuilder.button(
onlinePlayers.get(i),
() -> {
String clickedPlayer = onlinePlayers.get(finalI);
sendChallenge(clickedPlayer, "tic-tac-toe");
}));
}
final Container playersContainer = new VerticalContainer(10);
playersContainer.addNodes(players);
addContainer(playersContainer, Pos.CENTER, 0, 0, 0, 0);
}
}

View File

@@ -1,73 +0,0 @@
package org.toop.app.layer.layers;
import javafx.animation.PauseTransition;
import javafx.animation.TranslateTransition;
import javafx.geometry.Pos;
import javafx.scene.text.Text;
import javafx.util.Duration;
import org.toop.app.App;
import org.toop.app.layer.Container;
import org.toop.app.layer.NodeBuilder;
import org.toop.app.layer.Popup;
import org.toop.app.layer.containers.HorizontalContainer;
import org.toop.app.layer.containers.VerticalContainer;
import org.toop.local.AppContext;
public final class CreditsPopup extends Popup {
private final int lineHeight = 100;
public CreditsPopup() {
super(true, "bg-primary");
reload();
}
@Override
public void reload() {
popAll();
final String[] credits = {
AppContext.getString("scrumMaster") + ": Stef",
AppContext.getString("productOwner") + ": Omar",
AppContext.getString("mergeCommander") + ": Bas",
AppContext.getString("localization") + ": Ticho",
AppContext.getString("ai") + ": Michiel",
AppContext.getString("developers") + ": Michiel, Bas, Stef, Omar, Ticho",
AppContext.getString("moralSupport") + ": Wesley",
AppContext.getString("opengl") + ": Omar"
};
final Text[] creditsHeaders = new Text[credits.length];
for (int i = 0; i < credits.length; i++) {
creditsHeaders[i] = NodeBuilder.header(credits[i]);
}
final Container creditsContainer = new HorizontalContainer(0);
final Container animatedContainer = new VerticalContainer(lineHeight);
creditsContainer.addContainer(animatedContainer, true);
animatedContainer.addNodes(creditsHeaders);
addContainer(creditsContainer, Pos.CENTER, 0, 0, 50, 100);
playCredits(animatedContainer, App.getHeight());
}
private void playCredits(Container container, double sceneLength) {
container.getContainer().setTranslateY(-sceneLength);
final TranslateTransition scrollCredits =
new TranslateTransition(Duration.seconds(20), container.getContainer());
scrollCredits.setFromY(-sceneLength - lineHeight);
scrollCredits.setToY(sceneLength + lineHeight);
scrollCredits.setOnFinished(
_ -> {
final PauseTransition pauseCredits = new PauseTransition(Duration.seconds(3));
pauseCredits.setOnFinished(_ -> playCredits(container, sceneLength));
pauseCredits.play();
});
scrollCredits.play();
}
}

View File

@@ -1,68 +0,0 @@
package org.toop.app.layer.layers;
import javafx.geometry.Pos;
import org.toop.app.App;
import org.toop.app.layer.Container;
import org.toop.app.layer.Layer;
import org.toop.app.layer.NodeBuilder;
import org.toop.app.layer.containers.VerticalContainer;
import org.toop.framework.audio.VolumeControl;
import org.toop.framework.audio.events.AudioEvents;
import org.toop.framework.eventbus.EventFlow;
import org.toop.local.AppContext;
public final class MainLayer extends Layer {
public MainLayer() {
super("bg-primary");
reload();
}
@Override
public void reload() {
popAll();
final var tictactoeButton =
NodeBuilder.button(
AppContext.getString("tictactoe"),
() -> {
App.activate(new MultiplayerLayer());
});
final var othelloButton =
NodeBuilder.button(
AppContext.getString("othello"),
() -> {
App.activate(new MultiplayerLayer());
});
final var creditsButton =
NodeBuilder.button(
AppContext.getString("credits"),
() -> {
App.push(new CreditsPopup());
});
final var optionsButton =
NodeBuilder.button(
AppContext.getString("options"),
() -> {
App.push(new OptionsPopup());
});
final var quitButton =
NodeBuilder.button(
AppContext.getString("quit"),
() -> {
App.quitPopup();
});
final Container gamesContainer = new VerticalContainer(5);
gamesContainer.addNodes(tictactoeButton, othelloButton);
final Container controlContainer = new VerticalContainer(5);
controlContainer.addNodes(creditsButton, optionsButton, quitButton);
addContainer(gamesContainer, Pos.TOP_LEFT, 2, 2, 20, 0);
addContainer(controlContainer, Pos.BOTTOM_LEFT, 2, -2, 20, 0);
}
}

View File

@@ -1,241 +0,0 @@
package org.toop.app.layer.layers;
import java.time.LocalDateTime;
import javafx.geometry.Pos;
import org.toop.app.App;
import org.toop.app.GameInformation;
import org.toop.app.layer.Container;
import org.toop.app.layer.Layer;
import org.toop.app.layer.NodeBuilder;
import org.toop.app.layer.containers.HorizontalContainer;
import org.toop.app.layer.containers.VerticalContainer;
import org.toop.app.layer.layers.game.TicTacToeLayer;
import org.toop.local.AppContext;
public final class MultiplayerLayer extends Layer {
private boolean isConnectionLocal = true;
private boolean isPlayer1Human = true;
private String player1Name = "";
private int computer1Difficulty = 0;
private int computer1ThinkTime = 0;
private boolean isPlayer2Human = true;
private String player2Name = "";
private int computer2Difficulty = 0;
private int computer2ThinkTime = 0;
private String serverIP = "";
private String serverPort = "";
public MultiplayerLayer() {
super("bg-primary");
reload();
}
@Override
public void reload() {
popAll();
final Container player1Container = new VerticalContainer(20);
final Container player2Container = new VerticalContainer(20);
final var isPlayer1HumanToggle =
NodeBuilder.toggle(
AppContext.getString("human"),
AppContext.getString("computer"),
!isPlayer1Human,
(computer) -> {
isPlayer1Human = !computer;
reload();
});
player1Container.addNodes(isPlayer1HumanToggle);
if (isPlayer1Human) {
final var playerNameText = NodeBuilder.text(AppContext.getString("playerName"));
final var playerNameInput =
NodeBuilder.input(
player1Name,
(name) -> {
player1Name = name;
});
player1Container.addNodes(playerNameText, playerNameInput);
} else {
player1Name = "Pism Bot V" + LocalDateTime.now().getSecond();
final var computerNameText = NodeBuilder.text(player1Name);
final var computerNameSeparator = NodeBuilder.separator();
final var computerDifficultyText =
NodeBuilder.text(AppContext.getString("computerDifficulty"));
final var computerDifficultySeparator = NodeBuilder.separator();
final var computerDifficultySlider =
NodeBuilder.slider(
10,
computer1Difficulty,
(difficulty) -> computer1Difficulty = difficulty);
final var computerThinkTimeText =
NodeBuilder.text(AppContext.getString("computerThinkTime"));
final var computerThinkTimeSlider =
NodeBuilder.slider(
5, computer1ThinkTime, (thinkTime) -> computer1ThinkTime = thinkTime);
player1Container.addNodes(
computerNameText,
computerNameSeparator,
computerDifficultyText,
computerDifficultySlider,
computerDifficultySeparator,
computerThinkTimeText,
computerThinkTimeSlider);
}
if (isConnectionLocal) {
final var isPlayer2HumanToggle =
NodeBuilder.toggle(
AppContext.getString("human"),
AppContext.getString("computer"),
!isPlayer2Human,
(computer) -> {
isPlayer2Human = !computer;
reload();
});
player2Container.addNodes(isPlayer2HumanToggle);
if (isPlayer2Human) {
final var playerNameText = NodeBuilder.text(AppContext.getString("playerName"));
final var playerNameInput =
NodeBuilder.input(
player2Name,
(name) -> {
player2Name = name;
});
player2Container.addNodes(playerNameText, playerNameInput);
} else {
player2Name = "Pism Bot V" + LocalDateTime.now().getSecond();
final var computerNameText = NodeBuilder.text(player2Name);
final var computerNameSeparator = NodeBuilder.separator();
final var computerDifficultyText =
NodeBuilder.text(AppContext.getString("computerDifficulty"));
final var computerDifficultySeparator = NodeBuilder.separator();
final var computerDifficultySlider =
NodeBuilder.slider(
10,
computer2Difficulty,
(difficulty) -> computer2Difficulty = difficulty);
final var computerThinkTimeText =
NodeBuilder.text(AppContext.getString("computerThinkTime"));
final var computerThinkTimeSlider =
NodeBuilder.slider(
5,
computer2ThinkTime,
(thinkTime) -> computer2ThinkTime = thinkTime);
player2Container.addNodes(
computerNameText,
computerNameSeparator,
computerDifficultyText,
computerDifficultySlider,
computerDifficultySeparator,
computerThinkTimeText,
computerThinkTimeSlider);
}
} else {
final var serverIPText = NodeBuilder.text(AppContext.getString("serverIP"));
final var serverIPSeparator = NodeBuilder.separator();
final var serverIPInput =
NodeBuilder.input(
serverIP,
(ip) -> {
serverIP = ip;
});
final var serverPortText = NodeBuilder.text(AppContext.getString("serverPort"));
final var serverPortInput =
NodeBuilder.input(
serverPort,
(port) -> {
serverPort = port;
});
player2Container.addNodes(
serverIPText,
serverIPInput,
serverIPSeparator,
serverPortText,
serverPortInput);
}
final var versusText = NodeBuilder.header("VS");
final var connectionTypeText =
NodeBuilder.text(AppContext.getString("connectionType") + ":");
final var connectionTypeToggle =
NodeBuilder.toggle(
AppContext.getString("local"),
AppContext.getString("server"),
!isConnectionLocal,
(server) -> {
isConnectionLocal = !server;
reload();
});
final var playButton =
NodeBuilder.button(
isConnectionLocal
? AppContext.getString("start")
: AppContext.getString("connect"),
() -> {
final var information =
new GameInformation(
new String[] {player1Name, player2Name},
new boolean[] {isPlayer1Human, isPlayer2Human},
new int[] {computer1Difficulty, computer2Difficulty},
new int[] {computer1ThinkTime, computer2ThinkTime},
isConnectionLocal,
serverIP,
serverPort);
if (isConnectionLocal) {
App.activate(new TicTacToeLayer(information));
} else {
App.activate(new ConnectedLayer(information));
}
});
final Container mainContainer = new VerticalContainer(10);
final Container playersContainer = new HorizontalContainer(5);
final Container connectionTypeContainer = new HorizontalContainer(10);
mainContainer.addContainer(playersContainer, true);
mainContainer.addContainer(connectionTypeContainer, false);
mainContainer.addNodes(playButton);
connectionTypeContainer.addNodes(connectionTypeText, connectionTypeToggle);
playersContainer.addContainer(player1Container, true);
playersContainer.addNodes(versusText);
playersContainer.addContainer(player2Container, true);
final var backButton =
NodeBuilder.button(
AppContext.getString("back"),
() -> {
App.activate(new MainLayer());
});
final Container controlContainer = new VerticalContainer(0);
controlContainer.addNodes(backButton);
addContainer(mainContainer, Pos.CENTER, 0, 0, 75, 75);
addContainer(controlContainer, Pos.BOTTOM_LEFT, 2, -2, 0, 0);
}
}

View File

@@ -1,223 +0,0 @@
package org.toop.app.layer.layers;
import java.util.Locale;
import javafx.geometry.Pos;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import org.toop.app.App;
import org.toop.app.layer.Container;
import org.toop.app.layer.NodeBuilder;
import org.toop.app.layer.Popup;
import org.toop.app.layer.containers.VerticalContainer;
import org.toop.framework.audio.VolumeControl;
import org.toop.framework.audio.events.AudioEvents;
import org.toop.framework.eventbus.EventFlow;
import org.toop.framework.resource.resources.SettingsAsset;
import org.toop.local.AppContext;
import org.toop.local.AppSettings;
public final class OptionsPopup extends Popup {
AppSettings appSettings = new AppSettings();
SettingsAsset settings = appSettings.getPath();
private boolean isWindowed = !(settings.getFullscreen());
public OptionsPopup() {
super(true, "bg-primary");
reload();
}
@Override
public void reload() {
popAll();
final var languageHeader = NodeBuilder.header(AppContext.getString("language"));
final var languageSeparator = NodeBuilder.separator();
final var volumeHeader = NodeBuilder.header(AppContext.getString("volume"));
final var volumeSeparator = NodeBuilder.separator();
final var fxVolumeHeader = NodeBuilder.header(AppContext.getString("effectsVolume"));
final var fxVolumeSeparator = NodeBuilder.separator();
final var musicVolumeHeader = NodeBuilder.header(AppContext.getString("musicVolume"));
final var musicVolumeSeparator = NodeBuilder.separator();
final var themeHeader = NodeBuilder.header(AppContext.getString("theme"));
final var themeSeparator = NodeBuilder.separator();
final var layoutSizeHeader = NodeBuilder.header(AppContext.getString("layoutSize"));
final var layoutSizeSeparator = NodeBuilder.separator();
final var optionsContainer = new VerticalContainer(5);
optionsContainer.addNodes(languageHeader, languageChoiceBox(), languageSeparator);
optionsContainer.addNodes(volumeHeader, volumeSlider(), volumeSeparator);
optionsContainer.addNodes(fxVolumeHeader, fxVolumeSlider(), fxVolumeSeparator);
optionsContainer.addNodes(musicVolumeHeader, musicVolumeSlider(), musicVolumeSeparator);
optionsContainer.addNodes(themeHeader, themeChoiceBox(), themeSeparator);
optionsContainer.addNodes(layoutSizeHeader, layoutSizeChoiceBox(), layoutSizeSeparator);
optionsContainer.addNodes(fullscreenToggle());
final Container mainContainer = new VerticalContainer(50, "");
mainContainer.addContainer(optionsContainer, true);
final var backButton =
NodeBuilder.button(
AppContext.getString("back"),
() -> {
App.pop();
});
final Container controlContainer = new VerticalContainer(5);
controlContainer.addNodes(backButton);
addContainer(mainContainer, Pos.CENTER, 0, 0, 0, 0);
addContainer(controlContainer, Pos.BOTTOM_LEFT, 2, -2, 0, 0);
}
private ChoiceBox<Locale> languageChoiceBox() {
assert AppContext.getLocalization() != null;
final ChoiceBox<Locale> languageChoiceBox =
NodeBuilder.choiceBox(
(locale) -> {
if (locale == AppContext.getLocale()) {
return;
}
settings.setLocale(locale.toString());
AppContext.setLocale(locale);
App.reloadAll();
});
languageChoiceBox.setConverter(
new javafx.util.StringConverter<>() {
@Override
public String toString(Locale locale) {
return AppContext.getString(locale.getDisplayName().toLowerCase());
}
@Override
public Locale fromString(String string) {
return null;
}
});
languageChoiceBox.getItems().addAll(AppContext.getLocalization().getAvailableLocales());
languageChoiceBox.setValue(AppContext.getLocale());
return languageChoiceBox;
}
private Slider volumeSlider() {
return NodeBuilder.slider(
100,
settings.getVolume(),
(volume) -> {
settings.setVolume(volume);
new EventFlow()
.addPostEvent(new AudioEvents.ChangeVolume(volume.doubleValue(), VolumeControl.MASTERVOLUME))
.asyncPostEvent();
});
}
private Slider fxVolumeSlider() {
return NodeBuilder.slider(
100,
settings.getFxVolume(),
(volume) -> {
settings.setFxVolume(volume);
new EventFlow()
.addPostEvent(new AudioEvents.ChangeVolume(volume.doubleValue(), VolumeControl.FX))
.asyncPostEvent();
});
}
private Slider musicVolumeSlider() {
return NodeBuilder.slider(
100,
settings.getMusicVolume(),
(volume) -> {
settings.setMusicVolume(volume);
new EventFlow()
.addPostEvent(new AudioEvents.ChangeVolume(volume.doubleValue(), VolumeControl.MUSIC))
.asyncPostEvent();
});
}
private Label fullscreenToggle() {
return NodeBuilder.toggle(
AppContext.getString("windowed"),
AppContext.getString("fullscreen"),
!isWindowed,
(fullscreen) -> {
isWindowed = !fullscreen;
settings.setFullscreen(fullscreen);
App.setFullscreen(fullscreen);
});
}
private ChoiceBox<String> themeChoiceBox() {
final ChoiceBox<String> themeChoiceBox =
NodeBuilder.choiceBox(
(theme) -> {
if (theme.equalsIgnoreCase(settings.getTheme())) {
return;
}
settings.setTheme(theme);
App.setStyle(theme, settings.getLayoutSize());
});
themeChoiceBox.setConverter(
new javafx.util.StringConverter<>() {
@Override
public String toString(String theme) {
return AppContext.getString(theme);
}
@Override
public String fromString(String string) {
return null;
}
});
themeChoiceBox.getItems().addAll("dark", "light", "dark-hc", "light-hc");
themeChoiceBox.setValue(settings.getTheme());
return themeChoiceBox;
}
private ChoiceBox<String> layoutSizeChoiceBox() {
final ChoiceBox<String> layoutSizeChoiceBox =
NodeBuilder.choiceBox(
(layoutSize) -> {
if (layoutSize.equalsIgnoreCase(settings.getLayoutSize())) {
return;
}
settings.setLayoutSize(layoutSize);
App.setStyle(settings.getTheme(), layoutSize);
});
layoutSizeChoiceBox.setConverter(
new javafx.util.StringConverter<>() {
@Override
public String toString(String layoutSize) {
return AppContext.getString(layoutSize);
}
@Override
public String fromString(String string) {
return null;
}
});
layoutSizeChoiceBox.getItems().addAll("small", "medium", "large");
layoutSizeChoiceBox.setValue(settings.getLayoutSize());
return layoutSizeChoiceBox;
}
}

View File

@@ -1,47 +0,0 @@
package org.toop.app.layer.layers;
import javafx.geometry.Pos;
import org.toop.app.App;
import org.toop.app.layer.Container;
import org.toop.app.layer.NodeBuilder;
import org.toop.app.layer.Popup;
import org.toop.app.layer.containers.HorizontalContainer;
import org.toop.app.layer.containers.VerticalContainer;
import org.toop.local.AppContext;
public final class QuitPopup extends Popup {
public QuitPopup() {
super(true);
reload();
}
@Override
public void reload() {
popAll();
final var sureText = NodeBuilder.header(AppContext.getString("quitSure"));
final var yesButton =
NodeBuilder.button(
AppContext.getString("yes"),
() -> {
App.quit();
});
final var noButton =
NodeBuilder.button(
AppContext.getString("no"),
() -> {
App.pop();
});
final Container controlContainer = new HorizontalContainer(30);
controlContainer.addNodes(yesButton, noButton);
final Container mainContainer = new VerticalContainer(30);
mainContainer.addNodes(sureText);
mainContainer.addContainer(controlContainer, false);
addContainer(mainContainer, Pos.CENTER, 0, 0, 30, 30);
}
}

View File

@@ -1,55 +0,0 @@
package org.toop.app.layer.layers.game;
import javafx.geometry.Pos;
import org.toop.app.App;
import org.toop.app.layer.Container;
import org.toop.app.layer.NodeBuilder;
import org.toop.app.layer.Popup;
import org.toop.app.layer.containers.VerticalContainer;
import org.toop.app.layer.layers.MainLayer;
import org.toop.local.AppContext;
public class GameFinishedPopup extends Popup {
private final boolean isDraw;
private final String winner;
public GameFinishedPopup(boolean isDraw, String winner) {
super(true, "bg-popup");
this.isDraw = isDraw;
this.winner = winner;
reload();
}
@Override
public void reload() {
popAll();
final Container mainContainer = new VerticalContainer(30);
if (isDraw) {
final var drawHeader = NodeBuilder.header(AppContext.getString("drawText"));
final var goodGameText = NodeBuilder.text(AppContext.getString("goodGameText"));
mainContainer.addNodes(drawHeader, goodGameText);
} else {
final var winHeader =
NodeBuilder.header(AppContext.getString("congratulations") + ": " + winner);
final var goodGameText = NodeBuilder.text(AppContext.getString("goodGameText"));
mainContainer.addNodes(winHeader, goodGameText);
}
final var backToMainMenuButton =
NodeBuilder.button(
AppContext.getString("backToMainMenu"),
() -> {
App.activate(new MainLayer());
});
mainContainer.addNodes(backToMainMenuButton);
addContainer(mainContainer, Pos.CENTER, 0, 0, 30, 30);
}
}

View File

@@ -1,331 +0,0 @@
package org.toop.app.layer.layers.game;
import java.util.Objects;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import javafx.geometry.Pos;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import org.toop.app.App;
import org.toop.app.GameInformation;
import org.toop.app.canvas.TicTacToeCanvas;
import org.toop.app.layer.Container;
import org.toop.app.layer.Layer;
import org.toop.app.layer.NodeBuilder;
import org.toop.app.layer.containers.HorizontalContainer;
import org.toop.app.layer.containers.VerticalContainer;
import org.toop.app.layer.layers.MainLayer;
import org.toop.framework.eventbus.EventFlow;
import org.toop.framework.networking.events.NetworkEvents;
import org.toop.game.Game;
import org.toop.game.tictactoe.TicTacToe;
import org.toop.game.tictactoe.TicTacToeAI;
import org.toop.local.AppContext;
public final class TicTacToeLayer extends Layer {
private TicTacToeCanvas canvas;
private AtomicReference<TicTacToe> ticTacToe;
private TicTacToeAI ticTacToeAI;
private GameInformation information;
private final Text currentPlayerNameText;
private final Text currentPlayerMoveText;
private final BlockingQueue<Game.Move> playerMoveQueue = new LinkedBlockingQueue<>();
// Todo: set these from the server
private char currentPlayerMove = Game.EMPTY;
private String player2Name = "";
final AtomicBoolean firstPlayerIsMe = new AtomicBoolean(true);
public TicTacToeLayer(GameInformation information) {
super("bg-primary");
canvas =
new TicTacToeCanvas(
Color.LIME,
(App.getHeight() / 100) * 75,
(App.getHeight() / 100) * 75,
(cell) -> {
try {
if (information.isConnectionLocal()) {
if (ticTacToe.get().getCurrentTurn() == 0) {
playerMoveQueue.put(new Game.Move(cell, 'X'));
} else {
playerMoveQueue.put(new Game.Move(cell, 'O'));
}
} else {
if (information.isPlayerHuman()[0]
&& currentPlayerMove != Game.EMPTY) {
playerMoveQueue.put(
new Game.Move(
cell, firstPlayerIsMe.get() ? 'X' : 'O'));
}
}
} catch (InterruptedException _) {
}
});
ticTacToe = new AtomicReference<>(new TicTacToe());
ticTacToeAI = new TicTacToeAI();
this.information = information;
if (information.isConnectionLocal()) {
new Thread(this::localGameThread).start();
}
currentPlayerNameText = NodeBuilder.header("");
currentPlayerMoveText = NodeBuilder.header("");
reload();
}
public TicTacToeLayer(GameInformation information, long clientID) {
this(information);
Thread a = new Thread(this::serverGameThread);
a.setDaemon(false);
a.start();
reload();
}
@Override
public void reload() {
popAll();
canvas.resize((App.getHeight() / 100) * 75, (App.getHeight() / 100) * 75);
for (int i = 0; i < ticTacToe.get().board.length; i++) {
final char value = ticTacToe.get().board[i];
if (value == 'X') {
canvas.drawX(Color.RED, i);
} else if (value == 'O') {
canvas.drawO(Color.BLUE, i);
}
}
final var backButton =
NodeBuilder.button(
AppContext.getString("back"),
() -> {
App.activate(new MainLayer());
});
final Container controlContainer = new VerticalContainer(5);
controlContainer.addNodes(backButton);
final Container informationContainer = new HorizontalContainer(15);
informationContainer.addNodes(currentPlayerNameText, currentPlayerMoveText);
addContainer(controlContainer, Pos.BOTTOM_LEFT, 2, -2, 0, 0);
addContainer(informationContainer, Pos.TOP_LEFT, 2, 2, 0, 0);
addGameCanvas(canvas, Pos.CENTER, 0, 0);
}
private int compurterDifficultyToDepth(int maxDifficulty, int difficulty) {
return (int) (((float) maxDifficulty / difficulty) * 9);
}
private void localGameThread() {
boolean running = true;
while (running) {
final int currentPlayer = ticTacToe.get().getCurrentTurn();
currentPlayerNameText.setText(information.playerName()[currentPlayer]);
currentPlayerMoveText.setText(ticTacToe.get().getCurrentTurn() == 0 ? "X" : "O");
Game.Move move = null;
if (information.isPlayerHuman()[currentPlayer]) {
try {
final Game.Move wants = playerMoveQueue.take();
final Game.Move[] legalMoves = ticTacToe.get().getLegalMoves();
for (final Game.Move legalMove : legalMoves) {
if (legalMove.position() == wants.position()
&& legalMove.value() == wants.value()) {
move = wants;
// TODO: maybe add break?
}
}
} catch (InterruptedException _) {
}
} else {
final long start = System.currentTimeMillis();
move =
ticTacToeAI.findBestMove(
ticTacToe.get(),
compurterDifficultyToDepth(
10, information.computerDifficulty()[currentPlayer]));
if (information.computerThinkTime()[currentPlayer] > 0) {
final long elapsedTime = System.currentTimeMillis() - start;
final long sleepTime =
information.computerThinkTime()[currentPlayer] * 1000L - elapsedTime;
try {
Thread.sleep(sleepTime);
} catch (InterruptedException _) {
}
}
}
if (move == null) {
continue;
}
final Game.State state = ticTacToe.get().play(move);
if (move.value() == 'X') {
canvas.drawX(Color.RED, move.position());
} else if (move.value() == 'O') {
canvas.drawO(Color.BLUE, move.position());
}
if (state != Game.State.NORMAL) {
if (state == Game.State.WIN) {
App.push(
new GameFinishedPopup(
false,
information.playerName()[ticTacToe.get().getCurrentTurn()]));
} else if (state == Game.State.DRAW) {
App.push(new GameFinishedPopup(true, ""));
}
running = false;
}
}
}
private void serverGameThread() {
new EventFlow()
.listen(this::handleServerGameStart) // <-----------
.listen(this::yourTurnResponse)
.listen(this::onMoveResponse)
.listen(this::handleReceivedMessage);
}
private void handleServerGameStart(NetworkEvents.GameMatchResponse resp) {
// Meneer Bas de Jong. Dit functie wordt niet aangeroepen als je de challenger bent.
// Ik heb veel dingen geprobeerd. FUCKING veel dingen. Hij doet het niet.
// Ik heb zelfs in jouw code gekeken en unsubscribeAfterSuccess op false gezet. (zie
// ConnectedLayer).
// Alle andere functies worden wel gecalld. Behalve dit.
// Ben jij gehandicapt of ik? Want het moet 1 van de 2 zijn. Ik ben dit al 2 uur aan het
// debuggen.
// Ik ga nu slapen (04:46).
// ⠀⠀⠀⠀⠀⠀⣀⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⢀⣴⣿⣿⠿⣟⢷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⢸⣏⡏⠀⠀⠀⢣⢻⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⢸⣟⠧⠤⠤⠔⠋⠀⢿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⣿⡆⠀⠀⠀⠀⠀⠸⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠘⣿⡀⢀⣶⠤⠒⠀⢻⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠈⢿⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⣿⡆⠀⠀⠀⠀⠀⠈⢿⣆⣠⣤⣤⣤⣤⣴⣦⣄⡀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⢀⣾⢿⢿⠀⠀⠀⢀⣀⣀⠘⣿⠋⠁⠀⠙⢇⠀⠀⠙⢿⣦⡀⠀⠀⠀⠀⠀
// ⠀⠀⠀⢀⣾⢇⡞⠘⣧⠀⢖⡭⠞⢛⡄⠘⣆⠀⠀⠀⠈⢧⠀⠀⠀⠙⢿⣄⠀⠀⠀⠀
// ⠀⠀⣠⣿⣛⣥⠤⠤⢿⡄⠀⠀⠈⠉⠀⠀⠹⡄⠀⠀⠀⠈⢧⠀⠀⠀⠈⠻⣦⠀⠀⠀
// ⠀⣼⡟⡱⠛⠙⠀⠀⠘⢷⡀⠀⠀⠀⠀⠀⠀⠹⡀⠀⠀⠀⠈⣧⠀⠀⠀⠀⠹⣧⡀⠀
// ⢸⡏⢠⠃⠀⠀⠀⠀⠀⠀⢳⡀⠀⠀⠀⠀⠀⠀⢳⡀⠀⠀⠀⠘⣧⠀⠀⠀⠀⠸⣷⡀
// ⠸⣧⠘⡇⠀⠀⠀⠀⠀⠀⠀⢳⡀⠀⠀⠀⠀⠀⠀⢣⠀⠀⠀⠀⢹⡇⠀⠀⠀⠀⣿⠇
// ⠀⣿⡄⢳⠀⠀⠀⠀⠀⠀⠀⠈⣷⠀⠀⠀⠀⠀⠀⠈⠆⠀⠀⠀⠀⠀⠀⠀⠀⣼⡟⠀
// ⠀⢹⡇⠘⣇⠀⠀⠀⠀⠀⠀⠰⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⣼⡟⠀⠀
// ⠀⢸⡇⠀⢹⡆⠀⠀⠀⠀⠀⠀⠙⠁⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀⠀⢳⣼⠟⠀⠀⠀
// ⠀⠸⣧⣀⠀⢳⡀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠀⠀⠀⢃⠀⢀⣴⡿⠁⠀⠀⠀⠀
// ⠀⠀⠈⠙⢷⣄⢳⡀⠀⠀⠀⠀⠀⠀⢳⡀⠀⠀⠀⠀⠀⣠⡿⠟⠛⠉⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠈⠻⢿⣷⣦⣄⣀⣀⣠⣤⠾⠷⣦⣤⣤⡶⠟⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠈⠉⠛⠛⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
player2Name = resp.opponent();
System.out.println(player2Name);
currentPlayerMoveText.setText("X");
if (!resp.playerToMove().equalsIgnoreCase(resp.opponent())) {
currentPlayerNameText.setText(information.playerName()[0]);
firstPlayerIsMe.set(true);
System.out.printf("I am starting: My client id is %d\n", resp.clientId());
} else {
currentPlayerNameText.setText(player2Name);
firstPlayerIsMe.set(false);
System.out.printf("I am NOT starting: My client id is %d\n", resp.clientId());
}
}
private void onMoveResponse(NetworkEvents.GameMoveResponse resp) {
char playerChar;
if (!resp.player().equalsIgnoreCase(player2Name)) {
playerChar = firstPlayerIsMe.get() ? 'X' : 'O';
} else {
playerChar = firstPlayerIsMe.get() ? 'O' : 'X';
}
final Game.Move move = new Game.Move(Integer.parseInt(resp.move()), playerChar);
final Game.State state = ticTacToe.get().play(move);
if (state
!= Game.State.NORMAL) { // todo differentiate between future draw guaranteed and is
// currently a draw
if (state == Game.State.WIN) {
App.push(
new GameFinishedPopup(
false, information.playerName()[ticTacToe.get().getCurrentTurn()]));
} else if (state == Game.State.DRAW) {
App.push(new GameFinishedPopup(true, ""));
}
}
if (move.value() == 'X') {
canvas.drawX(Color.RED, move.position());
} else if (move.value() == 'O') {
canvas.drawO(Color.BLUE, move.position());
}
currentPlayerNameText.setText(
ticTacToe.get().getCurrentTurn() == (firstPlayerIsMe.get() ? 0 : 1)
? information.playerName()[0]
: player2Name);
currentPlayerMoveText.setText(ticTacToe.get().getCurrentTurn() == 0 ? "X" : "O");
}
private void yourTurnResponse(NetworkEvents.YourTurnResponse response) {
int position = -1;
if (information.isPlayerHuman()[0]) {
try {
position = playerMoveQueue.take().position();
} catch (InterruptedException _) {
}
} else {
final Game.Move move =
ticTacToeAI.findBestMove(
ticTacToe.get(),
compurterDifficultyToDepth(10, information.computerDifficulty()[0]));
position = Objects.requireNonNull(move).position();
}
new EventFlow()
.addPostEvent(new NetworkEvents.SendMove(response.clientId(), (short) position))
.postEvent();
}
private void handleReceivedMessage(NetworkEvents.ReceivedMessage msg) {
System.out.println("Received Message: " + msg.message()); // todo add chat window
}
}

View File

@@ -0,0 +1,400 @@
package org.toop.app.view;
import org.toop.framework.audio.events.AudioEvents;
import org.toop.framework.eventbus.EventFlow;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Separator;
import javafx.scene.control.Slider;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import java.util.HashMap;
import java.util.Map;
public abstract class View {
private final boolean mainView;
private final StackPane view;
private final Map<String, Node> nodeMap;
protected View(boolean mainView, String cssClass) {
this.mainView = mainView;
view = new StackPane();
view.getStyleClass().add(cssClass);
nodeMap = new HashMap<String, Node>();
}
public void add(Pos position, Node node) {
assert node != null;
StackPane.setAlignment(node, position);
view.getChildren().add(node);
}
protected Region hspacer() {
final Region hspacer = new Region();
hspacer.getStyleClass().add("hspacer");
return hspacer;
}
protected Region vspacer() {
final Region vspacer = new Region();
vspacer.getStyleClass().add("vspacer");
return vspacer;
}
protected ScrollPane fit(String identifier, String cssClass, Node node) {
assert node != null;
final ScrollPane fit = new ScrollPane(node);
fit.getStyleClass().add(cssClass);
fit.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
fit.setFitToWidth(true);
fit.setFitToHeight(true);
if (!identifier.isEmpty()) {
nodeMap.put(identifier, fit);
}
return fit;
}
protected ScrollPane fit(String identifier, Node node) {
return fit(identifier, "fit", node);
}
protected ScrollPane fit(Node node) {
return fit("", node);
}
protected HBox hbox(String identifier, String cssClass, Node... nodes) {
assert !nodeMap.containsKey(identifier);
final HBox hbox = new HBox();
hbox.getStyleClass().add(cssClass);
hbox.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
for (final Node node : nodes) {
if (node != null) {
hbox.getChildren().add(node);
}
}
if (!identifier.isEmpty()) {
nodeMap.put(identifier, hbox);
}
return hbox;
}
protected HBox hbox(String identifier, Node... nodes) {
return hbox(identifier, "container", nodes);
}
protected HBox hbox(Node... nodes) {
return hbox("", nodes);
}
protected HBox hboxFill(String identifier, String cssClass, Node... nodes) {
final HBox hbox = hbox(identifier, cssClass, nodes);
for (final Node node : hbox.getChildren()) {
if (node instanceof Region) {
((Region)node).setMaxHeight(Double.MAX_VALUE);
}
}
return hbox;
}
protected HBox hboxFill(String identifier, Node... nodes) {
final HBox hbox = hbox(identifier, nodes);
for (final Node node : hbox.getChildren()) {
if (node instanceof Region) {
((Region)node).setMaxHeight(Double.MAX_VALUE);
}
}
return hbox;
}
protected HBox hboxFill(Node... nodes) {
final HBox hbox = hbox(nodes);
for (final Node node : hbox.getChildren()) {
if (node instanceof Region) {
((Region)node).setMaxHeight(Double.MAX_VALUE);
}
}
return hbox;
}
protected VBox vbox(String identifier, String cssClass, Node... nodes) {
assert !nodeMap.containsKey(identifier);
final VBox vbox = new VBox();
vbox.getStyleClass().add(cssClass);
vbox.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
for (final Node node : nodes) {
if (node != null) {
vbox.getChildren().add(node);
}
}
if (!identifier.isEmpty()) {
nodeMap.put(identifier, vbox);
}
return vbox;
}
protected VBox vbox(String identifier, Node... nodes) {
return vbox(identifier, "container", nodes);
}
protected VBox vbox(Node... nodes) {
return vbox("", nodes);
}
protected VBox vboxFill(String identifier, String cssClass, Node... nodes) {
final VBox vbox = vbox(identifier, cssClass, nodes);
for (final Node node : vbox.getChildren()) {
if (node instanceof Region) {
((Region)node).setMaxWidth(Double.MAX_VALUE);
}
}
return vbox;
}
protected VBox vboxFill(String identifier, Node... nodes) {
final VBox vbox = vbox(identifier, nodes);
for (final Node node : vbox.getChildren()) {
if (node instanceof Region) {
((Region)node).setMaxWidth(Double.MAX_VALUE);
}
}
return vbox;
}
protected VBox vboxFill(Node... nodes) {
final VBox vbox = vbox(nodes);
for (final Node node : vbox.getChildren()) {
if (node instanceof Region) {
((Region)node).setMaxWidth(Double.MAX_VALUE);
}
}
return vbox;
}
protected Separator separator(String identifier, String cssClass) {
assert !nodeMap.containsKey(identifier);
final Separator separator = new Separator();
separator.getStyleClass().add(cssClass);
if (!identifier.isEmpty()) {
nodeMap.put(identifier, separator);
}
return separator;
}
protected Separator separator(String identifier) {
return separator(identifier, "separator");
}
protected Separator separator() {
return separator("");
}
protected Text header(String identifier, String cssClass) {
assert !nodeMap.containsKey(identifier);
final Text header = new Text();
header.getStyleClass().add(cssClass);
if (!identifier.isEmpty()) {
nodeMap.put(identifier, header);
}
return header;
}
protected Text header(String identifier) {
return header(identifier, "header");
}
protected Text header() {
return header("");
}
protected Text text(String identifier, String cssClass) {
assert !nodeMap.containsKey(identifier);
final Text text = new Text();
text.getStyleClass().add(cssClass);
if (!identifier.isEmpty()) {
nodeMap.put(identifier, text);
}
return text;
}
protected Text text(String identifier) {
return text(identifier, "text");
}
protected Text text() {
return text("");
}
protected Button button(String identifier, String cssClass) {
assert !nodeMap.containsKey(identifier);
final Button button = new Button();
button.getStyleClass().add(cssClass);
button.setOnMouseClicked(_ -> {
new EventFlow().addPostEvent(new AudioEvents.ClickButton()).asyncPostEvent();
});
if (!identifier.isEmpty()) {
nodeMap.put(identifier, button);
}
return button;
}
protected Button button(String identifier) {
return button(identifier, "button");
}
protected Button button() {
return button("");
}
protected Slider slider(String identifier, String cssClass) {
assert !nodeMap.containsKey(identifier);
final Slider slider = new Slider();
slider.getStyleClass().add(cssClass);
slider.setMinorTickCount(0);
slider.setMajorTickUnit(1);
slider.setBlockIncrement(1);
slider.setSnapToTicks(true);
slider.setShowTickLabels(true);
slider.setOnMouseClicked(_ -> {
new EventFlow().addPostEvent(new AudioEvents.ClickButton()).asyncPostEvent();
});
if (!identifier.isEmpty()) {
nodeMap.put(identifier, slider);
}
return slider;
}
protected Slider slider(String identifier) {
return slider(identifier, "slider");
}
protected Slider slider() {
return slider("");
}
protected TextField input(String identifier, String cssClass) {
assert !nodeMap.containsKey(identifier);
final TextField input = new TextField();
input.getStyleClass().add(cssClass);
input.setOnMouseClicked(_ -> {
new EventFlow().addPostEvent(new AudioEvents.ClickButton()).asyncPostEvent();
});
if (!identifier.isEmpty()) {
nodeMap.put(identifier, input);
}
return input;
}
protected TextField input(String identifier) {
return input(identifier, "input");
}
protected TextField input() {
return input("");
}
protected <T> ComboBox<T> combobox(String identifier, String cssClass) {
assert !nodeMap.containsKey(identifier);
final ComboBox<T> combobox = new ComboBox<T>();
combobox.getStyleClass().add(cssClass);
combobox.setOnMouseClicked(_ -> {
new EventFlow().addPostEvent(new AudioEvents.ClickButton()).asyncPostEvent();
});
if (!identifier.isEmpty()) {
nodeMap.put(identifier, combobox);
}
return combobox;
}
protected <T> ComboBox<T> combobox(String identifier) {
return combobox(identifier, "combo-box");
}
protected <T> ComboBox<T> combobox() {
return combobox("");
}
@SuppressWarnings("unchecked")
protected <T extends Node> T get(String identifier) {
assert nodeMap.containsKey(identifier);
return (T) nodeMap.get(identifier);
}
protected void clear() {
view.getChildren().clear();
nodeMap.clear();
}
public boolean isMainView() { return mainView; }
public Region getView() { return view; }
public abstract void setup();
public void cleanup() {
clear();
}
}

View File

@@ -0,0 +1,105 @@
package org.toop.app.view;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import java.util.Stack;
public final class ViewStack {
private static boolean setup = false;
private static StackPane root;
private static View active;
private static Stack<View> stack;
public static void setup(Scene scene) {
assert scene != null;
if (setup) {
return;
}
root = new StackPane();
active = null;
stack = new Stack<View>();
scene.setRoot(root);
setup = true;
}
public static void cleanup() {
assert setup;
final var count = stack.size();
for (int i = 0; i < count; i++) {
pop();
}
if (active != null) {
active.cleanup();
}
setup = false;
}
public static void reload() {
assert setup;
for (final var view : stack) {
view.cleanup();
}
if (active != null) {
active.cleanup();
active.setup();
}
for (final var view : stack) {
view.setup();
}
}
public static void push(View view) {
assert setup;
assert view != null;
if (view.isMainView()) {
Platform.runLater(() -> {
if (active != null) {
root.getChildren().removeFirst();
active.cleanup();
}
root.getChildren().addFirst(view.getView());
view.setup();
active = view;
});
} else {
Platform.runLater(() -> {
stack.push(view);
root.getChildren().addLast(view.getView());
view.setup();
});
}
}
public static void pop() {
assert setup;
if (stack.isEmpty()) {
return;
}
Platform.runLater(() -> {
final var last = stack.pop();
root.getChildren().removeLast();
last.cleanup();
});
}
}

View File

@@ -0,0 +1,118 @@
package org.toop.app.view.views;
import org.toop.app.GameInformation;
import org.toop.app.Server;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.local.AppContext;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Slider;
import javafx.scene.text.Text;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
public final class ChallengeView extends View {
private final GameInformation.Player playerInformation;
private final String challenger;
private final String game;
private final Consumer<GameInformation.Player> onAccept;
public ChallengeView(String challenger, String game, Consumer<GameInformation.Player> onAccept) {
super(false, "bg-popup");
playerInformation = new GameInformation.Player();
this.challenger = challenger;
this.game = game;
this.onAccept = onAccept;
}
@Override
public void setup() {
final Text challengeText = text();
challengeText.setText(AppContext.getString("you-were-challenged-by"));
final Text challengerHeader = header();
challengerHeader.setText(challenger);
final Text gameText = text();
gameText.setText(AppContext.getString("to-a-game-of") + " " + game);
final Button acceptButton = button();
acceptButton.setText(AppContext.getString("accept"));
acceptButton.setOnAction(_ -> {
onAccept.accept(playerInformation);
});
final Button denyButton = button();
denyButton.setText(AppContext.getString("deny"));
denyButton.setOnAction(_ -> {
ViewStack.pop();
});
final List<Node> nodes = new ArrayList<>();
if (playerInformation.isHuman) {
final Button playerToggle = button();
playerToggle.setText(AppContext.getString("player"));
playerToggle.setOnAction(_ -> {
playerInformation.isHuman = false;
cleanup();
setup();
});
nodes.add(vbox(playerToggle));
} else {
final Button computerToggle = button();
computerToggle.setText(AppContext.getString("computer"));
computerToggle.setOnAction(_ -> {
playerInformation.isHuman = true;
cleanup();
setup();
});
nodes.add(vbox(computerToggle));
final Text computerDifficultyText = text();
computerDifficultyText.setText(AppContext.getString("computer-difficulty"));
final Slider computerDifficultySlider = slider();
computerDifficultySlider.setMin(0);
computerDifficultySlider.setMax(GameInformation.Type.maxDepth(Server.gameToType(game)));
computerDifficultySlider.setValue(playerInformation.computerDifficulty);
computerDifficultySlider.valueProperty().addListener((_, _, newValue) -> {
playerInformation.computerDifficulty = newValue.intValue();
});
nodes.add(vbox(computerDifficultyText, computerDifficultySlider));
}
add(Pos.CENTER,
fit(hboxFill(
vboxFill(
challengeText,
challengerHeader,
gameText,
separator(),
hboxFill(
acceptButton,
denyButton
)
),
vboxFill(
nodes.toArray(new Node[0])
)
))
);
}
}

View File

@@ -0,0 +1,101 @@
package org.toop.app.view.views;
import org.toop.app.App;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.local.AppContext;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.util.Duration;
public final class CreditsView extends View {
public CreditsView() {
super(false, "bg-primary");
}
@Override
public void setup() {
final Text scrumMasterHeader = header();
scrumMasterHeader.setText(AppContext.getString("scrum-master") + ": Stef");
final Text productOwnerHeader = header();
productOwnerHeader.setText(AppContext.getString("product-owner") + ": Omar");
final Text mergeCommanderHeader = header();
mergeCommanderHeader.setText(AppContext.getString("merge-commander") + ": Bas");
final Text localizationHeader = header();
localizationHeader.setText(AppContext.getString("localization") + ": Ticho");
final Text aiHeader = header();
aiHeader.setText(AppContext.getString("ai") + ": Michiel");
final Text developersHeader = header();
developersHeader.setText(AppContext.getString("developers") + ": Michiel, Bas, Stef, Omar, Ticho");
final Text moralSupportHeader = header();
moralSupportHeader.setText(AppContext.getString("moral-support") + ": Wesley");
final Text openglHeader = header();
openglHeader.setText(AppContext.getString("opengl") + ": Omar");
add(Pos.CENTER,
fit("credits-fit", vboxFill("credits-container", "credits-container",
vbox("credits-spacer-top", ""),
scrumMasterHeader,
productOwnerHeader,
mergeCommanderHeader,
localizationHeader,
aiHeader,
developersHeader,
moralSupportHeader,
openglHeader,
vbox("credits-spacer-bottom", "")
))
);
final Button backButton = button();
backButton.setText(AppContext.getString("back"));
backButton.setOnAction(_ -> { ViewStack.pop(); });
add(Pos.BOTTOM_LEFT,
vboxFill(
backButton
)
);
playCredits(100, 20);
}
private void playCredits(int lineHeight, int length) {
final ScrollPane creditsFit = get("credits-fit");
creditsFit.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
creditsFit.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
final VBox creditsContainer = get("credits-container");
creditsContainer.setSpacing(lineHeight);
final VBox creditsSpacerTop = get("credits-spacer-top");
creditsSpacerTop.setMinHeight(App.getHeight() - lineHeight);
final VBox creditsSpacerBottom = get("credits-spacer-bottom");
creditsSpacerBottom.setMinHeight(App.getHeight() - lineHeight);
final Timeline timeline = new Timeline(
new KeyFrame(Duration.seconds(0), new KeyValue(creditsFit.vvalueProperty(), 0.0)),
new KeyFrame(Duration.seconds(length), new KeyValue(creditsFit.vvalueProperty(), 1.0))
);
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
}
}

View File

@@ -0,0 +1,45 @@
package org.toop.app.view.views;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.local.AppContext;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.text.Text;
public final class ErrorView extends View {
private final String error;
public ErrorView(String error) {
super(false, "bg-popup");
this.error = error;
}
@Override
public void setup() {
final Text errorHeader = header();
errorHeader.setText(AppContext.getString("error"));
final Text errorText = text();
errorText.setText(error);
final Button okButton = button();
okButton.setText(AppContext.getString("ok"));
okButton.setOnAction(_ -> { ViewStack.pop(); });
add(Pos.CENTER,
vboxFill(
errorHeader,
separator(),
vspacer(),
errorText,
vspacer(),
separator(),
okButton
)
);
}
}

View File

@@ -0,0 +1,171 @@
package org.toop.app.view.views;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.local.AppContext;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.scene.control.TextField;
import javafx.scene.text.Text;
import java.util.function.Consumer;
public final class GameView extends View {
private static class GameOverView extends View {
private final boolean iWon;
private final String winner;
public GameOverView(boolean iWon, String winner) {
super(false, "bg-popup");
this.iWon = iWon;
this.winner = winner;
}
@Override
public void setup() {
final Text gameOverHeader = header();
gameOverHeader.setText(AppContext.getString("game-over"));
final Button okButton = button();
okButton.setText(AppContext.getString("ok"));
okButton.setOnAction(_ -> { ViewStack.pop(); });
Text gameOverText = text();
if (winner.isEmpty()) {
gameOverText.setText(AppContext.getString("the-game-ended-in-a-draw"));
} else {
if (iWon) {
gameOverText.setText(AppContext.getString("you-win") + " " + winner);
} else {
gameOverText.setText(AppContext.getString("you-lost-against") + " " + winner);
}
}
add(Pos.CENTER,
fit(vboxFill(
gameOverHeader,
separator(),
vspacer(),
gameOverText,
vspacer(),
separator(),
okButton
))
);
}
}
private final Button forfeitButton;
private final Button exitButton;
private final Text currentPlayerHeader;
private final Text currentMoveHeader;
private final Text nextPlayerHeader;
private final ListView<Text> chatListView;
private final TextField chatInput;
public GameView(Runnable onForfeit, Runnable onExit, Consumer<String> onMessage) {
assert onExit != null;
super(true, "bg-primary");
if (onForfeit != null) {
forfeitButton = button();
forfeitButton.setText(AppContext.getString("forfeit"));
forfeitButton.setOnAction(_ -> onForfeit.run());
} else {
forfeitButton = null;
}
if (onMessage != null) {
chatListView = new ListView<Text>();
chatInput = input();
chatInput.setOnAction(_ -> {
onMessage.accept(chatInput.getText());
chatInput.setText("");
});
} else {
chatListView = null;
chatInput = null;
}
exitButton = button();
exitButton.setText(AppContext.getString("exit"));
exitButton.setOnAction(_ -> onExit.run());
currentPlayerHeader = header("", "current-player");
currentMoveHeader = header();
nextPlayerHeader = header();
}
@Override
public void setup() {
add(Pos.TOP_RIGHT,
fit(vboxFill(
currentPlayerHeader,
hboxFill(
separator(),
currentMoveHeader,
separator()
),
nextPlayerHeader
))
);
add(Pos.BOTTOM_LEFT,
vboxFill(
forfeitButton,
exitButton
)
);
if (chatListView != null) {
add(Pos.BOTTOM_RIGHT,
fit(vboxFill(
chatListView,
chatInput
)
));
}
}
public void nextPlayer(boolean isMe, String currentPlayer, String currentMove, String nextPlayer) {
currentPlayerHeader.setText(currentPlayer);
currentMoveHeader.setText(currentMove);
nextPlayerHeader.setText(nextPlayer);
if (isMe) {
currentPlayerHeader.getStyleClass().add("my-turn");
} else {
currentPlayerHeader.getStyleClass().remove("my-turn");
}
}
public void updateChat(String message) {
if (chatListView == null) {
return;
}
final Text messageText = text();
messageText.setText(message);
chatListView.getItems().add(messageText);
}
public void gameOver(boolean iWon, String winner) {
ViewStack.push(new GameOverView(iWon, winner));
}
}

View File

@@ -0,0 +1,159 @@
package org.toop.app.view.views;
import org.toop.app.GameInformation;
import org.toop.app.game.ReversiGame;
import org.toop.app.game.TicTacToeGame;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.local.AppContext;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Slider;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import java.util.ArrayList;
import java.util.List;
public final class LocalMultiplayerView extends View {
private final GameInformation information;
public LocalMultiplayerView(GameInformation information) {
super(true, "bg-primary");
this.information = information;
}
public LocalMultiplayerView(GameInformation.Type type) {
this(new GameInformation(type));
}
@Override
public void setup() {
final Button playButton = button();
playButton.setText(AppContext.getString("play"));
playButton.setOnAction(_ -> {
for (final GameInformation.Player player : information.players) {
if (player.name.isEmpty()) {
ViewStack.push(new ErrorView(AppContext.getString("please-enter-your-name")));
return;
}
}
switch (information.type) {
case TICTACTOE: new TicTacToeGame(information); break;
case REVERSI: new ReversiGame(information); break;
}
});
add(Pos.CENTER,
fit(vboxFill(
hbox(
setupPlayers()
),
separator(),
playButton
))
);
final Button backButton = button();
backButton.setText(AppContext.getString("back"));
backButton.setOnAction(_ -> { ViewStack.push(new MainView()); });
add(Pos.BOTTOM_LEFT,
vboxFill(
backButton
)
);
}
private VBox[] setupPlayers() {
final VBox[] playerBoxes = new VBox[GameInformation.Type.playerCount(information.type)];
for (int i = 0; i < playerBoxes.length; i++) {
final int index = i;
List<Node> nodes = new ArrayList<>();
final Text playerHeader = header();
playerHeader.setText(AppContext.getString("player") + " #" + (i + 1));
nodes.add(playerHeader);
nodes.add(separator());
final Text nameText = text();
nameText.setText(AppContext.getString("name"));
if (information.players[i].isHuman) {
final Button playerToggle = button();
playerToggle.setText(AppContext.getString("player"));
playerToggle.setOnAction(_ -> {
information.players[index].isHuman = false;
cleanup();
setup();
});
nodes.add(vboxFill(playerToggle));
final TextField playerNameInput = input();
playerNameInput.setPromptText(AppContext.getString("enter-your-name"));
playerNameInput.setText(information.players[i].name);
playerNameInput.textProperty().addListener((_, _, newValue) -> {
information.players[index].name = newValue;
});
nodes.add(vboxFill(nameText, playerNameInput));
} else {
final Button computerToggle = button();
computerToggle.setText(AppContext.getString("computer"));
computerToggle.setOnAction(_ -> {
information.players[index].isHuman = true;
cleanup();
setup();
});
nodes.add(vboxFill(computerToggle));
information.players[i].name = "Pism Bot V" + i;
final Text computerNameText = text();
computerNameText.setText(information.players[index].name);
nodes.add(vboxFill(nameText, computerNameText));
final Text computerDifficultyText = text();
computerDifficultyText.setText(AppContext.getString("computer-difficulty"));
final Slider computerDifficultySlider = slider();
computerDifficultySlider.setMin(0);
computerDifficultySlider.setMax(GameInformation.Type.maxDepth(information.type));
computerDifficultySlider.setValue(information.players[i].computerDifficulty);
computerDifficultySlider.valueProperty().addListener((_, _, newValue) -> {
information.players[index].computerDifficulty = newValue.intValue();
});
nodes.add(vboxFill(computerDifficultyText, computerDifficultySlider));
final Text computerThinkTimeText = text();
computerThinkTimeText.setText(AppContext.getString("computer-think-time"));
final Slider computerThinkTimeSlider = slider();
computerThinkTimeSlider.setMin(0);
computerThinkTimeSlider.setMax(5);
computerThinkTimeSlider.setValue(information.players[i].computerThinkTime);
computerThinkTimeSlider.valueProperty().addListener((_, _, newValue) -> {
information.players[index].computerThinkTime = newValue.intValue();
});
nodes.add(vboxFill(computerThinkTimeText, computerThinkTimeSlider));
}
playerBoxes[i] = vboxFill(nodes.toArray(new Node[0]));
}
return playerBoxes;
}
}

View File

@@ -0,0 +1,43 @@
package org.toop.app.view.views;
import org.toop.app.GameInformation;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.local.AppContext;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
public final class LocalView extends View {
public LocalView() {
super(true, "bg-primary");
}
@Override
public void setup() {
final Button ticTacToeButton = button();
ticTacToeButton.setText(AppContext.getString("tic-tac-toe"));
ticTacToeButton.setOnAction(_ -> { ViewStack.push(new LocalMultiplayerView(GameInformation.Type.TICTACTOE)); });
final Button reversiButton = button();
reversiButton.setText(AppContext.getString("reversi"));
reversiButton.setOnAction(_ -> { ViewStack.push(new LocalMultiplayerView(GameInformation.Type.REVERSI)); });
add(Pos.CENTER,
fit(vboxFill(
ticTacToeButton,
reversiButton
))
);
final Button backButton = button();
backButton.setText(AppContext.getString("back"));
backButton.setOnAction(_ -> { ViewStack.push(new MainView()); });
add(Pos.BOTTOM_LEFT,
vboxFill(
backButton
)
);
}
}

View File

@@ -0,0 +1,48 @@
package org.toop.app.view.views;
import org.toop.app.App;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.local.AppContext;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
public final class MainView extends View {
public MainView() {
super(true, "bg-primary");
}
@Override
public void setup() {
final Button localButton = button();
localButton.setText(AppContext.getString("local"));
localButton.setOnAction(_ -> { ViewStack.push(new LocalView()); });
final Button onlineButton = button();
onlineButton.setText(AppContext.getString("online"));
onlineButton.setOnAction(_ -> { ViewStack.push(new OnlineView()); });
final Button creditsButton = button();
creditsButton.setText(AppContext.getString("credits"));
creditsButton.setOnAction(_ -> { ViewStack.push(new CreditsView()); });
final Button optionsButton = button();
optionsButton.setText(AppContext.getString("options"));
optionsButton.setOnAction(_ -> { ViewStack.push(new OptionsView()); });
final Button quitButton = button();
quitButton.setText(AppContext.getString("quit"));
quitButton.setOnAction(_ -> { App.startQuit(); });
add(Pos.CENTER,
fit(vboxFill(
localButton,
onlineButton,
creditsButton,
optionsButton,
quitButton
))
);
}
}

View File

@@ -0,0 +1,83 @@
package org.toop.app.view.views;
import org.toop.app.Server;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.local.AppContext;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.text.Text;
public class OnlineView extends View {
public OnlineView() {
super(true, "bg-primary");
}
@Override
public void setup() {
final Text serverInformationHeader = header();
serverInformationHeader.setText(AppContext.getString("server-information"));
final Text serverIPText = text();
serverIPText.setText(AppContext.getString("ip-address"));
final TextField serverIPInput = input();
serverIPInput.setPromptText(AppContext.getString("enter-the-server-ip"));
final Text serverPortText = text();
serverPortText.setText(AppContext.getString("port"));
final TextField serverPortInput = input();
serverPortInput.setPromptText(AppContext.getString("enter-the-server-port"));
final Text playerNameText = text();
playerNameText.setText(AppContext.getString("player-name"));
final TextField playerNameInput = input();
playerNameInput.setPromptText(AppContext.getString("enter-your-name"));
final Button connectButton = button();
connectButton.setText(AppContext.getString("connect"));
connectButton.setOnAction(_ -> {
new Server(serverIPInput.getText(), serverPortInput.getText(), playerNameInput.getText());
});
add(Pos.CENTER,
fit(vboxFill(
serverInformationHeader,
separator(),
vboxFill(
serverIPText,
serverIPInput
),
vboxFill(
serverPortText,
serverPortInput
),
vboxFill(
playerNameText,
playerNameInput
),
vboxFill(
connectButton
)
))
);
final Button backButton = button();
backButton.setText(AppContext.getString("back"));
backButton.setOnAction(_ -> { ViewStack.push(new MainView()); });
add(Pos.BOTTOM_LEFT,
vboxFill(
backButton
)
);
}
}

View File

@@ -0,0 +1,250 @@
package org.toop.app.view.views;
import org.toop.app.App;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.framework.audio.VolumeControl;
import org.toop.framework.audio.events.AudioEvents;
import org.toop.framework.eventbus.EventFlow;
import org.toop.local.AppContext;
import org.toop.local.AppSettings;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Slider;
import javafx.scene.text.Text;
import javafx.util.StringConverter;
import java.util.Locale;
public final class OptionsView extends View {
public OptionsView() {
super(false, "bg-secondary");
}
@Override
public void setup() {
final Text generalHeader = header();
generalHeader.setText(AppContext.getString("general"));
final Text volumeHeader = header();
volumeHeader.setText(AppContext.getString("volume"));
final Text styleHeader = header();
styleHeader.setText(AppContext.getString("style"));
add(Pos.CENTER,
fit(hboxFill(
vboxFill(
generalHeader,
separator(),
vboxFill(
text("language-text"),
combobox("language-combobox")
),
vboxFill(
button("fullscreen-button")
)
),
vboxFill(
volumeHeader,
separator(),
vboxFill(
text("master-volume-text"),
slider("master-volume-slider")
),
vboxFill(
text("effects-volume-text"),
slider("effects-volume-slider")
),
vboxFill(
text("music-volume-text"),
slider("music-volume-slider")
)
),
vboxFill(
styleHeader,
separator(),
vboxFill(
text("theme-text"),
combobox("theme-combobox")
),
vboxFill(
text("layout-text"),
combobox("layout-combobox")
)
)
))
);
setupLanguageOption();
setupMasterVolumeOption();
setupEffectsVolumeOption();
setupMusicVolumeOption();
setupThemeOption();
setupLayoutOption();
setupFullscreenOption();
final Button backButton = button();
backButton.setText(AppContext.getString("back"));
backButton.setOnAction(_ -> { ViewStack.pop(); });
add(Pos.BOTTOM_LEFT,
vboxFill(
backButton
)
);
}
private void setupLanguageOption() {
final Text languageText = get("language-text");
languageText.setText(AppContext.getString("language"));
final ComboBox<Locale> languageCombobox = get("language-combobox");
languageCombobox.getItems().addAll(AppContext.getLocalization().getAvailableLocales());
languageCombobox.setValue(AppContext.getLocale());
languageCombobox.getSelectionModel().selectedItemProperty().addListener((_, _, newValue) -> {
AppSettings.getSettings().setLocale(newValue.toString());
AppContext.setLocale(newValue);
App.reload();
});
languageCombobox.setConverter(new StringConverter<>() {
@Override
public String toString(Locale locale) {
return AppContext.getString(locale.getDisplayName().toLowerCase());
}
@Override
public Locale fromString(String s) {
return null;
}
});
}
private void setupMasterVolumeOption() {
final Text masterVolumeText = get("master-volume-text");
masterVolumeText.setText(AppContext.getString("master-volume"));
final Slider masterVolumeSlider = get("master-volume-slider");
masterVolumeSlider.setMin(0);
masterVolumeSlider.setMax(100);
masterVolumeSlider.setValue(AppSettings.getSettings().getVolume());
masterVolumeSlider.valueProperty().addListener((_, _, newValue) -> {
AppSettings.getSettings().setVolume(newValue.intValue());
new EventFlow().addPostEvent(new AudioEvents.ChangeVolume(newValue.doubleValue(), VolumeControl.MASTERVOLUME)).asyncPostEvent();
});
}
private void setupEffectsVolumeOption() {
final Text effectsVolumeText = get("effects-volume-text");
effectsVolumeText.setText(AppContext.getString("effects-volume"));
final Slider effectsVolumeSlider = get("effects-volume-slider");
effectsVolumeSlider.setMin(0);
effectsVolumeSlider.setMax(100);
effectsVolumeSlider.setValue(AppSettings.getSettings().getFxVolume());
effectsVolumeSlider.valueProperty().addListener((_, _, newValue) -> {
AppSettings.getSettings().setFxVolume(newValue.intValue());
new EventFlow().addPostEvent(new AudioEvents.ChangeVolume(newValue.doubleValue(), VolumeControl.FX)).asyncPostEvent();
});
}
private void setupMusicVolumeOption() {
final Text musicVolumeText = get("music-volume-text");
musicVolumeText.setText(AppContext.getString("music-volume"));
final Slider musicVolumeSlider = get("music-volume-slider");
musicVolumeSlider.setMin(0);
musicVolumeSlider.setMax(100);
musicVolumeSlider.setValue(AppSettings.getSettings().getMusicVolume());
musicVolumeSlider.valueProperty().addListener((_, _, newValue) -> {
AppSettings.getSettings().setMusicVolume(newValue.intValue());
new EventFlow().addPostEvent(new AudioEvents.ChangeVolume(newValue.doubleValue(), VolumeControl.MUSIC)).asyncPostEvent();
});
}
private void setupThemeOption() {
final Text themeText = get("theme-text");
themeText.setText(AppContext.getString("theme"));
final ComboBox<String> themeCombobox = get("theme-combobox");
themeCombobox.getItems().addAll("dark", "light", "high-contrast");
themeCombobox.setValue(AppSettings.getSettings().getTheme());
themeCombobox.getSelectionModel().selectedItemProperty().addListener((_, _, newValue) -> {
AppSettings.getSettings().setTheme(newValue);
App.setStyle(newValue, AppSettings.getSettings().getLayoutSize());
});
themeCombobox.setConverter(new StringConverter<>() {
@Override
public String toString(String theme) {
return AppContext.getString(theme);
}
@Override
public String fromString(String s) {
return null;
}
});
}
private void setupLayoutOption() {
final Text layoutText = get("layout-text");
layoutText.setText(AppContext.getString("layout-size"));
final ComboBox<String> layoutCombobox = get("layout-combobox");
layoutCombobox.getItems().addAll("small", "medium", "large");
layoutCombobox.setValue(AppSettings.getSettings().getLayoutSize());
layoutCombobox.getSelectionModel().selectedItemProperty().addListener((_, _, newValue) -> {
AppSettings.getSettings().setLayoutSize(newValue);
App.setStyle(AppSettings.getSettings().getTheme(), newValue);
});
layoutCombobox.setConverter(new StringConverter<>() {
@Override
public String toString(String layout) {
return AppContext.getString(layout);
}
@Override
public String fromString(String s) {
return null;
}
});
}
private void setupFullscreenOption() {
final Button fullscreenButton = get("fullscreen-button");
if (AppSettings.getSettings().getFullscreen()) {
fullscreenButton.setText(AppContext.getString("windowed"));
fullscreenButton.setOnAction(_ -> {
AppSettings.getSettings().setFullscreen(false);
App.setFullscreen(false);
});
} else {
fullscreenButton.setText(AppContext.getString("fullscreen"));
fullscreenButton.setOnAction(_ -> {
AppSettings.getSettings().setFullscreen(true);
App.setFullscreen(true);
});
}
}
}

View File

@@ -0,0 +1,40 @@
package org.toop.app.view.views;
import org.toop.app.App;
import org.toop.app.view.View;
import org.toop.local.AppContext;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.text.Text;
public final class QuitView extends View {
public QuitView() {
super(false, "bg-popup");
}
@Override
public void setup() {
final Text sureHeader = header();
sureHeader.setText(AppContext.getString("are-you-sure"));
final Button yesButton = button();
yesButton.setText(AppContext.getString("yes"));
yesButton.setOnAction(_ -> { App.quit(); });
final Button noButton = button();
noButton.setText(AppContext.getString("no"));
noButton.setOnAction(_ -> { App.stopQuit(); });
add(Pos.CENTER,
fit(vbox(
sureHeader,
hbox(
yesButton,
noButton
)
))
);
}
}

View File

@@ -0,0 +1,118 @@
package org.toop.app.view.views;
import org.toop.app.GameInformation;
import org.toop.app.Server;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.local.AppContext;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Slider;
import javafx.scene.text.Text;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
public final class SendChallengeView extends View {
private final Server server;
private final String opponent;
private final BiConsumer<GameInformation.Player, String> onSend;
private final GameInformation.Player playerInformation;
public SendChallengeView(Server server, String opponent, BiConsumer<GameInformation.Player, String> onSend) {
super(true, "bg-popup");
this.server = server;
this.opponent = opponent;
this.onSend = onSend;
playerInformation = new GameInformation.Player();
}
@Override
public void setup() {
final Text challengeText = text();
challengeText.setText(AppContext.getString("challenge"));
final Text opponentHeader = header();
opponentHeader.setText(opponent);
final Text gameText = text();
gameText.setText(AppContext.getString("to-a-game-of"));
final ComboBox<String> gamesCombobox = combobox();
gamesCombobox.getItems().addAll(server.getGamesList());
gamesCombobox.setValue(gamesCombobox.getItems().getFirst());
final Button sendButton = button();
sendButton.setText(AppContext.getString("send"));
sendButton.setOnAction(_ -> { onSend.accept(playerInformation, gamesCombobox.getValue()); });
final Button cancelButton = button();
cancelButton.setText(AppContext.getString("cancel"));
cancelButton.setOnAction(_ -> { ViewStack.pop(); });
final List<Node> nodes = new ArrayList<>();
if (playerInformation.isHuman) {
final Button playerToggle = button();
playerToggle.setText(AppContext.getString("player"));
playerToggle.setOnAction(_ -> {
playerInformation.isHuman = false;
cleanup();
setup();
});
nodes.add(vbox(playerToggle));
} else {
final Button computerToggle = button();
computerToggle.setText(AppContext.getString("computer"));
computerToggle.setOnAction(_ -> {
playerInformation.isHuman = true;
cleanup();
setup();
});
nodes.add(vbox(computerToggle));
final Text computerDifficultyText = text();
computerDifficultyText.setText(AppContext.getString("computer-difficulty"));
final Slider computerDifficultySlider = slider();
computerDifficultySlider.setMin(0);
computerDifficultySlider.setMax(GameInformation.Type.maxDepth(Server.gameToType(gamesCombobox.getValue())));
computerDifficultySlider.setValue(playerInformation.computerDifficulty);
computerDifficultySlider.valueProperty().addListener((_, _, newValue) -> {
playerInformation.computerDifficulty = newValue.intValue();
});
nodes.add(vbox(computerDifficultyText, computerDifficultySlider));
}
add(Pos.CENTER,
fit(hboxFill(
vboxFill(
challengeText,
opponentHeader,
gameText,
gamesCombobox,
separator(),
hboxFill(
sendButton,
cancelButton
)
),
vboxFill(
nodes.toArray(new Node[0])
)
))
);
}
}

View File

@@ -0,0 +1,80 @@
package org.toop.app.view.views;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.local.AppContext;
import javafx.application.Platform;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.scene.text.Text;
import java.util.List;
import java.util.function.Consumer;
public final class ServerView extends View {
private final String user;
private final Consumer<String> onPlayerClicked;
private final Runnable onDisconnect;
private ListView<Button> listView;
public ServerView(String user, Consumer<String> onPlayerClicked, Runnable onDisconnect) {
super(true, "bg-primary");
this.user = user;
this.onPlayerClicked = onPlayerClicked;
this.onDisconnect = onDisconnect;
}
public void update(List<String> players) {
Platform.runLater(() -> {
listView.getItems().clear();
for (int i = 0; i < players.size(); i++) {
final int finalI = i;
final Button button = button();
button.setText(players.get(i));
button.setOnAction(_ -> {
onPlayerClicked.accept(players.get(finalI));
});
listView.getItems().add(button);
}
});
}
@Override
public void setup() {
final Text playerHeader = header();
playerHeader.setText(user);
listView = new ListView<Button>();
add(Pos.CENTER,
fit(vboxFill(
vbox(
playerHeader,
separator()
),
listView
))
);
final Button disconnectButton = button();
disconnectButton.setText(AppContext.getString("disconnect"));
disconnectButton.setOnAction(_ -> {
onDisconnect.run();
ViewStack.push(new OnlineView());
});
add(Pos.BOTTOM_LEFT,
vboxFill(
disconnectButton
)
);
}
}

View File

@@ -1,7 +1,5 @@
package org.toop.local;
import java.io.File;
import java.util.Locale;
import org.toop.app.App;
import org.toop.framework.audio.VolumeControl;
import org.toop.framework.audio.events.AudioEvents;
@@ -11,57 +9,59 @@ import org.toop.framework.resource.ResourceMeta;
import org.toop.framework.resource.resources.SettingsAsset;
import org.toop.framework.settings.Settings;
import java.io.File;
import java.util.Locale;
public class AppSettings {
private static SettingsAsset settingsAsset;
private SettingsAsset settingsAsset;
public static void applySettings() {
settingsAsset = getPath();
if (!settingsAsset.isLoaded()) {
settingsAsset.load();
}
public void applySettings() {
this.settingsAsset = getPath();
if (!this.settingsAsset.isLoaded()) {
this.settingsAsset.load();
}
Settings settingsData = settingsAsset.getContent();
Settings settingsData = this.settingsAsset.getContent();
AppContext.setLocale(Locale.of(settingsData.locale));
App.setFullscreen(settingsData.fullScreen);
new EventFlow()
.addPostEvent(new AudioEvents.ChangeVolume(settingsData.volume, VolumeControl.MASTERVOLUME))
.asyncPostEvent();
new EventFlow()
.addPostEvent(new AudioEvents.ChangeVolume(settingsData.fxVolume, VolumeControl.FX))
.asyncPostEvent();
new EventFlow()
.addPostEvent(new AudioEvents.ChangeVolume(settingsData.musicVolume, VolumeControl.MUSIC))
.asyncPostEvent();
App.setStyle(settingsAsset.getTheme(), settingsAsset.getLayoutSize());
}
AppContext.setLocale(Locale.of(settingsData.locale));
App.setFullscreen(settingsData.fullScreen);
new EventFlow()
.addPostEvent(new AudioEvents.ChangeVolume(settingsData.volume, VolumeControl.MASTERVOLUME))
.asyncPostEvent();
new EventFlow()
.addPostEvent(new AudioEvents.ChangeVolume(settingsData.fxVolume, VolumeControl.FX))
.asyncPostEvent();
new EventFlow()
.addPostEvent(new AudioEvents.ChangeVolume(settingsData.musicVolume, VolumeControl.MUSIC))
.asyncPostEvent();
App.setStyle(settingsAsset.getTheme(), settingsAsset.getLayoutSize());
}
public static SettingsAsset getPath() {
if (settingsAsset == null) {
String os = System.getProperty("os.name").toLowerCase();
String basePath;
public SettingsAsset getPath() {
if (this.settingsAsset == null) {
String os = System.getProperty("os.name").toLowerCase();
String basePath;
if (os.contains("win")) {
basePath = System.getenv("APPDATA");
if (basePath == null) {
basePath = System.getProperty("user.home");
}
} else if (os.contains("mac")) {
basePath = System.getProperty("user.home") + "/Library/Application Support";
} else {
basePath = System.getProperty("user.home") + "/.config";
}
if (os.contains("win")) {
basePath = System.getenv("APPDATA");
if (basePath == null) {
basePath = System.getProperty("user.home");
}
} else if (os.contains("mac")) {
basePath = System.getProperty("user.home") + "/Library/Application Support";
} else {
basePath = System.getProperty("user.home") + "/.config";
}
File settingsFile =
new File(basePath + File.separator + "ISY1" + File.separator + "settings.json");
// this.settingsAsset = new SettingsAsset(settingsFile);
ResourceManager.addAsset(new ResourceMeta<>("settings.json", new SettingsAsset(settingsFile)));
}
return ResourceManager.get("settings.json");
}
File settingsFile =
new File(basePath + File.separator + "ISY1" + File.separator + "settings.json");
return new SettingsAsset(settingsFile);
// this.settingsAsset = new SettingsAsset(settingsFile); // TODO
// ResourceManager.addAsset(new ResourceMeta<>("settings.json", new SettingsAsset(settingsFile))); // TODO
}
return this.settingsAsset;
// return ResourceManager.get("settings.json"); // TODO
}
}
public static SettingsAsset getSettings() {
return settingsAsset;
}
}

Binary file not shown.

View File

@@ -1,52 +1,74 @@
accept=\u0642\u0628\u0648\u0644
ai=\u0627\u0644\u0630\u0643\u0627\u0621 \u0627\u0644\u0635\u0646\u0627\u0639\u064a
appTitle=\u0645\u062e\u062a\u0627\u0631 \u0623\u0644\u0639\u0627\u0628 ISY
back=\u0631\u062c\u0648\u0639
backToMainMenu=\u0627\u0644\u0639\u0648\u062F\u0629 \u0625\u0644\u0649 \u0627\u0644\u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0631\u0626\u064A\u0633\u064A\u0629
computer=\u0627\u0644\u062d\u0627\u0633\u0648\u0628
computerDifficulty=\u0635\u0639\u0648\u0628\u0629 \u0627\u0644\u062d\u0627\u0633\u0648\u0628
computerThinkTime=\u0632\u0645\u0646 \u062a\u0641\u0643\u064a\u0631 \u0627\u0644\u0643\u0645\u0628\u064a\u0648\u062a\u0631
congratulations=\u0645\u0628\u0631\u0648\u0643
connect=\u0627\u062a\u0635\u0644
connectionType=\u0646\u0648\u0639 \u0627\u0644\u0627\u062A\u0635\u0627\u0644
credits=\u0627\u0644\u0634\u0643\u0631 \u0648\u0627\u0644\u062a\u0642\u062f\u064a\u0631
dark-hc=\u063A\u0627\u0645\u0642 (\u062A\u0646\u0627\u0642\u0636 \u0639\u0627\u0644\u064D)
dark=\u063A\u0627\u0645\u0642
app-title=\u0645\u062e\u062a\u0627\u0631 \u0627\u0644\u0643\u0627\u0645 \u0627\u0644\u0645\u062e\u062a\u0627\u0631
are-you-sure=\u0647\u0644 \u0623\u0646\u062a \u0645\u062a\u0623\u0643\u062f?
back=\u0627\u0644\u0631\u062c\u0648\u0639
cancel=\u0625\u0644\u063a\u0627\u0621
challenge=\u062a\u062d\u062f\u064a
computer-difficulty=\u0635\u0639\u0648\u0628 \u0627\u0644\u0643\u0645\u0628\u064a\u0648\u062a\u0631
computer-think-time=\u0648\u0642\u062a \u062a\u0641\u0643\u064a\u0631 \u0627\u0644\u0643\u0645\u0628\u064a\u0648\u062a\u0631
computer=\u0643\u0645\u0628\u064a\u0648\u062a\u0631
connect=\u0627\u062a\u0635\u0627\u0644
credits=\u0627\u0644\u0645\u0633\u0627\u0647\u0645\u0629
dark=\u0638\u0644\u0627\u0645
deny=\u0631\u0641\u0636
developers=\u0627\u0644\u0645\u0637\u0648\u0631\u0648\u0646
drawText=\u0627\u0646\u062A\u0647\u062A \u0627\u0644\u0644\u0639\u0628\u0629 \u0628\u062A\u0639\u0627\u062F\u0644
effectsVolume=\u062d\u062c\u0645 \u0627\u0644\u062a\u0623\u062b\u064a\u0631\u0627\u062a
musicVolume=Music Volume (translate me)
disconnect=\u0641\u0635\u0644 \u0627\u0644\u0627\u062a\u0635\u0627\u0644
effects-volume=\u0635\u0648\u062a \u0627\u0644\u062a\u0623\u062b\u064a\u0631\u0627\u062a
enter-the-server-ip=\u0623\u062f\u062e\u0644 \u0639\u0646\u0648\u0627\u0646 \u0627\u0644\u0633\u064a\u0631\u0641\u0631
enter-the-server-port=\u0623\u062f\u062e\u0644 \u0645\u0646\u0641\u0630 \u0627\u0644\u0633\u064a\u0631\u0641\u0631
enter-your-name=\u0623\u062f\u062e\u0644 \u0627\u0633\u0645\u0643
error=\u062e\u0637\u0623
exit=\u062e\u0631\u0648\u062c
forfeit=\u0627\u0633\u062a\u0643\u0644\u0627\u0644
fullscreen=\u0643\u0627\u0645\u0644 \u0627\u0644\u0634\u0627\u0634\u0629
goodGameText=\u0644\u0639\u0628\u0629 \u0631\u0627\u0626\u0639\u0629. \u0623\u062D\u0633\u0646\u062A.
human=\u0627\u0644\u0625\u0646\u0633\u0627\u0646
language=\u0627\u0644\u0644\u063a\u0629
large=\u0643\u0628\u064A\u0631
layoutSize=\u062D\u062C\u0645 \u0627\u0644\u062A\u0635\u0645\u064A\u0645
light-hc=\u0641\u0627\u062A\u062D (\u062A\u0646\u0627\u0642\u0636 \u0639\u0627\u0644\u064D)
light=\u0641\u0627\u062A\u062D
game-over=\u0627\u0646\u062a\u0647\u062a \u0627\u0644\u0644\u0639\u0628\u0629
general=\u0639\u0627\u0645
high-contrast=\u062A\u0628\u0627\u0646\u064A\u0629 \u0639\u0627\u0644\u064A
invalid-username=\u0627\u0633\u0645 \u063a\u064a\u0631 \u0635\u062d\u064a\u062d
ip-address=\u0639\u0646\u0648\u0627\u0646 IP
is-not-a-valid-ip-address=\u0644\u064a\u0633 \u0639\u0646\u0648\u0627\u0646 IP \u0635\u062d\u064a\u062d
is-not-a-valid-port=\u0644\u064a\u0633 \u0645\u0646\u0641\u0630 \u0635\u062d\u064a\u062d
language=\u0644\u063a\u0629
large=\u0633\u064a\u0631
layout-size=\u062d\u062c\u0645 \u0627\u0644\u062a\u0635\u0645\u064a\u0645
light=\u0636\u0624\u0621
local=\u0645\u062d\u0644\u064a
localization=\u062a\u0648\u0645\u064a\u0645 \u0627\u0644\u0644\u063a\u0629
medium=\u0645\u062A\u0648\u0633\u0637
mergeCommander=\u0642\u0627\u0626\u062f \u0627\u0644\u062f\u0645\u062c
moralSupport=\u062f\u0639\u0645 \u0645\u0639\u0646\u0648\u064a
localization=\u062a\u0639\u0631\u064a\u0628 \u0627\u0644\u0644\u063a\u0629
master-volume=\u0635\u0648\u062a \u0627\u0644\u0645\u0633\u062a\u0648\u0649
medium=\u0645\u062a\u0648\u0633\u0637
merge-commander=Merge Commander
moral-support=\u062f\u0639\u0645 \u0623\u0639\u0635\u0627\u0628\u064a
music-volume=\u0635\u0648\u062a \u0627\u0644\u0645\u0648\u0633\u064a\u0642\u0649
name=\u0627\u0633\u0645
no=\u0644\u0627
ok=\u0645\u0648\u0627\u0641\u0642
online=\u0645\u062a\u0635\u0644
opengl=OpenGL
options=\u0627\u0644\u062e\u064a\u0627\u0631\u0627\u062a
othello=\u0623\u0648\u062a\u064a\u0644\u0648
playerName=\u0627\u0633\u0645 \u0627\u0644\u0644\u0627\u0639\u0628
productOwner=\u0645\u0627\u0644\u0643 \u0627\u0644\u0645\u0646\u062a\u062c
options=\u062e\u064a\u0627\u0631\u0627\u062a
play=\u0644\u0639\u0628
player-name=\u0627\u0633\u0645 \u0627\u0644\u0644\u0627\u0639\u0628
player=\u0644\u0627\u0639\u0628
please-enter-your-name=\u064a\u0631\u062c\u0649 \u0623\u062f\u062e\u0644 \u0627\u0633\u0645\u0643
port=\u0645\u0646\u0641\u0630
product-owner=\u0635\u0627\u062d\u0628 \u0627\u0644\u0645\u0646\u062a\u062c
quit=\u062e\u0631\u0648\u062c
quitSure=\u0647\u0644 \u0623\u0646\u062a \u0645\u062a\u0623\u0643\u062f\u061f
scrumMaster=\u0645\u062f\u064a\u0631 \u0627\u0644\u0633\u0643\u0631\u0645
server=\u062e\u0627\u062f\u0645
serverIP=IP \u0627\u0644\u062e\u0627\u062f\u0645
serverPort=\u0645\u0646\u0641\u0630 \u0627\u0644\u062e\u0627\u062f\u0645
small=\u0635\u063A\u064A\u0631
start=\u0627\u0628\u062f\u0623
theme=\u0627\u0644\u0645\u0648\u0636\u0648\u0639
tictactoe=\u062a\u064a\u0643 \u062a\u0627\u0643 \u062a\u0648
volume=\u0627\u0644\u062d\u062c\u0645 \u0627\u0644\u0631\u0626\u064a\u0633\u064a
windowed=\u0646\u0627\u0641\u0630\u064a
reversi=\u0631\u064a\u0641\u0631\u0633\u064a
scrum-master=Scrum Master
send=\u0625\u0631\u0633\u0627\u0644
server-information=\u0645\u0639\u0644\u0648\u0645\u0627\u062a \u0627\u0644\u0633\u064a\u0631\u0641\u0631
small=\u0635\u063a\u064a\u0631
style=\u0623\u0633\u0644\u0648\u0628
the-game-ended-in-a-draw=\u0627\u0646\u062a\u0647\u062a \u0627\u0644\u0644\u0639\u0628\u0629 \u0628\u062a\u0639\u0627\u062f\u0644
theme=\u0645\u0648\u0636\u0648\u0639
tic-tac-toe=\u062a\u064a\u0643 \u062a\u0627\u0643 \u062a\u0648
to-a-game-of=\u0625\u0644\u0649 \u0644\u0639\u0628\u0629 \u0645\u0646
volume=\u0635\u0648\u062a
windowed=\u0641\u064a \u0646\u0641\u0630\u0629
yes=\u0646\u0639\u0645
you-lost-against=\u0623\u0646\u062a \u062e\u0633\u0631\u062a \u0636\u062f
you-were-challenged-by=\u062a\u062d\u062f\u064a\u062a \u0645\u0646
you-win=\u0623\u0646\u062a \u062a\u0641\u0648\u0632
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629
chinese=\u4e2d\u6587 (\u0627\u0644\u0635\u064a\u0646\u064a\u0629)

View File

@@ -1,52 +1,74 @@
accept=Akzeptieren
ai=K\u00fcnstliche Intelligenz
appTitle=ISY Spieleauswahl
app-title=ISY Spiele-Auswahl
are-you-sure=Sind Sie sicher?
back=Zur\u00fcck
backToMainMenu=Zur\u00FCck zum Hauptmen\u00FC
cancel=Abbrechen
challenge=Herausforderung
computer-difficulty=Computer Schwierigkeit
computer-think-time=Computer Denkzeit
computer=Computer
computerDifficulty=Computerschwierigkeit
computerThinkTime=Computer Denkzeit
congratulations=Gl\u00FCckwunsch
connect=Verbinden
connectionType=Verbindungstyp
credits=Credits
dark-hc=Dunkel (Hoher Kontrast)
dark=Dunkel
deny=Ablehnen
developers=Entwickler
drawText=Das Spiel endete unentschieden
effectsVolume=Effektlautst\u00e4rke
musicVolume=Music Volume (translate me)
disconnect=Trennen
effects-volume=Effektlautst\u00e4rke
enter-the-server-ip=Server-IP eingeben
enter-the-server-port=Server-Port eingeben
enter-your-name=Geben Sie Ihren Namen ein
error=Fehler
exit=Beenden
forfeit=Aufgeben
fullscreen=Vollbild
goodGameText=Gutes Spiel. Gut gespielt.
human=Mensch
game-over=Spiel vorbei
general=Allgemein
high-contrast=Hoher Kontrast
invalid-username=Ung\u00fcltiger Benutzername
ip-address=IP-Adresse
is-not-a-valid-ip-address=ist keine g\u00fcltige IP-Adresse
is-not-a-valid-port=ist kein g\u00fcltiger Port
language=Sprache
large=Gro\u00DF
layoutSize=Layout-Gr\u00F6\u00DFe
light-hc=Hell (Hoher Kontrast)
large=Gro\u00df
layout-size=Layout-Gr\u00f6\u00dfe
light=Hell
local=Lokal
localization=Lokalisierung
master-volume=Gesamtlautst\u00e4rke
medium=Mittel
mergeCommander=Merge-Kommandant
moralSupport=Mentale Unterst\u00fctzung
merge-commander=Merge Commander
moral-support=Mentale Unterst\u00fctzung
music-volume=Musiklautst\u00e4rke
name=Name
no=Nein
ok=Ok
online=Online
opengl=OpenGL
options=Optionen
othello=Othello
playerName=Spielername
productOwner=Produktverantwortlicher
play=Spielen
player-name=Spielername
player=Spieler
please-enter-your-name=Bitte geben Sie Ihren Namen ein
port=Port
product-owner=Produktverantwortlicher
quit=Beenden
quitSure=Bist du dir sicher?
scrumMaster=Scrum Master
server=Server
serverIP=Server-IP
serverPort=Server-Port
reversi=Reversi
scrum-master=Scrum Master
send=Senden
server-information=Serverinformationen
small=Klein
start=Start
style=Stil
the-game-ended-in-a-draw=Das Spiel endete unentschieden
theme=Thema
tictactoe=Tic Tac Toe
volume=Hauptlautst<EFBFBD>rke
tic-tac-toe=Tic Tac Toe
to-a-game-of=zu einem Spiel von
volume=Lautst\u00e4rke
windowed=Fenstermodus
yes=Ja
you-lost-against=Sie haben gegen ... verloren
you-were-challenged-by=Sie wurden herausgefordert von ...
you-win=Sie gewinnen
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabisch)
chinese=\u4e2d\u6587 (Chinesisch)

View File

@@ -1,56 +1,74 @@
accept=Accept
ai=Artificial Intelligence
appTitle=ISY Games Selector
app-title=ISY Games Selector
are-you-sure=Are you sure?
back=Back
backToMainMenu=Back to main menu
challengeText=You were challenged by
cancel=Cancel
challenge=Challenge
computer-difficulty=Computer difficulty
computer-think-time=Computer think time
computer=Computer
computerDifficulty=Computer Difficulty
computerThinkTime=Computer Think Time
congratulations=Congratulations
connect=Connect
connectionType=Connection Type
credits=Credits
dark=Dark
dark-hc=Dark (High Contrast)
deny=Deny
developers=Developers
drawText=The game ended in a draw
effectsVolume=Effects Volume
musicVolume=Music Volume
disconnect=Disconnect
effects-volume=Effects Volume
enter-the-server-ip=Enter the server ip
enter-the-server-port=Enter the server port
enter-your-name=Enter your name
error=Error
exit=Exit
forfeit=Forfeit
fullscreen=Fullscreen
gameIsText=To a game of
goodGameText=Good game. Well played.
human=Human
game-over=Game Over
general=General
high-contrast=High contrast
invalid-username=invalid username
ip-address=IP address
is-not-a-valid-ip-address=is not a valid-ip address
is-not-a-valid-port=is not a valid port
language=Language
large=Large
layoutSize=Layout Size
layout-size=Layout Size
light=Light
light-hc=Light (High Contrast)
local=Local
localization=Localization
master-volume=Master Volume
medium=Medium
mergeCommander=Merge Commander
moralSupport=Moral Support
merge-commander=Merge Commander
moral-support=Moral Support
music-volume=Music Volume
name=Name
no=No
ok=Ok
online=Online
opengl=OpenGL
options=Options
othello=Othello
playerName=Player Name
productOwner=Product Owner
play=Play
player-name=Player name
player=Player
please-enter-your-name=Please enter your name
port=Port
product-owner=Product Owner
quit=Quit
quitSure=Are you sure?
scrumMaster=Scrum Master
server=Server
serverIP=Server IP
serverPort=Server Port
reversi=Reversi
scrum-master=Scrum Master
send=Send
server-information=Server information
small=Small
start=Start
style=Style
the-game-ended-in-a-draw=The game ended in a draw
theme=Theme
tictactoe=Tic Tac Toe
volume=Master Volume
tic-tac-toe=Tic Tac Toe
to-a-game-of=to a game of
volume=Volume
windowed=Windowed
yes=Yes
you-lost-against=You lost against
you-were-challenged-by=You were challenged by
you-win=You win
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabic)
chinese=\u4e2d\u6587 (Chinese)

View File

@@ -1,52 +1,74 @@
accept=Aceptar
ai=Inteligencia Artificial
appTitle=Selector de Juegos ISY
app-title=Selector de Juegos ISY
are-you-sure=\u00bfEst\u00e1s seguro?
back=Atr\u00e1s
backToMainMenu=Volver al men\u00FA principal
cancel=Cancelar
challenge=Desaf\u00edo
computer-difficulty=Dificultad del ordenador
computer-think-time=Tiempo de pensamiento del ordenador
computer=Ordenador
computerDifficulty=Dificultad del Ordenador
computerThinkTime=Tiempo de pensamiento de la computadora
congratulations=Felicitaciones
connect=Conectar
connectionType=Tipo de conexi\u00F3n
credits=Cr\u00e9ditos
dark-hc=Oscuro (Alto Contraste)
dark=Oscuro
deny=Denegar
developers=Desarrolladores
drawText=El juego termin\u00F3 en empate
effectsVolume=Volumen de efectos
musicVolume=Music Volume (translate me)
disconnect=Desconectar
effects-volume=Volumen de efectos
enter-the-server-ip=Introduce la IP del servidor
enter-the-server-port=Introduce el puerto del servidor
enter-your-name=Introduce tu nombre
error=Error
exit=Salir
forfeit=Rendirse
fullscreen=Pantalla completa
goodGameText=Buen juego. Bien jugado.
human=Humano
game-over=Fin del juego
general=General
high-contrast=Alto contraste
invalid-username=nombre de usuario inv\u00e1lido
ip-address=Direcci\u00f3n IP
is-not-a-valid-ip-address=no es una direcci\u00f3n IP v\u00e1lida
is-not-a-valid-port=no es un puerto v\u00e1lido
language=Idioma
large=Grande
layoutSize=Tama\u00F1o del dise\u00F1o
light-hc=Claro (Alto Contraste)
layout-size=Tama\u00f1o de dise\u00f1o
light=Claro
local=Local
localization=Localizaci\u00f3n
master-volume=Volumen maestro
medium=Mediano
mergeCommander=Comandante de Merge
moralSupport=Apoyo moral
merge-commander=Merge Commander
moral-support=Apoyo moral
music-volume=Volumen de m\u00fasica
name=Nombre
no=No
ok=OK
online=En l\u00ednea
opengl=OpenGL
options=Opciones
othello=Othello
playerName=Nombre del Jugador
productOwner=Propietario del Producto
play=Jugar
player-name=Nombre del jugador
player=Jugador
please-enter-your-name=Por favor, introduce tu nombre
port=Puerto
product-owner=Propietario del producto
quit=Salir
quitSure=\u00BFAst\u00e1s seguro?
scrumMaster=Scrum Master
server=Servidor
serverIP=Servidor-IP
serverPort=Servidor-puerto
small=Peque\u00F1o
start=Iniciar
reversi=Reversi
scrum-master=Scrum Master
send=Enviar
server-information=Informaci\u00f3n del servidor
small=Peque\u00f1o
style=Estilo
the-game-ended-in-a-draw=El juego termin\u00f3 en empate
theme=Tema
tictactoe=Tres en Raya
volume=Volumen principal
windowed=Ventana
tic-tac-toe=Tres en raya
to-a-game-of=a un juego de
volume=Volumen
windowed=En ventana
yes=S\u00ed
you-lost-against=Perdiste contra
you-were-challenged-by=Fuiste desafiado por
you-win=Ganaste
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Ar\u00e1bigo)
chinese=\u4e2d\u6587 (Chino)

View File

@@ -1,52 +1,74 @@
accept=Accepter
ai=Intelligence Artificielle
appTitle=S\u00e9lecteur de Jeux ISY
app-title=S\u00c9LECTEUR DE JEUX ISY
are-you-sure=\u00cates-vous s\u00fbr ?
back=Retour
backToMainMenu=Retour au menu principal
cancel=Annuler
challenge=D\u00e9fi
computer-difficulty=Difficult\u00e9 de l'ordinateur
computer-think-time=Temps de r\u00e9flexion de l'ordinateur
computer=Ordinateur
computerDifficulty=Difficult\u00e9 de l'Ordinateur
computerThinkTime=Temps de r\u00e9flexion de l'ordinateur
congratulations=F\u00E9licitations
connect=Connecter
connectionType=Type de connexion
connect=Connexion
credits=Cr\u00e9dits
dark-hc=Sombre (Contraste \u00E9lev\u00E9)
dark=Sombre
deny=Refuser
developers=D\u00e9veloppeurs
drawText=La partie s'est termin\u00E9e par un match nul
effectsVolume=Volume des effets
musicVolume=Music Volume (translate me)
disconnect=D\u00e9connexion
effects-volume=Volume des effets
enter-the-server-ip=Entrez l'adresse IP du serveur
enter-the-server-port=Entrez le port du serveur
enter-your-name=Entrez votre nom
error=Erreur
exit=Quitter
forfeit=Abandonner
fullscreen=Plein \u00e9cran
goodGameText=Bien jou\u00E9. Bonne partie.
human=Humain
game-over=Fin de la partie
general=G\u00e9n\u00e9ral
high-contrast=Haut contraste
invalid-username=nom d'utilisateur invalide
ip-address=Adresse IP
is-not-a-valid-ip-address=n'est pas une adresse IP valide
is-not-a-valid-port=n'est pas un port valide
language=Langue
large=Grand
layoutSize=Taille de la disposition
light-hc=Clair (Contraste \u00E9lev\u00E9)
layout-size=Format de l'affichage
light=Clair
local=Local
localization=Localisation
localization=Traduction
master-volume=Volume principal
medium=Moyen
mergeCommander=Commandant de Merge
moralSupport=Soutien moral
merge-commander=Merge Commander
moral-support=Soutien moral
music-volume=Volume de la musique
name=Nom
no=Non
ok=OK
online=En ligne
opengl=OpenGL
options=Options
othello=Othello
playerName=Nom du joueur
productOwner=Responsable du produit
play=Jouer
player-name=Nom du joueur
player=Joueur
please-enter-your-name=Veuillez entrer votre nom
port=Port
product-owner=Responsable produit
quit=Quitter
quitSure=Es-tu s\u00fbr ?
scrumMaster=Scrum Master
server=Serveur
serverIP=Serveur-IP
serverPort=Serveur-Port
reversi=Reversi
scrum-master=Scrum Master
send=Envoyer
server-information=Informations du serveur
small=Petit
start=D\u00e9marrer
theme=Th\u00E8me
tictactoe=Morpion
volume=Volume principal
windowed=Fen\u00eatre
style=Style
the-game-ended-in-a-draw=La partie s'est termin\u00e9e par un match nul
theme=Th\u00e8me
tic-tac-toe=Morpion
to-a-game-of=\u00e0 une partie de
volume=Volume
windowed=Fen\u00eatrr\u00e9
yes=Oui
you-lost-against=Vous avez perdu contre
you-were-challenged-by=Vous avez \u00e9t\u00e9 d\u00e9fi\u00e9 par
you-win=Vous avez gagn\u00e9
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabe)
chinese=\u4e2d\u6587 (Chinois)

View File

@@ -1,52 +1,74 @@
ai=\u092a\u094d\u0930\u0924\u093f\u092a\u094d\u0930\u0923\u093e\u0924\u094d\u092e\u093e\u0928 \u092a\u094d\u0930\u092c\u094d\u0939\u093e\u0935\u0924\u094d\u0924\u093e
appTitle=ISY \u0917\u0947\u092e \u0938\u0947\u0932\u0947\u0915\u094d\u091f\u0930
back=\u092a\u093f\u091a\u093e\u0932
backToMainMenu=\u092E\u0947\u0928 \u092E\u0947\u0928\u0942 \u092A\u0930 \u0935\u093E\u092A\u0938 \u091C\u093E\u090F\u0902
computer=\u0915\u092e\u092a\u094d\u092f\u0942\u091f\u0930
computerDifficulty=\u0915\u092e\u092a\u094d\u092f\u0942\u091f\u0930 \u092a\u094d\u0930\u092f\u093e\u0938
computerThinkTime=\u0915\u0902\u092a\u094d\u092f\u0942\u091f\u0930 \u0915\u0940 \u092a\u0930 \u092b\u0930 \u0938\u092e\u092f
congratulations=\u092C\u0927\u093E\u0908
connect=\u091c\u0942\u0921\u094d\u0921 \u0915\u0930\u0947\u0902
connectionType=\u0915\u0928\u0947\u0915\u094D\u0936\u0928 \u0915\u093E \u092A\u094D\u0930\u0915\u093E\u0930
credits=\u0916\u094d\u092f\u093e\u0924\u0947
dark-hc=\u0915\u093E\u0932\u093E (\u090A\u091A\u094D\u091A \u0915\u0949\u0928\u094D\u091F\u094D\u0930\u093E\u0938\u094D\u091F)
dark=\u0915\u093E\u0932\u093E
developers=\u0935\u093f\u0915\u0938\u093f\u0915\u0930
drawText=\u0916\u0947\u0932 \u091F\u0940\u091A \u092A\u0930 \u0916\u0924\u094D\u092E \u0939\u094B \u0917\u092F\u0940
effectsVolume=\u092a\u0631\u094d\u092a\u093e\u0935 \u0935\u094b\u0932\u094d\u092e
musicVolume=Music Volume (translate me)
fullscreen=\u092a\u0942\u0930\u094d\u0923 \u0938\u0915\u0940\u0928\u093e
goodGameText=\u0905\u091A\u094D\u091B\u0940 \u0916\u0947\u0932 \u0925\u0940\u0964 \u091B\u0940 \u0916\u0942\u092C \u0916\u0947\u0932\u093E.
human=\u092e\u093e\u0928\u0935
accept=\u0938\u094d\u0935\u0940\u0915\u093e\u0930
ai=\u0915\u0943\u0924\u094d\u0930\u093f\u092e \u092c\u0941\u0926\u094d\u0927\u093f
app-title=ISY \u0917\u0947\u092e \u091a\u092f\u0928\u0915\u093e\u0930\u0940
are-you-sure=\u0915\u094d\u092f\u093e \u0906\u092a \u0928\u093f\u0936\u094d\u091a\u093f\u0924 \u0939\u0948\u0902?
back=\u092a\u0940\u091b\u0947
cancel=\u0930\u0926\u094d\u0926 \u0915\u0930\u0947\u0902
challenge=\u091a\u0941\u0928\u094c\u0924\u0940
computer-difficulty=\u0915\u0902\u092a\u094d\u092f\u0942\u091f\u0930 \u0915\u0940 \u0915\u0920\u0928\u093e\u0908
computer-think-time=\u0915\u0902\u092a\u094d\u092f\u0942\u091f\u0930 \u091a\u093f\u0902\u0924\u0928 \u0938\u092e\u092f
computer=\u0915\u0902\u092a\u094d\u092f\u0942\u091f\u0930
connect=\u091c\u094b\u095c\u0947\u0902
credits=\u0915\u094d\u0930\u0947\u0921\u093f\u091f\u094d\u0938
dark=\u0917\u0939\u0930\u093e
deny=\u0907\u0902\u0915\u093e\u0930
developers=\u0935\u093f\u0915\u093e\u0938\u093f\u0924\u093e
disconnect=\u091c\u094b\u095c \u091f\u0942\u091f\u0928\u093e
effects-volume=\u090f\u092b\u0947\u0915\u094d\u091f \u0935\u0949\u0932\u094d\u092f\u0942\u092e
enter-the-server-ip=\u0938\u0930\u094d\u0935\u0930 IP \u0926\u093e\u0916\u093f\u090f
enter-the-server-port=\u0938\u0930\u094d\u0935\u0930 \u092a\u094b\u0930\u094d\u091f \u0926\u093e\u0916\u093f\u090f
enter-your-name=\u0905\u092a\u0928\u093e \u0928\u093e\u092e \u0926\u093e\u0916\u093f\u090f
error=\u0924\u094d\u0930\u0941\u091f\u093f
exit=\u092c\u093e\u0939\u0930 \u0928\u093f\u0915\u093e\u0932\u0940\u090f\u0902
forfeit=\u0939\u093e\u0930 \u092e\u093e\u0928\u0928\u093e
fullscreen=\u092a\u0942\u0930\u0940 \u0938\u094d\u0915\u094d\u0930\u0940\u0928
game-over=\u0916\u0947\u0932 \u0916\u0924\u094d\u092e
general=\u0938\u093e\u092e\u093e\u0928\u094d\u092f
high-contrast=\u0909\u091A\u094D\u091A\u093F\u0924 \u0915\u0949\u0902\u091F\u094D\u0930\u093E\u0938\u094D\u091F
invalid-username=\u0905\u092e\u093e\u0928\u094d\u092f \u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e \u0928\u093e\u092e
ip-address=IP \u092a\u0924\u093e
is-not-a-valid-ip-address=\u092f\u0939 \u090f\u0915 \u0905\u092e\u093e\u0928\u094d\u092f IP \u092a\u0924\u093e \u0928\u0939\u0940\u0902 \u0939\u0948
is-not-a-valid-port=\u092f\u0939 \u090f\u0915 \u0905\u092e\u093e\u0928\u094d\u092f \u092a\u094b\u0930\u094d\u091f \u0928\u0939\u0940\u0902 \u0939\u0948
language=\u092d\u093e\u0937\u093e
large=\u092C\u0921\u093C\u093E
layoutSize=\u0930\u0942\u092A\u0930\u0947\u0916 \u0915\u093E \u0906\u0915\u093E\u0930
light-hc=\u091A\u094D\u092E\u092C\u0940\u0932\u093E (\u090A\u091A\u094D\u091A \u0915\u0949\u0928\u094D\u091F\u094D\u0930\u093E\u0938\u094D\u091F)
light=\u091A\u094D\u092E\u092C\u0940\u0932\u093E
local=\u0938\u094d\u0925\u093e\u0928\u093f\u092f
localization=\u0938\u094d\u0925\u093e\u0928\u093f\u092f\u0915\u0930\u0923
medium=\u092E\u0927\u094D\u092F\u092E
mergeCommander=\u092e\u0930\u094d\u091c \u0915\u092e\u0902\u0921\u0930
moralSupport=\u0928\u094d\u092e\u093e\u0928\u093f\u0915 \u0938\u092e\u0930\u094d\u0925\u0928
large=\u092c\u095c\u093e
layout-size=\u0932\u0947\u090f\u0913\u091f \u0915\u093e \u0906\u0915\u093e\u0930
light=\u0915\u0947\u091c\u093c\u093e
local=\u0938\u094d\u0925\u093e\u0928\u0940\u092f
localization=\u0938\u094d\u0925\u093e\u0928\u0940\u092f\u0915\u0930\u0923
master-volume=\u092e\u093e\u0938\u094d\u091f\u0930 \u0935\u0949\u0932\u094d\u092f\u0942\u092e
medium=\u092e\u0927\u094d\u092f\u092e
merge-commander=\u092e\u0930\u094d\u091c \u0915\u092e\u093e\u0902\u0921\u0930
moral-support=\u0928\u0948\u0924\u093f\u0915 \u0938\u0939\u093e\u0930\u093e
music-volume=\u0938\u0902\u0917\u0940\u0924 \u0935\u0949\u0932\u094d\u092f\u0942\u092e
name=\u0928\u093e\u092e
no=\u0928\u0939\u0940\u0902
ok=\u0920\u0940\u0915 \u0939\u0948
online=\u0911\u0928\u0932\u093e\u0907\u0928
opengl=OpenGL
options=\u0935\u093f\u0915\u0932\u094d\u092a
othello=\u0913\u0925\u0940\u0932\u094b
playerName=\u0915\u0941\u0930\u093e\u0930\u0940 \u0928\u093e\u092e
productOwner=\u0906\u092f\u0947\u0915\u093e \u092e\u093e\u0932\u093f\u0915
quit=\u0938\u094e\u091c\u094d
quitSure=\u0915\u094d\u092f\u093e \u0915\u094d\u092f\u093e \u091f\u0940\u091f \u0939\u0948\u0902?
scrumMaster=\u0938\u094d\u0915\u094d\u0930\u0941\u092e \u092e\u093e\u0938\u094d\u091f\u0930
server=\u0938\u0930\u094d\u0935\u0930
serverIP=\u0938\u0930\u094d\u0935\u0930 IP
serverPort=\u0938\u0930\u094d\u0935\u0930 \u092a\u094b\u0930\u094d\u091f
small=\u091B\u094B\u091F\u093E
start=\u092b\u093f\u0930\u0942
theme=\u0925\u0940\u092E
tictactoe=\u091f\u093f\u0915 \u091f\u0948\u0915 \u091f\u094b
volume=\u092e\u0941\u0916\u094d\u092f \u0906\u0935\u093e\u091c
windowed=\u0915\u094d\u0930\u094d\u0939 \u092e\u0947\u0902
yes=\u0939\u093e\u0907
play=\u0916\u0947\u0932\u0947\u0902
player-name=\u0916\u093f\u0932\u093e\u095e\u0940 \u0915\u093e \u0928\u093e\u092e
player=\u0916\u093f\u0932\u093e\u095e\u0940
please-enter-your-name=\u0915\u0943\u092a\u092f\u093e \u0905\u092a\u0928\u093e \u0928\u093e\u092e \u0926\u093e\u0916\u093f\u090f
port=\u092a\u094b\u0930\u094d\u091f
product-owner=\u092a\u094d\u0930\u094b\u0921\u0915\u094d\u091f \u0915\u093e \u092e\u093e\u0932\u093f\u0915
quit=\u091b\u094b\u0921\u0947\u0902
reversi=\u0930\u093f\u0935\u0930\u094d\u0938\u0940
scrum-master=\u0938\u094d\u0915\u094d\u0930\u092e \u092e\u093e\u0938\u094d\u091f\u0930
send=\u092d\u0947\u091c\u0947\u0902
server-information=\u0938\u0930\u094d\u0935\u0930 \u091c\u093e\u0928\u0915\u093e\u0930\u0940
small=\u091b\u094b\u091f\u093e
style=\u0936\u0948\u0932\u0940
the-game-ended-in-a-draw=\u0916\u0947\u0932 \u091f\u0940\u0915 \u0939\u094b \u0917\u092f\u093e
theme=\u0925\u0940\u092e
tic-tac-toe=\u091f\u093f\u0915-\u091f\u0948\u0915-\u091f\u094b
to-a-game-of=\u0916\u0947\u0932 \u0915\u0940 \u090f\u0915 \u0916\u0947\u0932 \u0915\u0940 \u0913\u0930
volume=\u0935\u0949\u0932\u094d\u092f\u0942\u092e
windowed=\u0935\u093f\u0902\u0921\u094b \u092e\u094b\u0921
yes=\u0939\u093e\u0901
you-lost-against=\u0906\u092a \u0939\u093e\u0930 \u0917\u090f
you-were-challenged-by=\u0906\u092a\u0915\u094b \u091a\u0941\u0928\u094c\u0924\u0940 \u0926\u0940 \u0917\u0908
you-win=\u0906\u092a \u091c\u0940\u0924 \u0917\u090f
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0905\u0930\u092c\u0940)
chinese=\u4e2d\u6587 (\u091a\u0940\u0928\u0940)

View File

@@ -1,52 +1,74 @@
accept=Accetta
ai=Intelligenza Artificiale
appTitle=Selettore di Giochi ISY
app-title=Selettore di Giochi ISY
are-you-sure=Sei sicuro?
back=Indietro
backToMainMenu=Ritorna al menu principale
cancel=Annulla
challenge=Sfida
computer-difficulty=Difficolt\u00e0 del computer
computer-think-time=Tempo di riflessione del computer
computer=Computer
computerDifficulty=Difficolt\u00e0 del computer
computerThinkTime=Tempo di pensiero del computer
congratulations=Congratulazioni
connect=Connetti
connectionType=Tipo di connessione
credits=Crediti
dark-hc=Scuro (Alto Contrasto)
dark=Scuro
deny=Nega
developers=Sviluppatori
drawText=La partita \u00E8 terminata in parit\u00E0
effectsVolume=Volume effetti
musicVolume=Music Volume (translate me)
disconnect=Disconnetti
effects-volume=Volume degli effetti
enter-the-server-ip=Inserisci l'IP del server
enter-the-server-port=Inserisci la porta del server
enter-your-name=Inserisci il tuo nome
error=Errore
exit=Esci
forfeit=Abbandona
fullscreen=Schermo intero
goodGameText=Bel gioco. Ben giocato.
human=Umano
game-over=Fine del gioco
general=Generale
high-contrast=Alto contrasto
invalid-username=nome utente non valido
ip-address=Indirizzo IP
is-not-a-valid-ip-address=non \u00e8 un indirizzo IP valido
is-not-a-valid-port=non \u00e8 una porta valida
language=Lingua
large=Grande
layoutSize=Dimensione Layout
light-hc=Chiaro (Alto Contrasto)
layout-size=Dimensione layout
light=Chiaro
local=Locale
localization=Localizzazione
master-volume=Volume principale
medium=Medio
mergeCommander=Comandante di Merge
moralSupport=Supporto morale
merge-commander=Merge Commander
moral-support=Supporto morale
music-volume=Volume della musica
name=Nome
no=No
ok=OK
online=Online
opengl=OpenGL
options=Opzioni
othello=Othello
playerName=Nome del giocatore
productOwner=Proprietario del prodotto
quit=Uscire
quitSure=Sei sicuro?
scrumMaster=Scrum Master
server=Server
serverIP=Server-IP
serverPort=Porta del server
play=Gioca
player-name=Nome del giocatore
player=Giocatore
please-enter-your-name=Per favore inserisci il tuo nome
port=Porta
product-owner=Proprietario del prodotto
quit=Esci
reversi=Reversi
scrum-master=Scrum Master
send=Invia
server-information=Informazioni sul server
small=Piccolo
start=Inizia
style=Stile
the-game-ended-in-a-draw=La partita \u00e8 terminata in parit\u00e0
theme=Tema
tictactoe=Tic Tac Toe
volume=Volume principale
tic-tac-toe=Tris
to-a-game-of=a una partita di
volume=Volume
windowed=Finestra
yes=S\u00ec
you-lost-against=Hai perso contro
you-were-challenged-by=Sei stato sfidato da
you-win=Hai vinto
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabo)
chinese=\u4e2d\u6587 (Cinese)

View File

@@ -1,52 +1,74 @@
ai=\u4eba\u5de5\u77e5\u80fd
appTitle=ISY \u30b2\u30fc\u30e0\u30bb\u30ec\u30af\u30bf\u30fc
accept=\u627f\u8a8d
ai=\u4eba\u5de5\u77e9\u7565
app-title=ISY\u30b2\u30fc\u30e0\u30bb\u30ec\u30af\u30bf\u30fc
are-you-sure=\u672c\u5f53\u306b\u3088\u308d\u3057\u3044\u3067\u3059\u304b\uff1f
back=\u623b\u308b
backToMainMenu=\u30E1\u30A4\u30F3\u30E1\u30CB\u30E5\u30FC\u306B\u623B\u308B
computer=\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u30fc
computerDifficulty=\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u30fc\u96e3\u6613\u5ea6
computerThinkTime=\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306e\u8003\u3048\u6642\u9593
congratulations=\u304A\u3081\u3067\u3068\u3046\u3054\u3056\u3044\u307E\u3059
cancel=\u30ad\u30e3\u30f3\u30bb\u30eb
challenge=\u6311\u6226
computer-difficulty=\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306e\u96e3\u6613\u5ea6
computer-think-time=\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306e\u601d\u8003\u6642\u9593
computer=\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf
connect=\u63a5\u7d9a
connectionType=\u63A5\u7D9A\u30BF\u30A4\u30D7
credits=\u30af\u30ec\u30b8\u30c3\u30c8
dark-hc=\u30C0\u30FC\u30AF (\u9AD8\u30B3\u30F3\u30C8\u30E9\u30B9\u30C8)
dark=\u30C0\u30FC\u30AF
dark=\u30c0\u30fc\u30af
deny=\u62d2\u5426
developers=\u958b\u767a\u8005
drawText=\u30B2\u30FC\u30E0\u306F\u5E73\u7B49\u306B\u7D42\u4E86\u3057\u307E\u3057\u305F
effectsVolume=\u30a8\u30d5\u30a7\u30af\u30c8\u30dc\u30ea\u30e5\u30fc\u30e0
musicVolume=Music Volume (translate me)
fullscreen=\u5168\u753b\u9762
goodGameText=\u3044\u3044\u30B2\u30FC\u30E0\u3067\u3057\u305F\u3002\u3088\u304F\u6226\u3044\u307E\u3057\u305F\u3002
human=\u4eba\u9593
disconnect=\u5207\u65ad
effects-volume=\u52b9\u679c\u97f3\u91cf
enter-the-server-ip=\u30b5\u30fc\u30d0\u30fcIP\u3092\u5165\u529b
enter-the-server-port=\u30b5\u30fc\u30d0\u30fc\u30dd\u30fc\u30c8\u3092\u5165\u529b
enter-your-name=\u540d\u524d\u3092\u5165\u529b
error=\u30a8\u30e9\u30fc
exit=\u7d42\u4e86
forfeit=\u8f9e\u9000
fullscreen=\u30d5\u30eb\u30b9\u30af\u30ea\u30fc\u30f3
game-over=\u30b2\u30fc\u30e0\u30aa\u30fc\u30d0\u30fc
general=\u4e00\u822c
high-contrast=\u9AD8\u30B3\u30F3\u30C8\u30E9\u30B9
invalid-username=\u7121\u52b9\u306a\u30e6\u30fc\u30b6\u30fc\u540d
ip-address=IP\u30a2\u30c9\u30ec\u30b9
is-not-a-valid-ip-address=\u6709\u52b9\u306aIP\u30a2\u30c9\u30ec\u30b9\u3067\u306f\u3042\u308a\u307e\u305b\u3093
is-not-a-valid-port=\u6709\u52b9\u306a\u30dd\u30fc\u30c8\u756a\u53f7\u3067\u306f\u3042\u308a\u307e\u305b\u3093
language=\u8a00\u8a9e
large=\u5927
layoutSize=\u30EC\u30A4\u30A2\u30A6\u30C8\u30B5\u30A4\u30BA
light-hc=\u30E9\u30A4\u30C8 (\u9AD8\u30B3\u30F3\u30C8\u30E9\u30B9\u30C8)
light=\u30E9\u30A4\u30C8
local=\u5730\u57df
layout-size=\u30ec\u30a4\u30a2\u30a6\u30c8\u30b5\u30a4\u30ba
light=\u30e9\u30a4\u30c8
local=\u30ed\u30fc\u30ab\u30eb
localization=\u30ed\u30fc\u30ab\u30e9\u30a4\u30bc\u30fc\u30b7\u30e7\u30f3
medium=\u4E2D
mergeCommander=\u30de\u30fc\u30b8\u30b3\u30de\u30f3\u30c0\u30fc
moralSupport=\u6c17\u529b\u652f\u63f4
master-volume=\u30de\u30b9\u30bf\u30fc\u30dc\u30ea\u30e5\u30fc\u30e0
medium=\u4e2d
merge-commander=\u30de\u30fc\u30b8\u30b3\u30de\u30f3\u30c0\u30fc
moral-support=\u30e1\u30f3\u30bf\u30eb\u30b5\u30dd\u30fc\u30c8
music-volume=\u97f3\u697d\u97f3\u91cf
name=\u540d\u524d
no=\u3044\u3044\u3048
ok=OK
online=\u30aa\u30f3\u30e9\u30a4\u30f3
opengl=OpenGL
options=\u30aa\u30d7\u30b7\u30e7\u30f3
othello=\u30aa\u30bb\u30ed
playerName=\u30d7\u30ec\u30a4\u30e4\u30fc\u540d
productOwner=\u30d7\u30ed\u30c0\u30af\u30c8\u30aa\u30fc\u30ca\u30fc
play=\u30d7\u30ec\u30a4
player-name=\u30d7\u30ec\u30a4\u30e4\u30fc\u540d
player=\u30d7\u30ec\u30a4\u30e4\u30fc
please-enter-your-name=\u540d\u524d\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044
port=\u30dd\u30fc\u30c8
product-owner=\u30d7\u30ed\u30c0\u30af\u30c8\u30aa\u30fc\u30ca\u30fc
quit=\u7d42\u4e86
quitSure=\u672c\u5f53\u306b\u7d42\u4e86\u3057\u307e\u3059\u304b\uff1f
scrumMaster=\u30b9\u30af\u30e9\u30e0\u30de\u30b9\u30bf\u30fc
server=\u30b5\u30fc\u30d0\u30fc
serverIP=\u30b5\u30fc\u30d0\u30fc IP
serverPort=\u30b5\u30fc\u30d0\u30fc \u30dd\u30fc\u30c8
small=\u5C0F
start=\u59cb\u307e\u308a
theme=\u30C6\u30FC\u30DE
tictactoe=\u30bf\u30a4\u30af\u30bf\u30c3\u30c8\u30c8\u30a6
volume=\u30de\u30b9\u30bf\u30fc\u30dc\u30ea\u30e5\u30fc\u30e0
windowed=\u30a6\u30a3\u30f3\u30c9\u30a6
reversi=\u30ea\u30d0\u30fc\u30b7
scrum-master=\u30b9\u30af\u30e9\u30e0\u30de\u30b9\u30bf\u30fc
send=\u9001\u4fe1
server-information=\u30b5\u30fc\u30d0\u60c5\u5831
small=\u5c0f
style=\u30b9\u30bf\u30a4\u30eb
the-game-ended-in-a-draw=\u30b2\u30fc\u30e0\u306f\u5f15\u304d\u5206\u3051\u306b\u7d42\u308f\u308a\u307e\u3057\u305f
theme=\u30c6\u30fc\u30de
tic-tac-toe=\u4e09\u76ee\u4e26\u3079
to-a-game-of=\u30b2\u30fc\u30e0\u306b
volume=\u97f3\u91cf
windowed=\u30a6\u30a3\u30f3\u30c9\u30a6\u8868\u793a
yes=\u306f\u3044
you-lost-against=\u3042\u306a\u305f\u306f ... \u306b\u6557\u308c\u307e\u3057\u305f
you-were-challenged-by=\u3042\u306a\u305f\u306f ... \u304b\u3089\u6311\u6226\u3055\u308c\u307e\u3057\u305f
you-win=\u52dd\u5229\u3067\u3059
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u30a2\u30e9\u30d3\u30a2\u8a9e)
chinese=\u4e2d\u6587 (\u4e2d\u6587)

View File

@@ -1,52 +1,74 @@
ai=\uc778\uacf5 \uc9c0\ub2a5
appTitle=ISY \uac8c\uc784 \uc120\ud0dd\uae30
back=\ub4a4\ub85c
backToMainMenu=\uBA54\uC778 \uBA54\uB274\uB85C \uB3CC\uC544\uAC00\uAE30
computer=\uce74\ud14c\uae4c
computerDifficulty=\uce74\ud14c\uae4c \ub2e8\uacc4
computerThinkTime=\uc870\ub9ac\ud558\ub294 \uc2dc\uac04
congratulations=\uCD95\uD558\uD569\uB2C8\uB2E4
connect=\uc5f0\uacb0
connectionType=\uC5F0\uACB0 \uC720\uD615
credits=\uac10\uc0ac
dark-hc=\uC5B4\uB460 (\uACE0 \uB300\uBE44)
accept=\uC218\uB77D
ai=\uC778\uACF5 \uC9C0\uB2A5
app-title=ISY \uAC8C\uC784 \uC120\uD0DD\uAE30
are-you-sure=\uC815\uB9D0\uB85C \uD655\uC2E4\uD569\uB2C8\uAE4C?
back=\uB4A4\uB85C
cancel=\uCDE8\uC18C
challenge=\uCC38\uC5EC
computer-difficulty=\uCEF4\uD4E8\uD130 \uC5B4\uB9AC\uAE30
computer-think-time=\uCEF4\uD4E8\uD130 \uC0DD\uAC01 \uC2DC\uAC04
computer=\uCEF4\uD4E8\uD130
connect=\uC5F0\uACB0
credits=\uD06C\uB808\uB527
dark=\uC5B4\uB460
developers=\uac1c\ubc1c\uc790
drawText=\uAC8C\uC784\uC740 \uBB34\uC2B9\uBD84\uC73C\uB85C \uB05D\uB0AC\uC2B5\uB2C8\uB2E4
effectsVolume=\ud654\uac70 \ubc84\uc804
musicVolume=Music Volume (translate me)
fullscreen=\uc804\uccb4 \ud654\uba74
goodGameText=\uC88B\uC740 \uAC8C\uC784\uC774\uC600\uC2B5\uB2C8\uB2E4. \uC798 \uD50C\uB808\uC774\uD588\uC2B5\uB2C8\uB2E4.
human=\uc778\uac04
language=\uc5b8\uc5b4
deny=\uAC70\uBD80
developers=\uAC1C\uBC1C\uC790
disconnect=\uC5F0\uACB0 \uC624\uD508
effects-volume=\uD6A8\uACFC\uC74C \uBCFC\uB968
enter-the-server-ip=\uC11C\uBC84 IP\uB97C \uC785\uB825\uD558\uC138\uC694
enter-the-server-port=\uC11C\uBC84 \uD3EC\uD2B8\uB97C \uC785\uB825\uD558\uC138\uC694
enter-your-name=\uC774\uB984\uC744 \uC785\uB825\uD558\uC138\uC694
error=\uC624\uB958
exit=\uB098\uAC00\uAE30
forfeit=\uAE30\uAD6C
fullscreen=\uC804\uCCB4 \uD654\uBA74
game-over=\uAC8C\uC784 \uC885\uB8CC
general=\uC77C\uBC18
high-contrast=\uACE0\uB3C4 \uB2E8\uC5B4
invalid-username=\uBB34\uD6A8\uD55C \uC0AC\uC6A9\uC790 \uC774\uB984
ip-address=IP \uC8FC\uC18C
is-not-a-valid-ip-address=\uC62C\uBC14\uB978 IP \uC8FC\uC18C\uAC00 \uC544\uB2D9\uB2C8\uB2E4
is-not-a-valid-port=\uC62C\uBC14\uB978 \uD3EC\uD2B8\uAC00 \uC544\uB2D9\uB2C8\uB2E4
language=\uC5B8\uC5B4
large=\uD070
layoutSize=\uB808\uC774\uC544\uC6C3 \uD06C\uAE30
light-hc=\uBC1D\uC74C (\uACE0 \uB300\uBE44)
light=\uBC1D\uC74C
local=\ub85c\uceec
localization=\uc5b8\uc5b4\ud654
layout-size=\uB77C\uC774\uC6C3 \uD06C\uAE30
light=\uBCF4\uD1B5
local=\uB85C\uCEEC
localization=\uB85C\uCEEC\uB9AC\uC870
master-volume=\uBAA8\uB4E0 \uBCFC\uB968
medium=\uBCF4\uD1B5
mergeCommander=\uba54\uc9c0 \ucea0\ub9ac\ub354
moralSupport=\uc815\uc2e0\uc801 \uc9c0\uc6d0
no=\uc544\ub2c8\uc624
merge-commander=\uBA54\uC9C0 \uCEE8\uBA38\uB2C8
moral-support=\uC815\uC2E0\uC801 \uC9C0\uC6D0
music-volume=\uC74C\uC545 \uBCFC\uB968
name=\uC774\uB984
no=\uC544\uB2C8\uC624
ok=\uD655\uC778
online=\uC628\uB77C\uC778
opengl=OpenGL
options=\uc635\uc158
othello=\uc624\ud14c\ub85c
playerName=\ud50c\ub808\uc774\uc5b4 \uc774\ub984
productOwner=\uc81c\ud488 \uad00\ub9ac\uc790
quit=\uc885\ub8cc
quitSure=\uc815\ub9d0 \uc885\ub8cc\ud558\uc2dc\uaca0\uc2b5\ub2c8\uae4c?
scrumMaster=\uc2a4\ud06c\ub7fc \ub9c8\uc2a4\ud130
server=\uc11c\ubc84
serverIP=\uc11c\ubc84 IP
serverPort=\uc11c\ubc84 \ud3ec\ud2b8
small=\uC791\uC74C
start=\uc2dc\uc791
options=\uC635\uC158
play=\uC7AC\uC0DD
player-name=\uD50C\uB808\uC774\uC5B4 \uC774\uB984
player=\uD50C\uB808\uC774\uC5B4
please-enter-your-name=\uC774\uB984\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694
port=\uD3EC\uD2B8
product-owner=\uD504\uB85C\uB354\uD2B8 \uC624\uB108
quit=\uC885\uB8CC
reversi=\uB9AC\uBC84\uC2DC
scrum-master=\uC2A4\uD06C\uB7FC \uB9C8\uC2A4\uD130
send=\uBCF4\uB0B4\uAE30
server-information=\uC11C\uBC84 \uC815\uBCF4
small=\uC791\uC740
style=\uC2A4\uD0C0\uC77C
the-game-ended-in-a-draw=\uAC8C\uC784\uC774 \uBB34\uC2B9\uBD80\uB85C \uC885\uB8CC\uB418\uC5C8\uC2B5\uB2C8\uB2E4
theme=\uC8FC\uC81C
tictactoe=\ud2f0\ud06c\ud0d0\ud1a0
volume=\ub9c8\uc2a4\ud130 \ubcfc\ub80c
windowed=\ucc3d \ubaa8\ub4dc
yes=\ub124
tic-tac-toe=\uD2F0\uD06C\uD0D1\uD1A0
to-a-game-of=... \uAC8C\uC784\uC5D0
volume=\uBCFC\uB968
windowed=\uCC3D \uBAA9\uB85D
yes=\uB124
you-lost-against=... \uC5D0\uAC8C \uC9C0\uC600\uC2B5\uB2C8\uB2E4
you-were-challenged-by=... \uB85C\uBD80\uD130 \uCC38\uC5EC \uC694\uCCAD\uC744 \uBC1B\uC558\uC2B5\uB2C8\uB2E4
you-win=\uC774\uACBC\uC2B5\uB2C8\uB2E4
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0639\u0631\u0628\u064a\u0629)
chinese=\u4e2d\u6587 (\u4e2d\u6587)

View File

@@ -1,52 +1,74 @@
accept=Accepteren
ai=Kunstmatige Intelligentie
appTitle=ISY Spel Kiezer
app-title=ISY Spel Kiezer
are-you-sure=Weet je het zeker?
back=Terug
backToMainMenu=Terug naar hoofdmenu
cancel=Annuleren
challenge=Uitdaging
computer-difficulty=Computermoeilijkheid
computer-think-time=Denktijd computer
computer=Computer
computerDifficulty=Computermoeilijkheid
computerThinkTime=Computer Denk Tijd
congratulations=Gefeliciteerd
connect=Verbinden
connectionType=Verbindingstype
credits=Credits
dark-hc=Donker (Hoog Contrast)
dark=Donker
deny=Weigeren
developers=Ontwikkelaars
drawText=Het spel eindigde in een gelijkspel
effectsVolume=Effecten Volume
musicVolume=Music Volume (translate me)
disconnect=Verbreken
effects-volume=Effectvolume
enter-the-server-ip=Voer het server-IP in
enter-the-server-port=Voer de serverpoort in
enter-your-name=Voer je naam in
error=Fout
exit=Afsluiten
forfeit=Opgeven
fullscreen=Volledig scherm
goodGameText=Goed gespeeld. Mooie wedstrijd.
human=Mens
game-over=Spel afgelopen
general=Algemeen
high-contrast=Hoog contrast
invalid-username=ongeldige gebruikersnaam
ip-address=IP-adres
is-not-a-valid-ip-address=is geen geldig IP-adres
is-not-a-valid-port=is geen geldige poort
language=Taal
large=Groot
layoutSize=Lay-outgrootte
light-hc=Licht (Hoog Contrast)
layout-size=Lay-outgrootte
light=Licht
local=Lokaal
localization=Lokalisatie
medium=Middel
mergeCommander=Merge-commandant
moralSupport=Moraalsteun
master-volume=Hoofdvolume
medium=Middelgroot
merge-commander=Merge Commander
moral-support=Morele steun
music-volume=Muziekvolume
name=Naam
no=Nee
ok=Ok<EFBFBD>
online=Online
opengl=OpenGL
options=Opties
othello=Othello
playerName=Spelernaam
productOwner=Producteigenaar
quit=Afsluiten
quitSure=Weet je het zeker?
scrumMaster=Scrum Master
server=Server
serverIP=Server-IP
serverPort=Serverpoort
play=Spelen
player-name=Spelersnaam
player=Speler
please-enter-your-name=Voer alstublieft je naam in
port=Poort
product-owner=Producteigenaar
quit=Stoppen
reversi=Reversi
scrum-master=Scrum Master
send=Verzenden
server-information=Serverinformatie
small=Klein
start=Start
style=Stijl
the-game-ended-in-a-draw=Het spel eindigde in een gelijkspel
theme=Thema
tictactoe=Boter Kaas en Eieren
volume=Hoofdvolume
tic-tac-toe=Boter Kaas en Eieren
to-a-game-of=voor een spelletje
volume=Volume
windowed=Venstermodus
yes=Ja
you-lost-against=Je hebt verloren van
you-were-challenged-by=Je bent uitgedaagd door
you-win=Je wint
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabisch)
chinese=\u4e2d\u6587 (Chinees)

View File

@@ -1,52 +1,74 @@
accept=\u041f\u0440\u0438\u043d\u044f\u0442\u044c
ai=\u0418\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442
appTitle=ISY \u0412\u044b\u0431\u043e\u0440 \u0438\u0433\u0440
app-title=ISY \u0412\u044b\u0431\u043e\u0440 \u0438\u0433\u0440
are-you-sure=\u0412\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b?
back=\u041d\u0430\u0437\u0430\u0434
backToMainMenu=\u041D\u0430\u0437\u0430\u0434 \u0432 \u0433\u043B\u0430\u0432\u043D\u043E\u0435 \u043C\u0435\u043D\u044E
cancel=\u041e\u0442\u043c\u0435\u043d\u0430
challenge=\u0412\u044b\u0437\u043e\u0432
computer-difficulty=\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430
computer-think-time=\u0412\u0440\u0435\u043c\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430
computer=\u041a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440
computerDifficulty=\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430
computerThinkTime=\u0412\u0440\u0435\u043c\u044f \u043e\u0431\u0434\u0443\u043c\u044b \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430
congratulations=\u041F\u043E\u0437\u0434\u0440\u0430\u0432\u043B\u044F\u0435\u043C
connect=\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f
connectionType=\u0442\u0438\u043F \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u044F
credits=\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u043d\u043e\u0441\u0442\u0438
dark-hc=\u0442\u0451\u043C\u043D\u044B\u0439 (\u0432\u044B\u0441\u043E\u043A\u0438\u0439 \u043A\u043E\u043D\u0442\u0440\u0430\u0441\u0442)
dark=\u0442\u0451\u043C\u043D\u044B\u0439
credits=\u041a\u0440\u0435\u0434\u0438\u0442\u044b
dark=\u0422\u0451\u043c\u043d\u044b\u0439
deny=\u041e\u0442\u043a\u0430\u0437\u0430\u0442\u044c
developers=\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438
drawText=\u0418\u0433\u0440\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043B\u0430\u0441\u044C \u043D\u0438\u0447\u044C\u0435\u0439
effectsVolume=\u042d\u0444\u0444\u0435\u043a\u0442\u044b \u0433\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u044c
musicVolume=Music Volume (translate me)
disconnect=\u041e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f
effects-volume=\u0413\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432
enter-the-server-ip=\u0412\u0432\u0435\u0434\u0438\u0442\u0435 IP \u0441\u0435\u0440\u0432\u0435\u0440\u0430
enter-the-server-port=\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043f\u043e\u0440\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430
enter-your-name=\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432\u0430\u0448\u0435 \u0438\u043c\u044f
error=\u041e\u0448\u0438\u0431\u043a\u0430
exit=\u0412\u044b\u0445\u043e\u0434
forfeit=\u0421\u0434\u0430\u0442\u044c \u0441\u043e\u0440\u043e\u0432\u043d\u043e\u0441\u0442\u0438
fullscreen=\u041f\u043e\u043b\u043d\u043e\u044d\u043a\u0440\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c
goodGameText=\u0425\u043E\u0440\u043E\u0448\u0430\u044F \u0438\u0433\u0440\u0430. \u0425\u043E\u0440\u043E\u0448\u043E \u0441\u044B\u0433\u0440\u0430\u043D\u043E.
human=\u0427\u0435\u043b\u043e\u0432\u0435\u043a
game-over=\u0418\u0433\u0440\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430
general=\u041e\u0431\u0449\u0438\u0435
high-contrast=\u0412\u044B\u0441\u043E\u043A\u0430\u044F \u043A\u043E\u043D\u0442\u0440\u0430\u0441\u0442\u043D\u043E\u0441\u0442\u044C
invalid-username=\u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0435 \u0438\u043c\u044f
ip-address=IP \u0430\u0434\u0440\u0435\u0441
is-not-a-valid-ip-address=\u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c IP \u0430\u0434\u0440\u0435\u0441\u043e\u043c
is-not-a-valid-port=\u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u0440\u0442\u043e\u043c
language=\u042f\u0437\u044b\u043a
large=\u0431\u043E\u043B\u044C\u0448\u043E\u0439
layoutSize=\u0440\u0430\u0437\u043C\u0435\u0440 \u043C\u0430\u043A\u0435\u0442\u0430
light-hc=\u0441\u0432\u0435\u0442\u043B\u044B\u0439 (\u0432\u044B\u0441\u043E\u043A\u0438\u0439 \u043A\u043E\u043D\u0442\u0440\u0430\u0441\u0442)
light=\u0441\u0432\u0435\u0442\u043B\u044B\u0439
large=\u0411\u043e\u043b\u044c\u0448\u043e\u0439
layout-size=\u0420\u0430\u0437\u043c\u0435\u0440 \u043c\u043e\u043d\u0442\u0430\u0436\u0430
light=\u0421\u0432\u0435\u0442\u043b\u044b\u0439
local=\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439
localization=\u041b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f
medium=\u0441\u0440\u0435\u0434\u043D\u0438\u0439
mergeCommander=\u041a\u043e\u043c\u0430\u043d\u0434\u0435\u0440 \u0441\u043b\u0438\u044f\u043d\u0438\u044f
moralSupport=\u041c\u043e\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430
master-volume=\u041e\u0431\u0449\u0438\u0439 \u0433\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u044c
medium=\u0421\u0440\u0435\u0434\u043d\u0438\u0439
merge-commander=Merge Commander
moral-support=\u041c\u043e\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430
music-volume=\u0413\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u044c \u043c\u0443\u0437\u044b\u043a\u0438
name=\u0418\u043c\u044f
no=\u041d\u0435\u0442
ok=OK
online=\u0412 \u0441\u0435\u0442\u0438
opengl=OpenGL
options=\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438
othello=\u041e\u0442\u0435\u043b\u043b\u043e
playerName=\u0418\u043c\u044f \u0438\u0433\u0440\u043e\u043a\u0430
productOwner=\u0412\u043b\u0430\u0434\u0435\u043b\u0435\u0446 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430
play=\u0418\u0433\u0440\u0430\u0442\u044c
player-name=\u0418\u043c\u044f \u0438\u0433\u0440\u043e\u043a\u0430
player=\u0418\u0433\u0440\u043e\u043a
please-enter-your-name=\u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u0432\u0430\u0448\u0435 \u0438\u043c\u044f
port=\u041f\u043e\u0440\u0442
product-owner=\u0412\u043b\u0430\u0434\u0435\u043b\u0435\u0446 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430
quit=\u0412\u044b\u0445\u043e\u0434
quitSure=\u0423\u0432\u0435\u0440\u0435\u043d\u044b \u043b\u0438?
scrumMaster=\u041c\u0430\u0441\u0442\u0435\u0440 Scrum
server=\u0421\u0435\u0440\u0432\u0435\u0440
serverIP=\u0418\u043f\u0440\u0435\u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430
serverPort=\u041f\u043e\u0440\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430
small=\u043C\u0430\u043B\u0435\u043D\u044C\u043A\u0438\u0439
start=\u0421\u0442\u0430\u0440\u0442
theme=\u0442\u0435\u043C\u0430
tictactoe=\u041a\u0440\u0435\u0441\u0442\u0438\u043a\u0438
volume=\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0433\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u044c
reversi=\u0420\u0435\u0432\u0435\u0440\u0441\u0438
scrum-master=Scrum Master
send=\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c
server-information=\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0435
small=\u041c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439
style=\u0421\u0442\u0438\u043b\u044c
the-game-ended-in-a-draw=\u0418\u0433\u0440\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0430\u0441\u044c \u043d\u0438\u0447\u044c\u0435\u0439
theme=\u0422\u0435\u043c\u0430
tic-tac-toe=\u041a\u0440\u0435\u0441\u0442\u0438\u043a\u043e
to-a-game-of=\u043a \u0438\u0433\u0440\u0435 \u0432
volume=\u0413\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u044c
windowed=\u041e\u043a\u043d\u043e
yes=\u0414\u0430
you-lost-against=\u0412\u044b \u043f\u0440\u043e\u0438\u0433\u0440\u0430\u043b\u0438 \u043a\u043e\u043c\u0443
you-were-challenged-by=\u0412\u0430\u0441 \u0432\u044b\u0437\u0432\u0430\u043b \u043d\u0430 \u0441\u043e\u0440\u0435\u0432\u043d\u0438\u043a
you-win=\u0412\u044b \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442\u0435
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0410\u0440\u0430\u0431\u0441\u043a\u0438\u0439)
chinese=\u4e2d\u6587 (\u041a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0439)

View File

@@ -1,52 +1,74 @@
accept=\u63a5\u53d7
ai=\u4eba\u5de5\u667a\u80fd
appTitle=ISY \u6e38\u620f\u9009\u62e9\u5668
app-title=ISY \u6e38\u620f\u9009\u62e9\u5668
are-you-sure=\u60a8\u786e\u5b9a\u5417\uff1f
back=\u8fd4\u56de
backToMainMenu=\u8FD4\u56DE\u4E3B\u83DC\u5355
cancel=\u53d6\u6d88
challenge=\u6311\u6218
computer-difficulty=\u8ba1\u7b97\u673a\u96be\u5ea6
computer-think-time=\u8ba1\u7b97\u673a\u601d\u8003\u65f6\u95f4
computer=\u8ba1\u7b97\u673a
computerDifficulty=\u8ba1\u7b97\u673a\u96be\u5ea6
computerThinkTime=\u7535\u8111\u8003\u616e\u65f6\u95f4
congratulations=\u606D\u559C
connect=\u8fde\u63a5
connectionType=\u8FDE\u63A5\u7C7B\u578B
credits=\u6b23\u8d4f
dark-hc=\u6697 (\u9AD8\u5BF9\u6BD4)
dark=\u6697
credits=\u81f4\u8c22
dark=\u6697\u8272
deny=\u62d2\u7edd
developers=\u5f00\u53d1\u8005
drawText=\u6E38\u620F\u4EE5\u5E73\u5C40\u7ED3\u675F
effectsVolume=\u6548\u679c\u91cf
musicVolume=Music Volume (translate me)
disconnect=\u65ad\u5f00\u8fde\u63a5
effects-volume=\u6548\u679c\u97f3\u91cf
enter-the-server-ip=\u8f93\u5165\u670d\u52a1\u5668 IP
enter-the-server-port=\u8f93\u5165\u670d\u52a1\u5668\u7aef\u53e3
enter-your-name=\u8f93\u5165\u60a8\u7684\u540d\u5b57
error=\u9519\u8bef
exit=\u9000\u51fa
forfeit=\u68c0\u8f93
fullscreen=\u5168\u5c4f
goodGameText=\u6E38\u620F\u5F88\u597D. \u8868\u73B0\u4F18\u79C0.
human=\u4eba
game-over=\u6e38\u620f\u7ed3\u675f
general=\u901a\u7528
high-contrast=\u9AD8\u5BF9\u6BD4\u5EA6
invalid-username=\u7528\u6237\u540d\u65e0\u6548
ip-address=IP \u5730\u5740
is-not-a-valid-ip-address=\u4e0d\u662f\u6709\u6548\u7684 IP \u5730\u5740
is-not-a-valid-port=\u4e0d\u662f\u6709\u6548\u7684\u7aef\u53e3
language=\u8bed\u8a00
large=\u5927
layoutSize=\u5E03\u5C40\u5927\u5C0F
light-hc=\u4EAE (\u9AD8\u5BF9\u6BD4)
light=\u4EAE
layout-size=\u5e03\u5c40\u5927\u5c0f
light=\u4eae\u8272
local=\u672c\u5730
localization=\u6d88\u606f\u5c55\u793a / \u672c\u5730\u5316
medium=\u4E2D
mergeCommander=Merge \u63a7\u4e3b
moralSupport=\u795e\u7cbe\u652f\u6301
no=\u5426
localization=\u672c\u5730\u5316
master-volume=\u603b\u97f3\u91cf
medium=\u4e2d
merge-commander=\u5408\u5e76\u6307\u6325
moral-support=\u7cbe\u795e\u652f\u6301
music-volume=\u97f3\u4e50\u97f3\u91cf
name=\u540d\u5b57
no=\u4e0d
ok=\u786e\u5b9a
online=\u5728\u7ebf
opengl=OpenGL
options=\u9009\u9879
othello=Othello
playerName=\u73a9\u5bb6\u540d\u79f0
productOwner=\u54c1\u76d8\u4ea7\u54c1\u4eba
play=\u6e38\u73a9
player-name=\u73a9\u5bb6\u540d
player=\u73a9\u5bb6
please-enter-your-name=\u8bf7\u8f93\u5165\u60a8\u7684\u540d\u5b57
port=\u7aef\u53e3
product-owner=\u4ea7\u54c1\u62e5\u6709\u8005
quit=\u9000\u51fa
quitSure=\u4f60\u786e\u5b9a\u5417?
scrumMaster=Scrum \u4f1a\u5458
server=\u670d\u52a1\u5668
serverIP=\u670d\u52a1\u5668 IP
serverPort=\u670d\u52a1\u5668 \u7aef\u53e3
small=\u5C0F
start=\u5f00\u59cb
theme=\u4E3B\u9898
tictactoe=Tic Tac Toe
volume=\u4e3b\u97f3\u91cf
reversi=\u9ed1\u767d\u68cb
scrum-master=\u9879\u76ee\u7ecf\u7406
send=\u53d1\u9001
server-information=\u670d\u52a1\u5668\u4fe1\u606f
small=\u5c0f
style=\u98ce\u683c
the-game-ended-in-a-draw=\u6e38\u620f\u4ee5\u548c\u5c40\u7ed3\u675f
theme=\u4e3b\u9898
tic-tac-toe=\u4e09\u5b9a\u7ebf
to-a-game-of=\u6311\u6218\u4e00\u573a
volume=\u97f3\u91cf
windowed=\u7a97\u53e3\u6a21\u5f0f
yes=\u662f
you-lost-against=\u60a8\u8f93\u7ed9\u4e86
you-were-challenged-by=\u60a8\u88ab\u6311\u6218\u81ea
you-win=\u60a8\u83b7\u80dc\u4e86
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u963f\u62c9\u4f2f\u8bed)
chinese=\u4e2d\u6587

View File

@@ -1,215 +0,0 @@
/* ----------------------------
.background
----------------------------- */
.bg-primary {
-fx-background-color: #0a0a0a;
}
.bg-secondary {
-fx-background-color: #1a1a1a;
}
.bg-popup {
-fx-background-color: #0a0a0acc;
}
/* ----------------------------
.button
----------------------------- */
.button {
/* Layout */
-fx-padding: 10 20;
-fx-background-radius: 6;
-fx-cursor: hand;
/* Color */
-fx-background-color: #1a1a1a;
-fx-text-fill: #ffffff;
-fx-border-color: #ffffff;
-fx-border-width: 1;
/* Effects */
-fx-effect: dropshadow(gaussian, #00000099, 4, 0, 0, 1);
}
.button:hover {
-fx-background-color: #2a2a2a;
-fx-border-color: #00ff00;
}
/* ----------------------------
.choice-box
----------------------------- */
.choice-box {
/* Layout */
-fx-padding: 6;
-fx-background-radius: 4;
/* Color */
-fx-background-color: #1a1a1a;
-fx-border-color: #ffffff;
-fx-border-width: 1;
-fx-mark-color: #ffffff;
}
.choice-box:hover {
-fx-border-color: #00ff00;
}
.choice-box:focused {
-fx-border-color: #00cc66;
}
.choice-box .label {
-fx-text-fill: #ffffff;
}
/* ----------------------------
.choice-box popup styling
----------------------------- */
.choice-box .context-menu {
/* Layout */
-fx-padding: 4;
-fx-background-radius: 4;
/* Color */
-fx-background-color: #1a1a1a;
-fx-border-color: #ffffff;
-fx-border-width: 1;
}
.choice-box .menu-item {
/* Layout */
-fx-padding: 6 12;
}
.choice-box .menu-item .label {
-fx-text-fill: #ffffff;
}
.choice-box .menu-item:hover {
-fx-background-color: #2a2a2a;
}
.choice-box .menu-item:focused {
-fx-background-color: #00ff00;
-fx-text-fill: #000000;
}
/* ----------------------------
.container
----------------------------- */
.container {
/* Layout */
-fx-padding: 10;
-fx-alignment: center;
/* Color */
-fx-background-color: #1a1a1a;
}
/* ----------------------------
.input
----------------------------- */
.input {
/* Layout */
-fx-padding: 8;
-fx-background-radius: 4;
/* Color */
-fx-background-color: #1a1a1a;
-fx-text-fill: #ffffff;
-fx-border-color: #ffffff;
-fx-border-width: 1;
}
.input:hover {
-fx-border-color: #00ff00;
}
.input:focused {
-fx-border-color: #00cc66;
}
/* ----------------------------
.separator
----------------------------- */
.separator {
/* Layout */
-fx-padding: 10 0;
}
.separator .line {
/* Color */
-fx-border-color: #ffffff;
-fx-border-width: 0 0 1 0;
}
/* ----------------------------
.slider
----------------------------- */
.slider {
/* Layout */
-fx-padding: 6 0;
/* Color */
-fx-background-color: transparent;
}
.slider .track {
/* Color */
-fx-background-color: linear-gradient(to left, #00ff00, #ff0000);
-fx-background-insets: 0;
-fx-background-radius: 2;
-fx-pref-height: 4;
}
.slider .thumb {
/* Color */
-fx-background-color: #ffffff;
-fx-background-radius: 50%;
/* Effects */
-fx-effect: dropshadow(gaussian, #000000aa, 4, 0, 0, 1);
}
.slider .thumb:hover {
-fx-scale-x: 1.2;
-fx-scale-y: 1.2;
}
/* ----------------------------
.text-header
----------------------------- */
.text-header {
-fx-fill: #ffffff;
-fx-text-fill: #ffffff;
}
/* ----------------------------
.text-normal
----------------------------- */
.text-normal {
-fx-fill: #f0f0f0;
-fx-text-fill: #f0f0f0;
}
/* ----------------------------
.toggle-button
----------------------------- */
.toggle {
/* Layout */
-fx-padding: 8 16;
-fx-background-radius: 6;
/* Color */
-fx-background-color: #1f1f1f;
-fx-text-fill: #ffffff;
-fx-border-color: #ffffff;
}
.toggle:hover {
-fx-background-color: #00ff00;
-fx-text-fill: #000000;
-fx-border-color: #00ff00;
}

View File

@@ -1,215 +1,134 @@
/* ----------------------------
.background
----------------------------- */
.bg-primary {
-fx-background-color: #181818;
-fx-background-color: linear-gradient(to bottom, #2a3a45, #1c2730);
}
.bg-secondary {
-fx-background-color: #2a2a2a;
-fx-background-color: linear-gradient(to bottom, #3b4a57, #2a3742);
}
.bg-popup {
-fx-background-color: #1818187f;
-fx-background-color: rgba(20, 40, 55, 0.9);
-fx-background-radius: 8;
-fx-effect: dropshadow(gaussian, #224455cc, 8, 0, 0, 2);
}
/* ----------------------------
.button
----------------------------- */
.button {
/* Layout */
-fx-padding: 10 20;
-fx-background-radius: 6;
-fx-background-color: linear-gradient(to bottom, #1f5e20, #2e7d2e);
-fx-background-radius: 8;
-fx-border-color: #3caf3f;
-fx-cursor: hand;
/* Color */
-fx-background-color: #2a2a2a;
-fx-text-fill: #f0f0f0;
-fx-border-color: #3a3a3a;
-fx-border-width: 1;
/* Effects */
-fx-effect: dropshadow(gaussian, #0000004d, 4, 0, 0, 1);
-fx-effect: dropshadow(gaussian, #3caf3fdd, 6, 0, 0, 2);
-fx-text-fill: #e0f2e9;
-fx-font-weight: bold;
}
.button:hover {
-fx-background-color: #3a3a3a;
-fx-border-color: #4caf50;
-fx-background-color: linear-gradient(to bottom, #44a044, #57b257);
-fx-border-color: #2f7d2f;
}
/* ----------------------------
.choice-box
----------------------------- */
.choice-box {
/* Layout */
-fx-padding: 6;
-fx-background-radius: 4;
/* Color */
-fx-background-color: #2a2a2a;
-fx-border-color: #444444;
-fx-border-width: 1;
-fx-mark-color: #f0f0f0;
.combo-box {
-fx-background-color: linear-gradient(to bottom, #3c5155, #2a3a3e);
-fx-background-radius: 6;
-fx-border-color: #3caf3f;
-fx-cursor: hand;
}
.choice-box:hover {
-fx-border-color: #4caf50;
.combo-box:hover {
-fx-border-color: #55a755;
}
.choice-box:focused {
-fx-border-color: #81c784;
.combo-box:focused {
-fx-border-color: #88cc88;
-fx-effect: dropshadow(gaussian, #88cc8899, 5, 0, 0, 1);
}
.choice-box .label {
-fx-text-fill: #f0f0f0;
.combo-box .arrow,
.combo-box .arrow-button {
-fx-background-color: transparent;
-fx-border-color: transparent;
}
/* ----------------------------
.choice-box popup styling
----------------------------- */
.choice-box .context-menu {
/* Layout */
-fx-padding: 4;
-fx-background-radius: 4;
/* Color */
-fx-background-color: #2a2a2a;
-fx-border-color: #444444;
-fx-border-width: 1;
.combo-box .list-cell {
-fx-background-color: transparent;
-fx-text-fill: #a8d0a8;
}
.choice-box .menu-item {
/* Layout */
-fx-padding: 6 12;
.combo-box .list-view {
-fx-background-color: #264233;
-fx-background-radius: 6;
-fx-border-color: #3caf3f;
}
.choice-box .menu-item .label {
-fx-text-fill: #dddddd;
.combo-box-popup .list-cell {
-fx-text-fill: #a8d0a8;
}
.choice-box .menu-item:hover {
-fx-background-color: #3a3a3a;
.combo-box-popup .list-cell:hover {
-fx-background-color: #44a044;
}
.choice-box .menu-item:focused {
-fx-background-color: #4caf50;
-fx-text-fill: #ffffff;
.combo-box-popup .list-cell:selected {
-fx-background-color: #2e7d2e;
-fx-text-fill: #e0f2e9;
}
/* ----------------------------
.container
----------------------------- */
.container {
/* Layout */
-fx-padding: 10;
-fx-alignment: center;
/* Color */
-fx-background-color: #2a2a2a;
}
/* ----------------------------
.input
----------------------------- */
.input {
/* Layout */
-fx-padding: 8;
-fx-background-radius: 4;
/* Color */
-fx-background-color: #2a2a2a;
-fx-text-fill: #f0f0f0;
-fx-border-color: #444444;
-fx-border-width: 1;
-fx-background-color: linear-gradient(to bottom, #1f3a3b, #124040);
-fx-background-radius: 6;
-fx-border-color: #3caf3f;
-fx-text-fill: #a8d0a8;
-fx-font-weight: normal;
}
.input:hover {
-fx-border-color: #4caf50;
-fx-border-color: #55a755;
}
.input:focused {
-fx-border-color: #81c784;
-fx-border-color: #88cc88;
-fx-effect: dropshadow(gaussian, #88cc8899, 5, 0, 0, 1);
}
/* ----------------------------
.separator
----------------------------- */
.separator {
/* Layout */
-fx-padding: 10 0;
.my-turn {
-fx-fill: #e05656;
-fx-font-weight: bold;
}
.separator .line {
/* Color */
-fx-border-color: #3a3a3a;
-fx-border-width: 0 0 1 0;
-fx-border-color: #55a755;
-fx-opacity: 1;
}
/* ----------------------------
.slider
----------------------------- */
.slider {
/* Layout */
-fx-padding: 6 0;
/* Color */
-fx-background-color: transparent;
}
.slider .track {
/* Color */
-fx-background-color: linear-gradient(to left, #4caf50, #f44336);
-fx-background-insets: 0;
-fx-background-radius: 2;
-fx-pref-height: 4;
}
.slider .thumb {
/* Color */
-fx-background-color: #f0f0f0;
-fx-background-color: linear-gradient(to bottom, #2e7d2e, #44a044);
-fx-background-radius: 50%;
/* Effects */
-fx-effect: dropshadow(gaussian, #00000066, 4, 0, 0, 1);
-fx-effect: dropshadow(gaussian, #3caf3fdd, 5, 0, 0, 1);
}
.slider .thumb:hover {
-fx-scale-x: 1.2;
-fx-scale-y: 1.2;
-fx-scale-x: 1.15;
-fx-scale-y: 1.15;
}
/* ----------------------------
.text-header
----------------------------- */
.text-header {
-fx-fill: #f0f0f0;
-fx-text-fill: #f0f0f0;
}
/* ----------------------------
.text-normal
----------------------------- */
.text-normal {
-fx-fill: #dddddd;
-fx-text-fill: #dddddd;
}
/* ----------------------------
.toggle-button
----------------------------- */
.toggle {
/* Layout */
-fx-padding: 8 16;
.slider .track {
-fx-background-color: linear-gradient(to left, #57b257, #e05c5c);
-fx-background-insets: 0;
-fx-background-radius: 6;
/* Color */
-fx-background-color: #333333;
-fx-text-fill: #cccccc;
-fx-border-color: #4a4a4a;
}
.toggle:hover {
-fx-background-color: #4caf50;
-fx-text-fill: #ffffff;
-fx-border-color: #4caf50;
.text {
-fx-fill: #a8d0a8;
-fx-font-weight: normal;
-fx-text-fill: #a8d0a8;
}
.header {
-fx-fill: #88cc88;
-fx-font-weight: bold;
-fx-text-fill: #88cc88;
}

View File

@@ -0,0 +1,43 @@
.combo-box .list-cell {
-fx-alignment: CENTER;
-fx-padding: 0;
}
.container,
.credits-container {
-fx-alignment: TOP_CENTER;
-fx-background-color: transparent;
}
.fit,
.fit .viewport {
-fx-background-color: transparent;
-fx-border-color: transparent;
}
.fit .scroll-bar .decrement-arrow,
.fit .scroll-bar .decrement-button,
.fit .scroll-bar .increment-arrow,
.fit .scroll-bar .increment-button {
-fx-padding: 0;
-fx-pref-height: 0;
-fx-pref-width: 0;
-fx-shape: "";
}
.fit .scroll-bar .thumb {
-fx-background-color: #888;
-fx-background-insets: 0;
-fx-background-radius: 1px;
}
.fit .scroll-bar:horizontal,
.fit .scroll-bar:vertical {
-fx-pref-height: 4px;
-fx-pref-width: 4px;
}
.header,
.text {
-fx-font-family: "Arial";
}

View File

@@ -0,0 +1,134 @@
.bg-primary {
-fx-background-color: linear-gradient(to bottom, #121b22, #0a0f14);
}
.bg-secondary {
-fx-background-color: linear-gradient(to bottom, #1a2b35, #0d181f);
}
.bg-popup {
-fx-background-color: rgba(10, 20, 30, 0.95);
-fx-background-radius: 8;
-fx-effect: dropshadow(gaussian, #1f6a22ff, 10, 0, 0, 3);
}
.button {
-fx-background-color: linear-gradient(to bottom, #1b7a1b, #2da32d);
-fx-background-radius: 8;
-fx-border-color: #28a428;
-fx-cursor: hand;
-fx-effect: dropshadow(gaussian, #28a428ff, 8, 0, 0, 3);
-fx-text-fill: #e0ffe0;
-fx-font-weight: bold;
}
.button:hover {
-fx-background-color: linear-gradient(to bottom, #45d045, #60e060);
-fx-border-color: #1c841c;
}
.combo-box {
-fx-background-color: linear-gradient(to bottom, #26473b, #1a2e25);
-fx-background-radius: 6;
-fx-border-color: #28a428;
-fx-cursor: hand;
}
.combo-box:hover {
-fx-border-color: #52c352;
}
.combo-box:focused {
-fx-border-color: #70e070;
-fx-effect: dropshadow(gaussian, #70e070cc, 6, 0, 0, 2);
}
.combo-box .arrow,
.combo-box .arrow-button {
-fx-background-color: transparent;
-fx-border-color: transparent;
}
.combo-box .list-cell {
-fx-background-color: transparent;
-fx-text-fill: #a8f0a8;
}
.combo-box .list-view {
-fx-background-color: #16321f;
-fx-background-radius: 6;
-fx-border-color: #28a428;
}
.combo-box-popup .list-cell {
-fx-text-fill: #a8f0a8;
}
.combo-box-popup .list-cell:hover {
-fx-background-color: #45d045;
}
.combo-box-popup .list-cell:selected {
-fx-background-color: #2da32d;
-fx-text-fill: #f0fff0;
}
.input {
-fx-background-color: linear-gradient(to bottom, #15331a, #0e2b15);
-fx-background-radius: 6;
-fx-border-color: #28a428;
-fx-text-fill: #a8f0a8;
-fx-font-weight: normal;
}
.input:hover {
-fx-border-color: #52c352;
}
.input:focused {
-fx-border-color: #70e070;
-fx-effect: dropshadow(gaussian, #70e070cc, 6, 0, 0, 2);
}
.my-turn {
-fx-fill: #ff4b4b;
-fx-font-weight: bold;
}
.separator .line {
-fx-border-color: #52c352;
-fx-opacity: 1;
}
.slider {
-fx-background-color: transparent;
}
.slider .thumb {
-fx-background-color: linear-gradient(to bottom, #2da32d, #45d045);
-fx-background-radius: 50%;
-fx-effect: dropshadow(gaussian, #28a428ff, 6, 0, 0, 2);
}
.slider .thumb:hover {
-fx-scale-x: 1.15;
-fx-scale-y: 1.15;
}
.slider .track {
-fx-background-color: linear-gradient(to left, #60e060, #ff5555);
-fx-background-insets: 0;
-fx-background-radius: 6;
}
.text {
-fx-fill: #a8f0a8;
-fx-font-weight: normal;
-fx-text-fill: #a8f0a8;
}
.header {
-fx-fill: #70e070;
-fx-font-weight: bold;
-fx-text-fill: #70e070;
}

View File

@@ -1,11 +1,51 @@
.text-header {
-fx-font-family: "Arial";
-fx-font-size: 24px;
.button {
-fx-background-radius: 6;
-fx-cursor: hand;
-fx-padding: 14 28;
}
.combo-box {
-fx-background-radius: 4;
-fx-cursor: hand;
-fx-padding: 12;
}
.combo-box .arrow-button {
-fx-padding: 0;
}
.combo-box-popup .list-cell {
-fx-padding: 8 0 8 0;
}
.container {
-fx-padding: 28;
-fx-spacing: 14;
}
.current-player {
-fx-font-size: 32px;
}
.header {
-fx-font-size: 28px;
-fx-font-weight: bold;
}
.text-normal {
-fx-font-family: "Arial";
-fx-font-size: 20px;
.input {
-fx-background-radius: 4;
-fx-padding: 12;
}
.separator {
-fx-padding: 14 0;
}
.slider {
-fx-padding: 10 0;
}
.text {
-fx-font-size: 22px;
-fx-font-weight: normal;
}

View File

@@ -1,215 +0,0 @@
/* ----------------------------
.background
----------------------------- */
.bg-primary {
-fx-background-color: #ffffff;
}
.bg-secondary {
-fx-background-color: #f2f2f2;
}
.bg-popup {
-fx-background-color: #ffffffcc;
}
/* ----------------------------
.button
----------------------------- */
.button {
/* Layout */
-fx-padding: 10 20;
-fx-background-radius: 6;
-fx-cursor: hand;
/* Color */
-fx-background-color: #f2f2f2;
-fx-text-fill: #000000;
-fx-border-color: #000000;
-fx-border-width: 1;
/* Effects */
-fx-effect: dropshadow(gaussian, #00000033, 4, 0, 0, 1);
}
.button:hover {
-fx-background-color: #e0e0e0;
-fx-border-color: #008000;
}
/* ----------------------------
.choice-box
----------------------------- */
.choice-box {
/* Layout */
-fx-padding: 6;
-fx-background-radius: 4;
/* Color */
-fx-background-color: #ffffff;
-fx-border-color: #000000;
-fx-border-width: 1;
-fx-mark-color: #000000;
}
.choice-box:hover {
-fx-border-color: #008000;
}
.choice-box:focused {
-fx-border-color: #009900;
}
.choice-box .label {
-fx-text-fill: #000000;
}
/* ----------------------------
.choice-box popup styling
----------------------------- */
.choice-box .context-menu {
/* Layout */
-fx-padding: 4;
-fx-background-radius: 4;
/* Color */
-fx-background-color: #ffffff;
-fx-border-color: #000000;
-fx-border-width: 1;
}
.choice-box .menu-item {
/* Layout */
-fx-padding: 6 12;
}
.choice-box .menu-item .label {
-fx-text-fill: #000000;
}
.choice-box .menu-item:hover {
-fx-background-color: #e0e0e0;
}
.choice-box .menu-item:focused {
-fx-background-color: #008000;
-fx-text-fill: #ffffff;
}
/* ----------------------------
.container
----------------------------- */
.container {
/* Layout */
-fx-padding: 10;
-fx-alignment: center;
/* Color */
-fx-background-color: #f9f9f9;
}
/* ----------------------------
.input
----------------------------- */
.input {
/* Layout */
-fx-padding: 8;
-fx-background-radius: 4;
/* Color */
-fx-background-color: #ffffff;
-fx-text-fill: #000000;
-fx-border-color: #000000;
-fx-border-width: 1;
}
.input:hover {
-fx-border-color: #008000;
}
.input:focused {
-fx-border-color: #009900;
}
/* ----------------------------
.separator
----------------------------- */
.separator {
/* Layout */
-fx-padding: 10 0;
}
.separator .line {
/* Color */
-fx-border-color: #000000;
-fx-border-width: 0 0 1 0;
}
/* ----------------------------
.slider
----------------------------- */
.slider {
/* Layout */
-fx-padding: 6 0;
/* Color */
-fx-background-color: transparent;
}
.slider .track {
/* Color */
-fx-background-color: linear-gradient(to left, #00cc00, #cc0000);
-fx-background-insets: 0;
-fx-background-radius: 2;
-fx-pref-height: 4;
}
.slider .thumb {
/* Color */
-fx-background-color: #000000;
-fx-background-radius: 50%;
/* Effects */
-fx-effect: dropshadow(gaussian, #00000066, 4, 0, 0, 1);
}
.slider .thumb:hover {
-fx-scale-x: 1.2;
-fx-scale-y: 1.2;
}
/* ----------------------------
.text-header
----------------------------- */
.text-header {
-fx-fill: #000000;
-fx-text-fill: #000000;
}
/* ----------------------------
.text-normal
----------------------------- */
.text-normal {
-fx-fill: #111111;
-fx-text-fill: #111111;
}
/* ----------------------------
.toggle-button
----------------------------- */
.toggle {
/* Layout */
-fx-padding: 8 16;
-fx-background-radius: 6;
/* Color */
-fx-background-color: #e6e6e6;
-fx-text-fill: #000000;
-fx-border-color: #000000;
}
.toggle:hover {
-fx-background-color: #00cc00;
-fx-text-fill: #ffffff;
-fx-border-color: #00cc00;
}

View File

@@ -1,215 +1,134 @@
/* ----------------------------
.background
----------------------------- */
.bg-primary {
-fx-background-color: #f5f5f5;
-fx-background-color: linear-gradient(to bottom, #e8f1ef, #cfded9);
}
.bg-secondary {
-fx-background-color: #e0e0e0;
-fx-background-color: linear-gradient(to bottom, #c3d6d1, #a9c2bb);
}
.bg-popup {
-fx-background-color: #f5f5f57f;
-fx-background-color: rgba(224, 240, 242, 0.95);
-fx-background-radius: 8;
-fx-effect: dropshadow(gaussian, #a0c4b088, 6, 0, 0, 2);
}
/* ----------------------------
.button
----------------------------- */
.button {
/* Layout */
-fx-padding: 10 20;
-fx-background-radius: 6;
-fx-background-color: linear-gradient(to bottom, #7ac27a, #90d090);
-fx-background-radius: 8;
-fx-border-color: #5caf5c;
-fx-cursor: hand;
/* Color */
-fx-background-color: #e0e0e0;
-fx-text-fill: #1a1a1a;
-fx-border-color: #cccccc;
-fx-border-width: 1;
/* Effects */
-fx-effect: dropshadow(gaussian, #00000026, 4, 0, 0, 1);
-fx-effect: dropshadow(gaussian, #7abf7aaa, 5, 0, 0, 2);
-fx-text-fill: #2e4d2e;
-fx-font-weight: bold;
}
.button:hover {
-fx-background-color: #d5d5d5;
-fx-border-color: #4caf50;
-fx-background-color: linear-gradient(to bottom, #a2d1a1, #b8e3b9);
-fx-border-color: #4a784a;
}
/* ----------------------------
.choice-box
----------------------------- */
.choice-box {
/* Layout */
-fx-padding: 6;
-fx-background-radius: 4;
/* Color */
-fx-background-color: #e0e0e0;
-fx-border-color: #cccccc;
-fx-border-width: 1;
-fx-mark-color: #1a1a1a;
.combo-box {
-fx-background-color: linear-gradient(to bottom, #d9e6e1, #b8ccc5);
-fx-background-radius: 6;
-fx-border-color: #5caf5c;
-fx-cursor: hand;
}
.choice-box:hover {
-fx-border-color: #4caf50;
.combo-box:hover {
-fx-border-color: #81b581;
}
.choice-box:focused {
-fx-border-color: #81c784;
.combo-box:focused {
-fx-border-color: #aad3aa;
-fx-effect: dropshadow(gaussian, #aad3aa99, 4, 0, 0, 1);
}
.choice-box .label {
-fx-text-fill: #1a1a1a;
.combo-box .arrow,
.combo-box .arrow-button {
-fx-background-color: transparent;
-fx-border-color: transparent;
}
/* ----------------------------
.choice-box popup styling
----------------------------- */
.choice-box .context-menu {
/* Layout */
-fx-padding: 4;
-fx-background-radius: 4;
/* Color */
-fx-background-color: #ffffff;
-fx-border-color: #cccccc;
-fx-border-width: 1;
.combo-box .list-cell {
-fx-background-color: transparent;
-fx-text-fill: #2e4d2e;
}
.choice-box .menu-item {
/* Layout */
-fx-padding: 6 12;
.combo-box .list-view {
-fx-background-color: #d3e4d7;
-fx-background-radius: 6;
-fx-border-color: #5caf5c;
}
.choice-box .menu-item .label {
-fx-text-fill: #333333;
.combo-box-popup .list-cell {
-fx-text-fill: #2e4d2e;
}
.choice-box .menu-item:hover {
-fx-background-color: #eeeeee;
.combo-box-popup .list-cell:hover {
-fx-background-color: #90d090;
}
.choice-box .menu-item:focused {
-fx-background-color: #4caf50;
.combo-box-popup .list-cell:selected {
-fx-background-color: #7ac27a;
-fx-text-fill: #ffffff;
}
/* ----------------------------
.container
----------------------------- */
.container {
/* Layout */
-fx-padding: 10;
-fx-alignment: center;
/* Color */
-fx-background-color: #e0e0e0;
}
/* ----------------------------
.input
----------------------------- */
.input {
/* Layout */
-fx-padding: 8;
-fx-background-radius: 4;
/* Color */
-fx-background-color: #ffffff;
-fx-text-fill: #1a1a1a;
-fx-border-color: #cccccc;
-fx-border-width: 1;
-fx-background-color: linear-gradient(to bottom, #e6f0ec, #c8dbcd);
-fx-background-radius: 6;
-fx-border-color: #5caf5c;
-fx-text-fill: #2e4d2e;
-fx-font-weight: normal;
}
.input:hover {
-fx-border-color: #4caf50;
-fx-border-color: #81b581;
}
.input:focused {
-fx-border-color: #81c784;
-fx-border-color: #aad3aa;
-fx-effect: dropshadow(gaussian, #aad3aa99, 4, 0, 0, 1);
}
/* ----------------------------
.separator
----------------------------- */
.separator {
/* Layout */
-fx-padding: 10 0;
.my-turn {
-fx-fill: #d14b4b;
-fx-font-weight: bold;
}
.separator .line {
/* Color */
-fx-border-color: #cccccc;
-fx-border-width: 0 0 1 0;
-fx-border-color: #81b581;
-fx-opacity: 1;
}
/* ----------------------------
.slider
----------------------------- */
.slider {
/* Layout */
-fx-padding: 6 0;
/* Color */
-fx-background-color: transparent;
}
.slider .track {
/* Color */
-fx-background-color: linear-gradient(to left, #4caf50, #f44336);
-fx-background-insets: 0;
-fx-background-radius: 2;
-fx-pref-height: 4;
}
.slider .thumb {
/* Color */
-fx-background-color: #1a1a1a;
-fx-background-color: linear-gradient(to bottom, #7ac27a, #90d090);
-fx-background-radius: 50%;
/* Effects */
-fx-effect: dropshadow(gaussian, #00000033, 4, 0, 0, 1);
-fx-effect: dropshadow(gaussian, #7abf7faa, 5, 0, 0, 1);
}
.slider .thumb:hover {
-fx-scale-x: 1.2;
-fx-scale-y: 1.2;
-fx-scale-x: 1.15;
-fx-scale-y: 1.15;
}
/* ----------------------------
.text-header
----------------------------- */
.text-header {
-fx-fill: #1a1a1a;
-fx-text-fill: #1a1a1a;
}
/* ----------------------------
.text-normal
----------------------------- */
.text-normal {
-fx-fill: #333333;
-fx-text-fill: #333333;
}
/* ----------------------------
.toggle-button
----------------------------- */
.toggle {
/* Layout */
-fx-padding: 8 16;
.slider .track {
-fx-background-color: linear-gradient(to left, #b8e3b9, #d05c5c);
-fx-background-insets: 0;
-fx-background-radius: 6;
/* Color */
-fx-background-color: #d0d0d0;
-fx-text-fill: #1a1a1a;
-fx-border-color: #b0b0b0;
}
.toggle:hover {
-fx-background-color: #4caf50;
-fx-text-fill: #ffffff;
-fx-border-color: #4caf50;
.text {
-fx-fill: #2e4d2e;
-fx-font-weight: normal;
-fx-text-fill: #2e4d2e;
}
.header {
-fx-fill: #2b5c2b;
-fx-font-weight: bold;
-fx-text-fill: #2b5c2b;
}

View File

@@ -1,11 +1,51 @@
.text-header {
-fx-font-family: "Arial";
.button {
-fx-background-radius: 6;
-fx-cursor: hand;
-fx-padding: 10 20;
}
.combo-box {
-fx-background-radius: 4;
-fx-cursor: hand;
-fx-padding: 8;
}
.combo-box .arrow-button {
-fx-padding: 0;
}
.combo-box-popup .list-cell {
-fx-padding: 5 0 5 0;
}
.container {
-fx-padding: 20;
-fx-spacing: 10;
}
.current-player {
-fx-font-size: 24px;
}
.header {
-fx-font-size: 20px;
-fx-font-weight: bold;
}
.text-normal {
-fx-font-family: "Arial";
.input {
-fx-background-radius: 4;
-fx-padding: 8;
}
.separator {
-fx-padding: 10 0;
}
.slider {
-fx-padding: 6 0;
}
.text {
-fx-font-size: 16px;
-fx-font-weight: normal;
}

View File

@@ -1,11 +1,51 @@
.text-header {
-fx-font-family: "Arial";
.button {
-fx-background-radius: 6;
-fx-cursor: hand;
-fx-padding: 6 12;
}
.combo-box {
-fx-background-radius: 4;
-fx-cursor: hand;
-fx-padding: 5;
}
.combo-box .arrow-button {
-fx-padding: 0;
}
.combo-box-popup .list-cell {
-fx-padding: 3 0 3 0;
}
.container {
-fx-padding: 12;
-fx-spacing: 6;
}
.current-player {
-fx-font-size: 16px;
}
.header {
-fx-font-size: 14px;
-fx-font-weight: bold;
}
.text-normal {
-fx-font-family: "Arial";
.input {
-fx-background-radius: 4;
-fx-padding: 5;
}
.separator {
-fx-padding: 6 0;
}
.slider {
-fx-padding: 4 0;
}
.text {
-fx-font-size: 12px;
-fx-font-weight: normal;
}

View File

@@ -7,11 +7,14 @@ public abstract class Game {
NORMAL,
DRAW,
WIN,
MOVE_SKIPPED,
}
public record Move(int position, char value) {}
public static final char EMPTY = (char) 0;
public record Score(int player1Score, int player2Score) {}
public static final char EMPTY = (char)0;
public final int rowSize;
public final int columnSize;

View File

@@ -1,19 +0,0 @@
package org.toop.game.othello;
import org.toop.game.TurnBasedGame;
public final class Othello extends TurnBasedGame {
Othello() {
super(8, 8, 2);
}
@Override
public Move[] getLegalMoves() {
return new Move[0];
}
@Override
public State play(Move move) {
return null;
}
}

View File

@@ -1,11 +0,0 @@
package org.toop.game.othello;
import org.toop.game.AI;
import org.toop.game.Game;
public final class OthelloAI extends AI<Othello> {
@Override
public Game.Move findBestMove(Othello game, int depth) {
return null;
}
}

View File

@@ -0,0 +1,196 @@
package org.toop.game.reversi;
import org.toop.game.Game;
import org.toop.game.TurnBasedGame;
import org.toop.game.tictactoe.TicTacToe;
import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public final class Reversi extends TurnBasedGame {
private int movesTaken;
public static final char FIRST_MOVE = 'B';
private Set<Point> filledCells = new HashSet<>();
public Reversi() {
super(8, 8, 2);
addStartPieces();
}
public Reversi(Reversi other) {
super(other);
this.movesTaken = other.movesTaken;
this.filledCells = other.filledCells;
}
private void addStartPieces() {
board[27] = 'W';
board[28] = 'B';
board[35] = 'B';
board[36] = 'W';
updateFilledCellsSet();
}
private void updateFilledCellsSet() {
for (int i = 0; i < 64; i++) {
if (board[i] == 'W' || board[i] == 'B') {
filledCells.add(new Point(i % columnSize, i / rowSize));
}
}
}
@Override
public Move[] getLegalMoves() {
final ArrayList<Move> legalMoves = new ArrayList<>();
char[][] boardGrid = makeBoardAGrid();
char currentPlayer = (currentTurn==0) ? 'B' : 'W';
Set<Point> adjCell = getAdjacentCells(boardGrid);
for (Point point : adjCell){
Move[] moves = getFlipsForPotentialMove(point,boardGrid,currentPlayer);
int score = moves.length;
if (score > 0){
legalMoves.add(new Move(point.x + point.y * rowSize, currentPlayer));
}
}
return legalMoves.toArray(new Move[0]);
}
private Set<Point> getAdjacentCells(char[][] boardGrid) {
Set<Point> possibleCells = new HashSet<>();
for (Point point : filledCells) { //for every filled cell
for (int deltaColumn = -1; deltaColumn <= 1; deltaColumn++){ //check adjacent cells
for (int deltaRow = -1; deltaRow <= 1; deltaRow++){ //orthogonally and diagonally
int newX = point.x + deltaColumn, newY = point.y + deltaRow;
if (deltaColumn == 0 && deltaRow == 0 //continue if out of bounds
|| !isOnBoard(newX, newY)) {
continue;
}
if (boardGrid[newY][newX] == Game.EMPTY) { //check if the cell is empty
possibleCells.add(new Point(newX, newY)); //and then add it to the set of possible moves
}
}
}
}
return possibleCells;
}
public Move[] getFlipsForPotentialMove(Point point, char[][] boardGrid, char currentPlayer) {
final ArrayList<Move> movesToFlip = new ArrayList<>();
for (int deltaColumn = -1; deltaColumn <= 1; deltaColumn++) {
for (int deltaRow = -1; deltaRow <= 1; deltaRow++) {
if (deltaColumn == 0 && deltaRow == 0){
continue;
}
Move[] moves = getFlipsInDirection(point,boardGrid,currentPlayer,deltaColumn,deltaRow);
if (moves != null) {
movesToFlip.addAll(Arrays.asList(moves));
}
}
}
return movesToFlip.toArray(new Move[0]);
}
private Move[] getFlipsInDirection(Point point, char[][] boardGrid, char currentPlayer, int dirX, int dirY) {
char opponent = getOpponent(currentPlayer);
final ArrayList<Move> movesToFlip = new ArrayList<>();
int x = point.x + dirX;
int y = point.y + dirY;
if (!isOnBoard(x, y) || boardGrid[y][x] != opponent) {
return null;
}
while (isOnBoard(x, y) && boardGrid[y][x] == opponent) {
movesToFlip.add(new Move(x+y*rowSize, currentPlayer));
x += dirX;
y += dirY;
}
if (isOnBoard(x, y) && boardGrid[y][x] == currentPlayer) {
return movesToFlip.toArray(new Move[0]);
}
return null;
}
private boolean isOnBoard(int x, int y) {
return x >= 0 && x < columnSize && y >= 0 && y < rowSize;
}
public char[][] makeBoardAGrid() {
char[][] boardGrid = new char[rowSize][columnSize];
for (int i = 0; i < 64; i++) {
boardGrid[i / rowSize][i % columnSize] = board[i]; //boardGrid[y / row] [x / column]
}
return boardGrid;
}
@Override
public State play(Move move) {
Move[] legalMoves = getLegalMoves();
boolean moveIsLegal = false;
for (Move legalMove : legalMoves) {
if (move.equals(legalMove)) {
moveIsLegal = true;
break;
}
}
if (moveIsLegal) {
Move[] moves = getFlipsForPotentialMove(new Point(move.position()%columnSize,move.position()/rowSize), makeBoardAGrid(), move.value());
board[move.position()] = move.value();
IO.println(move.position() +" "+ move.value());
for (Move m : moves) {
board[m.position()] = m.value();
}
filledCells.add(new Point(move.position() % rowSize, move.position() / columnSize));
//updateFilledCellsSet();
nextTurn();
if (getLegalMoves().length == 0) {
skipMyTurn();
return State.MOVE_SKIPPED;
}
return State.NORMAL;
}
return null;
}
public void skipMyTurn(){
IO.println("TURN " + getCurrentPlayer() + " SKIPPED");
nextTurn();
}
public char getCurrentPlayer() {
if (currentTurn == 0){
return 'B';
}
else {
return 'W';
}
}
private char getOpponent(char currentPlayer){
if (currentPlayer == 'B') {
return 'W';
}
else {
return 'B';
}
}
public Game.Score getScore(){
int player1Score = 0, player2Score = 0;
for (int count = 0; count < rowSize * columnSize; count++) {
if (board[count] == 'W') {
player1Score += 1;
}
if (board[count] == 'B') {
player2Score += 1;
}
}
return new Game.Score(player1Score, player2Score);
}
}

View File

@@ -0,0 +1,11 @@
package org.toop.game.reversi;
import org.toop.game.AI;
import org.toop.game.Game;
public final class ReversiAI extends AI<Reversi> {
@Override
public Game.Move findBestMove(Reversi game, int depth) {
return game.getLegalMoves()[0];
}
}

View File

@@ -0,0 +1,165 @@
package org.toop.game.tictactoe;
import org.toop.game.Game;
import java.util.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.toop.game.reversi.Reversi;
import org.toop.game.reversi.ReversiAI;
import static org.junit.jupiter.api.Assertions.*;
class ReversiTest {
private Reversi game;
private ReversiAI ai;
@BeforeEach
void setup() {
game = new Reversi();
ai = new ReversiAI();
}
@Test
void testCorrectStartPiecesPlaced() {
assertNotNull(game);
assertEquals('W',game.board[27]);
assertEquals('B',game.board[28]);
assertEquals('B',game.board[35]);
assertEquals('W',game.board[36]);
}
@Test
void testGetLegalMovesAtStart() {
Game.Move[] moves = game.getLegalMoves();
List<Game.Move> expectedMoves = List.of(
new Game.Move(19,'B'),
new Game.Move(26,'B'),
new Game.Move(37,'B'),
new Game.Move(44,'B')
);
assertNotNull(moves);
assertTrue(moves.length > 0);
assertMovesMatchIgnoreOrder(expectedMoves, Arrays.asList(moves));
}
private void assertMovesMatchIgnoreOrder(List<Game.Move> expected, List<Game.Move> actual) {
assertEquals(expected.size(), actual.size());
for (int i = 0; i < expected.size(); i++) {
assertTrue(actual.contains(expected.get(i)));
assertTrue(expected.contains(actual.get(i)));
}
}
@Test
void testMakeValidMoveFlipsPieces() {
game.play(new Game.Move(19, 'B'));
assertEquals('B', game.board[19]);
assertEquals('B', game.board[27], "Piece should have flipped to B");
}
@Test
void testMakeInvalidMoveDoesNothing() {
char[] before = game.board.clone();
game.play(new Game.Move(0, 'B'));
assertArrayEquals(before, game.board, "Board should not change on invalid move");
}
@Test
void testTurnSwitchesAfterValidMove() {
char current = game.getCurrentPlayer();
game.play(game.getLegalMoves()[0]);
assertNotEquals(current, game.getCurrentPlayer(), "Player turn should switch after a valid move");
}
@Test
void testCountScoreCorrectlyAtStart() {
long start = System.nanoTime();
Game.Score score = game.getScore();
assertEquals(2, score.player1Score()); // Black
assertEquals(2, score.player2Score()); // White
long end = System.nanoTime();
IO.println((end-start));
}
@Test
void zLegalMovesInCertainPosition() {
game.play(new Game.Move(19, 'B'));
game.play(new Game.Move(20, 'W'));
Game.Move[] moves = game.getLegalMoves();
List<Game.Move> expectedMoves = List.of(
new Game.Move(13,'B'),
new Game.Move(21, 'B'),
new Game.Move(29, 'B'),
new Game.Move(37, 'B'),
new Game.Move(45, 'B'));
assertNotNull(moves);
assertTrue(moves.length > 0);
IO.println(Arrays.toString(moves));
assertMovesMatchIgnoreOrder(expectedMoves, Arrays.asList(moves));
}
@Test
void testCountScoreCorrectlyAtEnd() {
for (int i = 0; i < 1; i++){
game = new Reversi();
Game.Move[] legalMoves = game.getLegalMoves();
while(legalMoves.length > 0) {
game.play(legalMoves[(int)(Math.random()*legalMoves.length)]);
legalMoves = game.getLegalMoves();
}
Game.Score score = game.getScore();
IO.println(score.player1Score());
IO.println(score.player2Score());
char[][] grid = game.makeBoardAGrid();
for (char[] chars : grid) {
IO.println(Arrays.toString(chars));
}
}
}
@Test
void testPlayerMustSkipTurnIfNoValidMoves() {
game.play(new Game.Move(19, 'B'));
game.play(new Game.Move(34, 'W'));
game.play(new Game.Move(45, 'B'));
game.play(new Game.Move(11, 'W'));
game.play(new Game.Move(42, 'B'));
game.play(new Game.Move(54, 'W'));
game.play(new Game.Move(37, 'B'));
game.play(new Game.Move(46, 'W'));
game.play(new Game.Move(63, 'B'));
game.play(new Game.Move(62, 'W'));
game.play(new Game.Move(29, 'B'));
game.play(new Game.Move(50, 'W'));
game.play(new Game.Move(55, 'B'));
game.play(new Game.Move(30, 'W'));
game.play(new Game.Move(53, 'B'));
game.play(new Game.Move(38, 'W'));
game.play(new Game.Move(61, 'B'));
game.play(new Game.Move(52, 'W'));
game.play(new Game.Move(51, 'B'));
game.play(new Game.Move(60, 'W'));
game.play(new Game.Move(59, 'B'));
assertEquals('B', game.getCurrentPlayer());
game.play(ai.findBestMove(game,5));
game.play(ai.findBestMove(game,5));
}
@Test
void testAISelectsLegalMove() {
Game.Move move = ai.findBestMove(game,4);
assertNotNull(move);
assertTrue(containsMove(game.getLegalMoves(),move), "AI should always choose a legal move");
}
private boolean containsMove(Game.Move[] moves, Game.Move move) {
for (Game.Move m : moves) {
if (m.equals(move)) return true;
}
return false;
}
}