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 zcmV+&0pkAB0nq{>iBL{Q4GJ0x0000DNk~Le0000a0000a2nGNE0O0_bn2{kG3kpsE z018e47%Ii9kwz$g&PhZ;R9J=W*i8W z9~d`K7xPvPG?_2JrhwI*d%qweb6^V;z^JFWci;r4vv<#$WAT0xF z8A!`OS_aZGkd}e845Sr1Gr-TCmrII^fq{Y7)59eQNDF{42OE%-|NK93qM{Tx?{%Q;bw($R*%cGr zG*bLMT^vI!df!goDcE2jaHOQ9{pEhf+qE4m676*yYcnQaeZ$ILzaTDa>-}uE!PC{xWt~$( F69DauH#`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 zcmV-71IYY|P)3^0B8tsyYkY z$3-Qv$NRt^`)sFmU_nGabp@oV0^9%|0;9kPFcbjQfn8uH2b2Quffpj89RsQA2=ExV z0*o6_IRI)HP!0HPmPgCLGZEQ~bq=?H5#SMU85jd9235vI30%5%Xij0CNL>PkRP{+L zQb}Y0z-=2?#zn?MO#oA76ZUM({7N}syeCH$yh@xWSAVKytwHN`MDe9&sSsXFRnAwokgu{i^ewEb% zuudZcFt4hUBC^>81e_(iFYVxJC&8sIr>{o7B_EU6+{*`nPDh*-mnJ1mTS6MG zFoH#*<24-vI?=*;A6GAR^A98BYph$H^oOL!3tbcsfX(0z|FZ>Q)^JzpOwAMm3c$_-*NC4kGw#4D?$3sm zHonDx0n{WD(fO3`a#8>Q002ovPDHLkV1nn{ BT6q8f 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)