Merge branch 'main' into 'gui'

# Conflicts:
#   Projekte/jme-common/src/main/resources/Interface/Lemur/pp-styles.groovy
#   Projekte/monopoly/client/src/main/java/pp/monopoly/client/GameSound.java
#   Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java
#   Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java
#   Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java
#   Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java
#   Projekte/monopoly/model/src/main/resources/monopoly.properties
This commit is contained in:
Johannes Schmelz
2024-11-18 03:14:07 +00:00
53 changed files with 3611 additions and 203 deletions

View File

@@ -55,6 +55,55 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
setSettings(makeSettings());
}
/**
* Creates and configures application settings from the client configuration.
*
* @return A configured {@link AppSettings} object.
*/
private AppSettings makeSettings() {
final AppSettings settings = new AppSettings(true);
settings.setTitle(lookup("monopoly.name"));
settings.setResolution(config.getResolutionWidth(), config.getResolutionHeight());
settings.setFullscreen(config.fullScreen());
settings.setUseRetinaFrameBuffer(config.useRetinaFrameBuffer());
settings.setGammaCorrection(config.useGammaCorrection());
return settings;
}
/**
* Factory method for creating a server connection based on the current
* client configuration.
*
* @return A {@link ServerConnection} instance, which could be a real or mock server.
*/
private ServerConnection makeServerConnection() {
return new NetworkSupport(this);
}
/**
* Returns the dialog manager responsible for managing in-game dialogs.
*
* @return The {@link DialogManager} instance.
*/
public DialogManager getDialogManager() {
return dialogManager;
}
/**
* Returns the game logic handler for the client.
*
* @return The {@link ClientGameLogic} instance.
*/
@Override
public ClientGameLogic getGameLogic() {
return logic;
}
/**
* Returns the current configuration settings for the Monopoly client.
*
* @return The {@link MonopolyClientConfig} instance.
*/
@Override
public MonopolyAppConfig getConfig() {
return config;

View File

@@ -1,123 +1,117 @@
package pp.monopoly.client;
import com.jme3.asset.TextureKey;
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.Axis;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.HAlignment;
import com.simsilica.lemur.Insets3f;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.Panel;
import com.simsilica.lemur.style.ElementId;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.component.SpringGridLayout;
import com.jme3.math.ColorRGBA;
import pp.dialog.Dialog;
import pp.monopoly.client.gui.CreateGameMenu;
import pp.monopoly.client.gui.SettingsMenu;
import pp.monopoly.client.gui.GameMenu;
import pp.dialog.DialogManager;
import java.util.prefs.Preferences;
import static pp.monopoly.Resources.lookup;
import static pp.util.PreferencesUtils.getPreferences;
/**
* Constructs the startup menu dialog for the Monopoly application.
*/
public class StartMenu extends Dialog {
private static final Preferences PREFERENCES = getPreferences(StartMenu.class);
private final MonopolyApp app;
// Buttons for the menu
private final Button playButton = new Button(lookup("button.play"));
private final Button quitButton = new Button(lookup("menu.quit"));
private final Button settingsButton = new Button("Einstellungen", new ElementId("menu-button"));
/**
* Constructs the Startup Menu dialog for the Monopoly application.
* Constructs the StartMenu dialog for the Monopoly application.
*
* @param app the MonopolyApp instance
*/
public StartMenu(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
}
/**
* Creates and displays the Start Menu with buttons for starting the game,
* opening settings, and quitting the application.
*/
public static void createStartMenu(MonopolyApp app) {
int screenWidth = app.getContext().getSettings().getWidth();
int screenHeight = app.getContext().getSettings().getHeight();
// Set up the background image
Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png");
Quad quad = new Quad(screenWidth, screenHeight);
Geometry background = new Geometry("Background", quad);
// Load and display the background image
TextureKey backgroundKey = new TextureKey("unibw-bib", false);
Texture backgroundTexture = app.getAssetManager().loadTexture(backgroundKey);
Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
backgroundMaterial.setTexture("ColorMap", backgroundImage);
backgroundMaterial.setTexture("ColorMap", backgroundTexture);
// Create a large Quad for the background
Quad backgroundQuad = new Quad(16, 9); // Adjust size as necessary to fill the screen
Geometry background = new Geometry("Background", backgroundQuad);
background.setMaterial(backgroundMaterial);
background.setLocalTranslation(0, 0, -1); // Ensure it is behind other GUI elements
background.setLocalTranslation(new Vector3f(-8, -4.5f, -1)); // Position it behind the UI components
// Attach the background as the first element
app.getGuiNode().attachChild(background);
// Center container for title and play button
Container centerMenu = new Container(new SpringGridLayout(Axis.Y, Axis.X));
// Load and display the Monopoly logo
TextureKey monopolyLogoKey = new TextureKey("log-Monopoly", false);
Texture monopolyLogoTexture = app.getAssetManager().loadTexture(monopolyLogoKey);
Material monopolyLogoMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
monopolyLogoMaterial.setTexture("ColorMap", monopolyLogoTexture);
Button startButton = new Button("Spielen");
startButton.setPreferredSize(new Vector3f(190, 60, 0)); // Increase button size (width, height)
startButton.setFontSize(40); // Set the font size for the button text
startButton.setTextHAlignment(HAlignment.Center); // Center the text horizontally
Quad monopolyQuad = new Quad(5, 1.5f); // Adjust dimensions as necessary
Geometry monopolyLogo = new Geometry("MonopolyLogo", monopolyQuad);
monopolyLogo.setMaterial(monopolyLogoMaterial);
monopolyLogo.setLocalTranslation(new Vector3f(0, 5, 0)); // Position Monopoly logo at the top
// Set a custom border and background color
ColorRGBA borderColor = ColorRGBA.Orange; // Example: White border
ColorRGBA backgroundColor = ColorRGBA.LightGray; // Example: light gray background
QuadBackgroundComponent backgroundColorSp = new QuadBackgroundComponent(backgroundColor);
backgroundColorSp.setMargin(2, 2); // Optional: Adjust margin for the border
backgroundColorSp.setColor(borderColor); // Set border color
startButton.setBackground(backgroundColorSp);
Panel monopolyLogoPanel = new Panel();
addChild(monopolyLogoPanel);
startButton.addClickCommands(source -> startGame(app));
centerMenu.addChild(startButton);
// Load and display the university logo
TextureKey universityLogoKey = new TextureKey("unibw-logo.png", false);
Texture universityLogoTexture = app.getAssetManager().loadTexture(universityLogoKey);
Material universityLogoMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
universityLogoMaterial.setTexture("ColorMap", universityLogoTexture);
// Position the center container in the middle of the screen
centerMenu.setLocalTranslation(new Vector3f(screenWidth / 2f - centerMenu.getPreferredSize().x / 2f,
screenHeight / 2f - 280 + centerMenu.getPreferredSize().y / 2f,
0));
app.getGuiNode().attachChild(centerMenu);
Quad universityQuad = new Quad(4, 1); // Adjust dimensions to fit below Monopoly logo
Geometry universityLogo = new Geometry("UniversityLogo", universityQuad);
universityLogo.setMaterial(universityLogoMaterial);
universityLogo.setLocalTranslation(new Vector3f(0, 3, 0)); // Position below the Monopoly logo
// Lower-left container for "Spiel beenden" button
Container lowerLeftMenu = new Container();
lowerLeftMenu.setLocalTranslation(new Vector3f(100, 90, 0));
Button quitButton = new Button("Spiel beenden");
quitButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height)
quitButton.setFontSize(20);
quitButton.addClickCommands(source -> quitGame());
lowerLeftMenu.addChild(quitButton);
app.getGuiNode().attachChild(lowerLeftMenu);
Panel universityLogoPanel = new Panel();
addChild(universityLogoPanel);
// Lower-right container for "Einstellungen" button
Container lowerRightMenu = new Container();
lowerRightMenu.setLocalTranslation(new Vector3f(screenWidth - 200, 90, 0));
Button settingsButton = new Button("Einstellungen");
settingsButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height)
settingsButton.setFontSize(20); // Increase the font size for the text
settingsButton.addClickCommands(source -> openSettings(app));
lowerRightMenu.addChild(settingsButton);
app.getGuiNode().attachChild(lowerRightMenu);
// Button actions
playButton.addClickCommands(source -> startGame());
quitButton.addClickCommands(source -> app.closeApp());
settingsButton.addClickCommands(source -> openSettings());
addChild(monopolyLogoPanel);
addChild(universityLogoPanel);
addChild(playButton);
addChild(quitButton);
addChild(settingsButton);
}
/**
* Starts the game by transitioning to the CreateGameMenu.
*/
private static void startGame(MonopolyApp app) {
app.getGuiNode().detachAllChildren();
new CreateGameMenu(app);
private void startGame() {
System.out.println("Starting game...");
}
/**
* Opens the settings menu.
*/
private static void openSettings(MonopolyApp app) {
app.getGuiNode().detachAllChildren();
new SettingsMenu(app);
private void openSettings() {
app.getDialogManager().close(this);
app.getDialogManager().open(new GameMenu(app));
}
/**
* Quits the game application.
*/
private static void quitGame() {
System.exit(0);
@Override
public void update() {
}
@Override
public void escape() {
close();
}
}

View File

@@ -0,0 +1,50 @@
package pp.monopoly.client.gui;
import com.jme3.math.ColorRGBA;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp;
public class GameMenu extends Dialog {
private final MonopolyApp app;
/**
* Constructs the SettingsMenu dialog for the Monopoly application.
*
* @param app the MonopolyApp instance
*/
public GameMenu(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
// Add a title label for Settings
Label settingsTitle = new Label("Einstellungen", new ElementId("settings-title"));
settingsTitle.setFontSize(48); // Set font size for the title
settingsTitle.setColor(ColorRGBA.White);
// Add any settings-related components here, such as volume control, toggles, etc.
// Add a back button to return to StartMenu
Button backButton = new Button("Zurück", new ElementId("menu-button"));
backButton.setColor(ColorRGBA.White);
backButton.setFontSize(24);
backButton.addClickCommands(source -> returnToStartMenu());
// Add components to this dialog
addChild(settingsTitle);
addChild(backButton);
// You can add more settings components here, like checkboxes or sliders.
}
/**
* Returns to the StartMenu when the back button is clicked.
*/
private void returnToStartMenu() {
app.getDialogManager().close(this); // Close the current settings dialog
//TODO return zum Ausgangsmenü
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB