simplified representation of trade

This commit is contained in:
Yvonne Schmidt 2024-12-04 01:48:18 +01:00
parent 49b9972ade
commit 9ee1b5b81b

View File

@ -218,8 +218,10 @@ 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("Gebäude: Währung: Sonderkarten:")); Label middleLabelTop = middleSection.addChild(new Label("Meine Gebäude:"));
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("")); leftSelectionsLabel = middleSection.addChild(new Label(""));
@ -243,8 +245,10 @@ 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: Währung: Sonderkarten:")); Label middleLabelBottom = middleSection.addChild(new Label("Gebäude des Gegenspielers:"));
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("")); rightSelectionsLabel = middleSection.addChild(new Label(""));
@ -322,25 +326,23 @@ public class TradeMenu extends Dialog {
*/ */
@Override @Override
public void update(float delta) { public void update(float delta) {
if (leftBuildingRef.update() || leftCardRef.update() || leftCurrencyRef.update()) { if (leftBuildingRef.update() || leftCardRef.update()) {
updateSelections(leftSelectionsLabel, leftBuildingSelector, leftCurrencyInput, leftSpecialCardSelector, true); updateSelections(leftSelectionsLabel, leftBuildingSelector, true);
} }
if (rightBuildingRef.update() || rightCardRef.update() || rightCurrencyRef.update()) { if (rightBuildingRef.update() || rightCardRef.update()) {
updateSelections(rightSelectionsLabel, rightBuildingSelector, rightCurrencyInput, rightSpecialCardSelector, false); 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 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, TextField currency, Selector<String> card, boolean isLeft) { private void updateSelections(Label target, Selector<String> building, boolean isLeft) {
StringBuilder buildingText = new StringBuilder(); StringBuilder buildingText = new StringBuilder();
if (isLeft) { if (isLeft) {
if (leftselBuildings.contains(building.getSelectedItem())) { if (leftselBuildings.contains(building.getSelectedItem())) {
@ -362,9 +364,7 @@ public class TradeMenu extends Dialog {
} }
} }
String currencyText = currency.getText() != null ? currency.getText().trim() : ""; target.setText(buildingText.toString().replaceAll(", $", ""));
String cardText = card.getSelectedItem() != null ? card.getSelectedItem() : "";
target.setText(String.join(" | ", buildingText.toString().replaceAll(", $", ""), currencyText, cardText));
} }
/** Opens the settings menu when the escape key is pressed. */ /** Opens the settings menu when the escape key is pressed. */