From b7392102f4587dbf8567de5175890e216f643233 Mon Sep 17 00:00:00 2001 From: JGlass Date: Tue, 19 Jan 2016 11:52:28 +0000 Subject: [PATCH] Added package system, also added text to buttons. + Changed name from projectiletest to JWeather. Versioning and master to be referenced from Reference.class finals. --- ProjectileTest/src/gui/Game.java | 2 ++ ProjectileTest/src/gui/Menu.java | 43 ++++++++++++++++++++++++++- ProjectileTest/src/gui/Particle.java | 1 + ProjectileTest/src/gui/Reference.java | 7 +++++ 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 ProjectileTest/src/gui/Reference.java diff --git a/ProjectileTest/src/gui/Game.java b/ProjectileTest/src/gui/Game.java index d683c45..3725014 100644 --- a/ProjectileTest/src/gui/Game.java +++ b/ProjectileTest/src/gui/Game.java @@ -1,3 +1,5 @@ +package gui; + import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics; diff --git a/ProjectileTest/src/gui/Menu.java b/ProjectileTest/src/gui/Menu.java index 3fa6abc..7041342 100644 --- a/ProjectileTest/src/gui/Menu.java +++ b/ProjectileTest/src/gui/Menu.java @@ -1,8 +1,15 @@ +package gui; + import java.awt.Color; +import java.awt.Font; +import java.awt.FontFormatException; +import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.MouseEvent; +import java.io.File; +import java.io.IOException; public class Menu { @@ -20,6 +27,8 @@ public class Menu { int mouseRelationX; int mouseRelationY; + Font titleFont, textFont; + boolean dragging = false; Point p = new Point(0, 0); @@ -48,7 +57,12 @@ public class Menu { Rectangle exitRect; public Menu() { - + try { + titleFont = Font.createFont(Font.TRUETYPE_FONT, new File("src/gui/fonts/Abel-Regular.ttf")).deriveFont(15f); + textFont = Font.createFont(Font.TRUETYPE_FONT, new File("src/gui/fonts/Abel-Regular.ttf")).deriveFont(15f); + } catch (FontFormatException | IOException e) { + e.printStackTrace(); + } } public void mouseClicked(MouseEvent e) { @@ -151,31 +165,58 @@ public void paint(Graphics2D g2d) { g2d.setColor(Color.GRAY); g2d.fill(moveRect); + FontMetrics fmT = g2d.getFontMetrics(titleFont); + g2d.setFont(titleFont); + g2d.setColor(Color.BLACK); + g2d.drawString(Reference.NAME + " " + Reference.VERSION, moveRect.x + 5, (moveRect.y + (moveRect.height / 2)) + (fmT.getHeight() / 4)); + g2d.setColor(Color.BLACK); g2d.fill(minRect); if (visible) { g2d.setColor(new Color(51, 51, 51, 220)); g2d.fill(manualRect); + + g2d.setColor(Color.GRAY); + g2d.drawString("Manual Mode", manualRect.x + (manualRect.width / 2) - (fmT.stringWidth("Manual Mode") / 2), (manualRect.y + (manualRect.height / 2)) + (fmT.getHeight() / 4)); + g2d.setColor(new Color(51, 51, 51, 220)); g2d.fill(rainPlus); g2d.fill(rainRect); g2d.fill(rainMinus); + + g2d.setColor(Color.GRAY); + g2d.drawString("+", rainPlus.x + (rainPlus.width / 2) - (fmT.stringWidth("+") / 2), (rainPlus.y + (rainPlus.height / 2)) + (fmT.getHeight() / 4)); + g2d.drawString("Rain Toggle", rainRect.x + (rainRect.width / 2) - (fmT.stringWidth("Rain Toggle") / 2), (rainRect.y + (rainRect.height / 2)) + (fmT.getHeight() / 4)); + g2d.drawString("-", rainMinus.x + (rainMinus.width / 2) - (fmT.stringWidth("-") / 2), (rainMinus.y + (rainMinus.height / 2)) + (fmT.getHeight() / 4)); + g2d.setColor(new Color(51, 51, 51, 220)); g2d.fill(snowPlus); g2d.fill(snowRect); g2d.fill(snowMinus); + + g2d.setColor(Color.GRAY); + g2d.drawString("+", snowPlus.x + (snowPlus.width / 2) - (fmT.stringWidth("+") / 2), (snowPlus.y + (snowPlus.height / 2)) + (fmT.getHeight() / 4)); + g2d.drawString("Snow Toggle", snowRect.x + (snowRect.width / 2) - (fmT.stringWidth("Snow Toggle") / 2), (snowRect.y + (snowRect.height / 2)) + (fmT.getHeight() / 4)); + g2d.drawString("-", snowMinus.x + (snowMinus.width / 2) - (fmT.stringWidth("-") / 2), (snowMinus.y + (snowMinus.height / 2)) + (fmT.getHeight() / 4)); g2d.setColor(new Color(51, 51, 51, 220)); g2d.fill(changeAngle); + + g2d.setColor(Color.GRAY); + g2d.drawString("Change Angle", changeAngle.x + (changeAngle.width / 2) - (fmT.stringWidth("Change Angle") / 2), (changeAngle.y + (changeAngle.height / 2)) + (fmT.getHeight() / 4)); g2d.setColor(new Color(51, 51, 51, 220)); g2d.fill(dayNightToggle); + + g2d.setColor(Color.GRAY); g2d.setColor(new Color(0x521616)); g2d.fill(exitRect); + + g2d.setColor(Color.GRAY); } } diff --git a/ProjectileTest/src/gui/Particle.java b/ProjectileTest/src/gui/Particle.java index c5bc533..3aa0903 100644 --- a/ProjectileTest/src/gui/Particle.java +++ b/ProjectileTest/src/gui/Particle.java @@ -6,6 +6,7 @@ * 3 = rain splash * */ +package gui; import java.awt.AlphaComposite; import java.awt.Color; diff --git a/ProjectileTest/src/gui/Reference.java b/ProjectileTest/src/gui/Reference.java new file mode 100644 index 0000000..7b1d4c4 --- /dev/null +++ b/ProjectileTest/src/gui/Reference.java @@ -0,0 +1,7 @@ +package gui; + +public class Reference { + public static final String NAME = "JWeather"; + public static final String VERSION = "1.0.3.0"; + public static final String AUTHOR = "Jacob & David"; +}