mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-25 02:19:45 +01:00
Compare commits
No commits in common. "75d5a15bdb78c6d70016596458deb08458170ca3" and "46d2dce3721760d71ed711b6261bf6c524786a33" have entirely different histories.
75d5a15bdb
...
46d2dce372
@ -31,9 +31,6 @@ public class LobbyMenu {
|
||||
private final MonopolyApp app;
|
||||
private final Container menuContainer;
|
||||
private Geometry background;
|
||||
private Geometry circle;
|
||||
private Container lowerLeftMenu;
|
||||
private Container lowerRightMenu;
|
||||
|
||||
public LobbyMenu(MonopolyApp app) {
|
||||
this.app = app;
|
||||
@ -64,7 +61,7 @@ public class LobbyMenu {
|
||||
spacerBeforeInput.setPreferredSize(new Vector3f(20, 1, 0)); // Width of the spacer
|
||||
|
||||
// Add an input field (TextField)
|
||||
TextField startingCapital = horizontalContainer.addChild(new TextField("15 000"));
|
||||
TextField startingCapital = horizontalContainer.addChild(new TextField(""));
|
||||
startingCapital.setPreferredWidth(100); // Set the width of the input field
|
||||
startingCapital.setPreferredSize(new Vector3f(150, 50, 0));
|
||||
startingCapital.setInsets(new Insets3f(5, 10, 5, 10)); // Add padding around the text inside the field
|
||||
@ -91,7 +88,7 @@ public class LobbyMenu {
|
||||
playerInputContainer.setBackground(null);
|
||||
|
||||
|
||||
TextField playerInputField = new TextField("Spieler 1");
|
||||
TextField playerInputField = new TextField("");
|
||||
playerInputField.setPreferredSize(new Vector3f(100, 20, 0));
|
||||
playerInputField.setInsets(new Insets3f(5, 10, 5, 10)); // Add padding for the text inside the field
|
||||
playerInputField.setBackground(new QuadBackgroundComponent(ColorRGBA.Black));
|
||||
@ -106,12 +103,10 @@ public class LobbyMenu {
|
||||
figureDropdownContainer.setBackground(null);
|
||||
|
||||
VersionedList<String> figures = new VersionedList<>();
|
||||
figures.add("Laptop");
|
||||
figures.add("Flugzeug");
|
||||
figures.add("Jägermeister");
|
||||
figures.add("Hund");
|
||||
figures.add("Katze");
|
||||
figures.add("OOP");
|
||||
figures.add("Handyholster");
|
||||
figures.add("Panzer");
|
||||
figures.add("Pot");
|
||||
|
||||
Selector<String> figureDropdown = new Selector<>(figures, "glass");
|
||||
figureDropdown.setBackground(new QuadBackgroundComponent(ColorRGBA.DarkGray));
|
||||
@ -125,7 +120,7 @@ public class LobbyMenu {
|
||||
buttonContainer.setInsets(new Insets3f(20, 0, 10, 0)); // Add spacing above the buttons
|
||||
buttonContainer.setBackground(null);
|
||||
// Lower-left container for "Abbrechen" button
|
||||
lowerLeftMenu = new Container();
|
||||
Container lowerLeftMenu = new Container();
|
||||
Button cancelButton = new Button("Abbrechen");
|
||||
cancelButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image
|
||||
cancelButton.setFontSize(18); // Adjust font size
|
||||
@ -137,7 +132,7 @@ public class LobbyMenu {
|
||||
app.getGuiNode().attachChild(lowerLeftMenu);
|
||||
|
||||
// Lower-right container for "Bereit" button
|
||||
lowerRightMenu = new Container();
|
||||
Container lowerRightMenu = new Container();
|
||||
Button readyButton = new Button("Bereit");
|
||||
readyButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image
|
||||
readyButton.setFontSize(18); // Adjust font size
|
||||
@ -150,7 +145,7 @@ public class LobbyMenu {
|
||||
app.getGuiNode().attachChild(lowerRightMenu);
|
||||
|
||||
// Add a colored circle between the input field and the dropdown menu
|
||||
circle = createCircle( ColorRGBA.Red); // 50 is the diameter, Red is the color
|
||||
Geometry circle = createCircle( ColorRGBA.Red); // 50 is the diameter, Red is the color
|
||||
circle.setLocalTranslation(new Vector3f(
|
||||
(app.getCamera().getWidth()) / 2, // Center horizontally
|
||||
(app.getCamera().getHeight() / 2) - 90, // Adjust Y position
|
||||
@ -210,10 +205,7 @@ public class LobbyMenu {
|
||||
*/
|
||||
private void goBackToCreateGame() {
|
||||
app.getGuiNode().detachChild(menuContainer);
|
||||
app.getGuiNode().detachChild(background);
|
||||
app.getGuiNode().detachChild(circle);
|
||||
app.getGuiNode().detachChild(lowerLeftMenu);
|
||||
app.getGuiNode().detachChild(lowerRightMenu);
|
||||
app.getGuiNode().detachChild(background); // Entfernt das Hintergrundbild
|
||||
new CreateGameMenu(app);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,75 @@
|
||||
package pp.monopoly.client.gui;
|
||||
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.material.RenderState.BlendMode;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial.CullHint;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.model.Board;
|
||||
|
||||
/**
|
||||
* Represents the visual view of a {@link Board}, used to display the map structure and elements.
|
||||
* This class handles the graphical representation of the board, including background setup and grid lines.
|
||||
*/
|
||||
class MapView {
|
||||
private static final float FIELD_SIZE = 40f;
|
||||
private static final float BACKGROUND_DEPTH = -4f;
|
||||
private static final ColorRGBA BACKGROUND_COLOR = new ColorRGBA(0, 0.05f, 0.05f, 0.5f);
|
||||
|
||||
private final MonopolyApp app;
|
||||
private final Node mapNode = new Node("map");
|
||||
private final Board board;
|
||||
private final MapViewSynchronizer synchronizer;
|
||||
|
||||
/**
|
||||
* Constructs a new MapView for a given {@link Board} and {@link MonopolyApp}.
|
||||
*
|
||||
* @param board the board to visualize
|
||||
* @param app the main application instance
|
||||
*/
|
||||
MapView(Board board, MonopolyApp app) {
|
||||
this.board = board;
|
||||
this.app = app;
|
||||
this.synchronizer = new MapViewSynchronizer(this);
|
||||
setupBackground();
|
||||
app.getGameLogic().addListener(synchronizer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters the {@link MapViewSynchronizer} from listening to board changes.
|
||||
*/
|
||||
void unregister() {
|
||||
app.getGameLogic().removeListener(synchronizer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the background of the map view using a quad geometry.
|
||||
*/
|
||||
private void setupBackground() {
|
||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.setColor("Color", BACKGROUND_COLOR);
|
||||
mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
|
||||
Geometry background = new Geometry("MapBackground", new Quad(board.getWidth() * FIELD_SIZE, board.getHeight() * FIELD_SIZE));
|
||||
background.setMaterial(mat);
|
||||
background.setLocalTranslation(0f, 1f, BACKGROUND_DEPTH);
|
||||
background.setCullHint(CullHint.Never);
|
||||
mapNode.attachChild(background);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the root node containing all visual elements in this map view.
|
||||
*
|
||||
* @return the root node for the map view
|
||||
*/
|
||||
public Node getNode() {
|
||||
return mapNode;
|
||||
}
|
||||
|
||||
public Board getBoard() {
|
||||
return board;
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package pp.monopoly.client.gui;
|
||||
|
||||
import com.jme3.scene.Spatial;
|
||||
|
||||
import pp.monopoly.model.Figure;
|
||||
|
||||
/**
|
||||
* Synchronizes the visual representation of the board with the game model.
|
||||
* Handles updates for items on the board.
|
||||
*/
|
||||
class MapViewSynchronizer extends BoardSynchronizer {
|
||||
private final MapView view;
|
||||
|
||||
/**
|
||||
* Constructs a new MapViewSynchronizer for the given MapView.
|
||||
*
|
||||
* @param view the MapView to synchronize with the game model
|
||||
*/
|
||||
public MapViewSynchronizer(MapView view) {
|
||||
super(view.getBoard(), view.getNode());
|
||||
this.view = view;
|
||||
addExisting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the state by performing initial setup, such as adding any items to the view.
|
||||
*/
|
||||
|
||||
protected void enableState() {
|
||||
// Platz für zusätzliche Initialisierungen
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the state by clearing the view.
|
||||
*/
|
||||
|
||||
protected void disableState() {
|
||||
view.getNode().detachAllChildren(); // Entfernt alle visuellen Elemente vom Knoten
|
||||
}
|
||||
|
||||
|
||||
public Spatial visit(Figure figure) {
|
||||
return figure.accept(this);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user