mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 08:59:44 +02:00
major changes in HighscoreMenu, implemented graphics and beginn for showing scores
This commit is contained in:
@@ -1,5 +1,125 @@
|
||||
package de.heatup.ui.menu;
|
||||
|
||||
public class HighscorePanel {
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridLayout;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import de.heatup.highscore.ScoreEntry;
|
||||
import de.heatup.logging.Logger;
|
||||
import de.heatup.mapengine.MapEngine;
|
||||
import de.heatup.ui.FontLoader;
|
||||
|
||||
public class HighscorePanel {
|
||||
|
||||
// dynamic panels
|
||||
private static JPanel highscorePanel = new JPanel();
|
||||
private static JPanel headingPanel;
|
||||
private static JPanel contentPanel;
|
||||
|
||||
// default text panels and labels
|
||||
private static JLabel headingLabel, dividerLabel;
|
||||
private static GridLayout grid = new GridLayout(2, 1);
|
||||
|
||||
|
||||
// Font Loader and font Settings
|
||||
private static FontLoader fl = new FontLoader();
|
||||
private static Font ttfbase, emulogicHeading, emulogicDivider, emulogicSmall;
|
||||
|
||||
// MapEngine used to get and set the Highscore
|
||||
private static MapEngine me;
|
||||
|
||||
public HighscorePanel() {
|
||||
|
||||
initHighscorePanel();
|
||||
getHighscores();
|
||||
}
|
||||
|
||||
private static void getHighscores() {
|
||||
// default map
|
||||
me = new MapEngine(1);
|
||||
|
||||
// set some default values
|
||||
me.getHighscoreHandler().setHighscore(me.getMapHash(), "Daniel", 3134);
|
||||
me.getHighscoreHandler().setHighscore(me.getMapHash(), "Tim", 2010);
|
||||
me.getHighscoreHandler().saveHighscores();
|
||||
|
||||
for (ScoreEntry score : me.getHighscoreHandler().getHighscores(me.getMapHash())) {
|
||||
Logger.write(score.getName()+" "+score.getScore());
|
||||
}
|
||||
}
|
||||
|
||||
private static void initHighscorePanel() {
|
||||
highscorePanel.setSize(new Dimension(800, 600));
|
||||
highscorePanel.setBackground(Color.BLACK);
|
||||
highscorePanel.setFocusable(false);
|
||||
|
||||
// build full highscorePanel
|
||||
initHeadingPanel();
|
||||
initContentPanel();
|
||||
highscorePanel.add(headingPanel);
|
||||
highscorePanel.add(contentPanel);
|
||||
highscorePanel.setVisible(true);
|
||||
}
|
||||
|
||||
private static void initHeadingPanel() {
|
||||
headingPanel = new JPanel();
|
||||
|
||||
headingPanel.setSize(new Dimension(800, 50));
|
||||
headingPanel.setBackground(Color.BLACK);
|
||||
headingPanel.setFocusable(false);
|
||||
headingPanel.setLayout(grid);
|
||||
headingPanel.setVisible(true);
|
||||
|
||||
ttfbase = FontLoader.getFont();
|
||||
emulogicHeading = ttfbase.deriveFont(Font.PLAIN, 20);
|
||||
emulogicDivider = ttfbase.deriveFont(Font.PLAIN, 10);
|
||||
|
||||
headingLabel = new JLabel();
|
||||
headingLabel.setText("HeatUP! - Highscores");
|
||||
headingLabel.setForeground(Color.YELLOW);
|
||||
headingLabel.setFont(emulogicHeading);
|
||||
|
||||
dividerLabel = new JLabel();
|
||||
dividerLabel.setText("----------------------------------------");
|
||||
dividerLabel.setForeground(Color.YELLOW);
|
||||
dividerLabel.setFont(emulogicDivider);
|
||||
|
||||
headingPanel.add(headingLabel);
|
||||
headingPanel.add(dividerLabel);
|
||||
}
|
||||
|
||||
private static void initContentPanel() {
|
||||
contentPanel = new JPanel();
|
||||
|
||||
contentPanel.setSize(new Dimension(800, 550));
|
||||
contentPanel.setBackground(Color.BLACK);
|
||||
contentPanel.setFocusable(false);
|
||||
contentPanel.setVisible(true);
|
||||
|
||||
// GridLayout for Scores
|
||||
}
|
||||
|
||||
|
||||
public static JPanel getHighscorePanel() {
|
||||
return highscorePanel;
|
||||
}
|
||||
|
||||
|
||||
public static void setHighscorePanel(JPanel highscorePanel) {
|
||||
HighscorePanel.highscorePanel = highscorePanel;
|
||||
}
|
||||
|
||||
|
||||
public static JPanel getContentPanel() {
|
||||
return contentPanel;
|
||||
}
|
||||
|
||||
|
||||
public static void setContentPanel(JPanel contentPanel) {
|
||||
HighscorePanel.contentPanel = contentPanel;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user