mirror of
https://github.com/yairm210/Unciv.git
synced 2024-12-23 01:24:26 +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 {
|
||||
"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-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")
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ Allow unit movement after unit automation steps
|
||||
|
||||
By SimonCeder:
|
||||
- Barbarian units
|
||||
- Fix for broken saves in #5573
|
||||
- Barbarian fixes
|
||||
|
||||
By SomeTroglodyte:
|
||||
|
@ -167,13 +167,17 @@ class KeyPressDispatcher(val name: String? = null) : HashMap<KeyCharAndCode, (()
|
||||
if (installStage != null) uninstall()
|
||||
listener =
|
||||
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
|
||||
// Char constructor of KeyCharAndCode generates keyCode based instances
|
||||
// preferentially but we would miss Ctrl- combos otherwise
|
||||
val key = when {
|
||||
contains(KeyCharAndCode.ascii(character)) ->
|
||||
KeyCharAndCode.ascii(character)
|
||||
event == null ->
|
||||
KeyCharAndCode.UNKNOWN
|
||||
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
|
||||
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 {
|
||||
|
@ -2,7 +2,6 @@ import com.badlogicgames.packr.Packr
|
||||
import com.badlogicgames.packr.PackrConfig
|
||||
import com.unciv.build.BuildConfig
|
||||
|
||||
|
||||
plugins {
|
||||
id("kotlin")
|
||||
}
|
||||
@ -23,6 +22,9 @@ val discordDir = file("discord_rpc")
|
||||
val deployFolder = file("../deploy")
|
||||
|
||||
tasks.register<JavaExec>("run") {
|
||||
|
||||
jvmArgs = listOf("-XstartOnFirstThread") // See https://github.com/libgdx/libgdx/wiki/Starter-classes-and-configuration#common-issues
|
||||
|
||||
dependsOn(tasks.getByName("classes"))
|
||||
|
||||
main = mainClassName
|
||||
|
@ -3,10 +3,10 @@ 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.backends.lwjgl3.Lwjgl3Application
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration
|
||||
import com.badlogic.gdx.files.FileHandle
|
||||
import com.badlogic.gdx.graphics.glutils.HdpiMode
|
||||
import com.sun.jna.Native
|
||||
import com.unciv.JsonParser
|
||||
import com.unciv.UncivGame
|
||||
@ -29,15 +29,16 @@ internal object DesktopLauncher {
|
||||
|
||||
ImagePacker.packImages()
|
||||
|
||||
val config = LwjglApplicationConfiguration()
|
||||
// Don't activate GL 3.0 because it causes problems for MacOS computers
|
||||
config.addIcon("ExtraImages/Icon.png", Files.FileType.Internal)
|
||||
config.title = "Unciv"
|
||||
config.useHDPI = true
|
||||
val config = Lwjgl3ApplicationConfiguration()
|
||||
config.setWindowIcon( "ExtraImages/Icon.png")
|
||||
config.setTitle("Unciv")
|
||||
config.setHdpiMode(HdpiMode.Logical)
|
||||
if (FileHandle(GameSaver.settingsFileName).exists()) {
|
||||
val settings = JsonParser().getFromJson(GameSettings::class.java, FileHandle(GameSaver.settingsFileName))
|
||||
config.width = settings.windowState.width
|
||||
config.height = settings.windowState.height
|
||||
val settings = JsonParser().getFromJson(
|
||||
GameSettings::class.java,
|
||||
FileHandle(GameSaver.settingsFileName)
|
||||
)
|
||||
config.setWindowedMode(settings.windowState.width, settings.windowState.height)
|
||||
}
|
||||
|
||||
val versionFromJar = DesktopLauncher.javaClass.`package`.specificationVersion ?: "Desktop"
|
||||
@ -53,7 +54,7 @@ internal object DesktopLauncher {
|
||||
|
||||
tryActivateDiscord(game)
|
||||
|
||||
LwjglApplication(game, config)
|
||||
Lwjgl3Application(game, config)
|
||||
}
|
||||
|
||||
private fun tryActivateDiscord(game: UncivGame) {
|
||||
|
Loading…
Reference in New Issue
Block a user