Discord RPC now works from Desktop .Jar!

This commit is contained in:
Yair Morgenstern 2019-11-21 23:01:38 +02:00
parent e0219036f6
commit 4844a98af1
6 changed files with 23 additions and 19 deletions

View file

@ -5,6 +5,7 @@ sourceSets.main.java.srcDirs = [ "src/" ]
project.ext.mainClassName = "com.unciv.app.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../android/assets")
project.ext.discordDir = new File("discord_rpc")
task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
@ -29,6 +30,8 @@ task dist(type: Jar) {
// see Laurent1967's comment on https://github.com/libgdx/libgdx/issues/5491
from {configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }}
from files(project.assetsDir)
// This is for the .dll and .so files to ake the Discord RPC work on all desktops
from files(project.discordDir)
archiveFileName = "${appName}.jar"
manifest {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -16,36 +16,37 @@ import kotlin.concurrent.thread
internal object DesktopLauncher {
@JvmStatic
fun main(arg: Array<String>) {
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")
}
if (File("../Images").exists()) // So we don't run this from within a fat JAR
packImages()
val config = LwjglApplicationConfiguration()
config.addIcon("ExtraImages/Icon.png", Files.FileType.Internal)
config.title = "Unciv"
val game = UnCivGame("Desktop")
// tryActivateDiscord(game) // Deactivated until we can figure out how to make it work from the .jar
tryActivateDiscord(game)
LwjglApplication(game, config)
}
private fun packImages() {
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")
}
private fun tryActivateDiscord(game: UnCivGame) {
try {
val handlers = DiscordEventHandlers()