diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java index 7affb71..74b2ead 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java @@ -16,6 +16,7 @@ import com.simsilica.lemur.core.VersionedList; import com.simsilica.lemur.style.ElementId; import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; +import pp.monopoly.game.server.Player; import pp.monopoly.model.TradeHandler; import pp.monopoly.model.fields.PropertyField; import pp.monopoly.notification.Sound; @@ -99,6 +100,7 @@ public class TradeMenu extends Dialog { column.addChild(new Label("Gebäude:")); Selector buildingSelector = createPropertySelector(isLeft); + buildingSelector.getPopupContainer().setBackground(new QuadBackgroundComponent(ColorRGBA.Orange)); column.addChild(buildingSelector); column.addChild(new Label("Währung:")); @@ -107,6 +109,7 @@ public class TradeMenu extends Dialog { column.addChild(new Label("Sonderkarten:")); Selector specialCardSelector = createSpecialCardSelector(); + specialCardSelector.getPopupContainer().setBackground(new QuadBackgroundComponent(ColorRGBA.Orange)); styleSelector(specialCardSelector); column.addChild(specialCardSelector); @@ -253,4 +256,24 @@ public class TradeMenu extends Dialog { app.getGuiNode().detachChild(mainContainer); super.close(); } + + /** + * Handles dropdown selection changes and updates the trade handler. + * + * @param selected The selected item from the dropdown. + */ + private void onDropdownSelectionChanged(String selected) { + app.getGameLogic().playSound(Sound.BUTTON); + int idStart = selected.indexOf("(ID: ") + 5; // Find start of the ID + int idEnd = selected.indexOf(")", idStart); // Find end of the ID + String idStr = selected.substring(idStart, idEnd); // Extract the ID as a string + int playerId = Integer.parseInt(idStr); // Convert the ID to an integer + + // Find the player by ID + Player selectedPlayer = app.getGameLogic().getPlayerHandler().getPlayerById(playerId); + + if (selectedPlayer != null) { + tradeHandler.setReceiver(selectedPlayer); // Set the receiver in TradeHandler + } + } }