added new font
This commit is contained in:
@@ -6,14 +6,16 @@ import de.miaurizius.jgame2d.entity.item.HeartObj;
|
|||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class UI {
|
public class UI {
|
||||||
|
|
||||||
GamePanel panel;
|
GamePanel panel;
|
||||||
Graphics2D graphics2d;
|
Graphics2D graphics2d;
|
||||||
Font arial_40, arial_80B; //TODO: Custom font loader: https://www.youtube.com/watch?v=g-wrebFVP3E
|
Font font;
|
||||||
BufferedImage heart_full, heart_half, heart_blank;
|
BufferedImage heart_full, heart_half, heart_blank;
|
||||||
ArrayList<String> messages = new ArrayList<>();
|
ArrayList<String> messages = new ArrayList<>();
|
||||||
ArrayList<Integer> messageCounter = new ArrayList<>();
|
ArrayList<Integer> messageCounter = new ArrayList<>();
|
||||||
@@ -23,8 +25,12 @@ public class UI {
|
|||||||
|
|
||||||
public UI(GamePanel panel) {
|
public UI(GamePanel panel) {
|
||||||
this.panel = panel;
|
this.panel = panel;
|
||||||
arial_40 = new Font("Arial", Font.PLAIN, 40);
|
font = new Font("Arial", Font.PLAIN, 40);
|
||||||
arial_80B = new Font("Arial", Font.BOLD, 80);
|
try {
|
||||||
|
font = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream("assets/font/x12y16pxMaruMonica.ttf"));
|
||||||
|
} catch (FontFormatException | IOException e) {
|
||||||
|
Boot.logger.log(Level.WARNING, "Could not load maruMonica.ttf", e);
|
||||||
|
}
|
||||||
|
|
||||||
// CREATE HUD OBJECT
|
// CREATE HUD OBJECT
|
||||||
Entity heart = new HeartObj(panel);
|
Entity heart = new HeartObj(panel);
|
||||||
@@ -35,7 +41,7 @@ public class UI {
|
|||||||
|
|
||||||
public void draw(Graphics2D graphics2d) {
|
public void draw(Graphics2D graphics2d) {
|
||||||
this.graphics2d = graphics2d;
|
this.graphics2d = graphics2d;
|
||||||
graphics2d.setFont(arial_40);
|
graphics2d.setFont(font);
|
||||||
graphics2d.setColor(Color.white);
|
graphics2d.setColor(Color.white);
|
||||||
|
|
||||||
if(panel.gameState == null) return;
|
if(panel.gameState == null) return;
|
||||||
@@ -115,7 +121,7 @@ public class UI {
|
|||||||
|
|
||||||
// TEXT
|
// TEXT
|
||||||
graphics2d.setColor(Color.white);
|
graphics2d.setColor(Color.white);
|
||||||
graphics2d.setFont(graphics2d.getFont().deriveFont(22F));
|
graphics2d.setFont(graphics2d.getFont().deriveFont(28F));
|
||||||
|
|
||||||
int textX = frameX + 20;
|
int textX = frameX + 20;
|
||||||
int textY = frameY + panel.tileSize;
|
int textY = frameY + panel.tileSize;
|
||||||
@@ -188,8 +194,10 @@ public class UI {
|
|||||||
graphics2d.drawRoundRect(curserX, curserY, curserWidth, curserHeight, 10, 10);
|
graphics2d.drawRoundRect(curserX, curserY, curserWidth, curserHeight, 10, 10);
|
||||||
|
|
||||||
// DESCRIPTION FRAME
|
// DESCRIPTION FRAME
|
||||||
|
int itemIndex = getItemIndex();
|
||||||
|
if(panel.player.inventory.size()-1 < itemIndex || panel.player.inventory.get(itemIndex).description == null) return;
|
||||||
int dFrameX = frameX;
|
int dFrameX = frameX;
|
||||||
int dFrameY = frameY + frameHeight;
|
int dFrameY = frameY + frameHeight+2;
|
||||||
int dFrameWidth = frameWidth;
|
int dFrameWidth = frameWidth;
|
||||||
int dFrameHeight = panel.tileSize*3;
|
int dFrameHeight = panel.tileSize*3;
|
||||||
drawSubWindow(dFrameX, dFrameY, dFrameWidth, dFrameHeight);
|
drawSubWindow(dFrameX, dFrameY, dFrameWidth, dFrameHeight);
|
||||||
@@ -197,8 +205,7 @@ public class UI {
|
|||||||
// DRAW DESCRIPTION
|
// DRAW DESCRIPTION
|
||||||
int textX = dFrameX + 20;
|
int textX = dFrameX + 20;
|
||||||
int textY = dFrameY + panel.tileSize;
|
int textY = dFrameY + panel.tileSize;
|
||||||
graphics2d.setFont(graphics2d.getFont().deriveFont(23F));
|
graphics2d.setFont(graphics2d.getFont().deriveFont(28F));
|
||||||
int itemIndex = getItemIndex();
|
|
||||||
if(itemIndex < panel.player.inventory.size())
|
if(itemIndex < panel.player.inventory.size())
|
||||||
for(String line : panel.player.inventory.get(itemIndex).description.split("\n")) {
|
for(String line : panel.player.inventory.get(itemIndex).description.split("\n")) {
|
||||||
graphics2d.drawString(line, textX, textY);
|
graphics2d.drawString(line, textX, textY);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class ShieldWoodObj extends Entity {
|
|||||||
public ShieldWoodObj(GamePanel panel) {
|
public ShieldWoodObj(GamePanel panel) {
|
||||||
super(panel);
|
super(panel);
|
||||||
name = "Wooden Shield";
|
name = "Wooden Shield";
|
||||||
description = "[" + name + "]\nAn old shield.\nIt's not that strong but\nit does its job.";
|
description = "[" + name + "]\nAn old shield. It's not\nthat strong but its okay.";
|
||||||
type = EntityType.ITEM;
|
type = EntityType.ITEM;
|
||||||
down1 = initEntitySprites("objects/shield_wood");
|
down1 = initEntitySprites("objects/shield_wood");
|
||||||
defenseValue = 1;
|
defenseValue = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user