Resolved #3317 - mod management screen displays properly again

3.11.9-patch2
This commit is contained in:
Yair Morgenstern 2020-11-03 23:23:02 +02:00
parent b5c9fb79bf
commit 315a55f972
3 changed files with 23 additions and 22 deletions

View File

@ -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"

View File

@ -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<Github.Repo>
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()
}
}

View File

@ -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
}
}
)