diff --git a/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt b/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt index c78fa55a53..2e3ee57881 100644 --- a/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt +++ b/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt @@ -1,10 +1,10 @@ package com.unciv.ui.worldscreen import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.scenes.scene2d.Touchable import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane import com.badlogic.gdx.scenes.scene2d.ui.Table import com.unciv.logic.civilization.Notification -import com.unciv.models.gamebasics.tr import com.unciv.ui.utils.* import kotlin.math.min @@ -12,7 +12,8 @@ class NotificationsScroll(internal val worldScreen: WorldScreen) : ScrollPane(nu private var notificationsTable = Table() init { - widget = notificationsTable + actor = notificationsTable.right() + touchable = Touchable.childrenOnly } internal fun update(notifications: MutableList) { @@ -20,21 +21,24 @@ class NotificationsScroll(internal val worldScreen: WorldScreen) : ScrollPane(nu for (notification in notifications.toList()) { // tolist to avoid concurrecy problems val label = notification.text.toLabel().setFontColor(Color.BLACK) .setFontSize(14) - val minitable = Table() + val listItem = Table() - minitable.add(ImageGetter.getCircle() + listItem.add(ImageGetter.getCircle() .apply { color=notification.color }).size(10f).pad(5f) - minitable.background(ImageGetter.getDrawable("OtherIcons/civTableBackground.png")) - minitable.add(label).pad(5f).padRight(10f) + listItem.background(ImageGetter.getDrawable("OtherIcons/civTableBackground.png")) + listItem.add(label).pad(5f).padRight(10f) - if (notification.location != null) { - minitable.onClick { - worldScreen.tileMapHolder.setCenterPosition(notification.location!!) + // using a larger click area to avoid miss-clicking in between the messages on the map + val clickArea = Table().apply { + add(listItem).pad(3f) + touchable = Touchable.enabled + onClick { + if (notification.location != null) + worldScreen.tileMapHolder.setCenterPosition(notification.location!!) } } - notificationsTable.add(minitable).pad(3f) - notificationsTable.row() + notificationsTable.add(clickArea).right().row() } notificationsTable.pack() pack() diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index ed0f2540c2..36ec14362d 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -49,7 +49,8 @@ class WorldScreen : CameraStageBaseScreen() { topBar.width = stage.width notificationsScroll = NotificationsScroll(this) - notificationsScroll.width = stage.width/3 + // notifications are right-aligned, they take up only as much space as necessary. + notificationsScroll.width = stage.width/2 minimapWrapper.x = stage.width - minimapWrapper.width @@ -150,7 +151,7 @@ class WorldScreen : CameraStageBaseScreen() { minimapWrapper.y = bottomBar.height // couldn't be bothered to create a separate val for minimap wrapper unitActionsTable.update(bottomBar.unitTable.selectedUnit) - unitActionsTable.y = bottomBar.height + unitActionsTable.y = bottomBar.unitTable.height // if we use the clone, then when we update viewable tiles // it doesn't update the explored tiles of the civ... need to think about that harder @@ -159,7 +160,6 @@ class WorldScreen : CameraStageBaseScreen() { topBar.update(cloneCivilization) notificationsScroll.update(currentPlayerCiv.notifications) - notificationsScroll.width = stage.width/3 notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f, nextTurnButton.y - notificationsScroll.height - 5f) diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt index 1395c7cf58..1feff44cf9 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt @@ -1,6 +1,7 @@ package com.unciv.ui.worldscreen.bottombar import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.scenes.scene2d.Touchable import com.badlogic.gdx.scenes.scene2d.actions.Actions import com.badlogic.gdx.scenes.scene2d.actions.RepeatAction import com.badlogic.gdx.scenes.scene2d.ui.Image @@ -24,6 +25,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() { skin = CameraStageBaseScreen.skin background = ImageGetter.getBackground(ImageGetter.getBlue()) pad(5f) + touchable = Touchable.enabled } fun hide(){ diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt index 49e3dc80cc..037cf8bcdc 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt @@ -2,6 +2,7 @@ package com.unciv.ui.worldscreen.unit import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.scenes.scene2d.Actor +import com.badlogic.gdx.scenes.scene2d.Touchable import com.badlogic.gdx.scenes.scene2d.ui.Button import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.Table @@ -14,6 +15,10 @@ import com.unciv.ui.worldscreen.WorldScreen class UnitActionsTable(val worldScreen: WorldScreen) : Table(){ + init { + touchable = Touchable.enabled + } + fun getIconForUnitAction(unitAction:String): Actor { if(unitAction.startsWith("Upgrade to")){ // Regexplaination: start with a [, take as many non-] chars as you can, until you reach a ]. diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt index 6dc4734aca..aeeb555205 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt @@ -34,7 +34,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ init { pad(5f) - + touchable = Touchable.enabled background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) add(VerticalGroup().apply {