mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-04-17 02:30:58 +02:00
Compare commits
5 Commits
3e487c00d5
...
c87406f60e
Author | SHA1 | Date | |
---|---|---|---|
|
c87406f60e | ||
|
21914a1294 | ||
|
a344145732 | ||
|
a27ac31086 | ||
|
9a7f75b76b |
@ -21,9 +21,11 @@ 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 solidWhiteBackground = new QuadBackgroundComponent(color(1, 1, 1, 1)) // Solid white
|
def solidWhiteBackground = new QuadBackgroundComponent(new ColorRGBA(1, 1, 1, 1))
|
||||||
def greyBackground = color(0.8, 0.8, 0.8, 1) // Grey background color
|
def greyBackground = new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 1.0f));
|
||||||
def redBorderColor = color(1, 0, 0, 1) // Red border color
|
def lightGreyBackground = new QuadBackgroundComponent(new ColorRGBA(0.4f, 0.4f, 0.4f, 1.0f));
|
||||||
|
def lightGrey = color(0.6, 0.6, 0.6, 1.0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -246,7 +248,12 @@ selector("tab.button", "pp") {
|
|||||||
buttonCommands = stdButtonCommands
|
buttonCommands = stdButtonCommands
|
||||||
}
|
}
|
||||||
selector("settings-title", "pp") {
|
selector("settings-title", "pp") {
|
||||||
fontSize = 48 // Set font size
|
def outerBackground = new QuadBackgroundComponent(color(1, 0.5, 0, 1)) // Grey inner border
|
||||||
|
def innerBackground = new QuadBackgroundComponent(buttonBgColor) // White outer border background
|
||||||
|
|
||||||
|
background = outerBackground
|
||||||
|
fontSize = 40
|
||||||
|
insets = new Insets3f(3, 3, 3, 3)
|
||||||
textHAlignment = HAlignment.Center
|
textHAlignment = HAlignment.Center
|
||||||
textVAlignment = VAlignment.Center
|
textVAlignment = VAlignment.Center
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class GameMusic extends AbstractAppState{
|
|||||||
return PREFERENCES.getBoolean(ENABLED_PREF, true);
|
return PREFERENCES.getBoolean(ENABLED_PREF, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if sound is enabled in the preferences.
|
* Checks if sound is enabled in the preferences.
|
||||||
*
|
*
|
||||||
* @return float to which the volume is set
|
* @return float to which the volume is set
|
||||||
|
@ -30,6 +30,7 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
|||||||
private static final Logger LOGGER = System.getLogger(GameSound.class.getName());
|
private static final Logger LOGGER = System.getLogger(GameSound.class.getName());
|
||||||
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 static final String VOLUME_PREF = "volume"; //NON-NLS
|
||||||
|
|
||||||
private AudioNode passStartSound;
|
private AudioNode passStartSound;
|
||||||
private AudioNode eventCardSound;
|
private AudioNode eventCardSound;
|
||||||
@ -59,6 +60,15 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
|||||||
setEnabled(!isEnabled());
|
setEnabled(!isEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if sound is enabled in the preferences.
|
||||||
|
*
|
||||||
|
* @return float to which the volume is set
|
||||||
|
*/
|
||||||
|
public static float volumeInPreferences() {
|
||||||
|
return PREFERENCES.getFloat(VOLUME_PREF, 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the enabled state of this AppState.
|
* Sets the enabled state of this AppState.
|
||||||
* Overrides {@link com.jme3.app.state.AbstractAppState#setEnabled(boolean)}
|
* Overrides {@link com.jme3.app.state.AbstractAppState#setEnabled(boolean)}
|
||||||
@ -92,7 +102,7 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
|||||||
tradeAcceptedSound = loadSound(app, "Sound/Effects/tradeAccepted.ogg");
|
tradeAcceptedSound = loadSound(app, "Sound/Effects/tradeAccepted.ogg");
|
||||||
tradeRejectedSound = loadSound(app, "Sound/Effects/tradeRejected.ogg");
|
tradeRejectedSound = loadSound(app, "Sound/Effects/tradeRejected.ogg");
|
||||||
winnerSound = loadSound(app, "Sound/Effects/winner.ogg");
|
winnerSound = loadSound(app, "Sound/Effects/winner.ogg");
|
||||||
looserSound = loadSound(app, "Sound/Effects/looser.ogg");
|
looserSound = loadSound(app, "Sound/Effects/loser.ogg");
|
||||||
buttonSound = loadSound(app, "Sound/Effects/button.ogg");
|
buttonSound = loadSound(app, "Sound/Effects/button.ogg");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,21 +203,40 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
|||||||
if (isEnabled() && buttonSound != null)
|
if (isEnabled() && buttonSound != null)
|
||||||
buttonSound.playInstance();
|
buttonSound.playInstance();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Sets the volume of the sounds
|
||||||
|
* @param vol the volume to which the sounds should be set
|
||||||
|
*/
|
||||||
|
public void setVolume(float vol){
|
||||||
|
passStartSound.setVolume(vol);
|
||||||
|
eventCardSound.setVolume(vol);
|
||||||
|
gulagSound.setVolume(vol);
|
||||||
|
diceRollSound.setVolume(vol);
|
||||||
|
moneyCollectSound.setVolume(vol);
|
||||||
|
moneyLostSound.setVolume(vol);
|
||||||
|
tradeAcceptedSound.setVolume(vol);
|
||||||
|
tradeRejectedSound.setVolume(vol);
|
||||||
|
winnerSound.setVolume(vol);
|
||||||
|
looserSound.setVolume(vol);
|
||||||
|
buttonSound.setVolume(vol);
|
||||||
|
|
||||||
|
PREFERENCES.putFloat(VOLUME_PREF, vol);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receivedEvent(SoundEvent event) {
|
public void receivedEvent(SoundEvent event) {
|
||||||
switch (event.sound()) {
|
switch (event.sound()) {
|
||||||
case PASS_START -> passStart();
|
case PASS_START -> passStart();
|
||||||
case EVENT_CARD -> eventCard();
|
case EVENT_CARD -> eventCard();
|
||||||
case GULAG -> eventCard();
|
case GULAG -> gulag();
|
||||||
case DICE_ROLL -> eventCard();
|
case DICE_ROLL -> diceRoll();
|
||||||
case MONEY_COLLECTED -> eventCard();
|
case MONEY_COLLECTED -> moneyCollect();
|
||||||
case MONEY_LOST -> eventCard();
|
case MONEY_LOST -> moneyLost();
|
||||||
case TRADE_ACCEPTED -> eventCard();
|
case TRADE_ACCEPTED -> tradeAccepted();
|
||||||
case TRADE_REJECTED -> eventCard();
|
case TRADE_REJECTED -> tradeRejected();
|
||||||
case WINNER -> eventCard();
|
case WINNER -> winner();
|
||||||
case LOSER -> eventCard();
|
case LOSER -> looser();
|
||||||
case BUTTON -> eventCard();
|
case BUTTON -> button();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ public class LobbyMenu extends Dialog {
|
|||||||
readyButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image
|
readyButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image
|
||||||
readyButton.setFontSize(18); // Adjust font size
|
readyButton.setFontSize(18); // Adjust font size
|
||||||
readyButton.setBackground(new QuadBackgroundComponent(ColorRGBA.Green)); // Add color to match the style
|
readyButton.setBackground(new QuadBackgroundComponent(ColorRGBA.Green)); // Add color to match the style
|
||||||
readyButton.addClickCommands(source -> toggleReady(null)); // Add functionality
|
readyButton.addClickCommands(source -> toggleReady()); // Add functionality
|
||||||
lowerRightMenu.addChild(readyButton);
|
lowerRightMenu.addChild(readyButton);
|
||||||
|
|
||||||
// Position the container near the bottom-right corner
|
// Position the container near the bottom-right corner
|
||||||
@ -204,7 +204,7 @@ public class LobbyMenu extends Dialog {
|
|||||||
/**
|
/**
|
||||||
* Schaltet den "Bereit"-Status um.
|
* Schaltet den "Bereit"-Status um.
|
||||||
*/
|
*/
|
||||||
private void toggleReady(Label playersLabel) {
|
private void toggleReady() {
|
||||||
app.getGameLogic().send(new PlayerReady(true, playerInputField.getText(), figure, Integer.parseInt(startingCapital.getText())));
|
app.getGameLogic().send(new PlayerReady(true, playerInputField.getText(), figure, Integer.parseInt(startingCapital.getText())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,8 @@ public class SettingsMenu extends Dialog {
|
|||||||
private static final Preferences PREFERENCES = getPreferences(SettingsMenu.class);
|
private static final Preferences PREFERENCES = getPreferences(SettingsMenu.class);
|
||||||
private static final String LAST_PATH = "last.file.path";
|
private static final String LAST_PATH = "last.file.path";
|
||||||
private final MonopolyApp app;
|
private final MonopolyApp app;
|
||||||
private final VolumeSlider slider;
|
private final VolumeSlider musicSlider;
|
||||||
|
private final SoundSlider soundSlider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the Menu dialog for the Battleship application.
|
* Constructs the Menu dialog for the Battleship application.
|
||||||
@ -41,18 +42,22 @@ public class SettingsMenu extends Dialog {
|
|||||||
public SettingsMenu(MonopolyApp app) {
|
public SettingsMenu(MonopolyApp app) {
|
||||||
super(app.getDialogManager());
|
super(app.getDialogManager());
|
||||||
this.app = app;
|
this.app = app;
|
||||||
slider = new VolumeSlider(app.getStateManager().getState(GameMusic.class));
|
musicSlider = new VolumeSlider(app.getStateManager().getState(GameMusic.class));
|
||||||
addChild(new Label("Einstellungen", new ElementId("header"))); //NON-NLS
|
soundSlider = new SoundSlider(app.getStateManager().getState(GameSound.class));
|
||||||
|
addChild(new Label("Einstellungen", new ElementId("settings-title"))); //NON-NLS
|
||||||
addChild(new Label("Sound Effekte", new ElementId("label"))); //NON-NLS
|
addChild(new Label("Sound Effekte", new ElementId("label"))); //NON-NLS
|
||||||
|
|
||||||
|
addChild(soundSlider);
|
||||||
|
|
||||||
addChild(new Checkbox("Soundeffekte an / aus", new StateCheckboxModel(app, GameSound.class)));
|
addChild(new Checkbox("Soundeffekte an / aus", new StateCheckboxModel(app, GameSound.class)));
|
||||||
|
|
||||||
addChild(new Label("Hintergrund Musik", new ElementId("label"))); //NON-NLS
|
addChild(new Label("Hintergrund Musik", new ElementId("label"))); //NON-NLS
|
||||||
addChild(new Checkbox("Musik an / aus", new StateCheckboxModel(app, GameMusic.class)));
|
addChild(new Checkbox("Musik an / aus", new StateCheckboxModel(app, GameMusic.class)));
|
||||||
|
|
||||||
addChild(slider);
|
addChild(musicSlider);
|
||||||
|
|
||||||
addChild(new Button("Zurück zum Spiel")).addClickCommands(s -> ifTopDialog(this::close));
|
addChild(new Button("Zurück zum Spiel", new ElementId("button"))).addClickCommands(s -> ifTopDialog(this::close));
|
||||||
addChild(new Button("Beenden")).addClickCommands(s -> ifTopDialog(app::closeApp));
|
addChild(new Button("Beenden", new ElementId("button"))).addClickCommands(s -> ifTopDialog(app::closeApp));
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@ -66,7 +71,8 @@ public class SettingsMenu extends Dialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float delta) {
|
public void update(float delta) {
|
||||||
slider.update();
|
musicSlider.update();
|
||||||
|
soundSlider.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
package pp.monopoly.client.gui;
|
||||||
|
|
||||||
|
import com.simsilica.lemur.Slider;
|
||||||
|
import pp.monopoly.client.GameMusic;
|
||||||
|
import pp.monopoly.client.GameSound;
|
||||||
|
|
||||||
|
public class SoundSlider extends Slider {
|
||||||
|
|
||||||
|
private final pp.monopoly.client.GameSound sound;
|
||||||
|
private double vol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs the Volume Slider for the Menu dialog
|
||||||
|
* @param sound the Effects sound instance
|
||||||
|
*/
|
||||||
|
public SoundSlider(GameSound sound) {
|
||||||
|
super();
|
||||||
|
this.sound = sound;
|
||||||
|
vol = GameSound.volumeInPreferences();
|
||||||
|
getModel().setPercent(vol);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* when triggered it updates the volume to the value set with the slider
|
||||||
|
*/
|
||||||
|
public void update() {
|
||||||
|
if (vol != getModel().getPercent()) {
|
||||||
|
vol = getModel().getPercent();
|
||||||
|
sound.setVolume( (float) vol);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,7 @@ import com.simsilica.lemur.component.SpringGridLayout;
|
|||||||
|
|
||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
|
import pp.monopoly.notification.Sound;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the startup menu dialog for the Monopoly application.
|
* Constructs the startup menu dialog for the Monopoly application.
|
||||||
@ -54,7 +55,11 @@ public class StartMenu extends Dialog {
|
|||||||
startButton.setFontSize(40); // Set the font size for the button text
|
startButton.setFontSize(40); // Set the font size for the button text
|
||||||
startButton.setTextHAlignment(HAlignment.Center); // Center the text horizontally
|
startButton.setTextHAlignment(HAlignment.Center); // Center the text horizontally
|
||||||
|
|
||||||
startButton.addClickCommands(s -> app.connect());
|
startButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||||
|
this.close(); // Close the StartMenu dialog
|
||||||
|
app.connect(); // Perform the connection logic
|
||||||
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
|
}));
|
||||||
centerMenu.addChild(startButton);
|
centerMenu.addChild(startButton);
|
||||||
|
|
||||||
// Position the center container in the middle of the screen
|
// Position the center container in the middle of the screen
|
||||||
@ -112,6 +117,12 @@ public class StartMenu extends Dialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void escape() {
|
public void escape() {
|
||||||
close();
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
app.getGuiNode().detachAllChildren();
|
||||||
|
super.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user