mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-29 00:49:46 +01:00
added framework for TradeMenu
This commit is contained in:
parent
840658b590
commit
d8a2225038
@ -89,7 +89,7 @@ public class ChoosePartner extends Dialog {
|
||||
playerOptions.add("Spieler 2");
|
||||
playerOptions.add("Spieler 3");
|
||||
playerOptions.add("Spieler 4");
|
||||
|
||||
//TODO Selector Logik
|
||||
playerSelector = new Selector<>(playerOptions, "glass");
|
||||
dropdownContainer.addChild(playerSelector);
|
||||
Vector3f dimens = dropdownContainer.getPreferredSize();
|
||||
@ -135,7 +135,7 @@ public class ChoosePartner extends Dialog {
|
||||
String selectedPlayer = playerSelector.getSelectedItem();
|
||||
System.out.println("Selected player: " + selectedPlayer);
|
||||
this.close();
|
||||
// TODO: Open trade menu or next step
|
||||
new TradeMenu(app).open();
|
||||
}));
|
||||
lowerRightMenu.addChild(confirmButton);
|
||||
|
||||
|
@ -0,0 +1,178 @@
|
||||
package pp.monopoly.client.gui;
|
||||
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
import com.jme3.texture.Texture;
|
||||
import com.simsilica.lemur.*;
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
import com.simsilica.lemur.component.SpringGridLayout;
|
||||
import com.simsilica.lemur.core.VersionedList;
|
||||
import com.simsilica.lemur.style.ElementId;
|
||||
import pp.dialog.Dialog;
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.notification.Sound;
|
||||
|
||||
public class TradeMenu extends Dialog {
|
||||
private final MonopolyApp app;
|
||||
private final Container mainContainer;
|
||||
private Selector<String> leftBuildingSelector, leftCurrencySelector, leftSpecialCardSelector;
|
||||
private Selector<String> rightBuildingSelector, rightCurrencySelector, rightSpecialCardSelector;
|
||||
private final Button cancelButton = new Button("Abbrechen");
|
||||
private final Button tradeButton = new Button("Handeln");
|
||||
private Container lowerLeftMenu, lowerRightMenu;
|
||||
QuadBackgroundComponent translucentWhiteBackground =
|
||||
new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.White));
|
||||
|
||||
/**
|
||||
* Constructs the TradeMenu dialog.
|
||||
*
|
||||
* @param app The Monopoly application instance.
|
||||
*/
|
||||
public TradeMenu(MonopolyApp app) {
|
||||
super(app.getDialogManager());
|
||||
this.app = app;
|
||||
|
||||
// Background Image
|
||||
addBackgroundImage();
|
||||
|
||||
// Main container for the UI components
|
||||
mainContainer = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
||||
mainContainer.setPreferredSize(new Vector3f(1200, 800, 0));
|
||||
mainContainer.setBackground(translucentWhiteBackground);
|
||||
|
||||
|
||||
// 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)
|
||||
mainContainer.addChild(createMainContent());
|
||||
|
||||
// Attach main container to GUI node
|
||||
app.getGuiNode().attachChild(mainContainer);
|
||||
mainContainer.setLocalTranslation(
|
||||
(app.getCamera().getWidth() - mainContainer.getPreferredSize().x) / 2,
|
||||
(app.getCamera().getHeight() + mainContainer.getPreferredSize().y) / 2,
|
||||
7
|
||||
);
|
||||
}
|
||||
//TODO Logik
|
||||
//TODO Ebenen prüfen und eine Ebene Hochsetzen
|
||||
//TODO Farben der Label anpassen
|
||||
|
||||
/**
|
||||
* Creates the main content layout (left, middle, right columns).
|
||||
*
|
||||
* @return The main content container.
|
||||
*/
|
||||
private Container createMainContent() {
|
||||
Container mainContent = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
||||
|
||||
// Left Column
|
||||
mainContent.addChild(createTradeColumn("Wähle Handelsobjekt:", true));
|
||||
|
||||
// Middle Section
|
||||
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)));
|
||||
|
||||
TextField leftSelectionsField = middleSection.addChild(new TextField("Quellobjekte..."));
|
||||
|
||||
|
||||
Label arrows = middleSection.addChild(new Label("⇅"));
|
||||
arrows.setFontSize(40);
|
||||
|
||||
TextField rightSelectionsField = middleSection.addChild(new TextField("Zielobjekte..."));
|
||||
|
||||
|
||||
// Right Column
|
||||
mainContent.addChild(createTradeColumn("Wähle Zielobjekt:", false));
|
||||
|
||||
return mainContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a column for trade objects (left or right side).
|
||||
*
|
||||
* @param label The label for the column.
|
||||
* @param isLeft Whether this column is the left side.
|
||||
* @return The column container.
|
||||
*/
|
||||
private Container createTradeColumn(String label, boolean isLeft) {
|
||||
Container column = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
||||
column.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.Black)));
|
||||
|
||||
Label columnLabel = column.addChild(new Label(label));
|
||||
columnLabel.setFontSize(24);
|
||||
columnLabel.setBackground(translucentWhiteBackground);
|
||||
|
||||
// Add dropdowns
|
||||
column.addChild(new Label("Gebäude:"));
|
||||
Selector<String> buildingSelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
|
||||
|
||||
column.addChild(new Label("Währung:"));
|
||||
Selector<String> currencySelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
|
||||
|
||||
column.addChild(new Label("Sonderkarten:"));
|
||||
Selector<String> specialCardSelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
|
||||
|
||||
// Assign selectors to corresponding fields
|
||||
if (isLeft) {
|
||||
leftBuildingSelector = buildingSelector;
|
||||
leftCurrencySelector = currencySelector;
|
||||
leftSpecialCardSelector = specialCardSelector;
|
||||
} else {
|
||||
rightBuildingSelector = buildingSelector;
|
||||
rightCurrencySelector = currencySelector;
|
||||
rightSpecialCardSelector = specialCardSelector;
|
||||
}
|
||||
|
||||
return column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides sample dropdown items.
|
||||
*/
|
||||
private VersionedList<String> getSampleItems() {
|
||||
VersionedList<String> items = new VersionedList<>();
|
||||
items.add("Option 1");
|
||||
items.add("Option 2");
|
||||
items.add("Option 3");
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a background image to the dialog.
|
||||
*/
|
||||
private void addBackgroundImage() {
|
||||
Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png");
|
||||
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
|
||||
Geometry background = new Geometry("Background", quad);
|
||||
Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
backgroundMaterial.setTexture("ColorMap", backgroundImage);
|
||||
background.setMaterial(backgroundMaterial);
|
||||
background.setLocalTranslation(0, 0, 6); // Position behind other GUI elements
|
||||
app.getGuiNode().attachChild(background);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the escape action for the dialog.
|
||||
*/
|
||||
@Override
|
||||
public void escape() {
|
||||
new SettingsMenu(app).open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the dialog periodically, called by the dialog manager.
|
||||
*
|
||||
* @param delta The time elapsed since the last update.
|
||||
*/
|
||||
@Override
|
||||
public void update(float delta) {
|
||||
// Periodic updates (if needed) can be implemented here
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user