diff --git a/android/assets/gfx/button/no_icon.png b/android/assets/gfx/button/no_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..45b688be7103f8e5e5e286f278a03aa5806c779b Binary files /dev/null and b/android/assets/gfx/button/no_icon.png differ diff --git a/android/assets/gfx/button/yes_icon.png b/android/assets/gfx/button/yes_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..4da4d0e166b93c52fc998fe1700f2013c5fd0fa9 Binary files /dev/null and b/android/assets/gfx/button/yes_icon.png differ diff --git a/android/build.gradle b/android/build.gradle index 56121a336580a03c61bf7538f181219e287def13..40e4607d06e0de5f0127a540953cc47413362d8a 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -44,6 +44,7 @@ android { res.srcDirs = ['res/main'] assets.srcDirs = ['assets'] java.srcDir file('src/main/java') + jniLibs.srcDirs = ['libs'] } androidTest { java.srcDir file('src/androidTest/java') @@ -156,11 +157,6 @@ tasks.whenTaskAdded { compileTask -> } } -// needed to add JNI shared libraries to APK when compiling on CLI -tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask -> - pkgTask.jniFolders = new HashSet<File>() - pkgTask.jniFolders.add(new File(projectDir, 'libs')) -} // called every time gradle gets executed, takes the native dependencies of // the natives configuration, and extracts them to the proper libs/ folders // so they get packed with the APK. diff --git a/build.gradle b/build.gradle index 7cf36d2be27e90eafe24312d5703baf57bd1958a..a621bbdf6c566b303002dacb009fa86a06f4c965 100644 --- a/build.gradle +++ b/build.gradle @@ -4,16 +4,15 @@ import com.badlogic.gdx.tools.texturepacker.TexturePacker buildscript { repositories { //mavenCentral() - jcenter{ - url "http://jcenter.bintray.com/" - } + maven { url 'https://jitpack.io' } + jcenter{ url "http://jcenter.bintray.com/" } } dependencies { classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6' - classpath 'com.android.tools.build:gradle:1.2.3' - classpath 'org.robovm:robovm-gradle-plugin:1.2.0' + classpath 'com.android.tools.build:gradle:2.0.0' + classpath 'org.robovm:robovm-gradle-plugin:1.12.0' classpath 'de.felixschulze.gradle:gradle-spoon-plugin:2.1' - classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0' + classpath 'com.github.JakeWharton:sdk-manager-plugin:220bf7a88a7072df3ed16dc8466fb144f2817070' classpath 'com.novoda:gradle-android-command-plugin:1.3.0' classpath "com.badlogicgames.gdx:gdx-tools:1.6.1" } @@ -56,13 +55,13 @@ allprojects { applicationIdDevelSuffix = '.devel' applicationIdDevel = applicationIdRelease + applicationIdDevelSuffix - gdxVersion = '1.6.1' - gdxUtilsVersion = '0.13.1' + gdxVersion = '1.9.2' + gdxUtilsVersion = '0.13.2' mbassadorVersion = '1.2.0' - roboVMVersion = '1.7.0' - box2DLightsVersion = '1.3' - ashleyVersion = '1.3.1' - aiVersion = '1.4.0' + roboVMVersion = '1.12.0' + box2DLightsVersion = '1.4' + ashleyVersion = '1.6.0' + aiVersion = '1.6.0' sqlDroidVersion = '1.0.3' sqlLiteJdbcVersion = '3.8.10.1' guavaVersion = '18.0' diff --git a/core/assets/common/game/kidnapping/common/gfx/arrow-left-down-pressed.png b/core/assets/common/game/kidnapping/common/gfx/arrow-left-down-pressed.png index d83ef8ae558dc2052cc3fab7b87012f44509a4f7..df74742e3f768e1c8fe4d324f46e37ebf83761c0 100644 Binary files a/core/assets/common/game/kidnapping/common/gfx/arrow-left-down-pressed.png and b/core/assets/common/game/kidnapping/common/gfx/arrow-left-down-pressed.png differ diff --git a/core/assets/common/game/kidnapping/common/gfx/arrow-left-down-unpressed.png b/core/assets/common/game/kidnapping/common/gfx/arrow-left-down-unpressed.png index 4db53acebdfbdfd778a563b01b92b1d793304699..c65a614520124d1f4486fa4cd2a6f2296b9137c2 100644 Binary files a/core/assets/common/game/kidnapping/common/gfx/arrow-left-down-unpressed.png and b/core/assets/common/game/kidnapping/common/gfx/arrow-left-down-unpressed.png differ diff --git a/core/assets/common/game/kidnapping/common/gfx/arrow-left-top-pressed.png b/core/assets/common/game/kidnapping/common/gfx/arrow-left-top-pressed.png index a6184f4d27e03a2ef21238c189c078ac6aa3c434..366fed7aee6ca35a0800c94cf0f2c64975c04f00 100644 Binary files a/core/assets/common/game/kidnapping/common/gfx/arrow-left-top-pressed.png and b/core/assets/common/game/kidnapping/common/gfx/arrow-left-top-pressed.png differ diff --git a/core/assets/common/game/kidnapping/common/gfx/arrow-left-top-unpressed.png b/core/assets/common/game/kidnapping/common/gfx/arrow-left-top-unpressed.png index d9a9e7f1c47350f4ca0e61baf84c6c6fb69966d2..3b1875d8742b8fd5fb746d8ab1533e0e36c777a9 100644 Binary files a/core/assets/common/game/kidnapping/common/gfx/arrow-left-top-unpressed.png and b/core/assets/common/game/kidnapping/common/gfx/arrow-left-top-unpressed.png differ diff --git a/core/assets/common/game/kidnapping/common/gfx/arrow-right-down-pressed.png b/core/assets/common/game/kidnapping/common/gfx/arrow-right-down-pressed.png index b6ddd2677eb50177d4c4308d553abae0236a2379..f7ee241e407a19ebe524a57df64fde6a78c4cd11 100644 Binary files a/core/assets/common/game/kidnapping/common/gfx/arrow-right-down-pressed.png and b/core/assets/common/game/kidnapping/common/gfx/arrow-right-down-pressed.png differ diff --git a/core/assets/common/game/kidnapping/common/gfx/arrow-right-down-unpressed.png b/core/assets/common/game/kidnapping/common/gfx/arrow-right-down-unpressed.png index 11e5b195b8bbb0eac268995605b56499a7bec09c..f02b435d1ac5797b9db012b60d56068dd3491370 100644 Binary files a/core/assets/common/game/kidnapping/common/gfx/arrow-right-down-unpressed.png and b/core/assets/common/game/kidnapping/common/gfx/arrow-right-down-unpressed.png differ diff --git a/core/assets/common/game/kidnapping/common/gfx/arrow-right-top-pressed.png b/core/assets/common/game/kidnapping/common/gfx/arrow-right-top-pressed.png index c5f307632c022b995ac840fecd396774be667bae..fd4cf5cf4b81e6115dc4be8267db1e5da9fade80 100644 Binary files a/core/assets/common/game/kidnapping/common/gfx/arrow-right-top-pressed.png and b/core/assets/common/game/kidnapping/common/gfx/arrow-right-top-pressed.png differ diff --git a/core/assets/common/game/kidnapping/common/gfx/arrow-right-top-unpressed.png b/core/assets/common/game/kidnapping/common/gfx/arrow-right-top-unpressed.png index c147e50ef9e52f0e0428ea505e88365c70bd86a8..e32a953528f90c5e85f9bf6818e120e395ba8f4e 100644 Binary files a/core/assets/common/game/kidnapping/common/gfx/arrow-right-top-unpressed.png and b/core/assets/common/game/kidnapping/common/gfx/arrow-right-top-unpressed.png differ diff --git a/core/assets/common/game/kidnapping/common/gfx/dobre.png b/core/assets/common/game/kidnapping/common/gfx/correct.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/dobre.png rename to core/assets/common/game/kidnapping/common/gfx/correct.png diff --git a/core/assets/common/game/kidnapping/common/gfx/lineNESW-2.png b/core/assets/common/game/kidnapping/common/gfx/lineNESW.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/lineNESW-2.png rename to core/assets/common/game/kidnapping/common/gfx/lineNESW.png diff --git a/core/assets/common/game/kidnapping/common/gfx/lineNWSE-2.png b/core/assets/common/game/kidnapping/common/gfx/lineNWSE.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/lineNWSE-2.png rename to core/assets/common/game/kidnapping/common/gfx/lineNWSE.png diff --git a/core/assets/common/game/kidnapping/common/gfx/zde-jsi.png b/core/assets/common/game/kidnapping/common/gfx/position-current.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/zde-jsi.png rename to core/assets/common/game/kidnapping/common/gfx/position-current.png diff --git a/core/assets/common/game/kidnapping/common/gfx/papir-pravidla.png b/core/assets/common/game/kidnapping/common/gfx/rules-background.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/papir-pravidla.png rename to core/assets/common/game/kidnapping/common/gfx/rules-background.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/domek1.png b/core/assets/common/game/kidnapping/common/gfx/tiles/house1.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/domek1.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/house1.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/domek2.png b/core/assets/common/game/kidnapping/common/gfx/tiles/house2.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/domek2.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/house2.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/domek3.png b/core/assets/common/game/kidnapping/common/gfx/tiles/house3.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/domek3.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/house3.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/domek4.png b/core/assets/common/game/kidnapping/common/gfx/tiles/house4.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/domek4.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/house4.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/domek5.png b/core/assets/common/game/kidnapping/common/gfx/tiles/house5.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/domek5.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/house5.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/domek6.png b/core/assets/common/game/kidnapping/common/gfx/tiles/house6.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/domek6.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/house6.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/domek7.png b/core/assets/common/game/kidnapping/common/gfx/tiles/house7.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/domek7.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/house7.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/domek8.png b/core/assets/common/game/kidnapping/common/gfx/tiles/house8.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/domek8.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/house8.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/hriste.png b/core/assets/common/game/kidnapping/common/gfx/tiles/playground.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/hriste.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/playground.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/posta.png b/core/assets/common/game/kidnapping/common/gfx/tiles/post.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/posta.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/post.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/skola.png b/core/assets/common/game/kidnapping/common/gfx/tiles/school.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/skola.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/school.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/vila1.png b/core/assets/common/game/kidnapping/common/gfx/tiles/villa1.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/vila1.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/villa1.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/vila2.png b/core/assets/common/game/kidnapping/common/gfx/tiles/villa2.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/vila2.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/villa2.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/vila3.png b/core/assets/common/game/kidnapping/common/gfx/tiles/villa3.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/vila3.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/villa3.png diff --git a/core/assets/common/game/kidnapping/common/gfx/tiles/vila4.png b/core/assets/common/game/kidnapping/common/gfx/tiles/villa4.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/tiles/vila4.png rename to core/assets/common/game/kidnapping/common/gfx/tiles/villa4.png diff --git a/core/assets/common/game/kidnapping/common/gfx/spatne.png b/core/assets/common/game/kidnapping/common/gfx/wrong.png similarity index 100% rename from core/assets/common/game/kidnapping/common/gfx/spatne.png rename to core/assets/common/game/kidnapping/common/gfx/wrong.png diff --git a/core/assets/common/game/kidnapping/common/gfx/znovu-pressed.png b/core/assets/common/game/kidnapping/common/gfx/znovu-pressed.png deleted file mode 100644 index 7be563dd996efb3da6e368c983d7ab8413075eb3..0000000000000000000000000000000000000000 Binary files a/core/assets/common/game/kidnapping/common/gfx/znovu-pressed.png and /dev/null differ diff --git a/core/assets/common/game/kidnapping/common/gfx/znovu.png b/core/assets/common/game/kidnapping/common/gfx/znovu.png deleted file mode 100644 index 7f95a7d5016f10996099306b0c3bb9dd0cbb9d39..0000000000000000000000000000000000000000 Binary files a/core/assets/common/game/kidnapping/common/gfx/znovu.png and /dev/null differ diff --git a/core/assets/common/screen/encyclopedia/gfx/pause_icon.png b/core/assets/common/screen/encyclopedia/gfx/pause_icon.png index 405297e17724830e9e8941ea6ac1513deb45a6c2..381cbc0b77ed86f89191bff3f127b62e47711db9 100644 Binary files a/core/assets/common/screen/encyclopedia/gfx/pause_icon.png and b/core/assets/common/screen/encyclopedia/gfx/pause_icon.png differ diff --git a/core/assets/common/screen/encyclopedia/gfx/play_icon.png b/core/assets/common/screen/encyclopedia/gfx/play_icon.png index e9ecd3d33d1393139590d65afd5b1ae7528df9d1..9bc867ec660158b964084d81611e72721fcb2087 100644 Binary files a/core/assets/common/screen/encyclopedia/gfx/play_icon.png and b/core/assets/common/screen/encyclopedia/gfx/play_icon.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/bankovniloupez_back.png b/core/assets/common/screen/gamemenu/gfx/bankovniloupez_back.png index 8523838e09a239ec8eca40cc7db55e8b636499d1..429c67a6a6b496e9ae16adcdbce4ccdaed344234 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/bankovniloupez_back.png and b/core/assets/common/screen/gamemenu/gfx/bankovniloupez_back.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/nocnisledovani_back.png b/core/assets/common/screen/gamemenu/gfx/nocnisledovani_back.png index acb8020fb937d010e11e4d200372102fb3ff76e7..7e1c827f7e3eec017fafbc5a26f21736f6c52b19 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/nocnisledovani_back.png and b/core/assets/common/screen/gamemenu/gfx/nocnisledovani_back.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/overscroll_left.png b/core/assets/common/screen/gamemenu/gfx/overscroll_left.png new file mode 100644 index 0000000000000000000000000000000000000000..ac8e4d8a2421cbe728f5092435f2b382987af723 Binary files /dev/null and b/core/assets/common/screen/gamemenu/gfx/overscroll_left.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/overscroll_right.png b/core/assets/common/screen/gamemenu/gfx/overscroll_right.png new file mode 100644 index 0000000000000000000000000000000000000000..8d7c0fb1a25417698dd1f9e4a61ccec745df0870 Binary files /dev/null and b/core/assets/common/screen/gamemenu/gfx/overscroll_right.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/potme_back.png b/core/assets/common/screen/gamemenu/gfx/potme_back.png index ef4501aaa8275b8f517558813abcf716017b377e..cad5eb7936f746d60e58248c95a285d4d45bfdb3 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/potme_back.png and b/core/assets/common/screen/gamemenu/gfx/potme_back.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/pronasledovani_back.png b/core/assets/common/screen/gamemenu/gfx/pronasledovani_back.png index 73453e3b46247e6e1e13ef0cbd0856d07c3d9a72..9d46fb3d78a9d65e50711e5c9ad0bbb1fcbeaf23 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/pronasledovani_back.png and b/core/assets/common/screen/gamemenu/gfx/pronasledovani_back.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/strelnice_back.png b/core/assets/common/screen/gamemenu/gfx/strelnice_back.png index 18c32833f31a1daa2184c4e77cfe3dcd351b7db2..6167680ddeceb60fc3c73ec22806aa42c1fcebc6 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/strelnice_back.png and b/core/assets/common/screen/gamemenu/gfx/strelnice_back.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/unos_back.png b/core/assets/common/screen/gamemenu/gfx/unos_back.png index eb63750c9e70cbcac1eabea142fe8abbe392c806..7faca7bdf3acfec30d66fbb4bc4eafa27191d9be 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/unos_back.png and b/core/assets/common/screen/gamemenu/gfx/unos_back.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/wall_back.png b/core/assets/common/screen/gamemenu/gfx/wall_back.png index e1e5303fbca2f5d8d413e2657c773585ce6e7520..a2f54b72a6de59fb95b3e20919c6e72dfbaac3f2 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/wall_back.png and b/core/assets/common/screen/gamemenu/gfx/wall_back.png differ diff --git a/core/assets/common/screen/panorama/gfx/swipe/overscroll_right.png b/core/assets/common/screen/panorama/gfx/swipe/overscroll_right.png new file mode 100644 index 0000000000000000000000000000000000000000..e859c84b4dd17bcc1db51960867c9c8a9454cc21 Binary files /dev/null and b/core/assets/common/screen/panorama/gfx/swipe/overscroll_right.png differ diff --git a/core/external b/core/external index 0aaae993125e350c440c8c4e6ec8888874037abb..eb3e01925a5a6d323d41f9271636ad5c24072e25 160000 --- a/core/external +++ b/core/external @@ -1 +1 @@ -Subproject commit 0aaae993125e350c440c8c4e6ec8888874037abb +Subproject commit eb3e01925a5a6d323d41f9271636ad5c24072e25 diff --git a/core/src/cz/nic/tablexia/TablexiaApplication.java b/core/src/cz/nic/tablexia/TablexiaApplication.java index 57f93d6c69f0d8bdcebc208e760dd3f6a6974c75..241e08e6c883526340020df23128c9ab79ea8d2a 100644 --- a/core/src/cz/nic/tablexia/TablexiaApplication.java +++ b/core/src/cz/nic/tablexia/TablexiaApplication.java @@ -215,8 +215,10 @@ public abstract class TablexiaApplication implements ApplicationListener { public void resize(int width, int height) { if (lastScreen != null) lastScreen.resize(width, height); if (screen != null) screen.resize(width, height); - stage.getViewport().update(width, height, true); - setScreenDimmerBounds(); + if (stage != null) { + stage.getViewport().update(width, height, true); + setScreenDimmerBounds(); + } if (screenSizeUnderThreshold != ComponentScaleUtil.isUnderThreshold()) { ApplicationBus.getInstance().publishAsync(new ScreenSizeThresholdChanged(ComponentScaleUtil.isUnderThreshold())); diff --git a/core/src/cz/nic/tablexia/TablexiaSettings.java b/core/src/cz/nic/tablexia/TablexiaSettings.java index e24c2e75440b09c29900738f7d75363c6e06ba9f..1b838c84d5698ecf3bd040cdaf9b47fbf8ee9251 100644 --- a/core/src/cz/nic/tablexia/TablexiaSettings.java +++ b/core/src/cz/nic/tablexia/TablexiaSettings.java @@ -216,16 +216,16 @@ public class TablexiaSettings { } public void setGameDifficulty(GameDefinition gameDefinition, GameDifficulty gameDifficulty) { - preferences.putString(getGameDifficultyPreferncesKey(gameDefinition), gameDifficulty.name()); + preferences.putString(getGameDifficultyPreferencesKey(gameDefinition), gameDifficulty.name()); preferences.flush(); } public GameDifficulty getGameDifficulty(GameDefinition gameDefinition) { - return GameDifficulty.valueOf(GameDifficulty.class, preferences.getString(getGameDifficultyPreferncesKey(gameDefinition), GameDifficulty.DEFAULT_DIFFICULTY.name())); + return GameDifficulty.valueOf(GameDifficulty.class, preferences.getString(getGameDifficultyPreferencesKey(gameDefinition), GameDifficulty.DEFAULT_DIFFICULTY.name())); } - private String getGameDifficultyPreferncesKey(GameDefinition gameDefinition) { - return "GAME_DIFFICULTY_" + gameDefinition.name(); + private String getGameDifficultyPreferencesKey(GameDefinition gameDefinition) { + return "GAME_DIFFICULTY_" + gameDefinition.name() + "_" + getSelectedUser().getId(); } public static Color getDefaultBackgroundColor() { diff --git a/core/src/cz/nic/tablexia/TablexiaStorage.java b/core/src/cz/nic/tablexia/TablexiaStorage.java index 2e36171abddd9ef47e90314750a9ab167f6bdcd6..5a56f559b1cf53e55e1be88e2a2e55fd9b1b9212 100644 --- a/core/src/cz/nic/tablexia/TablexiaStorage.java +++ b/core/src/cz/nic/tablexia/TablexiaStorage.java @@ -18,6 +18,7 @@ import java.util.Map; import cz.nic.tablexia.bus.ApplicationBus; import cz.nic.tablexia.loader.TablexiaAbstractFileManager; import cz.nic.tablexia.model.UserDAO; +import cz.nic.tablexia.model.UserDifficultySettingsDAO; import cz.nic.tablexia.model.game.GameDAO; import cz.nic.tablexia.model.game.GamePauseDAO; import cz.nic.tablexia.model.screen.ScreenDAO; @@ -130,6 +131,7 @@ public class TablexiaStorage { statement.execute(GamePauseDAO.CREATE_CONNECTION_TABLE); statement.execute(SCREEN_STATE_CREATE_TABLE); statement.execute(ScreenDAO.SCREEN_CREATE_TABLE); + statement.execute(UserDifficultySettingsDAO.CREATE_TABLE); statement.close(); } catch (SQLException e) { Log.err(getClass(), "Cannot init Tablexia tables!", e); diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/KidnappingGame.java b/core/src/cz/nic/tablexia/game/games/kidnapping/KidnappingGame.java index 52a6e2c32de68a45c7a0c520bc1b42d92c281aa6..6c02ba21d43f382fe5b93544f7b57440527d72c4 100644 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/KidnappingGame.java +++ b/core/src/cz/nic/tablexia/game/games/kidnapping/KidnappingGame.java @@ -10,8 +10,8 @@ import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction; import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; -import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.Scaling; +import com.badlogic.gdx.utils.Timer; import com.google.common.collect.ObjectArrays; import java.util.Arrays; @@ -130,8 +130,8 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> { screenResized(0, 0); } - - private void prepareRuleMessage() { + + private void prepareRuleMessage() { ruleMessage = new Group(); //Adds Backgrounds @@ -274,9 +274,8 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> { final Direction[] directions = DirectionsHelper.getNextDirections(getData().getLastDirectionFrom()); final Arrow[] arrows = map.getDirectionArrow(position, directions); for (final Arrow a : arrows) { - for (EventListener el : a.getListeners()) { - a.removeListener(el); - } + a.setDisabled(true); + a.clearListeners(); } map.addAction(Actions.sequence(ReplayAlphaAction.fadeOut(), new PlayExample(actualSoundPack.getExample(this)), Actions.run(new Runnable() { diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Arrow.java b/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Arrow.java index 973841bdade6cc3c1e2bd7622599bdc2d2c45125..80e30a5058b850fcba52d56f5042788ae261b2ee 100644 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Arrow.java +++ b/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Arrow.java @@ -21,6 +21,7 @@ package cz.nic.tablexia.game.games.kidnapping.actors; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.ui.Image; @@ -31,7 +32,9 @@ import com.badlogic.gdx.scenes.scene2d.ui.Stack; */ public class Arrow extends Stack { private Image normal, pressed; - private boolean disabled = false; + private boolean disabled = false; + private final Color COLOR_ENABLED = new Color(0x00AADEff); + private final Color COLOR_DISABLED = Color.GRAY; public Arrow(TextureRegion arrow, TextureRegion arrowPressed) { addActor(pressed = new Image(arrowPressed)); @@ -44,13 +47,21 @@ public class Arrow extends Stack { normal.setVisible(true); } - public void setDisabled(boolean val) { - this.disabled = val; - } - public boolean isDisabled() { - return disabled; - } + public void setDisabled(boolean val) { + if (!val) { + normal.setColor(COLOR_ENABLED); + pressed.setColor(COLOR_ENABLED); + } else { + normal.setColor(COLOR_DISABLED); + pressed.setColor(COLOR_DISABLED); + } + this.disabled = val; + } + + public boolean isDisabled() { + return disabled; + } @Override public Actor hit(float x, float y, boolean touchable) { diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Map.java b/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Map.java index d244a943842b71f7375e629e2cd545d4a17af905..acaefb195da2a5a1a6c70d8ffd51f5cf9139d3e9 100644 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Map.java +++ b/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Map.java @@ -64,7 +64,7 @@ public class Map extends Group { public void addTile(Position position, Tile tile) { int baseX = getBaseX(position); - int baseY = getBaseY(position) + (tile.getTileType().getyOffset() / 2); + int baseY = getBaseY(position) + (tile.getTileType().getYOffset() / 2); tile.setPosition(baseX, baseY); tile.setPosition(position); tileMap.put(position, tile); diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TextureTypes.java b/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TextureTypes.java index d4ee30225f2de6e68e8289c5928f95476f9325a3..101a0c6872a7da0e2aacbe67e1aec7fd746ef7f9 100644 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TextureTypes.java +++ b/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TextureTypes.java @@ -28,15 +28,15 @@ import cz.nic.tablexia.game.common.media.AssetDescription; */ public enum TextureTypes implements AssetDescription { - POSITION_CURRENT("zde-jsi"), // + POSITION_CURRENT("position-current"), // OVERLAY("overlay"), // EAR("ear"), // - PAPER("papir-pravidla"), - POSITION_LINE_NWSE("lineNWSE-2"), // - POSITION_LINE_NESW("lineNESW-2"), // + PAPER("rules-background"), + POSITION_LINE_NWSE("lineNWSE"), // + POSITION_LINE_NESW("lineNESW"), // - WRONG("spatne"), // - CORRECT("dobre"), // + WRONG("wrong"), // + CORRECT("correct"), // POSITION_NEXT_NW("arrow-left-top-unpressed"), // POSITION_NEXT_NE("arrow-right-top-unpressed"), // diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TileType.java b/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TileType.java index 5cdda73521032bd2f400edf8a7504ace3fe552ff..e544691e79c10771429fdf2eb6c08d4d351c2533 100644 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TileType.java +++ b/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TileType.java @@ -10,29 +10,29 @@ import cz.nic.tablexia.game.common.media.AssetDescription; public enum TileType implements AssetDescription { - DOME1(1, 1, "domek1", 78), // - DOME2(1, 1, "domek2", 78), // - DOME3(1, 1, "domek3", 78), // - DOME4(1, 1, "domek4", 78), // - DOME5(1, 1, "domek5", 78), // - DOME6(1, 1, "domek6", 78), // - DOME7(1, 1, "domek7", 78), // - DOME8(1, 1, "domek8", 78), // - HRISTE(1, 1, "hriste", 78), // + HOUSE1(1, 1, "house1", 78), // + HOUSE2(1, 1, "house2", 78), // + HOUSE3(1, 1, "house3", 78), // + HOUSE4(1, 1, "house4", 78), // + HOUSE5(1, 1, "house5", 78), // + HOUSE6(1, 1, "house6", 78), // + HOUSE7(1, 1, "house7", 78), // + HOUSE8(1, 1, "house8", 78), // + PLAYGOUND(1, 1, "playground", 78), // PARK(1, 1, "park", 78), // - POSTA(1, 1, "posta", 78), // - SKOLA(1, 1, "skola", 78), // - VILA1(1, 1, "vila1", 78), // - VILA2(1, 1, "vila2", 78), // - VILA3(1, 1, "vila3", 78), // - VILA4(1, 1, "vila4", 78); // + POST(1, 1, "post", 78), // + SCHOOL(1, 1, "school", 78), // + VILLA1(1, 1, "villa1", 78), // + VILLA2(1, 1, "villa2", 78), // + VILLA3(1, 1, "villa3", 78), // + VILLA4(1, 1, "villa4", 78); // public static final String BASE_DIR = "tiles/"; private final int swSize, seSize; private final String name; private final int yOffset; - private TileType(int sw, int se, String name, int yOffset) { + TileType(int sw, int se, String name, int yOffset) { this.swSize = sw; this.seSize = se; this.name = name; @@ -51,7 +51,7 @@ public enum TileType implements AssetDescription { return BASE_DIR + name; } - public int getyOffset() { + public int getYOffset() { return yOffset; } diff --git a/core/src/cz/nic/tablexia/loader/application/ApplicationInternalTextureManager.java b/core/src/cz/nic/tablexia/loader/application/ApplicationInternalTextureManager.java index d1f87eb3eee618d242a4c7afb18b1b8858aca859..00e14257eb193133f8f15a0faf433d7db6cf89ff 100644 --- a/core/src/cz/nic/tablexia/loader/application/ApplicationInternalTextureManager.java +++ b/core/src/cz/nic/tablexia/loader/application/ApplicationInternalTextureManager.java @@ -32,6 +32,8 @@ public class ApplicationInternalTextureManager extends TablexiaTextureManager { public static final String BUTTON_DISABLED = BUTTON_PATH + "tablexiabutton_disabled" + NINE_PATCH_SUFFIX; public static final String BUTTON_CLOSE_PRESSED = BUTTON_PATH + "closebutton_pressed" + PNG_SUFFIX; public static final String BUTTON_CLOSE_UNPRESSED = BUTTON_PATH + "closebutton_unpressed" + PNG_SUFFIX; + public static final String BUTTON_YES_ICON = BUTTON_PATH + "yes_icon" + PNG_SUFFIX; + public static final String BUTTON_NO_ICON = BUTTON_PATH + "no_icon" + PNG_SUFFIX; public enum InternalNinePatch { @@ -105,5 +107,7 @@ public class ApplicationInternalTextureManager extends TablexiaTextureManager { loadTexture(BUTTON_BLUE_PRESSED); loadTexture(BUTTON_CLOSE_PRESSED); loadTexture(BUTTON_CLOSE_UNPRESSED); + loadTexture(BUTTON_YES_ICON); + loadTexture(BUTTON_NO_ICON); } } diff --git a/core/src/cz/nic/tablexia/menu/main/locale/LocaleSelectBox.java b/core/src/cz/nic/tablexia/menu/main/locale/LocaleSelectBox.java index 9bfc0eccefb2e976b0d42fc04f7de43d09db3fff..ee906b0302e38f24dc668546fe301941deef1ead 100644 --- a/core/src/cz/nic/tablexia/menu/main/locale/LocaleSelectBox.java +++ b/core/src/cz/nic/tablexia/menu/main/locale/LocaleSelectBox.java @@ -71,6 +71,7 @@ public class LocaleSelectBox extends AbstractTablexiaSelectBox<LocaleSelectBox.L public LocaleSelectBox(float itemHeight) { super(itemHeight); ApplicationBus.getInstance().subscribe(this); + setCheckValidity(false); prepareLocales(); } @@ -81,10 +82,12 @@ public class LocaleSelectBox extends AbstractTablexiaSelectBox<LocaleSelectBox.L List<LocaleItem> localeItems = new ArrayList<LocaleItem>(); for (TablexiaSettings.LocaleDefinition localeDefinition: TablexiaSettings.LocaleDefinition.getEnabledLocaleDefinitions()) { LocaleItem localeItem = new LocaleItem(localeDefinition); - localeItems.add(localeItem); if (localeDefinition.equals(TablexiaSettings.getInstance().getLocaleDefinition())) { selectedLocaleItem = localeItem; } + else { + localeItems.add(localeItem); + } } setItems(localeItems.toArray(new LocaleItem[]{})); if (selectedLocaleItem != null) { @@ -93,6 +96,13 @@ public class LocaleSelectBox extends AbstractTablexiaSelectBox<LocaleSelectBox.L addCaptureListener(changeListener); } + @Override + public boolean onSelectBoxItemSelected(LocaleItem item) { + getSelectBoxList().changeToSelected(); + prepareLocales(); + return true; + } + @Override protected void drawSelectedItem(Batch batch, float parentAlpha, LocaleItem selected, float width, float height) { selected.setBounds(getX(), getY(), width, height); diff --git a/core/src/cz/nic/tablexia/menu/main/user/UserSelectBox.java b/core/src/cz/nic/tablexia/menu/main/user/UserSelectBox.java index 6ecc26932496c5d62ac602062eadfc0f77b78daa..193420267bd8d68534bbd6a5a093657fb36fb9fe 100644 --- a/core/src/cz/nic/tablexia/menu/main/user/UserSelectBox.java +++ b/core/src/cz/nic/tablexia/menu/main/user/UserSelectBox.java @@ -69,6 +69,7 @@ public class UserSelectBox extends AbstractTablexiaSelectBox<UserSelectBox.UserS } }; + setCheckValidity(false); prepareActiveUsers(); } @@ -78,12 +79,14 @@ public class UserSelectBox extends AbstractTablexiaSelectBox<UserSelectBox.UserS List<UserSelectBoxItem> userItems = new ArrayList<UserSelectBoxItem>(); for (User user: UserDAO.selectActiveUsers()) { UserMenuSelectBoxItemGroup userItem = new UserMenuSelectBoxItemGroup(new UserMenuItem(user), getWidth()); - userItems.add(userItem); if (user.equals(TablexiaSettings.getInstance().getSelectedUser())) { selectedUserItem = userItem; } + else { + userItems.add(userItem); + } } - userItems.add(new UserMenuNewSelectBoxItemGroup() { + UserMenuNewSelectBoxItemGroup newUserItem = new UserMenuNewSelectBoxItemGroup() { @Override public void performAction() { TablexiaSettings.getInstance().changeUser(null, new TablexiaSettings.LogoutAcceptListener() { @@ -98,11 +101,16 @@ public class UserSelectBox extends AbstractTablexiaSelectBox<UserSelectBox.UserS public User getUser() { return null; } - }); + }; + userItems.add(newUserItem); + setItems(userItems.toArray(new UserSelectBoxItem[]{})); if (selectedUserItem != null) { setSelected(selectedUserItem); } + else { + setSelected(newUserItem); + } addCaptureListener(changeListener); } diff --git a/core/src/cz/nic/tablexia/model/UserDAO.java b/core/src/cz/nic/tablexia/model/UserDAO.java index 4bb471b8f7aeb34028f3911b08f77113f0147ded..1898b43e10671ea9eeba1f8ebfc938c31b805272 100644 --- a/core/src/cz/nic/tablexia/model/UserDAO.java +++ b/core/src/cz/nic/tablexia/model/UserDAO.java @@ -20,6 +20,7 @@ import cz.nic.tablexia.shared.model.Game; import cz.nic.tablexia.shared.model.GamePause; import cz.nic.tablexia.shared.model.Screen; import cz.nic.tablexia.shared.model.User; +import cz.nic.tablexia.shared.model.UserDifficultySettings; import cz.nic.tablexia.util.Log; /** @@ -265,6 +266,12 @@ public class UserDAO { } } + if (user.getDifficultySettings() != null) { + for (UserDifficultySettings setting : user.getDifficultySettings()) { + UserDifficultySettingsDAO.saveSettingsForUser(dbUser.getId(), setting.getGameNumber(), setting.getGameDifficulty()); + } + } + TablexiaStorage.getInstance().commit(); TablexiaStorage.getInstance().setAutoCommit(true); diff --git a/core/src/cz/nic/tablexia/model/UserDifficultySettingsDAO.java b/core/src/cz/nic/tablexia/model/UserDifficultySettingsDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..f0bdf006b38f720883adaa6fc88c62a6250525d8 --- /dev/null +++ b/core/src/cz/nic/tablexia/model/UserDifficultySettingsDAO.java @@ -0,0 +1,83 @@ +package cz.nic.tablexia.model; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import cz.nic.tablexia.TablexiaStorage; +import cz.nic.tablexia.game.difficulty.GameDifficulty; +import cz.nic.tablexia.shared.model.User; +import cz.nic.tablexia.shared.model.UserDifficultySettings; +import cz.nic.tablexia.util.Log; + +/** + * Created by frantisek on 24.3.16. + */ +public class UserDifficultySettingsDAO { + +//////////////////////////// DB ACCESS + + public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS user_difficulty_setting (user_id INTEGER NOT NULL, game_number INTEGER NOT NULL, difficulty_number INTEGER NOT NULL, FOREIGN KEY(user_id) REFERENCES user(id), PRIMARY KEY(user_id, game_number))"; + public static final String SELECT_SETTINGS_FOR_USER = "SELECT game_number, difficulty_number FROM user_difficulty_setting WHERE user_id = ?"; + public static final String SELECT_SETTINGS_FOR_USER_AND_GAME = "SELECT difficulty_number FROM user_difficulty_setting WHERE user_id = ? AND game_number = ?"; + public static final String INSERT_SETTING_FOR_USER = "REPLACE INTO user_difficulty_setting(user_id, game_number, difficulty_number) VALUES (?, ?, ?)"; + + public static List<UserDifficultySettings> getUserSettings(long userId) { + ArrayList<UserDifficultySettings> settings = new ArrayList<UserDifficultySettings>(); + try { + PreparedStatement statement = TablexiaStorage.getInstance().prepareStatement(SELECT_SETTINGS_FOR_USER); + statement.setLong(1, userId); + try { + ResultSet resultSet = statement.executeQuery(); + while (resultSet.next()) { + settings.add(new UserDifficultySettings(userId, resultSet.getInt("game_number"), resultSet.getInt("difficulty_number"))); + } + resultSet.close(); + } catch (SQLException e) { + Log.err(User.class, "Cannot select users game settings from DB!", e); + } + statement.close(); + } catch (SQLException e) { + Log.err(User.class, "Cannot select users game settings from DB!", e); + } + return settings; + } + + public static GameDifficulty getUserSettingsByGame(long userId, int gameNumber) { + GameDifficulty difficulty = GameDifficulty.EASY; + try { + PreparedStatement statement = TablexiaStorage.getInstance().prepareStatement(SELECT_SETTINGS_FOR_USER_AND_GAME); + statement.setLong(1, userId); + statement.setInt(2, gameNumber); + try { + ResultSet resultSet = statement.executeQuery(); + while (resultSet.next()) { + difficulty = GameDifficulty.getGameDifficultyForDifficultyNumber(resultSet.getInt("difficulty_number")); + } + } catch (SQLException e) { + Log.err(User.class, "Cannot select users game settings from DB!", e); + } + statement.close(); + } catch (SQLException e) { + Log.err(User.class, "Cannot select users game settings from DB!", e); + } + + return difficulty; + } + + public static void saveSettingsForUser(long userId, int gameNumber, int difficultyNumber) { + try { + PreparedStatement insertStatement = TablexiaStorage.getInstance().prepareStatement(INSERT_SETTING_FOR_USER); + insertStatement.setLong(1, userId); + insertStatement.setInt(2, gameNumber); + insertStatement.setInt(3, difficultyNumber); + insertStatement.executeUpdate(); + insertStatement.close(); + + } catch (SQLException ex) { + Log.err(UserDifficultySettingsDAO.class, "Cannot insert new user difficulty settings record into DB!", ex); + } + } +} diff --git a/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java b/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java index 4f234f5082eb477b9ac4f85c4836dbc098030bca..41b5287cb611917dfeaa4d59499edbf116092142 100644 --- a/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java +++ b/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java @@ -35,6 +35,8 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; import cz.nic.tablexia.Tablexia; import cz.nic.tablexia.TablexiaApplication; @@ -104,6 +106,8 @@ public class FormScreen extends AbstractTablexiaScreen<Void> { private static final int COMMON_INT_CODE_FOR_ENTER = 13; private static final int ANDROID_INT_CODE_FOR_ENTER = 10; + private static final int TEXT_FIELD_HINT_DELAY = 5000; + public static final String GFX_PATH = "gfx/"; public static final String AVATAR_PATH = GFX_PATH + "avatar/"; public static final String HINT_FINGER_SOUND = "mfx/profil_podpis_prst.mp3"; @@ -118,6 +122,8 @@ public class FormScreen extends AbstractTablexiaScreen<Void> { protected Map<FormValidationEnum, Boolean> validations; protected Set<String> alreadyPlayedHints; private Group mugshots; + private Timer timer; + private boolean timerSet; protected TextField nameField; @@ -197,12 +203,27 @@ public class FormScreen extends AbstractTablexiaScreen<Void> { nameField.setFocusTraversal(false); nameField.setMaxLength(MAX_NAME_LENGTH); + timerSet = false; + nameField.addListener(new InputListener() { @Override public boolean keyTyped(InputEvent event, char character) { - // have to check also (int)character because of some bug in iOS keyboard. It returns code Input.Keys.ENTER for every key after "done" button pressed + + if(timerSet) timer.cancel(); + + // have to check also (int)character because of some bug in iOS keyboard. It returns code Input.Keys.ENTER for every key after "done" button pressed if ((event.getKeyCode() == Input.Keys.ENTER && ((int)character == ANDROID_INT_CODE_FOR_ENTER || (int)character == COMMON_INT_CODE_FOR_ENTER)) || event.getKeyCode() == Input.Keys.TAB) { validate(); + } else { + timer = new Timer(); + timer.schedule(new TimerTask() { + @Override + public void run() { + validate(); + timerSet = false; + } + }, TEXT_FIELD_HINT_DELAY); + timerSet = true; } return false; } diff --git a/core/src/cz/nic/tablexia/screen/createuser/PanoramaScreen.java b/core/src/cz/nic/tablexia/screen/createuser/PanoramaScreen.java index 3c525b293c927195d79f0e3777aea5dca34f2fbe..2b7fff6b40b833bb0e470bde497c5f7027bbdb35 100644 --- a/core/src/cz/nic/tablexia/screen/createuser/PanoramaScreen.java +++ b/core/src/cz/nic/tablexia/screen/createuser/PanoramaScreen.java @@ -42,6 +42,7 @@ import cz.nic.tablexia.util.Point; import cz.nic.tablexia.util.ScaleUtil; import cz.nic.tablexia.util.Utility; import cz.nic.tablexia.util.ui.ComponentScaleUtil; +import cz.nic.tablexia.util.ui.ScrollPaneWithBorders; import cz.nic.tablexia.util.ui.TablexiaNoBlendingImage; import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialog; import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialogFactory; @@ -61,7 +62,7 @@ import cz.nic.tablexia.util.ui.dialog.components.ViewportMaximumSizeComponent; * Screen showing street animation and office before user create form */ public class PanoramaScreen extends AbstractTablexiaScreen<int[][]> { - + private static Vector2 NEWSPAPER_TITLE_POSITION = new Vector2(0.26f, 0.197f); private static Vector2 SIGN_POSITION = new Vector2(0.30f, 0.285f); private static Vector2 PLATE_TITLE_POSITION = new Vector2(0.368f, 0.638f); @@ -77,6 +78,9 @@ public class PanoramaScreen extends AbstractTablexiaScreen<int[][]> { public static final String BALCONY_BLUR = GFX_PATH + "balcony_blur"; public static final String BALCONY_BLUR_WINTER = GFX_PATH + "balcony_blur_winter"; + public static final String SWIPE_OVERSCROLL_RIGHT = GFX_PATH + "swipe/overscroll_right"; + public static final Color SWIPE_OVERSCROLL_LEFT_COLOR = new Color(118/255f, 133/255f, 200/255f, 1); + private static final String NEWSPAPER_DETAIL = "newspaper/detail0"; public static final String SFX_NEWSPAPER_SPINNER = SFX_PATH + "noviny_prilet.mp3"; @@ -91,31 +95,34 @@ public class PanoramaScreen extends AbstractTablexiaScreen<int[][]> { public static final String MUSIC_3 = MFX_PATH + "newspaper/3.mp3"; public static final String MUSIC_4 = MFX_PATH + "newspaper/4.mp3"; - public static final float AMBIENT_SOUND_VOLUME = 0.5f; + public static final float AMBIENT_SOUND_VOLUME = 0.5f; - private static final String AMBIENT_RESTAURANT = MFX_PATH + "ambient/restaurant.mp3"; - private static final String AMBIENT_STREET = MFX_PATH + "ambient/swipe_street.mp3"; + private static final String AMBIENT_RESTAURANT = MFX_PATH + "ambient/restaurant.mp3"; + private static final String AMBIENT_STREET = MFX_PATH + "ambient/swipe_street.mp3"; - private static final int NUMBER_OF_NEWSPAPER_OPEN_FRAMES = 5; - private static final int NUMBER_OF_OFFICE_KNOCKS = 3; - private static final int NUMBER_OF_OFFICE_DIALOGS = 4; + private static final int NUMBER_OF_NEWSPAPER_OPEN_FRAMES = 5; + private static final int NUMBER_OF_OFFICE_KNOCKS = 3; + private static final int NUMBER_OF_OFFICE_DIALOGS = 4; - private static final Vector2 OFFICE_DIALOG_OFFSET = new Vector2(24, 12); - private static final int OFFICE_DIALOG_TEXT_PADDING_LEFT = 4; - private static final int OFFICE_DIALOG_TEXT_PADDING_RIGHT = 24; + private static final float OVERSCROLL_DISTANCE = 50; + private static final float OVERSCROLL_MIN_SPEED = 30; + private static final float OVERSCROLL_MAX_SPEED = 200; - private static final int NEWSPAPERS_SPEECH_DIALOG_OFFSET = 4; - private static final float NEWSPAPERS_SPEECH_DIALOG_OFFSET_MULTI = 0.6f; + private static final Vector2 OFFICE_DIALOG_OFFSET = new Vector2(24, 12); + private static final int OFFICE_DIALOG_TEXT_PADDING_LEFT = 4; + private static final int OFFICE_DIALOG_TEXT_PADDING_RIGHT = 24; - private static final float NEWSPAPER_DETAIL_DIALOG_DIMMER = 0.6f; + private static final int NEWSPAPERS_SPEECH_DIALOG_OFFSET = 4; + private static final float NEWSPAPERS_SPEECH_DIALOG_OFFSET_MULTI = 0.6f; + private static final float NEWSPAPER_DETAIL_DIALOG_DIMMER = 0.6f; - private static final float NEWS_DIALOG_MAX_WIDTH = 0.85f; - private static final float NEWS_DIALOG_MAX_HEIGHT = 0.85f; + private static final float NEWS_DIALOG_MAX_WIDTH = 0.85f; + private static final float NEWS_DIALOG_MAX_HEIGHT = 0.85f; private TextureRegion clickmap; private Group panel; - private ScrollPane scrollpane; + private ScrollPaneWithBorders scrollpane; private Music ambient; private Image leftFinger, rightFinger, hint; @@ -827,10 +834,16 @@ public class PanoramaScreen extends AbstractTablexiaScreen<int[][]> { detectiveDoor.setSize(tile3Background.getWidth(), tile3Background.getHeight()); group.add(detectiveDoor); - scrollpane = new ScrollPane(group); + TablexiaNoBlendingImage leftBorder = new TablexiaNoBlendingImage(ApplicationAtlasManager.getInstance().getColorTexture(SWIPE_OVERSCROLL_LEFT_COLOR)); + leftBorder.setSize(OVERSCROLL_DISTANCE, getSceneInnerHeight()); + + TablexiaNoBlendingImage rightBorder = new TablexiaNoBlendingImage(getScreenTextureRegion(SWIPE_OVERSCROLL_RIGHT)); + rightBorder.setHeight(getSceneInnerHeight()); + + scrollpane = new ScrollPaneWithBorders(group, leftBorder, rightBorder); scrollpane.setFillParent(true); scrollpane.setScrollingDisabled(false, true); - + scrollpane.setupOverscroll(OVERSCROLL_DISTANCE, OVERSCROLL_MIN_SPEED, OVERSCROLL_MAX_SPEED); return scrollpane; } diff --git a/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuAssets.java b/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuAssets.java index 6958c7802a132a26a60ac2d277b5b14749dd42e3..ca13a733a9dbb0f38e1ad8bd82caf91ca5cdb2fe 100644 --- a/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuAssets.java +++ b/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuAssets.java @@ -40,6 +40,9 @@ public final class GameMenuAssets { public static final String BASE_ASSETS_SHOOTING_RANGE = "strelnice"; public static final String BASE_ASSETS_IN_THE_DARKNESS = "potme"; + public static final String LEFT_OVERSCROLL = GFX_PATH + "overscroll_left"; + public static final String RIGHT_OVERSCROLL = GFX_PATH + "overscroll_right"; + public static final String BASE_ASSETS_FOREGROUND_POSTFIX = "fore"; public static final String BASE_ASSETS_MIDDLE_POSTFIX = "mid"; public static final String BASE_ASSETS_BACKGROUND_POSTFIX = "back"; diff --git a/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuScreen.java b/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuScreen.java index c306e9a8bde81d8598a27086b33ee5b967b2b438..116a0143dc6a94f9547f08505307c543a920ebc8 100644 --- a/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuScreen.java +++ b/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuScreen.java @@ -123,7 +123,10 @@ public class GameMenuScreen extends AbstractTablexiaScreen<int[][]> { // /game menu pages list, which will be later used for turning on sounds after first scroll final List<GameMenuPage> gameMenuPages = new ArrayList<GameMenuPage>(); - pagedScrollPane = new PagedScrollPane(); + Image leftBorder = new Image(getScreenTextureRegion(GameMenuAssets.LEFT_OVERSCROLL)); + Image rightBorder = new Image(getScreenTextureRegion(GameMenuAssets.RIGHT_OVERSCROLL)); + + pagedScrollPane = new PagedScrollPane(leftBorder, rightBorder); pagedScrollPane.setBounds(getSceneLeftX(), getSceneOuterBottomY(), getSceneWidth(), getSceneOuterHeight()); vignette = new Image(getScreenPatch(GameMenuAssets.VIGNETTE)); diff --git a/core/src/cz/nic/tablexia/screen/gamemenu/PagedScrollPane.java b/core/src/cz/nic/tablexia/screen/gamemenu/PagedScrollPane.java index d1d30cc51d7b3ea51e2f29bcf3561217f66023a0..c48a065b2fd7ddbc9125a6fa41b4cbc897c4c501 100644 --- a/core/src/cz/nic/tablexia/screen/gamemenu/PagedScrollPane.java +++ b/core/src/cz/nic/tablexia/screen/gamemenu/PagedScrollPane.java @@ -8,9 +8,10 @@ import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputListener; import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup; -import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; +import com.badlogic.gdx.scenes.scene2d.ui.Image; import cz.nic.tablexia.screen.gamemenu.pages.MenuPage; +import cz.nic.tablexia.util.ui.ScrollPaneWithBorders; /** * Represents Horizontal Paged Scroll Pane @@ -18,8 +19,14 @@ import cz.nic.tablexia.screen.gamemenu.pages.MenuPage; * * Created by Drahomir Karchnak on 01/12/15. */ -public class PagedScrollPane extends ScrollPane { - private static final int BACKGROUND_SPACING_WORKAROUND = -1; +public class PagedScrollPane extends ScrollPaneWithBorders { + private static final int BACKGROUND_SPACING_WORKAROUND = -1; + + //TODO - This is overscroll workaround... If you use int distance (like 50) it renders weird gap between menu pages and borders... + private static final float OVERSCROLL_DISTANCE = 49.5f; + private static final float OVERSCROLL_MIN_SPEED = 30f; + private static final float OVERSCROLL_MAX_SPEED = 200f; + private static final int INITIAL_PAGE_NUMBER = GameMenuScreen.GameMenuPageDefinition.OFFICE_PAGE.getPageNumber(); private HorizontalGroup content; @@ -34,8 +41,8 @@ public class PagedScrollPane extends ScrollPane { private int backgroundTotalWidth; - public PagedScrollPane() { - super(null); + public PagedScrollPane(Image leftBorder, Image rightBorder) { + super(null, leftBorder, rightBorder); prepareScrollPane(); prepareInput(); @@ -46,13 +53,14 @@ public class PagedScrollPane extends ScrollPane { * Prepares ScrollPane and it's content */ private void prepareScrollPane() { - content = new HorizontalGroup(); + content = new HorizontalGroup(); content.space(BACKGROUND_SPACING_WORKAROUND); - super.setWidget(content); + super.setWidget(content); setFlingTime(0); setScrollingDisabled(false, true); setCancelTouchFocus(false); + setupOverscroll(OVERSCROLL_DISTANCE, OVERSCROLL_MIN_SPEED, OVERSCROLL_MAX_SPEED); } @Override @@ -93,7 +101,7 @@ public class PagedScrollPane extends ScrollPane { //Is page visible ? if(posX < getWidth() && posX + page.getWidth() > 0) { batch.draw(page.getBackgroundTextureRegion(), - posX, + MathUtils.ceil(posX), getY() + getHeight() - page.getBackgroundTextureRegion().getRegionHeight(), backgroundWidth, page.getBackgroundTextureRegion().getRegionHeight()); diff --git a/core/src/cz/nic/tablexia/screen/gamemenu/pages/GameMenuPage.java b/core/src/cz/nic/tablexia/screen/gamemenu/pages/GameMenuPage.java index f8fa14e5cb6a92617e239ce68876170391888057..7ebc4f838ee0a53305403f94d768c02659a2ab09 100644 --- a/core/src/cz/nic/tablexia/screen/gamemenu/pages/GameMenuPage.java +++ b/core/src/cz/nic/tablexia/screen/gamemenu/pages/GameMenuPage.java @@ -1,5 +1,6 @@ package cz.nic.tablexia.screen.gamemenu.pages; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.Batch; @@ -7,6 +8,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.InputListener; import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction; import com.badlogic.gdx.scenes.scene2d.ui.Image; @@ -14,6 +16,8 @@ import com.badlogic.gdx.scenes.scene2d.ui.Stack; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; +import net.engio.mbassy.listener.Handler; + import cz.nic.tablexia.Tablexia; import cz.nic.tablexia.TablexiaApplication; import cz.nic.tablexia.TablexiaSettings; @@ -21,6 +25,7 @@ import cz.nic.tablexia.bus.ApplicationBus; import cz.nic.tablexia.game.GameDefinition; import cz.nic.tablexia.game.difficulty.GameDifficulty; import cz.nic.tablexia.loader.application.ApplicationFontManager; +import cz.nic.tablexia.model.UserDifficultySettingsDAO; import cz.nic.tablexia.screen.gamemenu.GameMenuAssets; import cz.nic.tablexia.screen.gamemenu.GameMenuScreen; import cz.nic.tablexia.util.MusicUtil; @@ -73,6 +78,8 @@ public class GameMenuPage extends MenuPage { private static final float DIFFICULTY_BAR_EDGE_OFFSET = 14/251f; private static final float INTRO_SOUND_DELAY = 1.0f; //Delay in seconds + + private static final int DRAGGING_THRESHOLD = 20; //Font for difficulty labels private static final ApplicationFontManager.FontType_NEW LABELS_FONT_STYLE = ApplicationFontManager.FontType_NEW.BOLD_18; @@ -96,8 +103,8 @@ public class GameMenuPage extends MenuPage { private Music introSound; - //Can we play the step sounds on difficulty change ? - private boolean stepSoundsReady = false; + //Enabled playing sound steps on difficulty change + private boolean stepSoundsEnabled = false; //Step sounds assets private Music step_easy_medium, step_medium_easy; @@ -131,7 +138,10 @@ public class GameMenuPage extends MenuPage { prepareTitle(); prepareStartButton(); prepareDifficulty(); - } + + // init event bus handlers + ApplicationBus.getInstance().subscribe(this); + } private void prepareBackground() { background = getScreen().getScreenTextureRegion( GameMenuScreen.GameMenuPageDefinition.getResourcePath(game, GameMenuAssets.AssetType.BACK)); @@ -145,8 +155,8 @@ public class GameMenuPage extends MenuPage { private void prepareForegroundLayer() { this.foregroundLayer = getScreen().getScreenTextureRegion( - GameMenuScreen.GameMenuPageDefinition.getResourcePath(game, GameMenuAssets.AssetType.FORE) - ); + GameMenuScreen.GameMenuPageDefinition.getResourcePath(game, GameMenuAssets.AssetType.FORE) + ); } /** @@ -198,8 +208,7 @@ public class GameMenuPage extends MenuPage { TextureRegion startReleased = getScreen().getScreenTextureRegion(GameMenuScreen.GameMenuPageDefinition.getResourcePath(game, GameMenuAssets.AssetType.STARTBUTTON_PRESSED)); TablexiaButton startButton = new TablexiaButton(null, false, startPressed, startReleased, null, null) - .adaptiveSize(true) - .useOnce(true); + .adaptiveSize(true); // Size int startWidth = (int) (getScreen().getSceneWidth() * START_BUTTON_WIDTH); @@ -219,13 +228,35 @@ public class GameMenuPage extends MenuPage { startButton.setSize(startWidth, startHeight); startButton.setPosition(startX, startY); + + startButton.setInputListener(new InputListener(){ + + private boolean dragged; + private float startX; + + @Override + public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { + super.touchDown(event, x, y, pointer, button); + dragged = false; + startX = x; + return true; + } + + @Override + public void touchUp(InputEvent event, float x, float y, int pointer, int button) { + super.touchUp(event, x, y, pointer, button); + if (!dragged){ + ApplicationBus.getInstance().publishAsync(new Tablexia.ChangeScreenEvent(GameMenuPage.this.game.getScreenClass(), + TablexiaApplication.ScreenTransaction.FADE)); + } + } - startButton.setInputListener(new ClickListener() { @Override - public void clicked(InputEvent event, float x, float y) { - ApplicationBus.getInstance().publishAsync(new Tablexia.ChangeScreenEvent(GameMenuPage.this.game.getScreenClass(), - TablexiaApplication.ScreenTransaction.FADE)); - super.clicked(event, x, y); + public void touchDragged(InputEvent event, float x, float y, int pointer) { + super.touchDragged(event, x, y, pointer); + if (Math.abs(startX-x)>DRAGGING_THRESHOLD){ + dragged =true; + } } }); @@ -308,8 +339,7 @@ public class GameMenuPage extends MenuPage { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); - difficultyChanged(GameDifficulty.EASY); - dragSwitchListener.switchToStep(gameDifficulty.getDifficultyNumber() - 1); + dragSwitchListener.switchToStep(GameDifficulty.EASY.getDifficultyNumber() - 1); } }); @@ -317,8 +347,7 @@ public class GameMenuPage extends MenuPage { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); - difficultyChanged(GameDifficulty.MEDIUM); - dragSwitchListener.switchToStep(gameDifficulty.getDifficultyNumber() - 1); + dragSwitchListener.switchToStep(GameDifficulty.MEDIUM.getDifficultyNumber() - 1); } }); @@ -326,8 +355,7 @@ public class GameMenuPage extends MenuPage { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); - difficultyChanged(GameDifficulty.HARD); - dragSwitchListener.switchToStep(gameDifficulty.getDifficultyNumber() - 1); + dragSwitchListener.switchToStep(GameDifficulty.HARD.getDifficultyNumber() - 1); } }); @@ -372,13 +400,10 @@ public class GameMenuPage extends MenuPage { difficulty = GameDifficulty.DEFAULT_DIFFICULTY; } - if(stepSoundsReady) { + if (stepSoundsEnabled) { playStepSound(gameDifficulty, difficulty); - } else { - stepSoundsReady = true; } - difficultyChanged(difficulty); lastDragDifficultyStep = step; } } @@ -391,8 +416,12 @@ public class GameMenuPage extends MenuPage { difficultyChanged(GameDifficulty.getVisibleGameDifficultyList().get(step)); } }); - gameDifficulty = TablexiaSettings.getInstance().getGameDifficulty(game); - dragSwitchListener.switchToStep(gameDifficulty.getDifficultyNumber() - 1); + gameDifficulty = UserDifficultySettingsDAO.getUserSettingsByGame(TablexiaSettings.getInstance().getSelectedUser().getId(), game.getGameNumber()); + //dragSwitchListener.switchToStep(gameDifficulty.getDifficultyNumber() - 1); + dragSwitchListener.switchToStep(gameDifficulty.getDifficultyNumber() - 1, false); + //Enabling step sounds later + //so it doesn't play 'em when initially setting difficulties from database... + stepSoundsEnabled = true; } /** @@ -400,10 +429,15 @@ public class GameMenuPage extends MenuPage { * * @param difficulty */ - public void difficultyChanged(GameDifficulty difficulty) { + public void difficultyChanged(final GameDifficulty difficulty) { gameDifficulty = difficulty; - TablexiaSettings.getInstance().setGameDifficulty(game, difficulty); - } + new Runnable() { + @Override + public void run() { + UserDifficultySettingsDAO.saveSettingsForUser(TablexiaSettings.getInstance().getSelectedUser().getId(), game.getGameNumber(), difficulty.getDifficultyNumber()); + } + }.run(); + } private void playStepSound(GameDifficulty previous, GameDifficulty current) { switch (previous) { @@ -544,4 +578,17 @@ public class GameMenuPage extends MenuPage { public void setIsFirstLogin(boolean isFirstLogin) { this.isFirstLogin = isFirstLogin; } + + @Handler + public void handleSelectedUserEvent(final TablexiaSettings.SelectedUserEvent selectedUserEvent) { + Gdx.app.postRunnable(new Runnable() { + @Override + public void run() { + if (selectedUserEvent.isUserSelected()) { + gameDifficulty = UserDifficultySettingsDAO.getUserSettingsByGame(TablexiaSettings.getInstance().getSelectedUser().getId(), game.getGameNumber()); + dragSwitchListener.switchToStep(gameDifficulty.getDifficultyNumber() - 1); + } + } + }); + } } diff --git a/core/src/cz/nic/tablexia/screen/halloffame/HallOfFameScreen.java b/core/src/cz/nic/tablexia/screen/halloffame/HallOfFameScreen.java index a04f193afad0cbdf7edcdb666ab1466719e4aafe..9407a89267e9da6fbed4fdb1ac2b6ae7d448811d 100644 --- a/core/src/cz/nic/tablexia/screen/halloffame/HallOfFameScreen.java +++ b/core/src/cz/nic/tablexia/screen/halloffame/HallOfFameScreen.java @@ -47,6 +47,7 @@ import cz.nic.tablexia.util.Log; import cz.nic.tablexia.util.Point; import cz.nic.tablexia.util.structure.Trio; import cz.nic.tablexia.util.ui.ComponentScaleUtil; +import cz.nic.tablexia.util.ui.ScrollPaneWithBorders; import cz.nic.tablexia.util.ui.TablexiaLabel; import cz.nic.tablexia.util.ui.TablexiaNoBlendingImage; import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialog; @@ -104,7 +105,7 @@ public class HallOfFameScreen extends AbstractTablexiaScreen<Map<ITrophyDefiniti private Group foregroundGroup; private TablexiaNoBlendingImage wallImage; - private ScrollPane scrollPane; + private ScrollPaneWithBorders scrollPane; @Override protected Viewport createViewport() { @@ -135,41 +136,11 @@ public class HallOfFameScreen extends AbstractTablexiaScreen<Map<ITrophyDefiniti contentStack.setDebug(TablexiaSettings.getInstance().isShowBoundingBoxes()); wallImage = new TablexiaNoBlendingImage(getScreenTextureRegion(HallOfFameAssets.HALL_OF_FAME_WALL)); - wallImage.setVisible(false); - - scrollPane = new ScrollPane(contentStack) { - private float lastScrollX = 0; - - @Override - public void act(float delta) { - super.act(delta); - - if(lastScrollX != getVisualScrollX()) { - lastScrollX = getVisualScrollX(); - - if(isRightEdge()) { - wallImage.setVisible(true); - float posX = getX() + getWidth() - (scrollPane.getVisualScrollX() - (scrollPane.getWidget().getWidth() - scrollPane.getWidth())); - wallImage.setPosition(MathUtils.floor(posX), getY()); - wallImage.setSize(wallImage.getWidth(), scrollPane.getHeight()); - } - else if(isLeftEdge()) { - wallImage.setVisible(true); - float posX = getX() - wallImage.getWidth() - scrollPane.getVisualScrollX(); - wallImage.setPosition(MathUtils.ceil(posX), getY()); - wallImage.setSize(wallImage.getWidth(), scrollPane.getHeight()); - } - else { - wallImage.setVisible(false); - } - } - } - }; + scrollPane = new ScrollPaneWithBorders(contentStack, wallImage); scrollPane.setScrollingDisabled(false, true); scrollPane.setFillParent(true); getStage().addActor(scrollPane); - getStage().addActor(wallImage); if (screenState.containsKey(SCREEN_STATE_SCROLL_POSITION_X)) { scrollPane.pack(); diff --git a/core/src/cz/nic/tablexia/screen/loader/LoadingBar.java b/core/src/cz/nic/tablexia/screen/loader/LoadingBar.java index 7c4efa19fb0a3f215b14a30a94df3b4f667bdd73..653eb98d45d681bca7f0e8eb0b8d041de43b0be6 100644 --- a/core/src/cz/nic/tablexia/screen/loader/LoadingBar.java +++ b/core/src/cz/nic/tablexia/screen/loader/LoadingBar.java @@ -112,7 +112,7 @@ public class LoadingBar extends Actor { } } - current = MathUtils.clamp(current, 0, 1 - IDLE_BAR_WIDTH); + idleCurrent = MathUtils.clamp(idleCurrent, 0, 1 - IDLE_BAR_WIDTH); } } diff --git a/core/src/cz/nic/tablexia/sync/work/PushDataToServer.java b/core/src/cz/nic/tablexia/sync/work/PushDataToServer.java index a6018c627bb6553b7380f413c464ec60d32e1ac3..77eb89efed9b007bafb180292db69f8a43b2e0bf 100644 --- a/core/src/cz/nic/tablexia/sync/work/PushDataToServer.java +++ b/core/src/cz/nic/tablexia/sync/work/PushDataToServer.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.net.HttpStatus; import cz.nic.tablexia.bus.ApplicationBus; import cz.nic.tablexia.model.UserDAO; +import cz.nic.tablexia.model.UserDifficultySettingsDAO; import cz.nic.tablexia.model.game.GameDAO; import cz.nic.tablexia.model.screen.ScreenDAO; import cz.nic.tablexia.shared.model.User; @@ -42,6 +43,7 @@ public class PushDataToServer extends SyncWork { setUser(user); getUser().setGames(GameDAO.selectUsersGamesForSync(user.getId())); getUser().setScreens(ScreenDAO.selectAllScreenForSync(user.getId())); + getUser().setDifficultySettings(UserDifficultySettingsDAO.getUserSettings(user.getId())); this.syncType = syncType; } diff --git a/core/src/cz/nic/tablexia/util/ui/AbstractTablexiaSelectBox.java b/core/src/cz/nic/tablexia/util/ui/AbstractTablexiaSelectBox.java index ac0ca4ac1d47609d1f5cb098aeeabfd7196915a3..7cb258fb9627245b83c377da336af2d987eb46c2 100644 --- a/core/src/cz/nic/tablexia/util/ui/AbstractTablexiaSelectBox.java +++ b/core/src/cz/nic/tablexia/util/ui/AbstractTablexiaSelectBox.java @@ -42,6 +42,7 @@ public abstract class AbstractTablexiaSelectBox<T> extends Widget implements Dis private float prefWidth, prefHeight; private ClickListener clickListener; boolean disabled; + boolean checkValidity = true; public AbstractTablexiaSelectBox(float itemHeight) { setSize(getPrefWidth(), itemHeight); @@ -167,12 +168,17 @@ public abstract class AbstractTablexiaSelectBox<T> extends Widget implements Dis /** Sets the selection to only the passed item, if it is a possible choice, else selects the first item. */ public void setSelected (T item) { - if (items.contains(item, false)) + if (!isCheckValidity()) { selection.set(item); - else if (items.size > 0) - selection.set(items.first()); - else - selection.clear(); + } + else { + if (items.contains(item, false)) + selection.set(item); + else if (items.size > 0) + selection.set(items.first()); + else + selection.clear(); + } } /** @return The index of the first selected item. The top item has an index of 0. Nothing selected has an index of -1. */ @@ -191,6 +197,14 @@ public abstract class AbstractTablexiaSelectBox<T> extends Widget implements Dis this.disabled = disabled; } + public void setCheckValidity(boolean checkValidity) { + this.checkValidity = checkValidity; + } + + public boolean isCheckValidity() { + return checkValidity; + } + public boolean isDisabled () { return disabled; } diff --git a/core/src/cz/nic/tablexia/util/ui/ScrollPaneWithBorders.java b/core/src/cz/nic/tablexia/util/ui/ScrollPaneWithBorders.java new file mode 100644 index 0000000000000000000000000000000000000000..2712ef9ca4efb7bca3f863ce5b5d454dbea3d16d --- /dev/null +++ b/core/src/cz/nic/tablexia/util/ui/ScrollPaneWithBorders.java @@ -0,0 +1,89 @@ +package cz.nic.tablexia.util.ui; + +import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.math.MathUtils; +import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.scenes.scene2d.ui.Image; +import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; + +/** + * Created by drahomir on 4/4/16. + */ +public class ScrollPaneWithBorders extends ScrollPane{ + + private float lastScrollX; + private Image leftBorder, rightBorder; + + private boolean singleBorder = false; + + public ScrollPaneWithBorders(Actor widget, Image border) { + this(widget, border, null); + } + + public ScrollPaneWithBorders(Actor widget, Image leftBorder, Image rightBorder) { + super(widget); + lastScrollX = getVisualScrollX(); + + this.leftBorder = leftBorder; + this.rightBorder = rightBorder; + + leftBorder.setVisible(false); + + if(rightBorder != null) { + rightBorder.setVisible(false); + } + else { + singleBorder = true; + this.rightBorder = leftBorder; + } + } + + @Override + public void act(float delta) { + super.act(delta); + + if(lastScrollX != getVisualScrollX()) { + lastScrollX = getVisualScrollX(); + + if(isRightEdge()) { + rightBorder.setVisible(true); + float posX = getX() + getWidth() - (getVisualScrollX() - (getWidget().getWidth() - getWidth())); + rightBorder.setPosition(MathUtils.floor(posX), getY()); + rightBorder.setSize(rightBorder.getWidth(), getHeight()); + } + else if(isLeftEdge()) { + leftBorder.setVisible(true); + float posX = getX() - leftBorder.getWidth() - getVisualScrollX(); + leftBorder.setPosition(MathUtils.ceil(posX), getY()); + leftBorder.setSize(leftBorder.getWidth(), getHeight()); + } + else { + leftBorder.setVisible(false); + rightBorder.setVisible(false); + } + } + } + + @Override + public void draw(Batch batch, float parentAlpha) { + super.draw(batch, parentAlpha); + + if(getLeftBorder().isVisible()) + getLeftBorder().draw(batch, parentAlpha); + + if(getRightBorder().isVisible()) + getRightBorder().draw(batch, parentAlpha); + } + + public boolean isSingleBorder() { + return singleBorder; + } + + public Image getLeftBorder() { + return leftBorder; + } + + public Image getRightBorder() { + return rightBorder; + } +} diff --git a/core/src/cz/nic/tablexia/util/ui/Switch.java b/core/src/cz/nic/tablexia/util/ui/Switch.java index fc3c4c7a1f2d5323994901629847cedac9c001ef..ab60cc84e1a7b012b87e8e9dc91eb5efcc2a4f60 100644 --- a/core/src/cz/nic/tablexia/util/ui/Switch.java +++ b/core/src/cz/nic/tablexia/util/ui/Switch.java @@ -148,14 +148,19 @@ public class Switch extends Group { return maxX; } - public void switchToStep(int step) { - actor.setX(getX(step)); - if (switchMovedListener != null) { - switchMovedListener.movedToStep(getStep(true)); - } - if (switchSelectedListener != null) { - switchSelectedListener.stepSelected(getStep(true)); - } + + public void switchToStep(int step, boolean triggerEvent) { + actor.setX(getX(step)); + if (switchMovedListener != null && triggerEvent) { + switchMovedListener.movedToStep(getStep(true)); + } + if (switchSelectedListener != null && triggerEvent) { + switchSelectedListener.stepSelected(getStep(true)); + } + } + + public void switchToStep(int step) { + switchToStep(step, true); } private float getClosestValue(boolean useDisabled) { diff --git a/core/src/cz/nic/tablexia/util/ui/button/ImageTablexiaButton.java b/core/src/cz/nic/tablexia/util/ui/button/ImageTablexiaButton.java index 8032d1c059c7e6bd7ba2e98d12c88b296816d835..4e5dbdb4fa889cdc8a957a6fdb093028d78df7c9 100644 --- a/core/src/cz/nic/tablexia/util/ui/button/ImageTablexiaButton.java +++ b/core/src/cz/nic/tablexia/util/ui/button/ImageTablexiaButton.java @@ -2,19 +2,18 @@ package cz.nic.tablexia.util.ui.button; import com.badlogic.gdx.scenes.scene2d.Group; import com.badlogic.gdx.scenes.scene2d.ui.Image; -import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.utils.Align; import cz.nic.tablexia.util.ScaleUtil; +import cz.nic.tablexia.util.ui.TablexiaLabel; /** * Created by frantisek on 18.2.16. */ public class ImageTablexiaButton extends StandardTablexiaButton { - private static final int DEFAULT_ICON_ALIGN = Align.left; - private static final float DEFAULT_IMAGE_HEIGHT_RATIO = 2f / 3; - private static final int IMAGE_CONTENT_SPACING = 10; + private static final float DEFAULT_IMAGE_HEIGHT_RATIO = 2f / 4; + private static final int IMAGE_CONTENT_SPACING = 20; private int iconAlign = DEFAULT_ICON_ALIGN; private final Group ICON_LAYER; @@ -31,9 +30,11 @@ public class ImageTablexiaButton extends StandardTablexiaButton { } public ImageTablexiaButton(String text, Image icon, int align, TablexiaButtonType tablexiaButtonType) { - super(text, tablexiaButtonType); - ICON_LAYER = new Group(); - init(icon, align); + this(text, icon, align, tablexiaButtonType, false); + } + + public ImageTablexiaButton(String text, Image icon, TablexiaButtonType tablexiaButtonType, boolean wrapText) { + this(text, icon, DEFAULT_ICON_ALIGN, tablexiaButtonType, wrapText); } public ImageTablexiaButton(String text, Image icon, int align, TablexiaButtonType tablexiaButtonType, boolean wrapText) { @@ -70,10 +71,10 @@ public class ImageTablexiaButton extends StandardTablexiaButton { ScaleUtil.setImageHeight(icon, getInnerHeight() * DEFAULT_IMAGE_HEIGHT_RATIO); switch (align) { case Align.left: - icon.setX(getActualPatch().getPadLeft() + icon.getWidth() / 2); + icon.setX(getLabel().getX() + ((getLabel().getWidth() - getLabel().getPrefWidth())/2) - icon.getWidth() - IMAGE_CONTENT_SPACING / 2); break; case Align.right: - icon.setX(getActualPatch().getTotalWidth() - getActualPatch().getPadRight() - icon.getWidth() / 2); + icon.setX(getLabel().getX() + getLabel().getWidth() - (getLabel().getWidth() - getLabel().getPrefWidth())/2 + IMAGE_CONTENT_SPACING / 2); break; } icon.setY(getActualPatch().getPadBottom() + (getInnerHeight() - icon.getHeight()) / 2); @@ -98,12 +99,35 @@ public class ImageTablexiaButton extends StandardTablexiaButton { } @Override - protected void prepareTextPosition(Label label) { - super.prepareTextPosition(label); + protected void prepareTextSize(TablexiaLabel label) { + super.prepareTextSize(label); + + float iconWidth = 0; + if (icon != null) { + iconWidth = icon.getWidth(); + } + + label.setWidth(label.getWidth() - iconWidth / 2 - IMAGE_CONTENT_SPACING / 2); + } + + @Override + protected void prepareTextPosition(TablexiaLabel label) { float iconWidth = 0; if (icon != null) { iconWidth = icon.getWidth(); } - label.setPosition(label.getX() + iconWidth, label.getY()); + + switch (iconAlign) { + case Align.left: + label.setPosition(getActualPatch().getPadLeft(), getActualPatch().getPadBottom()); + label.setPosition(label.getX() + iconWidth / 2 + IMAGE_CONTENT_SPACING / 2, label.getY()); + break; + + case Align.right: + label.setPosition(getWidth() - label.getWidth() - getActualPatch().getPadRight(), getActualPatch().getPadBottom()); + label.setPosition(label.getX() - iconWidth / 2 - IMAGE_CONTENT_SPACING / 2, label.getY()); + break; + } + } } diff --git a/core/src/cz/nic/tablexia/util/ui/button/TablexiaButton.java b/core/src/cz/nic/tablexia/util/ui/button/TablexiaButton.java index b0d6afda04a29d3d430ff734e4729eb46e6d773b..38ec65c1acd375a2862f868dced2a75ceb8984df 100644 --- a/core/src/cz/nic/tablexia/util/ui/button/TablexiaButton.java +++ b/core/src/cz/nic/tablexia/util/ui/button/TablexiaButton.java @@ -472,18 +472,18 @@ public class TablexiaButton extends Group { } } - private void setSizeTextLabel(Label label) { + private void setSizeTextLabel(TablexiaLabel label) { if (label != null && actualPatch != null) { - prepareTextPosition(label); prepareTextSize(label); + prepareTextPosition(label); } } - protected void prepareTextPosition(Label label) { + protected void prepareTextPosition(TablexiaLabel label) { label.setPosition(actualPatch.getPadLeft(), actualPatch.getPadBottom()); } - protected void prepareTextSize(Label label) { + protected void prepareTextSize(TablexiaLabel label) { label.setSize(getInnerWidth(), getInnerHeight()); } diff --git a/core/src/cz/nic/tablexia/util/ui/dialog/components/PositiveNegativeButtonContentDialogComponent.java b/core/src/cz/nic/tablexia/util/ui/dialog/components/PositiveNegativeButtonContentDialogComponent.java index b41ed9c46736d56f434209fc2edc7d5bea36fcfc..4921574a0a01cc9effa1b5d7b383fe1f7391b974 100644 --- a/core/src/cz/nic/tablexia/util/ui/dialog/components/PositiveNegativeButtonContentDialogComponent.java +++ b/core/src/cz/nic/tablexia/util/ui/dialog/components/PositiveNegativeButtonContentDialogComponent.java @@ -1,7 +1,9 @@ package cz.nic.tablexia.util.ui.dialog.components; import com.badlogic.gdx.scenes.scene2d.InputListener; +import com.badlogic.gdx.scenes.scene2d.ui.Image; +import cz.nic.tablexia.loader.application.ApplicationInternalTextureManager; import cz.nic.tablexia.loader.application.ApplicationTextManager; import cz.nic.tablexia.util.ui.button.StandardTablexiaButton; @@ -50,6 +52,8 @@ public class PositiveNegativeButtonContentDialogComponent extends TwoButtonConte public PositiveNegativeButtonContentDialogComponent(InputListener yesInputListener, InputListener noInputListener, PositiveNegativeButtonType positiveNegativeButtonType) { super( ApplicationTextManager.getInstance().getText(positiveNegativeButtonType.getNegativeText()), ApplicationTextManager.getInstance().getText(positiveNegativeButtonType.getPositiveText()), + new Image(ApplicationInternalTextureManager.getInstance().getTexture(ApplicationInternalTextureManager.BUTTON_NO_ICON)), + new Image(ApplicationInternalTextureManager.getInstance().getTexture(ApplicationInternalTextureManager.BUTTON_YES_ICON)), StandardTablexiaButton.TablexiaButtonType.RED, StandardTablexiaButton.TablexiaButtonType.GREEN, noInputListener, diff --git a/core/src/cz/nic/tablexia/util/ui/dialog/components/SingleButtonContentDialogComponent.java b/core/src/cz/nic/tablexia/util/ui/dialog/components/SingleButtonContentDialogComponent.java index 6caed0ab4ea7dc9fd8f4244310775d35af5dd2e1..838a929123ea24820a4ec99d252218d3bb41f264 100644 --- a/core/src/cz/nic/tablexia/util/ui/dialog/components/SingleButtonContentDialogComponent.java +++ b/core/src/cz/nic/tablexia/util/ui/dialog/components/SingleButtonContentDialogComponent.java @@ -2,7 +2,9 @@ package cz.nic.tablexia.util.ui.dialog.components; import com.badlogic.gdx.scenes.scene2d.InputListener; import com.badlogic.gdx.scenes.scene2d.ui.Cell; +import com.badlogic.gdx.scenes.scene2d.ui.Image; +import cz.nic.tablexia.util.ui.button.ImageTablexiaButton; import cz.nic.tablexia.util.ui.button.StandardTablexiaButton; import cz.nic.tablexia.util.ui.button.TablexiaButton; @@ -29,10 +31,23 @@ public class SingleButtonContentDialogComponent extends TablexiaDialogComponentA } public SingleButtonContentDialogComponent(String buttonText, boolean wrapText, StandardTablexiaButton.TablexiaButtonType buttonType, InputListener inputListener) { - button = new StandardTablexiaButton(buttonText, buttonType, wrapText) - .adaptiveSizeRatio(DIALOG_BUTTON_ADAPTIVE_SIZE_RATIO) - .adaptiveSize(false); - if (inputListener != null) { + this(new StandardTablexiaButton(buttonText, buttonType, wrapText), inputListener); + } + + public SingleButtonContentDialogComponent(String buttonText, Image buttonIcon, StandardTablexiaButton.TablexiaButtonType buttonType, InputListener inputListener) { + this(new ImageTablexiaButton(buttonText, buttonIcon, buttonType, false), inputListener); + } + + public SingleButtonContentDialogComponent(String buttonText, Image buttonIcon, boolean wrapText, StandardTablexiaButton.TablexiaButtonType buttonType, InputListener inputListener) { + this(new ImageTablexiaButton(buttonText, buttonIcon, buttonType, wrapText), inputListener); + } + + public SingleButtonContentDialogComponent(StandardTablexiaButton button, InputListener inputListener) { + this.button = button; + this.button.adaptiveSizeRatio(DIALOG_BUTTON_ADAPTIVE_SIZE_RATIO); + this.button.adaptiveSize(false); + + if(inputListener != null) { button.setInputListener(inputListener); } } diff --git a/core/src/cz/nic/tablexia/util/ui/dialog/components/TwoButtonContentDialogComponent.java b/core/src/cz/nic/tablexia/util/ui/dialog/components/TwoButtonContentDialogComponent.java index 05c0fe93e20bb52c351bd7bfb42a15fa780db6fe..3bfbf9abefa78f369a7ba173580d5a5ecf69e397 100644 --- a/core/src/cz/nic/tablexia/util/ui/dialog/components/TwoButtonContentDialogComponent.java +++ b/core/src/cz/nic/tablexia/util/ui/dialog/components/TwoButtonContentDialogComponent.java @@ -3,6 +3,7 @@ package cz.nic.tablexia.util.ui.dialog.components; import com.badlogic.gdx.scenes.scene2d.Event; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputListener; +import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import cz.nic.tablexia.util.ui.button.StandardTablexiaButton; @@ -63,4 +64,34 @@ public class TwoButtonContentDialogComponent extends TwoColumnContentDialogCompo firstButton.setInputListener(new DefaultHideListener(firstButtonInput)); secondButton.setInputListener(new DefaultHideListener(secondButtonInput)); } + + public TwoButtonContentDialogComponent(String firstButtonText, + String secondButtonText, + Image firstIcon, + Image secondIcon, + StandardTablexiaButton.TablexiaButtonType firstButtonType, + StandardTablexiaButton.TablexiaButtonType secondButtonType, + InputListener firstButtonInput, + InputListener secondButtonInput) { + + super(SPACE_RATIO); + + //Sets first buttons icon if needed + if(firstIcon != null) + firstButton = new SingleButtonContentDialogComponent(firstButtonText, firstIcon, firstButtonType, firstButtonInput); + else + firstButton = new SingleButtonContentDialogComponent(firstButtonText, firstButtonType, firstButtonInput); + + //Sets second buttons icon if needed + if(secondIcon != null) + secondButton = new SingleButtonContentDialogComponent(secondButtonText, secondIcon, secondButtonType, secondButtonInput); + else + secondButton = new SingleButtonContentDialogComponent(secondButtonText, secondButtonType, secondButtonInput); + + setDialogComponentAdapter1(firstButton); + setDialogComponentAdapter2(secondButton); + + firstButton.setInputListener(new DefaultHideListener(firstButtonInput)); + secondButton.setInputListener(new DefaultHideListener(secondButtonInput)); + } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index b979729db0ad460288cfe16f07072da7b1305e93..b5166dad4d90021f6a0b45268c0755719f1d5cd4 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d10c2e013a9f5154192ccb4c657afdac39d046ae..6a53aa049c9dd36a8940c9077293633a4439ddcc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Jan 09 13:07:45 CET 2015 +#Tue Apr 12 14:42:29 CEST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip diff --git a/ios/build.gradle b/ios/build.gradle index c0de588a8bd2dc89d22fa15190eb46c1d6843ff1..439653e88b471027790c6f09d319fedf8798e9bc 100644 --- a/ios/build.gradle +++ b/ios/build.gradle @@ -4,7 +4,6 @@ sourceCompatibility = '1.7' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' robovm { - ipaArchs = "thumbv7:arm64" iosSkipSigning = false } @@ -91,7 +90,7 @@ tasks.launchIOSDevice.doFirst { updateRoboVMProperties("devel", applicationIdDevel, 'Icon_devel') } -tasks.create(name: "createDebugIPA", type: org.robovm.gradle.tasks.CreateIPATask) { +tasks.create(name: "createDebugIPA", type: org.robovm.gradle.tasks.ArchiveTask) { doFirst { robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY robovm.iosProvisioningProfile = TABLEXIA_IOS_DEBUG_PROVISIONING @@ -99,7 +98,7 @@ tasks.create(name: "createDebugIPA", type: org.robovm.gradle.tasks.CreateIPATask } } -tasks.create(name: "createReleaseIPA", type: org.robovm.gradle.tasks.CreateIPATask) { +tasks.create(name: "createReleaseIPA", type: org.robovm.gradle.tasks.ArchiveTask) { doFirst { robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY robovm.iosProvisioningProfile = TABLEXIA_IOS_RELEASE_PROVISIONING @@ -136,4 +135,4 @@ createReleaseIPA.dependsOn updateRoboVMXML eclipse.project { name = appName + "-ios" natures 'org.robovm.eclipse.RoboVMNature' -} \ No newline at end of file +} diff --git a/wrapperVersion.gradle b/wrapperVersion.gradle new file mode 100644 index 0000000000000000000000000000000000000000..64dea4cf0746f714b066fcc889a15f4e12c21f49 --- /dev/null +++ b/wrapperVersion.gradle @@ -0,0 +1,3 @@ +task wrapper(type: Wrapper) { + gradleVersion = '2.10' +}