mirror of
https://github.com/yairm210/Unciv.git
synced 2024-12-23 01:34:25 +07:00
Upgrading to LWJGL 3, which is now the default, as of LibGDX 1.10.1 (#5614)
* Upgrading to LWJGL 3, which is now the default, as of LibGDX 1.10.1 MacOS running problem solved by adding JVM args to desktop build.gradle Should resolve #5601 * Apparently, keyTyped is ONLY for character keys. Esc and f12 are non-character keys, so we need to change from keyTyped to keyDown. How does this affect out ctrl combinations? Dunno yet :) I couldn't find any actual uses in code, but it shouldn't be worse than keyTyped This commit can be cherry-picked into the master branch as a preparation for the move to lwjgl3
This commit is contained in:
parent
118f11abb1
commit
a1e0b686b1
@ -62,10 +62,12 @@ project(":desktop") {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
"implementation"(project(":core"))
|
"implementation"(project(":core"))
|
||||||
"implementation"("com.badlogicgames.gdx:gdx-backend-lwjgl:${gdxVersion}")
|
"implementation"("com.badlogicgames.gdx:gdx-backend-lwjgl3:${gdxVersion}")
|
||||||
"implementation"("com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop")
|
"implementation"("com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop")
|
||||||
|
|
||||||
"implementation"("com.badlogicgames.gdx:gdx-tools:$gdxVersion") // This is for the TexturePacker class
|
"implementation"("com.badlogicgames.gdx:gdx-tools:$gdxVersion") {
|
||||||
|
exclude("com.badlogicgames.gdx", "gdx-backend-lwjgl")
|
||||||
|
}
|
||||||
|
|
||||||
"implementation"("com.github.MinnDevelopment:java-discord-rpc:v2.0.1")
|
"implementation"("com.github.MinnDevelopment:java-discord-rpc:v2.0.1")
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ Allow unit movement after unit automation steps
|
|||||||
|
|
||||||
By SimonCeder:
|
By SimonCeder:
|
||||||
- Barbarian units
|
- Barbarian units
|
||||||
- Fix for broken saves in #5573
|
|
||||||
- Barbarian fixes
|
- Barbarian fixes
|
||||||
|
|
||||||
By SomeTroglodyte:
|
By SomeTroglodyte:
|
||||||
|
@ -167,13 +167,17 @@ class KeyPressDispatcher(val name: String? = null) : HashMap<KeyCharAndCode, (()
|
|||||||
if (installStage != null) uninstall()
|
if (installStage != null) uninstall()
|
||||||
listener =
|
listener =
|
||||||
object : InputListener() {
|
object : InputListener() {
|
||||||
override fun keyTyped(event: InputEvent?, character: Char): Boolean {
|
override fun keyDown(event: InputEvent?, keycode: Int): Boolean {
|
||||||
|
/*
|
||||||
|
: Boolean {
|
||||||
|
return super.keyDown(event, keycode)
|
||||||
|
}(event: InputEvent?, character: Char)
|
||||||
|
*/
|
||||||
|
|
||||||
// look for both key code and ascii entries - ascii first as the
|
// look for both key code and ascii entries - ascii first as the
|
||||||
// Char constructor of KeyCharAndCode generates keyCode based instances
|
// Char constructor of KeyCharAndCode generates keyCode based instances
|
||||||
// preferentially but we would miss Ctrl- combos otherwise
|
// preferentially but we would miss Ctrl- combos otherwise
|
||||||
val key = when {
|
val key = when {
|
||||||
contains(KeyCharAndCode.ascii(character)) ->
|
|
||||||
KeyCharAndCode.ascii(character)
|
|
||||||
event == null ->
|
event == null ->
|
||||||
KeyCharAndCode.UNKNOWN
|
KeyCharAndCode.UNKNOWN
|
||||||
else ->
|
else ->
|
||||||
@ -182,7 +186,7 @@ class KeyPressDispatcher(val name: String? = null) : HashMap<KeyCharAndCode, (()
|
|||||||
|
|
||||||
// see if we want to handle this key, and if not, let it propagate
|
// see if we want to handle this key, and if not, let it propagate
|
||||||
if (!contains(key) || (checkIgnoreKeys?.invoke() == true))
|
if (!contains(key) || (checkIgnoreKeys?.invoke() == true))
|
||||||
return super.keyTyped(event, character)
|
return super.keyDown(event, keycode)
|
||||||
|
|
||||||
// try-catch mainly for debugging. Breakpoints in the vicinity can make the event fire twice in rapid succession, second time the context can be invalid
|
// try-catch mainly for debugging. Breakpoints in the vicinity can make the event fire twice in rapid succession, second time the context can be invalid
|
||||||
try {
|
try {
|
||||||
|
@ -2,7 +2,6 @@ import com.badlogicgames.packr.Packr
|
|||||||
import com.badlogicgames.packr.PackrConfig
|
import com.badlogicgames.packr.PackrConfig
|
||||||
import com.unciv.build.BuildConfig
|
import com.unciv.build.BuildConfig
|
||||||
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("kotlin")
|
id("kotlin")
|
||||||
}
|
}
|
||||||
@ -23,6 +22,9 @@ val discordDir = file("discord_rpc")
|
|||||||
val deployFolder = file("../deploy")
|
val deployFolder = file("../deploy")
|
||||||
|
|
||||||
tasks.register<JavaExec>("run") {
|
tasks.register<JavaExec>("run") {
|
||||||
|
|
||||||
|
jvmArgs = listOf("-XstartOnFirstThread") // See https://github.com/libgdx/libgdx/wiki/Starter-classes-and-configuration#common-issues
|
||||||
|
|
||||||
dependsOn(tasks.getByName("classes"))
|
dependsOn(tasks.getByName("classes"))
|
||||||
|
|
||||||
main = mainClassName
|
main = mainClassName
|
||||||
|
@ -3,10 +3,10 @@ package com.unciv.app.desktop
|
|||||||
import club.minnced.discord.rpc.DiscordEventHandlers
|
import club.minnced.discord.rpc.DiscordEventHandlers
|
||||||
import club.minnced.discord.rpc.DiscordRPC
|
import club.minnced.discord.rpc.DiscordRPC
|
||||||
import club.minnced.discord.rpc.DiscordRichPresence
|
import club.minnced.discord.rpc.DiscordRichPresence
|
||||||
import com.badlogic.gdx.Files
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration
|
|
||||||
import com.badlogic.gdx.files.FileHandle
|
import com.badlogic.gdx.files.FileHandle
|
||||||
|
import com.badlogic.gdx.graphics.glutils.HdpiMode
|
||||||
import com.sun.jna.Native
|
import com.sun.jna.Native
|
||||||
import com.unciv.JsonParser
|
import com.unciv.JsonParser
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
@ -29,15 +29,16 @@ internal object DesktopLauncher {
|
|||||||
|
|
||||||
ImagePacker.packImages()
|
ImagePacker.packImages()
|
||||||
|
|
||||||
val config = LwjglApplicationConfiguration()
|
val config = Lwjgl3ApplicationConfiguration()
|
||||||
// Don't activate GL 3.0 because it causes problems for MacOS computers
|
config.setWindowIcon( "ExtraImages/Icon.png")
|
||||||
config.addIcon("ExtraImages/Icon.png", Files.FileType.Internal)
|
config.setTitle("Unciv")
|
||||||
config.title = "Unciv"
|
config.setHdpiMode(HdpiMode.Logical)
|
||||||
config.useHDPI = true
|
|
||||||
if (FileHandle(GameSaver.settingsFileName).exists()) {
|
if (FileHandle(GameSaver.settingsFileName).exists()) {
|
||||||
val settings = JsonParser().getFromJson(GameSettings::class.java, FileHandle(GameSaver.settingsFileName))
|
val settings = JsonParser().getFromJson(
|
||||||
config.width = settings.windowState.width
|
GameSettings::class.java,
|
||||||
config.height = settings.windowState.height
|
FileHandle(GameSaver.settingsFileName)
|
||||||
|
)
|
||||||
|
config.setWindowedMode(settings.windowState.width, settings.windowState.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
val versionFromJar = DesktopLauncher.javaClass.`package`.specificationVersion ?: "Desktop"
|
val versionFromJar = DesktopLauncher.javaClass.`package`.specificationVersion ?: "Desktop"
|
||||||
@ -53,7 +54,7 @@ internal object DesktopLauncher {
|
|||||||
|
|
||||||
tryActivateDiscord(game)
|
tryActivateDiscord(game)
|
||||||
|
|
||||||
LwjglApplication(game, config)
|
Lwjgl3Application(game, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryActivateDiscord(game: UncivGame) {
|
private fun tryActivateDiscord(game: UncivGame) {
|
||||||
|
Loading…
Reference in New Issue
Block a user