Fix NPE in Nation selection & editor mods popup (#7144)

This commit is contained in:
Timo T 2022-06-12 18:10:03 +02:00 committed by GitHub
parent dc16bba983
commit 4da1d442e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 8 deletions

View File

@ -131,7 +131,7 @@ class MapEditorModsTab(
add(inc.toLabel()).row()
}
add(ScrollPane(incompatibilityTable)).colspan(2)
.maxHeight(stage.height * 0.8f).row()
.maxHeight(stageToShowOn.height * 0.8f).row()
addGoodSizedLabel("Change map to fit selected ruleset?", 24).colspan(2).row()
addButtonInRow(Constants.yes, 'y') {
onOK()

View File

@ -344,7 +344,7 @@ private class NationPickerPopup(
private val ruleset = previousScreen.ruleset
// This Popup's body has two halves of same size, either side by side or arranged vertically
// depending on screen proportions - determine height for one of those
private val partHeight = stage.height * (if (stage.isNarrowerThan4to3()) 0.45f else 0.8f)
private val partHeight = stageToShowOn.height * (if (stageToShowOn.isNarrowerThan4to3()) 0.45f else 0.8f)
private val civBlocksWidth = playerPicker.civBlocksWidth
private val nationListTable = Table()
private val nationListScroll = ScrollPane(nationListTable)
@ -356,7 +356,7 @@ private class NationPickerPopup(
nationListScroll.setOverscroll(false, false)
add(nationListScroll).size( civBlocksWidth + 10f, partHeight )
// +10, because the nation table has a 5f pad, for a total of +10f
if (stage.isNarrowerThan4to3()) row()
if (stageToShowOn.isNarrowerThan4to3()) row()
nationDetailsScroll.setOverscroll(false, false)
add(nationDetailsScroll).size(civBlocksWidth + 10f, partHeight) // Same here, see above

View File

@ -154,7 +154,7 @@ private fun addMultiplayerServerOptions(
}).colspan(2).row()
tab.add(connectionToServerButton.onClick {
val popup = Popup(optionsPopup.stage).apply {
val popup = Popup(optionsPopup.stageToShowOn).apply {
addGoodSizedLabel("Awaiting response...").row()
}
popup.open(true)

View File

@ -11,7 +11,7 @@ import kotlinx.coroutines.delay
* This is an unobtrusive popup which will close itself after a given amount of time.
* Default time is two seconds (in milliseconds)
*/
class ToastPopup (message: String, stage: Stage, val time: Long = 2000) : Popup(stage){
class ToastPopup (message: String, stageToShowOn: Stage, val time: Long = 2000) : Popup(stageToShowOn){
constructor(message: String, screen: BaseScreen, time: Long = 2000) : this(message, screen.stage, time)
@ -24,7 +24,7 @@ class ToastPopup (message: String, stage: Stage, val time: Long = 2000) : Popup(
open()
//move it to the top so its not in the middle of the screen
//have to be done after open() because open() centers the popup
y = stage.height - (height + 20f)
y = stageToShowOn.height - (height + 20f)
}
private fun startTimer(){

View File

@ -17,10 +17,10 @@ import com.unciv.ui.utils.extensions.toLabel
*/
open class YesNoPopup(
question: String,
stage: Stage,
stageToShowOn: Stage,
restoreDefault: () -> Unit = {},
action: () -> Unit
) : Popup(stage) {
) : Popup(stageToShowOn) {
constructor(
question: String,