Add missing colors to the themes

This commit is contained in:
Lonami Exo 2017-01-31 11:02:39 +01:00
parent 6fde0e7b00
commit 9d74c813e5
6 changed files with 34 additions and 13 deletions

View file

@ -9,11 +9,14 @@
"c23a20ff",
"956fd6ff"
],
"empty_cell": "292929ff",
"cells": [
"7931bfff", "4c87aeff", "3aa853ff",
"1e984dff", "2e749bff", "db5500ff", "d88109ff",
"d9294dff", "ac342bff"
]
],
"current_score": "c83737ff",
"high_score": "d400aaff"
},
"cell_texture": "basic.png"
}

View file

@ -9,11 +9,14 @@
"2389fcff",
"d94848ff"
],
"empty_cell": "ffffffff",
"cells": [
"7988bfff", "98dc53ff", "4cd4aeff",
"fec63dff", "ec9548ff", "e66a82ff", "da6554ff",
"57cb84ff", "5abee2ff"
]
],
"current_score": "ffcc00ff",
"high_score": "65d681ff"
},
"cell_texture": "basic.png"
}

View file

@ -20,7 +20,13 @@ public class Theme {
private String displayName;
private String name;
private int price;
public Color background;
public Color emptyCell;
public Color currentScore;
public Color highScore;
private Color[] cells;
private Color[] buttons;
@ -99,6 +105,11 @@ public class Theme {
buttonStyles[i].down = skin.newDrawable("button_down", buttons[i]);
}
currentScore = new Color((int)Long.parseLong(colors.getString("current_score"), 16));
highScore = new Color((int)Long.parseLong(colors.getString("high_score"), 16));
emptyCell = new Color((int)Long.parseLong(colors.getString("empty_cell"), 16));
JsonValue cellColors = colors.get("cells");
cells = new Color[cellColors.size];
for (int i = 0; i < cells.length; i++) {

View file

@ -35,7 +35,6 @@ public class Cell {
size = cellSize;
empty = true;
color = Color.WHITE;
vanishElapsed = Float.POSITIVE_INFINITY;
}
@ -50,7 +49,8 @@ public class Cell {
}
void draw(SpriteBatch batch) {
draw(color, batch, pos.x, pos.y, size);
// Always query the color to the theme, because it might have changed
draw(empty ? Klooni.theme.emptyCell : color, batch, pos.x, pos.y, size);
// Draw the previous vanishing cell
if (vanishElapsed <= vanishLifetime) {
@ -89,8 +89,6 @@ public class Cell {
// Negative time = delay, + 0.4*lifetime because elastic interpolation has that delay
vanishElapsed = vanishLifetime * 0.4f - vanishDist;
color = Color.WHITE;
}
boolean isEmpty() {

View file

@ -70,7 +70,7 @@ public class GameLayout {
area.x, area.y,
area.width * 0.5f - cupSize * 0.5f, area.height);
scorer.maxScoreLabel.setBounds(
scorer.highScoreLabel.setBounds(
area.x + area.width * 0.5f + cupSize * 0.5f, area.y,
area.width * 0.5f - cupSize * 0.5f, area.height);
}

View file

@ -22,11 +22,13 @@ public class Scorer {
private int currentScore, maxScore;
final Label currentScoreLabel;
final Label maxScoreLabel;
final Label highScoreLabel;
final Texture cupTexture;
final Rectangle cupArea;
private final Color cupColor;
// If the currentScore beat the maxScore, then we have a new record
private boolean newRecord;
@ -43,17 +45,18 @@ public class Scorer {
maxScore = Klooni.getMaxScore();
cupTexture = new Texture(Gdx.files.internal("ui/cup.png"));
cupColor = Klooni.theme.currentScore.cpy();
cupArea = new Rectangle();
Label.LabelStyle labelStyle = new Label.LabelStyle();
labelStyle.font = game.skin.getFont("font");
currentScoreLabel = new Label("0", labelStyle);
currentScoreLabel.setColor(Color.GOLD);
currentScoreLabel.setColor(Klooni.theme.currentScore);
currentScoreLabel.setAlignment(Align.right);
maxScoreLabel = new Label(Integer.toString(maxScore), labelStyle);
maxScoreLabel.setColor(new Color(0x65D681FF));
highScoreLabel = new Label(Integer.toString(maxScore), labelStyle);
highScoreLabel.setColor(Klooni.theme.highScore);
layout.update(this);
}
@ -108,10 +111,13 @@ public class Scorer {
currentScoreLabel.setText(Integer.toString(MathUtils.round(shownScore)));
}
batch.setColor(Color.GOLD);
// If we beat a new record, the cup color will linear interpolate to the high score color
cupColor.lerp(newRecord ? Klooni.theme.highScore : Klooni.theme.currentScore, 0.05f);
batch.setColor(cupColor);
batch.draw(cupTexture, cupArea.x, cupArea.y, cupArea.width, cupArea.height);
currentScoreLabel.draw(batch, 1f);
maxScoreLabel.draw(batch, 1f);
highScoreLabel.draw(batch, 1f);
}
//endregion