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. "e56cdb1dcb48692e116384a653fc5ca1e6e6a971" and "174958c6b1cdcf0b5af0891dfa903c7bb2cb10a4" have entirely different histories.
e56cdb1dcb
...
174958c6b1
@ -1,9 +1,5 @@
|
|||||||
package pp.monopoly.client.gui;
|
package pp.monopoly.client.gui;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.jme3.app.Application;
|
|
||||||
import com.jme3.app.state.BaseAppState;
|
|
||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
@ -18,12 +14,9 @@ import com.simsilica.lemur.Selector;
|
|||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
import com.simsilica.lemur.component.SpringGridLayout;
|
import com.simsilica.lemur.component.SpringGridLayout;
|
||||||
import com.simsilica.lemur.core.VersionedList;
|
import com.simsilica.lemur.core.VersionedList;
|
||||||
import com.simsilica.lemur.core.VersionedReference;
|
|
||||||
import com.simsilica.lemur.style.ElementId;
|
import com.simsilica.lemur.style.ElementId;
|
||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.game.server.Player;
|
|
||||||
import pp.monopoly.model.TradeHandler;
|
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
|
||||||
public class ChoosePartner extends Dialog {
|
public class ChoosePartner extends Dialog {
|
||||||
@ -35,7 +28,6 @@ public class ChoosePartner extends Dialog {
|
|||||||
private Container lowerLeftMenu;
|
private Container lowerLeftMenu;
|
||||||
private Container lowerRightMenu;
|
private Container lowerRightMenu;
|
||||||
private Geometry background;
|
private Geometry background;
|
||||||
private TradeHandler tradeHandler;
|
|
||||||
QuadBackgroundComponent translucentWhiteBackground =
|
QuadBackgroundComponent translucentWhiteBackground =
|
||||||
new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f));
|
new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f));
|
||||||
|
|
||||||
@ -47,7 +39,7 @@ public class ChoosePartner extends Dialog {
|
|||||||
public ChoosePartner(MonopolyApp app) {
|
public ChoosePartner(MonopolyApp app) {
|
||||||
super(app.getDialogManager());
|
super(app.getDialogManager());
|
||||||
this.app = app;
|
this.app = app;
|
||||||
tradeHandler = new TradeHandler(app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()));
|
|
||||||
|
|
||||||
// Background Image
|
// Background Image
|
||||||
addBackgroundImage();
|
addBackgroundImage();
|
||||||
@ -68,8 +60,6 @@ public class ChoosePartner extends Dialog {
|
|||||||
// Add buttons
|
// Add buttons
|
||||||
mainContainer.addChild(createButtonContainer());
|
mainContainer.addChild(createButtonContainer());
|
||||||
|
|
||||||
addSelectionActionListener(playerSelector, this::onDropdownSelectionChanged);
|
|
||||||
|
|
||||||
// Attach main container to GUI node
|
// Attach main container to GUI node
|
||||||
app.getGuiNode().attachChild(mainContainer);
|
app.getGuiNode().attachChild(mainContainer);
|
||||||
mainContainer.setLocalTranslation(
|
mainContainer.setLocalTranslation(
|
||||||
@ -90,12 +80,10 @@ public class ChoosePartner extends Dialog {
|
|||||||
dropdownContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.Black)));
|
dropdownContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.Black)));
|
||||||
|
|
||||||
VersionedList<String> playerOptions = new VersionedList<>();
|
VersionedList<String> playerOptions = new VersionedList<>();
|
||||||
|
playerOptions.add("Spieler 1");
|
||||||
for (Player player : app.getGameLogic().getPlayerHandler().getPlayers()) {
|
playerOptions.add("Spieler 2");
|
||||||
if (player.getId() != app.getId()) {
|
playerOptions.add("Spieler 3");
|
||||||
playerOptions.add(player.getName() + " (ID: "+player.getId()+")");
|
playerOptions.add("Spieler 4");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
playerSelector = new Selector<>(playerOptions, "glass");
|
playerSelector = new Selector<>(playerOptions, "glass");
|
||||||
dropdownContainer.addChild(playerSelector);
|
dropdownContainer.addChild(playerSelector);
|
||||||
@ -138,6 +126,8 @@ public class ChoosePartner extends Dialog {
|
|||||||
confirmButton.setFontSize(30);
|
confirmButton.setFontSize(30);
|
||||||
confirmButton.addClickCommands(s -> ifTopDialog(() -> {
|
confirmButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
|
String selectedPlayer = playerSelector.getSelectedItem();
|
||||||
|
System.out.println("Selected player: " + selectedPlayer);
|
||||||
close();
|
close();
|
||||||
new TradeMenu(app).open();
|
new TradeMenu(app).open();
|
||||||
}));
|
}));
|
||||||
@ -192,72 +182,6 @@ public class ChoosePartner extends Dialog {
|
|||||||
app.getGuiNode().detachChild(background);
|
app.getGuiNode().detachChild(background);
|
||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a custom action listener to the Selector.
|
|
||||||
*/
|
|
||||||
private void addSelectionActionListener(Selector<String> selector, SelectionActionListener<String> listener) {
|
|
||||||
VersionedReference<Set<Integer>> selectionRef = selector.getSelectionModel().createReference();
|
|
||||||
|
|
||||||
app.getStateManager().attach(new BaseAppState() {
|
|
||||||
@Override
|
|
||||||
public void update(float tpf) {
|
|
||||||
if (selectionRef.update()) {
|
|
||||||
String selected = selectionRef.get().toString();
|
|
||||||
System.out.println(selected);
|
|
||||||
listener.onSelectionChanged(selected);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initialize(Application app) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void cleanup(Application app) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onEnable() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDisable() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback for when the dropdown selection changes.
|
|
||||||
*/
|
|
||||||
private void onDropdownSelectionChanged(String selected) {
|
|
||||||
System.out.println("Selected: " + 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
|
|
||||||
System.out.println("Receiver set to: " + selectedPlayer.getName() + " (ID: " + selectedPlayer.getId() + ")");
|
|
||||||
} else {
|
|
||||||
System.err.println("Player with ID " + playerId + " not found.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Functional interface for a selection action listener.
|
|
||||||
*/
|
|
||||||
@FunctionalInterface
|
|
||||||
private interface SelectionActionListener<T> {
|
|
||||||
void onSelectionChanged(T selection);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package pp.monopoly.client.gui;
|
package pp.monopoly.client.gui;
|
||||||
|
|
||||||
import com.jme3.app.Application;
|
|
||||||
import com.jme3.app.state.BaseAppState;
|
|
||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
@ -12,15 +10,11 @@ import com.simsilica.lemur.*;
|
|||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
import com.simsilica.lemur.component.SpringGridLayout;
|
import com.simsilica.lemur.component.SpringGridLayout;
|
||||||
import com.simsilica.lemur.core.VersionedList;
|
import com.simsilica.lemur.core.VersionedList;
|
||||||
import com.simsilica.lemur.core.VersionedReference;
|
|
||||||
import com.simsilica.lemur.style.ElementId;
|
import com.simsilica.lemur.style.ElementId;
|
||||||
import com.simsilica.lemur.text.DocumentModel;
|
|
||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class TradeMenu extends Dialog {
|
public class TradeMenu extends Dialog {
|
||||||
private final MonopolyApp app;
|
private final MonopolyApp app;
|
||||||
private final Container mainContainer;
|
private final Container mainContainer;
|
||||||
@ -29,7 +23,6 @@ public class TradeMenu extends Dialog {
|
|||||||
private final Button cancelButton = new Button("Abbrechen");
|
private final Button cancelButton = new Button("Abbrechen");
|
||||||
private final Button tradeButton = new Button("Handeln");
|
private final Button tradeButton = new Button("Handeln");
|
||||||
private Container lowerLeftMenu, lowerRightMenu;
|
private Container lowerLeftMenu, lowerRightMenu;
|
||||||
private TextField leftSelectionsField;
|
|
||||||
QuadBackgroundComponent translucentWhiteBackground =
|
QuadBackgroundComponent translucentWhiteBackground =
|
||||||
new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.White));
|
new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.White));
|
||||||
|
|
||||||
@ -50,8 +43,12 @@ public class TradeMenu extends Dialog {
|
|||||||
mainContainer.setPreferredSize(new Vector3f(1200, 800, 0));
|
mainContainer.setPreferredSize(new Vector3f(1200, 800, 0));
|
||||||
mainContainer.setBackground(translucentWhiteBackground);
|
mainContainer.setBackground(translucentWhiteBackground);
|
||||||
|
|
||||||
// Add header container
|
|
||||||
mainContainer.addChild(createHeaderContainer());
|
// Add title with background
|
||||||
|
Label headerLabel = mainContainer.addChild(new Label("Handelsmenu", new ElementId("label-Bold")));
|
||||||
|
headerLabel.setFontSize(40);
|
||||||
|
headerLabel.setBackground(new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f)));
|
||||||
|
|
||||||
// Add main content (three columns: left, middle, right)
|
// Add main content (three columns: left, middle, right)
|
||||||
mainContainer.addChild(createMainContent());
|
mainContainer.addChild(createMainContent());
|
||||||
|
|
||||||
@ -64,25 +61,8 @@ public class TradeMenu extends Dialog {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
//TODO Logik
|
//TODO Logik
|
||||||
|
//TODO Ebenen prüfen und eine Ebene Hochsetzen
|
||||||
/**
|
//TODO Farben der Label anpassen
|
||||||
* Creates a container for the header with a fixed size.
|
|
||||||
*
|
|
||||||
* @return The header container.
|
|
||||||
*/
|
|
||||||
private Container createHeaderContainer() {
|
|
||||||
// Create a container for the header
|
|
||||||
Container headerContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
|
||||||
headerContainer.setPreferredSize(new Vector3f(200, 100, 0)); // Set fixed width and height
|
|
||||||
|
|
||||||
// Add the header label
|
|
||||||
Label headerLabel = headerContainer.addChild(new Label("Handelsmenü", new ElementId("label-Bold")));
|
|
||||||
headerLabel.setFontSize(50); // Adjust font size as needed
|
|
||||||
headerLabel.setInsets(new Insets3f(10, 10, 10, 10)); // Add padding around the label
|
|
||||||
headerLabel.setBackground(new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f))); // Optional background
|
|
||||||
|
|
||||||
return headerContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the main content layout (left, middle, right columns).
|
* Creates the main content layout (left, middle, right columns).
|
||||||
@ -91,7 +71,6 @@ public class TradeMenu extends Dialog {
|
|||||||
*/
|
*/
|
||||||
private Container createMainContent() {
|
private Container createMainContent() {
|
||||||
Container mainContent = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
Container mainContent = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
||||||
mainContent.setPreferredSize(new Vector3f(1200, 700, 0));
|
|
||||||
|
|
||||||
// Left Column
|
// Left Column
|
||||||
mainContent.addChild(createTradeColumn("Wähle Handelsobjekt:", true));
|
mainContent.addChild(createTradeColumn("Wähle Handelsobjekt:", true));
|
||||||
@ -100,56 +79,18 @@ public class TradeMenu extends Dialog {
|
|||||||
Container middleSection = mainContent.addChild(new Container(new SpringGridLayout(Axis.Y, Axis.X)));
|
Container middleSection = mainContent.addChild(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)));
|
||||||
|
|
||||||
// Add combined label
|
TextField leftSelectionsField = middleSection.addChild(new TextField("Quellobjekte..."));
|
||||||
Label middleLabel = middleSection.addChild(new Label("Gebäude: Währung: Sonderkarten:"));
|
|
||||||
middleLabel.setFontSize(24); // Adjust font size as needed
|
|
||||||
middleLabel.setInsets(new Insets3f(5, 5, 5, 5)); // Add padding around the label
|
|
||||||
|
|
||||||
// Add the Quellobjekte TextField
|
|
||||||
leftSelectionsField = middleSection.addChild(new TextField(""));
|
|
||||||
leftSelectionsField.setPreferredSize(new Vector3f(600, 50, 0)); // Larger width to fit the split sections
|
|
||||||
|
|
||||||
// Add listeners to update the TextField dynamically
|
|
||||||
addCustomSelectionListener(leftBuildingSelector, newSelection -> updateLeftSelectionsField(leftSelectionsField));
|
|
||||||
addCustomSelectionListener(leftSpecialCardSelector, newSelection -> updateLeftSelectionsField(leftSelectionsField));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Label arrows = middleSection.addChild(new Label("⇅"));
|
Label arrows = middleSection.addChild(new Label("⇅"));
|
||||||
arrows.setFontSize(40);
|
arrows.setFontSize(40);
|
||||||
|
|
||||||
// Add combined label
|
|
||||||
middleLabel = middleSection.addChild(new Label("Gebäude: Währung: Sonderkarten:"));
|
|
||||||
middleLabel.setFontSize(24); // Adjust font size as needed
|
|
||||||
middleLabel.setInsets(new Insets3f(5, 5, 5, 5)); // Add padding around the label
|
|
||||||
|
|
||||||
TextField rightSelectionsField = middleSection.addChild(new TextField("Zielobjekte..."));
|
TextField rightSelectionsField = middleSection.addChild(new TextField("Zielobjekte..."));
|
||||||
// "Bestätigen" button
|
|
||||||
lowerRightMenu = new Container();
|
|
||||||
tradeButton.setPreferredSize(new Vector3f(200, 60, 0));
|
|
||||||
tradeButton.setFontSize(30);
|
|
||||||
tradeButton.addClickCommands(s -> ifTopDialog(() -> {
|
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
|
||||||
close();
|
|
||||||
new TradeMenu(app).open();
|
|
||||||
}));
|
|
||||||
lowerRightMenu.addChild(tradeButton);
|
|
||||||
|
|
||||||
// Position the container near the bottom-right corner
|
|
||||||
lowerRightMenu.setLocalTranslation(new Vector3f(app.getCamera().getWidth() - 680, 100, 8)); // X: 220px from the right, Y: 50px above the bottom
|
|
||||||
app.getGuiNode().attachChild(lowerRightMenu);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Right Column
|
// Right Column
|
||||||
mainContent.addChild(createTradeColumn("Wähle Zielobjekt:", false));
|
mainContent.addChild(createTradeColumn("Wähle Zielobjekt:", false));
|
||||||
|
|
||||||
Label spacer = middleSection.addChild(new Label("")); // Spacer
|
|
||||||
spacer.setPreferredSize(new Vector3f(1, 50, 0));
|
|
||||||
|
|
||||||
return mainContent;
|
return mainContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +103,7 @@ public class TradeMenu extends Dialog {
|
|||||||
*/
|
*/
|
||||||
private Container createTradeColumn(String label, boolean isLeft) {
|
private Container createTradeColumn(String label, boolean isLeft) {
|
||||||
Container column = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
Container column = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
||||||
column.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.White)));
|
column.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.Black)));
|
||||||
|
|
||||||
Label columnLabel = column.addChild(new Label(label));
|
Label columnLabel = column.addChild(new Label(label));
|
||||||
columnLabel.setFontSize(24);
|
columnLabel.setFontSize(24);
|
||||||
@ -171,52 +112,22 @@ public class TradeMenu extends Dialog {
|
|||||||
// Add dropdowns
|
// Add dropdowns
|
||||||
column.addChild(new Label("Gebäude:"));
|
column.addChild(new Label("Gebäude:"));
|
||||||
Selector<String> buildingSelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
|
Selector<String> buildingSelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
|
||||||
buildingSelector.setInsets(new Insets3f(5, 10, 5, 10));
|
|
||||||
buildingSelector.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.Black)));
|
|
||||||
|
|
||||||
column.addChild(new Label("Währung:"));
|
column.addChild(new Label("Währung:"));
|
||||||
TextField currencyInput = column.addChild(new TextField(""));
|
Selector<String> currencySelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
|
||||||
currencyInput.setInsets(new Insets3f(5, 10, 5, 10));
|
|
||||||
currencyInput.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.Black)));
|
|
||||||
|
|
||||||
column.addChild(new Label("Sonderkarten:"));
|
column.addChild(new Label("Sonderkarten:"));
|
||||||
Selector<String> specialCardSelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
|
Selector<String> specialCardSelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
|
||||||
specialCardSelector.setInsets(new Insets3f(5, 10, 5, 10));
|
|
||||||
specialCardSelector.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.Black)));
|
|
||||||
|
|
||||||
|
|
||||||
// Assign selectors to corresponding fields
|
// Assign selectors to corresponding fields
|
||||||
if (isLeft) {
|
if (isLeft) {
|
||||||
leftBuildingSelector = buildingSelector;
|
leftBuildingSelector = buildingSelector;
|
||||||
|
leftCurrencySelector = currencySelector;
|
||||||
leftSpecialCardSelector = specialCardSelector;
|
leftSpecialCardSelector = specialCardSelector;
|
||||||
|
} else {
|
||||||
// Add listeners for left selectors to update the middle text field
|
|
||||||
addCustomSelectionListener(buildingSelector, newSelection -> updateLeftSelectionsField(leftSelectionsField));
|
|
||||||
addCustomSelectionListener(specialCardSelector, newSelection -> updateLeftSelectionsField(leftSelectionsField));
|
|
||||||
|
|
||||||
// "Abbrechen" button
|
|
||||||
lowerLeftMenu = new Container();
|
|
||||||
cancelButton.setPreferredSize(new Vector3f(200, 60, 0));
|
|
||||||
cancelButton.setFontSize(30);
|
|
||||||
cancelButton.addClickCommands(s -> ifTopDialog(() -> {
|
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
|
||||||
close();
|
|
||||||
}));
|
|
||||||
lowerLeftMenu.addChild(cancelButton);
|
|
||||||
|
|
||||||
// Position the container near the bottom-left corner
|
|
||||||
lowerLeftMenu.setLocalTranslation(new Vector3f(70, 100, 8)); // Adjust X and Y to align with the bottom-left corner
|
|
||||||
app.getGuiNode().attachChild(lowerLeftMenu);
|
|
||||||
|
|
||||||
Label spacer = column.addChild(new Label("")); // Spacer
|
|
||||||
spacer.setPreferredSize(new Vector3f(1, 130, 0));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
rightBuildingSelector = buildingSelector;
|
rightBuildingSelector = buildingSelector;
|
||||||
|
rightCurrencySelector = currencySelector;
|
||||||
rightSpecialCardSelector = specialCardSelector;
|
rightSpecialCardSelector = specialCardSelector;
|
||||||
|
|
||||||
Label spacer = column.addChild(new Label("")); // Spacer
|
|
||||||
spacer.setPreferredSize(new Vector3f(1, 130, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return column;
|
return column;
|
||||||
@ -247,26 +158,6 @@ public class TradeMenu extends Dialog {
|
|||||||
app.getGuiNode().attachChild(background);
|
app.getGuiNode().attachChild(background);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLeftSelectionsField(TextField leftSelectionsField) {
|
|
||||||
// Get all selections from the leftBuildingSelector and leftSpecialCardSelector
|
|
||||||
String buildingSelections = leftBuildingSelector.getSelectedItem() != null
|
|
||||||
? leftBuildingSelector.getSelectedItem()
|
|
||||||
: "";
|
|
||||||
String specialCardSelections = leftSpecialCardSelector.getSelectedItem() != null
|
|
||||||
? leftSpecialCardSelector.getSelectedItem()
|
|
||||||
: "";
|
|
||||||
|
|
||||||
// Get the direct input from the middle part of the TextField
|
|
||||||
String manualInput = leftSelectionsField.getText();
|
|
||||||
|
|
||||||
// Combine all parts into one formatted string
|
|
||||||
String combinedText = String.format("%-30s %-30s %-30s", buildingSelections, manualInput, specialCardSelections);
|
|
||||||
|
|
||||||
// Update the content of the TextField
|
|
||||||
leftSelectionsField.setText(combinedText);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the escape action for the dialog.
|
* Handles the escape action for the dialog.
|
||||||
*/
|
*/
|
||||||
@ -284,41 +175,4 @@ public class TradeMenu extends Dialog {
|
|||||||
public void update(float delta) {
|
public void update(float delta) {
|
||||||
// Periodic updates (if needed) can be implemented here
|
// Periodic updates (if needed) can be implemented here
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Functional interface for a selection action listener.
|
|
||||||
*/
|
|
||||||
@FunctionalInterface
|
|
||||||
private interface SelectionActionListener<T> {
|
|
||||||
void onSelectionChanged(T selection);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Adds a custom action listener to the Selector.
|
|
||||||
*/
|
|
||||||
private void addCustomSelectionListener(Selector<String> selector, SelectionActionListener<String> listener) {
|
|
||||||
VersionedReference<Set<Integer>> selectionRef = selector.getSelectionModel().createReference();
|
|
||||||
|
|
||||||
app.getStateManager().attach(new BaseAppState() {
|
|
||||||
@Override
|
|
||||||
public void update(float tpf) {
|
|
||||||
if (selectionRef.update()) {
|
|
||||||
String selected = selector.getSelectedItem();
|
|
||||||
listener.onSelectionChanged(selected);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initialize(Application app) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void cleanup(Application app) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onEnable() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDisable() {}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,13 @@ import java.util.List;
|
|||||||
public class TradeHandler {
|
public class TradeHandler {
|
||||||
|
|
||||||
private final Player sender;
|
private final Player sender;
|
||||||
private Player receiver;
|
private final Player receiver;
|
||||||
private int offeredAmount;
|
private final int offeredAmount;
|
||||||
private List<PropertyField> offeredProperties;
|
private final List<PropertyField> offeredProperties;
|
||||||
private int offeredJailCards;
|
private final int offeredJailCards;
|
||||||
private int requestedAmount;
|
private final int requestedAmount;
|
||||||
private List<PropertyField> requestedProperties;
|
private final List<PropertyField> requestedProperties;
|
||||||
private int requestedJailCards;
|
private final int requestedJailCards;
|
||||||
private Boolean status = null;
|
private Boolean status = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,22 +45,6 @@ public class TradeHandler {
|
|||||||
this.requestedJailCards = requestedJailCards;
|
this.requestedJailCards = requestedJailCards;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a TradeHandler for a single trade instance.
|
|
||||||
*
|
|
||||||
* @param sender the Player initiating the trade
|
|
||||||
* @param receiver the Player receiving the trade offer
|
|
||||||
* @param offeredAmount the amount of money offered by the sender
|
|
||||||
* @param offeredProperties the properties offered by the sender
|
|
||||||
* @param offeredJailCards the jail cards offered by the sender
|
|
||||||
* @param requestedAmount the amount of money requested from the receiver
|
|
||||||
* @param requestedProperties the properties requested from the receiver
|
|
||||||
* @param requestedJailCards the jail cards requested from the receiver
|
|
||||||
*/
|
|
||||||
public TradeHandler(Player sender) {
|
|
||||||
this.sender = sender;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getOfferedAmount() {
|
public int getOfferedAmount() {
|
||||||
return offeredAmount;
|
return offeredAmount;
|
||||||
}
|
}
|
||||||
@ -225,32 +209,4 @@ public class TradeHandler {
|
|||||||
}
|
}
|
||||||
System.out.println(numCards + " jail card(s) transferred from " + from.getName() + " to " + to.getName());
|
System.out.println(numCards + " jail card(s) transferred from " + from.getName() + " to " + to.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOfferedAmount(int offeredAmount) {
|
|
||||||
this.offeredAmount = offeredAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOfferedJailCards(int offeredJailCards) {
|
|
||||||
this.offeredJailCards = offeredJailCards;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOfferedProperties(List<PropertyField> offeredProperties) {
|
|
||||||
this.offeredProperties = offeredProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReceiver(Player receiver) {
|
|
||||||
this.receiver = receiver;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRequestedAmount(int requestedAmount) {
|
|
||||||
this.requestedAmount = requestedAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRequestedJailCards(int requestedJailCards) {
|
|
||||||
this.requestedJailCards = requestedJailCards;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRequestedProperties(List<PropertyField> requestedProperties) {
|
|
||||||
this.requestedProperties = requestedProperties;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user