Fix Unit rename popup offering up the icon's virtual codepoint (#10620)

* Fix Unit rename popup offering up the icon's virtual codepoint

* Fix City rename popup offering up the icon's virtual codepoint
This commit is contained in:
SomeTroglodyte 2023-11-30 18:13:11 +01:00 committed by GitHub
parent 58e5139f35
commit 4be14d77f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -10,7 +10,7 @@ class CityRenamePopup(val screen: BaseScreen, val city: City, val actionOnClose:
AskTextPopup(
screen,
label = "Please enter a new name for your city",
defaultText = city.name.tr(),
defaultText = city.name.tr(hideIcons = true),
validate = { it != "" },
actionOnOk = { text ->
city.name = text
@ -20,4 +20,3 @@ class CityRenamePopup(val screen: BaseScreen, val city: City, val actionOnClose:
}
}

View File

@ -2,10 +2,10 @@ package com.unciv.ui.screens.pickerscreens
import com.unciv.logic.map.mapunit.MapUnit
import com.unciv.models.translations.tr
import com.unciv.ui.components.extensions.surroundWithCircle
import com.unciv.ui.images.ImageGetter
import com.unciv.ui.popups.AskTextPopup
import com.unciv.ui.screens.basescreen.BaseScreen
import com.unciv.ui.components.extensions.surroundWithCircle
class UnitRenamePopup(val screen: BaseScreen, val unit: MapUnit, val actionOnClose: ()->Unit) {
init {
@ -13,7 +13,7 @@ class UnitRenamePopup(val screen: BaseScreen, val unit: MapUnit, val actionOnClo
screen,
label = "Choose name for [${unit.baseUnit.name}]",
icon = ImageGetter.getUnitIcon(unit.name).surroundWithCircle(80f),
defaultText = unit.instanceName ?: unit.baseUnit.name.tr(),
defaultText = unit.instanceName ?: unit.baseUnit.name.tr(hideIcons = true),
validate = { it != unit.name },
actionOnOk = { userInput ->
//If the user inputs an empty string, clear the unit instanceName so the base name is used