mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-18 22:56:15 +01:00
cleanup toolbar
This commit is contained in:
parent
9120e4d53c
commit
547a4c2353
@ -61,4 +61,9 @@ public class ChoosePartner extends Dialog {
|
||||
|
||||
app.getGuiNode().attachChild(background);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void escape() {
|
||||
new SettingsMenu(app).open();
|
||||
}
|
||||
}
|
||||
|
@ -27,11 +27,10 @@ public class Toolbar extends Dialog {
|
||||
private final MonopolyApp app;
|
||||
private final Container toolbarContainer;
|
||||
private final BitmapText positionText; // Anzeige für die aktuelle Position
|
||||
private final float boardLimit = 0.95f; // Grenzen des Bretts
|
||||
private final float stepSize = 0.18f; // Schrittgröße pro Bewegung
|
||||
private int currentPosition = 0; // Aktuelle Position auf dem Spielfeld
|
||||
private final int positionsPerSide = 10; // Anzahl der Positionen pro Seite
|
||||
private final Random random = new Random(); // Zufallsgenerator für den Würfelwurf
|
||||
private String diceOneImage = "Pictures/dice/one.png";
|
||||
private String diceTwoImage = "Pictures/dice/two.png";
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor für die Toolbar.
|
||||
@ -94,12 +93,12 @@ public class Toolbar extends Dialog {
|
||||
leftContainer.setPreferredSize(new Vector3f(100, 150, 0)); // Adjust size as needed
|
||||
|
||||
Label imageLabel = new Label("");
|
||||
IconComponent icon = new IconComponent("Pictures/dice/one.png"); // Icon mit Textur erstellen
|
||||
IconComponent icon = new IconComponent(diceOneImage); // Icon mit Textur erstellen
|
||||
icon.setIconSize(new Vector2f(100,100)); // Skalierung des Bildes
|
||||
imageLabel.setIcon(icon);
|
||||
|
||||
Label imageLabel2 = new Label("");
|
||||
IconComponent icon2 = new IconComponent("Pictures/dice/two.png"); // Icon mit Textur erstellen
|
||||
IconComponent icon2 = new IconComponent(diceTwoImage); // Icon mit Textur erstellen
|
||||
icon2.setIconSize(new Vector2f(100,100)); // Skalierung des Bildes
|
||||
imageLabel2.setIcon(icon2);
|
||||
|
||||
@ -132,7 +131,7 @@ public class Toolbar extends Dialog {
|
||||
Button diceButton = new Button("Würfeln");
|
||||
diceButton.setPreferredSize(new Vector3f(200, 50, 0)); // Full width for Würfeln button
|
||||
diceButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
rollDice();
|
||||
//TODO dice roll logic
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
}));
|
||||
diceContainer.addChild(diceButton);
|
||||
@ -142,9 +141,9 @@ public class Toolbar extends Dialog {
|
||||
|
||||
// Menü-Container: Ein Nested-Container für Handeln, Grundstücke und Zug beenden
|
||||
Container menuContainer = toolbarContainer.addChild(new Container());
|
||||
menuContainer.addChild(new Button("Handeln"));
|
||||
menuContainer.addChild(new Button("Grundstücke"));
|
||||
menuContainer.addChild(new Button("Zug beenden"));
|
||||
menuContainer.addChild(addTradeMenuButton());
|
||||
menuContainer.addChild(addPropertyMenuButton());
|
||||
menuContainer.addChild(addEndTurnButton());
|
||||
menuContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
|
||||
// Füge die Toolbar zur GUI hinzu
|
||||
@ -155,107 +154,35 @@ public class Toolbar extends Dialog {
|
||||
updatePositionDisplay(); // Initialisiere die Anzeige mit der Startposition
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialisiert die Buttons in der Toolbar.
|
||||
*/
|
||||
private void initializeButtons() {
|
||||
addTradeMenuButton(); // Bewegung nach vorne
|
||||
addEndTurnButton(); // Bewegung nach hinten
|
||||
addDiceRollButton(); // Würfel-Button
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt einen Button mit einer Bewegung hinzu.
|
||||
*
|
||||
* @param label Der Text des Buttons
|
||||
* @param step Schrittweite (+1 für vorwärts, -1 für rückwärts)
|
||||
*/
|
||||
|
||||
/*private void addButton(String label, int step) {
|
||||
Button button = new Button(label);
|
||||
button.setPreferredSize(new Vector3f(150, 50, 0)); // Größe der Buttons
|
||||
button.addClickCommands(source -> moveCube(step));
|
||||
toolbarContainer.addChild(button);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Fügt den Würfel-Button hinzu, der die Figur entsprechend der gewürfelten Zahl bewegt.
|
||||
*/
|
||||
private Button addDiceRollButton() {
|
||||
Button diceButton = new Button("Würfeln");
|
||||
diceButton.setPreferredSize(new Vector3f(50, 20, 0));
|
||||
diceButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
rollDice();
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
}));
|
||||
toolbarContainer.addChild(diceButton);
|
||||
return diceButton;
|
||||
}
|
||||
|
||||
private void addTradeMenuButton() {
|
||||
Button diceButton = new Button("Handeln");
|
||||
diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
||||
diceButton.addClickCommands(s -> {
|
||||
rollDice();
|
||||
private Button addTradeMenuButton() {
|
||||
Button tradebutton = new Button("Handeln");
|
||||
tradebutton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
||||
tradebutton.addClickCommands(s -> ifTopDialog( () -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
this.close();
|
||||
System.out.println("test");
|
||||
new ChoosePartner(app).open();
|
||||
});
|
||||
toolbarContainer.addChild(diceButton);
|
||||
}// TODO Funktion der Buttons Überarbeiten und prüfen
|
||||
|
||||
private void addEndTurnButton() {
|
||||
Button diceButton = new Button("Grundstücke");
|
||||
diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
||||
diceButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
rollDice();
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
}));
|
||||
toolbarContainer.addChild(diceButton);
|
||||
return tradebutton;
|
||||
}
|
||||
|
||||
private void addPropertyMenuButton() {
|
||||
Button diceButton = new Button("Zug beenden");
|
||||
diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
||||
diceButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
rollDice();
|
||||
private Button addEndTurnButton() {
|
||||
Button endTurnButton = new Button("Grundstücke");
|
||||
endTurnButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
||||
endTurnButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
//TODO open property dialog
|
||||
}));
|
||||
toolbarContainer.addChild(diceButton);
|
||||
return endTurnButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simuliert einen Würfelwurf und bewegt die Figur entsprechend.
|
||||
*/
|
||||
private void rollDice() {
|
||||
int diceRoll = random.nextInt(6) + 1; // Zahl zwischen 1 und 6
|
||||
System.out.println("Gewürfelt: " + diceRoll);
|
||||
}
|
||||
|
||||
/**
|
||||
* Berechnet die neue Position des Würfels basierend auf der aktuellen Brettseite und Position.
|
||||
*
|
||||
* @param position Aktuelle Position auf dem Spielfeld
|
||||
* @return Die berechnete Position als Vector3f
|
||||
*/
|
||||
private Vector3f calculatePosition(int position) {
|
||||
int side = position / positionsPerSide; // Seite des Bretts (0 = unten, 1 = rechts, 2 = oben, 3 = links)
|
||||
int offset = position % positionsPerSide; // Position auf der aktuellen Seite
|
||||
|
||||
switch (side) {
|
||||
case 0: // Unten (positive x-Achse)
|
||||
return new Vector3f(-boardLimit + offset * stepSize, 0.1f, -boardLimit + 0.05f);
|
||||
case 1: // Rechts (positive z-Achse)
|
||||
return new Vector3f(boardLimit - 0.05f, 0.1f, -boardLimit + offset * stepSize);
|
||||
case 2: // Oben (negative x-Achse)
|
||||
return new Vector3f(boardLimit - offset * stepSize, 0.1f, boardLimit - 0.05f);
|
||||
case 3: // Links (negative z-Achse)
|
||||
return new Vector3f(-boardLimit + 0.05f, 0.1f, boardLimit - offset * stepSize);
|
||||
default:
|
||||
throw new IllegalArgumentException("Ungültige Position: " + position);
|
||||
}
|
||||
private Button addPropertyMenuButton() {
|
||||
Button propertyMenuButton = new Button("Zug beenden");
|
||||
propertyMenuButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
||||
propertyMenuButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
//TODO send end turn
|
||||
}));
|
||||
return propertyMenuButton;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user