This commit is contained in:
Johannes Schmelz 2024-11-26 17:53:49 +01:00
parent 6eeb6fd209
commit f4c4f6bc93

View File

@ -19,6 +19,7 @@ import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.game.server.Player;
import pp.monopoly.game.server.PlayerHandler;
import pp.monopoly.message.client.EndTurn;
import pp.monopoly.message.client.RollDice;
import pp.monopoly.notification.DiceRollEvent;
import pp.monopoly.notification.GameEventListener;
@ -32,10 +33,11 @@ public class Toolbar extends Dialog implements GameEventListener{
private final MonopolyApp app;
private final Container toolbarContainer;
private final BitmapText positionText; // Anzeige für die aktuelle Position
private int currentPosition = 0; // Aktuelle Position auf dem Spielfeld
private Label imageLabel;
private Label imageLabel2;
private Container overviewContainer;
private Container accountContainer;
private PlayerHandler playerHandler;
/**
@ -48,6 +50,7 @@ public class Toolbar extends Dialog implements GameEventListener{
this.app = app;
app.getGameLogic().addListener(this);
playerHandler = app.getGameLogic().getPlayerHandler();
// Erstelle die Toolbar
toolbarContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y), "toolbar");
@ -60,24 +63,17 @@ public class Toolbar extends Dialog implements GameEventListener{
);
toolbarContainer.setPreferredSize(new Vector3f(app.getCamera().getWidth(), 200, 0)); // Volle Breite
PlayerHandler playerHandler = app.getGameLogic().getPlayerHandler();
// Menü-Container: Ein Nested-Container für Kontostand und "Meine Gulag Frei Karten"
Container accountContainer = toolbarContainer.addChild(new Container());
accountContainer = toolbarContainer.addChild(new Container());
accountContainer.addChild(new Label("Kontostand", new ElementId("label-Bold")));
accountContainer.addChild(new Label(playerHandler.getPlayerById(app.getId()).getAccountBalance() + " EUR", new ElementId("label-Text"))); //TODO Variable hier einsetzen
accountContainer.addChild(new Label(playerHandler.getPlayerById(app.getId()).getAccountBalance() + " EUR", new ElementId("label-Text")));
accountContainer.addChild(new Label("Gulag Frei Karten", new ElementId("label-Bold")));
accountContainer.addChild(new Label(playerHandler.getPlayerById(app.getId()).getNumJailCard()+"", new ElementId("label-Text")));
accountContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
// // Add a spacer between accountContainer and overviewContainer
// Panel spacer = new Panel(); // Create an empty panel as a spacer
// spacer.setPreferredSize(new Vector3f(5, 0, 0)); // Adjust the width as needed
// spacer.setBackground(null);
// toolbarContainer.addChild(spacer);
// Menü-Container: Ein Container für Übersicht
Container overviewContainer = toolbarContainer.addChild(new Container());
overviewContainer = toolbarContainer.addChild(new Container());
overviewContainer.addChild(new Label("Übersicht", new ElementId("label-Bold")));
for (Player player : playerHandler.getPlayers()) {
@ -161,10 +157,6 @@ public class Toolbar extends Dialog implements GameEventListener{
// Füge die Toolbar zur GUI hinzu
app.getGuiNode().attachChild(toolbarContainer);
// Erstelle die Position-Anzeige
positionText = createPositionDisplay();
updatePositionDisplay(); // Initialisiere die Anzeige mit der Startposition
}
private Button addTradeMenuButton() {
@ -193,35 +185,14 @@ public class Toolbar extends Dialog implements GameEventListener{
endTurnButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
endTurnButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON);
//TODO send end turn
app.getGameLogic().send(new EndTurn());
}));
return endTurnButton;
}
/**
* Erstellt die Anzeige für die aktuelle Position.
*
* @return Das BitmapText-Objekt für die Anzeige
*/
private BitmapText createPositionDisplay() {
BitmapText text = new BitmapText(app.getAssetManager().loadFont("Interface/Fonts/Default.fnt"), false);
text.setSize(20); // Schriftgröße
text.setLocalTranslation(10, app.getCamera().getHeight() - 10, 0); // Oben links
app.getGuiNode().attachChild(text);
return text;
}
/**
* Aktualisiert die Anzeige für die aktuelle Position.
*/
private void updatePositionDisplay() {
positionText.setText("Feld-ID: " + currentPosition);
}
@Override
public void close() {
app.getGuiNode().detachChild(toolbarContainer);
app.getGuiNode().detachChild(positionText);
super.close();
}
@ -237,6 +208,7 @@ public class Toolbar extends Dialog implements GameEventListener{
private void updateDiceImages(int a, int b) {
//TODO dice toll animation
IconComponent icon1 = new IconComponent(diceToString(a));
IconComponent icon2 = new IconComponent(diceToString(b));
icon1.setIconSize(new Vector2f(100, 100));