diff --git a/android/assets/themes/theme.list b/android/assets/themes/theme.list index 22714f5..8ffea23 100644 --- a/android/assets/themes/theme.list +++ b/android/assets/themes/theme.list @@ -1,3 +1,4 @@ default dark bandw +underwater diff --git a/android/assets/themes/underwater.theme b/android/assets/themes/underwater.theme new file mode 100644 index 0000000..6f27107 --- /dev/null +++ b/android/assets/themes/underwater.theme @@ -0,0 +1,26 @@ +{ + "name": "Underwater", + "price": 50, + "colors": { + "background": "0044aaff", + "foreground": "d7f4e3ff", + "buttons": [ + "37c871ff", + "2a7fffff", + "00ccffff", + "5f5fd3ff" + ], + "empty_cell": "0066ffff", + "cells": [ + "37c871ff", "2ad4ffff", "0000d4ff", + "00ffccff", "5599ffff", "87cddeff", "80b3ffff", + "00ff66ff", "00d4aaff" + ], + "current_score": "aaccffff", + "high_score": "2aff80ff", + "bonus": "aaeeffff", + "band": "3771c8ff", + "text": "002255ff" + }, + "cell_texture": "bubble.png" +} diff --git a/android/assets/ui/cells/basic.png b/android/assets/ui/cells/basic.png index e8f30bc..f242f18 100644 Binary files a/android/assets/ui/cells/basic.png and b/android/assets/ui/cells/basic.png differ diff --git a/android/assets/ui/cells/bubble.png b/android/assets/ui/cells/bubble.png new file mode 100644 index 0000000..54eb12d Binary files /dev/null and b/android/assets/ui/cells/bubble.png differ diff --git a/core/src/io/github/lonamiwebs/klooni/Theme.java b/core/src/io/github/lonamiwebs/klooni/Theme.java index 489210f..fe66551 100644 --- a/core/src/io/github/lonamiwebs/klooni/Theme.java +++ b/core/src/io/github/lonamiwebs/klooni/Theme.java @@ -38,7 +38,7 @@ public class Theme { public static Skin skin; - public NinePatch cellPatch; + public Texture cellTexture; // Save the button styles so the changes here get reflected private ImageButton.ImageButtonStyle[] buttonStyles; @@ -153,8 +153,7 @@ public class Theme { } String cellTextureFile = json.getString("cell_texture"); - cellPatch = new NinePatch(new Texture( - Gdx.files.internal("ui/cells/"+cellTextureFile)), 4, 4, 4, 4); + cellTexture = new Texture(Gdx.files.internal("ui/cells/"+cellTextureFile)); return this; } diff --git a/core/src/io/github/lonamiwebs/klooni/actors/ThemeCard.java b/core/src/io/github/lonamiwebs/klooni/actors/ThemeCard.java index 57ac430..a4b34f7 100644 --- a/core/src/io/github/lonamiwebs/klooni/actors/ThemeCard.java +++ b/core/src/io/github/lonamiwebs/klooni/actors/ThemeCard.java @@ -29,6 +29,12 @@ public class ThemeCard extends Actor { public float cellSize; + private final static int colorsUsed[][] = { + {0, 7, 7}, + {8, 7, 3}, + {8, 8, 3} + }; + //endregion //region Constructor @@ -64,21 +70,14 @@ public class ThemeCard extends Actor { batch.setColor(theme.background); batch.draw(background, x, y, getWidth(), getHeight()); - // Do not draw on the borders (0,0 offset to add some padding), colors used: - // 0 7 7 - // 8 7 3 - // 8 8 3 - Cell.draw(theme.getCellColor(0), batch, x + cellSize, y + cellSize, cellSize); - Cell.draw(theme.getCellColor(7), batch, x + cellSize * 2, y + cellSize, cellSize); - Cell.draw(theme.getCellColor(7), batch, x + cellSize * 3, y + cellSize, cellSize); - Cell.draw(theme.getCellColor(8), batch, x + cellSize, y + cellSize * 2, cellSize); - Cell.draw(theme.getCellColor(7), batch, x + cellSize * 2, y + cellSize * 2, cellSize); - Cell.draw(theme.getCellColor(8), batch, x + cellSize * 3, y + cellSize * 2, cellSize); - - Cell.draw(theme.getCellColor(8), batch, x + cellSize, y + cellSize * 3, cellSize); - Cell.draw(theme.getCellColor(8), batch, x + cellSize * 2, y + cellSize * 3, cellSize); - Cell.draw(theme.getCellColor(3), batch, x + cellSize * 3, y + cellSize * 3, cellSize); + // Avoid drawing on the borders by adding +1 cell padding + for (int i = 0; i < colorsUsed.length; ++i) { + for (int j = 0; j < colorsUsed[i].length; ++j) { + Cell.draw(theme.cellTexture, theme.getCellColor(colorsUsed[i][j]), batch, + x + cellSize * (j + 1), y + cellSize * (i + 1), cellSize); + } + } nameLabel.setBounds(x + nameBounds.x, y + nameBounds.y, nameBounds.width, nameBounds.height); nameLabel.draw(batch, parentAlpha); diff --git a/core/src/io/github/lonamiwebs/klooni/game/Cell.java b/core/src/io/github/lonamiwebs/klooni/game/Cell.java index 861332e..f4a827d 100644 --- a/core/src/io/github/lonamiwebs/klooni/game/Cell.java +++ b/core/src/io/github/lonamiwebs/klooni/game/Cell.java @@ -2,6 +2,7 @@ package io.github.lonamiwebs.klooni.game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Interpolation; @@ -105,11 +106,18 @@ public class Cell implements BinSerializable { //region Static methods - // TODO Use skin atlas - public static void draw(Color color, Batch batch, - float x, float y, float size) { + // Default texture (don't call overloaded version to avoid overhead) + public static void draw(final Color color, final Batch batch, + final float x, final float y, final float size) { batch.setColor(color); - Klooni.theme.cellPatch.draw(batch, x, y, size, size); + batch.draw(Klooni.theme.cellTexture, x, y, size, size); + } + + // Custom texture + public static void draw(final Texture texture, final Color color, final Batch batch, + final float x, final float y, final float size) { + batch.setColor(color); + batch.draw(texture, x, y, size, size); } //endregion diff --git a/original-resources/buttons.svg b/original-resources/buttons.svg index b4643dc..15360c7 100644 --- a/original-resources/buttons.svg +++ b/original-resources/buttons.svg @@ -19,6 +19,18 @@ sodipodi:docname="buttons.svg"> + + + + @@ -94,6 +106,17 @@ y1="1012.8427" x2="-441.97687" y2="1072.3632" /> + + transform="matrix(3.0000588,0,0,3.0000588,0,-2123.8991)"> cells - - - - - - - @@ -847,88 +833,6 @@ x="13.435027" y="587.79303" style="font-size:40px;line-height:1.25">measures - 2px radius - 4px patch - - - - - - - - + + + + diff --git a/original-resources/gen-ui-png.py b/original-resources/gen-ui-png.py index 6335a7e..dc1a3b8 100755 --- a/original-resources/gen-ui-png.py +++ b/original-resources/gen-ui-png.py @@ -36,6 +36,11 @@ ids = [ 'web' ] +cells = [ + 'basic', + 'bubble' +] + inkscape_default_dpi = 90 svg = 'buttons.svg' root = '../android/assets/ui' @@ -55,4 +60,10 @@ for multiplier in multipliers: # -d to specify the DPI run(f'inkscape -z -i{objectid} -j -e{filename} -d{dpi} {svg}', shell=True, stdout=DEVNULL) - + + folder = os.path.join(folder, 'cells') + os.makedirs(folder, exist_ok=True) + for cellid in cells: + filename = os.path.join(folder, cellid + '.png') + run(f'inkscape -z -i{cellid} -j -e{filename} -d{dpi} {svg}', + shell=True, stdout=DEVNULL)