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