merged
This commit is contained in:
commit
4525f632dc
@ -37,7 +37,7 @@ import tonegod.gui.core.Screen;
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class GameGUI extends Panel {
|
||||
public class GameGUI extends Panel implements Gui{
|
||||
|
||||
private GameListener listener;
|
||||
private Button btnStart;
|
||||
@ -185,4 +185,7 @@ public class GameGUI extends Panel {
|
||||
this.player = player;
|
||||
this.addControl(new GuiPlayerPointsControl(player, this));
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ import org.wyrez.shootingstars.gui.model.Score;
|
||||
import org.wyrez.shootingstars.helper.ScreenHelper;
|
||||
import tonegod.gui.controls.buttons.Button;
|
||||
import tonegod.gui.controls.text.Label;
|
||||
import tonegod.gui.controls.text.TextField;
|
||||
import tonegod.gui.controls.windows.Panel;
|
||||
import tonegod.gui.core.Screen;
|
||||
|
||||
@ -38,6 +39,8 @@ public class HighscoreGUI extends Panel implements Gui {
|
||||
private HighscoreListener listener;
|
||||
private HighscoreManager highscoreManager;
|
||||
private ScreenHelper screenHelper;
|
||||
private Panel plnScores;
|
||||
private TextField txtFilter;
|
||||
|
||||
public HighscoreGUI(Screen screen, HighscoreListener listener, HighscoreManager highscoreManager, ScreenHelper screenHelper) {
|
||||
super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f));
|
||||
@ -45,7 +48,8 @@ public class HighscoreGUI extends Panel implements Gui {
|
||||
this.highscoreManager = highscoreManager;
|
||||
this.screenHelper = screenHelper;
|
||||
this.setIgnoreMouse(true);
|
||||
this.setIsVisible(false);
|
||||
this.setIsVisible(false);
|
||||
plnScores = new Panel(screen, new Vector2f(0f, 0f),new Vector2f(0f, 0f));
|
||||
create();
|
||||
}
|
||||
|
||||
@ -64,10 +68,12 @@ public class HighscoreGUI extends Panel implements Gui {
|
||||
float marginScoreNameLeft = screenHelper.calcX(14f);
|
||||
float marginScorePointsLeft = screenHelper.calcX(300f);
|
||||
float marginScoreSongNameLeft = screenHelper.calcX(600f);
|
||||
|
||||
float marginScoreTop = screenHelper.calcY(50f);
|
||||
|
||||
|
||||
float labelFontSize = screenHelper.calcX(20f);
|
||||
|
||||
float buttonHeight = screenHelper.calcY(40f);
|
||||
float buttonWidth = screenHelper.calcX(153f);
|
||||
float buttonFontSize = screenHelper.calcX(20f);
|
||||
|
||||
List<Score> highscores = highscoreManager.getScores();
|
||||
|
||||
@ -83,15 +89,66 @@ public class HighscoreGUI extends Panel implements Gui {
|
||||
lblScoreSongNameHead.setText("Song Name");
|
||||
lblScoreSongNameHead.setFontSize(labelFontSize);
|
||||
|
||||
drawHighscores(highscores);
|
||||
|
||||
Button btnBack = new ButtonBase(screen, new Vector2f(startPointx + screenHelper.calcX(1060f), startPointy + screenHelper.calcY(622.8f)), new Vector2f(buttonWidth, buttonHeight)) {
|
||||
@Override
|
||||
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
||||
listener.back();
|
||||
}
|
||||
};
|
||||
btnBack.setText("Back");
|
||||
btnBack.setFontSize(buttonFontSize);
|
||||
|
||||
txtFilter = new TextField(screen, new Vector2f(screenHelper.calcX(800f), screenHelper.calcY(15f)), new Vector2f(screenHelper.calcX(280f), screenHelper.calcY(40f)));
|
||||
|
||||
Button btnFilter = new ButtonBase(screen, new Vector2f(screenHelper.calcX(1092f), screenHelper.calcY(15f)), new Vector2f(buttonWidth, buttonHeight)) {
|
||||
@Override
|
||||
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
||||
List<Score> scores = highscoreManager.getScoresWithSongName(txtFilter.getText());
|
||||
drawHighscores(scores);
|
||||
}
|
||||
};
|
||||
btnFilter.setText("Filter Song Name");
|
||||
btnFilter.setFontSize(buttonFontSize);
|
||||
|
||||
this.addChild(lblScoreNameHead);
|
||||
this.addChild(lblScorePointsHead);
|
||||
this.addChild(lblScoreSongNameHead);
|
||||
this.addChild(plnScores);
|
||||
this.addChild(txtFilter);
|
||||
this.addChild(btnFilter);
|
||||
this.addChild(btnBack);
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
List<Score> highscores = highscoreManager.getScores();
|
||||
drawHighscores(highscores);
|
||||
}
|
||||
|
||||
private void drawHighscores(List<Score> scores) {
|
||||
plnScores.detachAllChildren();
|
||||
|
||||
float startPointx = screenHelper.calcX(32f);
|
||||
float startPointy = screenHelper.calcY(18f);
|
||||
|
||||
float marginScoreNameLeft = screenHelper.calcX(14f);
|
||||
float marginScorePointsLeft = screenHelper.calcX(300f);
|
||||
float marginScoreSongNameLeft = screenHelper.calcX(600f);
|
||||
|
||||
float marginScoreTop = screenHelper.calcY(50f);
|
||||
|
||||
float labelFontSize = screenHelper.calcX(20f);
|
||||
|
||||
int maxScores = 0;
|
||||
if (highscores.size() > 10) {
|
||||
if (scores.size() > 10) {
|
||||
maxScores = 10;
|
||||
} else {
|
||||
maxScores = highscores.size();
|
||||
maxScores = scores.size();
|
||||
}
|
||||
|
||||
for (int i = 0; i < maxScores; i++) {
|
||||
Score score = highscores.get(i);
|
||||
Score score = scores.get(i);
|
||||
Label lblScoreName = new Label(screen, new Vector2f(startPointx + marginScoreNameLeft, startPointy + marginScoreTop), new Vector2f(screenHelper.calcX(250f), screenHelper.calcY(40f)));
|
||||
lblScoreName.setText(score.getPlayerName());
|
||||
lblScoreName.setFontSize(labelFontSize);
|
||||
@ -101,30 +158,13 @@ public class HighscoreGUI extends Panel implements Gui {
|
||||
lblScorePoints.setFontSize(labelFontSize);
|
||||
|
||||
Label lblScoreSongName = new Label(screen, new Vector2f(startPointx + marginScoreSongNameLeft, startPointy + marginScoreTop), new Vector2f(screenHelper.calcX(600f), screenHelper.calcY(40f)));
|
||||
|
||||
lblScoreSongName.setText(score.getSongName());
|
||||
lblScoreSongName.setFontSize(labelFontSize);
|
||||
|
||||
this.addChild(lblScoreName);
|
||||
this.addChild(lblScorePoints);
|
||||
this.addChild(lblScoreSongName);
|
||||
plnScores.addChild(lblScoreName);
|
||||
plnScores.addChild(lblScorePoints);
|
||||
plnScores.addChild(lblScoreSongName);
|
||||
marginScoreTop += screenHelper.calcY(50f);
|
||||
}
|
||||
|
||||
Button btnBack = new ButtonBase(screen, new Vector2f(startPointx + screenHelper.calcX(1060f), startPointy + screenHelper.calcY(622.8f)), new Vector2f(screenHelper.calcX(153f), screenHelper.calcY(40f))) {
|
||||
@Override
|
||||
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
||||
listener.back();
|
||||
}
|
||||
};
|
||||
btnBack.setText("Back");
|
||||
btnBack.setFontSize(labelFontSize);
|
||||
|
||||
this.addChild(lblScoreNameHead);
|
||||
this.addChild(lblScorePointsHead);
|
||||
this.addChild(lblScoreSongNameHead);
|
||||
this.addChild(btnBack);
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ import tonegod.gui.core.Screen;
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class LoadingGui extends Panel {
|
||||
public class LoadingGui extends Panel implements Gui{
|
||||
|
||||
private Label lblStatus;
|
||||
private Indicator indProgress;
|
||||
@ -78,4 +78,7 @@ public class LoadingGui extends Panel {
|
||||
lblStatus.setText(progress.getText());
|
||||
indProgress.setCurrentValue(progress.getValue());
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,6 @@ import tonegod.gui.controls.lists.Slider;
|
||||
import tonegod.gui.controls.text.Label;
|
||||
import tonegod.gui.controls.text.TextField;
|
||||
import tonegod.gui.controls.windows.Panel;
|
||||
import tonegod.gui.controls.windows.TabControl;
|
||||
import tonegod.gui.core.Screen;
|
||||
|
||||
/**
|
||||
|
||||
@ -44,11 +44,11 @@ public class HighscoreManager {
|
||||
}
|
||||
|
||||
public List<Score> getScores() {
|
||||
sort();
|
||||
sort(scores);
|
||||
return scores;
|
||||
}
|
||||
|
||||
private void sort() {
|
||||
private void sort(List<Score> scores) {
|
||||
Collections.sort(scores, scoreComparator);
|
||||
}
|
||||
|
||||
@ -57,6 +57,22 @@ public class HighscoreManager {
|
||||
scores.add(new Score(songName, optionSettings.getUsername(), score));
|
||||
updateScoreFile(optionSettings.getUsername(), score, songName);
|
||||
}
|
||||
|
||||
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()) {
|
||||
tempScores.add(new Score(rs.getString("SongName"), rs.getString("Name"), rs.getInt("Points")));
|
||||
}
|
||||
rs.close();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
sort(tempScores);
|
||||
return tempScores;
|
||||
}
|
||||
|
||||
private void loadScoreFile() {
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user