mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-25 03:29:44 +01:00
Merge branch 'gui' into 'main'
First compileable version of Client See merge request progproj/gruppen-ht24/Gruppe-02!4
This commit is contained in:
commit
19a9b06f3c
@ -111,7 +111,7 @@ public class DialogManager {
|
|||||||
*
|
*
|
||||||
* @param dialog the dialog to open
|
* @param dialog the dialog to open
|
||||||
*/
|
*/
|
||||||
void open(Dialog dialog) {
|
public void open(Dialog dialog) {
|
||||||
dialogStack.push(dialog);
|
dialogStack.push(dialog);
|
||||||
dialog.update();
|
dialog.update();
|
||||||
app.getGuiNode().attachChild(dialog);
|
app.getGuiNode().attachChild(dialog);
|
||||||
@ -133,7 +133,7 @@ public class DialogManager {
|
|||||||
* @param dialog the dialog to close
|
* @param dialog the dialog to close
|
||||||
* @throws IllegalArgumentException if the specified dialog is not the top dialog
|
* @throws IllegalArgumentException if the specified dialog is not the top dialog
|
||||||
*/
|
*/
|
||||||
void close(Dialog dialog) {
|
public void close(Dialog dialog) {
|
||||||
if (!isTop(dialog))
|
if (!isTop(dialog))
|
||||||
throw new IllegalArgumentException(dialog + " is not the top dialog");
|
throw new IllegalArgumentException(dialog + " is not the top dialog");
|
||||||
dialogStack.pop();
|
dialogStack.pop();
|
||||||
|
@ -10,15 +10,22 @@ import com.simsilica.lemur.Insets3f
|
|||||||
import com.simsilica.lemur.component.QuadBackgroundComponent
|
import com.simsilica.lemur.component.QuadBackgroundComponent
|
||||||
import com.simsilica.lemur.component.TbtQuadBackgroundComponent
|
import com.simsilica.lemur.component.TbtQuadBackgroundComponent
|
||||||
|
|
||||||
def bgColor = color(0.25, 0.5, 0.5, 1)
|
def bgColor = color(1, 1, 1, 1)
|
||||||
def buttonEnabledColor = color(0.8, 0.9, 1, 1)
|
def buttonEnabledColor = color(0.8, 0.9, 1, 1)
|
||||||
def buttonDisabledColor = color(0.8, 0.9, 1, 0.2)
|
def buttonDisabledColor = color(0.8, 0.9, 1, 0.2)
|
||||||
def buttonBgColor = color(0, 0.75, 0.75, 1)
|
//def buttonBgColor = color(0, 0.75, 0.75, 1)
|
||||||
def sliderColor = color(0.6, 0.8, 0.8, 1)
|
def sliderColor = color(0.6, 0.8, 0.8, 1)
|
||||||
def sliderBgColor = color(0.5, 0.75, 0.75, 1)
|
def sliderBgColor = color(0.5, 0.75, 0.75, 1)
|
||||||
def gradientColor = color(0.5, 0.75, 0.85, 0.5)
|
def gradientColor = color(0.5, 0.75, 0.85, 0.5)
|
||||||
def tabbuttonEnabledColor = color(0.4, 0.45, 0.5, 1)
|
def tabbuttonEnabledColor = color(0.4, 0.45, 0.5, 1)
|
||||||
|
|
||||||
|
def playButtonBorderColor = color(1, 0.6, 0, 1) // Orange border for "Spielen" button
|
||||||
|
def playButtonTextColor = color(0, 0, 0, 1) // Black text color for "Spielen" button
|
||||||
|
def buttonBgColor = color(1, 1, 1, 1) // White background for "Spiel beenden" and "Einstellungen" buttons
|
||||||
|
def buttonTextColor = color(0, 0, 0, 1) // Black text color for "Spiel beenden" and "Einstellungen" buttons
|
||||||
|
def borderColor = color(0, 0, 0, 1) // Black border for "Spiel beenden" and "Einstellungen"
|
||||||
|
|
||||||
|
|
||||||
def gradient = TbtQuadBackgroundComponent.create(
|
def gradient = TbtQuadBackgroundComponent.create(
|
||||||
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png",
|
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png",
|
||||||
generateMips: false),
|
generateMips: false),
|
||||||
@ -55,6 +62,24 @@ selector("slider", "pp") {
|
|||||||
background.setColor(bgColor)
|
background.setColor(bgColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selector("play-button", "pp") {
|
||||||
|
color = playButtonTextColor // Black text color
|
||||||
|
background = new QuadBackgroundComponent(playButtonBorderColor) // Orange border background
|
||||||
|
insets = new Insets3f(15, 25, 15, 25) // Padding for larger button size
|
||||||
|
background.setMargin(5, 5) // Thin border effect around the background color
|
||||||
|
fontSize = 36 // Larger font size for prominence
|
||||||
|
}
|
||||||
|
|
||||||
|
selector("menu-button", "pp") {
|
||||||
|
color = buttonTextColor // Black text color
|
||||||
|
background = new QuadBackgroundComponent(buttonBgColor) // White background
|
||||||
|
insets = new Insets3f(10, 20, 10, 20) // Padding
|
||||||
|
background.setMargin(1, 1) // Thin black border
|
||||||
|
background.setColor(borderColor) // Set black border color
|
||||||
|
|
||||||
|
fontSize = 24 // Standard font size
|
||||||
|
}
|
||||||
|
|
||||||
def pressedCommand = new Command<Button>() {
|
def pressedCommand = new Command<Button>() {
|
||||||
void execute(Button source) {
|
void execute(Button source) {
|
||||||
if (source.isPressed())
|
if (source.isPressed())
|
||||||
|
@ -31,10 +31,6 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
|||||||
private static final Preferences PREFERENCES = getPreferences(GameSound.class);
|
private static final Preferences PREFERENCES = getPreferences(GameSound.class);
|
||||||
private static final String ENABLED_PREF = "enabled"; //NON-NLS
|
private static final String ENABLED_PREF = "enabled"; //NON-NLS
|
||||||
|
|
||||||
private AudioNode splashSound;
|
|
||||||
private AudioNode shipDestroyedSound;
|
|
||||||
private AudioNode explosionSound;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if sound is enabled in the preferences.
|
* Checks if sound is enabled in the preferences.
|
||||||
*
|
*
|
||||||
@ -75,9 +71,6 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize(AppStateManager stateManager, Application app) {
|
public void initialize(AppStateManager stateManager, Application app) {
|
||||||
super.initialize(stateManager, app);
|
super.initialize(stateManager, app);
|
||||||
shipDestroyedSound = loadSound(app, "Sound/Effects/sunken.wav"); //NON-NLS
|
|
||||||
splashSound = loadSound(app, "Sound/Effects/splash.wav"); //NON-NLS
|
|
||||||
explosionSound = loadSound(app, "Sound/Effects/explosion.wav"); //NON-NLS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,36 +93,10 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Plays the splash sound effect.
|
|
||||||
*/
|
|
||||||
public void splash() {
|
|
||||||
if (isEnabled() && splashSound != null)
|
|
||||||
splashSound.playInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Plays the explosion sound effect.
|
|
||||||
*/
|
|
||||||
public void explosion() {
|
|
||||||
if (isEnabled() && explosionSound != null)
|
|
||||||
explosionSound.playInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Plays sound effect when a ship has been destroyed.
|
|
||||||
*/
|
|
||||||
public void shipDestroyed() {
|
|
||||||
if (isEnabled() && shipDestroyedSound != null)
|
|
||||||
shipDestroyedSound.playInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receivedEvent(SoundEvent event) {
|
public void receivedEvent(SoundEvent event) {
|
||||||
switch (event.sound()) {
|
switch (event.sound()) {
|
||||||
case EXPLOSION -> explosion();
|
|
||||||
case SPLASH -> splash();
|
|
||||||
case DESTROYED_SHIP -> shipDestroyed();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
|||||||
*/
|
*/
|
||||||
private AppSettings makeSettings() {
|
private AppSettings makeSettings() {
|
||||||
final AppSettings settings = new AppSettings(true);
|
final AppSettings settings = new AppSettings(true);
|
||||||
settings.setTitle(lookup("Monopoly.name"));
|
settings.setTitle(lookup("monopoly.name"));
|
||||||
settings.setResolution(config.getResolutionWidth(), config.getResolutionHeight());
|
settings.setResolution(config.getResolutionWidth(), config.getResolutionHeight());
|
||||||
settings.setFullscreen(config.fullScreen());
|
settings.setFullscreen(config.fullScreen());
|
||||||
settings.setUseRetinaFrameBuffer(config.useRetinaFrameBuffer());
|
settings.setUseRetinaFrameBuffer(config.useRetinaFrameBuffer());
|
||||||
@ -182,7 +182,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
|||||||
*
|
*
|
||||||
* @return The {@link DialogManager} instance.
|
* @return The {@link DialogManager} instance.
|
||||||
*/
|
*/
|
||||||
DialogManager getDialogManager() {
|
public DialogManager getDialogManager() {
|
||||||
return dialogManager;
|
return dialogManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,117 @@
|
|||||||
|
package pp.monopoly.client;
|
||||||
|
|
||||||
|
import com.jme3.asset.TextureKey;
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
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.Button;
|
||||||
|
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.jme3.math.ColorRGBA;
|
||||||
|
import pp.dialog.Dialog;
|
||||||
|
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;
|
||||||
|
|
||||||
|
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 StartMenu dialog for the Monopoly application.
|
||||||
|
*
|
||||||
|
* @param app the MonopolyApp instance
|
||||||
|
*/
|
||||||
|
public StartMenu(MonopolyApp app) {
|
||||||
|
super(app.getDialogManager());
|
||||||
|
this.app = app;
|
||||||
|
|
||||||
|
// 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", 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(new Vector3f(-8, -4.5f, -1)); // Position it behind the UI components
|
||||||
|
|
||||||
|
// Attach the background as the first element
|
||||||
|
app.getGuiNode().attachChild(background);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Panel monopolyLogoPanel = new Panel();
|
||||||
|
addChild(monopolyLogoPanel);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Panel universityLogoPanel = new Panel();
|
||||||
|
addChild(universityLogoPanel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startGame() {
|
||||||
|
System.out.println("Starting game...");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openSettings() {
|
||||||
|
app.getDialogManager().close(this);
|
||||||
|
app.getDialogManager().open(new GameMenu(app));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void escape() {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
@ -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: 44 KiB |
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
Binary file not shown.
After Width: | Height: | Size: 144 KiB |
@ -39,7 +39,9 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
private Board ownMap;
|
private Board ownMap;
|
||||||
private Board harbor;
|
private Board harbor;
|
||||||
private Board opponentMap;
|
private Board opponentMap;
|
||||||
private ClientState state = null;
|
private ClientState state = new ClientState(this) {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a ClientGameLogic with the specified sender object.
|
* Constructs a ClientGameLogic with the specified sender object.
|
||||||
|
@ -5,5 +5,38 @@
|
|||||||
## (c) Mark Minas (mark.minas@unibw.de)
|
## (c) Mark Minas (mark.minas@unibw.de)
|
||||||
########################################
|
########################################
|
||||||
#
|
#
|
||||||
battleship.name=Battleship
|
monopoly.name=Monopoly
|
||||||
|
button.play=Start Game
|
||||||
button.ready=Ready
|
button.ready=Ready
|
||||||
|
button.rotate=Rotate
|
||||||
|
server.connection.failed=Failed to establish a server connection.
|
||||||
|
its.your.turn=It's your turn! Click on the opponent's field to shoot...
|
||||||
|
lost.connection.to.server=Lost connection to server. The game terminated.
|
||||||
|
place.ships.in.your.map=Place ships in your map.
|
||||||
|
wait.for.an.opponent=Wait for an opponent!
|
||||||
|
wait.for.opponent=Wait for your opponent!
|
||||||
|
confirm.leaving=Would you really like to leave the game?
|
||||||
|
you.lost.the.game=You lost the game!
|
||||||
|
you.won.the.game=You won the game!
|
||||||
|
button.yes=Yes
|
||||||
|
button.no=No
|
||||||
|
button.ok=Ok
|
||||||
|
button.connect=Connect
|
||||||
|
button.cancel=Cancel
|
||||||
|
server.dialog=Server
|
||||||
|
host.name=Host
|
||||||
|
port.number=Port
|
||||||
|
wait.its.not.your.turn=Wait, it's not your turn!!
|
||||||
|
menu.quit=Quit game
|
||||||
|
menu.return-to-game=Return to game
|
||||||
|
menu.sound-enabled=Sound switched on
|
||||||
|
menu.background-sound-enabled=Background music switched on
|
||||||
|
menu.map.load=Load map from file...
|
||||||
|
menu.map.save=Save map in file...
|
||||||
|
label.file=File:
|
||||||
|
label.connecting=Connecting...
|
||||||
|
dialog.error=Error
|
||||||
|
dialog.question=Question
|
||||||
|
port.must.be.integer=Port must be an integer number
|
||||||
|
map.doesnt.fit=The map doesn't fit to this game
|
||||||
|
client.server-start=Start server
|
||||||
|
@ -6,4 +6,37 @@
|
|||||||
########################################
|
########################################
|
||||||
#
|
#
|
||||||
monopoly.name=Monopoly
|
monopoly.name=Monopoly
|
||||||
button.ready=Bereit
|
button.play=Start Game
|
||||||
|
button.ready=Ready
|
||||||
|
button.rotate=Rotate
|
||||||
|
server.connection.failed=Failed to establish a server connection.
|
||||||
|
its.your.turn=It's your turn! Click on the opponent's field to shoot...
|
||||||
|
lost.connection.to.server=Lost connection to server. The game terminated.
|
||||||
|
place.ships.in.your.map=Place ships in your map.
|
||||||
|
wait.for.an.opponent=Wait for an opponent!
|
||||||
|
wait.for.opponent=Wait for your opponent!
|
||||||
|
confirm.leaving=Would you really like to leave the game?
|
||||||
|
you.lost.the.game=You lost the game!
|
||||||
|
you.won.the.game=You won the game!
|
||||||
|
button.yes=Yes
|
||||||
|
button.no=No
|
||||||
|
button.ok=Ok
|
||||||
|
button.connect=Connect
|
||||||
|
button.cancel=Cancel
|
||||||
|
server.dialog=Server
|
||||||
|
host.name=Host
|
||||||
|
port.number=Port
|
||||||
|
wait.its.not.your.turn=Wait, it's not your turn!!
|
||||||
|
menu.quit=Quit game
|
||||||
|
menu.return-to-game=Return to game
|
||||||
|
menu.sound-enabled=Sound switched on
|
||||||
|
menu.background-sound-enabled=Background music switched on
|
||||||
|
menu.map.load=Load map from file...
|
||||||
|
menu.map.save=Save map in file...
|
||||||
|
label.file=File:
|
||||||
|
label.connecting=Connecting...
|
||||||
|
dialog.error=Error
|
||||||
|
dialog.question=Question
|
||||||
|
port.must.be.integer=Port must be an integer number
|
||||||
|
map.doesnt.fit=The map doesn't fit to this game
|
||||||
|
client.server-start=Start server
|
||||||
|
Loading…
Reference in New Issue
Block a user