mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added new improvements
This commit is contained in:
parent
ace943aa3b
commit
b32595d58f
@ -13,7 +13,7 @@ import java.text.DecimalFormat;
|
|||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
|
||||||
public class Battery extends Widget {
|
public class Battery extends Widget {
|
||||||
|
public static boolean wavesOff = false;
|
||||||
public static final Color LOW = new Color(253, 130, 130);
|
public static final Color LOW = new Color(253, 130, 130);
|
||||||
public static final Color MEDIUM = new Color(255, 204, 153);
|
public static final Color MEDIUM = new Color(255, 204, 153);
|
||||||
public static final Color HIGH = new Color(204, 255, 204);
|
public static final Color HIGH = new Color(204, 255, 204);
|
||||||
@ -70,7 +70,7 @@ public class Battery extends Widget {
|
|||||||
double surfacePower = 1;//donePercent < 0.5 ? 0.5 : donePercent;// (donePercent * 100 - ((int)(donePercent * 100)));
|
double surfacePower = 1;//donePercent < 0.5 ? 0.5 : donePercent;// (donePercent * 100 - ((int)(donePercent * 100)));
|
||||||
int waterSurfaceHeight = (int) (4 * surfacePower);//2 + (int) (Math.random() * 3);
|
int waterSurfaceHeight = (int) (4 * surfacePower);//2 + (int) (Math.random() * 3);
|
||||||
if(waterSurfaceHeight <= 2 || !TimeCalcConf.getInstance()
|
if(waterSurfaceHeight <= 2 || !TimeCalcConf.getInstance()
|
||||||
.areBatteryWavesEnabled()) {
|
.areBatteryWavesEnabled() || wavesOff) {
|
||||||
waterSurfaceHeight = 0;
|
waterSurfaceHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,9 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
|
public static long startNanoTime;
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
|
startNanoTime = System.nanoTime();
|
||||||
while (true) {
|
while (true) {
|
||||||
boolean test = new File("test.txt").exists();
|
boolean test = new File("test.txt").exists();
|
||||||
File starttimeTxt = new File("starttime.txt");
|
File starttimeTxt = new File("starttime.txt");
|
||||||
|
@ -4,6 +4,7 @@ import javax.imageio.ImageIO;
|
|||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JTextPane;
|
import javax.swing.JTextPane;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
@ -82,12 +83,14 @@ public class TimeCalcWindow {
|
|||||||
|
|
||||||
JFrame window = new JFrame();
|
JFrame window = new JFrame();
|
||||||
|
|
||||||
|
JButton commandButton = new JButton("Command");
|
||||||
JButton weatherButton = new JButton("Weather");
|
JButton weatherButton = new JButton("Weather");
|
||||||
JButton jokeButton = new JButton("Joke");
|
JButton jokeButton = new JButton("Joke");
|
||||||
JButton restartButton = new JButton("Restart");
|
JButton restartButton = new JButton("Restart");
|
||||||
JButton exitButton = new JButton("Exit");
|
JButton exitButton = new JButton("Exit");
|
||||||
|
|
||||||
//window.add(weatherButton);
|
//window.add(weatherButton);
|
||||||
|
window.add(commandButton);
|
||||||
|
|
||||||
window.add(jokeButton);
|
window.add(jokeButton);
|
||||||
window.add(restartButton);
|
window.add(restartButton);
|
||||||
@ -113,6 +116,9 @@ public class TimeCalcWindow {
|
|||||||
if(e.getKeyCode() == KeyEvent.VK_V){
|
if(e.getKeyCode() == KeyEvent.VK_V){
|
||||||
everythingHidden = !everythingHidden;
|
everythingHidden = !everythingHidden;
|
||||||
}
|
}
|
||||||
|
if(e.getKeyCode() == KeyEvent.VK_R){
|
||||||
|
commandButton.doClick();
|
||||||
|
}
|
||||||
|
|
||||||
window.repaint();
|
window.repaint();
|
||||||
}
|
}
|
||||||
@ -155,6 +161,7 @@ public class TimeCalcWindow {
|
|||||||
window.add(text);
|
window.add(text);
|
||||||
weatherButton
|
weatherButton
|
||||||
.setBounds(20, text.getY() + text.getHeight() + 10, 100, 30);
|
.setBounds(20, text.getY() + text.getHeight() + 10, 100, 30);
|
||||||
|
commandButton.setBounds(20, text.getY() + text.getHeight() + 10, 100, 30);
|
||||||
jokeButton.setBounds(140, text.getY() + text.getHeight() + 10, 100, 30);
|
jokeButton.setBounds(140, text.getY() + text.getHeight() + 10, 100, 30);
|
||||||
restartButton
|
restartButton
|
||||||
.setBounds(280, text.getY() + text.getHeight() + 10, 100, 30);
|
.setBounds(280, text.getY() + text.getHeight() + 10, 100, 30);
|
||||||
@ -174,6 +181,31 @@ public class TimeCalcWindow {
|
|||||||
});
|
});
|
||||||
weatherButton
|
weatherButton
|
||||||
.addActionListener(e -> new WeatherWindow().setVisible(true));
|
.addActionListener(e -> new WeatherWindow().setVisible(true));
|
||||||
|
commandButton
|
||||||
|
.addActionListener(e ->
|
||||||
|
{
|
||||||
|
String commands = (String) JOptionPane.showInputDialog(
|
||||||
|
null,
|
||||||
|
"Run a command:",
|
||||||
|
"Command launching",
|
||||||
|
JOptionPane.PLAIN_MESSAGE,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
"test"
|
||||||
|
);
|
||||||
|
String[] commandsAsArray = commands.split(" ");
|
||||||
|
switch(commandsAsArray[0]) {
|
||||||
|
case "test": JOptionPane.showMessageDialog(null, "Test");break;
|
||||||
|
case "color": Utils.highlighted.set(commandsAsArray[1].equals("1"));break;
|
||||||
|
case "gray": Utils.ultraLight.set(commandsAsArray[1].equals("1"));break;
|
||||||
|
case "waves": Battery.wavesOff = commandsAsArray[1].equals("0");break;
|
||||||
|
case "uptime": JOptionPane.showMessageDialog(null, ((int)((System.nanoTime() -Main.startNanoTime)) / 1000000000 / 60) + " minutes");break;
|
||||||
|
default: JOptionPane.showMessageDialog(null, "Unknown command: " + commandsAsArray[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jokeButton.addActionListener(e -> {
|
jokeButton.addActionListener(e -> {
|
||||||
for (int i = 1; i <= 1; i++) {
|
for (int i = 1; i <= 1; i++) {
|
||||||
Jokes.showRandom();
|
Jokes.showRandom();
|
||||||
@ -261,6 +293,7 @@ public class TimeCalcWindow {
|
|||||||
batteryForWeek.setVisible(!everythingHidden);
|
batteryForWeek.setVisible(!everythingHidden);
|
||||||
batteryForMonth.setVisible(!everythingHidden);
|
batteryForMonth.setVisible(!everythingHidden);
|
||||||
jokeButton.setVisible(!TimeCalcConf.getInstance().isJokeVisible()? false : !everythingHidden);
|
jokeButton.setVisible(!TimeCalcConf.getInstance().isJokeVisible()? false : !everythingHidden);
|
||||||
|
commandButton.setVisible(!everythingHidden);
|
||||||
restartButton.setVisible(!everythingHidden);
|
restartButton.setVisible(!everythingHidden);
|
||||||
exitButton.setVisible(!everythingHidden);
|
exitButton.setVisible(!everythingHidden);
|
||||||
window.setTitle(everythingHidden ? "" : "Time Calc");
|
window.setTitle(everythingHidden ? "" : "Time Calc");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user