Skip to content

Commit

Permalink
Added package system, also added text to buttons.
Browse files Browse the repository at this point in the history
+ Changed name from projectiletest to JWeather. Versioning and master to
be referenced from Reference.class finals.
  • Loading branch information
jacojazz committed Jan 19, 2016
1 parent 417dc67 commit b739210
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ProjectileTest/src/gui/Game.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package gui;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
Expand Down
43 changes: 42 additions & 1 deletion ProjectileTest/src/gui/Menu.java
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -20,6 +27,8 @@ public class Menu {
int mouseRelationX;
int mouseRelationY;

Font titleFont, textFont;

boolean dragging = false;

Point p = new Point(0, 0);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}

Expand Down
1 change: 1 addition & 0 deletions ProjectileTest/src/gui/Particle.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* 3 = rain splash
*
*/
package gui;

import java.awt.AlphaComposite;
import java.awt.Color;
Expand Down
7 changes: 7 additions & 0 deletions ProjectileTest/src/gui/Reference.java
Original file line number Diff line number Diff line change
@@ -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";
}

0 comments on commit b739210

Please sign in to comment.