mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 07:21:34 -04:00
made on-map windows touchable, so you can't "touch through" them on the map
This commit is contained in:
parent
48af218795
commit
462dc26460
@ -1,10 +1,10 @@
|
|||||||
package com.unciv.ui.worldscreen
|
package com.unciv.ui.worldscreen
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
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.ScrollPane
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.unciv.logic.civilization.Notification
|
import com.unciv.logic.civilization.Notification
|
||||||
import com.unciv.models.gamebasics.tr
|
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
@ -12,7 +12,8 @@ class NotificationsScroll(internal val worldScreen: WorldScreen) : ScrollPane(nu
|
|||||||
private var notificationsTable = Table()
|
private var notificationsTable = Table()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
widget = notificationsTable
|
actor = notificationsTable.right()
|
||||||
|
touchable = Touchable.childrenOnly
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun update(notifications: MutableList<Notification>) {
|
internal fun update(notifications: MutableList<Notification>) {
|
||||||
@ -20,21 +21,24 @@ class NotificationsScroll(internal val worldScreen: WorldScreen) : ScrollPane(nu
|
|||||||
for (notification in notifications.toList()) { // tolist to avoid concurrecy problems
|
for (notification in notifications.toList()) { // tolist to avoid concurrecy problems
|
||||||
val label = notification.text.toLabel().setFontColor(Color.BLACK)
|
val label = notification.text.toLabel().setFontColor(Color.BLACK)
|
||||||
.setFontSize(14)
|
.setFontSize(14)
|
||||||
val minitable = Table()
|
val listItem = Table()
|
||||||
|
|
||||||
minitable.add(ImageGetter.getCircle()
|
listItem.add(ImageGetter.getCircle()
|
||||||
.apply { color=notification.color }).size(10f).pad(5f)
|
.apply { color=notification.color }).size(10f).pad(5f)
|
||||||
minitable.background(ImageGetter.getDrawable("OtherIcons/civTableBackground.png"))
|
listItem.background(ImageGetter.getDrawable("OtherIcons/civTableBackground.png"))
|
||||||
minitable.add(label).pad(5f).padRight(10f)
|
listItem.add(label).pad(5f).padRight(10f)
|
||||||
|
|
||||||
if (notification.location != null) {
|
// using a larger click area to avoid miss-clicking in between the messages on the map
|
||||||
minitable.onClick {
|
val clickArea = Table().apply {
|
||||||
|
add(listItem).pad(3f)
|
||||||
|
touchable = Touchable.enabled
|
||||||
|
onClick {
|
||||||
|
if (notification.location != null)
|
||||||
worldScreen.tileMapHolder.setCenterPosition(notification.location!!)
|
worldScreen.tileMapHolder.setCenterPosition(notification.location!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notificationsTable.add(minitable).pad(3f)
|
notificationsTable.add(clickArea).right().row()
|
||||||
notificationsTable.row()
|
|
||||||
}
|
}
|
||||||
notificationsTable.pack()
|
notificationsTable.pack()
|
||||||
pack()
|
pack()
|
||||||
|
@ -49,7 +49,8 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
topBar.width = stage.width
|
topBar.width = stage.width
|
||||||
|
|
||||||
notificationsScroll = NotificationsScroll(this)
|
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
|
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
|
minimapWrapper.y = bottomBar.height // couldn't be bothered to create a separate val for minimap wrapper
|
||||||
|
|
||||||
unitActionsTable.update(bottomBar.unitTable.selectedUnit)
|
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
|
// 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
|
// 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)
|
topBar.update(cloneCivilization)
|
||||||
notificationsScroll.update(currentPlayerCiv.notifications)
|
notificationsScroll.update(currentPlayerCiv.notifications)
|
||||||
notificationsScroll.width = stage.width/3
|
|
||||||
notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f,
|
notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f,
|
||||||
nextTurnButton.y - notificationsScroll.height - 5f)
|
nextTurnButton.y - notificationsScroll.height - 5f)
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.ui.worldscreen.bottombar
|
package com.unciv.ui.worldscreen.bottombar
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
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.Actions
|
||||||
import com.badlogic.gdx.scenes.scene2d.actions.RepeatAction
|
import com.badlogic.gdx.scenes.scene2d.actions.RepeatAction
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
@ -24,6 +25,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
|||||||
skin = CameraStageBaseScreen.skin
|
skin = CameraStageBaseScreen.skin
|
||||||
background = ImageGetter.getBackground(ImageGetter.getBlue())
|
background = ImageGetter.getBackground(ImageGetter.getBlue())
|
||||||
pad(5f)
|
pad(5f)
|
||||||
|
touchable = Touchable.enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hide(){
|
fun hide(){
|
||||||
|
@ -2,6 +2,7 @@ package com.unciv.ui.worldscreen.unit
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
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.Button
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
@ -14,6 +15,10 @@ import com.unciv.ui.worldscreen.WorldScreen
|
|||||||
|
|
||||||
class UnitActionsTable(val worldScreen: WorldScreen) : Table(){
|
class UnitActionsTable(val worldScreen: WorldScreen) : Table(){
|
||||||
|
|
||||||
|
init {
|
||||||
|
touchable = Touchable.enabled
|
||||||
|
}
|
||||||
|
|
||||||
fun getIconForUnitAction(unitAction:String): Actor {
|
fun getIconForUnitAction(unitAction:String): Actor {
|
||||||
if(unitAction.startsWith("Upgrade to")){
|
if(unitAction.startsWith("Upgrade to")){
|
||||||
// Regexplaination: start with a [, take as many non-] chars as you can, until you reach a ].
|
// Regexplaination: start with a [, take as many non-] chars as you can, until you reach a ].
|
||||||
|
@ -34,7 +34,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
pad(5f)
|
pad(5f)
|
||||||
|
touchable = Touchable.enabled
|
||||||
background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
||||||
|
|
||||||
add(VerticalGroup().apply {
|
add(VerticalGroup().apply {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user