Merge, refactor GUI, enable collision, try to add new button style
This commit is contained in:
parent
b960885942
commit
4f50eda9ea
51
ShootingStars/assets/Gui/Button.xml
Normal file
51
ShootingStars/assets/Gui/Button.xml
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<root>
|
||||
<element name="Button">
|
||||
<font>
|
||||
<property name="fontSize" type="float" value="20" />
|
||||
<property name="fontColor" type="ColorRGBA">
|
||||
<r value="0.8" />
|
||||
<g value="0.8" />
|
||||
<b value="0.8" />
|
||||
<a value="1.0" />
|
||||
</property>
|
||||
<property name="textAlign" type="String" value="Center" />
|
||||
<property name="textVAlign" type="String" value="Center" />
|
||||
<property name="textWrap" type="String" value="NoWrap" />
|
||||
<property name="hoverColor" type="ColorRGBA">
|
||||
<r value="1.0" />
|
||||
<g value="1.0" />
|
||||
<b value="1.0" />
|
||||
<a value="1.0" />
|
||||
</property>
|
||||
<property name="pressedColor" type="ColorRGBA">
|
||||
<r value="0.6" />
|
||||
<g value="0.6" />
|
||||
<b value="0.6" />
|
||||
<a value="1.0" />
|
||||
</property>
|
||||
</font>
|
||||
<attributes>
|
||||
<property name="resizeBorders" type="Vector4f">
|
||||
<x value="5" />
|
||||
<y value="5" />
|
||||
<z value="5" />
|
||||
<w value="5" />
|
||||
</property>
|
||||
<property name="defaultSize" type="Vector2f">
|
||||
<x value="100" />
|
||||
<y value="30" />
|
||||
</property>
|
||||
<property name="pressedSound" type="String" value="button_pressed" />
|
||||
<property name="usePressedSound" type="boolean" value="true" />
|
||||
<property name="pressedSoundVolume" type="float" value="1" />
|
||||
<property name="hoverSound" type="String" value="button_focus" />
|
||||
<property name="useHoverSound" type="boolean" value="true" />
|
||||
<property name="hoverSoundVolume" type="float" value=".5" />
|
||||
</attributes>
|
||||
<images>
|
||||
<property name="defaultImg" type="String" value="Gui/button.png" />
|
||||
</images>
|
||||
</element>
|
||||
</root>
|
||||
BIN
ShootingStars/assets/Gui/button.png
Normal file
BIN
ShootingStars/assets/Gui/button.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 463 B |
5
ShootingStars/assets/Gui/style_map.xml
Normal file
5
ShootingStars/assets/Gui/style_map.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<root>
|
||||
<style control="Button" path="Button.xml" />
|
||||
</root>
|
||||
|
||||
@ -54,11 +54,11 @@ public class ShootingStars extends SimpleApplication {
|
||||
private PersiJContainer container;
|
||||
private StateManager sManager;
|
||||
private OptionSettings optionSettings;
|
||||
private Screen screen;
|
||||
|
||||
public ShootingStars(OptionSettings optionSettings) {
|
||||
super(new StatsAppState(), new DebugKeysAppState());
|
||||
this.optionSettings = optionSettings;
|
||||
|
||||
Logger.getLogger("").setLevel(Level.SEVERE);
|
||||
System.setProperty("jna.library.path", "lib/vlc");
|
||||
}
|
||||
@ -75,6 +75,7 @@ public class ShootingStars extends SimpleApplication {
|
||||
cam.setFrustumFar(2500f);
|
||||
sManager = container.resolve(StateManager.class);
|
||||
sManager.setState(State.START);
|
||||
//screen = new Screen(this, "Gui/style_map.xml");
|
||||
}
|
||||
|
||||
private void initGUI() {
|
||||
|
||||
@ -21,6 +21,7 @@ import com.jme3.collision.CollisionResults;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import org.wyrez.shootingstars.game.Player;
|
||||
import org.wyrez.shootingstars.helper.UserDataKeys;
|
||||
|
||||
/**
|
||||
@ -32,9 +33,11 @@ public class WeaponProjectileCollisionControl extends BaseControl {
|
||||
private Node starNode;
|
||||
private BoundingVolume boundingVolume;
|
||||
private CollisionResults results;
|
||||
private Player player;
|
||||
|
||||
public WeaponProjectileCollisionControl(Node starNode) {
|
||||
public WeaponProjectileCollisionControl(Node starNode, Player player) {
|
||||
this.starNode = starNode;
|
||||
this.player = player;
|
||||
this.results = new CollisionResults();
|
||||
}
|
||||
|
||||
@ -46,17 +49,19 @@ public class WeaponProjectileCollisionControl extends BaseControl {
|
||||
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
for (Spatial s : starNode.getChildren()) {
|
||||
results.clear();
|
||||
s.collideWith(boundingVolume, results);
|
||||
if (results.size() > 0) {
|
||||
s.setUserData(UserDataKeys.HITTED, true);
|
||||
if(player.getUserData(UserDataKeys.SHOOTING)) {
|
||||
for (Spatial s : starNode.getChildren()) {
|
||||
results.clear();
|
||||
s.collideWith(boundingVolume, results);
|
||||
if (results.size() > 0) {
|
||||
s.setUserData(UserDataKeys.HITTED, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Control cloneForSpatial(Spatial spatial) {
|
||||
WeaponProjectileCollisionControl control = new WeaponProjectileCollisionControl(starNode);
|
||||
WeaponProjectileCollisionControl control = new WeaponProjectileCollisionControl(starNode,player);
|
||||
spatial.addControl(control);
|
||||
return control;
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ import org.wyrez.shootingstars.controls.PlayerCamControl;
|
||||
import org.wyrez.shootingstars.controls.PlayerMouseControl;
|
||||
import org.wyrez.shootingstars.controls.PlayerMoveControl;
|
||||
import org.wyrez.shootingstars.controls.PlayerShootControl;
|
||||
import org.wyrez.shootingstars.controls.WeaponProjectileCollisionControl;
|
||||
import org.wyrez.shootingstars.controls.WeaponProjectileControl;
|
||||
import org.wyrez.shootingstars.data.AudioDataManager;
|
||||
import org.wyrez.shootingstars.factories.Materials;
|
||||
@ -53,13 +54,14 @@ public class Player extends Node {
|
||||
|
||||
public Player(Node rootNode, StateManager stateManager, AssetManager assetManager,
|
||||
ViewPort viewPort, GameGUI gui, InputManager inputManager, Camera camera,
|
||||
AudioDataManager audioDataManager) {
|
||||
AudioDataManager audioDataManager, Node starNode) {
|
||||
super("Player");
|
||||
|
||||
|
||||
initPlayer(inputManager, camera, audioDataManager, gui);
|
||||
initWeapon(assetManager);
|
||||
initProjectile(rootNode);
|
||||
initWeaponContainer();
|
||||
initGhostProjectile(starNode);
|
||||
addLight();
|
||||
}
|
||||
|
||||
@ -93,7 +95,7 @@ public class Player extends Node {
|
||||
geom2.setMaterial(Materials.WEAPON.create());
|
||||
geom2.move(0f, 0.25f, -5f);
|
||||
projectile.attachChild(geom2);
|
||||
|
||||
|
||||
projectile.addControl(new WeaponProjectileControl(rootNode, this));
|
||||
}
|
||||
|
||||
@ -109,6 +111,15 @@ public class Player extends Node {
|
||||
|
||||
this.attachChild(weaponContainer);
|
||||
}
|
||||
|
||||
private void initGhostProjectile(Node starNode) {
|
||||
Geometry ghostProjectile = new Geometry("ghostProjectile", new Box(0.1f, 0.1f, 2500f));
|
||||
ghostProjectile.setMaterial(Materials.UNSHADED.create());
|
||||
ghostProjectile.setCullHint(CullHint.Always);
|
||||
ghostProjectile.move(0f,0f,2510f);
|
||||
ghostProjectile.addControl(new WeaponProjectileCollisionControl(starNode,this));
|
||||
this.attachChild(ghostProjectile);
|
||||
}
|
||||
|
||||
private void addLight() {
|
||||
AmbientLight ambient = new AmbientLight();
|
||||
|
||||
@ -1,103 +1,105 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.game;
|
||||
|
||||
import com.jme3.light.AmbientLight;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import java.util.Random;
|
||||
import org.wyrez.shootingstars.controls.StarDeathControl;
|
||||
import org.wyrez.shootingstars.controls.StarFaceControl;
|
||||
import org.wyrez.shootingstars.controls.StarPointControl;
|
||||
import org.wyrez.shootingstars.data.AudioDataManager;
|
||||
import org.wyrez.shootingstars.factories.Materials;
|
||||
import org.wyrez.shootingstars.helper.MathHelper;
|
||||
import org.wyrez.shootingstars.helper.UserDataKeys;
|
||||
import org.wyrez.shootingstars.mesh.Star;
|
||||
import org.wyrez.shootingstars.states.GameState;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class StarManager extends Node {
|
||||
|
||||
private static final Random random;
|
||||
private static final float MAX_STAR_SIZE = 15f;
|
||||
private static final float VAR_STAR_SIZE = 10f;
|
||||
|
||||
static {
|
||||
random = new Random();
|
||||
}
|
||||
/**/
|
||||
private AudioDataManager audioDataManager;
|
||||
private Spatial player;
|
||||
|
||||
public StarManager(AudioDataManager audioDataManager, Spatial player) {
|
||||
this.audioDataManager = audioDataManager;
|
||||
this.player = player;
|
||||
addLight();
|
||||
}
|
||||
|
||||
public void update(float tpf) {
|
||||
float[] data = audioDataManager.getSpawnData();
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
for (float d : data) {
|
||||
if (d > 0f) {
|
||||
spawn(calcPosition(), calcSize(d), d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3f calcPosition() {
|
||||
float radius = (GameState.FIELD_RADIUS - MAX_STAR_SIZE) * random.nextFloat();
|
||||
|
||||
return MathHelper.calcPointOnCircle(MathHelper.degreeToRadian(random.nextFloat() * 360f),
|
||||
radius, random.nextFloat() * GameState.FIELD_HEIGHT + GameState.FIELD_LOWER_POS);
|
||||
}
|
||||
|
||||
private float calcSize(float data) {
|
||||
return MAX_STAR_SIZE - VAR_STAR_SIZE * data;
|
||||
}
|
||||
|
||||
private void spawn(Vector3f location, float size, float value) {
|
||||
Geometry star = new Geometry("Star", new Star(size, size * 0.2f, 0.5f));
|
||||
star.setLocalTranslation(location);
|
||||
Material mat = Materials.STAR.create();
|
||||
mat.setColor("Color", ColorRGBA.Yellow);
|
||||
star.setMaterial(mat);
|
||||
star.setUserData(UserDataKeys.SIZE, size);
|
||||
|
||||
star.addControl(new StarFaceControl(player));
|
||||
star.addControl(new StarDeathControl());
|
||||
star.addControl(new StarPointControl(player, value));
|
||||
|
||||
this.attachChild(star);
|
||||
}
|
||||
|
||||
private void addLight() {
|
||||
AmbientLight ambient = new AmbientLight();
|
||||
ambient.setColor(ColorRGBA.White);
|
||||
this.addLight(ambient);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.game;
|
||||
|
||||
import com.jme3.light.AmbientLight;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import java.util.Random;
|
||||
import org.wyrez.shootingstars.controls.StarDeathControl;
|
||||
import org.wyrez.shootingstars.controls.StarFaceControl;
|
||||
import org.wyrez.shootingstars.controls.StarPointControl;
|
||||
import org.wyrez.shootingstars.data.AudioDataManager;
|
||||
import org.wyrez.shootingstars.factories.Materials;
|
||||
import org.wyrez.shootingstars.helper.MathHelper;
|
||||
import org.wyrez.shootingstars.helper.UserDataKeys;
|
||||
import org.wyrez.shootingstars.mesh.Star;
|
||||
import org.wyrez.shootingstars.states.GameState;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class StarManager{
|
||||
|
||||
private static final Random random;
|
||||
private static final float MAX_STAR_SIZE = 15f;
|
||||
private static final float VAR_STAR_SIZE = 10f;
|
||||
|
||||
static {
|
||||
random = new Random();
|
||||
}
|
||||
/**/
|
||||
private AudioDataManager audioDataManager;
|
||||
private Spatial player;
|
||||
private Node starNode;
|
||||
|
||||
public StarManager(AudioDataManager audioDataManager, Spatial player, Node starNode) {
|
||||
this.audioDataManager = audioDataManager;
|
||||
this.player = player;
|
||||
this.starNode = starNode;
|
||||
addLight();
|
||||
}
|
||||
|
||||
public void update(float tpf) {
|
||||
float[] data = audioDataManager.getSpawnData();
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
for (float d : data) {
|
||||
if (d > 0f) {
|
||||
spawn(calcPosition(), calcSize(d), d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3f calcPosition() {
|
||||
float radius = (GameState.FIELD_RADIUS - MAX_STAR_SIZE) * random.nextFloat();
|
||||
|
||||
return MathHelper.calcPointOnCircle(MathHelper.degreeToRadian(random.nextFloat() * 360f),
|
||||
radius, random.nextFloat() * GameState.FIELD_HEIGHT + GameState.FIELD_LOWER_POS);
|
||||
}
|
||||
|
||||
private float calcSize(float data) {
|
||||
return MAX_STAR_SIZE - VAR_STAR_SIZE * data;
|
||||
}
|
||||
|
||||
private void spawn(Vector3f location, float size, float value) {
|
||||
Geometry star = new Geometry("Star", new Star(size, size * 0.2f, 0.5f));
|
||||
star.setLocalTranslation(location);
|
||||
Material mat = Materials.STAR.create();
|
||||
mat.setColor("Color", ColorRGBA.Yellow);
|
||||
star.setMaterial(mat);
|
||||
star.setUserData(UserDataKeys.SIZE, size);
|
||||
|
||||
star.addControl(new StarFaceControl(player));
|
||||
star.addControl(new StarDeathControl());
|
||||
star.addControl(new StarPointControl(player, value));
|
||||
|
||||
starNode.attachChild(star);
|
||||
}
|
||||
|
||||
private void addLight() {
|
||||
AmbientLight ambient = new AmbientLight();
|
||||
ambient.setColor(ColorRGBA.White);
|
||||
starNode.addLight(ambient);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,8 +65,8 @@ public class GameGUI extends Panel {
|
||||
float startPointx = screenHelper.calcX(537f);
|
||||
float startPointy = screenHelper.calcY(576f);
|
||||
|
||||
float startPointPointsx = screenHelper.calcX(1100f);
|
||||
float startPointPointsy = screenHelper.calcY(25f);
|
||||
float startPointPointsx = screenHelper.calcX(1000f);
|
||||
float startPointPointsy = screenHelper.calcY(10f);
|
||||
|
||||
float startPointYMenu = screenHelper.calcY(200f);
|
||||
|
||||
@ -133,7 +133,7 @@ public class GameGUI extends Panel {
|
||||
|
||||
lblPoints = new Label(screen, new Vector2f(startPointPointsx, startPointPointsy), new Vector2f(screenHelper.calcX(275f), screenHelper.calcY(180f)));
|
||||
lblPoints.setFontColor(new ColorRGBA(1f, 0f, 0f, 1f));
|
||||
lblPoints.setFontSize(screenHelper.calcX(50f));
|
||||
lblPoints.setFontSize(screenHelper.calcX(30f));
|
||||
|
||||
this.addChild(btnStart);
|
||||
this.addChild(btnResume);
|
||||
@ -198,7 +198,7 @@ public class GameGUI extends Panel {
|
||||
}
|
||||
|
||||
public void setPoints(String points) {
|
||||
lblPoints.setText(points);
|
||||
lblPoints.setText("Points: " + points);
|
||||
}
|
||||
|
||||
public void setPlayer(Spatial player) {
|
||||
|
||||
@ -51,12 +51,12 @@ public class OptionsGUI extends Panel implements Gui {
|
||||
private ComboBox cboFrequency;
|
||||
private CheckBox chkFullscreen;
|
||||
private CheckBox chkVSync;
|
||||
private CheckBox chkPostProcessing;
|
||||
private CheckBox chkShowWeapon;
|
||||
private Slider sldParticleDensity;
|
||||
//Audio Controls
|
||||
private Slider sldMasterVolume;
|
||||
private Slider sldFXVolume;
|
||||
private Slider sldSoundVolume;
|
||||
private Slider sldMenuVolume;
|
||||
private Slider sldMusicVolume;
|
||||
|
||||
public OptionsGUI(Screen screen, OptionsListener listener, OptionSettings settings, ScreenHelper screenHelper) {
|
||||
super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); //create for full hd
|
||||
@ -121,7 +121,7 @@ public class OptionsGUI extends Panel implements Gui {
|
||||
float marginLeftControls = screenHelper.calcX(115.8f);
|
||||
|
||||
Label lblPlayerName = new Label(screen, new Vector2f(startPointx, startPointy), new Vector2f(screenHelper.calcX(120f), screenHelper.calcY(40f)));
|
||||
lblPlayerName.setText("PlayerName");
|
||||
lblPlayerName.setText("Player Name");
|
||||
lblPlayerName.setFontSize(labelFontSize);
|
||||
|
||||
txtPlayerName = new TextField(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(7f)), new Vector2f(screenHelper.calcX(200f), screenHelper.calcY(30f)));
|
||||
@ -161,10 +161,10 @@ public class OptionsGUI extends Panel implements Gui {
|
||||
chkVSync = new CheckBox(screen, new Vector2f(startPointx + marginLeftControls + screenHelper.calcX(400f), startPointy + screenHelper.calcY(12f)), new Vector2f(checkBoxWitdh, checkBoxHeight));
|
||||
|
||||
Label lblPostProcessing = new Label(screen, "lblPostProcessing", new Vector2f(startPointx + screenHelper.calcX(800f), startPointy), new Vector2f(labelWitdh, labelHeight));
|
||||
lblPostProcessing.setText("PostProcessing");
|
||||
lblPostProcessing.setText("Show Weapon");
|
||||
lblPostProcessing.setFontSize(labelFontSize);
|
||||
|
||||
chkPostProcessing = new CheckBox(screen, new Vector2f(startPointx + marginLeftControls + screenHelper.calcX(800f), startPointy + screenHelper.calcY(12f)), new Vector2f(checkBoxWitdh, checkBoxHeight));
|
||||
chkShowWeapon = new CheckBox(screen, new Vector2f(startPointx + marginLeftControls + screenHelper.calcX(800f), startPointy + screenHelper.calcY(12f)), new Vector2f(checkBoxWitdh, checkBoxHeight));
|
||||
|
||||
Label lblResolution = new Label(screen, "lblResolution", new Vector2f(startPointx, startPointy + screenHelper.calcY(50f)), new Vector2f(labelWitdh, labelHeight));
|
||||
lblResolution.setText("Resolution");
|
||||
@ -195,7 +195,7 @@ public class OptionsGUI extends Panel implements Gui {
|
||||
}
|
||||
|
||||
Label lblParticleDensity = new Label(screen, "lblParticleDensity", new Vector2f(startPointx + screenHelper.calcX(800f), startPointy +screenHelper.calcY(50f)), new Vector2f(labelWitdh, labelHeight));
|
||||
lblParticleDensity.setText("ParticleDensity");
|
||||
lblParticleDensity.setText("Particle Density");
|
||||
lblParticleDensity.setFontSize(labelFontSize);
|
||||
|
||||
sldParticleDensity = new Slider(screen, new Vector2f(startPointx + marginLeftControls + screenHelper.calcX(800f), startPointy + screenHelper.calcY(57f)), new Vector2f(sliderWitdh, sliderHeight), Slider.Orientation.HORIZONTAL, false) {
|
||||
@ -215,7 +215,7 @@ public class OptionsGUI extends Panel implements Gui {
|
||||
this.addChild(lblResolution);
|
||||
this.addChild(cboResolution);
|
||||
this.addChild(lblPostProcessing);
|
||||
this.addChild(chkPostProcessing);
|
||||
this.addChild(chkShowWeapon);
|
||||
this.addChild(lblParticleDensity);
|
||||
this.addChild(sldParticleDensity);
|
||||
}
|
||||
@ -232,7 +232,7 @@ public class OptionsGUI extends Panel implements Gui {
|
||||
float sliderHeight = screenHelper.calcY(30f);
|
||||
|
||||
Label lblMasterVolume = new Label(screen, "lblMasterVolume", new Vector2f(startPointx, startPointy), new Vector2f(labelWitdh, labelHeight));
|
||||
lblMasterVolume.setText("MasterVolume");
|
||||
lblMasterVolume.setText("Master Volume");
|
||||
lblMasterVolume.setFontSize(labelFontSize);
|
||||
|
||||
sldMasterVolume = new Slider(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(7f)), new Vector2f(sliderWitdh, sliderHeight), Slider.Orientation.HORIZONTAL, false) {
|
||||
@ -243,33 +243,33 @@ public class OptionsGUI extends Panel implements Gui {
|
||||
sldMasterVolume.setStepIntegerRange(0, 100, 1);
|
||||
|
||||
Label lblFXVolume = new Label(screen, "lblFXVolume", new Vector2f(startPointx + screenHelper.calcX(400f), startPointy), new Vector2f(labelWitdh, labelHeight));
|
||||
lblFXVolume.setText("FXVolume");
|
||||
lblFXVolume.setText("Menu Volume");
|
||||
lblFXVolume.setFontSize(labelFontSize);
|
||||
|
||||
sldFXVolume = new Slider(screen, new Vector2f(startPointx + marginLeftControls + screenHelper.calcX(400f), startPointy + screenHelper.calcY(7f)), new Vector2f(sliderWitdh, sliderHeight), Slider.Orientation.HORIZONTAL, false) {
|
||||
sldMenuVolume = new Slider(screen, new Vector2f(startPointx + marginLeftControls + screenHelper.calcX(400f), startPointy + screenHelper.calcY(7f)), new Vector2f(sliderWitdh, sliderHeight), Slider.Orientation.HORIZONTAL, false) {
|
||||
@Override
|
||||
public void onChange(int selectedIndex, Object value) {
|
||||
}
|
||||
};
|
||||
sldFXVolume.setStepIntegerRange(0, 100, 1);
|
||||
sldMenuVolume.setStepIntegerRange(0, 100, 1);
|
||||
|
||||
Label lblSoundVolume = new Label(screen, "lblSoundVolume", new Vector2f(startPointx + screenHelper.calcX(800f), startPointy + screenHelper.calcY(0f)), new Vector2f(labelWitdh, labelHeight));
|
||||
lblSoundVolume.setText("SoundVolume");
|
||||
lblSoundVolume.setText("Music Volume");
|
||||
lblSoundVolume.setFontSize(labelFontSize);
|
||||
|
||||
sldSoundVolume = new Slider(screen, new Vector2f(startPointx + marginLeftControls + screenHelper.calcX(800f), startPointy + screenHelper.calcY(7f)), new Vector2f(sliderWitdh, sliderHeight), Slider.Orientation.HORIZONTAL, false) {
|
||||
sldMusicVolume = new Slider(screen, new Vector2f(startPointx + marginLeftControls + screenHelper.calcX(800f), startPointy + screenHelper.calcY(7f)), new Vector2f(sliderWitdh, sliderHeight), Slider.Orientation.HORIZONTAL, false) {
|
||||
@Override
|
||||
public void onChange(int selectedIndex, Object value) {
|
||||
}
|
||||
};
|
||||
sldSoundVolume.setStepIntegerRange(0, 100, 1);
|
||||
sldMusicVolume.setStepIntegerRange(0, 100, 1);
|
||||
|
||||
this.addChild(lblMasterVolume);
|
||||
this.addChild(sldMasterVolume);
|
||||
this.addChild(lblFXVolume);
|
||||
this.addChild(sldFXVolume);
|
||||
this.addChild(sldMenuVolume);
|
||||
this.addChild(lblSoundVolume);
|
||||
this.addChild(sldSoundVolume);
|
||||
this.addChild(sldMusicVolume);
|
||||
}
|
||||
|
||||
private void readControlValues() {
|
||||
@ -283,13 +283,13 @@ public class OptionsGUI extends Panel implements Gui {
|
||||
setComboBoxValue(cboFrequency, String.valueOf(settings.getFrequency()));
|
||||
chkFullscreen.setIsChecked(settings.isFullscreenEnabled());
|
||||
chkVSync.setIsChecked(settings.isVSyncEnabled());
|
||||
chkPostProcessing.setIsChecked(settings.isPostprocessingEnabled());
|
||||
chkShowWeapon.setIsChecked(settings.isShowWeaponEnabled());
|
||||
sldParticleDensity.setSelectedIndex(settings.getParticleDensity());
|
||||
|
||||
//Audio
|
||||
sldMasterVolume.setSelectedIndex(settings.getMasterVolume());
|
||||
sldFXVolume.setSelectedIndex(settings.getFXVolume());
|
||||
sldSoundVolume.setSelectedIndex(settings.getSoundVolume());
|
||||
sldMenuVolume.setSelectedIndex(settings.getMenuVolume());
|
||||
sldMusicVolume.setSelectedIndex(settings.getMusicVolume());
|
||||
}
|
||||
|
||||
private void setComboBoxValue(ComboBox comboBox, String value) {
|
||||
@ -311,13 +311,13 @@ public class OptionsGUI extends Panel implements Gui {
|
||||
settings.setFrequency(Integer.parseInt(cboFrequency.getSelectedListItem().getValue().toString()));
|
||||
settings.setFullscreen(chkFullscreen.getIsChecked());
|
||||
settings.setVSync(chkVSync.getIsChecked());
|
||||
settings.setPostProcessing(chkPostProcessing.getIsChecked());
|
||||
settings.setShowWeapon(chkShowWeapon.getIsChecked());
|
||||
settings.setParticleDensity(sldParticleDensity.getSelectedIndex());
|
||||
|
||||
//Audio
|
||||
settings.setMasterVolume(sldMasterVolume.getSelectedIndex());
|
||||
settings.setFXVolume(sldFXVolume.getSelectedIndex());
|
||||
settings.setSoundVolume(sldSoundVolume.getSelectedIndex());
|
||||
settings.setMenuVolume(sldMenuVolume.getSelectedIndex());
|
||||
settings.setMusicVolume(sldMusicVolume.getSelectedIndex());
|
||||
|
||||
settings.save();
|
||||
}
|
||||
|
||||
@ -70,11 +70,13 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
||||
private Cinema cinema;
|
||||
private Ground ground;
|
||||
private Node player;
|
||||
private Node starNode;
|
||||
private OptionSettings optionSettings;
|
||||
private boolean isRunning = false;
|
||||
private boolean isFinished = false;
|
||||
|
||||
public GameState(Node rootNode, Screen screen, StateManager stateManager,
|
||||
AssetManager assetManager, ViewPort viewPort, OptionSettings options,
|
||||
AssetManager assetManager, ViewPort viewPort, OptionSettings optionSettings,
|
||||
InputManager inputManager, Camera camera, AudioDataManager audioDataManager,
|
||||
GameSettings settings, ScreenHelper screenHelper) {
|
||||
|
||||
@ -88,12 +90,13 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
||||
this.audioDataManager = audioDataManager;
|
||||
this.assetManager = assetManager;
|
||||
this.viewPort = viewPort;
|
||||
this.optionSettings = optionSettings;
|
||||
|
||||
mediaPlayerFactory = new MediaPlayerFactory("--no-video-title-show", "--quiet");
|
||||
|
||||
this.settings = settings;
|
||||
|
||||
Particles.setParticleDensity(options.getParticleDensity());
|
||||
Particles.setParticleDensity(optionSettings.getParticleDensity());
|
||||
}
|
||||
|
||||
public void loadGround() {
|
||||
@ -122,13 +125,14 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
||||
}
|
||||
|
||||
public void loadPlayer() {
|
||||
starNode = new Node();
|
||||
player = new Player(rootNode, stateManager, assetManager, viewPort, gui,
|
||||
inputManager, camera, audioDataManager);
|
||||
inputManager, camera, audioDataManager, starNode);
|
||||
|
||||
gui.setPlayer(player);
|
||||
|
||||
//Out of possition, but it needs an initialized player...
|
||||
this.starManager = new StarManager(audioDataManager, player);
|
||||
this.starManager = new StarManager(audioDataManager, player, starNode);
|
||||
}
|
||||
|
||||
private void setRunning(boolean running) {
|
||||
@ -139,6 +143,8 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
||||
public void start() {
|
||||
gui.setStart();
|
||||
inputManager.setCursorVisible(false);
|
||||
mediaPlayer.setVolume(optionSettings.getMusicVolume() *
|
||||
Math.round((float)optionSettings.getMasterVolume() / 100f));
|
||||
mediaPlayer.play();
|
||||
setRunning(true);
|
||||
}
|
||||
@ -148,7 +154,7 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
||||
rootNode.attachChild(cinema);
|
||||
rootNode.attachChild(ground);
|
||||
rootNode.attachChild(player);
|
||||
rootNode.attachChild(starManager);
|
||||
rootNode.attachChild(starNode);
|
||||
gui.setWait();
|
||||
gui.attach();
|
||||
}
|
||||
@ -156,7 +162,7 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
||||
@Override
|
||||
public void stateDetached(AppStateManager stateManager) {
|
||||
gui.detach();
|
||||
rootNode.detachChild(starManager);
|
||||
rootNode.detachChild(starNode);
|
||||
rootNode.detachChild(player);
|
||||
rootNode.detachChild(ground);
|
||||
rootNode.detachChild(cinema);
|
||||
|
||||
@ -59,12 +59,13 @@ public class OptionSettings {
|
||||
settings.setTitle("Shooting Stars");
|
||||
settings.setSettingsDialogImage("");
|
||||
setMasterVolume(100);
|
||||
setFXVolume(100);
|
||||
setMenuVolume(100);
|
||||
setSoundVolume(100);
|
||||
setUsername("Player");
|
||||
setPostProcessing(true);
|
||||
setParticleDensity(3);
|
||||
setDepthBits(24);
|
||||
setShowWeapon(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,8 +89,8 @@ public class OptionSettings {
|
||||
settings.putInteger("MusicVolume", volume);
|
||||
}
|
||||
|
||||
public void setFXVolume(int volume) {
|
||||
settings.putInteger("FXVolume", volume);
|
||||
public void setMenuVolume(int volume) {
|
||||
settings.putInteger("MenuVolume", volume);
|
||||
}
|
||||
|
||||
public void setSoundVolume(int volume) {
|
||||
@ -99,6 +100,10 @@ public class OptionSettings {
|
||||
public void setPostProcessing(boolean enabled) {
|
||||
settings.putBoolean("PostProcessing", enabled);
|
||||
}
|
||||
|
||||
public void setShowWeapon(boolean enabled) {
|
||||
settings.putBoolean("ShowWeapon", enabled);
|
||||
}
|
||||
|
||||
public void setFullscreen(boolean enabled) {
|
||||
settings.setFullscreen(enabled);
|
||||
@ -144,8 +149,8 @@ public class OptionSettings {
|
||||
return settings.getInteger("MusicVolume");
|
||||
}
|
||||
|
||||
public int getFXVolume() {
|
||||
return settings.getInteger("FXVolume");
|
||||
public int getMenuVolume() {
|
||||
return settings.getInteger("MenuVolume");
|
||||
}
|
||||
|
||||
public int getSoundVolume() {
|
||||
@ -155,6 +160,10 @@ public class OptionSettings {
|
||||
public boolean isPostprocessingEnabled() {
|
||||
return settings.getBoolean("PostProcessing");
|
||||
}
|
||||
|
||||
public boolean isShowWeaponEnabled() {
|
||||
return settings.getBoolean("ShowWeapon");
|
||||
}
|
||||
|
||||
public boolean isFullscreenEnabled() {
|
||||
return settings.isFullscreen();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user