From 4e5c4fd45315ef2c2b81ccae769371dffe7683d9 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 7 May 2017 18:29:31 +0200 Subject: [PATCH] Add a new underwater theme --- android/assets/themes/theme.list | 1 + android/assets/themes/underwater.theme | 26 +++ android/assets/ui/cells/basic.png | Bin 210 -> 337 bytes android/assets/ui/cells/bubble.png | Bin 0 -> 823 bytes .../io/github/lonamiwebs/klooni/Theme.java | 5 +- .../lonamiwebs/klooni/actors/ThemeCard.java | 27 ++- .../github/lonamiwebs/klooni/game/Cell.java | 16 +- original-resources/buttons.svg | 176 +++++------------- original-resources/gen-ui-png.py | 13 +- 9 files changed, 115 insertions(+), 149 deletions(-) create mode 100644 android/assets/themes/underwater.theme create mode 100644 android/assets/ui/cells/bubble.png 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 e8f30bc0127a2a9eef247ef1782928c7ad2ab870..f242f18cc3003fd58c3ec76cb39fb8b51d0a5796 100644 GIT binary patch delta 285 zcmcb_c#%o5Gr-TCmrII^fq{Y7)59f*fq_89k5NMF z=<11X8ujNqT^vIqTHoIA+8!u;miE1Gr-TCmrII^fq{Y7)59f*fq_8)ggMw47#QR~|4*E#D8V(I-`@u z?23tQ8Y%vsE{-7BP)6l^dMI8sv5{&GL#?b;3&iS{~|VkH#`6U diff --git a/android/assets/ui/cells/bubble.png b/android/assets/ui/cells/bubble.png new file mode 100644 index 0000000000000000000000000000000000000000..54eb12da0649e3760cc4ec4b4bcff47b26e62d42 GIT binary patch literal 823 zcmeAS@N?(olHy`uVBq!ia0y~yU{C>J4mJh`hKCF@W-u@?uoOFahH!9jaMW<5bTBY5 za29w(7Bet#`GGK_gx1m33=9mCC9V-A!TD(=<%vb94CUqJdYO6I#mR{Use1WE>9gP2 zNHH)lZSiz*42fucJHy&P#8KpU{d1<>2e?GC)Ww)4o^wx1Ob{A3gz7U~Z`>)9EV_cJTj|rr@MZo-XQouus~9RS&J?7m@8+@uCffj#CaaEOl=`w zJ#~USQy329N=F=XJ?8Ao5S%9bE$7T1FUy2IdQ9fYvXTng52AOx;C-wVWVC_HATvzS zH(B$;`PJ5|tS*aj>}X%DyYU}OxVf|0#~lZIBpiwkeDZ2w50fiYxSejZm2I2^v&EWnurDXof zhfa4CVm<4oUS-X|T5A@8_3QTuGUduJd8EA)Sm9Ofy?w=>Kyi+SHx6;Vy)QP0 zxu$3{r$osZ_@tdvQ`jxLhF>7f*Ci~9X{MNjkM7E|SC{Zihz*V7Wq7f)qb83#rHWhU ztKc){4|>-GSvTE2Q2d7XPO>hefArn6pW;N`Z~J^!k@X(KdhS>e{)V#;`2KHZO}thR z{?g~H2ou+VbIjK}=Ia^1JD~OMeA`sBeMcLZHh4DAIwt!@>)KY{8uon;{`KAL`hRF* a*K2*|cNc$7d0zy|8VsJUelF{r5}E+#+gf=5 literal 0 HcmV?d00001 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)