mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
Merge remote-tracking branch 'origin/Development' into Development
This commit is contained in:
@@ -152,6 +152,7 @@ public final class Server {
|
|||||||
information.players[0].name = user;
|
information.players[0].name = user;
|
||||||
information.players[0].isHuman = false;
|
information.players[0].isHuman = false;
|
||||||
information.players[0].computerDifficulty = 5;
|
information.players[0].computerDifficulty = 5;
|
||||||
|
information.players[0].computerThinkTime = 1;
|
||||||
information.players[1].name = response.opponent();
|
information.players[1].name = response.opponent();
|
||||||
|
|
||||||
Runnable onGameOverRunnable = isSingleGame.get()? null: this::gameOver;
|
Runnable onGameOverRunnable = isSingleGame.get()? null: this::gameOver;
|
||||||
|
|||||||
@@ -230,12 +230,7 @@ public final class TicTacToeGame {
|
|||||||
} catch (InterruptedException _) {}
|
} catch (InterruptedException _) {}
|
||||||
} else {
|
} else {
|
||||||
final Game.Move move;
|
final Game.Move move;
|
||||||
if (information.players[1].name.equalsIgnoreCase("pism")) {
|
|
||||||
move = ai.findWorstMove(game,9);
|
|
||||||
}else{
|
|
||||||
move = ai.findBestMove(game, information.players[0].computerDifficulty);
|
move = ai.findBestMove(game, information.players[0].computerDifficulty);
|
||||||
}
|
|
||||||
|
|
||||||
assert move != null;
|
assert move != null;
|
||||||
position = move.position();
|
position = move.position();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class SongDisplay extends VBox {
|
|||||||
private final Text songTitle;
|
private final Text songTitle;
|
||||||
private final ProgressBar progressBar;
|
private final ProgressBar progressBar;
|
||||||
private final Text progressText;
|
private final Text progressText;
|
||||||
|
private boolean paused = false;
|
||||||
|
|
||||||
public SongDisplay() {
|
public SongDisplay() {
|
||||||
new EventFlow()
|
new EventFlow()
|
||||||
@@ -26,7 +27,6 @@ public class SongDisplay extends VBox {
|
|||||||
setAlignment(Pos.CENTER);
|
setAlignment(Pos.CENTER);
|
||||||
getStyleClass().add("song-display");
|
getStyleClass().add("song-display");
|
||||||
|
|
||||||
// TODO ADD GOOD SONG TITLES WITH ARTISTS DISPLAYED
|
|
||||||
songTitle = new Text("song playing");
|
songTitle = new Text("song playing");
|
||||||
songTitle.getStyleClass().add("song-title");
|
songTitle.getStyleClass().add("song-title");
|
||||||
|
|
||||||
@@ -36,8 +36,6 @@ public class SongDisplay extends VBox {
|
|||||||
progressText = new Text("0:00/0:00");
|
progressText = new Text("0:00/0:00");
|
||||||
progressText.getStyleClass().add("progress-text");
|
progressText.getStyleClass().add("progress-text");
|
||||||
|
|
||||||
// TODO ADD BETTER CSS FOR THE SKIPBUTTON WHERE ITS AT A NICER POSITION
|
|
||||||
|
|
||||||
Button skipButton = new Button(">>");
|
Button skipButton = new Button(">>");
|
||||||
Button pauseButton = new Button("⏸");
|
Button pauseButton = new Button("⏸");
|
||||||
Button previousButton = new Button("<<");
|
Button previousButton = new Button("<<");
|
||||||
@@ -48,20 +46,20 @@ public class SongDisplay extends VBox {
|
|||||||
|
|
||||||
skipButton.setOnAction( event -> {
|
skipButton.setOnAction( event -> {
|
||||||
GlobalEventBus.post(new AudioEvents.SkipMusic());
|
GlobalEventBus.post(new AudioEvents.SkipMusic());
|
||||||
|
paused = false;
|
||||||
|
pauseButton.setText(getPlayString(paused));
|
||||||
});
|
});
|
||||||
|
|
||||||
pauseButton.setOnAction(event -> {
|
pauseButton.setOnAction(event -> {
|
||||||
GlobalEventBus.post(new AudioEvents.PauseMusic());
|
GlobalEventBus.post(new AudioEvents.PauseMusic());
|
||||||
if (pauseButton.getText().equals("⏸")) {
|
paused = !paused;
|
||||||
pauseButton.setText("▶");
|
pauseButton.setText(getPlayString(paused));
|
||||||
}
|
|
||||||
else if (pauseButton.getText().equals("▶")) {
|
|
||||||
pauseButton.setText("⏸");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
previousButton.setOnAction( event -> {
|
previousButton.setOnAction( event -> {
|
||||||
GlobalEventBus.post(new AudioEvents.PreviousMusic());
|
GlobalEventBus.post(new AudioEvents.PreviousMusic());
|
||||||
|
paused = false;
|
||||||
|
pauseButton.setText(getPlayString(paused));
|
||||||
});
|
});
|
||||||
|
|
||||||
HBox control = new HBox(10, previousButton, pauseButton, skipButton);
|
HBox control = new HBox(10, previousButton, pauseButton, skipButton);
|
||||||
@@ -107,6 +105,15 @@ public class SongDisplay extends VBox {
|
|||||||
String time = positionMinutes + ":" + positionSecondsStr + " / " + durationMinutes + ":" + durationSecondsStr;
|
String time = positionMinutes + ":" + positionSecondsStr + " / " + durationMinutes + ":" + durationSecondsStr;
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getPlayString(boolean paused) {
|
||||||
|
if (paused) {
|
||||||
|
return "▶";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "⏸";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package org.toop.local;
|
package org.toop.local;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.MissingResourceException;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.toop.framework.resource.ResourceManager;
|
import org.toop.framework.resource.ResourceManager;
|
||||||
import org.toop.framework.resource.resources.LocalizationAsset;
|
import org.toop.framework.resource.resources.LocalizationAsset;
|
||||||
|
|
||||||
@@ -8,6 +12,8 @@ public class AppContext {
|
|||||||
private static final LocalizationAsset localization = ResourceManager.get("localization");
|
private static final LocalizationAsset localization = ResourceManager.get("localization");
|
||||||
private static Locale locale = Locale.forLanguageTag("en");
|
private static Locale locale = Locale.forLanguageTag("en");
|
||||||
|
|
||||||
|
private static final Logger logger = LogManager.getLogger(AppContext.class);
|
||||||
|
|
||||||
public static LocalizationAsset getLocalization() {
|
public static LocalizationAsset getLocalization() {
|
||||||
return localization;
|
return localization;
|
||||||
}
|
}
|
||||||
@@ -22,6 +28,24 @@ public class AppContext {
|
|||||||
|
|
||||||
public static String getString(String key) {
|
public static String getString(String key) {
|
||||||
assert localization != null;
|
assert localization != null;
|
||||||
|
|
||||||
|
// TODO: Gebruik ResourceBundle.getBundle() zodat de fallback automatisch gaat.
|
||||||
|
// Hiervoor zou de assetManager aangepast moeten worden.
|
||||||
|
|
||||||
|
try{ // Main return
|
||||||
return localization.getString(key, locale);
|
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";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -63,6 +63,9 @@ public class LocalizationAsset extends BaseResource implements LoadableResource,
|
|||||||
loaded = false;
|
loaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the fallback locale used when locale is missing argument*/
|
||||||
|
public Locale getFallback() {return this.fallback;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether this asset has been loaded.
|
* Checks whether this asset has been loaded.
|
||||||
*
|
*
|
||||||
@@ -126,7 +129,7 @@ public class LocalizationAsset extends BaseResource implements LoadableResource,
|
|||||||
public void loadFile(File file) {
|
public void loadFile(File file) {
|
||||||
try (InputStreamReader reader =
|
try (InputStreamReader reader =
|
||||||
new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)) {
|
new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)) {
|
||||||
Locale locale = extractLocale(file.getName(), baseName);
|
Locale locale = extractLocale(file.getName());
|
||||||
bundles.put(locale, new PropertyResourceBundle(reader));
|
bundles.put(locale, new PropertyResourceBundle(reader));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("Failed to load localization file: " + file, e);
|
throw new RuntimeException("Failed to load localization file: " + file, e);
|
||||||
@@ -166,10 +169,9 @@ public class LocalizationAsset extends BaseResource implements LoadableResource,
|
|||||||
* Extracts a locale from a file name based on the pattern "base_LOCALE.properties".
|
* Extracts a locale from a file name based on the pattern "base_LOCALE.properties".
|
||||||
*
|
*
|
||||||
* @param fileName the file name
|
* @param fileName the file name
|
||||||
* @param baseName the base name
|
|
||||||
* @return extracted locale, or fallback if none found
|
* @return extracted locale, or fallback if none found
|
||||||
*/
|
*/
|
||||||
private Locale extractLocale(String fileName, String baseName) {
|
private Locale extractLocale(String fileName) {
|
||||||
int underscoreIndex = fileName.indexOf('_');
|
int underscoreIndex = fileName.indexOf('_');
|
||||||
int dotIndex = fileName.lastIndexOf('.');
|
int dotIndex = fileName.lastIndexOf('.');
|
||||||
if (underscoreIndex > 0 && dotIndex > underscoreIndex) {
|
if (underscoreIndex > 0 && dotIndex > underscoreIndex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user