mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 09:59:45 +02:00
205 lines
5.7 KiB
Java
205 lines
5.7 KiB
Java
package de.heatup.ui;
|
|
|
|
import java.awt.BorderLayout;
|
|
import java.awt.Color;
|
|
import java.awt.Component;
|
|
import java.awt.FlowLayout;
|
|
import java.awt.Font;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.InputStream;
|
|
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JProgressBar;
|
|
import javax.swing.SwingConstants;
|
|
|
|
import de.heatup.logging.Logger;
|
|
import de.heatup.ui.statusPanel.Score;
|
|
import de.heatup.ui.statusPanel.Timer;
|
|
|
|
|
|
public class StatusPanelAdder{
|
|
private static JPanel panel;
|
|
private static int hgap=30;
|
|
private static int vgap=9;
|
|
private static int modifier=-1;
|
|
private static int temping=0;
|
|
private static int manipulations=0;
|
|
private static double tempPlus=0.0;
|
|
private static double tempMinus=0.0;
|
|
private static double barSpeed=0.01;
|
|
private static boolean ende=false;
|
|
private static JLabel labelTempC= new JLabel("§");
|
|
private static JLabel labelTemp= new JLabel("temperature");
|
|
private static JProgressBar tempBar;
|
|
private static JLabel labelScore= new JLabel("score");
|
|
private static JLabel scoreLabel= new JLabel("new Score Label");
|
|
private static JLabel labelPowerUp = new JLabel("PowerUp");
|
|
private static JLabel powerUpLabel = new JLabel(/*new ImageIcon("path_to_image.png")*/"powerUpLabel");
|
|
private static JLabel labelTime=new JLabel("Time");
|
|
private static JLabel timeLabel = new JLabel("0");
|
|
private static Font emulogicheading;
|
|
private static Font emulogictext;
|
|
private static Font ttfBase;
|
|
private static FontLoader fl=new FontLoader();
|
|
|
|
|
|
|
|
public static void raiseMod(){
|
|
if (modifier==-1){
|
|
modifier=1;
|
|
} else {
|
|
modifier+=1;
|
|
}
|
|
}
|
|
public static void reduceMod(){
|
|
if (modifier==1){
|
|
modifier=-1;
|
|
} else if(modifier==-1){
|
|
} else {
|
|
modifier-=1;
|
|
}
|
|
|
|
}
|
|
public int getScore(){
|
|
return Score.getScore();
|
|
}
|
|
|
|
/**
|
|
* @param newPanel das zu verwendende Panel zur Bearbeitung
|
|
*/
|
|
public static void setPanel(JPanel newPanel){
|
|
newPanel.setLayout(new FlowLayout(FlowLayout.CENTER, hgap,5));
|
|
panel=newPanel;
|
|
}
|
|
public static void addManipulations(){
|
|
manipulations+=1;
|
|
Score.raiseScore(25);
|
|
}
|
|
public static int getManipulations(){
|
|
return manipulations;
|
|
}
|
|
|
|
|
|
public static void tick() {
|
|
Timer.tickTimer();
|
|
timeLabel.setText(Timer.getMinuteS() + ":" + Timer.getSecondsS());
|
|
|
|
/**
|
|
* Temperaturbearbeitung
|
|
*/
|
|
labelTempC.setText(tempBar.getValue() + "°C");
|
|
temping=0;
|
|
if (modifier<0){
|
|
barSpeed=0.01;
|
|
tempMinus+=barSpeed*modifier;
|
|
if (tempMinus<-1){
|
|
temping=-1;
|
|
tempMinus+=1;
|
|
}
|
|
} else if (modifier>0){
|
|
barSpeed=0.02;
|
|
tempPlus+=barSpeed*modifier;
|
|
if (tempPlus>1){
|
|
temping=1;
|
|
tempPlus=-1;
|
|
}
|
|
}
|
|
|
|
if (temping!=0){
|
|
Logger.write("Temperatur: " + tempBar.getValue());
|
|
}
|
|
if (tempBar.getValue()<=30 && modifier==-1) {
|
|
} else {
|
|
tempBar.setValue(tempBar.getValue()+temping);
|
|
}
|
|
if (tempBar.getValue()==110&&(ende=false)){
|
|
Logger.write("EEENNNDDEEEE");
|
|
ende = true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* fügt dem der Klasse übergebenen Panel Objekte hinzu & formatiert diese
|
|
*/
|
|
public static void createPanel(){
|
|
ttfBase=fl.getFont();
|
|
emulogicheading = ttfBase.deriveFont(Font.PLAIN, 16);
|
|
emulogictext= ttfBase.deriveFont(Font.PLAIN, 12);
|
|
|
|
JPanel tempPanel=new JPanel();
|
|
labelTemp.setFont(emulogicheading);
|
|
labelTemp.setForeground(Color.YELLOW);
|
|
labelTemp.setHorizontalAlignment(SwingConstants.CENTER);
|
|
tempBar= new JProgressBar(0,110);
|
|
tempBar.setValue(30);
|
|
labelTempC.setFont(emulogictext);
|
|
labelTempC.setHorizontalAlignment(SwingConstants.CENTER);
|
|
labelTempC.setForeground(Color.YELLOW);
|
|
tempPanel.setLayout(new BorderLayout(0,vgap/2));
|
|
tempPanel.add(labelTemp, BorderLayout.NORTH);
|
|
tempPanel.add(tempBar, BorderLayout.CENTER);
|
|
tempPanel.add(labelTempC, BorderLayout.SOUTH);
|
|
tempPanel.setBackground(Color.BLACK);
|
|
|
|
JPanel scorePanel=new JPanel();
|
|
labelScore.setFont(emulogicheading);
|
|
labelScore.setForeground(Color.YELLOW);
|
|
labelScore.setHorizontalAlignment(SwingConstants.CENTER);
|
|
scoreLabel.setFont(emulogictext);
|
|
scoreLabel.setForeground(Color.YELLOW);
|
|
scoreLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
scorePanel.setLayout(new BorderLayout(0,vgap));
|
|
scorePanel.add(labelScore, BorderLayout.NORTH);
|
|
scorePanel.add(scoreLabel, BorderLayout.SOUTH);
|
|
scorePanel.setBackground(Color.BLACK);
|
|
|
|
JPanel powerUpPanel=new JPanel();
|
|
labelPowerUp.setFont(emulogicheading);
|
|
labelPowerUp.setForeground(Color.YELLOW);
|
|
labelPowerUp.setHorizontalAlignment(SwingConstants.CENTER);
|
|
powerUpLabel.setFont(emulogictext);
|
|
powerUpLabel.setForeground(Color.YELLOW);
|
|
powerUpLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
powerUpPanel.setLayout(new BorderLayout(0,vgap));
|
|
powerUpPanel.add(labelPowerUp, BorderLayout.NORTH);
|
|
powerUpPanel.add(powerUpLabel, BorderLayout.SOUTH);
|
|
powerUpPanel.setBackground(Color.BLACK);
|
|
|
|
JPanel timePanel=new JPanel();
|
|
labelTime.setFont(emulogicheading);
|
|
//labelTime.setSize(100,10);
|
|
labelTime.setHorizontalAlignment(SwingConstants.CENTER);
|
|
labelTime.setForeground(Color.YELLOW);
|
|
timeLabel.setFont(emulogictext);
|
|
timeLabel.setForeground(Color.YELLOW);
|
|
timeLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
timePanel.setLayout(new BorderLayout(0,vgap));
|
|
timePanel.add(labelTime, BorderLayout.NORTH);
|
|
timePanel.add(timeLabel, BorderLayout.SOUTH);
|
|
timePanel.setBackground(Color.BLACK);
|
|
|
|
|
|
|
|
panel.add(timePanel);
|
|
panel.add(scorePanel);
|
|
panel.add(tempPanel);
|
|
panel.add(powerUpPanel);
|
|
panel.setBackground(Color.BLACK);
|
|
panel.setVisible(false);
|
|
panel.setVisible(true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|