Merge remote-tracking branch 'origin/OtherGames' into OtherGames

This commit is contained in:
ramollia
2025-10-27 17:21:32 +01:00
26 changed files with 546 additions and 10 deletions

View File

@@ -0,0 +1,115 @@
package org.toop.app.view.displays;
import javafx.application.Platform;
import javafx.scene.control.Button;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import org.toop.framework.audio.AudioEventListener;
import org.toop.framework.audio.events.AudioEvents;
import org.toop.framework.eventbus.EventFlow;
import javafx.geometry.Pos;
import javafx.scene.text.Text;
import org.toop.framework.eventbus.GlobalEventBus;
public class SongDisplay extends VBox {
private final Text songTitle;
private final ProgressBar progressBar;
private final Text progressText;
public SongDisplay() {
new EventFlow()
.listen(this::updateTheSong);
setAlignment(Pos.CENTER);
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("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.post(new AudioEvents.SkipMusic());
});
pauseButton.setOnAction(event -> {
GlobalEventBus.post(new AudioEvents.PauseMusic());
if (pauseButton.getText().equals("")) {
pauseButton.setText("");
}
else if (pauseButton.getText().equals("")) {
pauseButton.setText("");
}
});
previousButton.setOnAction( event -> {
GlobalEventBus.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;
}
}

View File

@@ -4,6 +4,7 @@ import org.toop.app.GameInformation;
import org.toop.app.Server;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.app.view.displays.SongDisplay;
import org.toop.local.AppContext;
import javafx.geometry.Pos;
@@ -95,6 +96,14 @@ public final class ChallengeView extends View {
nodes.add(vbox(computerDifficultyText, computerDifficultySlider));
}
final SongDisplay songdisplay = new SongDisplay();
add(Pos.BOTTOM_RIGHT,
fit(vboxFill(
songdisplay
)));
add(Pos.CENTER,
fit(hboxFill(
vboxFill(

View File

@@ -3,6 +3,7 @@ package org.toop.app.view.views;
import org.toop.app.App;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.app.view.displays.SongDisplay;
import org.toop.local.AppContext;
import javafx.animation.KeyFrame;
@@ -46,6 +47,14 @@ public final class CreditsView extends View {
final Text openglHeader = header();
openglHeader.setText(AppContext.getString("opengl") + ": Omar");
final SongDisplay songdisplay = new SongDisplay();
add(Pos.BOTTOM_RIGHT,
fit(vboxFill(
songdisplay
)));
add(Pos.CENTER,
fit("credits-fit", vboxFill("credits-container", "credits-container",
vbox("credits-spacer-top", ""),

View File

@@ -2,6 +2,7 @@ package org.toop.app.view.views;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.app.view.displays.SongDisplay;
import org.toop.local.AppContext;
import javafx.geometry.Pos;
@@ -85,6 +86,14 @@ public final class GameView extends View {
forfeitButton = null;
}
final SongDisplay songdisplay = new SongDisplay();
add(Pos.BOTTOM_RIGHT,
fit(vboxFill(
songdisplay
)));
if (onMessage != null) {
chatListView = new ListView<Text>();

View File

@@ -6,6 +6,7 @@ import org.toop.app.game.ReversiGame;
import org.toop.app.game.TicTacToeGame;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.app.view.displays.SongDisplay;
import org.toop.local.AppContext;
import javafx.geometry.Pos;
@@ -51,6 +52,14 @@ public final class LocalMultiplayerView extends View {
}
});
final SongDisplay songdisplay = new SongDisplay();
add(Pos.BOTTOM_RIGHT,
fit(vboxFill(
songdisplay
)));
add(Pos.CENTER,
fit(vboxFill(
hbox(

View File

@@ -3,6 +3,7 @@ package org.toop.app.view.views;
import org.toop.app.GameInformation;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.app.view.displays.SongDisplay;
import org.toop.local.AppContext;
import javafx.geometry.Pos;
@@ -39,6 +40,14 @@ public final class LocalView extends View {
backButton.setText(AppContext.getString("back"));
backButton.setOnAction(_ -> { ViewStack.push(new MainView()); });
final SongDisplay songdisplay = new SongDisplay();
add(Pos.BOTTOM_RIGHT,
fit(vboxFill(
songdisplay
)));
add(Pos.BOTTOM_LEFT,
vboxFill(
backButton

View File

@@ -4,7 +4,7 @@ import org.toop.app.App;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.local.AppContext;
import org.toop.app.view.displays.SongDisplay;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
@@ -35,6 +35,13 @@ public final class MainView extends View {
quitButton.setText(AppContext.getString("quit"));
quitButton.setOnAction(_ -> { App.startQuit(); });
final SongDisplay songdisplay = new SongDisplay();
add(Pos.BOTTOM_RIGHT,
fit(vboxFill(
songdisplay
)));
add(Pos.CENTER,
fit(vboxFill(
localButton,

View File

@@ -3,6 +3,7 @@ package org.toop.app.view.views;
import org.toop.app.Server;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.app.view.displays.SongDisplay;
import org.toop.local.AppContext;
import javafx.geometry.Pos;
@@ -44,6 +45,13 @@ public class OnlineView extends View {
new Server(serverIPInput.getText(), serverPortInput.getText(), playerNameInput.getText());
});
final SongDisplay songdisplay = new SongDisplay();
add(Pos.BOTTOM_RIGHT,
fit(vboxFill(
songdisplay
)));
add(Pos.CENTER,
fit(vboxFill(
serverInformationHeader,

View File

@@ -3,6 +3,7 @@ package org.toop.app.view.views;
import org.toop.app.App;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.app.view.displays.SongDisplay;
import org.toop.framework.audio.VolumeControl;
import org.toop.framework.audio.events.AudioEvents;
import org.toop.framework.eventbus.EventFlow;
@@ -99,6 +100,14 @@ public final class OptionsView extends View {
backButton.setText(AppContext.getString("back"));
backButton.setOnAction(_ -> { ViewStack.pop(); });
final SongDisplay songdisplay = new SongDisplay();
add(Pos.BOTTOM_RIGHT,
fit(vboxFill(
songdisplay
)));
add(Pos.BOTTOM_LEFT,
vboxFill(
backButton

View File

@@ -2,6 +2,7 @@ package org.toop.app.view.views;
import org.toop.app.view.View;
import org.toop.app.view.ViewStack;
import org.toop.app.view.displays.SongDisplay;
import org.toop.local.AppContext;
import javafx.application.Platform;
@@ -53,6 +54,14 @@ public final class ServerView extends View {
listView = new ListView<Button>();
final SongDisplay songdisplay = new SongDisplay();
add(Pos.BOTTOM_RIGHT,
fit(vboxFill(
songdisplay
)));
add(Pos.CENTER,
fit(vboxFill(
vbox(

View File

@@ -12,6 +12,71 @@
-fx-effect: dropshadow(gaussian, #224455cc, 8, 0, 0, 2);
}
.song-display {
-fx-padding: 8 12 8 12;
-fx-spacing: 6px;
-fx-alignment: center;
-fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.5), 6, 0.5, 0, 2);
-fx-min-width: 220px;
-fx-max-width: 260px;
}
.song-title {
-fx-font-size: 14px;
-fx-fill: white;
}
.progress-bar {
-fx-pref-width: 200px;
-fx-accent: red;
}
.progress-bar > .track {
-fx-background-radius: 30;
}
.progress-bar > .bar {
-fx-background-radius: 30px;
}
.progress-text {
-fx-font-size: 11px;
-fx-fill: white;
}
.skip-button {
-fx-background-color: transparent;
-fx-background-radius: 0;
-fx-cursor: hand;
-fx-text-fill: white;
}
.skip-button .text {
-fx-fill: white;
}
.pause-button {
-fx-background-color: transparent;
-fx-background-radius: 0;
-fx-cursor: hand;
-fx-text-fill: white;
}
.pause-button .text {
-fx-fill: white;
}
.previous-button {
-fx-background-color: transparent;
-fx-background-radius: 0;
-fx-cursor: hand;
-fx-text-fill: white;
}
.previous-button .text {
-fx-fill: white;
}
.button {
-fx-background-color: linear-gradient(to bottom, #1f5e20, #2e7d2e);
-fx-background-radius: 8;

View File

@@ -12,6 +12,71 @@
-fx-effect: dropshadow(gaussian, #1f6a22ff, 10, 0, 0, 3);
}
.song-display {
-fx-padding: 8 12 8 12;
-fx-spacing: 6px;
-fx-alignment: center;
-fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.5), 6, 0.5, 0, 2);
-fx-min-width: 220px;
-fx-max-width: 260px;
}
.song-title {
-fx-font-size: 14px;
-fx-fill: white;
}
.progress-bar {
-fx-pref-width: 200px;
-fx-accent: red;
}
.progress-bar > .track {
-fx-background-radius: 30;
}
.progress-bar > .bar {
-fx-background-radius: 30px;
}
.progress-text {
-fx-font-size: 11px;
-fx-fill: white;
}
.skip-button {
-fx-background-color: transparent;
-fx-background-radius: 0;
-fx-cursor: hand;
-fx-text-fill: white;
}
.skip-button .text {
-fx-fill: white;
}
.pause-button {
-fx-background-color: transparent;
-fx-background-radius: 0;
-fx-cursor: hand;
-fx-text-fill: white;
}
.pause-button .text {
-fx-fill: white;
}
.previous-button {
-fx-background-color: transparent;
-fx-background-radius: 0;
-fx-cursor: hand;
-fx-text-fill: white;
}
.previous-button .text {
-fx-fill: white;
}
.button {
-fx-background-color: linear-gradient(to bottom, #1b7a1b, #2da32d);
-fx-background-radius: 8;

View File

@@ -12,6 +12,72 @@
-fx-effect: dropshadow(gaussian, #a0c4b088, 6, 0, 0, 2);
}
.song-display {
-fx-padding: 8 12 8 12;
-fx-spacing: 6px;
-fx-alignment: center;
-fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.5), 6, 0.5, 0, 2);
-fx-min-width: 220px;
-fx-max-width: 260px;
}
.song-title {
-fx-font-size: 14px;
-fx-fill: black;
}
.progress-bar {
-fx-inner-background-color: black;
-fx-pref-width: 200px;
-fx-accent: red;
}
.progress-bar > .track {
-fx-background-radius: 30;
}
.progress-bar > .bar {
-fx-background-radius: 30px;
}
.progress-text {
-fx-font-size: 11px;
-fx-fill: black;
}
.skip-button {
-fx-background-color: transparent;
-fx-background-radius: 0;
-fx-cursor: hand;
-fx-text-fill: black;
}
.skip-button .text {
-fx-fill: black;
}
.pause-button {
-fx-background-color: transparent;
-fx-background-radius: 0;
-fx-cursor: hand;
-fx-text-fill: black;
}
.pause-button .text {
-fx-fill: black;
}
.previous-button {
-fx-background-color: transparent;
-fx-background-radius: 0;
-fx-cursor: hand;
-fx-text-fill: black;
}
.previous-button .text {
-fx-fill: black;
}
.button {
-fx-background-color: linear-gradient(to bottom, #7ac27a, #90d090);
-fx-background-radius: 8;