Merge branch 'master' of https://github.com/LonamiWebs/Klooni1010
# Conflicts: # core/src/io/github/lonamiwebs/klooni/Klooni.java
This commit is contained in:
commit
f600d5f2dc
176 changed files with 17668 additions and 462 deletions
|
@ -25,6 +25,9 @@ public class Klooni extends Game {
|
|||
|
||||
private final static float SCORE_TO_MONEY = 1f / 100f;
|
||||
|
||||
public static final int GAME_HEIGHT = 680;
|
||||
public static final int GAME_WIDTH = 408;
|
||||
|
||||
//endregion
|
||||
|
||||
//region Creation
|
||||
|
@ -34,38 +37,8 @@ public class Klooni extends Game {
|
|||
onDesktop = Gdx.app.getType().equals(Application.ApplicationType.Desktop);
|
||||
prefs = Gdx.app.getPreferences("io.github.lonamiwebs.klooni.game");
|
||||
|
||||
// TODO Better way to have this skin somewhere
|
||||
// Gotta create that darn .json…!
|
||||
skin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
|
||||
skin.add("button_up", new NinePatch(new Texture(
|
||||
Gdx.files.internal("ui/button_up.png")), 28, 28, 28, 28));
|
||||
|
||||
skin.add("button_dscalableown", new NinePatch(new Texture(
|
||||
Gdx.files.internal("ui/button_down.png")), 28, 28, 28, 28));
|
||||
|
||||
skin.add("play_texture", new Texture(Gdx.files.internal("ui/play.png")));
|
||||
skin.add("play_saved_texture", new Texture(Gdx.files.internal("ui/play_saved.png")));
|
||||
skin.add("star_texture", new Texture(Gdx.files.internal("ui/star.png")));
|
||||
skin.add("stopwatch_texture", new Texture(Gdx.files.internal("ui/stopwatch.png")));
|
||||
skin.add("palette_texture", new Texture(Gdx.files.internal("ui/palette.png")));
|
||||
skin.add("home_texture", new Texture(Gdx.files.internal("ui/home.png")));
|
||||
skin.add("replay_texture", new Texture(Gdx.files.internal("ui/replay.png")));
|
||||
skin.add("share_texture", new Texture(Gdx.files.internal("ui/share.png")));
|
||||
skin.add("sound_on_texture", new Texture(Gdx.files.internal("ui/sound_on.png")));
|
||||
skin.add("sound_off_texture", new Texture(Gdx.files.internal("ui/sound_off.png")));
|
||||
skin.add("snap_on_texture", new Texture(Gdx.files.internal("ui/snap_on.png")));
|
||||
skin.add("snap_off_texture", new Texture(Gdx.files.internal("ui/snap_off.png")));
|
||||
skin.add("issues_texture", new Texture(Gdx.files.internal("ui/issues.png")));
|
||||
skin.add("credits_texture", new Texture(Gdx.files.internal("ui/credits.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("ok_texture", new Texture(Gdx.files.internal("ui/ok.png")));
|
||||
skin.add("cancel_texture", new Texture(Gdx.files.internal("ui/cancel.png")));
|
||||
|
||||
skin.add("font", new BitmapFont(Gdx.files.internal("font/geosans-light.fnt")));
|
||||
skin.add("font_small", new BitmapFont(Gdx.files.internal("font/geosans-light32.fnt")));
|
||||
skin.add("font_bonus", new BitmapFont(Gdx.files.internal("font/the-next-font.fnt")));
|
||||
// Load the best match for the skin (depending on the device screen dimensions)
|
||||
skin = SkinLoader.loadSkin();
|
||||
|
||||
// Use only one instance for the theme, so anyone using it uses the most up-to-date
|
||||
Theme.skin = skin; // Not the best idea
|
||||
|
|
65
core/src/io/github/lonamiwebs/klooni/SkinLoader.java
Normal file
65
core/src/io/github/lonamiwebs/klooni/SkinLoader.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
package io.github.lonamiwebs.klooni;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.NinePatch;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
|
||||
public class SkinLoader {
|
||||
private static float[] multipliers = {0.75f, 1.0f, 1.25f, 1.5f, 2.0f, 4.0f};
|
||||
private static String[] ids = {
|
||||
"play", "play_saved", "star", "stopwatch", "palette", "home", "replay",
|
||||
"share", "sound_on", "sound_off", "snap_on", "snap_off", "issues", "credits",
|
||||
"web", "back", "ok", "cancel"
|
||||
};
|
||||
|
||||
private static float bestMultiplier;
|
||||
|
||||
static {
|
||||
// Use the height to determine the best match
|
||||
// We cannot use a size which is over the device height,
|
||||
// so use the closest smaller one
|
||||
int i;
|
||||
float desired = (float)Gdx.graphics.getHeight() / (float)Klooni.GAME_HEIGHT;
|
||||
for (i = multipliers.length - 1; i > 0; --i) {
|
||||
if (multipliers[i] < desired)
|
||||
break;
|
||||
}
|
||||
|
||||
// Now that we have the right multiplier, load the skin
|
||||
Gdx.app.log("SkinLoader", "Using assets multiplier x" + multipliers[i]);
|
||||
bestMultiplier = multipliers[i];
|
||||
}
|
||||
|
||||
static Skin loadSkin() {
|
||||
String folder = "ui/x" + bestMultiplier + "/";
|
||||
|
||||
// Base skin
|
||||
Skin skin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
|
||||
// Nine patches
|
||||
final int border = (int)(28 * bestMultiplier);
|
||||
skin.add("button_up", new NinePatch(new Texture(
|
||||
Gdx.files.internal(folder + "button_up.png")), border, border, border, border));
|
||||
|
||||
skin.add("button_down", new NinePatch(new Texture(
|
||||
Gdx.files.internal(folder + "button_down.png")), border, border, border, border));
|
||||
|
||||
for (String id : ids) {
|
||||
skin.add(id + "_texture", new Texture(Gdx.files.internal(folder + id + ".png")));
|
||||
}
|
||||
|
||||
folder = "font/x" + bestMultiplier + "/";
|
||||
skin.add("font", new BitmapFont(Gdx.files.internal(folder + "geosans-light64.fnt")));
|
||||
skin.add("font_small", new BitmapFont(Gdx.files.internal(folder + "geosans-light32.fnt")));
|
||||
skin.add("font_bonus", new BitmapFont(Gdx.files.internal(folder + "the-next-font.fnt")));
|
||||
|
||||
return skin;
|
||||
}
|
||||
|
||||
public static Texture loadPng(String name) {
|
||||
final String filename = "ui/x" + bestMultiplier + "/" + name + ".png";
|
||||
return new Texture(Gdx.files.internal(filename));
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
|||
import com.badlogic.gdx.utils.Align;
|
||||
|
||||
import io.github.lonamiwebs.klooni.Klooni;
|
||||
import io.github.lonamiwebs.klooni.SkinLoader;
|
||||
import io.github.lonamiwebs.klooni.serializer.BinSerializable;
|
||||
|
||||
public abstract class BaseScorer implements BinSerializable {
|
||||
|
@ -36,7 +37,7 @@ public abstract class BaseScorer implements BinSerializable {
|
|||
|
||||
// The board size is required when calculating the score
|
||||
BaseScorer(final Klooni game, GameLayout layout, int highScore) {
|
||||
cupTexture = new Texture(Gdx.files.internal("ui/cup.png"));
|
||||
cupTexture = SkinLoader.loadPng("cup");
|
||||
cupColor = Klooni.theme.currentScore.cpy();
|
||||
cupArea = new Rectangle();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue