Files
HeatUp/HeatUp/src/de/heatup/ui/menu/MenuPanel.java
T

183 lines
4.3 KiB
Java

package de.heatup.ui.menu;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import de.heatup.logging.Logger;
import de.heatup.ui.FontLoader;
import de.heatup.ui.Main;
import de.heatup.ui.PanelBuilder;
public class MenuPanel {
// main menu panel
private static JPanel menuPanel = new JPanel();
// panels for menu buttons
static JPanel start, end, highscore, credits, tutorial;
// sub buttons for functions
static JLabel startGame, endGame, showHighscore, showCredits, showTutorial;
// font settings
private static FontLoader fl = new FontLoader();
private static Font emulogic;
private static Font ttfbase;
public MenuPanel() {
/** not in usage yet */
}
public static void setMenuPanel() {
menuPanel.setPreferredSize(new Dimension(800,600));
menuPanel.setFocusable(false);
GridLayout menuGrid = new GridLayout(5, 1);
menuPanel.setBackground(Color.BLACK);
menuPanel.setLayout(menuGrid);
ttfbase = FontLoader.getFont();
emulogic = ttfbase.deriveFont(Font.PLAIN, 28);
createStart();
createEnd();
createHighscore();
createCredits();
createTutorial();
buildMenuPanel();
}
public static JPanel getMenuPanel() {
menuPanel.setVisible(true);
return menuPanel;
}
/**
* Create a JPanel which contains full function for starting a new Game
*/
private static void createStart() {
start = new JPanel();
start.setBackground(Color.BLACK);
startGame = new JLabel("[ Spiel starten ]");
startGame.setForeground(Color.YELLOW);
startGame.setFont(emulogic);
startGame.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
// @TODO: implement start game
//PanelBuilder.createGame(1);
Logger.write("Game Started via menu");
}
});
start.add(startGame);
}
/**
* Create a JPanel which contains full function for Ending the current game
*/
private static void createEnd() {
end = new JPanel();
end.setBackground(Color.BLACK);
endGame = new JLabel("[ Spiel beenden ]");
endGame.setForeground(Color.YELLOW);
endGame.setFont(emulogic);
endGame.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
// @TODO: implement end game
Logger.write("game ended");
}
});
end.add(endGame);
}
/**
* Create a JPanel which contains full function for showing the Highscores
*/
private static void createHighscore() {
highscore = new JPanel();
highscore.setBackground(Color.BLACK);
showHighscore = new JLabel("[ Highscores anzeigen ]");
showHighscore.setForeground(Color.YELLOW);
showHighscore.setFont(emulogic);
showHighscore.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
// @TODO: implement show highscore
Logger.write("show highscore");
}
});
highscore.add(showHighscore);
}
/**
* Create a JPanel which contains full function for showing the Credits
*/
private static void createCredits() {
credits = new JPanel();
credits.setBackground(Color.BLACK);
showCredits = new JLabel("[ Credits anzeigen ]");
showCredits.setForeground(Color.YELLOW);
showCredits.setFont(emulogic);
showCredits.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
// @TODO: implement show credits
menuPanel.setVisible(false);
Logger.write("show credits");
}
});
credits.add(showCredits);
}
/**
* Create a JPanel which contains full function for showing the Tutorial
*/
private static void createTutorial() {
tutorial = new JPanel();
tutorial.setBackground(Color.BLACK);
showTutorial = new JLabel("[ Tutorial starten ]");
showTutorial.setForeground(Color.YELLOW);
showTutorial.setFont(emulogic);
showTutorial.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
// @TODO: implement show tutorial
Logger.write("show tutorial");
}
});
tutorial.add(showTutorial);
}
/**
* building the MenuPanel from all previous created panels
* */
private static void buildMenuPanel() {
menuPanel.add(start);
menuPanel.add(end);
menuPanel.add(highscore);
menuPanel.add(credits);
menuPanel.add(tutorial);
}
}