mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-29 01:59:42 +01:00
cleanup
This commit is contained in:
parent
6eeb6fd209
commit
f4c4f6bc93
@ -19,6 +19,7 @@ import pp.dialog.Dialog;
|
|||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
import pp.monopoly.game.server.PlayerHandler;
|
import pp.monopoly.game.server.PlayerHandler;
|
||||||
|
import pp.monopoly.message.client.EndTurn;
|
||||||
import pp.monopoly.message.client.RollDice;
|
import pp.monopoly.message.client.RollDice;
|
||||||
import pp.monopoly.notification.DiceRollEvent;
|
import pp.monopoly.notification.DiceRollEvent;
|
||||||
import pp.monopoly.notification.GameEventListener;
|
import pp.monopoly.notification.GameEventListener;
|
||||||
@ -32,10 +33,11 @@ public class Toolbar extends Dialog implements GameEventListener{
|
|||||||
|
|
||||||
private final MonopolyApp app;
|
private final MonopolyApp app;
|
||||||
private final Container toolbarContainer;
|
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 imageLabel;
|
||||||
private Label imageLabel2;
|
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;
|
this.app = app;
|
||||||
|
|
||||||
app.getGameLogic().addListener(this);
|
app.getGameLogic().addListener(this);
|
||||||
|
playerHandler = app.getGameLogic().getPlayerHandler();
|
||||||
|
|
||||||
// Erstelle die Toolbar
|
// Erstelle die Toolbar
|
||||||
toolbarContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y), "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
|
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"
|
// 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("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("Gulag Frei Karten", new ElementId("label-Bold")));
|
||||||
accountContainer.addChild(new Label(playerHandler.getPlayerById(app.getId()).getNumJailCard()+"", new ElementId("label-Text")));
|
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)));
|
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
|
// 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")));
|
overviewContainer.addChild(new Label("Übersicht", new ElementId("label-Bold")));
|
||||||
|
|
||||||
for (Player player : playerHandler.getPlayers()) {
|
for (Player player : playerHandler.getPlayers()) {
|
||||||
@ -161,10 +157,6 @@ public class Toolbar extends Dialog implements GameEventListener{
|
|||||||
|
|
||||||
// Füge die Toolbar zur GUI hinzu
|
// Füge die Toolbar zur GUI hinzu
|
||||||
app.getGuiNode().attachChild(toolbarContainer);
|
app.getGuiNode().attachChild(toolbarContainer);
|
||||||
|
|
||||||
// Erstelle die Position-Anzeige
|
|
||||||
positionText = createPositionDisplay();
|
|
||||||
updatePositionDisplay(); // Initialisiere die Anzeige mit der Startposition
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Button addTradeMenuButton() {
|
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.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
||||||
endTurnButton.addClickCommands(s -> ifTopDialog(() -> {
|
endTurnButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
//TODO send end turn
|
app.getGameLogic().send(new EndTurn());
|
||||||
}));
|
}));
|
||||||
return endTurnButton;
|
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
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
app.getGuiNode().detachChild(toolbarContainer);
|
app.getGuiNode().detachChild(toolbarContainer);
|
||||||
app.getGuiNode().detachChild(positionText);
|
|
||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,6 +208,7 @@ public class Toolbar extends Dialog implements GameEventListener{
|
|||||||
|
|
||||||
|
|
||||||
private void updateDiceImages(int a, int b) {
|
private void updateDiceImages(int a, int b) {
|
||||||
|
//TODO dice toll animation
|
||||||
IconComponent icon1 = new IconComponent(diceToString(a));
|
IconComponent icon1 = new IconComponent(diceToString(a));
|
||||||
IconComponent icon2 = new IconComponent(diceToString(b));
|
IconComponent icon2 = new IconComponent(diceToString(b));
|
||||||
icon1.setIconSize(new Vector2f(100, 100));
|
icon1.setIconSize(new Vector2f(100, 100));
|
||||||
|
Loading…
Reference in New Issue
Block a user