fixed all bugs found through tested
This commit is contained in:
parent
c90c70d0d9
commit
d6ceab8afb
Binary file not shown.
BIN
ShootingStars/assets/Sound/menu_loop1.wav
Normal file
BIN
ShootingStars/assets/Sound/menu_loop1.wav
Normal file
Binary file not shown.
@ -59,7 +59,9 @@ public class ShootingStars extends SimpleApplication {
|
||||
super((AppState) null);
|
||||
this.optionSettings = optionSettings;
|
||||
this.setPauseOnLostFocus(false);
|
||||
Logger.getLogger("").setLevel(Level.SEVERE);
|
||||
if (!optionSettings.isLogEnabled()) {
|
||||
Logger.getLogger("").setLevel(Level.SEVERE);
|
||||
}
|
||||
System.setProperty("jna.library.path", "lib/vlc");
|
||||
}
|
||||
|
||||
|
||||
@ -56,22 +56,24 @@ public class StarPointControl extends BaseControl {
|
||||
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
if ((Boolean) spatial.getUserData(UserDataKeys.HITTED) && !isHitted) {
|
||||
player.setUserData(UserDataKeys.POINTS, (Integer) (player.getUserData(UserDataKeys.POINTS))
|
||||
+ (int) Math.round(points));
|
||||
isHitted = true;
|
||||
} else if (timer <= 0f) {
|
||||
if (points > 1f) {
|
||||
points -= 2f * tpf;
|
||||
color = ColorHelper.calcColor(points / MAX_POINTS);
|
||||
} else if (points <= 1f) {
|
||||
points = 1f;
|
||||
color = ColorHelper.calcColor(points / MAX_POINTS);
|
||||
spatial.setUserData(UserDataKeys.HITTED, true);
|
||||
if (spatial.getUserData(UserDataKeys.RUNNING)) {
|
||||
if ((Boolean) spatial.getUserData(UserDataKeys.HITTED) && !isHitted) {
|
||||
player.setUserData(UserDataKeys.POINTS, (Integer) (player.getUserData(UserDataKeys.POINTS))
|
||||
+ (int) Math.round(points));
|
||||
isHitted = true;
|
||||
} else if (timer <= 0f) {
|
||||
if (points > 1f) {
|
||||
points -= 2f * tpf;
|
||||
color = ColorHelper.calcColor(points / MAX_POINTS);
|
||||
} else if (points <= 1f) {
|
||||
points = 1f;
|
||||
color = ColorHelper.calcColor(points / MAX_POINTS);
|
||||
spatial.setUserData(UserDataKeys.HITTED, true);
|
||||
}
|
||||
material.setColor("Color", color);
|
||||
} else {
|
||||
timer -= tpf;
|
||||
}
|
||||
material.setColor("Color", color);
|
||||
} else {
|
||||
timer -= tpf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -59,10 +59,10 @@ public class HighscoreManager {
|
||||
scores.add(new Score(songName, optionSettings.getUsername(), score, date));
|
||||
updateScoreFile(optionSettings.getUsername(), score, songName, date);
|
||||
}
|
||||
|
||||
|
||||
public List<Score> getScoresWithSongName(String songName) {
|
||||
List<Score> tempScores = new ArrayList<Score>();
|
||||
|
||||
|
||||
try {
|
||||
ResultSet rs = connector.excecuteQuery(connection, "SELECT * FROM Scores WHERE LOWER(SongName) LIKE LOWER('%" + songName + "%');");
|
||||
while (rs.next()) {
|
||||
@ -70,7 +70,6 @@ public class HighscoreManager {
|
||||
}
|
||||
rs.close();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
sort(tempScores);
|
||||
return tempScores;
|
||||
@ -84,15 +83,13 @@ public class HighscoreManager {
|
||||
}
|
||||
rs.close();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateScoreFile(String name, int score, String songName, Date date) {
|
||||
try {
|
||||
connector.excecuteUpdate(connection, "INSERT INTO Scores(Name,Points,SongName,Date) values('" + name + "'," + score + ", '" + songName + "', '" + DateFormat.getDateTimeInstance().format(date) +"' )");
|
||||
connector.excecuteUpdate(connection, "INSERT INTO Scores(Name,Points,SongName,Date) values('" + name + "'," + score + ", '" + songName + "', '" + DateFormat.getDateTimeInstance().format(date) + "' )");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -23,15 +23,23 @@ package org.wyrez.shootingstars.gui.model;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class Score implements Serializable {
|
||||
public class Score implements Serializable {
|
||||
|
||||
private int score;
|
||||
private String playerName;
|
||||
private String songName;
|
||||
private Date date;
|
||||
|
||||
public Score(String songName, String playerName, int score, Date date) {
|
||||
this.songName = songName;
|
||||
this.score = score;
|
||||
this.playerName = playerName;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public void setSongName(String songName) {
|
||||
this.songName = songName;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayerName(String playerName) {
|
||||
this.playerName = playerName;
|
||||
@ -49,10 +57,10 @@ public class Score implements Serializable {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public String getSongName(){
|
||||
public String getSongName() {
|
||||
return songName;
|
||||
}
|
||||
|
||||
|
||||
public int getScore() {
|
||||
return score;
|
||||
}
|
||||
@ -60,11 +68,4 @@ public class Score implements Serializable {
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public Score(String songName, String playerName, int score, Date date) {
|
||||
this.songName = songName;
|
||||
this.score = score;
|
||||
this.playerName = playerName;
|
||||
this.date = date;
|
||||
}
|
||||
}
|
||||
@ -30,9 +30,9 @@ public class BackgroundMusic extends AudioNode {
|
||||
private boolean isRunning = false;
|
||||
|
||||
public BackgroundMusic(AssetManager assetManager, OptionSettings settings) {
|
||||
super(assetManager, "Sound/menu_loop1.ogg", true);
|
||||
super(assetManager, "Sound/menu_loop1.wav", false);
|
||||
this.settings = settings;
|
||||
//this.setLooping(true); //TODO loop
|
||||
this.setLooping(true);
|
||||
this.setPositional(false);
|
||||
|
||||
update();
|
||||
|
||||
@ -30,25 +30,23 @@ import tonegod.gui.core.Screen;
|
||||
*
|
||||
* @author Snowsun
|
||||
*/
|
||||
public class HighscoreState extends AbstractAppState implements HighscoreListener{
|
||||
public class HighscoreState extends AbstractAppState implements HighscoreListener {
|
||||
|
||||
private StateManager stateManager;
|
||||
private HighscoreManager highscoreManager;
|
||||
private Gui gui;
|
||||
private BackgroundMusic music;
|
||||
|
||||
|
||||
public HighscoreState(Screen screen, StateManager stateManager, HighscoreManager highscoreManager,
|
||||
ScreenHelper screenHelper, BackgroundMusic music) {
|
||||
this.stateManager = stateManager;
|
||||
this.highscoreManager = highscoreManager;
|
||||
this.gui = new HighscoreGUI(screen, this, highscoreManager,screenHelper);
|
||||
this.gui = new HighscoreGUI(screen, this, highscoreManager, screenHelper);
|
||||
this.music = music;
|
||||
}
|
||||
|
||||
|
||||
public void back() {
|
||||
stateManager.setState(State.MENU);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stateAttached(AppStateManager stateManager) {
|
||||
gui.refresh();
|
||||
|
||||
@ -21,10 +21,12 @@ import com.jme3.app.state.AppStateManager;
|
||||
import com.sun.jna.Memory;
|
||||
import java.io.File;
|
||||
import javax.swing.JFileChooser;
|
||||
import org.wyrez.shootingstars.ShootingStars;
|
||||
import org.wyrez.shootingstars.game.GameSettings;
|
||||
import org.wyrez.shootingstars.gui.SelectTrackGUI;
|
||||
import org.wyrez.shootingstars.gui.listener.SelectFileListener;
|
||||
import org.wyrez.shootingstars.helper.ScreenHelper;
|
||||
import org.wyrez.shootingstars.states.util.OptionSettings;
|
||||
import tonegod.gui.core.Screen;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
|
||||
import uk.co.caprica.vlcj.player.direct.BufferFormat;
|
||||
@ -36,42 +38,89 @@ import uk.co.caprica.vlcj.player.direct.RenderCallback;
|
||||
* @author Snowsun
|
||||
*/
|
||||
public class SelectTrackState extends AbstractAppState implements SelectFileListener {
|
||||
|
||||
|
||||
private static final int SLEEP = 1000;
|
||||
/**/
|
||||
private ShootingStars shootingStars;
|
||||
private OptionSettings optionSettings;
|
||||
private StateManager stateManager;
|
||||
private GameSettings settings;
|
||||
private SelectTrackGUI gui;
|
||||
|
||||
public SelectTrackState(Screen screen, StateManager stateManager, GameSettings settings, ScreenHelper screenHelper) {
|
||||
//HACK filechooser is not visible in fullscreen
|
||||
private int selectState = -1;
|
||||
private boolean wasFullscreen;
|
||||
|
||||
public SelectTrackState(Screen screen, StateManager stateManager,
|
||||
GameSettings settings, ScreenHelper screenHelper,
|
||||
OptionSettings optionSettings, ShootingStars shootingStars) {
|
||||
this.shootingStars = shootingStars;
|
||||
this.optionSettings = optionSettings;
|
||||
this.stateManager = stateManager;
|
||||
this.settings = settings;
|
||||
this.gui = new SelectTrackGUI(screen, this, screenHelper);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stateAttached(AppStateManager stateManager) {
|
||||
gui.attach();
|
||||
selectState = -1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stateDetached(AppStateManager stateManager) {
|
||||
gui.detach();
|
||||
selectState = -1;
|
||||
}
|
||||
|
||||
public void selectFile() {
|
||||
JFileChooser jFileChooser = new JFileChooser();
|
||||
int returnVal = jFileChooser.showOpenDialog(null);
|
||||
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = jFileChooser.getSelectedFile();
|
||||
settings.setVideoFile(file.getPath());
|
||||
readMetadata(settings.getVideoFile());
|
||||
|
||||
stateManager.setState(State.FILEMETAINFO);
|
||||
|
||||
@Override
|
||||
public void update(float tpf) {
|
||||
//TODO this is a hell of a workaround...
|
||||
switch (selectState) {
|
||||
case 0:
|
||||
if (wasFullscreen) {
|
||||
optionSettings.setFullscreen(false);
|
||||
shootingStars.setSettings(optionSettings.getAppSettings());
|
||||
shootingStars.restart();
|
||||
}
|
||||
selectState++;
|
||||
break;
|
||||
case 1:
|
||||
JFileChooser jFileChooser = new JFileChooser();
|
||||
int returnVal = jFileChooser.showOpenDialog(null);
|
||||
|
||||
settings.setAudioFile(null);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = jFileChooser.getSelectedFile();
|
||||
settings.setVideoFile(file.getPath());
|
||||
readMetadata(settings.getVideoFile());
|
||||
} else {
|
||||
settings.setVideoFile(null);
|
||||
}
|
||||
selectState++;
|
||||
break;
|
||||
case 2:
|
||||
if (wasFullscreen) {
|
||||
optionSettings.setFullscreen(true);
|
||||
shootingStars.setSettings(optionSettings.getAppSettings());
|
||||
shootingStars.restart();
|
||||
}
|
||||
selectState++;
|
||||
break;
|
||||
case 3:
|
||||
if (settings.getVideoFile() != null) {
|
||||
stateManager.setState(State.FILEMETAINFO);
|
||||
} else {
|
||||
selectState = -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void selectFile() {
|
||||
wasFullscreen = optionSettings.isFullscreenEnabled();
|
||||
selectState = 0;
|
||||
}
|
||||
|
||||
private void readMetadata(String file) {
|
||||
MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory("--no-video-title-show", "--quiet");
|
||||
DirectMediaPlayer mediaPlayer = mediaPlayerFactory.newDirectMediaPlayer(1, 1, new RenderCallback() {
|
||||
@ -89,16 +138,16 @@ public class SelectTrackState extends AbstractAppState implements SelectFileList
|
||||
settings.setTrackTitle(mediaPlayer.getMediaMeta().getTitle());
|
||||
settings.setTrackArtist(mediaPlayer.getMediaMeta().getArtist());
|
||||
settings.setTrackLength(Math.round((float) mediaPlayer.getLength() / 1000f));
|
||||
|
||||
|
||||
mediaPlayer.stop();
|
||||
mediaPlayer.release();
|
||||
mediaPlayerFactory.release();
|
||||
}
|
||||
|
||||
|
||||
public void downloadYT() {
|
||||
stateManager.setState(State.YTDOWNLOAD);
|
||||
}
|
||||
|
||||
|
||||
public void cancel() {
|
||||
stateManager.setState(State.MENU);
|
||||
}
|
||||
|
||||
@ -58,13 +58,16 @@ public class OptionSettings {
|
||||
settings.setResolution(1280, 720);
|
||||
settings.setTitle("Shooting Stars");
|
||||
settings.setSettingsDialogImage("");
|
||||
settings.putBoolean("EnableLogging", false);
|
||||
setMasterVolume(100);
|
||||
setMenuVolume(50);
|
||||
setMenuVolume(25);
|
||||
setMusicVolume(100);
|
||||
setUsername("Nagareboshi");
|
||||
setParticleDensity(3);
|
||||
setDepthBits(24);
|
||||
setShowWeapon(true);
|
||||
setVSync(true);
|
||||
setEnableAudioVisualization(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,4 +212,8 @@ public class OptionSettings {
|
||||
public AppSettings getAppSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public boolean isLogEnabled() {
|
||||
return settings.getBoolean("EnableLogging");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user