From 315a55f972b8defe22e76d4a2d811c6e6b607e57 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 3 Nov 2020 23:23:02 +0200 Subject: [PATCH] Resolved #3317 - mod management screen displays properly again 3.11.9-patch2 --- buildSrc/src/main/kotlin/BuildConfig.kt | 4 +-- .../ui/pickerscreens/ModManagementScreen.kt | 25 ++++++++++--------- .../unciv/ui/utils/CameraStageBaseScreen.kt | 16 ++++++------ 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/buildSrc/src/main/kotlin/BuildConfig.kt b/buildSrc/src/main/kotlin/BuildConfig.kt index c0e2a3c492..a03295689b 100644 --- a/buildSrc/src/main/kotlin/BuildConfig.kt +++ b/buildSrc/src/main/kotlin/BuildConfig.kt @@ -3,8 +3,8 @@ package com.unciv.build object BuildConfig { const val kotlinVersion = "1.3.71" const val appName = "Unciv" - const val appCodeNumber = 493 - const val appVersion = "3.11.9-patch1" + const val appCodeNumber = 494 + const val appVersion = "3.11.9-patch2" const val gdxVersion = "1.9.12" const val roboVMVersion = "2.3.1" diff --git a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt index b8993354cc..b34add5d25 100644 --- a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt @@ -20,9 +20,9 @@ class ModManagementScreen: PickerScreen() { init { setDefaultCloseAction(MainMenuScreen()) - refresh() + refreshModTable() - topTable.add(ScrollPane(modTable)).height(topTable.height).pad(10f) + topTable.add(ScrollPane(modTable)).height(scrollPane.height).pad(10f) downloadTable.add(getDownloadButton()).row() @@ -30,7 +30,6 @@ class ModManagementScreen: PickerScreen() { val repoList: ArrayList try { repoList = Github.tryGetGithubReposWithTopic() - } catch (ex: Exception) { Gdx.app.postRunnable { ToastPopup("Could not download mod list", this) @@ -57,10 +56,12 @@ class ModManagementScreen: PickerScreen() { } downloadTable.add(downloadButton).row() } + downloadTable.pack() + (downloadTable.parent as ScrollPane).actor = downloadTable } } - topTable.add(ScrollPane(downloadTable)).height(topTable.height) + topTable.add(ScrollPane(downloadTable)).height(scrollPane.height)//.size(downloadTable.width, topTable.height) } fun getDownloadButton(): TextButton { @@ -69,13 +70,13 @@ class ModManagementScreen: PickerScreen() { val popup = Popup(this) val textArea = TextArea("https://github.com/...",skin) popup.add(textArea).width(stage.width/2).row() - val downloadButton = "Download".toTextButton() - downloadButton.onClick { - downloadButton.setText("Downloading...".tr()) - downloadButton.disable() + val actualDownloadButton = "Download".toTextButton() + actualDownloadButton.onClick { + actualDownloadButton.setText("Downloading...".tr()) + actualDownloadButton.disable() downloadMod(textArea.text) { popup.close() } } - popup.add(downloadButton).row() + popup.add(actualDownloadButton).row() popup.addCloseButton() popup.open() } @@ -90,7 +91,7 @@ class ModManagementScreen: PickerScreen() { Gdx.app.postRunnable { ToastPopup("Downloaded!", this) RulesetCache.loadRulesets() - refresh() + refreshModTable() } } catch (ex:Exception){ Gdx.app.postRunnable { @@ -103,7 +104,7 @@ class ModManagementScreen: PickerScreen() { } } - fun refresh(){ + fun refreshModTable(){ modTable.clear() val currentMods = RulesetCache.values.filter { it.name != "" } for (mod in currentMods) { @@ -126,6 +127,6 @@ class ModManagementScreen: PickerScreen() { if(modFileHandle.isDirectory) modFileHandle.deleteDirectory() else modFileHandle.delete() RulesetCache.loadRulesets() - refresh() + refreshModTable() } } \ No newline at end of file diff --git a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt index 1ed6900630..c0f510cacd 100644 --- a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt +++ b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt @@ -46,14 +46,14 @@ open class CameraStageBaseScreen : Screen { stage.addListener( object : InputListener() { override fun keyTyped(event: InputEvent?, character: Char): Boolean { - if (character.toLowerCase() in keyPressDispatcher && !hasOpenPopups()) { - //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 { - keyPressDispatcher[character.toLowerCase()]?.invoke() - } catch (ex: Exception) {} - return true - } - return super.keyTyped(event, character) + if (character.toLowerCase() !in keyPressDispatcher || hasOpenPopups()) + return super.keyTyped(event, character) + + //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 { + keyPressDispatcher[character.toLowerCase()]?.invoke() + } catch (ex: Exception) {} + return true } } )