Demo 5
* fast server connection
* Fixed bugs and oversights
* Renamed asset folder to resource, made resourceLoader more robust. Completed some TODO's, formatting
* AppSettings now also get loaded into the assetmanager
* start to reversi logic
* legal moves now get highlighted in red
* Moves flip dots. all tests pass. can play reversi local.
* Working state. Split AudioManager into 3 different branches for easier testing and srp
* Reworked to now use better defined generics and easier to use API. Added AudioResource to be used in changing volume
* Made all of the updated classes more generic for better flexibility in unittesting
* Added more flexible dependency injection to MusicManager for unittesting. Moved to event driven design for less complex code and lower runtime complexity.
* Split SoundEffectManager from AudioManager. (#171)
Clips no longer create a new clip instance each time they are played. A singular clip is made for each resource and is opened/closed when loaded/unloaded. When a clip is played that is already playing it'll stop playback and start again. Clip volume handling isn't done very well.
* Unit tests for MusicManager.java
* Hotfix for loading clip volume issue (#174)
* Fixed AudioVolumemanager, all volumes calculations are now made in VolumeTypes enum
* Added ability to remove a manager from VolumeTypes
* Removed file no longer in use
* Fixed grammer and spelling mistakes
* Renamed VOLUME to MASTERVOLUME for better naming
* Minor changes in API design
* Renamed VolumeTypes to VolumeControl. Made it thread safe. Added docs to VolumeControl and co.
removed .updateAllVolumes() in favor of auto updating inside enum instead
* Added ErrorProne for potential bugs. Fixed potential bugs.
* Small fixes.
* Removed no more needed code.
* Finished todo's
* Moved restrictedAPI to future release
* Finished todo's
* Moved restrictedAPI to future release
* Changed pom to be correct.
Fixed SnowflakeGenerator not making unique ids.
Changed naming for event implementation.
Automated id getter for events.
Added Error-Prone to all modules.
Added parents to all modules.
Added processors module.
* SoundEffectManager now generic
* Removed ResourceManager from AudioManagers
* Added linelistener to SoundEffectAsset
* commit
* commit ofzo
* Tests for SoundEffectManager
* getLegalMoves logic seems fixed //todo write better tests
* Tests toegevoegd
* punk toegevoegd
* Added shuffling on user request
* Reworked NetworkingClientManager into SRP model.
* Forgot to remove
* Improved API for dependency injection
* Some better docs.
* gui refactor
* fixed merge conflicts
* Added exceptions. Added reconnect attempts and changeable address
* Fixed event bug
* add: reversi game
* add: server chat box
* visual update
* Refactor to make Events easier to work with.
* Quick fix for closing connection.
* Documentation
* Correct client creation and user polling
* begin van audio display
* Polling music event, fires every 1 second
* Updated test.
* Updated timings
* Nuke everything on close.
* Basis Audio Display toegevoegd + standaard CSS toegevoegd
Kan nu zien hoe lang de song duurt, hoe lang ie al bezig is met draaien en de titel (-.mp3)
* Clips now also return positional information
* Skip Button
* Skip Button
* Fixes for garbage code by Omar
* Tiny fix when natural skip
* Small event fix
* Faster event schedule for PlayingMusic event
* test fix
* added method for sorting the flipped pieces by distance to Move.position
* new reversi test (both players no legal moves)
* connect4 with minimax AI
* Toegevoegd:
-Play Button + CSS + Events
-Previous Button + CSS + Events
-Changed interface for AudioResource to include a pause button which works really well with mediaplayer, however now SoundEffectAsset has an unnessescary pause
* Made it so that it indicates with the play/pause button if its paused or played
* add simple flip animations and fixed(?) server somewhat
* fixed tests
* can start game from playerlist screen
* tourney ready
* spam minder
* fixed setgamelabels
* spam minder v2
* canvas changes
* moved score out of game
* can now go to last using previous and being at the first song
* mainview false for sendchallengeview
* moved score out of game
* kleine ui fix
* updated music ma,es
* started working on the widget system
* iets met timing verkeerd temporary fix
* Fixes for garbage code by Omar
* Added replace to reduce boiler plate code
* Manually fallback to the fallback locale when a ResourceBundle is missing a resource key. Fallsback to "MISSING RESOUREC" if it's not present in the fallback.
* Removed unused import and unused parameter
* cool onhover effect for reversi
* Made the GameState enum it's own file and fixed imports
* Removed unused import
* Turned abstract methods into an interface
* Moved the Move record into it's own file, seperated from Game
* Removed unused imports
* Renamed Interface Playtable to IPlayable
* Turned Abstract Method for AI into interface
* Refactored Game to follow encapsulation principle
* Removed unused imports
* Applied encapsulation principle to TurnBasedBame.java
* Privated methods that didn't have to be public
* Reversi: made method private
* Changed checkForEarlyDraw so it doesn't need a game as input.
* Fixed warning "Warning:(27, 12) Copy constructor does not copy field 'mostRecentlyFlippedPieces'", removed unused field
* Made connect4 public method private
* half done with the widget system
* added some comments and made some methods a bit more readable
* widget system almost complete
* Functional code, is now object orientated
* Removed no more needed comments
* started a basis for the tutorials, tic tac toe is almost done with some general stuff still to do.
* rest van de tutorials toegevoegd
* resizable true
* fixed turn skip bug
fixed end score bug
now only shows legal and highlight moves when human
* Squashed commit of the following:
commit a517f2f302baa89f8ef59946a31c7bb59c56770f
Author: Stef <stbuwalda@gmail.com>
Date: Thu Nov 27 15:43:43 2025 +0100
Make it so the game shows "Waiting on ... to make their move". Styling isn't done but it is easier to see who's turn it is. There is a lot of structuring to do in the previous code...
* Fixed compilation errors
* Changed the way turns are being stored in TurnBasedGame.
* Removed views
* Added function input for enabling/disabling localization p/text
* Fix eventbus problems (#265)
* Added unsubscribe to EventFlow. ListenerHandler now functional. GlobalEventbus now user listenerHandler
* getAllListeners
* Removed nulls
* Fixed stress tests
* Added docs, no more list creation when adding events to the bus.
* Fixed unsubscribe not working.
* Moved away from deprecated functions
* moved from wildcard to typed
* Moved away from deprecated function
* Debugs for EventBus and fixed unsubscribe all (#266)
* Added unsubscribe to EventFlow. ListenerHandler now functional. GlobalEventbus now user listenerHandler
* getAllListeners
* Removed nulls
* Fixed stress tests
* Added docs, no more list creation when adding events to the bus.
* Fixed unsubscribe not working.
* Moved away from deprecated functions
* moved from wildcard to typed
* Moved away from deprecated function
* Added debugging to GlobalEventBus
* Fixed cleaning flow
* Fixed unsubscribe all
* Fixed unsubscribe all
* Removed unused import
* Fix music display not working (#267)
* Added unsubscribe to EventFlow. ListenerHandler now functional. GlobalEventbus now user listenerHandler
* getAllListeners
* Removed nulls
* Fixed stress tests
* Added docs, no more list creation when adding events to the bus.
* Fixed unsubscribe not working.
* Moved away from deprecated functions
* moved from wildcard to typed
* Moved away from deprecated function
* Added debugging to GlobalEventBus
* Fixed cleaning flow
* Fixed unsubscribe all
* Fixed unsubscribe all
* Removed unused import
* Added LoadingWidget.java for server feedback
* Replace deprecated with correct function
* Removed loading widget from Server.java
* Fixed old new EventFlow().listen() missing false as third param
* Tutorials to Dev (#264)
* Fixed garbage code
* added a pop button
* Tutorial images now use ImageAsset.java
* Added button to continue and start game. Refactors
* Refactored nextScreen runnable
* Removed unused imports
* Refactored switch statement
* Added documentation
* Removed space
* Added translations
* Added function input for enabling/disabling localization p/text
---------
Co-authored-by: ramollia <>
* Merge new framework into development (#269)
* Created a somewhat generic TurnBasedGame thread. Temporary UI that only works for TicTacToe rn. Added a LocalPlayer with the intent to add more players
* (RANDOM COMMIT) Hope it works
* Changes by bas
* Fixed dependency issues
* Fixed major issue in game deepcopy
* Merge conflict fix
* Removed unused import
* Update GTBGT branch from dev branch (#263)
* started a basis for the tutorials, tic tac toe is almost done with some general stuff still to do.
* rest van de tutorials toegevoegd
* Removed views
* Merge conflict fix
* Removed unused import
---------
Co-authored-by: michiel301b <m.brands.3@st.hanze.nl>
Co-authored-by: ramollia <>
Co-authored-by: Bas Antonius de Jong <49651652+BAFGdeJong@users.noreply.github.com>
* Revert "Update GTBGT branch from dev branch (#263)"
This reverts commit 9134d7e343.
* Fixed frontend not using GameController because of spaghetti code.
* Removed unused imports
* GameCanvas not implements a DrawPlayerMove that can be overridden for specific implementations
* Created an event that will request the controller to refresh the UI.
* ADDED DEPENDENCY. Renamed GameControllers to GameManagers, gameThread is not game controller.
* Attempt at adding an online player. I think it doesn't work because of unsubscriben after success not working
* Multiplayer is functional through OnlineThreadBehaviour. Empty slots are currently represented by -1 in the GUI.
* Removed sout spam, added logger than I can't get to work.
* Idek what these changes are
* Te lang geen commit, sorry
* Multiplayer seems to work pretty well now, hopefully I can add the other games soon.
* Added unsubscribe to EventFlow. ListenerHandler now functional. GlobalEventbus now user listenerHandler
* getAllListeners
* Removed nulls
* Inbetween commit of adding Reversi. This is a lot of spaghetti.
* Fixed stress tests
* Fixed typo in NetworkingGameClientHandler that prevented losses from being received
* Missed 2nd typo. Fixed
* Added docs, no more list creation when adding events to the bus.
* Fixed unsubscribe not working.
* Moved away from deprecated functions
* moved from wildcard to typed
* Moved away from deprecated function
* Added debugging to GlobalEventBus
* Fixed cleaning flow
* Fixed unsubscribe all
* Fixed unsubscribe all
* Removed unused import
* Works now with updated EventFlow(). Unsubscribing works. ReversiAIR has an issue where a forced move returns -1 and local play back button doesn't work properly. To be fixed
* Fixed ReversiR issue that caused skip turn desync
* Fixed color mismatch with server and online main player is now correct.
* Added a bunch of java doc and small changes
* Small changes
* Added a new Thread Behaviour to test framework.
* Fixed human error I made in TicTacToeR logic...
* Fixed broken event and wrong player being presented as winner.
* Idk changes
* Fixed PR conflicts
---------
Co-authored-by: michiel301b <m.brands.3@st.hanze.nl>
Co-authored-by: Bas Antonius de Jong <49651652+BAFGdeJong@users.noreply.github.com>
* added back button sounds because SOMEONE fucked it up.....
* 231 connecting to server feedback (#275)
* Added unsubscribe to EventFlow. ListenerHandler now functional. GlobalEventbus now user listenerHandler
* getAllListeners
* Removed nulls
* Fixed stress tests
* Added docs, no more list creation when adding events to the bus.
* Fixed unsubscribe not working.
* Moved away from deprecated functions
* moved from wildcard to typed
* Moved away from deprecated function
* Added debugging to GlobalEventBus
* Fixed cleaning flow
* Fixed unsubscribe all
* Fixed unsubscribe all
* Removed unused import
* Added LoadingWidget.java for server feedback
* Imports
* fixed loadingwidget
* Workable LoadingWidget and trying to connect to server
* Removed output
* Small bug temp fix
---------
Co-authored-by: ramollia <>
* Double loading call fix, LoadingWidget docs
* Main menu loader (#277)
* LoadingWidget main menu
* fixed garbage code
* Fixed garbage code 2
* LoadWidget fix, added loading to starting the game. Removed unnecessary console output
---------
Co-authored-by: ramollia <>
* Fixed systems starting, before assets being loaded (I am retarded)
* Added infinite boolean, fixed loading behaviour at startup
* 272 remake game framework interfaces to properly represent vmc (#278)
* Cleaned up a lot of old files and renamed/remade interfaces to better suit the framework
* Broken commit
* Fixed online play
* Better file structure and closer to MVC
* Best fix for white screen at start
* Making threads verbose regarding exceptions
* Loading circle, better loading colors.
* Event bus now testable, improved UI (#284)
* turn updates
* smalle fixes aan turn updates
* better human/ai selector with bot selection and depth on TicTacToeAIR
* depth + thinktime back to AIs, along with a a specific TicTacToeAIRSleep
* fixed overlapping back and disconnect buttons
* Changed to debug instead of info
* changed the transitionNextCustom to be easier to use
* added getAllWidgets to WidgetContainer
* Correct back view
* added replacePrevious in ViewWidget
* added removeIndexFromPreviousChain
* fixed incorrect index counting
* Fixt wrong view order
* Removed todo
* Challenge popups "Fixed"
* Popups now remove themselves
* localize the ChallengePopup text
* made the game text a header instead
* fixed getAllWidgets
* Escape popup
* fixed redundant container
* Escape remove popup
* Working escape menu
* Added find functionality
* Tutorials moved to escape menu
* Escape can't be opened in mainview now
* Can now test the event bus, created testable interfaces
* Logging errors
* Made events and handlers more generic
* Suppress
* Managers now have changeable eventbus
* Tutorials fixed
* Removed import
* Single threaded eventbus
* Fixed wrong eventbus
* Removed get
* Removed old code
* Renaming
* Optimization
* Removed useless comment
* Removed unnecessary imports
* Rename
* Renaming, refactor and type safety
* Rename
* Removed import
---------
Co-authored-by: michiel301b <m.brands.3@st.hanze.nl>
Co-authored-by: ramollia <>
* initSystems now uses latch instead of timer. Moved single threads to Executor
* Safety
* Deleted unnecessary imports
* Code cleanup
* changed "fullscreen exit key combination" from esc to F11
* shitty fix for player selector spacing issue
* shitty fix for player selector spacing issue v2
* fixed reversi colors being switched, causing multiple issues
* Merge bitboards into development (#285)
* added new classes for the games that use bitboards instead. also combined game with turnbasedgame
* (DOES NOT COMPILE) In-between commit
* turn updates
* smalle fixes aan turn updates
* Bitboard implemented with scuffed TicTacToe translation done by game. This should be done by the view.
* Almost done with implementing bitboards. Reversi is broken and artifical players don't work yet.
* better human/ai selector with bot selection and depth on TicTacToeAIR
* fixed getLegalMoves
* depth + thinktime back to AIs, along with a a specific TicTacToeAIRSleep
* fixed overlapping back and disconnect buttons
* Changed to debug instead of info
* changed the transitionNextCustom to be easier to use
* added getAllWidgets to WidgetContainer
* Correct back view
* added replacePrevious in ViewWidget
* added removeIndexFromPreviousChain
* fixed incorrect index counting
* Fixt wrong view order
* fixed? getLegalMoves
* Everything is broken
* Removed todo
* fixed getLegalMoves & getFlips
* Challenge popups "Fixed"
* Fixed local and online play for both games
* Popups now remove themselves
* Removed souts for debugging
* localize the ChallengePopup text
* made the game text a header instead
* made more classes deepClonable.
* fixed getAllWidgets
* Added comment
* Escape popup
* fixed redundant container
* Made all network events async again
* Escape remove popup
* Working escape menu
* Removed old AI and old files. Added a new generic random AI. game no longer deals with translation.
* Drawing of board on canvas is now done from bitboards rather than translating.
* Added a method getWinner() to game interface.Controller now tells gameThreads how to deal with drawing UI and sending a move to server.
* Added find functionality
* Added a ChatGPT generated MiniMaxAI based on the old MiniMaxAI but with alpha-beta pruning and heuristics for Reversi
* Removed System-Outs to clean up console
* Update BitGameCanvas.java
* Merge fixes
* Removed unused imports
---------
Co-authored-by: ramollia <>
Co-authored-by: michiel301b <m.brands.3@st.hanze.nl>
Co-authored-by: lieght <49651652+BAFGdeJong@users.noreply.github.com>
* Better limits to generic acceptance
* Will fix tests etc later
---------
Co-authored-by: ramollia <@>
Co-authored-by: Ticho Hidding <tichohidding@gmail.com>
Co-authored-by: Stef <48526421+StefBuwalda@users.noreply.github.com>
Co-authored-by: Stef <stbuwalda@gmail.com>
Co-authored-by: michiel <m.brands.3@st.hanze.nl>
Co-authored-by: ramollia <>
Co-authored-by: tichohidding <58555714+tichohidding@users.noreply.github.com>
@@ -1,21 +1,9 @@
|
||||
package org.toop;
|
||||
|
||||
import org.toop.app.App;
|
||||
import org.toop.framework.asset.ResourceLoader;
|
||||
import org.toop.framework.asset.ResourceManager;
|
||||
import org.toop.framework.audio.SoundManager;
|
||||
import org.toop.framework.networking.NetworkingClientManager;
|
||||
import org.toop.framework.networking.NetworkingInitializationException;
|
||||
|
||||
public final class Main {
|
||||
public static void main(String[] args) {
|
||||
initSystems();
|
||||
static void main(String[] args) {
|
||||
App.run(args);
|
||||
}
|
||||
|
||||
private static void initSystems() throws NetworkingInitializationException {
|
||||
ResourceManager.loadAssets(new ResourceLoader("app/src/main/resources/assets"));
|
||||
new Thread(NetworkingClientManager::new).start();
|
||||
new Thread(SoundManager::new).start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,167 +1,279 @@
|
||||
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.asset.ResourceManager;
|
||||
import org.toop.framework.asset.resources.CssAsset;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyCodeCombination;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.WidgetContainer;
|
||||
import org.toop.app.widget.complex.LoadingWidget;
|
||||
import org.toop.app.widget.display.SongDisplay;
|
||||
import org.toop.app.widget.popup.EscapePopup;
|
||||
import org.toop.app.widget.popup.QuitPopup;
|
||||
import org.toop.app.widget.view.MainView;
|
||||
import org.toop.framework.audio.*;
|
||||
import org.toop.framework.audio.events.AudioEvents;
|
||||
import org.toop.framework.eventbus.EventFlow;
|
||||
import org.toop.framework.eventbus.GlobalEventBus;
|
||||
import org.toop.framework.networking.NetworkingClientEventListener;
|
||||
import org.toop.framework.networking.NetworkingClientManager;
|
||||
import org.toop.framework.resource.ResourceLoader;
|
||||
import org.toop.framework.resource.ResourceManager;
|
||||
import org.toop.framework.resource.events.AssetLoaderEvents;
|
||||
import org.toop.framework.resource.resources.CssAsset;
|
||||
import org.toop.framework.resource.resources.MusicAsset;
|
||||
import org.toop.framework.resource.resources.SoundEffectAsset;
|
||||
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.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
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;
|
||||
public static void run(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
public static void run(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
@Override
|
||||
public void start(Stage stage) {
|
||||
// Start loading localization
|
||||
ResourceManager.loadAssets(new ResourceLoader("app/src/main/resources/localization"));
|
||||
ResourceManager.loadAssets(new ResourceLoader("app/src/main/resources/style"));
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws Exception {
|
||||
final StackPane root = new StackPane();
|
||||
final Scene scene = new Scene(root);
|
||||
final StackPane root = WidgetContainer.setup();
|
||||
final Scene scene = new Scene(root);
|
||||
|
||||
stage.setTitle(AppContext.getString("appTitle"));
|
||||
stage.setWidth(1080);
|
||||
stage.setHeight(720);
|
||||
stage.setOpacity(0.0);
|
||||
|
||||
stage.setOnCloseRequest(
|
||||
event -> {
|
||||
event.consume();
|
||||
stage.setTitle(AppContext.getString("app-title"));
|
||||
stage.titleProperty().bind(AppContext.bindToKey("app-title"));
|
||||
|
||||
if (!isQuitting) {
|
||||
quitPopup();
|
||||
}
|
||||
});
|
||||
stage.setWidth(0);
|
||||
stage.setHeight(0);
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.setResizable(false);
|
||||
scene.getRoot();
|
||||
|
||||
stage.show();
|
||||
stage.setMinWidth(1200);
|
||||
stage.setMinHeight(800);
|
||||
stage.setOnCloseRequest(event -> {
|
||||
event.consume();
|
||||
quit();
|
||||
});
|
||||
|
||||
App.stage = stage;
|
||||
App.scene = scene;
|
||||
App.root = root;
|
||||
stage.setScene(scene);
|
||||
stage.setResizable(true);
|
||||
|
||||
App.stack = new Stack<>();
|
||||
App.stage = stage;
|
||||
App.scene = scene;
|
||||
|
||||
App.width = (int) stage.getWidth();
|
||||
App.height = (int) stage.getHeight();
|
||||
App.width = (int)stage.getWidth();
|
||||
App.height = (int)stage.getHeight();
|
||||
|
||||
App.isQuitting = false;
|
||||
AppSettings.applySettings();
|
||||
|
||||
final AppSettings settings = new AppSettings();
|
||||
settings.applySettings();
|
||||
setKeybinds(root);
|
||||
|
||||
new EventFlow().addPostEvent(new AudioEvents.StartBackgroundMusic()).asyncPostEvent();
|
||||
activate(new MainLayer());
|
||||
}
|
||||
LoadingWidget loading = new LoadingWidget(Primitive.text(
|
||||
"Loading...", false), 0, 0, Integer.MAX_VALUE, false, false // Just set a high default
|
||||
);
|
||||
|
||||
public static void activate(Layer layer) {
|
||||
Platform.runLater(
|
||||
() -> {
|
||||
popAll();
|
||||
push(layer);
|
||||
});
|
||||
}
|
||||
WidgetContainer.setCurrentView(loading);
|
||||
|
||||
public static void push(Layer layer) {
|
||||
Platform.runLater(
|
||||
() -> {
|
||||
root.getChildren().addLast(layer.getLayer());
|
||||
stack.push(layer);
|
||||
});
|
||||
}
|
||||
setOnLoadingSuccess(loading);
|
||||
|
||||
public static void pop() {
|
||||
Platform.runLater(
|
||||
() -> {
|
||||
root.getChildren().removeLast();
|
||||
stack.pop();
|
||||
EventFlow loadingFlow = new EventFlow();
|
||||
|
||||
isQuitting = false;
|
||||
});
|
||||
}
|
||||
final boolean[] hasRun = {false};
|
||||
loadingFlow
|
||||
.listen(AssetLoaderEvents.LoadingProgressUpdate.class, e -> {
|
||||
if (!hasRun[0]) {
|
||||
hasRun[0] = true;
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
Platform.runLater(() -> stage.setOpacity(1.0));
|
||||
}
|
||||
|
||||
public static void popAll() {
|
||||
Platform.runLater(
|
||||
() -> {
|
||||
final int childrenCount = root.getChildren().size();
|
||||
|
||||
for (int i = 0; i < childrenCount; i++) {
|
||||
try {
|
||||
root.getChildren().removeLast();
|
||||
} catch (Exception e) {
|
||||
IO.println(e);
|
||||
Platform.runLater(() -> {
|
||||
loading.setMaxAmount(e.isLoadingAmount());
|
||||
try {
|
||||
loading.setAmount(e.hasLoadedAmount());
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
if (e.hasLoadedAmount() >= e.isLoadingAmount()-1) {
|
||||
Platform.runLater(loading::triggerSuccess);
|
||||
loadingFlow.unsubscribe("init_loading");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
stack.removeAllElements();
|
||||
});
|
||||
|
||||
}, false, "init_loading");
|
||||
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
try {
|
||||
executor.submit(
|
||||
() -> ResourceManager.loadAssets(new ResourceLoader("app/src/main/resources/assets")
|
||||
));
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
|
||||
stage.show();
|
||||
|
||||
}
|
||||
|
||||
private void setKeybinds(StackPane root) {
|
||||
root.addEventHandler(KeyEvent.KEY_PRESSED,event -> {
|
||||
if (event.getCode() == KeyCode.ESCAPE) {
|
||||
escapePopup();
|
||||
}
|
||||
});
|
||||
stage.setFullScreenExitKeyCombination(
|
||||
new KeyCodeCombination(
|
||||
KeyCode.F11
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public void escapePopup() {
|
||||
|
||||
if ( WidgetContainer.getCurrentView() == null
|
||||
|| WidgetContainer.getCurrentView() instanceof MainView) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Objects.requireNonNull(
|
||||
WidgetContainer.find(widget -> widget instanceof QuitPopup || widget instanceof EscapePopup)
|
||||
).isEmpty()) {
|
||||
WidgetContainer.removeFirst(QuitPopup.class);
|
||||
WidgetContainer.removeFirst(EscapePopup.class);
|
||||
return;
|
||||
}
|
||||
|
||||
EscapePopup escPopup = new EscapePopup();
|
||||
escPopup.show(Pos.CENTER);
|
||||
}
|
||||
|
||||
private void setOnLoadingSuccess(LoadingWidget loading) {
|
||||
loading.setOnSuccess(() -> {
|
||||
|
||||
try {
|
||||
initSystems();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
AppSettings.applyMusicVolumeSettings();
|
||||
new EventFlow().addPostEvent(new AudioEvents.StartBackgroundMusic()).postEvent();
|
||||
loading.hide();
|
||||
WidgetContainer.add(Pos.CENTER, new MainView());
|
||||
WidgetContainer.add(Pos.BOTTOM_RIGHT, new SongDisplay());
|
||||
stage.setOnCloseRequest(event -> {
|
||||
event.consume();
|
||||
|
||||
if (WidgetContainer.getAllWidgets().stream().anyMatch(e -> e instanceof QuitPopup)) return;
|
||||
|
||||
QuitPopup a = new QuitPopup();
|
||||
a.show(Pos.CENTER);
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void initSystems() throws InterruptedException { // TODO Move to better place
|
||||
|
||||
final int THREAD_COUNT = 2;
|
||||
CountDownLatch latch = new CountDownLatch(THREAD_COUNT);
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
ExecutorService threads = Executors.newFixedThreadPool(THREAD_COUNT);
|
||||
|
||||
try {
|
||||
|
||||
threads.submit(() -> {
|
||||
new NetworkingClientEventListener(
|
||||
GlobalEventBus.get(),
|
||||
new NetworkingClientManager(GlobalEventBus.get()));
|
||||
|
||||
latch.countDown();
|
||||
});
|
||||
|
||||
threads.submit(() -> {
|
||||
MusicManager<MusicAsset> musicManager =
|
||||
new MusicManager<>(
|
||||
GlobalEventBus.get(),
|
||||
ResourceManager.getAllOfTypeAndRemoveWrapper(MusicAsset.class),
|
||||
true
|
||||
);
|
||||
|
||||
SoundEffectManager<SoundEffectAsset> soundEffectManager =
|
||||
new SoundEffectManager<>(ResourceManager.getAllOfType(SoundEffectAsset.class));
|
||||
|
||||
AudioVolumeManager audioVolumeManager = new AudioVolumeManager()
|
||||
.registerManager(VolumeControl.MASTERVOLUME, musicManager)
|
||||
.registerManager(VolumeControl.MASTERVOLUME, soundEffectManager)
|
||||
.registerManager(VolumeControl.FX, soundEffectManager)
|
||||
.registerManager(VolumeControl.MUSIC, musicManager);
|
||||
|
||||
new AudioEventListener<>(
|
||||
GlobalEventBus.get(),
|
||||
musicManager,
|
||||
soundEffectManager,
|
||||
audioVolumeManager
|
||||
).initListeners("medium-button-click.wav");
|
||||
|
||||
latch.countDown();
|
||||
});
|
||||
|
||||
} finally {
|
||||
latch.await();
|
||||
threads.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public static void quitPopup() {
|
||||
Platform.runLater(
|
||||
() -> {
|
||||
push(new QuitPopup());
|
||||
isQuitting = true;
|
||||
});
|
||||
}
|
||||
public static void quit() {
|
||||
stage.close();
|
||||
System.exit(0); // TODO: This is like dropping a nuke
|
||||
}
|
||||
|
||||
public static void quit() {
|
||||
stage.close();
|
||||
}
|
||||
public static void setFullscreen(boolean fullscreen) {
|
||||
stage.setFullScreen(fullscreen);
|
||||
|
||||
public static void reloadAll() {
|
||||
stage.setTitle(AppContext.getString("appTitle"));
|
||||
width = (int)stage.getWidth();
|
||||
height = (int)stage.getHeight();
|
||||
}
|
||||
|
||||
for (final Layer layer : stack) {
|
||||
layer.reload();
|
||||
}
|
||||
}
|
||||
public static void setStyle(String theme, String layoutSize) {
|
||||
scene.getStylesheets().clear();
|
||||
|
||||
public static void setFullscreen(boolean fullscreen) {
|
||||
stage.setFullScreen(fullscreen);
|
||||
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());
|
||||
}
|
||||
|
||||
width = (int) stage.getWidth();
|
||||
height = (int) stage.getHeight();
|
||||
public static int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,54 @@
|
||||
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(2, 5),
|
||||
REVERSI(2, 10);
|
||||
|
||||
private final int playerCount;
|
||||
private final int maxDepth;
|
||||
|
||||
Type(int playerCount, int maxDepth) {
|
||||
this.playerCount = playerCount;
|
||||
this.maxDepth = maxDepth;
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
return playerCount;
|
||||
}
|
||||
|
||||
public int getMaxDepth() {
|
||||
return maxDepth;
|
||||
}
|
||||
|
||||
public String getTypeToString() {
|
||||
String name = this.name();
|
||||
return switch (name) {
|
||||
case "TICTACTOE" -> "TicTacToe";
|
||||
case "REVERSI" -> "Reversi";
|
||||
case "CONNECT4" -> "Connect4";
|
||||
case "BATTLESHIP" -> "Battleship";
|
||||
default -> name;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
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.getPlayerCount()];
|
||||
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
players[i] = new Player();
|
||||
}
|
||||
}
|
||||
}
|
||||
354
app/src/main/java/org/toop/app/Server.java
Normal file
@@ -0,0 +1,354 @@
|
||||
package org.toop.app;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Pos;
|
||||
import org.toop.app.gameControllers.*;
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.WidgetContainer;
|
||||
import org.toop.app.widget.complex.LoadingWidget;
|
||||
import org.toop.app.widget.popup.ChallengePopup;
|
||||
import org.toop.app.widget.popup.ErrorPopup;
|
||||
import org.toop.app.widget.popup.SendChallengePopup;
|
||||
import org.toop.app.widget.view.ServerView;
|
||||
import org.toop.framework.eventbus.EventFlow;
|
||||
import org.toop.framework.gameFramework.controller.GameController;
|
||||
import org.toop.framework.eventbus.GlobalEventBus;
|
||||
import org.toop.framework.gameFramework.model.player.Player;
|
||||
import org.toop.framework.networking.clients.TournamentNetworkingClient;
|
||||
import org.toop.framework.networking.events.NetworkEvents;
|
||||
import org.toop.framework.networking.types.NetworkingConnector;
|
||||
import org.toop.game.games.reversi.BitboardReversi;
|
||||
import org.toop.game.games.tictactoe.BitboardTicTacToe;
|
||||
import org.toop.game.players.ArtificialPlayer;
|
||||
import org.toop.game.players.OnlinePlayer;
|
||||
import org.toop.game.players.RandomAI;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public final class Server {
|
||||
// TODO: Keep track of listeners. Remove them on Server connection close so reference is deleted.
|
||||
private String user = "";
|
||||
private long clientId = -1;
|
||||
|
||||
private final List<String> onlinePlayers = new CopyOnWriteArrayList<>();
|
||||
private final List<String> gameList = new CopyOnWriteArrayList<>();
|
||||
|
||||
private ServerView primary;
|
||||
private boolean isPolling = true;
|
||||
|
||||
private GameController gameController;
|
||||
|
||||
private final AtomicBoolean isSingleGame = new AtomicBoolean(false);
|
||||
|
||||
private ScheduledExecutorService scheduler;
|
||||
|
||||
private EventFlow connectFlow;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// Server has to deal with ALL network related listen events. This "server" can then interact with the manager to make stuff happen.
|
||||
// This prevents data races where events get sent to the game manager but the manager isn't ready yet.
|
||||
public Server(String ip, String port, String user) {
|
||||
if (ip.split("\\.").length < 4) {
|
||||
new ErrorPopup("\"" + ip + "\" " + AppContext.getString("is-not-a-valid-ip-address"));
|
||||
return;
|
||||
}
|
||||
|
||||
int parsedPort;
|
||||
|
||||
try {
|
||||
parsedPort = Integer.parseInt(port);
|
||||
} catch (NumberFormatException _) {
|
||||
new ErrorPopup("\"" + port + "\" " + AppContext.getString("is-not-a-valid-port"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.isEmpty() || user.matches("^[0-9].*")) {
|
||||
new ErrorPopup(AppContext.getString("invalid-username"));
|
||||
return;
|
||||
}
|
||||
|
||||
final int reconnectAttempts = 10;
|
||||
|
||||
LoadingWidget loading = new LoadingWidget(
|
||||
Primitive.text("connecting"), 0, 0, reconnectAttempts, true, true
|
||||
);
|
||||
|
||||
WidgetContainer.getCurrentView().transitionNextCustom(loading, "disconnect", this::disconnect);
|
||||
|
||||
var a = new EventFlow()
|
||||
.addPostEvent(NetworkEvents.StartClient.class,
|
||||
new TournamentNetworkingClient(GlobalEventBus.get()),
|
||||
new NetworkingConnector(ip, parsedPort, reconnectAttempts, 1, TimeUnit.SECONDS)
|
||||
);
|
||||
|
||||
loading.setOnFailure(() -> {
|
||||
if (WidgetContainer.getCurrentView() == loading) WidgetContainer.getCurrentView().transitionPrevious();
|
||||
a.unsubscribeAll();
|
||||
WidgetContainer.add(
|
||||
Pos.CENTER,
|
||||
new ErrorPopup(AppContext.getString("connecting-failed") + " " + ip + ":" + port)
|
||||
);
|
||||
});
|
||||
|
||||
a.onResponse(NetworkEvents.CreatedIdForClient.class, e -> clientId = e.clientId(), true);
|
||||
|
||||
a.onResponse(NetworkEvents.StartClientResponse.class, e -> {
|
||||
if (!e.successful()) {
|
||||
return;
|
||||
}
|
||||
|
||||
primary = new ServerView(user, this::sendChallenge);
|
||||
WidgetContainer.getCurrentView().transitionNextCustom(primary, "disconnect", this::disconnect);
|
||||
|
||||
a.unsubscribe("connecting");
|
||||
a.unsubscribe("startclient");
|
||||
|
||||
this.user = user;
|
||||
|
||||
new EventFlow().addPostEvent(new NetworkEvents.SendLogin(clientId, user)).postEvent();
|
||||
|
||||
startPopulateScheduler();
|
||||
populateGameList();
|
||||
|
||||
primary.removeViewFromPreviousChain(loading);
|
||||
|
||||
}, false, "startclient")
|
||||
.listen(
|
||||
NetworkEvents.ConnectTry.class,
|
||||
e -> {
|
||||
if (clientId != e.clientId()) return;
|
||||
Platform.runLater(
|
||||
() -> {
|
||||
try {
|
||||
loading.setAmount(e.amount());
|
||||
if (e.amount() >= loading.getMaxAmount()) {
|
||||
loading.triggerFailure();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
false, "connecting"
|
||||
)
|
||||
.postEvent();
|
||||
|
||||
a.listen(NetworkEvents.ChallengeResponse.class, this::handleReceivedChallenge, false, "challenge")
|
||||
.listen(NetworkEvents.GameMatchResponse.class, this::handleMatchResponse, false, "match-response")
|
||||
.listen(NetworkEvents.GameResultResponse.class, this::handleGameResult, false, "game-result")
|
||||
.listen(NetworkEvents.GameMoveResponse.class, this::handleReceivedMove, false, "game-move")
|
||||
.listen(NetworkEvents.YourTurnResponse.class, this::handleYourTurn, false, "your-turn");
|
||||
|
||||
connectFlow = a;
|
||||
}
|
||||
|
||||
private void sendChallenge(String opponent) {
|
||||
if (!isPolling) return;
|
||||
|
||||
var a = new SendChallengePopup(this, opponent, (playerInformation, gameType) -> {
|
||||
new EventFlow().addPostEvent(new NetworkEvents.SendChallenge(clientId, opponent, gameType)).postEvent();
|
||||
isSingleGame.set(true);
|
||||
});
|
||||
|
||||
a.show(Pos.CENTER);
|
||||
}
|
||||
|
||||
private void handleMatchResponse(NetworkEvents.GameMatchResponse response) {
|
||||
// TODO: Redo all of this mess
|
||||
if (gameController != null) {
|
||||
gameController.stop();
|
||||
}
|
||||
|
||||
gameController = null;
|
||||
|
||||
//if (!isPolling) return;
|
||||
|
||||
String gameType = extractQuotedValue(response.gameType());
|
||||
if (response.clientId() == clientId) {
|
||||
isPolling = false;
|
||||
onlinePlayers.clear();
|
||||
|
||||
final GameInformation.Type type = gameToType(gameType);
|
||||
if (type == null) {
|
||||
new ErrorPopup("Unsupported game type: " + gameType);
|
||||
return;
|
||||
}
|
||||
|
||||
final int myTurn = response.playerToMove().equalsIgnoreCase(response.opponent()) ? 1 : 0;
|
||||
|
||||
final GameInformation information = new GameInformation(type);
|
||||
//information.players[0] = playerInformation;
|
||||
information.players[0].name = user;
|
||||
information.players[0].isHuman = false;
|
||||
information.players[0].computerDifficulty = 5;
|
||||
information.players[0].computerThinkTime = 1;
|
||||
information.players[1].name = response.opponent();
|
||||
|
||||
/*switch (type){
|
||||
case TICTACTOE ->{
|
||||
players[myTurn] = new ArtificialPlayer<>(new TicTacToeAIR(9), user);
|
||||
}
|
||||
case REVERSI ->{
|
||||
players[myTurn] = new ArtificialPlayer<>(new ReversiAIR(), user);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
switch (type) {
|
||||
case TICTACTOE ->{
|
||||
Player<BitboardTicTacToe>[] players = new Player[2];
|
||||
players[(myTurn + 1) % 2] = new OnlinePlayer<>(response.opponent());
|
||||
players[myTurn] = new ArtificialPlayer<>(new RandomAI<BitboardTicTacToe>(), user);
|
||||
gameController = new TicTacToeBitController(players);
|
||||
}
|
||||
case REVERSI -> {
|
||||
Player<BitboardReversi>[] players = new Player[2];
|
||||
players[(myTurn + 1) % 2] = new OnlinePlayer<>(response.opponent());
|
||||
players[myTurn] = new ArtificialPlayer<>(new RandomAI<BitboardReversi>(), user);
|
||||
gameController = new ReversiBitController(players);}
|
||||
default -> new ErrorPopup("Unsupported game type.");
|
||||
|
||||
}
|
||||
|
||||
if (gameController != null){
|
||||
gameController.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleYourTurn(NetworkEvents.YourTurnResponse response) {
|
||||
if (gameController == null) {
|
||||
return;
|
||||
}
|
||||
gameController.onYourTurn(response);
|
||||
|
||||
}
|
||||
|
||||
private void handleGameResult(NetworkEvents.GameResultResponse response) {
|
||||
if (gameController == null) {
|
||||
return;
|
||||
}
|
||||
gameController.gameFinished(response);
|
||||
}
|
||||
|
||||
private void handleReceivedMove(NetworkEvents.GameMoveResponse response) {
|
||||
if (gameController == null) {
|
||||
return;
|
||||
}
|
||||
gameController.onMoveReceived(response);
|
||||
}
|
||||
|
||||
private void handleReceivedChallenge(NetworkEvents.ChallengeResponse response) {
|
||||
if (!isPolling) return;
|
||||
|
||||
String challengerName = extractQuotedValue(response.challengerName());
|
||||
String gameType = extractQuotedValue(response.gameType());
|
||||
final String finalGameType = gameType;
|
||||
var a = new ChallengePopup(challengerName, gameType, (playerInformation) -> {
|
||||
final int challengeId = Integer.parseInt(response.challengeId().replaceAll("\\D", ""));
|
||||
new EventFlow().addPostEvent(new NetworkEvents.SendAcceptChallenge(clientId, challengeId)).postEvent();
|
||||
isSingleGame.set(true);
|
||||
});
|
||||
|
||||
a.show(Pos.CENTER);
|
||||
}
|
||||
|
||||
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();
|
||||
isPolling = false;
|
||||
stopScheduler();
|
||||
connectFlow.unsubscribeAll();
|
||||
|
||||
WidgetContainer.getCurrentView().transitionPrevious();
|
||||
}
|
||||
|
||||
private void forfeitGame() {
|
||||
new EventFlow().addPostEvent(new NetworkEvents.SendForfeit(clientId)).postEvent();
|
||||
}
|
||||
|
||||
private void exitGame() {
|
||||
forfeitGame();
|
||||
startPopulateScheduler();
|
||||
}
|
||||
|
||||
private void gameOver(){
|
||||
startPopulateScheduler();
|
||||
}
|
||||
|
||||
private void startPopulateScheduler() {
|
||||
isPolling = true;
|
||||
isSingleGame.set(false);
|
||||
stopScheduler();
|
||||
|
||||
new EventFlow()
|
||||
.listen(NetworkEvents.PlayerlistResponse.class, e -> {
|
||||
if (e.clientId() == clientId) {
|
||||
onlinePlayers.clear();
|
||||
onlinePlayers.addAll(List.of(e.playerlist()));
|
||||
onlinePlayers.removeIf(name -> name.equalsIgnoreCase(user));
|
||||
primary.update(onlinePlayers);
|
||||
}
|
||||
}, false);
|
||||
|
||||
scheduler = Executors.newSingleThreadScheduledExecutor();
|
||||
scheduler.scheduleAtFixedRate(() -> {
|
||||
if (isPolling) {
|
||||
new EventFlow().addPostEvent(new NetworkEvents.SendGetPlayerlist(clientId)).postEvent();
|
||||
} else {
|
||||
stopScheduler();
|
||||
}
|
||||
}, 0, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private void stopScheduler() {
|
||||
if (scheduler != null && !scheduler.isShutdown()) {
|
||||
scheduler.shutdownNow();
|
||||
}
|
||||
}
|
||||
|
||||
private void gamesListFromServerHandler(NetworkEvents.GamelistResponse event) {
|
||||
gameList.clear();
|
||||
gameList.addAll(List.of(event.gamelist()));
|
||||
}
|
||||
|
||||
public void populateGameList() {
|
||||
new EventFlow().addPostEvent(new NetworkEvents.SendGetGamelist(clientId))
|
||||
.listen(NetworkEvents.GamelistResponse.class, this::gamesListFromServerHandler, true)
|
||||
.postEvent();
|
||||
}
|
||||
|
||||
public List<String> getGameList() {
|
||||
return gameList;
|
||||
}
|
||||
|
||||
private String extractQuotedValue(String s) {
|
||||
int first = s.indexOf('"');
|
||||
int last = s.lastIndexOf('"');
|
||||
if (first >= 0 && last > first) {
|
||||
return s.substring(first + 1, last);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
247
app/src/main/java/org/toop/app/canvas/BitGameCanvas.java
Normal file
@@ -0,0 +1,247 @@
|
||||
package org.toop.app.canvas;
|
||||
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.scene.canvas.Canvas;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.util.Duration;
|
||||
import org.toop.framework.eventbus.EventFlow;
|
||||
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
||||
import org.toop.framework.gameFramework.view.GUIEvents;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public abstract class BitGameCanvas<T extends TurnBasedGame<T>> implements GameCanvas<T> {
|
||||
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 Color color;
|
||||
protected final Color backgroundColor;
|
||||
|
||||
protected final int width;
|
||||
protected final int height;
|
||||
|
||||
protected final int rowSize;
|
||||
protected final int columnSize;
|
||||
|
||||
protected final int gapSize;
|
||||
protected final boolean edges;
|
||||
|
||||
protected final Cell[] cells;
|
||||
|
||||
private Consumer<Long> onCellCLicked;
|
||||
|
||||
public void setOnCellClicked(Consumer<Long> onClick) {
|
||||
this.onCellCLicked = onClick;
|
||||
}
|
||||
|
||||
protected BitGameCanvas(Color color, Color backgroundColor, int width, int height, int rowSize, int columnSize, int gapSize, boolean edges) {
|
||||
canvas = new Canvas(width, height);
|
||||
graphics = canvas.getGraphicsContext2D();
|
||||
|
||||
this.onCellCLicked = (c) -> new EventFlow().addPostEvent(GUIEvents.PlayerAttemptedMove.class, c).postEvent();
|
||||
|
||||
this.color = color;
|
||||
this.backgroundColor = backgroundColor;
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
this.rowSize = rowSize;
|
||||
this.columnSize = columnSize;
|
||||
|
||||
this.gapSize = gapSize;
|
||||
this.edges = edges;
|
||||
|
||||
cells = new Cell[rowSize * columnSize];
|
||||
|
||||
final float cellWidth = ((float) width - gapSize * rowSize - gapSize) / rowSize;
|
||||
final float cellHeight = ((float) height - gapSize * columnSize - gapSize) / columnSize;
|
||||
|
||||
for (int y = 0; y < columnSize; y++) {
|
||||
final float startY = y * cellHeight + y * gapSize + gapSize;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
final int column = (int) ((event.getX() / this.width) * rowSize);
|
||||
final int row = (int) ((event.getY() / this.height) * columnSize);
|
||||
|
||||
final Cell cell = cells[column + row * rowSize];
|
||||
|
||||
if (cell.isInside(event.getX(), event.getY())) {
|
||||
event.consume();
|
||||
this.onCellCLicked.accept(1L << (column + row * rowSize));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
render();
|
||||
}
|
||||
|
||||
public void loopOverBoard(long bb, Consumer<Integer> onCell){
|
||||
while (bb != 0) {
|
||||
int idx = Long.numberOfTrailingZeros(bb); // index of least-significant 1-bit
|
||||
onCell.accept(idx);
|
||||
|
||||
bb &= bb - 1; // clear LSB 1-bit
|
||||
}
|
||||
}
|
||||
|
||||
private void render() {
|
||||
graphics.setFill(backgroundColor);
|
||||
graphics.fillRect(0, 0, width, height);
|
||||
|
||||
graphics.setFill(color);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (edges) {
|
||||
graphics.fillRect(0, 0, width, gapSize);
|
||||
graphics.fillRect(0, 0, gapSize, height);
|
||||
|
||||
graphics.fillRect(width - gapSize, 0, gapSize, height);
|
||||
graphics.fillRect(0, height - gapSize, width, gapSize);
|
||||
}
|
||||
}
|
||||
|
||||
public void fill(Color color, int cell) {
|
||||
final float x = cells[cell].x();
|
||||
final float y = cells[cell].y();
|
||||
|
||||
final float width = cells[cell].width();
|
||||
final float height = cells[cell].height();
|
||||
|
||||
graphics.setFill(color);
|
||||
graphics.fillRect(x, y, width, height);
|
||||
}
|
||||
|
||||
public void clear(int cell) {
|
||||
final float x = cells[cell].x();
|
||||
final float y = cells[cell].y();
|
||||
|
||||
final float width = cells[cell].width();
|
||||
final float height = cells[cell].height();
|
||||
|
||||
graphics.clearRect(x, y, width, height);
|
||||
|
||||
graphics.setFill(backgroundColor);
|
||||
graphics.fillRect(x, y, width, height);
|
||||
}
|
||||
|
||||
public void clearAll() {
|
||||
for (int i = 0; i < cells.length; i++) {
|
||||
clear(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawPlayerMove(int player, int move) {
|
||||
final float x = cells[move].x() + gapSize;
|
||||
final float y = cells[move].y() + gapSize;
|
||||
|
||||
final float width = cells[move].width() - gapSize * 2;
|
||||
final float height = cells[move].height() - gapSize * 2;
|
||||
|
||||
graphics.setFill(color);
|
||||
graphics.setFont(Font.font("Arial", 40)); // TODO different font and size
|
||||
graphics.fillText(String.valueOf(player), x + width, y + height);
|
||||
}
|
||||
|
||||
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 drawInnerDot(Color color, int cell, boolean slightlyBigger) {
|
||||
final float x = cells[cell].x() + gapSize;
|
||||
final float y = cells[cell].y() + gapSize;
|
||||
|
||||
float multiplier = slightlyBigger?1.4f:1.5f;
|
||||
|
||||
final float width = (cells[cell].width() - gapSize * 2)/multiplier;
|
||||
final float height = (cells[cell].height() - gapSize * 2)/multiplier;
|
||||
|
||||
float offset = slightlyBigger?5f:4f;
|
||||
|
||||
graphics.setFill(color);
|
||||
graphics.fillOval(x + width/offset, y + height/offset, width, height);
|
||||
}
|
||||
|
||||
private void drawDotScaled(Color color, int cell, double scale) {
|
||||
final float cx = cells[cell].x() + gapSize;
|
||||
final float cy = cells[cell].y() + gapSize;
|
||||
|
||||
final float fullWidth = cells[cell].width() - gapSize * 2;
|
||||
final float height = cells[cell].height() - gapSize * 2;
|
||||
|
||||
final float scaledWidth = (float)(fullWidth * scale);
|
||||
final float offsetX = (fullWidth - scaledWidth) / 2;
|
||||
|
||||
graphics.setFill(color);
|
||||
graphics.fillOval(cx + offsetX, cy, scaledWidth, height);
|
||||
}
|
||||
|
||||
public Timeline flipDot(Color fromColor, Color toColor, int cell) {
|
||||
final int steps = 60;
|
||||
final long duration = 250;
|
||||
final double interval = duration / (double) steps;
|
||||
|
||||
final Timeline timeline = new Timeline();
|
||||
|
||||
for (int i = 0; i <= steps; i++) {
|
||||
final double t = i / (double) steps;
|
||||
final KeyFrame keyFrame = new KeyFrame(Duration.millis(i * interval),
|
||||
_ -> {
|
||||
clear(cell);
|
||||
|
||||
final double scale = t <= 0.5 ? 1 - 2 * t : 2 * t - 1;
|
||||
final Color currentColor = t < 0.5 ? fromColor : toColor;
|
||||
|
||||
drawDotScaled(currentColor, cell, scale);
|
||||
}
|
||||
);
|
||||
|
||||
timeline.getKeyFrames().add(keyFrame);
|
||||
}
|
||||
|
||||
return timeline;
|
||||
}
|
||||
|
||||
public Canvas getCanvas() {
|
||||
return canvas;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.toop.app.canvas;
|
||||
|
||||
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
||||
|
||||
public interface DrawPlayerHover {
|
||||
void drawPlayerHover(int player, int move, TurnBasedGame game);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.toop.app.canvas;
|
||||
|
||||
public interface DrawPlayerMove {
|
||||
void drawPlayerMove(int player, int move);
|
||||
}
|
||||
@@ -1,130 +1,8 @@
|
||||
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 org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
||||
|
||||
public abstract class GameCanvas {
|
||||
protected record Cell(float x, float y, float width, float height) {}
|
||||
|
||||
protected final Canvas canvas;
|
||||
protected final GraphicsContext graphics;
|
||||
|
||||
protected final Color color;
|
||||
|
||||
protected int width;
|
||||
protected int height;
|
||||
|
||||
protected final int rows;
|
||||
protected final int columns;
|
||||
|
||||
protected final int gapSize;
|
||||
protected final boolean edges;
|
||||
|
||||
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();
|
||||
|
||||
this.color = color;
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
this.rows = rows;
|
||||
this.columns = columns;
|
||||
|
||||
this.gapSize = gapSize;
|
||||
this.edges = edges;
|
||||
|
||||
cells = new Cell[rows * columns];
|
||||
|
||||
final float cellWidth = ((float) width - (rows - 1) * gapSize) / rows;
|
||||
final float cellHeight = ((float) height - (columns - 1) * gapSize) / columns;
|
||||
|
||||
for (int y = 0; y < columns; y++) {
|
||||
final float startY = y * cellHeight + y * 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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
event.consume();
|
||||
onCellClicked.accept(row * rows + column);
|
||||
});
|
||||
|
||||
render();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
graphics.clearRect(0, 0, width, height);
|
||||
}
|
||||
|
||||
public void render() {
|
||||
graphics.setFill(color);
|
||||
|
||||
for (int x = 1; x < rows; x++) {
|
||||
graphics.fillRect(cells[x].x() - gapSize, 0, gapSize, height);
|
||||
}
|
||||
|
||||
for (int y = 1; y < columns; y++) {
|
||||
graphics.fillRect(0, cells[y * rows].y() - gapSize, width, gapSize);
|
||||
}
|
||||
|
||||
if (edges) {
|
||||
graphics.fillRect(-gapSize, 0, gapSize, height);
|
||||
graphics.fillRect(0, -gapSize, width, gapSize);
|
||||
|
||||
graphics.fillRect(width - gapSize, 0, gapSize, height);
|
||||
graphics.fillRect(0, height - gapSize, width, gapSize);
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(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.fillRect(x, y, width, height);
|
||||
}
|
||||
|
||||
public void resize(int width, int height) {
|
||||
canvas.setWidth(width);
|
||||
canvas.setHeight(height);
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
clear();
|
||||
render();
|
||||
}
|
||||
|
||||
public Canvas getCanvas() {
|
||||
return canvas;
|
||||
}
|
||||
public interface GameCanvas<T extends TurnBasedGame<T>> extends GameDrawer<T>{
|
||||
Canvas getCanvas();
|
||||
}
|
||||
|
||||
7
app/src/main/java/org/toop/app/canvas/GameDrawer.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package org.toop.app.canvas;
|
||||
|
||||
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
||||
|
||||
public interface GameDrawer<T extends TurnBasedGame<T>> {
|
||||
void redraw(T gameCopy);
|
||||
}
|
||||
42
app/src/main/java/org/toop/app/canvas/ReversiBitCanvas.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package org.toop.app.canvas;
|
||||
|
||||
import javafx.scene.paint.Color;
|
||||
import org.toop.app.App;
|
||||
import org.toop.game.games.reversi.BitboardReversi;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ReversiBitCanvas extends BitGameCanvas<BitboardReversi> {
|
||||
public ReversiBitCanvas() {
|
||||
super(Color.GRAY, new Color(0f, 0.4f, 0.2f, 1f), (App.getHeight() / 4) * 3, (App.getHeight() / 4) * 3, 8, 8, 5, true);
|
||||
canvas.setOnMouseMoved(event -> {
|
||||
double mouseX = event.getX();
|
||||
double mouseY = event.getY();
|
||||
int cellId = -1;
|
||||
|
||||
BitGameCanvas.Cell hovered = null;
|
||||
for (BitGameCanvas.Cell cell : cells) {
|
||||
if (cell.isInside(mouseX, mouseY)) {
|
||||
hovered = cell;
|
||||
cellId = turnCoordsIntoCellId(mouseX, mouseY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private int turnCoordsIntoCellId(double x, double y) {
|
||||
final int column = (int) ((x / this.width) * rowSize);
|
||||
final int row = (int) ((y / this.height) * columnSize);
|
||||
return column + row * rowSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redraw(BitboardReversi gameCopy) {
|
||||
clearAll();
|
||||
long[] board = gameCopy.getBoard();
|
||||
loopOverBoard(board[0], (i) -> drawDot(Color.WHITE, i));
|
||||
loopOverBoard(board[1], (i) -> drawDot(Color.BLACK, i));
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,39 @@
|
||||
package org.toop.app.canvas;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import javafx.scene.paint.Color;
|
||||
import org.toop.app.App;
|
||||
import org.toop.game.games.tictactoe.BitboardTicTacToe;
|
||||
|
||||
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.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class TicTacToeBitCanvas extends BitGameCanvas<BitboardTicTacToe>{
|
||||
public TicTacToeBitCanvas() {
|
||||
super(
|
||||
Color.GRAY,
|
||||
Color.TRANSPARENT,
|
||||
(App.getHeight() / 4) * 3,
|
||||
(App.getHeight() / 4) * 3,
|
||||
3,
|
||||
3,
|
||||
30,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redraw(BitboardTicTacToe gameCopy) {
|
||||
clearAll();
|
||||
drawMoves(gameCopy.getBoard());
|
||||
}
|
||||
|
||||
private void drawMoves(long[] gameBoard){
|
||||
loopOverBoard(gameBoard[0], (i) -> drawX(Color.RED, i));
|
||||
loopOverBoard(gameBoard[1], (i) -> drawO(Color.BLUE, i));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void drawX(Color color, int cell) {
|
||||
graphics.setStroke(color);
|
||||
graphics.setLineWidth(gapSize);
|
||||
@@ -0,0 +1,140 @@
|
||||
package org.toop.app.gameControllers;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Pos;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.toop.app.canvas.GameCanvas;
|
||||
import org.toop.app.widget.WidgetContainer;
|
||||
import org.toop.app.widget.view.GameView;
|
||||
import org.toop.framework.eventbus.EventFlow;
|
||||
import org.toop.framework.eventbus.GlobalEventBus;
|
||||
import org.toop.framework.gameFramework.controller.GameController;
|
||||
import org.toop.framework.gameFramework.model.game.SupportsOnlinePlay;
|
||||
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
||||
import org.toop.framework.gameFramework.model.game.threadBehaviour.ThreadBehaviour;
|
||||
import org.toop.framework.gameFramework.model.player.Player;
|
||||
import org.toop.framework.gameFramework.view.GUIEvents;
|
||||
import org.toop.framework.networking.events.NetworkEvents;
|
||||
import org.toop.game.players.LocalPlayer;
|
||||
|
||||
public class GenericGameController<T extends TurnBasedGame<T>> implements GameController {
|
||||
protected final EventFlow eventFlow = new EventFlow();
|
||||
|
||||
// Logger for logging
|
||||
protected final Logger logger = LogManager.getLogger(this.getClass());
|
||||
|
||||
// Reference to gameView view
|
||||
protected final GameView gameView;
|
||||
|
||||
// Reference to game canvas
|
||||
protected final GameCanvas<T> canvas;
|
||||
|
||||
protected final TurnBasedGame<T> game; // Reference to game instance
|
||||
private final ThreadBehaviour gameThreadBehaviour;
|
||||
|
||||
// TODO: Change gameType to automatically happen with either dependency injection or something else.
|
||||
public GenericGameController(GameCanvas<T> canvas, T game, ThreadBehaviour gameThreadBehaviour, String gameType) {
|
||||
logger.info("Creating: " + this.getClass());
|
||||
|
||||
this.canvas = canvas;
|
||||
this.game = game;
|
||||
this.gameThreadBehaviour = gameThreadBehaviour;
|
||||
|
||||
// Tell thread how to send moves
|
||||
this.gameThreadBehaviour.setOnSendMove((id, m) -> GlobalEventBus.get().post(new NetworkEvents.SendMove(id, (short)translateMove(m))));
|
||||
|
||||
// Tell thread how to update UI
|
||||
this.gameThreadBehaviour.setOnUpdateUI(() -> Platform.runLater(this::updateUI));
|
||||
|
||||
// Change scene to game view
|
||||
gameView = new GameView(null, null, null, gameType);
|
||||
gameView.add(Pos.CENTER, canvas.getCanvas());
|
||||
WidgetContainer.getCurrentView().transitionNext(gameView, true);
|
||||
|
||||
// Listen to updates
|
||||
eventFlow
|
||||
.listen(GUIEvents.GameEnded.class, this::onGameFinish, false)
|
||||
.listen(GUIEvents.PlayerAttemptedMove.class, event -> {if (getCurrentPlayer() instanceof LocalPlayer<T> lp){lp.setMove(event.move());}}, false);
|
||||
}
|
||||
|
||||
public void start(){
|
||||
logger.info("Starting GameManager");
|
||||
updateUI();
|
||||
gameThreadBehaviour.start();
|
||||
}
|
||||
|
||||
public void stop(){
|
||||
logger.info("Stopping GameManager");
|
||||
removeListeners();
|
||||
gameThreadBehaviour.stop();
|
||||
}
|
||||
|
||||
public Player<T> getCurrentPlayer(){
|
||||
return game.getPlayer(getCurrentPlayerIndex());
|
||||
}
|
||||
|
||||
public int getCurrentPlayerIndex(){
|
||||
return game.getCurrentTurn();
|
||||
}
|
||||
|
||||
protected long translateMove(int move){
|
||||
return 1L << move;
|
||||
}
|
||||
|
||||
protected int translateMove(long move){
|
||||
return Long.numberOfTrailingZeros(move);
|
||||
}
|
||||
|
||||
private void removeListeners(){
|
||||
eventFlow.unsubscribeAll();
|
||||
}
|
||||
|
||||
private void onGameFinish(GUIEvents.GameEnded event){
|
||||
logger.info("Game Finished");
|
||||
String name = event.winner() == -1 ? null : getPlayer(event.winner()).getName();
|
||||
gameView.gameOver(event.winOrTie(), name);
|
||||
stop();
|
||||
}
|
||||
|
||||
public Player<T> getPlayer(int player){
|
||||
if (player < 0 || player >= 2){ // TODO: Make game turn player count
|
||||
logger.error("Invalid player index");
|
||||
throw new IllegalArgumentException("player out of range");
|
||||
}
|
||||
return game.getPlayer(player);
|
||||
}
|
||||
|
||||
private boolean isOnline(){
|
||||
return this.gameThreadBehaviour instanceof SupportsOnlinePlay;
|
||||
}
|
||||
|
||||
public void onYourTurn(NetworkEvents.YourTurnResponse event){
|
||||
if (isOnline()){
|
||||
((SupportsOnlinePlay) this.gameThreadBehaviour).onYourTurn(event.clientId());
|
||||
}
|
||||
}
|
||||
|
||||
public void onMoveReceived(NetworkEvents.GameMoveResponse event){
|
||||
if (isOnline()){
|
||||
((SupportsOnlinePlay) this.gameThreadBehaviour).onMoveReceived(
|
||||
translateMove(Integer.parseInt(event.move())));
|
||||
}
|
||||
}
|
||||
|
||||
public void gameFinished(NetworkEvents.GameResultResponse event){
|
||||
if (isOnline()){
|
||||
((SupportsOnlinePlay) this.gameThreadBehaviour).gameFinished(event.condition());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMove(long clientId, long move) {
|
||||
new EventFlow().addPostEvent(NetworkEvents.SendMove.class, clientId, (short) Long.numberOfTrailingZeros(move)).asyncPostEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
canvas.redraw(game.deepCopy());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.toop.app.gameControllers;
|
||||
|
||||
import org.toop.app.canvas.ReversiBitCanvas;
|
||||
import org.toop.framework.gameFramework.model.game.threadBehaviour.ThreadBehaviour;
|
||||
import org.toop.framework.gameFramework.model.player.Player;
|
||||
import org.toop.game.gameThreads.LocalThreadBehaviour;
|
||||
import org.toop.game.gameThreads.OnlineThreadBehaviour;
|
||||
import org.toop.game.games.reversi.BitboardReversi;
|
||||
import org.toop.game.players.OnlinePlayer;
|
||||
|
||||
public class ReversiBitController extends GenericGameController<BitboardReversi> {
|
||||
public ReversiBitController(Player<BitboardReversi>[] players) {
|
||||
BitboardReversi game = new BitboardReversi(players);
|
||||
ThreadBehaviour thread = new LocalThreadBehaviour<>(game);
|
||||
for (Player<BitboardReversi> player : players) {
|
||||
if (player instanceof OnlinePlayer<BitboardReversi>){
|
||||
thread = new OnlineThreadBehaviour<>(game);
|
||||
}
|
||||
}
|
||||
super(new ReversiBitCanvas(), game, thread, "Reversi");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.toop.app.gameControllers;
|
||||
|
||||
import org.toop.app.canvas.TicTacToeBitCanvas;
|
||||
import org.toop.framework.gameFramework.model.game.threadBehaviour.ThreadBehaviour;
|
||||
import org.toop.framework.gameFramework.model.player.Player;
|
||||
import org.toop.game.gameThreads.LocalFixedRateThreadBehaviour;
|
||||
import org.toop.game.gameThreads.LocalThreadBehaviour;
|
||||
import org.toop.game.gameThreads.OnlineThreadBehaviour;
|
||||
import org.toop.game.games.tictactoe.BitboardTicTacToe;
|
||||
import org.toop.game.players.OnlinePlayer;
|
||||
|
||||
public class TicTacToeBitController extends GenericGameController<BitboardTicTacToe> {
|
||||
public TicTacToeBitController(Player<BitboardTicTacToe>[] players) {
|
||||
BitboardTicTacToe game = new BitboardTicTacToe(players);
|
||||
ThreadBehaviour thread = new LocalThreadBehaviour<>(game);
|
||||
for (Player<BitboardTicTacToe> player : players) {
|
||||
if (player instanceof OnlinePlayer<BitboardTicTacToe>){
|
||||
thread = new OnlineThreadBehaviour<>(game);
|
||||
}
|
||||
}
|
||||
super(new TicTacToeBitCanvas(), game, thread , "TicTacToe");
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,235 +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.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,
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -1,65 +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.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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,222 +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.asset.resources.SettingsAsset;
|
||||
import org.toop.framework.audio.events.AudioEvents;
|
||||
import org.toop.framework.eventbus.EventFlow;
|
||||
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()))
|
||||
.asyncPostEvent();
|
||||
});
|
||||
}
|
||||
|
||||
private Slider fxVolumeSlider() {
|
||||
return NodeBuilder.slider(
|
||||
100,
|
||||
settings.getFxVolume(),
|
||||
(volume) -> {
|
||||
settings.setFxVolume(volume);
|
||||
new EventFlow()
|
||||
.addPostEvent(new AudioEvents.ChangeFxVolume(volume.doubleValue()))
|
||||
.asyncPostEvent();
|
||||
});
|
||||
}
|
||||
|
||||
private Slider musicVolumeSlider() {
|
||||
return NodeBuilder.slider(
|
||||
100,
|
||||
settings.getMusicVolume(),
|
||||
(volume) -> {
|
||||
settings.setMusicVolume(volume);
|
||||
new EventFlow()
|
||||
.addPostEvent(new AudioEvents.ChangeMusicVolume(volume.doubleValue()))
|
||||
.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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,329 +0,0 @@
|
||||
package org.toop.app.layer.layers.game;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
} 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 geprobeert. FUCKING veel dingen. Hij doet het niet.
|
||||
// Ik heb zelfs in jou code gekeken en unsubscribeAfterSuccess op false gezet. (zie
|
||||
// ConnectedLayer).
|
||||
// Alle andere functies worden wel gecalt. 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 = 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
|
||||
}
|
||||
}
|
||||
208
app/src/main/java/org/toop/app/widget/Primitive.java
Normal file
@@ -0,0 +1,208 @@
|
||||
package org.toop.app.widget;
|
||||
|
||||
import javafx.scene.image.ImageView;
|
||||
import org.toop.framework.audio.events.AudioEvents;
|
||||
import org.toop.framework.eventbus.EventFlow;
|
||||
import org.toop.framework.resource.resources.ImageAsset;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
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.VBox;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
public final class Primitive {
|
||||
public static Text header(String key, boolean localize) {
|
||||
var header = new Text();
|
||||
header.getStyleClass().add("header");
|
||||
|
||||
if (!key.isEmpty()) {
|
||||
if (localize) header.setText(AppContext.getString(key)); else header.setText(key);
|
||||
header.textProperty().bind(AppContext.bindToKey(key, localize));
|
||||
}
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
public static Text header(String key) {
|
||||
return header(key, true);
|
||||
}
|
||||
|
||||
public static Text text(String key, boolean localize) {
|
||||
var text = new Text();
|
||||
text.getStyleClass().add("text");
|
||||
|
||||
if (!key.isEmpty()) {
|
||||
if (localize) text.setText(AppContext.getString(key)); else text.setText(key);
|
||||
text.textProperty().bind(AppContext.bindToKey(key, localize));
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
public static Text text(String key) {
|
||||
return text(key, true);
|
||||
}
|
||||
|
||||
public static ImageView image(ImageAsset imageAsset) {
|
||||
ImageView imageView = new ImageView(imageAsset.getImage());
|
||||
imageView.getStyleClass().add("image");
|
||||
imageView.setPreserveRatio(true);
|
||||
imageView.setFitWidth(400);
|
||||
imageView.setFitHeight(400);
|
||||
return imageView;
|
||||
}
|
||||
|
||||
public static Button button(String key, Runnable onAction, boolean localize) {
|
||||
var button = new Button();
|
||||
button.getStyleClass().add("button");
|
||||
|
||||
if (!key.isEmpty()) {
|
||||
if (localize) button.setText(AppContext.getString(key)); else button.setText(key);
|
||||
button.textProperty().bind(AppContext.bindToKey(key, localize));
|
||||
}
|
||||
|
||||
if (onAction != null) {
|
||||
button.setOnAction(_ -> {
|
||||
onAction.run();
|
||||
playButtonSound();
|
||||
});
|
||||
}
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
public static Button button(String key, Runnable onAction) {
|
||||
return button(key, onAction, true);
|
||||
}
|
||||
|
||||
public static TextField input(String promptKey, String text, Consumer<String> onValueChanged, boolean localize) {
|
||||
var input = new TextField();
|
||||
input.getStyleClass().add("input");
|
||||
|
||||
if (!promptKey.isEmpty()) {
|
||||
if (localize) input.setPromptText(AppContext.getString(promptKey)); else input.setPromptText(promptKey);
|
||||
input.promptTextProperty().bind(AppContext.bindToKey(promptKey, localize));
|
||||
}
|
||||
|
||||
input.setText(text);
|
||||
|
||||
if (onValueChanged != null) {
|
||||
input.textProperty().addListener((_, _, newValue) ->
|
||||
onValueChanged.accept(newValue));
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
public static TextField input(String promptKey, String text, Consumer<String> onValueChanged) {
|
||||
return input(promptKey, text, onValueChanged, true);
|
||||
}
|
||||
|
||||
public static Slider slider(int min, int max, int value, Consumer<Integer> onValueChanged) {
|
||||
var slider = new Slider();
|
||||
slider.getStyleClass().add("slider");
|
||||
|
||||
slider.setMin(min);
|
||||
slider.setMax(max);
|
||||
slider.setValue(value);
|
||||
|
||||
if (onValueChanged != null) {
|
||||
slider.valueProperty().addListener((_, _, newValue) -> {
|
||||
onValueChanged.accept(newValue.intValue());
|
||||
});
|
||||
}
|
||||
|
||||
slider.setOnMouseReleased(event -> {
|
||||
playButtonSound();
|
||||
});
|
||||
|
||||
return slider;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static <T> ComboBox<T> choice(StringConverter<T> converter, T value, Consumer<T> onValueChanged, T... items) {
|
||||
var choice = new ComboBox<T>();
|
||||
choice.getStyleClass().add("choice");
|
||||
|
||||
if (converter != null) {
|
||||
choice.setConverter(converter);
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
choice.setValue(value);
|
||||
}
|
||||
|
||||
if (onValueChanged != null) {
|
||||
choice.valueProperty().addListener((_, _, newValue) -> {
|
||||
onValueChanged.accept(newValue);
|
||||
playButtonSound();
|
||||
});
|
||||
}
|
||||
|
||||
choice.setItems(FXCollections.observableArrayList(items));
|
||||
|
||||
return choice;
|
||||
}
|
||||
|
||||
public static ScrollPane scroll(Node content) {
|
||||
var scroll = new ScrollPane();
|
||||
scroll.getStyleClass().add("scroll");
|
||||
scroll.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
|
||||
scroll.setFitToWidth(true);
|
||||
|
||||
scroll.setContent(content);
|
||||
|
||||
return scroll;
|
||||
}
|
||||
|
||||
public static Separator separator() {
|
||||
var separator = new Separator();
|
||||
separator.getStyleClass().add("separator");
|
||||
|
||||
return separator;
|
||||
}
|
||||
|
||||
public static HBox hbox(Node... nodes) {
|
||||
var hbox = new HBox();
|
||||
hbox.getStyleClass().add("container");
|
||||
hbox.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
|
||||
|
||||
for (var node : nodes) {
|
||||
if (node != null) {
|
||||
hbox.getChildren().add(node);
|
||||
}
|
||||
}
|
||||
|
||||
return hbox;
|
||||
}
|
||||
|
||||
public static VBox vbox(Node... nodes) {
|
||||
var vbox = new VBox();
|
||||
vbox.getStyleClass().add("container");
|
||||
vbox.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
|
||||
|
||||
for (var node : nodes) {
|
||||
if (node != null) {
|
||||
vbox.getChildren().add(node);
|
||||
}
|
||||
}
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
||||
private static void playButtonSound() {
|
||||
new EventFlow().addPostEvent(new AudioEvents.ClickButton()).postEvent();
|
||||
}
|
||||
}
|
||||
5
app/src/main/java/org/toop/app/widget/Updatable.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package org.toop.app.widget;
|
||||
|
||||
public interface Updatable {
|
||||
void update();
|
||||
}
|
||||
29
app/src/main/java/org/toop/app/widget/Widget.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package org.toop.app.widget;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public interface Widget {
|
||||
Logger logger = LogManager.getLogger(Widget.class);
|
||||
|
||||
Node getNode();
|
||||
|
||||
default void show(Pos position) {
|
||||
logger.debug("Showing Widget: {} at position: {}", this.getNode(), position.toString());
|
||||
WidgetContainer.add(position, this);
|
||||
}
|
||||
|
||||
default void hide() {
|
||||
logger.debug("Hiding Widget: {}", this.getNode());
|
||||
WidgetContainer.remove(this);
|
||||
}
|
||||
|
||||
default void replace(Pos position, Widget widget) {
|
||||
logger.debug("Replacing Widget: {}, with widget: {}, to position: {}",
|
||||
this.getNode(), widget.getNode(), position.toString());
|
||||
widget.show(position);
|
||||
hide();
|
||||
}
|
||||
}
|
||||
148
app/src/main/java/org/toop/app/widget/WidgetContainer.java
Normal file
@@ -0,0 +1,148 @@
|
||||
package org.toop.app.widget;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import org.toop.app.widget.complex.PopupWidget;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.layout.StackPane;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public final class WidgetContainer {
|
||||
private static StackPane root;
|
||||
private static ViewWidget currentView;
|
||||
|
||||
public static synchronized StackPane setup() {
|
||||
if (root != null) {
|
||||
return root;
|
||||
}
|
||||
|
||||
root = new StackPane();
|
||||
root.getStyleClass().add("bg-view");
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
public static void add(Pos position, Widget widget) {
|
||||
if (root == null || widget == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Platform.runLater(() -> {
|
||||
if (root.getChildren().contains(widget.getNode())) {
|
||||
return;
|
||||
}
|
||||
|
||||
StackPane.setAlignment(widget.getNode(), position);
|
||||
|
||||
if (widget instanceof ViewWidget view) {
|
||||
root.getChildren().addFirst(view.getNode());
|
||||
currentView = view;
|
||||
} else if (widget instanceof PopupWidget popup) {
|
||||
currentView.add(Pos.CENTER, (Widget) popup);
|
||||
} else {
|
||||
root.getChildren().add(widget.getNode());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void remove(Widget widget) {
|
||||
if (root == null || widget == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Platform.runLater(() -> {
|
||||
if (widget instanceof PopupWidget popup) {
|
||||
currentView.remove((Widget) popup);
|
||||
} else {
|
||||
root.getChildren().remove(widget.getNode());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void remove(Class<? extends Widget> widgetClass) {
|
||||
if (root == null || currentView == null) return;
|
||||
|
||||
Platform.runLater(() ->
|
||||
currentView.getChildren().removeIf(widget -> widget.getClass().isAssignableFrom(widgetClass))
|
||||
);
|
||||
}
|
||||
|
||||
public static void removeFirst(Class<? extends Widget> widgetClass) {
|
||||
if (root == null || currentView == null) return;
|
||||
|
||||
Platform.runLater(() -> {
|
||||
for (Node widget : currentView.getChildren()) {
|
||||
if (widgetClass.isAssignableFrom(widget.getClass())) {
|
||||
currentView.getChildren().remove(widget);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static List<Widget> find(Class<? extends Widget> widgetClass) {
|
||||
if (root == null || currentView == null) return null;
|
||||
|
||||
return getAllWidgets()
|
||||
.stream()
|
||||
.filter(widget -> widget.getClass().isAssignableFrom(widgetClass))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public static List<Widget> find(Predicate<Widget> predicate) {
|
||||
if (root == null || currentView == null) return null;
|
||||
|
||||
return getAllWidgets()
|
||||
.stream()
|
||||
.filter(predicate)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public static Widget findFirst(Class<? extends Widget> widgetClass) {
|
||||
if (root == null || currentView == null) return null;
|
||||
|
||||
return getAllWidgets()
|
||||
.stream()
|
||||
.filter(widget -> widget.getClass().isAssignableFrom(widgetClass))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static ViewWidget getCurrentView() {
|
||||
return currentView;
|
||||
}
|
||||
|
||||
public static void setCurrentView(ViewWidget view) {
|
||||
if (root == null || view == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Platform.runLater(() -> {
|
||||
root.getChildren().clear();
|
||||
root.getChildren().add(view.getNode());
|
||||
currentView = view;
|
||||
});
|
||||
}
|
||||
|
||||
public static List<Widget> getAllWidgets() {
|
||||
final List<Widget> children = new ArrayList<>();
|
||||
|
||||
for (var child : root.getChildren()) {
|
||||
if (child instanceof Widget widget) {
|
||||
children.add(widget);
|
||||
}
|
||||
}
|
||||
|
||||
for (var child : currentView.getNode().getChildren()) {
|
||||
if (child instanceof Widget widget) {
|
||||
children.add(widget);
|
||||
}
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.toop.app.widget.complex;
|
||||
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.Widget;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
public class ConfirmWidget implements Widget {
|
||||
private final HBox buttonsContainer;
|
||||
private final Text messageText;
|
||||
private final VBox container;
|
||||
|
||||
public ConfirmWidget(String confirm) {
|
||||
buttonsContainer = Primitive.hbox();
|
||||
messageText = Primitive.text("");
|
||||
container = Primitive.vbox(Primitive.header(confirm), messageText, Primitive.separator(), buttonsContainer);
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
messageText.setText(message);
|
||||
}
|
||||
|
||||
public void addButton(String key, Runnable onClick) {
|
||||
Platform.runLater(() -> {
|
||||
var button = Primitive.button(key, onClick);
|
||||
buttonsContainer.getChildren().add(button);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getNode() {
|
||||
return container;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.toop.app.widget.complex;
|
||||
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.Widget;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
public class LabeledChoiceWidget<T> implements Widget {
|
||||
private final ComboBox<T> comboBox;
|
||||
private final VBox container;
|
||||
|
||||
@SafeVarargs
|
||||
public LabeledChoiceWidget(
|
||||
String key,
|
||||
StringConverter<T> converter,
|
||||
T initialValue,
|
||||
Consumer<T> onValueChanged,
|
||||
T... items
|
||||
) {
|
||||
var label = Primitive.text(key);
|
||||
comboBox = Primitive.choice(converter, initialValue, onValueChanged, items);
|
||||
container = Primitive.vbox(label, comboBox);
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
return comboBox.getValue();
|
||||
}
|
||||
|
||||
public void setValue(T value) {
|
||||
comboBox.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getNode() {
|
||||
return container;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.toop.app.widget.complex;
|
||||
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.Widget;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
public class LabeledInputWidget implements Widget {
|
||||
private final TextField input;
|
||||
private final VBox container;
|
||||
|
||||
public LabeledInputWidget(String key, String promptKey, String initialText, Consumer<String> onValueChanged) {
|
||||
var label = Primitive.text(key);
|
||||
input = Primitive.input(promptKey, initialText, onValueChanged);
|
||||
container = Primitive.vbox(label, input);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return input.getText();
|
||||
}
|
||||
|
||||
public void setValue(String text) {
|
||||
input.setText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getNode() {
|
||||
return container;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.toop.app.widget.complex;
|
||||
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.Widget;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Slider;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
public class LabeledSliderWidget implements Widget {
|
||||
private final Slider slider;
|
||||
private final Text labelValue;
|
||||
private final VBox container;
|
||||
|
||||
public LabeledSliderWidget(String key, int min, int max, int value, Consumer<Integer> onValueChanged) {
|
||||
var label = Primitive.text(key);
|
||||
|
||||
labelValue = new Text(String.valueOf(value));
|
||||
labelValue.getStyleClass().add("text");
|
||||
|
||||
slider = Primitive.slider(min, max, value, newValue -> {
|
||||
labelValue.setText(String.valueOf(newValue));
|
||||
|
||||
if (onValueChanged != null) {
|
||||
onValueChanged.accept(newValue);
|
||||
}
|
||||
});
|
||||
|
||||
var sliderRow = Primitive.hbox(slider, labelValue);
|
||||
container = Primitive.vbox(label, sliderRow);
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return (int)slider.getValue();
|
||||
}
|
||||
|
||||
public void setValue(int newValue) {
|
||||
slider.setValue(newValue);
|
||||
labelValue.setText(String.valueOf(newValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getNode() {
|
||||
return container;
|
||||
}
|
||||
}
|
||||
162
app/src/main/java/org/toop/app/widget/complex/LoadingWidget.java
Normal file
@@ -0,0 +1,162 @@
|
||||
package org.toop.app.widget.complex;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.ProgressBar;
|
||||
import javafx.scene.control.ProgressIndicator;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.text.Text;
|
||||
import org.toop.app.widget.Primitive;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class LoadingWidget extends ViewWidget implements Update { // TODO make of widget type
|
||||
private final Text loadingText; // TODO Make changeable
|
||||
private final ProgressIndicator progressBar;
|
||||
private final AtomicBoolean successTriggered = new AtomicBoolean(false);
|
||||
private final AtomicBoolean failureTriggered = new AtomicBoolean(false);
|
||||
|
||||
private Runnable success = () -> {};
|
||||
private Runnable failure = () -> {};
|
||||
private int maxAmount;
|
||||
private int minAmount;
|
||||
private int amount;
|
||||
private Callable<Boolean> successTrigger = () -> (amount >= maxAmount);
|
||||
private Callable<Boolean> failureTrigger = () -> (amount < minAmount);
|
||||
private float percentage = 0.0f;
|
||||
|
||||
private boolean isInfinite = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* Widget that shows a loading bar.
|
||||
*
|
||||
* @param loadingText Text above the loading bar.
|
||||
* @param minAmount The minimum amount.
|
||||
* @param startAmount The starting amount.
|
||||
* @param maxAmount The max amount.
|
||||
*/
|
||||
public LoadingWidget(Text loadingText, int minAmount, int startAmount, int maxAmount, boolean infinite, boolean circle) {
|
||||
isInfinite = infinite;
|
||||
|
||||
this.maxAmount = maxAmount;
|
||||
this.minAmount = minAmount;
|
||||
amount = startAmount;
|
||||
|
||||
this.loadingText = loadingText;
|
||||
progressBar = circle ? new ProgressIndicator() : new ProgressBar();
|
||||
|
||||
VBox box = Primitive.vbox(this.loadingText, progressBar);
|
||||
progressBar.getStyleClass().add("loading-progress-bar");
|
||||
add(Pos.CENTER, box);
|
||||
}
|
||||
|
||||
public void setMaxAmount(int maxAmount) {
|
||||
this.maxAmount = maxAmount;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) throws Exception {
|
||||
this.amount = amount;
|
||||
update();
|
||||
}
|
||||
|
||||
public int getMaxAmount() {
|
||||
return maxAmount;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public float getPercentage() {
|
||||
return percentage;
|
||||
}
|
||||
|
||||
public boolean isTriggered() {
|
||||
return (failureTriggered.get() || successTriggered.get());
|
||||
}
|
||||
|
||||
public ProgressIndicator getProgressBar() {
|
||||
return progressBar;
|
||||
}
|
||||
|
||||
/**
|
||||
* What to do when success is triggered.
|
||||
* @param onSuccess The lambda that gets run on success.
|
||||
*/
|
||||
public void setOnSuccess(Runnable onSuccess) {
|
||||
success = onSuccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* What to do when failure is triggered.
|
||||
* @param onFailure The lambda that gets run on failure.
|
||||
*/
|
||||
public void setOnFailure(Runnable onFailure) {
|
||||
failure = onFailure;
|
||||
}
|
||||
|
||||
/**
|
||||
* The trigger to activate onSuccess.
|
||||
* @param trigger The lambda that triggers onSuccess.
|
||||
*/
|
||||
public void setSuccessTrigger(Callable<Boolean> trigger) {
|
||||
successTrigger = trigger;
|
||||
}
|
||||
|
||||
/**
|
||||
* The trigger to activate onFailure.
|
||||
* @param trigger The lambda that triggers onFailure.
|
||||
*/
|
||||
public void setFailureTrigger(Callable<Boolean> trigger) {
|
||||
failureTrigger = trigger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forcefully trigger success.
|
||||
*/
|
||||
public void triggerSuccess() {
|
||||
if (successTriggered.compareAndSet(false, true)) {
|
||||
Platform.runLater(() -> {
|
||||
if (success != null) success.run();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forcefully trigger failure.
|
||||
*/
|
||||
public void triggerFailure() {
|
||||
if (failureTriggered.compareAndSet(false, true)) {
|
||||
Platform.runLater(() -> {
|
||||
if (failure != null) failure.run();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() throws Exception { // TODO Better exception
|
||||
if (successTriggered.get() || failureTriggered.get()) { // If already triggered, throw exception.
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
if (successTrigger.call()) {
|
||||
triggerSuccess();
|
||||
this.remove((Node) this);
|
||||
return;
|
||||
} else if (failureTrigger.call()) {
|
||||
triggerFailure();
|
||||
this.remove((Node) this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (maxAmount != 0) {
|
||||
percentage = (float) amount / maxAmount;
|
||||
}
|
||||
if (!isInfinite) {
|
||||
progressBar.setProgress(percentage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package org.toop.app.widget.complex;
|
||||
|
||||
import org.toop.app.GameInformation;
|
||||
import org.toop.app.widget.Primitive;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
public class PlayerInfoWidget {
|
||||
private final GameInformation.Player information;
|
||||
private final VBox container;
|
||||
private Text playerName;
|
||||
private boolean hasSet;
|
||||
|
||||
public PlayerInfoWidget(GameInformation.Player information) {
|
||||
this.information = information;
|
||||
container = Primitive.vbox(
|
||||
buildToggle().getNode(),
|
||||
buildContent()
|
||||
);
|
||||
this.playerName = null;
|
||||
}
|
||||
|
||||
private ToggleWidget buildToggle() {
|
||||
return new ToggleWidget(
|
||||
"computer", "player",
|
||||
information.isHuman,
|
||||
isHuman -> {
|
||||
information.isHuman = isHuman;
|
||||
container.getChildren().setAll(
|
||||
buildToggle().getNode(),
|
||||
buildContent()
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private Node buildContent() {
|
||||
|
||||
if (information.isHuman) {
|
||||
var spacer = Primitive.vbox(
|
||||
makeAIButton(0, 0, "zwartepiet"),
|
||||
makeAIButton(0, 0, "sinterklaas"),
|
||||
makeAIButton(0, 0, "santa")
|
||||
); //todo make a better solution
|
||||
spacer.setVisible(false);
|
||||
var nameInput = new LabeledInputWidget(
|
||||
"name",
|
||||
"enter-your-name",
|
||||
information.name,
|
||||
newName -> information.name = newName
|
||||
);
|
||||
|
||||
return Primitive.vbox(spacer,nameInput.getNode());
|
||||
} else {
|
||||
var AIBox = Primitive.vbox(
|
||||
makeAIButton(0, 1, "zwartepiet"),
|
||||
makeAIButton(2, 1, "sinterklaas"),
|
||||
makeAIButton(9, 1, "santa")
|
||||
);
|
||||
|
||||
this.playerName = Primitive.text("");
|
||||
playerName.setText(information.name);
|
||||
|
||||
var nameDisplay = Primitive.vbox(
|
||||
Primitive.text("name"),
|
||||
playerName
|
||||
);
|
||||
|
||||
if (!hasSet) {
|
||||
doDefault();
|
||||
hasSet = true;
|
||||
}
|
||||
|
||||
return Primitive.vbox(
|
||||
AIBox,
|
||||
nameDisplay
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Node getNode() {
|
||||
return container;
|
||||
}
|
||||
|
||||
private Node makeAIButton(int depth, int thinktime, String name) {
|
||||
return Primitive.button(name, () -> {
|
||||
information.name = getName(name);
|
||||
information.computerDifficulty = depth;
|
||||
information.computerThinkTime = thinktime;
|
||||
this.playerName.setText(getName(name));
|
||||
});
|
||||
}
|
||||
|
||||
private String getName(String name) {
|
||||
return switch (name) {
|
||||
case "sinterklaas" -> "Sint. R. Klaas";
|
||||
case "zwartepiet" -> "Zwarte Piet";
|
||||
case "santa" -> "Santa";
|
||||
default -> "Default";
|
||||
};
|
||||
}
|
||||
|
||||
private void doDefault() {
|
||||
information.name = getName("zwartepiet");
|
||||
information.computerDifficulty = 0;
|
||||
information.computerThinkTime = 1;
|
||||
this.playerName.setText(getName("zwartepiet"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.toop.app.widget.complex;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
|
||||
public abstract class PopupWidget extends StackWidget {
|
||||
private final Button popButton;
|
||||
|
||||
public PopupWidget() {
|
||||
super("bg-popup");
|
||||
|
||||
popButton = new Button("X");
|
||||
popButton.setOnAction(_ -> hide());
|
||||
|
||||
add(Pos.TOP_RIGHT, popButton);
|
||||
}
|
||||
|
||||
protected void setOnPop(Runnable onPop) {
|
||||
popButton.setOnAction(_ -> onPop.run());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.toop.app.widget.complex;
|
||||
|
||||
import org.toop.app.widget.Widget;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.layout.StackPane;
|
||||
|
||||
public abstract class StackWidget extends StackPane implements Widget {
|
||||
public StackWidget(String cssClass) {
|
||||
this.getStyleClass().add(cssClass);
|
||||
}
|
||||
|
||||
public void add(Pos position, Node node) {
|
||||
Platform.runLater(() -> {
|
||||
if (this.getChildren().contains(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
StackPane.setAlignment(node, position);
|
||||
this.getChildren().add(node);
|
||||
});
|
||||
}
|
||||
|
||||
public void add(Pos position, Widget widget) {
|
||||
add(position, widget.getNode());
|
||||
}
|
||||
|
||||
public void remove(Node node) {
|
||||
Platform.runLater(() -> {
|
||||
this.getChildren().remove(node);
|
||||
});
|
||||
}
|
||||
|
||||
public void remove(Widget widget) {
|
||||
remove(widget.getNode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackPane getNode() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package org.toop.app.widget.complex;
|
||||
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.Widget;
|
||||
import org.toop.framework.audio.events.AudioEvents;
|
||||
import org.toop.framework.eventbus.EventFlow;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
public class ToggleWidget implements Widget {
|
||||
private final Button button;
|
||||
private final VBox container;
|
||||
|
||||
private final String onKey;
|
||||
private final String offKey;
|
||||
|
||||
private boolean state;
|
||||
|
||||
public ToggleWidget(String onKey, String offKey, boolean initialState, Consumer<Boolean> onToggle) {
|
||||
this.onKey = onKey;
|
||||
this.offKey = offKey;
|
||||
this.state = initialState;
|
||||
|
||||
button = new Button(AppContext.getString(getCurrentKey()));
|
||||
button.setOnAction(_ -> {
|
||||
state = !state;
|
||||
updateText();
|
||||
if (onToggle != null) {
|
||||
onToggle.accept(state);
|
||||
new EventFlow().addPostEvent(new AudioEvents.ClickButton()).postEvent(); // TODO FIX PRIMITIVES
|
||||
}
|
||||
});
|
||||
|
||||
container = Primitive.vbox(button);
|
||||
}
|
||||
|
||||
private String getCurrentKey() {
|
||||
return state? offKey : onKey;
|
||||
}
|
||||
|
||||
private void updateText() {
|
||||
button.setText(AppContext.getString(getCurrentKey()));
|
||||
}
|
||||
|
||||
public boolean getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(boolean newState) {
|
||||
if (state != newState) {
|
||||
state = newState;
|
||||
updateText();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getNode() {
|
||||
return container;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.toop.app.widget.complex;
|
||||
|
||||
public interface Update {
|
||||
void update() throws Exception;
|
||||
}
|
||||
104
app/src/main/java/org/toop/app/widget/complex/ViewWidget.java
Normal file
@@ -0,0 +1,104 @@
|
||||
package org.toop.app.widget.complex;
|
||||
|
||||
import org.toop.app.widget.Primitive;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
|
||||
public abstract class ViewWidget extends StackWidget {
|
||||
private ViewWidget previous = null;
|
||||
|
||||
public ViewWidget() {
|
||||
super("bg-primary");
|
||||
}
|
||||
|
||||
public void transition(ViewWidget view) {
|
||||
view.previous = this;
|
||||
replace(Pos.CENTER, view);
|
||||
}
|
||||
|
||||
public void transitionNext(ViewWidget view) {
|
||||
transitionNext(view, false);
|
||||
}
|
||||
|
||||
public void transitionNext(ViewWidget view, boolean aware) {
|
||||
if (aware && this.getClass().equals(view.getClass())) {
|
||||
view.previous = this.previous;
|
||||
}
|
||||
else{
|
||||
view.previous = this;
|
||||
}
|
||||
|
||||
replace(Pos.CENTER, view);
|
||||
|
||||
var backButton = Primitive.button("back", () -> {
|
||||
view.transitionPrevious();
|
||||
});
|
||||
|
||||
view.add(Pos.BOTTOM_LEFT, Primitive.vbox(backButton));
|
||||
}
|
||||
|
||||
public void transitionNextCustom(ViewWidget view, String key, Runnable runnable) {
|
||||
view.previous = this;
|
||||
|
||||
replace(Pos.CENTER, view);
|
||||
|
||||
var customButton = Primitive.button(key, () -> {
|
||||
runnable.run();
|
||||
view.transitionPrevious();
|
||||
});
|
||||
|
||||
view.add(Pos.BOTTOM_LEFT, Primitive.vbox(customButton));
|
||||
}
|
||||
|
||||
public void transitionPrevious() {
|
||||
if (previous == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
replace(Pos.CENTER, previous);
|
||||
previous = null;
|
||||
}
|
||||
|
||||
public void removeIndexFromPreviousChain(int index) {
|
||||
ViewWidget view = this;
|
||||
|
||||
while (index > 0 && view != null) {
|
||||
index--;
|
||||
|
||||
if (index == 0) {
|
||||
if (view.previous != null && view.previous.previous != null) {
|
||||
view.previous = view.previous.previous;
|
||||
}
|
||||
}
|
||||
|
||||
view = view.previous;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeViewFromPreviousChain(ViewWidget view) {
|
||||
ViewWidget prev = previous;
|
||||
int index = 0;
|
||||
|
||||
while (prev != null) {
|
||||
index++;
|
||||
|
||||
if (prev == view) {
|
||||
removeIndexFromPreviousChain(index);
|
||||
break;
|
||||
}
|
||||
|
||||
prev = prev.previous;
|
||||
}
|
||||
}
|
||||
|
||||
public void reload(ViewWidget view) {
|
||||
view.previous = previous;
|
||||
replace(Pos.CENTER, view);
|
||||
|
||||
var backButton = Primitive.button("back", () -> {
|
||||
view.transitionPrevious();
|
||||
});
|
||||
|
||||
view.add(Pos.BOTTOM_LEFT, Primitive.vbox(backButton));
|
||||
}
|
||||
}
|
||||
117
app/src/main/java/org/toop/app/widget/display/SongDisplay.java
Normal file
@@ -0,0 +1,117 @@
|
||||
package org.toop.app.widget.display;
|
||||
|
||||
import org.toop.app.widget.Widget;
|
||||
import org.toop.framework.audio.events.AudioEvents;
|
||||
import org.toop.framework.eventbus.EventFlow;
|
||||
import org.toop.framework.eventbus.GlobalEventBus;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ProgressBar;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
public class SongDisplay extends VBox implements Widget {
|
||||
private final Text songTitle;
|
||||
private final ProgressBar progressBar;
|
||||
private final Text progressText;
|
||||
|
||||
public SongDisplay() {
|
||||
new EventFlow()
|
||||
.listen(AudioEvents.PlayingMusic.class, this::updateTheSong, false);
|
||||
|
||||
setAlignment(Pos.CENTER);
|
||||
setMaxHeight(Region.USE_PREF_SIZE);
|
||||
getStyleClass().add("song-display");
|
||||
|
||||
// TODO ADD GOOD SONG TITLES WITH ARTISTS DISPLAYED
|
||||
songTitle = new Text("song playing");
|
||||
songTitle.getStyleClass().add("song-title");
|
||||
|
||||
progressBar = new ProgressBar(0);
|
||||
progressBar.getStyleClass().add("loading-progress-bar");
|
||||
|
||||
progressText = new Text("0:00/0:00");
|
||||
progressText.getStyleClass().add("progress-text");
|
||||
|
||||
// TODO ADD BETTER CSS FOR THE SKIPBUTTON WHERE ITS AT A NICER POSITION
|
||||
|
||||
Button skipButton = new Button(">>");
|
||||
Button pauseButton = new Button("⏸");
|
||||
Button previousButton = new Button("<<");
|
||||
|
||||
skipButton.getStyleClass().setAll("skip-button");
|
||||
pauseButton.getStyleClass().setAll("pause-button");
|
||||
previousButton.getStyleClass().setAll("previous-button");
|
||||
|
||||
skipButton.setOnAction( event -> {
|
||||
GlobalEventBus.get().post(new AudioEvents.SkipMusic());
|
||||
});
|
||||
|
||||
pauseButton.setOnAction(event -> {
|
||||
GlobalEventBus.get().post(new AudioEvents.PauseMusic());
|
||||
if (pauseButton.getText().equals("⏸")) {
|
||||
pauseButton.setText("▶");
|
||||
}
|
||||
else if (pauseButton.getText().equals("▶")) {
|
||||
pauseButton.setText("⏸");
|
||||
}
|
||||
});
|
||||
|
||||
previousButton.setOnAction( event -> {
|
||||
GlobalEventBus.get().post(new AudioEvents.PreviousMusic());
|
||||
});
|
||||
|
||||
HBox control = new HBox(10, previousButton, pauseButton, skipButton);
|
||||
control.setAlignment(Pos.CENTER);
|
||||
control.getStyleClass().add("controls");
|
||||
|
||||
getChildren().addAll(songTitle, progressBar, progressText, control);
|
||||
}
|
||||
|
||||
private void updateTheSong(AudioEvents.PlayingMusic event) {
|
||||
Platform.runLater(() -> {
|
||||
String text = event.name();
|
||||
text = text.substring(0, text.length() - 4);
|
||||
songTitle.setText(text);
|
||||
double currentPos = event.currentPosition();
|
||||
double duration = event.duration();
|
||||
if (currentPos / duration > 0.05) {
|
||||
double progress = currentPos / duration;
|
||||
progressBar.setProgress(progress);
|
||||
}
|
||||
else if (currentPos / duration < 0.05) {
|
||||
progressBar.setProgress(0.05);
|
||||
}
|
||||
progressText.setText(getTimeString(event.currentPosition(), event.duration()));
|
||||
});
|
||||
}
|
||||
|
||||
private String getTimeString(long position, long duration) {
|
||||
long positionMinutes = position / 60;
|
||||
long durationMinutes = duration / 60;
|
||||
long positionSeconds = position % 60;
|
||||
long durationSeconds = duration % 60;
|
||||
String positionSecondsStr = String.valueOf(positionSeconds);
|
||||
String durationSecondsStr = String.valueOf(durationSeconds);
|
||||
|
||||
if (positionSeconds < 10) {
|
||||
positionSecondsStr = "0" + positionSeconds;
|
||||
}
|
||||
if (durationSeconds < 10) {
|
||||
durationSecondsStr = "0" + durationSeconds;
|
||||
}
|
||||
|
||||
String time = positionMinutes + ":" + positionSecondsStr + " / " + durationMinutes + ":" + durationSecondsStr;
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getNode() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.toop.app.widget.popup;
|
||||
|
||||
import org.toop.app.GameInformation;
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.complex.PlayerInfoWidget;
|
||||
import org.toop.app.widget.complex.PopupWidget;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
public final class ChallengePopup extends PopupWidget {
|
||||
private final GameInformation.Player playerInformation;
|
||||
private final String challenger;
|
||||
private final String game;
|
||||
private final Consumer<GameInformation.Player> onAccept;
|
||||
|
||||
public ChallengePopup(String challenger, String game, Consumer<GameInformation.Player> onAccept) {
|
||||
this.challenger = challenger;
|
||||
this.game = game;
|
||||
this.onAccept = onAccept;
|
||||
|
||||
this.playerInformation = new GameInformation.Player();
|
||||
|
||||
setupLayout();
|
||||
}
|
||||
|
||||
private void setupLayout() {
|
||||
var challengeText = Primitive.text("you-were-challenged-by");
|
||||
|
||||
var challengerHeader = Primitive.header(challenger, false);
|
||||
|
||||
var toAGameOfText = Primitive.text("to-a-game-of");
|
||||
var gameHeader = Primitive.header(game, false);
|
||||
|
||||
var acceptButton = Primitive.button("accept", () -> {
|
||||
onAccept.accept(playerInformation);
|
||||
this.hide();
|
||||
});
|
||||
var denyButton = Primitive.button("deny", () -> hide());
|
||||
|
||||
var leftSection = Primitive.vbox(
|
||||
challengeText,
|
||||
challengerHeader,
|
||||
toAGameOfText,
|
||||
gameHeader,
|
||||
Primitive.separator(),
|
||||
Primitive.hbox(
|
||||
acceptButton,
|
||||
denyButton
|
||||
)
|
||||
);
|
||||
|
||||
var playerInfoWidget = new PlayerInfoWidget(playerInformation);
|
||||
|
||||
add(Pos.CENTER,
|
||||
Primitive.hbox(
|
||||
leftSection,
|
||||
playerInfoWidget.getNode()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
16
app/src/main/java/org/toop/app/widget/popup/ErrorPopup.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package org.toop.app.widget.popup;
|
||||
|
||||
import org.toop.app.widget.complex.ConfirmWidget;
|
||||
import org.toop.app.widget.complex.PopupWidget;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
|
||||
public class ErrorPopup extends PopupWidget {
|
||||
public ErrorPopup(String error) {
|
||||
var confirmWidget = new ConfirmWidget("error");
|
||||
confirmWidget.setMessage(error);
|
||||
confirmWidget.addButton("ok", this::hide);
|
||||
|
||||
add(Pos.CENTER, confirmWidget);
|
||||
}
|
||||
}
|
||||
48
app/src/main/java/org/toop/app/widget/popup/EscapePopup.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package org.toop.app.widget.popup;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.Widget;
|
||||
import org.toop.app.widget.WidgetContainer;
|
||||
import org.toop.app.widget.complex.PopupWidget;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
import org.toop.app.widget.view.GameView;
|
||||
import org.toop.app.widget.view.OptionsView;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class EscapePopup extends PopupWidget {
|
||||
public EscapePopup() {
|
||||
ViewWidget currentView = WidgetContainer.getCurrentView();
|
||||
ArrayList<Node> nodes = new ArrayList<>();
|
||||
|
||||
nodes.add(Primitive.button("Continue", this::hide, false)); // TODO, localize
|
||||
|
||||
if (!(currentView.getClass().isAssignableFrom(OptionsView.class))) {
|
||||
var opt = Primitive.button("options", () -> {
|
||||
hide();
|
||||
WidgetContainer.getCurrentView().transitionNext(new OptionsView());
|
||||
});
|
||||
nodes.add(opt);
|
||||
}
|
||||
|
||||
if (currentView.getClass().isAssignableFrom(GameView.class)) {
|
||||
Widget tut = AppContext.currentTutorial();
|
||||
if (tut != null) {
|
||||
nodes.add(Primitive.button("tutorialstring", () -> {
|
||||
WidgetContainer.getCurrentView().add(Pos.CENTER, tut);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
nodes.add(Primitive.button("quit", () -> {
|
||||
hide();
|
||||
WidgetContainer.add(Pos.CENTER, new QuitPopup());
|
||||
}));
|
||||
|
||||
add(Pos.CENTER, Primitive.vbox(nodes.toArray(new Node[0])));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.toop.app.widget.popup;
|
||||
|
||||
import org.toop.app.widget.complex.ConfirmWidget;
|
||||
import org.toop.app.widget.complex.PopupWidget;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
|
||||
public final class GameOverPopup extends PopupWidget {
|
||||
public GameOverPopup(boolean winOrTie, String winner) {
|
||||
var confirmWidget = new ConfirmWidget("game-over");
|
||||
|
||||
if (winOrTie) {
|
||||
confirmWidget.setMessage(winner + " won the game!");
|
||||
}
|
||||
else{
|
||||
confirmWidget.setMessage("It was a tie!");
|
||||
}
|
||||
|
||||
confirmWidget.addButton("ok", this::hide);
|
||||
|
||||
add(Pos.CENTER, confirmWidget);
|
||||
}
|
||||
}
|
||||
27
app/src/main/java/org/toop/app/widget/popup/QuitPopup.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package org.toop.app.widget.popup;
|
||||
|
||||
import org.toop.app.App;
|
||||
import org.toop.app.widget.complex.ConfirmWidget;
|
||||
import org.toop.app.widget.complex.PopupWidget;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
|
||||
public class QuitPopup extends PopupWidget {
|
||||
public QuitPopup() {
|
||||
var confirmWidget = new ConfirmWidget("are-you-sure");
|
||||
|
||||
confirmWidget.addButton("yes", () -> {
|
||||
App.quit();
|
||||
});
|
||||
|
||||
confirmWidget.addButton("no", () -> {
|
||||
hide();
|
||||
});
|
||||
|
||||
add(Pos.CENTER, confirmWidget);
|
||||
|
||||
setOnPop(() -> {
|
||||
hide();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package org.toop.app.widget.popup;
|
||||
|
||||
import org.toop.app.GameInformation;
|
||||
import org.toop.app.Server;
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.complex.LabeledChoiceWidget;
|
||||
import org.toop.app.widget.complex.PlayerInfoWidget;
|
||||
import org.toop.app.widget.complex.PopupWidget;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
public final class SendChallengePopup extends PopupWidget {
|
||||
private final Server server;
|
||||
private final String opponent;
|
||||
private final BiConsumer<GameInformation.Player, String> onSend;
|
||||
|
||||
private final GameInformation.Player playerInformation;
|
||||
|
||||
public SendChallengePopup(Server server, String opponent, BiConsumer<GameInformation.Player, String> onSend) {
|
||||
this.server = server;
|
||||
this.opponent = opponent;
|
||||
this.onSend = onSend;
|
||||
|
||||
this.playerInformation = new GameInformation.Player();
|
||||
|
||||
setupLayout();
|
||||
}
|
||||
|
||||
private void setupLayout() {
|
||||
// --- Left side: challenge text and buttons ---
|
||||
var challengeText = Primitive.text("challenge");
|
||||
|
||||
var opponentHeader = Primitive.header(opponent, false);
|
||||
|
||||
var gameText = Primitive.text("to-a-game-of");
|
||||
|
||||
var games = server.getGameList();
|
||||
var gameChoice = new LabeledChoiceWidget<>(
|
||||
"game",
|
||||
new StringConverter<>() {
|
||||
@Override
|
||||
public String toString(String game) {
|
||||
return AppContext.getString(game);
|
||||
}
|
||||
@Override
|
||||
public String fromString(String s) { return null; }
|
||||
},
|
||||
games.getFirst(),
|
||||
newGame -> {
|
||||
playerInformation.computerDifficulty = Math.min(
|
||||
playerInformation.computerDifficulty,
|
||||
Server.gameToType(newGame).getMaxDepth()
|
||||
);
|
||||
},
|
||||
games.toArray(new String[0])
|
||||
);
|
||||
|
||||
var sendButton = Primitive.button(
|
||||
"send",
|
||||
() -> { onSend.accept(playerInformation, gameChoice.getValue()); this.hide(); }
|
||||
);
|
||||
|
||||
var cancelButton = Primitive.button("cancel", () -> hide());
|
||||
|
||||
var leftSection = Primitive.vbox(
|
||||
challengeText,
|
||||
opponentHeader,
|
||||
gameText,
|
||||
gameChoice.getNode(),
|
||||
Primitive.separator(),
|
||||
Primitive.hbox(
|
||||
sendButton,
|
||||
cancelButton
|
||||
)
|
||||
);
|
||||
|
||||
var playerInfoWidget = new PlayerInfoWidget(playerInformation);
|
||||
|
||||
add(Pos.CENTER,
|
||||
Primitive.hbox(
|
||||
leftSection,
|
||||
playerInfoWidget.getNode()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package org.toop.app.widget.tutorial;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.text.Text;
|
||||
import org.apache.maven.surefire.shared.lang3.tuple.ImmutablePair;
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.Updatable;
|
||||
import org.toop.app.widget.complex.PopupWidget;
|
||||
|
||||
import org.toop.framework.resource.resources.ImageAsset;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A widget base for all the tutorial widgets.
|
||||
*
|
||||
* <p>Usage example:
|
||||
*
|
||||
* <pre>{@code
|
||||
* public class Connect4TutorialWidget extends BaseTutorialWidget {
|
||||
* public Connect4TutorialWidget(Runnable nextScreen) {
|
||||
* super(List.of(
|
||||
* new ImmutablePair<>("connect4.1", ResourceManager.get("connect41.png")),
|
||||
* new ImmutablePair<>("connect4.2", ResourceManager.get("connect42.png"))
|
||||
* ), nextScreen);
|
||||
* }
|
||||
* }</pre>
|
||||
*/
|
||||
public class BaseTutorialWidget extends PopupWidget implements Updatable {
|
||||
|
||||
private final Text tutorialText;
|
||||
private final ImageView imagery;
|
||||
private final Button previousButton;
|
||||
private final Button nextButton;
|
||||
private final List<ImmutablePair<String, ImageAsset>> pages;
|
||||
private final Runnable nextScreen;
|
||||
|
||||
private int pageIndex = 0;
|
||||
|
||||
public BaseTutorialWidget(List<ImmutablePair<String, ImageAsset>> pages, Runnable nextScreen) {
|
||||
this.tutorialText = Primitive.text(pages.getFirst().getKey());
|
||||
this.imagery = Primitive.image(pages.getFirst().getValue());
|
||||
|
||||
this.pages = pages;
|
||||
this.nextScreen = nextScreen;
|
||||
|
||||
previousButton = Primitive.button("goback", () -> { update(false); this.hide(); });
|
||||
nextButton = Primitive.button(">", () -> update(true));
|
||||
|
||||
var w = Primitive.hbox(
|
||||
previousButton,
|
||||
nextButton
|
||||
);
|
||||
|
||||
var x = Primitive.vbox(imagery, tutorialText);
|
||||
|
||||
add(Pos.CENTER, Primitive.vbox(x, w));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
update(true);
|
||||
}
|
||||
|
||||
// TODO Refactor if statements to make code easier to read.
|
||||
public void update(boolean next) {
|
||||
pageIndex = next ? pageIndex + 1 : pageIndex - 1;
|
||||
|
||||
if (pageIndex >= pages.size()) {
|
||||
pageIndex--;
|
||||
return;
|
||||
} else if (pageIndex < 0) {
|
||||
pageIndex++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (pageIndex == pages.size()-1) {
|
||||
nextButton.textProperty().unbind();
|
||||
nextButton.setText(AppContext.getString("startgame"));
|
||||
nextButton.setOnAction((_) -> {
|
||||
this.hide();
|
||||
nextScreen.run();
|
||||
});
|
||||
} else {
|
||||
nextButton.textProperty().unbind();
|
||||
nextButton.setText(AppContext.getString(">"));
|
||||
nextButton.setOnAction((_) -> this.update(true));
|
||||
}
|
||||
|
||||
if (pageIndex == 0) {
|
||||
previousButton.textProperty().unbind();
|
||||
previousButton.setText(AppContext.getString("goback"));
|
||||
previousButton.setOnAction((_) -> this.hide());
|
||||
} else {
|
||||
previousButton.textProperty().unbind();
|
||||
previousButton.setText(AppContext.getString("<"));
|
||||
previousButton.setOnAction((_) -> this.update(false));
|
||||
}
|
||||
|
||||
var currentPage = pages.get(pageIndex);
|
||||
|
||||
var text = currentPage.getKey();
|
||||
var image = currentPage.getValue();
|
||||
|
||||
tutorialText.textProperty().unbind();
|
||||
tutorialText.setText(AppContext.getString(text));
|
||||
imagery.setImage(Primitive.image(image).getImage());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.toop.app.widget.tutorial;
|
||||
|
||||
import org.apache.maven.surefire.shared.lang3.tuple.ImmutablePair;
|
||||
import org.toop.framework.resource.ResourceManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Connect4TutorialWidget extends BaseTutorialWidget {
|
||||
public Connect4TutorialWidget(Runnable nextScreen) {
|
||||
super(List.of(
|
||||
new ImmutablePair<>("connect4.1", ResourceManager.get("connect41.png")),
|
||||
new ImmutablePair<>("connect4.2", ResourceManager.get("connect42.png"))
|
||||
), nextScreen);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.toop.app.widget.tutorial;
|
||||
|
||||
import org.apache.maven.surefire.shared.lang3.tuple.ImmutablePair;
|
||||
import org.toop.framework.resource.ResourceManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReversiTutorialWidget extends BaseTutorialWidget {
|
||||
public ReversiTutorialWidget(Runnable nextScreen) {
|
||||
super(List.of(
|
||||
new ImmutablePair<>("reversi1", ResourceManager.get("reversi1.png")),
|
||||
new ImmutablePair<>("reversi2", ResourceManager.get("reversi2.png")),
|
||||
new ImmutablePair<>("reversi3", ResourceManager.get("cat.jpg")),
|
||||
new ImmutablePair<>("reversi4", ResourceManager.get("cat.jpg"))
|
||||
), nextScreen);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.toop.app.widget.tutorial;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.WidgetContainer;
|
||||
import org.toop.app.widget.complex.PopupWidget;
|
||||
import org.toop.local.AppSettings;
|
||||
|
||||
public class ShowEnableTutorialWidget extends PopupWidget {
|
||||
|
||||
public ShowEnableTutorialWidget(Runnable tutorial, Runnable nextScreen, Runnable appSettingsSetter) {
|
||||
var a = Primitive.hbox(
|
||||
Primitive.button("ok", () -> { appSettingsSetter.run(); tutorial.run(); this.hide(); }),
|
||||
Primitive.button("no", () -> { appSettingsSetter.run(); nextScreen.run(); this.hide(); }),
|
||||
Primitive.button("never", () -> { AppSettings.getSettings().setTutorialFlag(false); nextScreen.run(); this.hide(); })
|
||||
);
|
||||
|
||||
var txt = Primitive.text("tutorial");
|
||||
add(Pos.CENTER, Primitive.vbox(txt, a));
|
||||
WidgetContainer.add(Pos.CENTER, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.toop.app.widget.tutorial;
|
||||
|
||||
import org.apache.maven.surefire.shared.lang3.tuple.ImmutablePair;
|
||||
import org.toop.framework.resource.ResourceManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TicTacToeTutorialWidget extends BaseTutorialWidget {
|
||||
public TicTacToeTutorialWidget(Runnable nextScreen) {
|
||||
super(List.of(
|
||||
new ImmutablePair<>("tictactoe1", ResourceManager.get("tictactoe1.png")),
|
||||
new ImmutablePair<>("tictactoe2", ResourceManager.get("tictactoe2.png"))
|
||||
), nextScreen);
|
||||
}
|
||||
|
||||
}
|
||||
81
app/src/main/java/org/toop/app/widget/view/CreditsView.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package org.toop.app.widget.view;
|
||||
|
||||
import org.toop.app.App;
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.KeyValue;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class CreditsView extends ViewWidget {
|
||||
public CreditsView() {
|
||||
var scrumMasterCredit = newCredit("scrum-master", "Stef");
|
||||
var productOwnerCredit = newCredit("product-owner", "Omar");
|
||||
var mergeCommanderCredit = newCredit("merge-commander", "Bas");
|
||||
var localizationCredit = newCredit("localization", "Ticho");
|
||||
var aiCredit = newCredit("ai", "Michiel");
|
||||
var developersCredit = newCredit("developers", "Michiel, Bas, Stef, Omar, Ticho");
|
||||
var moralSupportCredit = newCredit("moral-support", "Wesley");
|
||||
var openglCredit = newCredit("opengl", "Omar");
|
||||
|
||||
var topSpacer = new Region();
|
||||
topSpacer.setPrefHeight(App.getHeight());
|
||||
|
||||
var bottomSpacer = new Region();
|
||||
bottomSpacer.setPrefHeight(App.getHeight());
|
||||
|
||||
var creditsContainer = Primitive.vbox(
|
||||
topSpacer,
|
||||
|
||||
scrumMasterCredit,
|
||||
productOwnerCredit,
|
||||
mergeCommanderCredit,
|
||||
localizationCredit,
|
||||
aiCredit,
|
||||
developersCredit,
|
||||
moralSupportCredit,
|
||||
openglCredit,
|
||||
|
||||
bottomSpacer
|
||||
);
|
||||
|
||||
var creditsScroll = Primitive.scroll(creditsContainer);
|
||||
|
||||
creditsScroll.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
|
||||
creditsScroll.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
|
||||
|
||||
add(Pos.CENTER, creditsScroll);
|
||||
|
||||
animate(creditsScroll, 15);
|
||||
}
|
||||
|
||||
private HBox newCredit(String key, String other) {
|
||||
var credit = new Text(": " + other);
|
||||
credit.getStyleClass().add("header");
|
||||
|
||||
var creditBox = Primitive.hbox(
|
||||
Primitive.header(key),
|
||||
credit
|
||||
);
|
||||
|
||||
creditBox.setPrefHeight(App.getHeight() / 3.0);
|
||||
return creditBox;
|
||||
}
|
||||
|
||||
private void animate(ScrollPane scroll, int length) {
|
||||
final Timeline timeline = new Timeline(
|
||||
new KeyFrame(Duration.seconds(0), new KeyValue(scroll.vvalueProperty(), 0.0)),
|
||||
new KeyFrame(Duration.seconds(length), new KeyValue(scroll.vvalueProperty(), 1.0))
|
||||
);
|
||||
|
||||
timeline.setCycleCount(Timeline.INDEFINITE);
|
||||
timeline.play();
|
||||
}
|
||||
}
|
||||
179
app/src/main/java/org/toop/app/widget/view/GameView.java
Normal file
@@ -0,0 +1,179 @@
|
||||
package org.toop.app.widget.view;
|
||||
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.scene.text.Font;
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
import org.toop.app.widget.popup.GameOverPopup;
|
||||
import java.util.function.Consumer;
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.text.Text;
|
||||
import org.toop.app.widget.tutorial.Connect4TutorialWidget;
|
||||
import org.toop.app.widget.tutorial.ReversiTutorialWidget;
|
||||
import org.toop.app.widget.tutorial.TicTacToeTutorialWidget;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
public final class GameView extends ViewWidget {
|
||||
private final Text playerHeader;
|
||||
private final Text turnHeader;
|
||||
private final Text player1Header;
|
||||
private final Text player2Header;
|
||||
private Circle player1Icon;
|
||||
private Circle player2Icon;
|
||||
private final Button forfeitButton;
|
||||
private final Button exitButton;
|
||||
private final TextField chatInput;
|
||||
private final Text keyThingy;
|
||||
private boolean hasSet = false;
|
||||
|
||||
public GameView(Runnable onForfeit, Runnable onExit, Consumer<String> onMessage, String gameType) {
|
||||
playerHeader = Primitive.header("");
|
||||
turnHeader = Primitive.header("");
|
||||
keyThingy = Primitive.text("turnof");
|
||||
player1Header = Primitive.header("");
|
||||
player2Header = Primitive.header("");
|
||||
player1Icon = new Circle();
|
||||
player2Icon = new Circle();
|
||||
|
||||
if (onForfeit != null) {
|
||||
forfeitButton = Primitive.button("forfeit", () -> onForfeit.run());
|
||||
} else {
|
||||
forfeitButton = null;
|
||||
}
|
||||
|
||||
exitButton = Primitive.button("exit", () -> {
|
||||
onExit.run();
|
||||
transitionPrevious();
|
||||
});
|
||||
|
||||
if (onMessage != null) {
|
||||
chatInput = Primitive.input("enter-your-message", "", null);
|
||||
chatInput.setOnAction(_ -> {
|
||||
onMessage.accept(chatInput.getText());
|
||||
chatInput.clear();
|
||||
});
|
||||
} else {
|
||||
chatInput = null;
|
||||
}
|
||||
|
||||
switch (gameType) {
|
||||
case "TicTacToe":
|
||||
AppContext.setCurrentTutorial(new TicTacToeTutorialWidget(() -> {}));
|
||||
break;
|
||||
case "Reversi":
|
||||
AppContext.setCurrentTutorial(new ReversiTutorialWidget(() -> {}));
|
||||
break;
|
||||
case "Connect4":
|
||||
AppContext.setCurrentTutorial(new Connect4TutorialWidget(() -> {}));
|
||||
break;
|
||||
}
|
||||
|
||||
setupLayout();
|
||||
}
|
||||
|
||||
private void setupLayout() {
|
||||
var turnInfo = Primitive.vbox(
|
||||
turnHeader
|
||||
);
|
||||
|
||||
add(Pos.TOP_CENTER, turnInfo);
|
||||
|
||||
var buttons = Primitive.vbox(
|
||||
forfeitButton,
|
||||
exitButton
|
||||
);
|
||||
|
||||
add(Pos.BOTTOM_LEFT, buttons);
|
||||
|
||||
if (chatInput != null) {
|
||||
add(Pos.BOTTOM_RIGHT, Primitive.vbox(chatInput));
|
||||
}
|
||||
}
|
||||
|
||||
public void nextPlayer(boolean isMe, String currentPlayer, String currentMove, String nextPlayer, char GameType) {
|
||||
Platform.runLater(() -> {
|
||||
if (!(hasSet)) {
|
||||
playerHeader.setText(currentPlayer + " vs. " + nextPlayer);
|
||||
hasSet = true;
|
||||
setPlayerHeaders(isMe, currentPlayer, nextPlayer, GameType);
|
||||
}
|
||||
//TODO idk if theres any way to check this? only EN uses 's and the rest doesnt. if theres a better way to do this pls let me know
|
||||
if (AppContext.getLocale().toLanguageTag().equals("en")) {
|
||||
turnHeader.setText(currentPlayer + keyThingy.getText());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void gameOver(boolean iWon, String winner) {
|
||||
new GameOverPopup(iWon, winner).show(Pos.CENTER);
|
||||
}
|
||||
|
||||
private void setPlayerHeaders(boolean isMe, String currentPlayer, String nextPlayer, char GameType) {
|
||||
if (GameType == 'T') {
|
||||
if (isMe) {
|
||||
player1Header.setText("X: " + currentPlayer);
|
||||
player2Header.setText("O: " + nextPlayer);
|
||||
}
|
||||
else {
|
||||
player1Header.setText("X: " + nextPlayer);
|
||||
player2Header.setText("O: " + currentPlayer);
|
||||
}
|
||||
setPlayerInfoTTT();
|
||||
}
|
||||
else if (GameType == 'R') {
|
||||
if (isMe) {
|
||||
player1Header.setText(currentPlayer);
|
||||
player2Header.setText(nextPlayer);
|
||||
}
|
||||
else {
|
||||
player1Header.setText(nextPlayer);
|
||||
player2Header.setText(currentPlayer);
|
||||
}
|
||||
setPlayerInfoReversi();
|
||||
}
|
||||
}
|
||||
|
||||
private void setPlayerInfoTTT() {
|
||||
var playerInfo = Primitive.vbox(
|
||||
playerHeader,
|
||||
Primitive.separator(),
|
||||
player1Header,
|
||||
player2Header
|
||||
);
|
||||
|
||||
add(Pos.TOP_RIGHT, playerInfo);
|
||||
}
|
||||
|
||||
private void setPlayerInfoReversi() {
|
||||
var player1box = Primitive.hbox(
|
||||
player1Icon,
|
||||
player1Header
|
||||
);
|
||||
|
||||
player1box.getStyleClass().add("hboxspacing");
|
||||
|
||||
var player2box = Primitive.hbox(
|
||||
player2Icon,
|
||||
player2Header
|
||||
);
|
||||
|
||||
player2box.getStyleClass().add("hboxspacing");
|
||||
|
||||
var playerInfo = Primitive.vbox(
|
||||
playerHeader,
|
||||
Primitive.separator(),
|
||||
player1box,
|
||||
player2box
|
||||
);
|
||||
|
||||
player1Icon.setRadius(player1Header.fontProperty().map(Font::getSize).getValue());
|
||||
player2Icon.setRadius(player2Header.fontProperty().map(Font::getSize).getValue());
|
||||
player1Icon.setFill(Color.BLACK);
|
||||
player2Icon.setFill(Color.WHITE);
|
||||
add(Pos.TOP_RIGHT, playerInfo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package org.toop.app.widget.view;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import org.toop.app.GameInformation;
|
||||
import org.toop.app.canvas.ReversiBitCanvas;
|
||||
import org.toop.app.canvas.TicTacToeBitCanvas;
|
||||
import org.toop.app.gameControllers.GenericGameController;
|
||||
import org.toop.app.gameControllers.ReversiBitController;
|
||||
import org.toop.app.gameControllers.TicTacToeBitController;
|
||||
import org.toop.framework.gameFramework.controller.GameController;
|
||||
import org.toop.framework.gameFramework.model.player.Player;
|
||||
import org.toop.game.games.reversi.BitboardReversi;
|
||||
import org.toop.game.games.tictactoe.BitboardTicTacToe;
|
||||
import org.toop.game.players.ArtificialPlayer;
|
||||
import org.toop.game.players.LocalPlayer;
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.complex.PlayerInfoWidget;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
import org.toop.app.widget.popup.ErrorPopup;
|
||||
import org.toop.app.widget.tutorial.*;
|
||||
import org.toop.game.players.MiniMaxAI;
|
||||
import org.toop.game.players.RandomAI;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import org.toop.local.AppSettings;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
public class LocalMultiplayerView extends ViewWidget {
|
||||
private final GameInformation information;
|
||||
|
||||
private GameController gameController;
|
||||
|
||||
public LocalMultiplayerView(GameInformation.Type type) {
|
||||
this(new GameInformation(type));
|
||||
}
|
||||
|
||||
public LocalMultiplayerView(GameInformation information) {
|
||||
this.information = information;
|
||||
var playButton = Primitive.button("play", () -> {
|
||||
if (gameController != null) {
|
||||
gameController.stop();
|
||||
}
|
||||
for (var player : information.players) {
|
||||
if (player.isHuman && player.name.isEmpty()) {
|
||||
new ErrorPopup(AppContext.getString("please-enter-your-name")).show(Pos.CENTER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Fix this temporary ass way of setting the players
|
||||
Player[] players = new Player[2];
|
||||
|
||||
switch (information.type) {
|
||||
case TICTACTOE:
|
||||
if (information.players[0].isHuman) {
|
||||
players[0] = new LocalPlayer<>(information.players[0].name);
|
||||
} else {
|
||||
players[0] = new ArtificialPlayer<>(new RandomAI<BitboardTicTacToe>(), "Random AI");
|
||||
}
|
||||
if (information.players[1].isHuman) {
|
||||
players[1] = new LocalPlayer<>(information.players[1].name);
|
||||
} else {
|
||||
players[1] = new ArtificialPlayer<>(new MiniMaxAI<BitboardTicTacToe>(9), "MiniMax AI");
|
||||
}
|
||||
if (AppSettings.getSettings().getTutorialFlag() && AppSettings.getSettings().getFirstTTT()) {
|
||||
new ShowEnableTutorialWidget(
|
||||
() -> new TicTacToeTutorialWidget(() -> {
|
||||
gameController = new TicTacToeBitController(players);
|
||||
gameController.start();
|
||||
}),
|
||||
() -> Platform.runLater(() -> {
|
||||
gameController = new TicTacToeBitController(players);
|
||||
gameController.start();
|
||||
}),
|
||||
() -> AppSettings.getSettings().setFirstTTT(false)
|
||||
);
|
||||
} else {
|
||||
gameController = new TicTacToeBitController(players);
|
||||
gameController.start();
|
||||
}
|
||||
break;
|
||||
case REVERSI:
|
||||
if (information.players[0].isHuman) {
|
||||
players[0] = new LocalPlayer<>(information.players[0].name);
|
||||
} else {
|
||||
players[0] = new ArtificialPlayer<>(new RandomAI<BitboardReversi>(), "Random AI");
|
||||
}
|
||||
if (information.players[1].isHuman) {
|
||||
players[1] = new LocalPlayer<>(information.players[1].name);
|
||||
} else {
|
||||
players[1] = new ArtificialPlayer<>(new MiniMaxAI<BitboardReversi>(6), "MiniMax");
|
||||
}
|
||||
if (AppSettings.getSettings().getTutorialFlag() && AppSettings.getSettings().getFirstReversi()) {
|
||||
new ShowEnableTutorialWidget(
|
||||
() -> new ReversiTutorialWidget(() -> {
|
||||
gameController = new ReversiBitController(players);
|
||||
gameController.start();
|
||||
}),
|
||||
() -> Platform.runLater(() -> {
|
||||
gameController = new ReversiBitController(players);
|
||||
gameController.start();
|
||||
}),
|
||||
() -> AppSettings.getSettings().setFirstReversi(false)
|
||||
);
|
||||
} else {
|
||||
gameController = new ReversiBitController(players);
|
||||
gameController.start();
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
var playerSection = setupPlayerSections();
|
||||
|
||||
add(Pos.CENTER, Primitive.vbox(
|
||||
playerSection,
|
||||
Primitive.separator(),
|
||||
playButton
|
||||
));
|
||||
}
|
||||
|
||||
private ScrollPane setupPlayerSections() {
|
||||
int playerCount = information.type.getPlayerCount();
|
||||
VBox[] playerBoxes = new VBox[playerCount];
|
||||
|
||||
for (int i = 0; i < playerCount; i++) {
|
||||
var player = information.players[i];
|
||||
|
||||
var playerHeader = Primitive.header("");
|
||||
playerHeader.setText("player" + " #" + (i + 1));
|
||||
|
||||
var playerWidget = new PlayerInfoWidget(player);
|
||||
|
||||
playerBoxes[i] = Primitive.vbox(
|
||||
playerHeader,
|
||||
Primitive.separator(),
|
||||
playerWidget.getNode()
|
||||
);
|
||||
}
|
||||
|
||||
return Primitive.scroll(Primitive.hbox(
|
||||
playerBoxes
|
||||
));
|
||||
}
|
||||
}
|
||||
24
app/src/main/java/org/toop/app/widget/view/LocalView.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package org.toop.app.widget.view;
|
||||
|
||||
import org.toop.app.GameInformation;
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
|
||||
public class LocalView extends ViewWidget {
|
||||
public LocalView() {
|
||||
var ticTacToeButton = Primitive.button("tic-tac-toe", () -> {
|
||||
transitionNext(new LocalMultiplayerView(GameInformation.Type.TICTACTOE));
|
||||
});
|
||||
|
||||
var reversiButton = Primitive.button("reversi", () -> {
|
||||
transitionNext(new LocalMultiplayerView(GameInformation.Type.REVERSI));
|
||||
});
|
||||
|
||||
add(Pos.CENTER, Primitive.vbox(
|
||||
ticTacToeButton,
|
||||
reversiButton
|
||||
));
|
||||
}
|
||||
}
|
||||
39
app/src/main/java/org/toop/app/widget/view/MainView.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package org.toop.app.widget.view;
|
||||
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
import javafx.geometry.Pos;
|
||||
import org.toop.app.widget.popup.QuitPopup;
|
||||
|
||||
public class MainView extends ViewWidget {
|
||||
public MainView() {
|
||||
var localButton = Primitive.button("local", () -> {
|
||||
transitionNext(new LocalView());
|
||||
});
|
||||
|
||||
var onlineButton = Primitive.button("online", () -> {
|
||||
transitionNext(new OnlineView());
|
||||
});
|
||||
|
||||
var creditsButton = Primitive.button("credits", () -> {
|
||||
transitionNext(new CreditsView());
|
||||
});
|
||||
|
||||
var optionsButton = Primitive.button("options", () -> {
|
||||
transitionNext(new OptionsView());
|
||||
});
|
||||
|
||||
var quitButton = Primitive.button("quit", () -> {
|
||||
var a = new QuitPopup();
|
||||
a.show(Pos.CENTER);
|
||||
});
|
||||
|
||||
add(Pos.CENTER, Primitive.vbox(
|
||||
localButton,
|
||||
onlineButton,
|
||||
creditsButton,
|
||||
optionsButton,
|
||||
quitButton
|
||||
));
|
||||
}
|
||||
}
|
||||
38
app/src/main/java/org/toop/app/widget/view/OnlineView.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package org.toop.app.widget.view;
|
||||
|
||||
import org.toop.app.Server;
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.complex.LabeledInputWidget;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
|
||||
public class OnlineView extends ViewWidget {
|
||||
public OnlineView() {
|
||||
var serverInformationHeader = Primitive.header("server-information");
|
||||
|
||||
var serverIPInput = new LabeledInputWidget("ip-address", "enter-the-server-ip", "", _ -> {});
|
||||
var serverPortInput = new LabeledInputWidget("port", "enter-the-server-port", "", _ -> {});
|
||||
var playerNameInput = new LabeledInputWidget("player-name", "enter-your-name", "", _ -> {});
|
||||
|
||||
var connectButton = Primitive.button("connect", () -> {
|
||||
new Server(
|
||||
serverIPInput.getValue(),
|
||||
serverPortInput.getValue(),
|
||||
playerNameInput.getValue()
|
||||
);
|
||||
});
|
||||
|
||||
add(Pos.CENTER, Primitive.vbox(
|
||||
serverInformationHeader,
|
||||
Primitive.separator(),
|
||||
|
||||
serverIPInput.getNode(),
|
||||
serverPortInput.getNode(),
|
||||
playerNameInput.getNode(),
|
||||
Primitive.separator(),
|
||||
|
||||
connectButton
|
||||
));
|
||||
}
|
||||
}
|
||||
161
app/src/main/java/org/toop/app/widget/view/OptionsView.java
Normal file
@@ -0,0 +1,161 @@
|
||||
package org.toop.app.widget.view;
|
||||
|
||||
import org.toop.app.App;
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.complex.LabeledChoiceWidget;
|
||||
import org.toop.app.widget.complex.LabeledSliderWidget;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
import org.toop.app.widget.complex.ToggleWidget;
|
||||
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 java.util.Locale;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
public class OptionsView extends ViewWidget {
|
||||
public OptionsView() {
|
||||
add(Pos.CENTER, Primitive.hbox(
|
||||
generalSection(),
|
||||
volumeSection(),
|
||||
styleSection()
|
||||
));
|
||||
}
|
||||
|
||||
private VBox generalSection() {
|
||||
var languageWidget = new LabeledChoiceWidget<>(
|
||||
"language",
|
||||
new StringConverter<>() {
|
||||
@Override
|
||||
public String toString(Locale locale) {
|
||||
return AppContext.getString(locale.getDisplayName().toLowerCase());
|
||||
}
|
||||
@Override
|
||||
public Locale fromString(String s) { return null; }
|
||||
},
|
||||
AppContext.getLocale(),
|
||||
newLocale -> {
|
||||
AppSettings.getSettings().setLocale(newLocale.toString());
|
||||
AppContext.setLocale(newLocale);
|
||||
reload(new OptionsView());
|
||||
},
|
||||
AppContext.getLocalization().getAvailableLocales().toArray(new Locale[0])
|
||||
);
|
||||
|
||||
var fullscreenToggle = new ToggleWidget(
|
||||
"fullscreen", "windowed",
|
||||
AppSettings.getSettings().getFullscreen(),
|
||||
fullscreen -> {
|
||||
AppSettings.getSettings().setFullscreen(fullscreen);
|
||||
App.setFullscreen(fullscreen);
|
||||
}
|
||||
);
|
||||
|
||||
return Primitive.vbox(
|
||||
Primitive.header("general"),
|
||||
Primitive.separator(),
|
||||
|
||||
languageWidget.getNode(),
|
||||
fullscreenToggle.getNode()
|
||||
);
|
||||
}
|
||||
|
||||
private VBox volumeSection() {
|
||||
var masterVolumeWidget = new LabeledSliderWidget(
|
||||
"master-volume",
|
||||
0, 100,
|
||||
AppSettings.getSettings().getVolume(),
|
||||
val -> {
|
||||
AppSettings.getSettings().setVolume(val);
|
||||
new EventFlow()
|
||||
.addPostEvent(new AudioEvents.ChangeVolume(val, VolumeControl.MASTERVOLUME))
|
||||
.postEvent();
|
||||
}
|
||||
);
|
||||
|
||||
var effectsVolumeWidget = new LabeledSliderWidget(
|
||||
"effects-volume",
|
||||
0, 100,
|
||||
AppSettings.getSettings().getFxVolume(),
|
||||
val -> {
|
||||
AppSettings.getSettings().setFxVolume(val);
|
||||
new EventFlow()
|
||||
.addPostEvent(new AudioEvents.ChangeVolume(val, VolumeControl.FX))
|
||||
.postEvent();
|
||||
}
|
||||
);
|
||||
|
||||
var musicVolumeWidget = new LabeledSliderWidget(
|
||||
"music-volume",
|
||||
0, 100,
|
||||
AppSettings.getSettings().getMusicVolume(),
|
||||
val -> {
|
||||
AppSettings.getSettings().setMusicVolume(val);
|
||||
new EventFlow()
|
||||
.addPostEvent(new AudioEvents.ChangeVolume(val, VolumeControl.MUSIC))
|
||||
.postEvent();
|
||||
}
|
||||
);
|
||||
|
||||
return Primitive.vbox(
|
||||
Primitive.header("volume"),
|
||||
Primitive.separator(),
|
||||
|
||||
masterVolumeWidget.getNode(),
|
||||
effectsVolumeWidget.getNode(),
|
||||
musicVolumeWidget.getNode()
|
||||
);
|
||||
}
|
||||
|
||||
private VBox styleSection() {
|
||||
var themeWidget = new LabeledChoiceWidget<>(
|
||||
"theme",
|
||||
new StringConverter<>() {
|
||||
@Override
|
||||
public String toString(String theme) {
|
||||
return AppContext.getString(theme);
|
||||
}
|
||||
@Override
|
||||
public String fromString(String s) { return null; }
|
||||
},
|
||||
AppSettings.getSettings().getTheme(),
|
||||
newTheme -> {
|
||||
AppSettings.getSettings().setTheme(newTheme);
|
||||
App.setStyle(newTheme, AppSettings.getSettings().getLayoutSize());
|
||||
},
|
||||
"dark", "light", "high-contrast"
|
||||
);
|
||||
|
||||
var layoutWidget = new LabeledChoiceWidget<>(
|
||||
"layout-size",
|
||||
new StringConverter<>() {
|
||||
@Override
|
||||
public String toString(String layout) {
|
||||
return AppContext.getString(layout);
|
||||
}
|
||||
@Override
|
||||
public String fromString(String s) { return null; }
|
||||
},
|
||||
AppSettings.getSettings().getLayoutSize(),
|
||||
newLayout -> {
|
||||
AppSettings.getSettings().setLayoutSize(newLayout);
|
||||
App.setStyle(AppSettings.getSettings().getTheme(), newLayout);
|
||||
},
|
||||
"small", "medium", "large"
|
||||
);
|
||||
|
||||
|
||||
return Primitive.vbox(
|
||||
Primitive.header("style"),
|
||||
Primitive.separator(),
|
||||
|
||||
themeWidget.getNode(),
|
||||
layoutWidget.getNode()
|
||||
);
|
||||
}
|
||||
}
|
||||
57
app/src/main/java/org/toop/app/widget/view/ServerView.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package org.toop.app.widget.view;
|
||||
|
||||
import org.toop.app.widget.Primitive;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ListView;
|
||||
|
||||
public final class ServerView extends ViewWidget {
|
||||
private final String user;
|
||||
private final Consumer<String> onPlayerClicked;
|
||||
|
||||
private final ListView<Button> listView;
|
||||
|
||||
public ServerView(String user, Consumer<String> onPlayerClicked) {
|
||||
this.user = user;
|
||||
this.onPlayerClicked = onPlayerClicked;
|
||||
|
||||
this.listView = new ListView<>();
|
||||
|
||||
setupLayout();
|
||||
}
|
||||
|
||||
private void setupLayout() {
|
||||
var playerHeader = Primitive.header(user, false);
|
||||
|
||||
var playerListSection = Primitive.vbox(
|
||||
playerHeader,
|
||||
Primitive.separator(),
|
||||
listView
|
||||
);
|
||||
|
||||
add(Pos.CENTER, playerListSection);
|
||||
|
||||
var disconnectButton = Primitive.button("disconnect", () -> {
|
||||
transitionPrevious();
|
||||
});
|
||||
|
||||
add(Pos.BOTTOM_LEFT, Primitive.vbox(disconnectButton));
|
||||
}
|
||||
|
||||
public void update(List<String> players) {
|
||||
Platform.runLater(() -> {
|
||||
listView.getItems().clear();
|
||||
|
||||
for (String player : players) {
|
||||
var playerButton = Primitive.button(player, () -> onPlayerClicked.accept(player), false);
|
||||
listView.getItems().add(playerButton);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,36 @@
|
||||
package org.toop.local;
|
||||
|
||||
import java.util.MissingResourceException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.toop.app.widget.tutorial.BaseTutorialWidget;
|
||||
import org.toop.framework.resource.ResourceManager;
|
||||
import org.toop.framework.resource.resources.LocalizationAsset;
|
||||
|
||||
import java.util.Locale;
|
||||
import org.toop.framework.asset.ResourceManager;
|
||||
import org.toop.framework.asset.resources.LocalizationAsset;
|
||||
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
|
||||
public class AppContext {
|
||||
private static final Logger logger = LogManager.getLogger(AppContext.class);
|
||||
|
||||
private static final LocalizationAsset localization = ResourceManager.get("localization");
|
||||
private static Locale locale = Locale.forLanguageTag("en");
|
||||
|
||||
private static final ObjectProperty<Locale> localeProperty = new SimpleObjectProperty<>(locale);
|
||||
private static BaseTutorialWidget tutorialWidget;
|
||||
|
||||
public static LocalizationAsset getLocalization() {
|
||||
return localization;
|
||||
}
|
||||
|
||||
public static void setLocale(Locale locale) {
|
||||
AppContext.locale = locale;
|
||||
localeProperty.set(locale);
|
||||
}
|
||||
|
||||
public static Locale getLocale() {
|
||||
@@ -22,6 +39,48 @@ public class AppContext {
|
||||
|
||||
public static String getString(String key) {
|
||||
assert localization != null;
|
||||
return localization.getString(key, locale);
|
||||
|
||||
// TODO: Gebruik ResourceBundle.getBundle() zodat de fallback automatisch gaat.
|
||||
// Hiervoor zou de assetManager aangepast moeten worden.
|
||||
|
||||
try{ // Main return
|
||||
return localization.getString(key, locale);
|
||||
}
|
||||
catch (MissingResourceException e) {
|
||||
logger.error("Missing resource key: {}, in bundle: {}. ", key, locale, e);
|
||||
}
|
||||
|
||||
try{ // Fallback return
|
||||
return localization.getString(key, localization.getFallback());
|
||||
}
|
||||
catch (MissingResourceException e) {
|
||||
logger.error("Missing resource key: {}, in default bundle!", key, e);
|
||||
}
|
||||
// Default return
|
||||
return "MISSING RESOURCE";
|
||||
}
|
||||
}
|
||||
|
||||
public static StringBinding bindToKey(String key, boolean localize) {
|
||||
if (localize) return Bindings.createStringBinding(
|
||||
() -> localization.getString(key, locale),
|
||||
localeProperty
|
||||
);
|
||||
|
||||
return Bindings.createStringBinding(
|
||||
() -> key
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public static StringBinding bindToKey(String key) {
|
||||
return bindToKey(key, true);
|
||||
}
|
||||
|
||||
public static void setCurrentTutorial(BaseTutorialWidget tutorial) {
|
||||
AppContext.tutorialWidget = tutorial;
|
||||
}
|
||||
|
||||
public static BaseTutorialWidget currentTutorial() {
|
||||
return AppContext.tutorialWidget;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +1,114 @@
|
||||
package org.toop.local;
|
||||
|
||||
import org.toop.app.App;
|
||||
import org.toop.framework.audio.VolumeControl;
|
||||
import org.toop.framework.audio.events.AudioEvents;
|
||||
import org.toop.framework.eventbus.EventFlow;
|
||||
import org.toop.framework.resource.ResourceManager;
|
||||
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;
|
||||
import org.toop.app.App;
|
||||
import org.toop.framework.asset.resources.SettingsAsset;
|
||||
import org.toop.framework.audio.events.AudioEvents;
|
||||
import org.toop.framework.eventbus.EventFlow;
|
||||
import org.toop.framework.settings.Settings;
|
||||
|
||||
public class AppSettings {
|
||||
private static SettingsAsset settingsAsset;
|
||||
|
||||
private SettingsAsset settingsAsset;
|
||||
public static void applySettings() {
|
||||
settingsAsset = getPath();
|
||||
if (!settingsAsset.isLoaded()) {
|
||||
settingsAsset.load();
|
||||
}
|
||||
|
||||
public void applySettings() {
|
||||
SettingsAsset settings = getPath();
|
||||
if (!settings.isLoaded()) {
|
||||
settings.load();
|
||||
checkSettings();
|
||||
|
||||
Settings settingsData = settingsAsset.getContent();
|
||||
|
||||
AppContext.setLocale(Locale.of(settingsData.locale));
|
||||
App.setFullscreen(settingsData.fullScreen);
|
||||
|
||||
App.setStyle(settingsAsset.getTheme(), settingsAsset.getLayoutSize());
|
||||
}
|
||||
|
||||
public static void applyMusicVolumeSettings() {
|
||||
Settings settingsData = settingsAsset.getContent();
|
||||
|
||||
new EventFlow()
|
||||
.addPostEvent(new AudioEvents.ChangeVolume(settingsData.volume, VolumeControl.MASTERVOLUME))
|
||||
.postEvent();
|
||||
new EventFlow()
|
||||
.addPostEvent(new AudioEvents.ChangeVolume(settingsData.fxVolume, VolumeControl.FX))
|
||||
.postEvent();
|
||||
new EventFlow()
|
||||
.addPostEvent(new AudioEvents.ChangeVolume(settingsData.musicVolume, VolumeControl.MUSIC))
|
||||
.postEvent();
|
||||
}
|
||||
|
||||
public static SettingsAsset getPath() {
|
||||
if (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";
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
public static SettingsAsset getSettings() {
|
||||
return settingsAsset;
|
||||
}
|
||||
|
||||
public static void checkSettings() {
|
||||
Settings s = settingsAsset.getContent();
|
||||
boolean changed = false;
|
||||
|
||||
if (s.showTutorials == null) {
|
||||
settingsAsset.setTutorialFlag(true);
|
||||
changed = true;
|
||||
}
|
||||
if (s.firstReversi == null) {
|
||||
settingsAsset.setFirstReversi(true);
|
||||
changed = true;
|
||||
}
|
||||
if (s.firstTTT == null) {
|
||||
settingsAsset.setFirstTTT(true);
|
||||
changed = true;
|
||||
}
|
||||
if (s.firstConnect4 == null) {
|
||||
settingsAsset.setFirstConnect4(true);
|
||||
changed = true;
|
||||
}
|
||||
if (changed) {
|
||||
getSettings().save();
|
||||
}
|
||||
Settings settingsData = settings.getContent();
|
||||
|
||||
AppContext.setLocale(Locale.of(settingsData.locale));
|
||||
App.setFullscreen(settingsData.fullScreen);
|
||||
new EventFlow()
|
||||
.addPostEvent(new AudioEvents.ChangeVolume(settingsData.volume))
|
||||
.asyncPostEvent();
|
||||
new EventFlow()
|
||||
.addPostEvent(new AudioEvents.ChangeFxVolume(settingsData.fxVolume))
|
||||
.asyncPostEvent();
|
||||
new EventFlow()
|
||||
.addPostEvent(new AudioEvents.ChangeMusicVolume(settingsData.musicVolume))
|
||||
.asyncPostEvent();
|
||||
App.setStyle(settingsAsset.getTheme(), settingsAsset.getLayoutSize());
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
File settingsFile =
|
||||
new File(basePath + File.separator + "ISY1" + File.separator + "settings.json");
|
||||
this.settingsAsset = new SettingsAsset(settingsFile);
|
||||
}
|
||||
return this.settingsAsset;
|
||||
public static void doDefaultSettings() {
|
||||
settingsAsset.setFirstConnect4(true);
|
||||
settingsAsset.setFirstTTT(true);
|
||||
settingsAsset.setFirstReversi(true);
|
||||
settingsAsset.setLocale("en");
|
||||
settingsAsset.setTheme("dark");
|
||||
settingsAsset.setFullscreen(false);
|
||||
settingsAsset.setVolume(100);
|
||||
settingsAsset.setFxVolume(20);
|
||||
settingsAsset.setMusicVolume(15);
|
||||
settingsAsset.setTutorialFlag(true);
|
||||
settingsAsset.setLayoutSize("medium");
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
app/src/main/resources/assets/images/cat.jpg
Normal file
|
After Width: | Height: | Size: 596 KiB |
BIN
app/src/main/resources/assets/images/connect41.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
app/src/main/resources/assets/images/connect42.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
app/src/main/resources/assets/images/reversi1.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
app/src/main/resources/assets/images/reversi2.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
app/src/main/resources/assets/images/tictactoe1.png
Normal file
|
After Width: | Height: | Size: 9.7 KiB |
BIN
app/src/main/resources/assets/images/tictactoe2.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
@@ -1,63 +0,0 @@
|
||||
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
|
||||
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)
|
||||
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
|
||||
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
|
||||
no=\u0644\u0627
|
||||
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
|
||||
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
|
||||
yes=\u0646\u0639\u0645
|
||||
|
||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629
|
||||
chinese=\u4e2d\u6587 (\u0627\u0644\u0635\u064a\u0646\u064a\u0629)
|
||||
dutch=Nederlands (\u0627\u0644\u0647\u0648\u0644\u0646\u062f\u064a\u0629)
|
||||
english=English (\u0627\u0644\u0625\u0646\u062c\u0644\u064a\u0632\u064a\u0629)
|
||||
french=Fran\u00e7ais (\u0627\u0644\u0641\u0631\u0646\u0633\u064a\u0629)
|
||||
georgian=\u10e5\u10d0\u10e0\u10d4\u10e1\u10d8 (\u0627\u0644\u062c\u0648\u0631\u062c\u064a\u0629)
|
||||
german=Deutsch (\u0627\u0644\u0623\u0644\u0645\u0627\u0646\u064a\u0629)
|
||||
hindi=\u0939\u093f\u0928\u094d\u0926\u0940 (\u0627\u0644\u0647\u0646\u062f\u064a\u0629)
|
||||
italian=Italiano (\u0627\u0644\u0625\u064a\u0637\u0627\u0644\u064a\u0629)
|
||||
japanese=\u65e5\u672c\u8a9e (\u0627\u0644\u064a\u0627\u0628\u0627\u0646\u064a\u0629)
|
||||
korean=\ud55c\uad6d\uc5b4 (\u0627\u0644\u0643\u0648\u0631\u064a\u0629)
|
||||
russian=\u0420\u0443\u0441\u0441\u043a\u0438\u0439 (\u0627\u0644\u0631\u0648\u0633\u064a\u0629)
|
||||
spanish=Espa\u00f1ol (\u0627\u0644\u0625\u0633\u0628\u0627\u0646\u064a\u0629)
|
||||
@@ -1,63 +0,0 @@
|
||||
ai=K\u00fcnstliche Intelligenz
|
||||
appTitle=ISY Spieleauswahl
|
||||
back=Zur\u00fcck
|
||||
backToMainMenu=Zur\u00FCck zum Hauptmen\u00FC
|
||||
computer=Computer
|
||||
computerDifficulty=Computerschwierigkeit
|
||||
computerThinkTime=Computer Denkzeit
|
||||
congratulations=Gl\u00FCckwunsch
|
||||
connect=Verbinden
|
||||
connectionType=Verbindungstyp
|
||||
credits=Credits
|
||||
dark-hc=Dunkel (Hoher Kontrast)
|
||||
dark=Dunkel
|
||||
developers=Entwickler
|
||||
drawText=Das Spiel endete unentschieden
|
||||
effectsVolume=Effektlautst\u00e4rke
|
||||
musicVolume=Music Volume (translate me)
|
||||
fullscreen=Vollbild
|
||||
goodGameText=Gutes Spiel. Gut gespielt.
|
||||
human=Mensch
|
||||
language=Sprache
|
||||
large=Gro\u00DF
|
||||
layoutSize=Layout-Gr\u00F6\u00DFe
|
||||
light-hc=Hell (Hoher Kontrast)
|
||||
light=Hell
|
||||
local=Lokal
|
||||
localization=Lokalisierung
|
||||
medium=Mittel
|
||||
mergeCommander=Merge-Kommandant
|
||||
moralSupport=Mentale Unterst\u00fctzung
|
||||
no=Nein
|
||||
opengl=OpenGL
|
||||
options=Optionen
|
||||
othello=Othello
|
||||
playerName=Spielername
|
||||
productOwner=Produktverantwortlicher
|
||||
quit=Beenden
|
||||
quitSure=Bist du dir sicher?
|
||||
scrumMaster=Scrum Master
|
||||
server=Server
|
||||
serverIP=Server-IP
|
||||
serverPort=Server-Port
|
||||
small=Klein
|
||||
start=Start
|
||||
theme=Thema
|
||||
tictactoe=Tic Tac Toe
|
||||
volume=Hauptlautst<EFBFBD>rke
|
||||
windowed=Fenstermodus
|
||||
yes=Ja
|
||||
|
||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabisch)
|
||||
chinese=\u4e2d\u6587 (Chinesisch)
|
||||
dutch=Nederlands (Niederl\u00e4ndisch)
|
||||
english=English (Englisch)
|
||||
french=Fran\u00e7ais (Franz\u00f6sisch)
|
||||
georgian=\u10e5\u10d0\u10e0\u10d4\u10e1\u10d8 (Georgisch)
|
||||
german=Deutsch
|
||||
hindi=\u0939\u093f\u0928\u094d\u0926\u0940 (Hindi)
|
||||
italian=Italiano (Italienisch)
|
||||
japanese=\u65e5\u672c\u8a9e (Japanisch)
|
||||
korean=\ud55c\uad6d\uc5b4 (Koreanisch)
|
||||
russian=\u0420\u0443\u0441\u0441\u043a\u0438\u0439 (Russisch)
|
||||
spanish=Espa\u00f1ol (Spanisch)
|
||||
@@ -1,67 +0,0 @@
|
||||
accept=Accept
|
||||
ai=Artificial Intelligence
|
||||
appTitle=ISY Games Selector
|
||||
back=Back
|
||||
backToMainMenu=Back to main menu
|
||||
challengeText=You were challenged by
|
||||
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
|
||||
fullscreen=Fullscreen
|
||||
gameIsText=To a game of
|
||||
goodGameText=Good game. Well played.
|
||||
human=Human
|
||||
language=Language
|
||||
large=Large
|
||||
layoutSize=Layout Size
|
||||
light=Light
|
||||
light-hc=Light (High Contrast)
|
||||
local=Local
|
||||
localization=Localization
|
||||
medium=Medium
|
||||
mergeCommander=Merge Commander
|
||||
moralSupport=Moral Support
|
||||
no=No
|
||||
opengl=OpenGL
|
||||
options=Options
|
||||
othello=Othello
|
||||
playerName=Player Name
|
||||
productOwner=Product Owner
|
||||
quit=Quit
|
||||
quitSure=Are you sure?
|
||||
scrumMaster=Scrum Master
|
||||
server=Server
|
||||
serverIP=Server IP
|
||||
serverPort=Server Port
|
||||
small=Small
|
||||
start=Start
|
||||
theme=Theme
|
||||
tictactoe=Tic Tac Toe
|
||||
volume=Master Volume
|
||||
windowed=Windowed
|
||||
yes=Yes
|
||||
|
||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabic)
|
||||
chinese=\u4e2d\u6587 (Chinese)
|
||||
dutch=Nederlands (Dutch)
|
||||
english=English
|
||||
french=Fran\u00e7ais (French)
|
||||
georgian=\u10e5\u10d0\u10e0\u10d4\u10e1\u10d8 (Georgian)
|
||||
german=Deutsch (German)
|
||||
hindi=\u0939\u093f\u0928\u094d\u0926\u0940 (Hindi)
|
||||
italian=Italiano (Italian)
|
||||
japanese=\u65e5\u672c\u8a9e (Japanese)
|
||||
korean=\ud55c\uad6d\uc5b4 (Korean)
|
||||
russian=\u0420\u0443\u0441\u0441\u043a\u0438\u0439 (Russian)
|
||||
spanish=Espa\u00f1ol (Spanish)
|
||||
@@ -1,63 +0,0 @@
|
||||
ai=Inteligencia Artificial
|
||||
appTitle=Selector de Juegos ISY
|
||||
back=Atr\u00e1s
|
||||
backToMainMenu=Volver al men\u00FA principal
|
||||
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
|
||||
developers=Desarrolladores
|
||||
drawText=El juego termin\u00F3 en empate
|
||||
effectsVolume=Volumen de efectos
|
||||
musicVolume=Music Volume (translate me)
|
||||
fullscreen=Pantalla completa
|
||||
goodGameText=Buen juego. Bien jugado.
|
||||
human=Humano
|
||||
language=Idioma
|
||||
large=Grande
|
||||
layoutSize=Tama\u00F1o del dise\u00F1o
|
||||
light-hc=Claro (Alto Contraste)
|
||||
light=Claro
|
||||
local=Local
|
||||
localization=Localizaci\u00f3n
|
||||
medium=Mediano
|
||||
mergeCommander=Comandante de Merge
|
||||
moralSupport=Apoyo moral
|
||||
no=No
|
||||
opengl=OpenGL
|
||||
options=Opciones
|
||||
othello=Othello
|
||||
playerName=Nombre del Jugador
|
||||
productOwner=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
|
||||
theme=Tema
|
||||
tictactoe=Tres en Raya
|
||||
volume=Volumen principal
|
||||
windowed=Ventana
|
||||
yes=S\u00ed
|
||||
|
||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Ar\u00e1bigo)
|
||||
chinese=\u4e2d\u6587 (Chino)
|
||||
dutch=Nederlands (Neerland\u00e9s)
|
||||
english=English (Ingl\u00e9s)
|
||||
french=Fran\u00e7ais (Franc\u00e9s)
|
||||
georgian=\u10e5\u10d0\u10e0\u10d4\u10e1\u10d8 (Georgiano)
|
||||
german=Deutsch (Alem\u00e1n)
|
||||
hindi=\u0939\u093f\u0928\u094d\u0926\u0940 (Hindi)
|
||||
italian=Italiano (Italiano)
|
||||
japanese=\u65e5\u672c\u8a9e (Japon\u00e9s)
|
||||
korean=\ud55c\uad6d\uc5b4 (Coreano)
|
||||
russian=\u0420\u0443\u0441\u0441\u043a\u0438\u0439 (Ruso)
|
||||
spanish=Espa\u00f1ol
|
||||
@@ -1,63 +0,0 @@
|
||||
ai=Intelligence Artificielle
|
||||
appTitle=S\u00e9lecteur de Jeux ISY
|
||||
back=Retour
|
||||
backToMainMenu=Retour au menu principal
|
||||
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
|
||||
credits=Cr\u00e9dits
|
||||
dark-hc=Sombre (Contraste \u00E9lev\u00E9)
|
||||
dark=Sombre
|
||||
developers=D\u00e9veloppeurs
|
||||
drawText=La partie s'est termin\u00E9e par un match nul
|
||||
effectsVolume=Volume des effets
|
||||
musicVolume=Music Volume (translate me)
|
||||
fullscreen=Plein \u00e9cran
|
||||
goodGameText=Bien jou\u00E9. Bonne partie.
|
||||
human=Humain
|
||||
language=Langue
|
||||
large=Grand
|
||||
layoutSize=Taille de la disposition
|
||||
light-hc=Clair (Contraste \u00E9lev\u00E9)
|
||||
light=Clair
|
||||
local=Local
|
||||
localization=Localisation
|
||||
medium=Moyen
|
||||
mergeCommander=Commandant de Merge
|
||||
moralSupport=Soutien moral
|
||||
no=Non
|
||||
opengl=OpenGL
|
||||
options=Options
|
||||
othello=Othello
|
||||
playerName=Nom du joueur
|
||||
productOwner=Responsable du produit
|
||||
quit=Quitter
|
||||
quitSure=Es-tu s\u00fbr ?
|
||||
scrumMaster=Scrum Master
|
||||
server=Serveur
|
||||
serverIP=Serveur-IP
|
||||
serverPort=Serveur-Port
|
||||
small=Petit
|
||||
start=D\u00e9marrer
|
||||
theme=Th\u00E8me
|
||||
tictactoe=Morpion
|
||||
volume=Volume principal
|
||||
windowed=Fen\u00eatre
|
||||
yes=Oui
|
||||
|
||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabe)
|
||||
chinese=\u4e2d\u6587 (Chinois)
|
||||
dutch=Nederlands (N\u00e9erlandais)
|
||||
english=English (Anglais)
|
||||
french=Fran\u00e7ais
|
||||
georgian=\u10e5\u10d0\u10e0\u10d4\u10e1\u10d8 (G\u00e9orgien)
|
||||
german=Deutsch (Allemand)
|
||||
hindi=\u0939\u093f\u0928\u094d\u0926\u0940 (Hindi)
|
||||
italian=Italiano (Italien)
|
||||
japanese=\u65e5\u672c\u8a9e (Japonais)
|
||||
korean=\ud55c\uad6d\uc5b4 (Cor\u00e9en)
|
||||
russian=\u0420\u0443\u0441\u0441\u043a\u0438\u0439 (Russe)
|
||||
spanish=Espa\u00f1ol (Espagnol)
|
||||
@@ -1,63 +0,0 @@
|
||||
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
|
||||
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
|
||||
no=\u0928\u0939\u0940\u0902
|
||||
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
|
||||
|
||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0905\u0930\u092c\u0940)
|
||||
chinese=\u4e2d\u6587 (\u091a\u0940\u0928\u0940)
|
||||
dutch=Nederlands (\u0921\u091a)
|
||||
english=English (\u0905\u0902\u0917\u094d\u0930\u0947\u091c\u0940)
|
||||
french=Fran\u00e7ais (\u092b\u094d\u0930\u0947\u0902\u091a)
|
||||
georgian=\u10e5\u10d0\u10e0\u10d4\u10e1\u10d8 (\u091c\u094d\u091c\u094b\u0930\u094d\u091c\u093f\u092f\u0928)
|
||||
german=Deutsch (\u091c\u0930\u094d\u092e\u0928)
|
||||
hindi=\u0939\u093f\u0928\u094d\u0926\u0940
|
||||
italian=Italiano (\u0907\u091f\u093e\u0932\u093f\u092f\u0928)
|
||||
japanese=\u65e5\u672c\u8a9e (\u091c\u093e\u092a\u093e\u0928\u0940)
|
||||
korean=\ud55c\uad6d\uc5b4 (\u0915\u094b\u0930\u093f\u092f\u0928)
|
||||
russian=\u0420\u0443\u0441\u0441\u043a\u0438\u0439 (\u0930\u0942\u0938\u0940)
|
||||
spanish=Espa\u00f1ol (\u0938\u094d\u092a\u0947\u0928\u093f\u0936)
|
||||
@@ -1,63 +0,0 @@
|
||||
ai=Intelligenza Artificiale
|
||||
appTitle=Selettore di Giochi ISY
|
||||
back=Indietro
|
||||
backToMainMenu=Ritorna al menu principale
|
||||
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
|
||||
developers=Sviluppatori
|
||||
drawText=La partita \u00E8 terminata in parit\u00E0
|
||||
effectsVolume=Volume effetti
|
||||
musicVolume=Music Volume (translate me)
|
||||
fullscreen=Schermo intero
|
||||
goodGameText=Bel gioco. Ben giocato.
|
||||
human=Umano
|
||||
language=Lingua
|
||||
large=Grande
|
||||
layoutSize=Dimensione Layout
|
||||
light-hc=Chiaro (Alto Contrasto)
|
||||
light=Chiaro
|
||||
local=Locale
|
||||
localization=Localizzazione
|
||||
medium=Medio
|
||||
mergeCommander=Comandante di Merge
|
||||
moralSupport=Supporto morale
|
||||
no=No
|
||||
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
|
||||
small=Piccolo
|
||||
start=Inizia
|
||||
theme=Tema
|
||||
tictactoe=Tic Tac Toe
|
||||
volume=Volume principale
|
||||
windowed=Finestra
|
||||
yes=S\u00ec
|
||||
|
||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabo)
|
||||
chinese=\u4e2d\u6587 (Cinese)
|
||||
dutch=Nederlands (Olandese)
|
||||
english=English (Inglese)
|
||||
french=Fran\u00e7ais (Francese)
|
||||
georgian=\u10e5\u10d0\u10e0\u10d4\u10e1\u10d8 (Georgiano)
|
||||
german=Deutsch (Tedesco)
|
||||
hindi=\u0939\u093f\u0928\u094d\u0926\u0940 (Hindi)
|
||||
italian=Italiano
|
||||
japanese=\u65e5\u672c\u8a9e (Giapponese)
|
||||
korean=\ud55c\uad6d\uc5b4 (Coreano)
|
||||
russian=\u0420\u0443\u0441\u0441\u043a\u0438\u0439 (Russo)
|
||||
spanish=Espa\u00f1ol (Spagnolo)
|
||||
@@ -1,63 +0,0 @@
|
||||
ai=\u4eba\u5de5\u77e5\u80fd
|
||||
appTitle=ISY \u30b2\u30fc\u30e0\u30bb\u30ec\u30af\u30bf\u30fc
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
no=\u3044\u3044\u3048
|
||||
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
|
||||
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
|
||||
yes=\u306f\u3044
|
||||
|
||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u30a2\u30e9\u30d3\u30a2\u8a9e)
|
||||
chinese=\u4e2d\u6587 (\u4e2d\u6587)
|
||||
dutch=Nederlands (\u30aa\u30e9\u30f3\u30c0\u8a9e)
|
||||
english=English (\u82f1\u8a9e)
|
||||
french=Fran\u00e7ais (\u30d5\u30e9\u30f3\u30b9\u8a9e)
|
||||
georgian=\u10e5\u10d0\u10e0\u10d4\u10e1\u10d8 (\u30b0\u30eb\u30b8\u30a2\u8a9e)
|
||||
german=Deutsch (\u30c9\u30a4\u30c4\u8a9e)
|
||||
hindi=\u0939\u093f\u0928\u094d\u0926\u0940 (\u30d2\u30f3\u30c7\u30a3\u8a9e)
|
||||
italian=Italiano (\u30a4\u30bf\u30ea\u30a2\u8a9e)
|
||||
japanese=\u65e5\u672c\u8a9e
|
||||
korean=\ud55c\uad6d\uc5b4 (\u97d3\u56fd\u8a9e)
|
||||
russian=\u0420\u0443\u0441\u0441\u043a\u0438\u0439 (\u30ed\u30b7\u30a2\u8a9e)
|
||||
spanish=Espa\u00f1ol (\u30b9\u30da\u30a4\u30f3\u8a9e)
|
||||
@@ -1,63 +0,0 @@
|
||||
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)
|
||||
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
|
||||
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
|
||||
medium=\uBCF4\uD1B5
|
||||
mergeCommander=\uba54\uc9c0 \ucea0\ub9ac\ub354
|
||||
moralSupport=\uc815\uc2e0\uc801 \uc9c0\uc6d0
|
||||
no=\uc544\ub2c8\uc624
|
||||
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
|
||||
theme=\uC8FC\uC81C
|
||||
tictactoe=\ud2f0\ud06c\ud0d0\ud1a0
|
||||
volume=\ub9c8\uc2a4\ud130 \ubcfc\ub80c
|
||||
windowed=\ucc3d \ubaa8\ub4dc
|
||||
yes=\ub124
|
||||
|
||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0639\u0631\u0628\u064a\u0629)
|
||||
chinese=\u4e2d\u6587 (\u4e2d\u6587)
|
||||
dutch=Nederlands (\ub3c4\ucc99)
|
||||
english=English (\uc601\uad6d\uc5b4)
|
||||
french=Fran\u00e7ais (\ud504\ub791\uc81c\uc2a4\ucf54)
|
||||
georgian=\u10e5\u10d0\u10e0\u10d4\u10e1\u10d8 (\uac8c\uc774\uc874)
|
||||
german=Deutsch (\ub3c4\ucf54)
|
||||
hindi=\u0939\u093f\u0928\u094d\u0926\u0940 (\ud567\ub9ac)
|
||||
italian=Italiano (\uc774\ud0c0\ub9ac\uc5b4\ub098)
|
||||
japanese=\u65e5\u672c\u8a9e (\uc65c\uc790\ub9ac\uc5b4)
|
||||
korean=\ud55c\uad6d\uc5b4
|
||||
russian=\u0420\u0443\u0441\u0441\u043a\u0438\u0439 (\ub85c\uc6b0\uc2a4\uc544\uc774\ucf58)
|
||||
spanish=Espa\u00f1ol (\uc2a4\ud398\ub974\uc2a4\uc544\uc774\ucf58)
|
||||
@@ -1,63 +0,0 @@
|
||||
ai=Kunstmatige Intelligentie
|
||||
appTitle=ISY Spel Kiezer
|
||||
back=Terug
|
||||
backToMainMenu=Terug naar hoofdmenu
|
||||
computer=Computer
|
||||
computerDifficulty=Computermoeilijkheid
|
||||
computerThinkTime=Computer Denk Tijd
|
||||
congratulations=Gefeliciteerd
|
||||
connect=Verbinden
|
||||
connectionType=Verbindingstype
|
||||
credits=Credits
|
||||
dark-hc=Donker (Hoog Contrast)
|
||||
dark=Donker
|
||||
developers=Ontwikkelaars
|
||||
drawText=Het spel eindigde in een gelijkspel
|
||||
effectsVolume=Effecten Volume
|
||||
musicVolume=Music Volume (translate me)
|
||||
fullscreen=Volledig scherm
|
||||
goodGameText=Goed gespeeld. Mooie wedstrijd.
|
||||
human=Mens
|
||||
language=Taal
|
||||
large=Groot
|
||||
layoutSize=Lay-outgrootte
|
||||
light-hc=Licht (Hoog Contrast)
|
||||
light=Licht
|
||||
local=Lokaal
|
||||
localization=Lokalisatie
|
||||
medium=Middel
|
||||
mergeCommander=Merge-commandant
|
||||
moralSupport=Moraalsteun
|
||||
no=Nee
|
||||
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
|
||||
small=Klein
|
||||
start=Start
|
||||
theme=Thema
|
||||
tictactoe=Boter Kaas en Eieren
|
||||
volume=Hoofdvolume
|
||||
windowed=Venstermodus
|
||||
yes=Ja
|
||||
|
||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabisch)
|
||||
chinese=\u4e2d\u6587 (Chinees)
|
||||
dutch=Nederlands
|
||||
english=English (Engels)
|
||||
french=Fran\u00e7ais (Frans)
|
||||
georgian=\u10e5\u10d0\u10e0\u10d4\u10e1\u10d8 (Georgisch)
|
||||
german=Deutsch (Duits)
|
||||
hindi=\u0939\u093f\u0928\u094d\u0926\u0940 (Hindi)
|
||||
italian=Italiano (Italiaans)
|
||||
japanese=\u65e5\u672c\u8a9e (Japans)
|
||||
korean=\ud55c\uad6d\uc5b4 (Koreaans)
|
||||
russian=\u0420\u0443\u0441\u0441\u043a\u0438\u0439 (Russisch)
|
||||
spanish=Espa\u00f1ol (Spaans)
|
||||
@@ -1,63 +0,0 @@
|
||||
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
|
||||
back=\u041d\u0430\u0437\u0430\u0434
|
||||
backToMainMenu=\u041D\u0430\u0437\u0430\u0434 \u0432 \u0433\u043B\u0430\u0432\u043D\u043E\u0435 \u043C\u0435\u043D\u044E
|
||||
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
|
||||
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)
|
||||
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
|
||||
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
|
||||
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
|
||||
no=\u041d\u0435\u0442
|
||||
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
|
||||
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
|
||||
windowed=\u041e\u043a\u043d\u043e
|
||||
yes=\u0414\u0430
|
||||
|
||||
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)
|
||||
dutch=Nederlands (\u041d\u0438\u0434\u0435\u0440\u043b\u0430\u043d\u0434\u0441\u043a\u0438\u0439)
|
||||
english=English (\u0410\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439)
|
||||
french=Fran\u00e7ais (\u0424\u0440\u0430\u043d\u0446\u0443\u0437\u0441\u043a\u0438\u0439)
|
||||
georgian=\u10e5\u10d0\u10e0\u10d4\u10e1\u10d8 (\u0413\u0440\u0443\u0437\u0438\u043d\u0441\u043a\u0438\u0439)
|
||||
german=Deutsch (\u041d\u0435\u043c\u0435\u0446\u043a\u0438\u0439)
|
||||
hindi=\u0939\u093f\u0928\u094d\u0926\u0940 (\u0425\u0438\u043d\u0434\u0438)
|
||||
italian=Italiano (\u0418\u0442\u0430\u043b\u044c\u044f\u043d\u0441\u043a\u0438\u0439)
|
||||
japanese=\u65e5\u672c\u8a9e (\u042f\u043f\u043e\u043d\u0441\u043a\u0438\u0439)
|
||||
korean=\ud55c\uad6d\uc5b4 (\u041a\u043e\u0440\u0435\u0439\u0441\u043a\u0438\u0439)
|
||||
russian=\u0420\u0443\u0441\u0441\u043a\u0438\u0439
|
||||
spanish=Espa\u00f1ol (\u0418\u0441\u043f\u0430\u043d\u0441\u043a\u0438\u0439)
|
||||
@@ -1,63 +0,0 @@
|
||||
ai=\u4eba\u5de5\u667a\u80fd
|
||||
appTitle=ISY \u6e38\u620f\u9009\u62e9\u5668
|
||||
back=\u8fd4\u56de
|
||||
backToMainMenu=\u8FD4\u56DE\u4E3B\u83DC\u5355
|
||||
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
|
||||
developers=\u5f00\u53d1\u8005
|
||||
drawText=\u6E38\u620F\u4EE5\u5E73\u5C40\u7ED3\u675F
|
||||
effectsVolume=\u6548\u679c\u91cf
|
||||
musicVolume=Music Volume (translate me)
|
||||
fullscreen=\u5168\u5c4f
|
||||
goodGameText=\u6E38\u620F\u5F88\u597D. \u8868\u73B0\u4F18\u79C0.
|
||||
human=\u4eba
|
||||
language=\u8bed\u8a00
|
||||
large=\u5927
|
||||
layoutSize=\u5E03\u5C40\u5927\u5C0F
|
||||
light-hc=\u4EAE (\u9AD8\u5BF9\u6BD4)
|
||||
light=\u4EAE
|
||||
local=\u672c\u5730
|
||||
localization=\u6d88\u606f\u5c55\u793a / \u672c\u5730\u5316
|
||||
medium=\u4E2D
|
||||
mergeCommander=Merge \u63a7\u4e3b
|
||||
moralSupport=\u795e\u7cbe\u652f\u6301
|
||||
no=\u5426
|
||||
opengl=OpenGL
|
||||
options=\u9009\u9879
|
||||
othello=Othello
|
||||
playerName=\u73a9\u5bb6\u540d\u79f0
|
||||
productOwner=\u54c1\u76d8\u4ea7\u54c1\u4eba
|
||||
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
|
||||
windowed=\u7a97\u53e3\u6a21\u5f0f
|
||||
yes=\u662f
|
||||
|
||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u963f\u62c9\u4f2f\u8bed)
|
||||
chinese=\u4e2d\u6587
|
||||
dutch=Nederlands (\u8377\u5170\u8bed)
|
||||
english=English (\u82f1\u8bed)
|
||||
french=Fran\u00e7ais (\u6cd5\u8bed)
|
||||
georgian=\u10e5\u10d0\u10e0\u10d4\u10e1\u10d8 (\u683c\u9c81\u5409\u4e9a\u8bed)
|
||||
german=Deutsch (\u5fb7\u8bed)
|
||||
hindi=\u0939\u093f\u0928\u094d\u0926\u0940 (\u5370\u5ea6\u8bed)
|
||||
italian=Italiano (\u610f\u5927\u5229\u8bed)
|
||||
japanese=\u65e5\u672c\u8a9e (\u65e5\u8bed)
|
||||
korean=\ud55c\uad6d\uc5b4 (\u97e9\u8bed)
|
||||
russian=\u0420\u0443\u0441\u0441\u043a\u0438\u0439 (\u4fc4\u8bed)
|
||||
spanish=Espa\u00f1ol (\u897f\u73ed\u7259\u8bed)
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
/* ----------------------------
|
||||
.background
|
||||
----------------------------- */
|
||||
.bg-primary {
|
||||
-fx-background-color: #181818;
|
||||
}
|
||||
|
||||
.bg-secondary {
|
||||
-fx-background-color: #2a2a2a;
|
||||
}
|
||||
|
||||
.bg-popup {
|
||||
-fx-background-color: #1818187f;
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
.button
|
||||
----------------------------- */
|
||||
.button {
|
||||
/* Layout */
|
||||
-fx-padding: 10 20;
|
||||
-fx-background-radius: 6;
|
||||
-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);
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
-fx-background-color: #3a3a3a;
|
||||
-fx-border-color: #4caf50;
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
.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;
|
||||
}
|
||||
|
||||
.choice-box:hover {
|
||||
-fx-border-color: #4caf50;
|
||||
}
|
||||
|
||||
.choice-box:focused {
|
||||
-fx-border-color: #81c784;
|
||||
}
|
||||
|
||||
.choice-box .label {
|
||||
-fx-text-fill: #f0f0f0;
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
.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;
|
||||
}
|
||||
|
||||
.choice-box .menu-item {
|
||||
/* Layout */
|
||||
-fx-padding: 6 12;
|
||||
}
|
||||
|
||||
.choice-box .menu-item .label {
|
||||
-fx-text-fill: #dddddd;
|
||||
}
|
||||
|
||||
.choice-box .menu-item:hover {
|
||||
-fx-background-color: #3a3a3a;
|
||||
}
|
||||
|
||||
.choice-box .menu-item:focused {
|
||||
-fx-background-color: #4caf50;
|
||||
-fx-text-fill: #ffffff;
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
.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;
|
||||
}
|
||||
|
||||
.input:hover {
|
||||
-fx-border-color: #4caf50;
|
||||
}
|
||||
|
||||
.input:focused {
|
||||
-fx-border-color: #81c784;
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
.separator
|
||||
----------------------------- */
|
||||
.separator {
|
||||
/* Layout */
|
||||
-fx-padding: 10 0;
|
||||
}
|
||||
|
||||
.separator .line {
|
||||
/* Color */
|
||||
-fx-border-color: #3a3a3a;
|
||||
-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, #4caf50, #f44336);
|
||||
-fx-background-insets: 0;
|
||||
-fx-background-radius: 2;
|
||||
-fx-pref-height: 4;
|
||||
}
|
||||
|
||||
.slider .thumb {
|
||||
/* Color */
|
||||
-fx-background-color: #f0f0f0;
|
||||
-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: #f0f0f0;
|
||||
-fx-text-fill: #f0f0f0;
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
.text-normal
|
||||
----------------------------- */
|
||||
.text-normal {
|
||||
-fx-fill: #dddddd;
|
||||
-fx-text-fill: #dddddd;
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
.toggle-button
|
||||
----------------------------- */
|
||||
.toggle {
|
||||
/* Layout */
|
||||
-fx-padding: 8 16;
|
||||
-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;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
.text-header {
|
||||
-fx-font-family: "Arial";
|
||||
-fx-font-size: 24px;
|
||||
-fx-font-weight: bold;
|
||||
}
|
||||
|
||||
.text-normal {
|
||||
-fx-font-family: "Arial";
|
||||
-fx-font-size: 20px;
|
||||
-fx-font-weight: normal;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
/* ----------------------------
|
||||
.background
|
||||
----------------------------- */
|
||||
.bg-primary {
|
||||
-fx-background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.bg-secondary {
|
||||
-fx-background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
.bg-popup {
|
||||
-fx-background-color: #f5f5f57f;
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
.button
|
||||
----------------------------- */
|
||||
.button {
|
||||
/* Layout */
|
||||
-fx-padding: 10 20;
|
||||
-fx-background-radius: 6;
|
||||
-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);
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
-fx-background-color: #d5d5d5;
|
||||
-fx-border-color: #4caf50;
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
.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;
|
||||
}
|
||||
|
||||
.choice-box:hover {
|
||||
-fx-border-color: #4caf50;
|
||||
}
|
||||
|
||||
.choice-box:focused {
|
||||
-fx-border-color: #81c784;
|
||||
}
|
||||
|
||||
.choice-box .label {
|
||||
-fx-text-fill: #1a1a1a;
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
.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;
|
||||
}
|
||||
|
||||
.choice-box .menu-item {
|
||||
/* Layout */
|
||||
-fx-padding: 6 12;
|
||||
}
|
||||
|
||||
.choice-box .menu-item .label {
|
||||
-fx-text-fill: #333333;
|
||||
}
|
||||
|
||||
.choice-box .menu-item:hover {
|
||||
-fx-background-color: #eeeeee;
|
||||
}
|
||||
|
||||
.choice-box .menu-item:focused {
|
||||
-fx-background-color: #4caf50;
|
||||
-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;
|
||||
}
|
||||
|
||||
.input:hover {
|
||||
-fx-border-color: #4caf50;
|
||||
}
|
||||
|
||||
.input:focused {
|
||||
-fx-border-color: #81c784;
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
.separator
|
||||
----------------------------- */
|
||||
.separator {
|
||||
/* Layout */
|
||||
-fx-padding: 10 0;
|
||||
}
|
||||
|
||||
.separator .line {
|
||||
/* Color */
|
||||
-fx-border-color: #cccccc;
|
||||
-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, #4caf50, #f44336);
|
||||
-fx-background-insets: 0;
|
||||
-fx-background-radius: 2;
|
||||
-fx-pref-height: 4;
|
||||
}
|
||||
|
||||
.slider .thumb {
|
||||
/* Color */
|
||||
-fx-background-color: #1a1a1a;
|
||||
-fx-background-radius: 50%;
|
||||
|
||||
/* Effects */
|
||||
-fx-effect: dropshadow(gaussian, #00000033, 4, 0, 0, 1);
|
||||
}
|
||||
|
||||
.slider .thumb:hover {
|
||||
-fx-scale-x: 1.2;
|
||||
-fx-scale-y: 1.2;
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
.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;
|
||||
-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;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
.text-header {
|
||||
-fx-font-family: "Arial";
|
||||
-fx-font-size: 20px;
|
||||
-fx-font-weight: bold;
|
||||
}
|
||||
|
||||
.text-normal {
|
||||
-fx-font-family: "Arial";
|
||||
-fx-font-size: 16px;
|
||||
-fx-font-weight: normal;
|
||||
}
|
||||