diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryCrewSlotUI.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryCrewSlotUI.java index e2f8b96152e1f9aef081ac7ecffe7e688ef0b5cc..d37acddec84fde9af426114f4aa91fde27aa06f4 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryCrewSlotUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryCrewSlotUI.java @@ -2,14 +2,12 @@ package com.galaxytrucker.galaxytruckerreloaded.View.UI.Inventory; import com.badlogic.gdx.graphics.Texture; -import java.util.LinkedList; import java.util.List; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.galaxytrucker.galaxytruckerreloaded.Main; import com.galaxytrucker.galaxytruckerreloaded.Model.Crew.Crew; -import sun.jvm.hotspot.gc.shared.G1YCType; /** * to represent a crew member in the inventory @@ -60,8 +58,8 @@ public class InventoryCrewSlotUI extends InventorySlotUI { * * @param main - main class */ - public InventoryCrewSlotUI(Main main, Crew crew, float x, float y) { - super(main, x, y); + public InventoryCrewSlotUI(Main main, Crew crew, float x, float y, BitmapFont font) { + super(main, x, y, font); glyphName.setText(font, crew.getName()); List<Integer> stats = crew.getStats(); diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryIntSlotUI.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryIntSlotUI.java index b51c857642a3b3c73ef02f08b04d5b51c8e1041b..51634067637de66e42dc3c0239fb8e2fe28b6561 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryIntSlotUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryIntSlotUI.java @@ -17,8 +17,8 @@ public class InventoryIntSlotUI extends InventorySlotUI { * * @param main - main class */ - public InventoryIntSlotUI(Main main, int value, float x, float y, String text) { - super(main, x, y); + public InventoryIntSlotUI(Main main, int value, float x, float y, String text, BitmapFont font) { + super(main, x, y, font); glyphLayout.setText(font, text + ": " + value); } @@ -29,7 +29,6 @@ public class InventoryIntSlotUI extends InventorySlotUI { @Override public void disposeInventorySlotUI() { super.disposeInventorySlotUI(); - font.dispose(); } /** diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventorySlotUI.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventorySlotUI.java index 79e5e35364fd5ca7ae8f06aa1e9688f10001df3f..c92c374578411c6f1dd4db5b04b996f5defb5584 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventorySlotUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventorySlotUI.java @@ -30,22 +30,9 @@ public abstract class InventorySlotUI { * * @param main - main class */ - public InventorySlotUI(Main main, float x, float y) { + public InventorySlotUI(Main main, float x, float y, BitmapFont font) { this.main = main; - - //font generator to get bitmapfont from .ttf file - FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.local("fonts/JustinFont11Bold.ttf")); - FreeTypeFontGenerator.FreeTypeFontParameter params = new FreeTypeFontGenerator.FreeTypeFontParameter(); - //setting parameters of font - params.borderWidth = 1; - params.borderColor = Color.BLACK; - params.characters = FreeTypeFontGenerator.DEFAULT_CHARS; - params.magFilter = Texture.TextureFilter.Nearest; - params.minFilter = Texture.TextureFilter.Nearest; - params.genMipMaps = true; - params.size = 15; - - font = generator.generateFont(params); + this.font = font; posX = x; posY = y; diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryUI.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryUI.java index ee09eebddfc173373c51987776c654e7797be8f6..e2a6cbe28bbbaf049119c68c6c5a295369144ea5 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryUI.java @@ -2,6 +2,7 @@ package com.galaxytrucker.galaxytruckerreloaded.View.UI.Inventory; import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.scenes.scene2d.Stage; import java.util.LinkedList; @@ -44,7 +45,7 @@ public class InventoryUI { * @param crew the crew members * @param weapons the weapons */ - public InventoryUI(Main main, List<Crew> crew, List<Weapon> weapons, int fuel, int missiles, Stage stage, ShipView shipView) { + public InventoryUI(Main main, List<Crew> crew, List<Weapon> weapons, int fuel, int missiles, Stage stage, ShipView shipView, BitmapFont font) { this.main = main; this.stage = stage; this.shipView = shipView; @@ -61,17 +62,17 @@ public class InventoryUI { float cx = x + 25; float cy = y + 560; for(Crew c : crew) { - slots.add(new InventoryCrewSlotUI(main, c, cx, cy)); + slots.add(new InventoryCrewSlotUI(main, c, cx, cy, font)); cy -= 80; } float wy = y + 525; float wx = cx + 400; for(Weapon w : weapons) { - slots.add(new InventoryWeaponSlotUI(main, w, wx, wy)); + slots.add(new InventoryWeaponSlotUI(main, w, wx, wy, font)); wy -=100; } - slots.add(new InventoryIntSlotUI(main, fuel, x+50, y+50, "fuel")); - slots.add(new InventoryIntSlotUI(main, missiles, x+150, y+50, "missiles")); + slots.add(new InventoryIntSlotUI(main, fuel, x+50, y+50, "fuel", font)); + slots.add(new InventoryIntSlotUI(main, missiles, x+150, y+50, "missiles", font)); } /** diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryWeaponSlotUI.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryWeaponSlotUI.java index a82c52a8363e0368ec36c65fe96ec9fe89bbf398..c817bb766c7ba52bed6a162e1525e7221948092a 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryWeaponSlotUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Inventory/InventoryWeaponSlotUI.java @@ -27,8 +27,8 @@ public class InventoryWeaponSlotUI extends InventorySlotUI { * @param main the main class * @param weapon the weapon to be displayed */ - public InventoryWeaponSlotUI(Main main, Weapon weapon, float x, float y) { - super(main, x, y); + public InventoryWeaponSlotUI(Main main, Weapon weapon, float x, float y, BitmapFont font) { + super(main, x, y, font); glyphDamage.setText(font, "Damage: "+weapon.getDamage()); glyphCooldown.setText(font, "Cooldown: "+weapon.getCooldown()); glyphMissile.setText(font, "Missile Cost: "+weapon.getMissileCost()); diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Ship/ShipView.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Ship/ShipView.java index f6eabf594ca164d5d193d2b1a70c7d0deb1589e4..a6a4da97dbb43086439ccaae725a16e704ba3ea6 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Ship/ShipView.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Ship/ShipView.java @@ -1,6 +1,10 @@ package com.galaxytrucker.galaxytruckerreloaded.View.UI.Ship; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; import com.badlogic.gdx.scenes.scene2d.Stage; import com.galaxytrucker.galaxytruckerreloaded.Main; import com.galaxytrucker.galaxytruckerreloaded.Model.Crew.Crew; @@ -94,6 +98,8 @@ public class ShipView extends AbstractShip { private float width, height; private float roomWidth, roomHeight; + private BitmapFont font15; + /** * Constructor * @param main - the main class for SpriteBatch @@ -101,6 +107,20 @@ public class ShipView extends AbstractShip { public ShipView(Main main, Ship ship, Stage stage, Overworld map, GamePlay game) { super(main, ship, stage, game); + //font generator to get bitmapfont from .ttf file + FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.local("fonts/JustinFont11Bold.ttf")); + FreeTypeFontGenerator.FreeTypeFontParameter params = new FreeTypeFontGenerator.FreeTypeFontParameter(); + //setting parameters of font + params.borderWidth = 1; + params.borderColor = Color.BLACK; + params.characters = FreeTypeFontGenerator.DEFAULT_CHARS; + params.magFilter = Texture.TextureFilter.Nearest; + params.minFilter = Texture.TextureFilter.Nearest; + params.genMipMaps = true; + params.size = 15; + + font15 = generator.generateFont(params); + List<Crew> crews = new ArrayList<>(); for(Room r : ship.getSystems()) { crews.addAll(r.getCrew()); @@ -108,7 +128,7 @@ public class ShipView extends AbstractShip { crew = new HashMap<>(); float cy = main.HEIGHT - 150; for(Crew c : crews) { - crew.put(c.getId(), new CrewUI(main, c, stage, ship, this, 30, cy)); + crew.put(c.getId(), new CrewUI(main, c, stage, ship, this, 30, cy, font15)); cy -= 60; } @@ -297,6 +317,7 @@ public class ShipView extends AbstractShip { for(CrewUI c : crew.values()) { c.disposeCrewUI(); } + font15.dispose(); } /** @@ -325,7 +346,7 @@ public class ShipView extends AbstractShip { */ public void openInventory() { if(inventoryUI == null){ - inventoryUI = new InventoryUI(main, game.loadCrew(), game.loadWeapons(), game.loadFuel(), game.loadMissiles(), stage, this); + inventoryUI = new InventoryUI(main, game.loadCrew(), game.loadWeapons(), game.loadFuel(), game.loadMissiles(), stage, this, font15); } } diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/ShipInformation/CrewUI.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/ShipInformation/CrewUI.java index bbe7d72b6806e3a7d794048fb5f5b5ae428b0bb6..3fee3b6e7bb3d1c5170e55ba2265632533050ccd 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/ShipInformation/CrewUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/ShipInformation/CrewUI.java @@ -96,26 +96,14 @@ public class CrewUI { * @param main the main class * @param crew the crew member */ - public CrewUI(Main main, Crew crew, Stage stage, Ship ship, ShipView shipView, float x, float y) { + public CrewUI(Main main, Crew crew, Stage stage, Ship ship, ShipView shipView, float x, float y, BitmapFont font) { this.main = main; this.crew = crew; this.shipView = shipView; this.x = x; this.y = y; + this.font = font; - //font generator to get bitmapfont from .ttf file - FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.local("fonts/JustinFont11Bold.ttf")); - FreeTypeFontGenerator.FreeTypeFontParameter params = new FreeTypeFontGenerator.FreeTypeFontParameter(); - //setting parameters of font - params.borderWidth = 1; - params.borderColor = Color.BLACK; - params.characters = FreeTypeFontGenerator.DEFAULT_CHARS; - params.magFilter = Texture.TextureFilter.Nearest; - params.minFilter = Texture.TextureFilter.Nearest; - params.genMipMaps = true; - params.size = 15; - - font = generator.generateFont(params); glyph.setText(font, crew.getName()); if(crew.getName().equals("ana")) { diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/ShipInformation/ScrapUI.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/ShipInformation/ScrapUI.java index 3e0d6590c3383f7a54a64841bd8e437ed5a82d29..05f8a76c5fabd8dc35375dd1fd015f350f76f4eb 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/ShipInformation/ScrapUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/ShipInformation/ScrapUI.java @@ -1,7 +1,12 @@ package com.galaxytrucker.galaxytruckerreloaded.View.UI.ShipInformation; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.GlyphLayout; +import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; import com.galaxytrucker.galaxytruckerreloaded.Main; public class ScrapUI { @@ -14,13 +19,17 @@ public class ScrapUI { /** * the amount of money */ - private int amount; + private int amount = 0; /** * the main class with the sprite batch */ private Main main; + private BitmapFont font; + + private GlyphLayout glyph = new GlyphLayout(); + /** * Constructor * @@ -29,9 +38,25 @@ public class ScrapUI { */ public ScrapUI(Main main, int money) { this.main = main; - amount = money; + this.amount = money; scrapBackground = new Texture("gameuis/top_scrap.png"); + + //font generator to get bitmapfont from .ttf file + FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.local("fonts/JustinFont11Bold.ttf")); + FreeTypeFontGenerator.FreeTypeFontParameter params = new FreeTypeFontGenerator.FreeTypeFontParameter(); + //setting parameters of font + params.borderWidth = 1; + params.borderColor = Color.BLACK; + params.characters = FreeTypeFontGenerator.DEFAULT_CHARS; + params.magFilter = Texture.TextureFilter.Nearest; + params.minFilter = Texture.TextureFilter.Nearest; + params.genMipMaps = true; + params.size = 25; + + font = generator.generateFont(params); + + glyph.setText(font, Integer.toString(amount)); } /** @@ -40,7 +65,8 @@ public class ScrapUI { */ public void render() { main.batch.begin(); - main.batch.draw(scrapBackground, 600, main.HEIGHT - 90, 147, 60); + main.batch.draw(scrapBackground, 600, Main.HEIGHT - 90, 147, 60); + font.draw(main.batch, glyph, 600 + (147f/2) - glyph.width/2, (Main.HEIGHT - 40) - glyph.height/2); main.batch.end(); } @@ -67,6 +93,7 @@ public class ScrapUI { */ public void disposeScrapUI() { scrapBackground.dispose(); + font.dispose(); } /** @@ -75,5 +102,6 @@ public class ScrapUI { */ public void changeAmount(int amount) { this.amount += amount; + glyph.setText(font, Integer.toString(this.amount)); } } diff --git a/database.mv.db b/database.mv.db index bf06dadd61d71c6ec7a71fa2f6686a4096a679e1..982aa38872a423ec994a4705c17b56540fec7336 100644 Binary files a/database.mv.db and b/database.mv.db differ