mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-08-07 08:46:37 +02:00
Compare commits
121 Commits
logic
...
274df8dfd1
Author | SHA1 | Date | |
---|---|---|---|
|
274df8dfd1 | ||
|
0c2b266f5e | ||
|
16b4dbae18 | ||
|
88409dcc99 | ||
|
5cacff39b7 | ||
|
093723a9d0 | ||
|
dfdbcdc9f3 | ||
|
bd725e2dc4 | ||
|
dd9d9144dd | ||
|
1a429e4bb6 | ||
|
ad6fb5e926 | ||
|
72cb7049ba | ||
|
2e42f3afac | ||
|
8474c9f5bc | ||
|
b7ed03f7e8 | ||
|
a44b6b5e4c | ||
|
5268f75e17 | ||
|
687d1621fc | ||
|
a6944aa6e3 | ||
|
b8365c76a1 | ||
|
19216cc174 | ||
|
c6a23b9b8e | ||
|
c0f42fb1eb | ||
|
160873e2cc | ||
|
8df859bbef | ||
|
e30d10a85d | ||
|
bafc3f1db6 | ||
|
03571fcf74 | ||
|
e7a6802488 | ||
|
a6e6b5e158 | ||
|
74c3d925e6 | ||
|
f67fa4d7f0 | ||
|
225a8c0e08 | ||
|
9a6ce27fe1 | ||
|
437114704a | ||
|
9b4cac4e56 | ||
|
e780513b35 | ||
|
d582c59a7d | ||
|
7d2c85f617 | ||
|
4a882bc4ac | ||
|
3c4eac1fcd | ||
|
75d5a15bdb | ||
|
17f121f7d1 | ||
|
a66c570b51 | ||
|
e1e7f2eaf6 | ||
|
46d2dce372 | ||
|
c39f1f6d4c | ||
|
738b04f2d9 | ||
|
ecba1c3135 | ||
|
748226f4ed | ||
|
f658f53ba9 | ||
|
4a8304ee4f | ||
|
7fe9604338 | ||
|
7f09a6dae8 | ||
|
270129bc97 | ||
|
62ec6f6bef | ||
|
b24c14900c | ||
|
44c55ce3a6 | ||
|
895bea048c | ||
|
885ab5bdc9 | ||
|
c6355b2c09 | ||
|
ada6bf3f24 | ||
|
db471ac679 | ||
|
84059c4085 | ||
|
09b363f943 | ||
|
fd347c7780 | ||
|
b38a34efa5 | ||
|
10e24cf30e | ||
|
3369057afb | ||
|
7ada56e215 | ||
|
373b9e6d53 | ||
|
3de31de9f7 | ||
|
7252259ab3 | ||
|
f33c673a05 | ||
|
65a7958b66 | ||
|
91e4df7478 | ||
|
399606d9a0 | ||
|
559afcaffd | ||
|
15f5f91ddb | ||
|
067a8063a5 | ||
|
35e367ba24 | ||
|
fe68d991fc | ||
|
88dc633e8e | ||
|
0b9cbb0f5f | ||
|
c3a33b4402 | ||
|
e12f00aad6 | ||
|
47bac0185f | ||
|
dafe1dab2a | ||
|
8ba4ea2819 | ||
|
f6f708fd5b | ||
|
1203077aed | ||
|
ddbf79c928 | ||
|
aa47dd579f | ||
|
cdce478d77 | ||
|
f11f4a59f1 | ||
|
d631e8df1e | ||
|
af80d40700 | ||
|
3a6f8a945a | ||
|
bb9727d54a | ||
|
7da8b3e545 | ||
|
b6968df451 | ||
|
aa986fb948 | ||
|
6e63de6e99 | ||
|
962ecd08fa | ||
|
580a26b3ea | ||
|
0cda6b5fa0 | ||
|
cc8c3795b8 | ||
|
3c21165efb | ||
|
818fdf4670 | ||
|
b7d679b492 | ||
|
a42093df23 | ||
|
6157db51da | ||
|
843052989b | ||
|
8e01fa3192 | ||
|
e2126a7ea7 | ||
|
0b46d14650 | ||
|
9e28deedf7 | ||
|
9c0172b413 | ||
|
2933d022aa | ||
|
bdefb7193e | ||
|
69b68a6975 |
@@ -1,6 +1,5 @@
|
||||
// Styling of Lemur components
|
||||
// For documentation, see:
|
||||
// For documentation, see:
|
||||
// https://github.com/jMonkeyEngine-Contributions/Lemur/wiki/Styling
|
||||
|
||||
import com.jme3.math.ColorRGBA
|
||||
@@ -12,6 +11,7 @@ import com.simsilica.lemur.Command
|
||||
import com.simsilica.lemur.HAlignment
|
||||
import com.simsilica.lemur.Insets3f
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent
|
||||
import com.simsilica.lemur.component.TbtQuadBackgroundComponent
|
||||
|
||||
def bgColor = color(1, 1, 1, 1)
|
||||
def buttonEnabledColor = color(0, 0, 0, 1)
|
||||
@@ -19,7 +19,7 @@ def buttonDisabledColor = color(0.8, 0.9, 1, 0.2)
|
||||
def buttonBgColor = color(1, 1, 1, 1)
|
||||
def sliderColor = color(0.6, 0.8, 0.8, 1)
|
||||
def sliderBgColor = color(0.5, 0.75, 0.75, 1)
|
||||
def gradientColor = color(1, 1, 1, 1)
|
||||
def gradientColor = color(0.5, 0.75, 0.85, 0.5)
|
||||
def tabbuttonEnabledColor = color(0.4, 0.45, 0.5, 1)
|
||||
def solidWhiteBackground = new QuadBackgroundComponent(new ColorRGBA(1, 1, 1, 1))
|
||||
def greyBackground = new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 1.0f));
|
||||
@@ -30,8 +30,10 @@ def lightGrey = color(0.6, 0.6, 0.6, 1.0)
|
||||
|
||||
|
||||
def gradient = TbtQuadBackgroundComponent.create(
|
||||
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png", generateMips: false),
|
||||
1, 1, 1, 126, 126, 1f, false)
|
||||
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png",
|
||||
generateMips: false),
|
||||
1, 1, 1, 126, 126,
|
||||
1f, false)
|
||||
|
||||
def doubleGradient = new QuadBackgroundComponent(gradientColor)
|
||||
doubleGradient.texture = texture(name: "/com/simsilica/lemur/icons/double-gradient-128.png",
|
||||
@@ -77,7 +79,6 @@ selector("header", "pp") {
|
||||
textVAlignment = VAlignment.Center
|
||||
}
|
||||
|
||||
// Container Stil
|
||||
selector("container", "pp") {
|
||||
background = solidWhiteBackground.clone()
|
||||
background.setColor(bgColor)
|
||||
@@ -90,8 +91,8 @@ selector("toolbar") {
|
||||
|
||||
}
|
||||
selector("slider", "pp") {
|
||||
insets = new Insets3f(5, 10, 5, 10) // Abstand
|
||||
background = new QuadBackgroundComponent(sliderBgColor)
|
||||
background = gradient.clone()
|
||||
background.setColor(bgColor)
|
||||
}
|
||||
|
||||
def pressedCommand = new Command<Button>() {
|
||||
@@ -112,6 +113,30 @@ def enabledCommand = new Command<Button>() {
|
||||
}
|
||||
}
|
||||
|
||||
def repeatCommand = new Command<Button>() {
|
||||
private long startTime
|
||||
private long lastClick
|
||||
|
||||
void execute(Button source) {
|
||||
// Only do the repeating click while the mouse is
|
||||
// over the button (and pressed of course)
|
||||
if (source.isPressed() && source.isHighlightOn()) {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime
|
||||
// After half a second pause, click 8 times a second
|
||||
if (elapsedTime > 500 && elapsedTime > lastClick + 125) {
|
||||
source.click()
|
||||
|
||||
// Try to quantize the last click time to prevent drift
|
||||
lastClick = ((elapsedTime - 500) / 125) * 125 + 500
|
||||
}
|
||||
}
|
||||
else {
|
||||
startTime = System.currentTimeMillis()
|
||||
lastClick = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def stdButtonCommands = [
|
||||
(ButtonAction.Down) : [pressedCommand],
|
||||
(ButtonAction.Up) : [pressedCommand],
|
||||
|
@@ -1,8 +1,11 @@
|
||||
package pp.monopoly.client;
|
||||
////////////////////////////////////////
|
||||
// Programming project code
|
||||
// UniBw M, 2022, 2023, 2024
|
||||
// www.unibw.de/inf2
|
||||
// (c) Mark Minas (mark.minas@unibw.de)
|
||||
////////////////////////////////////////
|
||||
|
||||
import java.lang.System.Logger;
|
||||
import java.lang.System.Logger.Level;
|
||||
import java.util.prefs.Preferences;
|
||||
package pp.monopoly.client;
|
||||
|
||||
import java.lang.System.Logger;
|
||||
import java.lang.System.Logger.Level;
|
||||
@@ -11,16 +14,17 @@ import java.util.prefs.Preferences;
|
||||
import com.jme3.app.Application;
|
||||
import com.jme3.app.state.AbstractAppState;
|
||||
import com.jme3.app.state.AppStateManager;
|
||||
import com.jme3.asset.AssetLoadException;
|
||||
import com.jme3.asset.AssetNotFoundException;
|
||||
import com.jme3.audio.AudioData;
|
||||
import com.jme3.audio.AudioNode;
|
||||
|
||||
|
||||
import pp.monopoly.notification.GameEventListener;
|
||||
import pp.monopoly.notification.SoundEvent;
|
||||
import static pp.util.PreferencesUtils.getPreferences;
|
||||
|
||||
/**
|
||||
* An application state that plays sounds based on game events.
|
||||
* An application state that plays sounds.
|
||||
*/
|
||||
public class GameSound extends AbstractAppState implements GameEventListener {
|
||||
private static final Logger LOGGER = System.getLogger(GameSound.class.getName());
|
||||
@@ -67,6 +71,7 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
||||
|
||||
/**
|
||||
* Sets the enabled state of this AppState.
|
||||
* Overrides {@link com.jme3.app.state.AbstractAppState#setEnabled(boolean)}
|
||||
*
|
||||
* @param enabled {@code true} to enable the AppState, {@code false} to disable it.
|
||||
*/
|
||||
@@ -74,15 +79,16 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (isEnabled() == enabled) return;
|
||||
super.setEnabled(enabled);
|
||||
LOGGER.log(Level.INFO, "Sound enabled: {0}", enabled);
|
||||
LOGGER.log(Level.INFO, "Sound enabled: {0}", enabled); //NON-NLS
|
||||
PREFERENCES.putBoolean(ENABLED_PREF, enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the sound effects for the game and stores the application reference.
|
||||
* Initializes the sound effects for the game.
|
||||
* Overrides {@link AbstractAppState#initialize(AppStateManager, Application)}
|
||||
*
|
||||
* @param stateManager The state manager
|
||||
* @param app The application instance
|
||||
* @param app The application
|
||||
*/
|
||||
@Override
|
||||
public void initialize(AppStateManager stateManager, Application app) {
|
||||
@@ -103,16 +109,18 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
||||
/**
|
||||
* Loads a sound from the specified file.
|
||||
*
|
||||
* @param app The application
|
||||
* @param name The name of the sound file.
|
||||
* @return The loaded AudioNode.
|
||||
*/
|
||||
private AudioNode loadSound(String name) {
|
||||
private AudioNode loadSound(Application app, String name) {
|
||||
try {
|
||||
AudioNode sound = new AudioNode(app.getAssetManager(), name, AudioData.DataType.Buffer);
|
||||
final AudioNode sound = new AudioNode(app.getAssetManager(), name, AudioData.DataType.Buffer);
|
||||
sound.setLooping(false);
|
||||
sound.setPositional(false);
|
||||
return sound;
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (AssetLoadException | AssetNotFoundException ex) {
|
||||
LOGGER.log(Level.ERROR, ex.getMessage(), ex);
|
||||
}
|
||||
return null;
|
||||
@@ -231,4 +239,4 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
||||
case BUTTON -> button();
|
||||
}
|
||||
}
|
||||
}//heloo
|
||||
}
|
||||
|
@@ -18,7 +18,6 @@ import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.system.AppSettings;
|
||||
import com.jme3.texture.Texture;
|
||||
import com.simsilica.lemur.GuiGlobals;
|
||||
import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.style.BaseStyles;
|
||||
|
@@ -3,10 +3,8 @@ package pp.monopoly.client.gui;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
|
||||
|
||||
import pp.monopoly.model.Board;
|
||||
import pp.monopoly.model.Item;
|
||||
import pp.monopoly.model.Item;
|
||||
import pp.monopoly.model.Visitor;
|
||||
import pp.monopoly.notification.GameEventListener;
|
||||
import pp.monopoly.notification.ItemAddedEvent;
|
||||
@@ -26,14 +24,10 @@ abstract class BoardSynchronizer extends ModelViewSynchronizer<Item> implements
|
||||
*
|
||||
* @param board the game board to synchronize
|
||||
* @param root the root node to which the view representations of the board items are attached
|
||||
* @param board the game board to synchronize
|
||||
* @param root the root node to which the view representations of the board items are attached
|
||||
*/
|
||||
protected BoardSynchronizer(Board board, Node root) {
|
||||
protected BoardSynchronizer(Board board, Node root) {
|
||||
super(root);
|
||||
this.board = board;
|
||||
this.board = board;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,7 +42,6 @@ abstract class BoardSynchronizer extends ModelViewSynchronizer<Item> implements
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the existing items from the board to the view during initialization.
|
||||
* Adds the existing items from the board to the view during initialization.
|
||||
*/
|
||||
protected void addExisting() {
|
||||
@@ -56,36 +49,26 @@ abstract class BoardSynchronizer extends ModelViewSynchronizer<Item> implements
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the event when an item is removed from the board.
|
||||
* Handles the event when an item is removed from the board.
|
||||
*
|
||||
* @param event the event indicating that an item has been removed from the board
|
||||
* @param event the event indicating that an item has been removed from the board
|
||||
*/
|
||||
@Override
|
||||
public void receivedEvent(ItemRemovedEvent event) {
|
||||
if (board == event.getBoard()) {
|
||||
delete(event.getItem());
|
||||
}
|
||||
if (board == event.getBoard()) {
|
||||
delete(event.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the event when an item is added to the board.
|
||||
* Handles the event when an item is added to the board.
|
||||
*
|
||||
* @param event the event indicating that an item has been added to the board
|
||||
* @param event the event indicating that an item has been added to the board
|
||||
*/
|
||||
@Override
|
||||
public void receivedEvent(ItemAddedEvent event) {
|
||||
if (board == event.getBoard()) {
|
||||
add(event.getItem());
|
||||
}
|
||||
if (board == event.getBoard()) {
|
||||
add(event.getItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,17 +6,12 @@ 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.Axis;
|
||||
import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Container;
|
||||
import com.simsilica.lemur.HAlignment;
|
||||
import com.simsilica.lemur.Container;
|
||||
import com.simsilica.lemur.HAlignment;
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
import com.simsilica.lemur.component.SpringGridLayout;
|
||||
|
||||
import com.simsilica.lemur.component.SpringGridLayout;
|
||||
|
||||
import pp.dialog.Dialog;
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.notification.Sound;
|
||||
@@ -25,12 +20,10 @@ import pp.monopoly.notification.Sound;
|
||||
* Constructs the startup menu dialog for the Monopoly application.
|
||||
import pp.monopoly.client.gui.GameMenu;
|
||||
*/
|
||||
*/
|
||||
public class StartMenu extends Dialog {
|
||||
private final MonopolyApp app;
|
||||
|
||||
/**
|
||||
* Constructs the Startup Menu dialog for the Monopoly application.
|
||||
* Constructs the Startup Menu dialog for the Monopoly application.
|
||||
*
|
||||
* @param app the MonopolyApp instance
|
||||
@@ -48,10 +41,8 @@ public class StartMenu extends Dialog {
|
||||
Geometry background = new Geometry("Background", quad);
|
||||
Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
backgroundMaterial.setTexture("ColorMap", backgroundImage);
|
||||
backgroundMaterial.setTexture("ColorMap", backgroundImage);
|
||||
background.setMaterial(backgroundMaterial);
|
||||
background.setLocalTranslation(0, 0, -1); // Ensure it is behind other GUI elements
|
||||
background.setLocalTranslation(0, 0, -1); // Ensure it is behind other GUI elements
|
||||
app.getGuiNode().attachChild(background);
|
||||
|
||||
// Center container for title and play button
|
||||
|
@@ -1,80 +0,0 @@
|
||||
package pp.monopoly.client.gui;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.shape.Box;
|
||||
import com.jme3.texture.Texture;
|
||||
import com.jme3.system.JmeCanvasContext;
|
||||
import com.jme3.system.AppSettings;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class TestWorldWithMenu extends SimpleApplication {
|
||||
|
||||
public static void createAndShowGUI() {
|
||||
// Create JFrame
|
||||
JFrame frame = new JFrame("Test World with Menu");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setLayout(new BorderLayout());
|
||||
frame.setSize(800, 600);
|
||||
|
||||
// Create Menu Bar
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
JMenu fileMenu = new JMenu("File");
|
||||
JMenuItem exitItem = new JMenuItem(new AbstractAction("Exit") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
fileMenu.add(exitItem);
|
||||
menuBar.add(fileMenu);
|
||||
frame.setJMenuBar(menuBar);
|
||||
|
||||
// Create Canvas for jMonkey
|
||||
AppSettings settings = new AppSettings(true);
|
||||
settings.setWidth(800);
|
||||
settings.setHeight(600);
|
||||
|
||||
TestWorldWithMenu app = new TestWorldWithMenu();
|
||||
app.setSettings(settings);
|
||||
app.createCanvas(); // Create a canvas for embedding
|
||||
JmeCanvasContext ctx = (JmeCanvasContext) app.getContext();
|
||||
ctx.setSystemListener(app);
|
||||
Canvas canvas = ctx.getCanvas();
|
||||
canvas.setSize(800, 600);
|
||||
|
||||
// Add the canvas to JFrame
|
||||
frame.add(canvas, BorderLayout.CENTER);
|
||||
|
||||
// Show the frame
|
||||
frame.setVisible(true);
|
||||
|
||||
// Start the jMonkeyEngine application
|
||||
app.startCanvas();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleInitApp() {
|
||||
// Erstelle ein Quadrat
|
||||
Box box = new Box(1, 0.01f, 1); // Dünnes Quadrat für die Textur
|
||||
Geometry geom = new Geometry("Box", box);
|
||||
|
||||
// Setze das Material mit Textur
|
||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
Texture texture = assetManager.loadTexture("Pictures/board.png"); // Replace with the path to your image
|
||||
mat.setTexture("ColorMap", texture);
|
||||
geom.setMaterial(mat);
|
||||
|
||||
// Füge das Quadrat zur Szene hinzu
|
||||
rootNode.attachChild(geom);
|
||||
|
||||
// Setze die Kameraposition, um das Quadrat zu fokussieren
|
||||
cam.setLocation(new Vector3f(0, 0, 3)); // Kamera auf der Z-Achse, nah am Quadrat
|
||||
cam.lookAt(geom.getLocalTranslation(), Vector3f.UNIT_Y);
|
||||
}
|
||||
}
|
@@ -1,25 +1,26 @@
|
||||
////////////////////////////////////////
|
||||
// Programming project code
|
||||
// UniBw M, 2022, 2023, 2024
|
||||
// www.unibw.de/inf2
|
||||
// (c) Mark Minas (mark.minas@unibw.de)
|
||||
////////////////////////////////////////
|
||||
|
||||
package pp.monopoly.notification;
|
||||
|
||||
/**
|
||||
* Event when a sound needs to be played.
|
||||
* Event when an item is added to a map.
|
||||
*
|
||||
* @param soundFileName the sound file to be played
|
||||
* @param sound the sound to be played
|
||||
*/
|
||||
public class SoundEvent implements GameEvent {
|
||||
private final String soundFileName;
|
||||
|
||||
public SoundEvent(Sound sound) {
|
||||
this.soundFileName = sound.getFileName(); // Angenommen, Sound hat eine Methode getFileName()
|
||||
}
|
||||
|
||||
public String getSoundFileName() {
|
||||
return soundFileName;
|
||||
}
|
||||
public record SoundEvent(Sound sound) implements GameEvent {
|
||||
|
||||
/**
|
||||
* Notifies the game event listener of this event.
|
||||
*
|
||||
* @param listener the game event listener
|
||||
*/
|
||||
@Override
|
||||
public void notifyListener(GameEventListener listener) {
|
||||
listener.receivedEvent(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user