Merge branch 'development' into 'dev/test'
Updated 'Die' class. See merge request progproj/gruppen-ht24/Gruppe-01!31
This commit is contained in:
1887
Projekte/mdga/client/hs_err_pid24033.log
Normal file
1887
Projekte/mdga/client/hs_err_pid24033.log
Normal file
File diff suppressed because one or more lines are too long
@@ -1,15 +1,18 @@
|
||||
package pp.mdga.client;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.system.JmeContext;
|
||||
import com.simsilica.lemur.GuiGlobals;
|
||||
import pp.mdga.client.acoustic.AcousticHandler;
|
||||
import pp.mdga.client.animation.AnimationHandler;
|
||||
import com.jme3.system.AppSettings;
|
||||
import pp.mdga.client.dialog.JoinDialog;
|
||||
import pp.mdga.client.view.*;
|
||||
import pp.mdga.message.server.ServerInterpreter;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* Main application class for the MdgaApp game.
|
||||
@@ -17,6 +20,8 @@
|
||||
*/
|
||||
public class MdgaApp extends SimpleApplication {
|
||||
|
||||
private static Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
|
||||
|
||||
/** Handles animations in the application. */
|
||||
private AnimationHandler animationHandler;
|
||||
|
||||
@@ -39,7 +44,7 @@ public class MdgaApp extends SimpleApplication {
|
||||
private MdgaState state = null;
|
||||
|
||||
/** Scale for rendering images. */
|
||||
private static final float IMAGE_SCALE = 1.5f;
|
||||
private float imageScale = prefs.getInt("scale", 1);
|
||||
|
||||
/** The main menu view. */
|
||||
private MdgaView mainView;
|
||||
@@ -74,9 +79,9 @@ private MdgaApp() {
|
||||
public static void main(String[] args) {
|
||||
AppSettings settings = new AppSettings(true);
|
||||
settings.setSamples(128);
|
||||
settings.setWidth(prefs.getInt("width", 1280));
|
||||
settings.setHeight(prefs.getInt("height", 720));
|
||||
settings.setCenterWindow(true);
|
||||
settings.setWidth((int) (1920*0.9f));
|
||||
settings.setHeight((int) (1080*0.9f));
|
||||
settings.setVSync(false);
|
||||
|
||||
MdgaApp app = new MdgaApp();
|
||||
@@ -190,7 +195,7 @@ public MdgaState getState() {
|
||||
* @return the image scale as a float
|
||||
*/
|
||||
public float getImageScale() {
|
||||
return IMAGE_SCALE;
|
||||
return imageScale;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,15 +258,12 @@ public ServerConnection getNetworkSupport(){
|
||||
return networkConnection;
|
||||
}
|
||||
|
||||
public void updateResolution(int width, int height) {
|
||||
AppSettings settings = getContext().getSettings();
|
||||
public void updateResolution(int width, int height, float imageFactor) {
|
||||
prefs.putInt("width", width);
|
||||
prefs.putInt("height", height);
|
||||
prefs.putFloat("scale", imageFactor);
|
||||
|
||||
settings.setResolution(width, height);
|
||||
setSettings(settings);
|
||||
restart();
|
||||
|
||||
enter(state);
|
||||
stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -158,4 +158,8 @@ protected void calculateRelative() {
|
||||
heightStep = verticalStep / 2;
|
||||
widthStep = horizontalStep / 2;
|
||||
}
|
||||
|
||||
public Vector2f getPos() {
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,20 +30,9 @@ public SettingsButton(MdgaApp app, Node node, Runnable action) {
|
||||
|
||||
// Enable adjustment for positioning
|
||||
adjust = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the settings button by attaching it to the scene graph.
|
||||
*/
|
||||
@Override
|
||||
public void show() {
|
||||
release();
|
||||
|
||||
calculateRelative();
|
||||
setRelative();
|
||||
setImageRelative(pictureNormal);
|
||||
|
||||
node.attachChild(instance);
|
||||
pictureNormal.setImage(app.getAssetManager(), "Images/Settings_Button_normal.png", true);
|
||||
pictureHover.setImage(app.getAssetManager(), "Images/Settings_Button_hover.png", true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,12 +40,6 @@ public void show() {
|
||||
*/
|
||||
@Override
|
||||
public void onHover() {
|
||||
icon = new IconComponent("Images/Settings_Button_hover.png");
|
||||
icon.setIconScale(0.02f * app.getImageScale());
|
||||
icon.setHAlignment(HAlignment.Center);
|
||||
icon.setVAlignment(VAlignment.Center);
|
||||
|
||||
instance.setIcon(icon);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,12 +47,6 @@ public void onHover() {
|
||||
*/
|
||||
@Override
|
||||
public void onUnHover() {
|
||||
icon = new IconComponent("Images/Settings_Button_normal.png");
|
||||
icon.setIconScale(0.02f * app.getImageScale());
|
||||
icon.setHAlignment(HAlignment.Center);
|
||||
icon.setVAlignment(VAlignment.Center);
|
||||
|
||||
instance.setIcon(icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,18 +3,20 @@
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.scene.Node;
|
||||
import pp.mdga.client.MdgaApp;
|
||||
import pp.mdga.client.button.ButtonLeft;
|
||||
import pp.mdga.client.button.ButtonRight;
|
||||
import pp.mdga.client.button.MenuButton;
|
||||
import pp.mdga.client.view.MdgaView;
|
||||
|
||||
public class VideoSettingsDialog extends Dialog {
|
||||
private MenuButton backButton;
|
||||
|
||||
private MenuButton hdButton9;
|
||||
private MenuButton fullHdButton9;
|
||||
private MenuButton wqhdButton9;
|
||||
private MenuButton hdButton10;
|
||||
private MenuButton fullHdButton10;
|
||||
private MenuButton wqhdButton10;
|
||||
private ButtonLeft hdButton9;
|
||||
private ButtonLeft fullHdButton9;
|
||||
private ButtonLeft wqhdButton9;
|
||||
private ButtonRight hdButton10;
|
||||
private ButtonRight fullHdButton10;
|
||||
private ButtonRight wqhdButton10;
|
||||
|
||||
private final MdgaView view;
|
||||
|
||||
@@ -28,16 +30,29 @@ public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
||||
backButton = new MenuButton(app, node, view::leaveVideoSettings, "Zurück");
|
||||
|
||||
// MenuButton für verschiedene Auflösungen erstellen
|
||||
hdButton9 = new MenuButton(app, node, () -> app.updateResolution(1280, 720), "hd 16:9");
|
||||
fullHdButton9 = new MenuButton(app, node, () -> app.updateResolution(1920, 1080), "full hd 16:9");
|
||||
wqhdButton9 = new MenuButton(app, node, () -> app.updateResolution(2560, 1440), "wqhd 16:9");
|
||||
hdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(1280, 720, 1.0f), "hd 16:9", 10);
|
||||
fullHdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(1920, 1080, 2.25f), "full hd 16:9", 10);
|
||||
wqhdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(2560, 1440, 4.0f), "wqhd 16:9", 10);
|
||||
|
||||
hdButton10 = new MenuButton(app, node, () -> app.updateResolution(1280, 800), "hd 16:10");
|
||||
fullHdButton10 = new MenuButton(app, node, () -> app.updateResolution(1920, 1200), "full hd 16:10");
|
||||
wqhdButton10 = new MenuButton(app, node, () -> app.updateResolution(2560, 1600), "wqhd 16:10");
|
||||
|
||||
hdButton10 = new ButtonRight(app, node, () -> app.updateResolution(1280, 800, 1.0f), "hd 16:10", 10);
|
||||
fullHdButton10 = new ButtonRight(app, node, () -> app.updateResolution(1920, 1200, 2.25f), "full hd 16:10", 10);
|
||||
wqhdButton10 = new ButtonRight(app, node, () -> app.updateResolution(2560, 1600, 4.0f), "wqhd 16:10", 10);
|
||||
|
||||
float offset = 2.8f;
|
||||
|
||||
hdButton9.setPos(new Vector2f(hdButton9.getPos().x, MenuButton.VERTICAL - offset));
|
||||
hdButton10.setPos(new Vector2f(hdButton10.getPos().x, MenuButton.VERTICAL - offset));
|
||||
offset += 1.5f;
|
||||
|
||||
fullHdButton9.setPos(new Vector2f(fullHdButton9.getPos().x, MenuButton.VERTICAL - offset));
|
||||
fullHdButton10.setPos(new Vector2f(fullHdButton10.getPos().x, MenuButton.VERTICAL - offset));
|
||||
offset += 1.5f;
|
||||
|
||||
wqhdButton9.setPos(new Vector2f(wqhdButton9.getPos().x, MenuButton.VERTICAL - offset));
|
||||
wqhdButton10.setPos(new Vector2f(wqhdButton10.getPos().x, MenuButton.VERTICAL - offset));
|
||||
offset += 1.5f;
|
||||
|
||||
backButton.setPos(new Vector2f(0, 1.8f));
|
||||
}
|
||||
|
||||
|
||||
@@ -43,11 +43,14 @@ public class Die {
|
||||
*/
|
||||
private int lastNumberOfDice;
|
||||
|
||||
private final boolean lock;
|
||||
|
||||
/**
|
||||
* This constructor is used to create a new Die object with a random seed.
|
||||
*/
|
||||
public Die() {
|
||||
this.random = RandomGeneratorFactory.of("Random").create();
|
||||
this.lock = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,6 +60,18 @@ public Die() {
|
||||
*/
|
||||
public Die(long seed) {
|
||||
this.random = RandomGeneratorFactory.of("Random").create(seed);
|
||||
this.lock = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param roll as the roll which should be returned everytime the shuffle method will be called as an Integer.
|
||||
*/
|
||||
public Die(int roll) {
|
||||
this.random = RandomGeneratorFactory.of("Random").create();
|
||||
this.lastNumberOfDice = roll;
|
||||
this.lock = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,6 +80,10 @@ public Die(long seed) {
|
||||
* @return lastNumberOfDice as an Integer.
|
||||
*/
|
||||
public int shuffle() {
|
||||
if (this.lock) {
|
||||
return this.lastNumberOfDice;
|
||||
}
|
||||
|
||||
this.lastNumberOfDice = this.random.nextInt(MAXIMUM_EYES) + 1;
|
||||
|
||||
return this.lastNumberOfDice;
|
||||
|
||||
Reference in New Issue
Block a user