mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-19 00:06:16 +01:00
replaced textinput with dynamic label
This commit is contained in:
parent
09ea8a046e
commit
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;
|
||||
@ -221,8 +222,8 @@ public class TradeMenu extends Dialog {
|
||||
middleLabelTop.setFontSize(24);
|
||||
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");
|
||||
@ -246,8 +247,8 @@ public class TradeMenu extends Dialog {
|
||||
middleLabelBottom.setFontSize(24);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -322,11 +323,11 @@ public class TradeMenu extends Dialog {
|
||||
@Override
|
||||
public void update(float delta) {
|
||||
if (leftBuildingRef.update() || leftCardRef.update() || leftCurrencyRef.update()) {
|
||||
updateSelections(leftSelectionsField, leftBuildingSelector, leftCurrencyInput, leftSpecialCardSelector, true);
|
||||
updateSelections(leftSelectionsLabel, leftBuildingSelector, leftCurrencyInput, leftSpecialCardSelector, true);
|
||||
}
|
||||
|
||||
if (rightBuildingRef.update() || rightCardRef.update() || rightCurrencyRef.update()) {
|
||||
updateSelections(rightSelectionsField, rightBuildingSelector, rightCurrencyInput, rightSpecialCardSelector, false);
|
||||
updateSelections(rightSelectionsLabel, rightBuildingSelector, rightCurrencyInput, rightSpecialCardSelector, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,7 +340,7 @@ public class TradeMenu extends Dialog {
|
||||
* @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, TextField currency, Selector<String> card, boolean isLeft) {
|
||||
StringBuilder buildingText = new StringBuilder();
|
||||
if (isLeft) {
|
||||
if (leftselBuildings.contains(building.getSelectedItem())) {
|
||||
@ -347,8 +348,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 +357,14 @@ 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(String.join(" | ", buildingText.toString().replaceAll(", $", ""), currencyText, cardText));
|
||||
}
|
||||
|
||||
/** Opens the settings menu when the escape key is pressed. */
|
||||
|
Loading…
Reference in New Issue
Block a user