mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-04-12 04:21:08 +02:00
Compare commits
3 Commits
09ea8a046e
...
eaff7b6c5d
Author | SHA1 | Date | |
---|---|---|---|
|
eaff7b6c5d | ||
|
9ee1b5b81b | ||
|
49b9972ade |
@ -23,6 +23,7 @@ import pp.monopoly.notification.Sound;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Represents the trade menu dialog in the Monopoly application.
|
||||
* <p>
|
||||
@ -45,7 +46,7 @@ public class TradeMenu extends Dialog {
|
||||
private Geometry background;
|
||||
private Selector<String> leftBuildingSelector, leftSpecialCardSelector;
|
||||
private Selector<String> rightBuildingSelector, rightSpecialCardSelector;
|
||||
private TextField leftSelectionsField, rightSelectionsField;
|
||||
private Label leftSelectionsLabel, rightSelectionsLabel;
|
||||
private TextField leftCurrencyInput, rightCurrencyInput;
|
||||
|
||||
private VersionedReference<Set<Integer>> leftBuildingRef, rightBuildingRef;
|
||||
@ -217,12 +218,14 @@ public class TradeMenu extends Dialog {
|
||||
Container middleSection = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
||||
middleSection.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8f, 0.8f, 0.8f, 1.0f)));
|
||||
|
||||
Label middleLabelTop = middleSection.addChild(new Label("Gebäude: Währung: Sonderkarten:"));
|
||||
Label middleLabelTop = middleSection.addChild(new Label("Meine Gebäude:"));
|
||||
middleLabelTop.setFontSize(24);
|
||||
middleLabelTop.setTextVAlignment(VAlignment.Center);
|
||||
middleLabelTop.setTextHAlignment(HAlignment.Center);
|
||||
middleLabelTop.setInsets(new Insets3f(5, 5, 5, 5));
|
||||
|
||||
leftSelectionsField = middleSection.addChild(new TextField(""));
|
||||
leftSelectionsField.setPreferredSize(new Vector3f(600, 50, 0));
|
||||
leftSelectionsLabel = middleSection.addChild(new Label(""));
|
||||
leftSelectionsLabel.setPreferredSize(new Vector3f(600, 50, 0));
|
||||
|
||||
Container buttons = middleSection.addChild(new Container(new SpringGridLayout()));
|
||||
Button cancel = new Button("Abbrechen");
|
||||
@ -242,12 +245,14 @@ public class TradeMenu extends Dialog {
|
||||
buttons.addChild(cancel);
|
||||
buttons.addChild(trade);
|
||||
|
||||
Label middleLabelBottom = middleSection.addChild(new Label("Gebäude: Währung: Sonderkarten:"));
|
||||
Label middleLabelBottom = middleSection.addChild(new Label("Gebäude des Gegenspielers:"));
|
||||
middleLabelBottom.setFontSize(24);
|
||||
middleLabelBottom.setTextVAlignment(VAlignment.Center);
|
||||
middleLabelBottom.setTextHAlignment(HAlignment.Center);
|
||||
middleLabelBottom.setInsets(new Insets3f(5, 5, 5, 5));
|
||||
|
||||
rightSelectionsField = middleSection.addChild(new TextField(""));
|
||||
rightSelectionsField.setPreferredSize(new Vector3f(600, 50, 0));
|
||||
rightSelectionsLabel = middleSection.addChild(new Label(""));
|
||||
rightSelectionsLabel.setPreferredSize(new Vector3f(600, 50, 0));
|
||||
return middleSection;
|
||||
}
|
||||
|
||||
@ -321,25 +326,23 @@ public class TradeMenu extends Dialog {
|
||||
*/
|
||||
@Override
|
||||
public void update(float delta) {
|
||||
if (leftBuildingRef.update() || leftCardRef.update() || leftCurrencyRef.update()) {
|
||||
updateSelections(leftSelectionsField, leftBuildingSelector, leftCurrencyInput, leftSpecialCardSelector, true);
|
||||
if (leftBuildingRef.update() || leftCardRef.update()) {
|
||||
updateSelections(leftSelectionsLabel, leftBuildingSelector, true);
|
||||
}
|
||||
|
||||
if (rightBuildingRef.update() || rightCardRef.update() || rightCurrencyRef.update()) {
|
||||
updateSelections(rightSelectionsField, rightBuildingSelector, rightCurrencyInput, rightSpecialCardSelector, false);
|
||||
if (rightBuildingRef.update() || rightCardRef.update()) {
|
||||
updateSelections(rightSelectionsLabel, rightBuildingSelector, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the displayed selections for properties, currency, and cards.
|
||||
* Updates the displayed selections for properties.
|
||||
*
|
||||
* @param target the target text field to update
|
||||
* @param target the target label to update
|
||||
* @param building the building selector
|
||||
* @param currency the currency input field
|
||||
* @param card the special card selector
|
||||
* @param isLeft true if updating the left column; false otherwise
|
||||
*/
|
||||
private void updateSelections(TextField target, Selector<String> building, TextField currency, Selector<String> card, boolean isLeft) {
|
||||
private void updateSelections(Label target, Selector<String> building, boolean isLeft) {
|
||||
StringBuilder buildingText = new StringBuilder();
|
||||
if (isLeft) {
|
||||
if (leftselBuildings.contains(building.getSelectedItem())) {
|
||||
@ -347,8 +350,8 @@ public class TradeMenu extends Dialog {
|
||||
} else {
|
||||
leftselBuildings.add(building.getSelectedItem()); // Add if not already selected
|
||||
}
|
||||
for (String property : leftselBuildings) {
|
||||
buildingText.append(property);
|
||||
for (String property : leftselBuildings) {
|
||||
buildingText.append(property).append(", ");
|
||||
}
|
||||
} else {
|
||||
if (rightselBuildings.contains(building.getSelectedItem())) {
|
||||
@ -356,14 +359,12 @@ public class TradeMenu extends Dialog {
|
||||
} else {
|
||||
rightselBuildings.add(building.getSelectedItem()); // Add if not already selected
|
||||
}
|
||||
for (String property : rightselBuildings) {
|
||||
buildingText.append(property);
|
||||
for (String property : rightselBuildings) {
|
||||
buildingText.append(property).append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
String currencyText = currency.getText() != null ? currency.getText().trim() : "";
|
||||
String cardText = card.getSelectedItem() != null ? card.getSelectedItem() : "";
|
||||
target.setText(String.join(" | ", buildingText, currencyText, cardText));
|
||||
target.setText(buildingText.toString().replaceAll(", $", ""));
|
||||
}
|
||||
|
||||
/** Opens the settings menu when the escape key is pressed. */
|
||||
|
@ -74,7 +74,7 @@ public class RejectTrade extends Dialog {
|
||||
|
||||
// Text, der im Popup steht
|
||||
Container textContainer = noMoneyWarningContainer.addChild(new Container());
|
||||
textContainer.addChild(new Label("Du hast Spieler"+ msg.getTradeHandler().getReceiver().getName() + "einen Handel vorgeschlagen", new ElementId("label-Text")));
|
||||
textContainer.addChild(new Label("Du hast Spieler"+ " " + msg.getTradeHandler().getReceiver().getName() + " " + "einen Handel vorgeschlagen", new ElementId("label-Text")));
|
||||
textContainer.addChild(new Label("", new ElementId("label-Text")));
|
||||
textContainer.addChild(new Label("Der Handel wurde abgelehnt", new ElementId("label-Text")));
|
||||
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
|
Loading…
Reference in New Issue
Block a user