Compare commits

..

No commits in common. "d6ce859fcda643ff04849a00445057c208f89b1f" and "c5e7ef855edfc47f713b69ae3980418aff6ad37e" have entirely different histories.

3 changed files with 17 additions and 199 deletions

View File

@ -1,5 +1,7 @@
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;
@ -9,16 +11,20 @@ import com.jme3.texture.Texture;
import com.simsilica.lemur.Axis; import com.simsilica.lemur.Axis;
import com.simsilica.lemur.Button; import com.simsilica.lemur.Button;
import com.simsilica.lemur.Container; import com.simsilica.lemur.Container;
import com.simsilica.lemur.Insets3f;
import com.simsilica.lemur.Label; import com.simsilica.lemur.Label;
import com.simsilica.lemur.Selector; import com.simsilica.lemur.Selector;
import com.simsilica.lemur.TextField;
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.notification.Sound; import pp.monopoly.notification.Sound;
import java.util.Set;
public class ChoosePartner extends Dialog { public class ChoosePartner extends Dialog {
private final MonopolyApp app; private final MonopolyApp app;
private Selector<String> playerSelector; private Selector<String> playerSelector;
@ -27,7 +33,6 @@ public class ChoosePartner extends Dialog {
private final Container mainContainer; private final Container mainContainer;
private Container lowerLeftMenu; private Container lowerLeftMenu;
private Container lowerRightMenu; private Container lowerRightMenu;
private Geometry background;
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));
@ -65,7 +70,7 @@ public class ChoosePartner extends Dialog {
mainContainer.setLocalTranslation( mainContainer.setLocalTranslation(
(app.getCamera().getWidth() - mainContainer.getPreferredSize().x) / 2, (app.getCamera().getWidth() - mainContainer.getPreferredSize().x) / 2,
(app.getCamera().getHeight() + mainContainer.getPreferredSize().y) / 2, (app.getCamera().getHeight() + mainContainer.getPreferredSize().y) / 2,
4 0
); );
} }
@ -90,8 +95,7 @@ public class ChoosePartner extends Dialog {
Vector3f dimens = dropdownContainer.getPreferredSize(); Vector3f dimens = dropdownContainer.getPreferredSize();
Vector3f dimens2 = playerSelector.getPopupContainer().getPreferredSize(); Vector3f dimens2 = playerSelector.getPopupContainer().getPreferredSize();
dimens2.setX( dimens.getX() ); dimens2.setX( dimens.getX() );
playerSelector.getPopupContainer().setPreferredSize(new Vector3f(200,200,3)); playerSelector.getPopupContainer().setPreferredSize(new Vector3f(200,200,5));
playerSelector.setLocalTranslation(0,0,5);
return dropdownContainer; return dropdownContainer;
} }
@ -111,12 +115,13 @@ public class ChoosePartner extends Dialog {
cancelButton.setFontSize(30); cancelButton.setFontSize(30);
cancelButton.addClickCommands(s -> ifTopDialog(() -> { cancelButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON); app.getGameLogic().playSound(Sound.BUTTON);
close(); this.close();
new Toolbar(app).open();
})); }));
lowerLeftMenu.addChild(cancelButton); lowerLeftMenu.addChild(cancelButton);
// Position the container near the bottom-left corner // Position the container near the bottom-left corner
lowerLeftMenu.setLocalTranslation(new Vector3f(120, 170, 5)); // Adjust X and Y to align with the bottom-left corner lowerLeftMenu.setLocalTranslation(new Vector3f(120, 170, 3)); // Adjust X and Y to align with the bottom-left corner
app.getGuiNode().attachChild(lowerLeftMenu); app.getGuiNode().attachChild(lowerLeftMenu);
@ -128,13 +133,13 @@ public class ChoosePartner extends Dialog {
app.getGameLogic().playSound(Sound.BUTTON); app.getGameLogic().playSound(Sound.BUTTON);
String selectedPlayer = playerSelector.getSelectedItem(); String selectedPlayer = playerSelector.getSelectedItem();
System.out.println("Selected player: " + selectedPlayer); System.out.println("Selected player: " + selectedPlayer);
close(); this.close();
new TradeMenu(app).open(); // TODO: Open trade menu or next step
})); }));
lowerRightMenu.addChild(confirmButton); lowerRightMenu.addChild(confirmButton);
// Position the container near the bottom-right corner // Position the container near the bottom-right corner
lowerRightMenu.setLocalTranslation(new Vector3f(app.getCamera().getWidth() - 320, 170, 5)); // X: 220px from the right, Y: 50px above the bottom lowerRightMenu.setLocalTranslation(new Vector3f(app.getCamera().getWidth() - 320, 170, 3)); // X: 220px from the right, Y: 50px above the bottom
app.getGuiNode().attachChild(lowerRightMenu); app.getGuiNode().attachChild(lowerRightMenu);
@ -147,11 +152,11 @@ public class ChoosePartner extends Dialog {
private void addBackgroundImage() { private void addBackgroundImage() {
Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png"); Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png");
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight()); Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
background = new Geometry("Background", quad); Geometry background = new Geometry("Background", quad);
Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
backgroundMaterial.setTexture("ColorMap", backgroundImage); backgroundMaterial.setTexture("ColorMap", backgroundImage);
background.setMaterial(backgroundMaterial); background.setMaterial(backgroundMaterial);
background.setLocalTranslation(0, 0, 3); // Position behind other GUI elements background.setLocalTranslation(0, 0, 1); // Position behind other GUI elements
app.getGuiNode().attachChild(background); app.getGuiNode().attachChild(background);
} }
@ -172,16 +177,6 @@ public class ChoosePartner 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
} }
@Override
public void close() {
app.getGuiNode().detachChild(playerSelector);
app.getGuiNode().detachChild(lowerLeftMenu);
app.getGuiNode().detachChild(lowerRightMenu);
app.getGuiNode().detachChild(mainContainer);
app.getGuiNode().detachChild(background);
super.close();
}
} }

View File

@ -166,6 +166,7 @@ public class Toolbar extends Dialog {
tradebutton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons tradebutton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
tradebutton.addClickCommands(s -> ifTopDialog( () -> { tradebutton.addClickCommands(s -> ifTopDialog( () -> {
app.getGameLogic().playSound(Sound.BUTTON); app.getGameLogic().playSound(Sound.BUTTON);
this.close();
new ChoosePartner(app).open(); new ChoosePartner(app).open();
})); }));
return tradebutton; return tradebutton;

View File

@ -1,178 +0,0 @@
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
}
}