mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-05 13:08:48 +07:00
Fixed the positioning of popups after changing the screen orientation on Android (#8927)
This commit is contained in:
parent
a4b6585626
commit
ba63f9a62b
@ -1,5 +1,6 @@
|
||||
package com.unciv.app
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.graphics.Rect
|
||||
import android.net.Uri
|
||||
@ -14,7 +15,9 @@ import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import com.unciv.ui.screens.basescreen.UncivStage
|
||||
import com.unciv.utils.concurrency.Concurrency
|
||||
|
||||
class AndroidGame : UncivGame() {
|
||||
class AndroidGame(private val activity: Activity) : UncivGame() {
|
||||
|
||||
private var lastOrientation = activity.resources.configuration.orientation
|
||||
|
||||
fun addScreenObscuredListener() {
|
||||
val contentView = (Gdx.graphics as AndroidGraphics).view
|
||||
@ -53,6 +56,12 @@ class AndroidGame : UncivGame() {
|
||||
lastFrame = currentFrame
|
||||
lastVisibleStage = visibleStage
|
||||
|
||||
val currentOrientation = activity.resources.configuration.orientation
|
||||
if (lastOrientation != currentOrientation) {
|
||||
lastOrientation = currentOrientation
|
||||
return
|
||||
}
|
||||
|
||||
Concurrency.runOnGLThread {
|
||||
EventBus.send(UncivStage.VisibleAreaChanged(visibleStage))
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ open class AndroidLauncher : AndroidApplication() {
|
||||
Display.setOrientation(settings.displayOrientation)
|
||||
Display.setCutout(settings.androidCutout)
|
||||
|
||||
game = AndroidGame()
|
||||
game = AndroidGame(this)
|
||||
initialize(game, config)
|
||||
|
||||
game!!.setDeepLinkedGame(intent)
|
||||
|
Loading…
Reference in New Issue
Block a user