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