Store the used font on the game skin
This commit is contained in:
parent
43f4ca68c6
commit
dd76e119df
5 changed files with 16 additions and 15 deletions
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.Game;
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Preferences;
|
import com.badlogic.gdx.Preferences;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.NinePatch;
|
import com.badlogic.gdx.graphics.g2d.NinePatch;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
|
|
||||||
|
@ -49,6 +50,8 @@ public class Klooni extends Game {
|
||||||
skin.add("web_texture", new Texture(Gdx.files.internal("ui/web.png")));
|
skin.add("web_texture", new Texture(Gdx.files.internal("ui/web.png")));
|
||||||
skin.add("back_texture", new Texture(Gdx.files.internal("ui/back.png")));
|
skin.add("back_texture", new Texture(Gdx.files.internal("ui/back.png")));
|
||||||
|
|
||||||
|
skin.add("font", new BitmapFont(Gdx.files.internal("font/geosans-light.fnt")));
|
||||||
|
|
||||||
// Use only one instance for the theme, so anyone using it uses the most up-to-date
|
// Use only one instance for the theme, so anyone using it uses the most up-to-date
|
||||||
Theme.skin = skin; // Not the best idea
|
Theme.skin = skin; // Not the best idea
|
||||||
theme = Theme.getTheme(prefs.getString("themeName", "default"));
|
theme = Theme.getTheme(prefs.getString("themeName", "default"));
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
package io.github.lonamiwebs.klooni.actors;
|
package io.github.lonamiwebs.klooni.actors;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Pixmap;
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
|
|
||||||
|
import io.github.lonamiwebs.klooni.Klooni;
|
||||||
import io.github.lonamiwebs.klooni.game.GameLayout;
|
import io.github.lonamiwebs.klooni.game.GameLayout;
|
||||||
import io.github.lonamiwebs.klooni.game.Scorer;
|
import io.github.lonamiwebs.klooni.game.Scorer;
|
||||||
|
|
||||||
|
@ -33,7 +32,7 @@ public class Band extends Actor {
|
||||||
|
|
||||||
//region Constructor
|
//region Constructor
|
||||||
|
|
||||||
public Band(final GameLayout layout, final Scorer scorer, final Color bandColor) {
|
public Band(final Klooni game, final GameLayout layout, final Scorer scorer, final Color bandColor) {
|
||||||
this.scorer = scorer;
|
this.scorer = scorer;
|
||||||
|
|
||||||
// A 1x1 pixel map will be enough since the band texture will then be expanded
|
// A 1x1 pixel map will be enough since the band texture will then be expanded
|
||||||
|
@ -43,12 +42,12 @@ public class Band extends Actor {
|
||||||
bandTexture = new Texture(pixmap);
|
bandTexture = new Texture(pixmap);
|
||||||
pixmap.dispose();
|
pixmap.dispose();
|
||||||
|
|
||||||
Label.LabelStyle scoreStyle = new Label.LabelStyle();
|
Label.LabelStyle labelStyle = new Label.LabelStyle();
|
||||||
scoreStyle.font = new BitmapFont(Gdx.files.internal("font/geosans-light.fnt"));
|
labelStyle.font = game.skin.getFont("font");
|
||||||
|
|
||||||
scoreLabel = new Label("", scoreStyle);
|
scoreLabel = new Label("", labelStyle);
|
||||||
scoreLabel.setAlignment(Align.center);
|
scoreLabel.setAlignment(Align.center);
|
||||||
infoLabel = new Label("pause menu", scoreStyle);
|
infoLabel = new Label("pause menu", labelStyle);
|
||||||
infoLabel.setAlignment(Align.center);
|
infoLabel.setAlignment(Align.center);
|
||||||
|
|
||||||
scoreBounds = new Rectangle();
|
scoreBounds = new Rectangle();
|
||||||
|
|
|
@ -3,7 +3,6 @@ package io.github.lonamiwebs.klooni.game;
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.math.Interpolation;
|
import com.badlogic.gdx.math.Interpolation;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
@ -39,21 +38,21 @@ public class Scorer {
|
||||||
//region Constructor
|
//region Constructor
|
||||||
|
|
||||||
// The board size is required when calculating the score
|
// The board size is required when calculating the score
|
||||||
public Scorer(GameLayout layout) {
|
public Scorer(final Klooni game, GameLayout layout) {
|
||||||
currentScore = 0;
|
currentScore = 0;
|
||||||
maxScore = Klooni.getMaxScore();
|
maxScore = Klooni.getMaxScore();
|
||||||
|
|
||||||
cupTexture = new Texture(Gdx.files.internal("ui/cup.png"));
|
cupTexture = new Texture(Gdx.files.internal("ui/cup.png"));
|
||||||
cupArea = new Rectangle();
|
cupArea = new Rectangle();
|
||||||
|
|
||||||
Label.LabelStyle scoreStyle = new Label.LabelStyle();
|
Label.LabelStyle labelStyle = new Label.LabelStyle();
|
||||||
scoreStyle.font = new BitmapFont(Gdx.files.internal("font/geosans-light.fnt"));
|
labelStyle.font = game.skin.getFont("font");
|
||||||
|
|
||||||
currentScoreLabel = new Label("0", scoreStyle);
|
currentScoreLabel = new Label("0", labelStyle);
|
||||||
currentScoreLabel.setColor(Color.GOLD);
|
currentScoreLabel.setColor(Color.GOLD);
|
||||||
currentScoreLabel.setAlignment(Align.right);
|
currentScoreLabel.setAlignment(Align.right);
|
||||||
|
|
||||||
maxScoreLabel = new Label(Integer.toString(maxScore), scoreStyle);
|
maxScoreLabel = new Label(Integer.toString(maxScore), labelStyle);
|
||||||
maxScoreLabel.setColor(new Color(0x65D681FF));
|
maxScoreLabel.setColor(new Color(0x65D681FF));
|
||||||
|
|
||||||
layout.update(this);
|
layout.update(this);
|
||||||
|
|
|
@ -44,7 +44,7 @@ class GameScreen implements Screen, InputProcessor {
|
||||||
batch = new SpriteBatch();
|
batch = new SpriteBatch();
|
||||||
|
|
||||||
final GameLayout layout = new GameLayout();
|
final GameLayout layout = new GameLayout();
|
||||||
scorer = new Scorer(layout);
|
scorer = new Scorer(game, layout);
|
||||||
board = new Board(layout, BOARD_SIZE);
|
board = new Board(layout, BOARD_SIZE);
|
||||||
holder = new PieceHolder(layout, HOLDER_PIECE_COUNT, board.cellSize);
|
holder = new PieceHolder(layout, HOLDER_PIECE_COUNT, board.cellSize);
|
||||||
pauseMenu = new PauseMenuStage(layout, game, scorer);
|
pauseMenu = new PauseMenuStage(layout, game, scorer);
|
||||||
|
|
|
@ -52,7 +52,7 @@ class PauseMenuStage extends Stage {
|
||||||
|
|
||||||
// Current and maximum score band.
|
// Current and maximum score band.
|
||||||
// Do not add it to the table not to over-complicate things.
|
// Do not add it to the table not to over-complicate things.
|
||||||
band = new Band(layout, this.scorer, Color.SKY);
|
band = new Band(game, layout, this.scorer, Color.SKY);
|
||||||
addActor(band);
|
addActor(band);
|
||||||
|
|
||||||
// Home screen button
|
// Home screen button
|
||||||
|
|
Loading…
Reference in a new issue