diff --git a/android/Images/UnitIcons/Bowman.png b/android/Images/UnitIcons/Bowman.png index fe9ae38ad5..c62eec5aab 100644 Binary files a/android/Images/UnitIcons/Bowman.png and b/android/Images/UnitIcons/Bowman.png differ diff --git a/android/assets/game.png b/android/assets/game.png index 50b330d28e..8c6dc9cb8b 100644 Binary files a/android/assets/game.png and b/android/assets/game.png differ diff --git a/build.gradle b/build.gradle index e72a908138..aa0a6a74ca 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,6 @@ buildscript { ext.kotlinVersion = '1.3.50' - repositories { // Chinese mirrors for quicker loading for chinese devs maven{ url 'https://maven.aliyun.com/repository/jcenter'} @@ -14,6 +13,7 @@ buildscript { mavenCentral() maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } jcenter() + } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" @@ -49,6 +49,7 @@ allprojects { mavenCentral() maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url "https://oss.sonatype.org/content/repositories/releases/" } + maven{ url 'https://jitpack.io' } // for java-discord-rpc } } @@ -63,9 +64,10 @@ project(":desktop") { implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop" implementation "com.badlogicgames.gdx:gdx-tools:$gdxVersion" // This is for the TexturePacker class - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" - } + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" // This iss so the JAR works with Kotlin + implementation 'com.github.MinnDevelopment:java-discord-rpc:v2.0.1' + } } diff --git a/core/src/com/unciv/UnCivGame.kt b/core/src/com/unciv/UnCivGame.kt index 87ff1091fb..05a59cbf96 100644 --- a/core/src/com/unciv/UnCivGame.kt +++ b/core/src/com/unciv/UnCivGame.kt @@ -34,6 +34,7 @@ class UnCivGame(val version: String) : Game() { var music : Music? =null val musicLocation = "music/thatched-villagers.mp3" + var isInitialized=false override fun create() { Current = this @@ -58,6 +59,7 @@ class UnCivGame(val version: String) : Game() { else setScreen(LanguagePickerScreen()) thread { startMusic() } + isInitialized=true } fun startMusic(){ diff --git a/desktop/src/com/unciv/app/desktop/DesktopLauncher.java b/desktop/src/com/unciv/app/desktop/DesktopLauncher.java deleted file mode 100644 index c4fea5e47b..0000000000 --- a/desktop/src/com/unciv/app/desktop/DesktopLauncher.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.unciv.app.desktop; - -import com.badlogic.gdx.Files; -import com.badlogic.gdx.backends.lwjgl.LwjglApplication; -import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.tools.texturepacker.TexturePacker; -import com.unciv.UnCivGame; - -import java.io.File; - -class DesktopLauncher { - public static void main (String[] arg) { - - if (new File("../Images").exists()) { // So we don't run this from within a fat JAR - TexturePacker.Settings settings = new TexturePacker.Settings(); - // Apparently some chipsets, like NVIDIA Tegra 3 graphics chipset (used in Asus TF700T tablet), - // don't support non-power-of-two texture sizes - kudos @yuroller! - // https://github.com/yairm210/UnCiv/issues/1340 - settings.maxWidth = 2048; - settings.maxHeight = 2048; - settings.combineSubdirectories = true; - settings.pot = true; - settings.fast = true; - - // This is so they don't look all pixelated - settings.filterMag = Texture.TextureFilter.MipMapLinearLinear; - settings.filterMin = Texture.TextureFilter.MipMapLinearLinear; - TexturePacker.process(settings, "../Images", ".", "game"); - } - - LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); - config.addIcon("ExtraImages/Icon.png", Files.FileType.Internal); - config.title="Unciv"; - new LwjglApplication(new UnCivGame("Desktop"), config); - } -} diff --git a/desktop/src/com/unciv/app/desktop/DesktopLauncher.kt b/desktop/src/com/unciv/app/desktop/DesktopLauncher.kt new file mode 100644 index 0000000000..b9a4c53771 --- /dev/null +++ b/desktop/src/com/unciv/app/desktop/DesktopLauncher.kt @@ -0,0 +1,72 @@ +package com.unciv.app.desktop + +import club.minnced.discord.rpc.DiscordEventHandlers +import club.minnced.discord.rpc.DiscordRPC +import club.minnced.discord.rpc.DiscordRichPresence +import com.badlogic.gdx.Files +import com.badlogic.gdx.backends.lwjgl.LwjglApplication +import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration +import com.badlogic.gdx.graphics.Texture +import com.badlogic.gdx.tools.texturepacker.TexturePacker +import com.unciv.UnCivGame +import com.unciv.models.gamebasics.tr +import java.io.File +import kotlin.concurrent.thread + +internal object DesktopLauncher { + @JvmStatic + fun main(arg: Array) { + + if (File("../Images").exists()) { // So we don't run this from within a fat JAR + val settings = TexturePacker.Settings() + // Apparently some chipsets, like NVIDIA Tegra 3 graphics chipset (used in Asus TF700T tablet), + // don't support non-power-of-two texture sizes - kudos @yuroller! + // https://github.com/yairm210/UnCiv/issues/1340 + settings.maxWidth = 2048 + settings.maxHeight = 2048 + settings.combineSubdirectories = true + settings.pot = true + settings.fast = true + + // This is so they don't look all pixelated + settings.filterMag = Texture.TextureFilter.MipMapLinearLinear + settings.filterMin = Texture.TextureFilter.MipMapLinearLinear + TexturePacker.process(settings, "../Images", ".", "game") + } + + val config = LwjglApplicationConfiguration() + config.addIcon("ExtraImages/Icon.png", Files.FileType.Internal) + config.title = "Unciv" + + + val game = UnCivGame("Desktop") + + try { + val handlers = DiscordEventHandlers() + DiscordRPC.INSTANCE.Discord_Initialize("647066573147996161", handlers, true, null) + + Runtime.getRuntime().addShutdownHook(Thread { DiscordRPC.INSTANCE.Discord_Shutdown() }) + + thread { + while(true){ + updateRpc(game) + Thread.sleep(1000) + } + } + } catch (ex: Exception) { + print("Could not initialize Discord") + } + + LwjglApplication(game, config) + } + + fun updateRpc(game: UnCivGame) { + if(!game.isInitialized) return + val presence = DiscordRichPresence() + val currentPlayerCiv = game.gameInfo.getCurrentPlayerCivilization() + presence.details=currentPlayerCiv.getTranslatedNation().getLeaderDisplayName().tr() + presence.largeImageKey = "logo" // The actual image is uploaded to the discord app / applications webpage + presence.largeImageText ="Turn".tr()+" " + currentPlayerCiv.gameInfo.turns + DiscordRPC.INSTANCE.Discord_UpdatePresence(presence); + } +}