From 8979b81bd647c6d650dca44989faa99e653572c2 Mon Sep 17 00:00:00 2001 From: hyst329 Date: Thu, 25 May 2017 22:09:55 +0300 Subject: [PATCH] 0.1.7; removed String.format, Czech locale --- android/assets/i18n/OpenFool.properties | 4 ++- android/assets/i18n/OpenFool_cs.properties | 34 +++++++++++++++++++ android/assets/i18n/OpenFool_en.properties | 4 ++- android/assets/i18n/OpenFool_ru.properties | 4 ++- build.gradle | 4 +-- core/src/ru/hyst329/openfool/Card.kt | 3 +- core/src/ru/hyst329/openfool/CardActor.kt | 6 ++-- core/src/ru/hyst329/openfool/GameScreen.kt | 27 ++++++++------- core/src/ru/hyst329/openfool/OpenFoolGame.kt | 9 ++--- .../src/ru/hyst329/openfool/SettingsScreen.kt | 15 ++++++-- gradlew | 0 11 files changed, 78 insertions(+), 32 deletions(-) create mode 100644 android/assets/i18n/OpenFool_cs.properties mode change 100644 => 100755 gradlew diff --git a/android/assets/i18n/OpenFool.properties b/android/assets/i18n/OpenFool.properties index 0a5172a..ed5c69f 100644 --- a/android/assets/i18n/OpenFool.properties +++ b/android/assets/i18n/OpenFool.properties @@ -11,8 +11,9 @@ CardsFrench=French Language=Language: LanguageRussian=Russian LanguageEnglish=English +LanguageCzech=Czech VictoryHeader=Victory! -VictoryText= +VictoryText=Your team has defeated the opponents! DefeatHeader=Defeat :( DefeatText=Your team has lost the game. PartnerDefeatHeader=Still a defeat... @@ -30,3 +31,4 @@ YourTurn=Your turn! Defend=Defend! PlayerTakes=I take PlayerDone=Done +PlayerNames=Player Names diff --git a/android/assets/i18n/OpenFool_cs.properties b/android/assets/i18n/OpenFool_cs.properties new file mode 100644 index 0000000..f3e6206 --- /dev/null +++ b/android/assets/i18n/OpenFool_cs.properties @@ -0,0 +1,34 @@ +NewGame=Nová hra +Settings=Nastavení +LoadingAssets=Načítání zdrojů {0}% +Quit=Opustit +ChangeBackgroundColor=Změnit barvu pozadí +SaveSettings=Uložit +Cards=Karty: +CardsRussian=Ruské +CardsInternational=Mezinárodní +CardsFrench=Francouzské +Language=Jazyk: +LanguageRussian=Ruština +LanguageEnglish=Angličtina +LanguageCzech=Čeština +VictoryHeader=Výhra! +DefeatHeader=Prohra :( +PartnerDefeatHeader=To je ještě prohra... +DrawHeader=Remíza. +SortingUnsorted=Bez třídění +SortingSuitAscending=Podle barvy, vzestupně +SortingSuitDescending=Podle barvy, sestupně +SortingRankAscending=Podle hodnoty, vzestupně +SortingRankDescending=Podle hodnoty, sestupně +Background=Pozadí: +YourTurn=Řada je na vás! +Defend=Přebíjejte! +PlayerTakes=Beru +PlayerDone=Bito +PlayerNames=Jména hráčů +VictoryText=Vaš tým porazil protihráčů! +DefeatText=Vaš tým prohrál. +PartnerDefeatText=Jste dosáhli konce hry, ale vaš spoluhráč není. +DrawText=Vaš tým a protihráče dosáhli remízy. +Sorting=Třídění karet: \ No newline at end of file diff --git a/android/assets/i18n/OpenFool_en.properties b/android/assets/i18n/OpenFool_en.properties index 7cf70fd..ccca4e9 100644 --- a/android/assets/i18n/OpenFool_en.properties +++ b/android/assets/i18n/OpenFool_en.properties @@ -29,4 +29,6 @@ SortingRankDescending=By rank, ascending Background=Background: YourTurn=Your turn! Defend=Defend! -PlayerDone=Done \ No newline at end of file +PlayerDone=Done +PlayerNames=Player Names +LanguageCzech=Czech \ No newline at end of file diff --git a/android/assets/i18n/OpenFool_ru.properties b/android/assets/i18n/OpenFool_ru.properties index 6faf64f..de5ebf3 100644 --- a/android/assets/i18n/OpenFool_ru.properties +++ b/android/assets/i18n/OpenFool_ru.properties @@ -29,4 +29,6 @@ SortingRankDescending=По рангу (убыв.) Background=Фон: YourTurn=Ваш ход! Defend=Отбивайтесь! -PlayerDone=Бито \ No newline at end of file +PlayerDone=Бито +PlayerNames=Имена игроков +LanguageCzech=Чешский \ No newline at end of file diff --git a/build.gradle b/build.gradle index 13853c8..518f96f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlinVersion = '1.1.1' + ext.kotlinVersion = '1.1.2-2' repositories { mavenLocal() @@ -19,7 +19,7 @@ allprojects { apply plugin: "eclipse" apply plugin: "idea" - version = '0.1.6' + version = '0.1.7' ext { appName = "OpenFool" gdxVersion = '1.9.6' diff --git a/core/src/ru/hyst329/openfool/Card.kt b/core/src/ru/hyst329/openfool/Card.kt index 51a8c0c..e6d4361 100644 --- a/core/src/ru/hyst329/openfool/Card.kt +++ b/core/src/ru/hyst329/openfool/Card.kt @@ -14,7 +14,6 @@ class Card(internal val suit: Suit, internal val rank: Rank) { } override fun toString(): String { - return String.format(Locale.ENGLISH, "%d%c", rank.value, - suit.name.toLowerCase()[0]) + return "${rank.value}${suit.name.toLowerCase()[0]}" } } diff --git a/core/src/ru/hyst329/openfool/CardActor.kt b/core/src/ru/hyst329/openfool/CardActor.kt index 1b7f679..df3c2d8 100644 --- a/core/src/ru/hyst329/openfool/CardActor.kt +++ b/core/src/ru/hyst329/openfool/CardActor.kt @@ -12,12 +12,10 @@ import com.badlogic.gdx.scenes.scene2d.Actor internal class CardActor(game: OpenFoolGame, val card: Card, deckStyle: String) : Actor() { var isFaceUp: Boolean = false - private val face: Sprite - private val back: Sprite + private val face: Sprite = Sprite(game.assetManager.get("decks/$deckStyle/$card.png", Texture::class.java)) + private val back: Sprite = Sprite(game.assetManager.get("decks/$deckStyle/back.png", Texture::class.java)) init { - this.face = Sprite(game.assetManager.get(String.format("decks/%s/%s.png", deckStyle, card), Texture::class.java)) - this.back = Sprite(game.assetManager.get(String.format("decks/%s/back.png", deckStyle), Texture::class.java)) setSize(face.width, face.height) face.setOrigin(face.width / 2, face.height / 2) back.setOrigin(back.width / 2, back.height / 2) diff --git a/core/src/ru/hyst329/openfool/GameScreen.kt b/core/src/ru/hyst329/openfool/GameScreen.kt index 852e0c2..3e6f2a0 100644 --- a/core/src/ru/hyst329/openfool/GameScreen.kt +++ b/core/src/ru/hyst329/openfool/GameScreen.kt @@ -93,15 +93,15 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener { private var oldGameState = FINISHED private val sortingMode: Player.SortingMode private var throwLimit = DEAL_LIMIT - private var playerDoneStatuses = Array(PLAYER_COUNT, {i -> false}) + private var playerDoneStatuses = Array(PLAYER_COUNT, { i -> false }) init { // Initialise the stage Gdx.input.inputProcessor = stage // Get background color backgroundColor = Color(game.preferences.getInteger(SettingsScreen.BACKGROUND_COLOR, 0x33cc4dff)) - background = game.assetManager.get(String.format(Locale.ENGLISH, "backgrounds/background%d.png", - game.preferences.getInteger(SettingsScreen.BACKGROUND, 1)), Texture::class.java) + val backgroundNo = game.preferences.getInteger(SettingsScreen.BACKGROUND, 1) + background = game.assetManager.get("backgrounds/background$backgroundNo.png", Texture::class.java) background.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat) //background. val deckStyle = game.preferences.getString(SettingsScreen.DECK, "rus") @@ -199,7 +199,7 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener { trump?.isFaceUp = true trump?.moveBy(90 * CARD_SCALE_TABLE, 0f) trumpSuit = trumpCard!!.suit - println(String.format("Trump suit is %s", trumpSuit.toString())) + println("Trump suit is ${trumpSuit.toString()}") // Draw cards for (i in 0..PLAYER_COUNT - 1) { drawCardsToPlayer(i, DEAL_LIMIT) @@ -235,8 +235,9 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener { } })) } - println(String.format("%s (%s) has the lowest trump %s", - players[firstAttacker].name, players[firstAttacker].index, lowestTrump)) + println(players[firstAttacker].name + + " (${players[firstAttacker].index})" + + " has the lowest trump $lowestTrump") currentAttackerIndex = firstAttacker currentThrowerIndex = firstAttacker } @@ -320,7 +321,7 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener { if (i > 0) position[0] += ((i - 1) * 640 / (PLAYER_COUNT - 2)).toFloat() position[1] += 640 * if (i == 0) CARD_SCALE_PLAYER else CARD_SCALE_AI - var playerFormat = String.format("%s: %s ", players[i].name, players[i].hand.size) + var playerFormat = "${players[i].name}: ${players[i].hand.size}" if (playerDoneStatuses[i]) playerFormat += game.localeBundle["PlayerDone"] if (isPlayerTaking && currentDefender.index == i) playerFormat += game.localeBundle["PlayerTakes"] @@ -328,8 +329,8 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener { position[0], position[1]) } - game.font.draw(game.batch, String.format("%s %s", trumpSuit, cardsRemaining()), 20f, 160f) - var turnString = String.format("%s -> %s", currentAttacker.name, currentDefender.name) + game.font.draw(game.batch, "$trumpSuit ${cardsRemaining()}", 20f, 160f) + var turnString = "${currentAttacker.name} -> ${currentDefender.name}" if (currentAttacker.index == 0) turnString += "\n" + game.localeBundle["YourTurn"] if (currentDefender.index == 0) @@ -368,7 +369,7 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener { private fun endTurn(playerIndex: Int) { playersSaidDone = 0 - playerDoneStatuses = Array(PLAYER_COUNT, {i -> false}) + playerDoneStatuses = Array(PLAYER_COUNT, { i -> false }) val tableCards = ArrayList() for (i in attackCards.indices) { if (attackCards[i] != null) { @@ -451,7 +452,7 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener { if (event is Player.CardThrownEvent) { // Handle when card is thrown playersSaidDone = 0 - playerDoneStatuses = Array(PLAYER_COUNT, {i -> false}) + playerDoneStatuses = Array(PLAYER_COUNT, { i -> false }) var throwIndex = 0 while (attackCards[throwIndex] != null) throwIndex++ val throwCard = event.card @@ -489,7 +490,7 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener { if (event is Player.CardBeatenEvent) { // Handle when card is beaten playersSaidDone = 0 - playerDoneStatuses = Array(PLAYER_COUNT, {i -> false}) + playerDoneStatuses = Array(PLAYER_COUNT, { i -> false }) var beatIndex = 0 while (defenseCards[beatIndex] != null) beatIndex++ val beatCard = event.card @@ -527,7 +528,7 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener { if (event is Player.TakeEvent) { // Handle when player takes playersSaidDone = 0 - playerDoneStatuses = Array(PLAYER_COUNT, {i -> false}) + playerDoneStatuses = Array(PLAYER_COUNT, { i -> false }) isPlayerTaking = true val player = event.getTarget() as Player System.out.printf("%s (%s) decides to take\n", diff --git a/core/src/ru/hyst329/openfool/OpenFoolGame.kt b/core/src/ru/hyst329/openfool/OpenFoolGame.kt index a6c72e2..71b7ea3 100644 --- a/core/src/ru/hyst329/openfool/OpenFoolGame.kt +++ b/core/src/ru/hyst329/openfool/OpenFoolGame.kt @@ -54,16 +54,13 @@ class OpenFoolGame : Game() { for (d in decks) { for (i in 1..13) { for (s in suits.toCharArray()) { - assetManager.load(String.format(Locale.ENGLISH, "decks/%s/%d%s.png", d, i, s), - Texture::class.java, param) + assetManager.load("decks/$d/$i$s.png", Texture::class.java, param) } } - assetManager.load(String.format(Locale.ENGLISH, "decks/%s/back.png", d), - Texture::class.java, param) + assetManager.load("decks/$d/back.png", Texture::class.java, param) } for (i in 1..2) { - assetManager.load(String.format(Locale.ENGLISH, "backgrounds/background%d.png", i), - Texture::class.java, param) + assetManager.load("backgrounds/background$i.png", Texture::class.java, param) } this.setScreen(MainMenuScreen(this)) } diff --git a/core/src/ru/hyst329/openfool/SettingsScreen.kt b/core/src/ru/hyst329/openfool/SettingsScreen.kt index cbc9656..d419349 100644 --- a/core/src/ru/hyst329/openfool/SettingsScreen.kt +++ b/core/src/ru/hyst329/openfool/SettingsScreen.kt @@ -63,6 +63,7 @@ internal class SettingsScreen(private val game: OpenFoolGame) : Screen { LANGUAGES = HashMap() LANGUAGES.put(game.localeBundle.get("LanguageRussian"), "ru") LANGUAGES.put(game.localeBundle.get("LanguageEnglish"), "en") + LANGUAGES.put(game.localeBundle.get("LanguageCzech"), "cs") // Initialise SORTING_MODES val SORTING_MODES = ArrayList() SORTING_MODES.add(game.localeBundle.get("SortingUnsorted")) @@ -87,7 +88,7 @@ internal class SettingsScreen(private val game: OpenFoolGame) : Screen { }) val changeColorButton = VisTextButton(game.localeBundle.get("ChangeBackgroundColor")) - changeColorButton.setBounds(40f, 300f, 250f, 80f) + changeColorButton.setBounds(40f, 350f, 250f, 80f) changeColorButton.addListener(object : ClickListener() { override fun clicked(event: InputEvent?, x: Float, y: Float) { // super.clicked(event, x, y); @@ -97,7 +98,7 @@ internal class SettingsScreen(private val game: OpenFoolGame) : Screen { }) stage.addActor(changeColorButton) val saveButton = VisTextButton(game.localeBundle.get("SaveSettings")) - saveButton.setBounds(40f, 200f, 250f, 80f) + saveButton.setBounds(40f, 250f, 250f, 80f) saveButton.addListener(object : ClickListener() { override fun clicked(event: InputEvent?, x: Float, y: Float) { // super.clicked(event, x, y); @@ -106,6 +107,16 @@ internal class SettingsScreen(private val game: OpenFoolGame) : Screen { } }) stage.addActor(saveButton) + val playerNamesButton = VisTextButton(game.localeBundle.get("PlayerNames")) + playerNamesButton.setBounds(40f, 150f, 250f, 80f) + playerNamesButton.addListener(object : ClickListener() { + override fun clicked(event: InputEvent?, x: Float, y: Float) { + // super.clicked(event, x, y); + // TODO: Add real player name selection + + } + }) + stage.addActor(playerNamesButton) val backgroundSelectLabel = VisLabel(game.localeBundle.get("Background")) backgroundSelectLabel.setBounds(420f, 250f, 60f, 40f) stage.addActor(backgroundSelectLabel) diff --git a/gradlew b/gradlew old mode 100644 new mode 100755