mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-16 02:40:41 +07:00
Disable spectators from changing unit names (#7737)
This commit is contained in:
@ -64,11 +64,14 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen(), RecreateOnResiz
|
|||||||
renameButton.isEnabled = true
|
renameButton.isEnabled = true
|
||||||
|
|
||||||
renameButton.onClick {
|
renameButton.onClick {
|
||||||
|
if (!canChangeState) return@onClick
|
||||||
UnitRenamePopup(
|
UnitRenamePopup(
|
||||||
screen = this,
|
screen = this,
|
||||||
unit = unit,
|
unit = unit,
|
||||||
actionOnClose = {
|
actionOnClose = {
|
||||||
this.game.replaceCurrentScreen(PromotionPickerScreen(unit)) })
|
game.replaceCurrentScreen(PromotionPickerScreen(unit))
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
availablePromotionsGroup.add(renameButton)
|
availablePromotionsGroup.add(renameButton)
|
||||||
availablePromotionsGroup.row()
|
availablePromotionsGroup.row()
|
||||||
|
@ -26,7 +26,7 @@ import com.unciv.ui.utils.extensions.onClick
|
|||||||
import com.unciv.ui.utils.extensions.toLabel
|
import com.unciv.ui.utils.extensions.toLabel
|
||||||
import com.unciv.ui.worldscreen.WorldScreen
|
import com.unciv.ui.worldscreen.WorldScreen
|
||||||
|
|
||||||
class UnitTable(val worldScreen: WorldScreen) : Table(){
|
class UnitTable(val worldScreen: WorldScreen) : Table() {
|
||||||
private val prevIdleUnitButton = IdleUnitButton(this,worldScreen.mapHolder,true)
|
private val prevIdleUnitButton = IdleUnitButton(this,worldScreen.mapHolder,true)
|
||||||
private val nextIdleUnitButton = IdleUnitButton(this,worldScreen.mapHolder,false)
|
private val nextIdleUnitButton = IdleUnitButton(this,worldScreen.mapHolder,false)
|
||||||
private val unitIconHolder = Table()
|
private val unitIconHolder = Table()
|
||||||
@ -67,7 +67,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
touchable = Touchable.enabled
|
touchable = Touchable.enabled
|
||||||
background = ImageGetter.getBackground(ImageGetter.getBlue().darken(0.5f))
|
background = ImageGetter.getBackground(ImageGetter.getBlue().darken(0.5f))
|
||||||
|
|
||||||
promotionsTable.touchable=Touchable.enabled
|
promotionsTable.touchable = Touchable.enabled
|
||||||
|
|
||||||
add(VerticalGroup().apply {
|
add(VerticalGroup().apply {
|
||||||
pad(5f)
|
pad(5f)
|
||||||
@ -75,7 +75,11 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
deselectUnitButton.add(ImageGetter.getImage("OtherIcons/Close")).size(20f).pad(10f)
|
deselectUnitButton.add(ImageGetter.getImage("OtherIcons/Close")).size(20f).pad(10f)
|
||||||
deselectUnitButton.pack()
|
deselectUnitButton.pack()
|
||||||
deselectUnitButton.touchable = Touchable.enabled
|
deselectUnitButton.touchable = Touchable.enabled
|
||||||
deselectUnitButton.onClick { selectUnit(); worldScreen.shouldUpdate=true; this@UnitTable.isVisible=false }
|
deselectUnitButton.onClick {
|
||||||
|
selectUnit()
|
||||||
|
worldScreen.shouldUpdate = true
|
||||||
|
this@UnitTable.isVisible = false
|
||||||
|
}
|
||||||
addActor(deselectUnitButton)
|
addActor(deselectUnitButton)
|
||||||
}).left()
|
}).left()
|
||||||
|
|
||||||
@ -137,12 +141,15 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
|
|
||||||
unitNameLabel.clearListeners()
|
unitNameLabel.clearListeners()
|
||||||
unitNameLabel.onClick {
|
unitNameLabel.onClick {
|
||||||
|
if (!worldScreen.canChangeState) return@onClick
|
||||||
UnitRenamePopup(
|
UnitRenamePopup(
|
||||||
screen = worldScreen,
|
screen = worldScreen,
|
||||||
unit = unit,
|
unit = unit,
|
||||||
actionOnClose = {
|
actionOnClose = {
|
||||||
unitNameLabel.setText(buildNameLabelText(unit))
|
unitNameLabel.setText(buildNameLabelText(unit))
|
||||||
selectedUnitHasChanged = true })
|
selectedUnitHasChanged = true
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
unitDescriptionTable.clear()
|
unitDescriptionTable.clear()
|
||||||
@ -234,7 +241,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
// Since Clear also clears the listeners, we need to re-add them every time
|
// Since Clear also clears the listeners, we need to re-add them every time
|
||||||
promotionsTable.onClick {
|
promotionsTable.onClick {
|
||||||
if (selectedUnit == null || selectedUnit!!.promotions.promotions.isEmpty()) return@onClick
|
if (selectedUnit == null || selectedUnit!!.promotions.promotions.isEmpty()) return@onClick
|
||||||
UncivGame.Current.pushScreen(PromotionPickerScreen(selectedUnit!!))
|
worldScreen.game.pushScreen(PromotionPickerScreen(selectedUnit!!))
|
||||||
}
|
}
|
||||||
|
|
||||||
unitIconHolder.onClick {
|
unitIconHolder.onClick {
|
||||||
@ -247,7 +254,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
pack()
|
pack()
|
||||||
selectedUnitHasChanged=false
|
selectedUnitHasChanged = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildNameLabelText(unit: MapUnit) : String {
|
private fun buildNameLabelText(unit: MapUnit) : String {
|
||||||
|
Reference in New Issue
Block a user