mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 15:29:32 +07:00
More UI cleanup
This commit is contained in:
@ -180,11 +180,12 @@ class UncivTooltip <T: Actor>(
|
||||
size: Float = 26f,
|
||||
always: Boolean = false,
|
||||
targetAlign: Int = Align.topRight,
|
||||
tipAlign: Int = Align.top
|
||||
tipAlign: Int = Align.top,
|
||||
hideIcons: Boolean = false
|
||||
) {
|
||||
if (!(always || GUI.keyboardAvailable) || text.isEmpty()) return
|
||||
|
||||
val label = text.toLabel(BaseScreen.skinStrings.skinConfig.baseColor, 38)
|
||||
val label = text.toLabel(BaseScreen.skinStrings.skinConfig.baseColor, 38, hideIcons = hideIcons)
|
||||
label.setAlignment(Align.center)
|
||||
|
||||
val background = BaseScreen.skinStrings.getUiBackground("General/Tooltip", BaseScreen.skinStrings.roundedEdgeRectangleShape, Color.LIGHT_GRAY)
|
||||
|
@ -7,8 +7,8 @@ import com.badlogic.gdx.scenes.scene2d.ui.Cell
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.Constants
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import com.unciv.ui.components.extensions.toLabel
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
|
||||
/**
|
||||
* Translate a [String] and make a [Button] widget from it, with control over font size, font colour, an optional icon, and custom formatting.
|
||||
@ -22,10 +22,11 @@ open class IconTextButton(
|
||||
text: String,
|
||||
val icon: Actor? = null,
|
||||
fontSize: Int = Constants.defaultFontSize,
|
||||
fontColor: Color = Color.WHITE
|
||||
fontColor: Color = Color.WHITE,
|
||||
hideIcons: Boolean = false
|
||||
): Button(BaseScreen.skin) {
|
||||
/** [Label] instance produced by and with content and formatting as specified to [String.toLabel]. */
|
||||
val label = text.toLabel(fontColor, fontSize)
|
||||
val label = text.toLabel(fontColor, fontSize, hideIcons = hideIcons)
|
||||
/** Table cell containing the [icon] if any, or `null`. */
|
||||
val iconCell: Cell<Actor> =
|
||||
if (icon != null) {
|
||||
|
@ -15,10 +15,8 @@ import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||
import com.unciv.logic.map.HexMath
|
||||
import com.unciv.models.ruleset.Policy.PolicyBranchType
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.screens.diplomacyscreen.DiplomacyScreen
|
||||
import com.unciv.ui.components.AutoScrollPane
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import com.unciv.ui.components.ColorMarkupLabel
|
||||
import com.unciv.ui.components.Fonts
|
||||
import com.unciv.ui.components.UncivTooltip.Companion.addTooltip
|
||||
import com.unciv.ui.components.extensions.addBorder
|
||||
@ -28,6 +26,9 @@ import com.unciv.ui.components.extensions.center
|
||||
import com.unciv.ui.components.extensions.onClick
|
||||
import com.unciv.ui.components.extensions.toLabel
|
||||
import com.unciv.ui.components.extensions.toTextButton
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import com.unciv.ui.screens.diplomacyscreen.DiplomacyScreen
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class GlobalPoliticsOverviewTable (
|
||||
@ -160,7 +161,7 @@ class GlobalPoliticsOverviewTable (
|
||||
worldScreen.mapHolder.setCenterPosition(wonder.location.position)
|
||||
}
|
||||
}
|
||||
wonderTable.add(wonderName).row()
|
||||
wonderTable.add(wonderName).left().row()
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,8 +184,7 @@ class GlobalPoliticsOverviewTable (
|
||||
// wars
|
||||
for (otherCiv in civ.getKnownCivs()) {
|
||||
if (civ.isAtWarWith(otherCiv)) {
|
||||
val warText = "At war with [${getCivName(otherCiv)}]".toLabel()
|
||||
warText.color = Color.RED
|
||||
val warText = ColorMarkupLabel("At war with [${getCivName(otherCiv)}]", Color.RED)
|
||||
politicsTable.add(warText).row()
|
||||
}
|
||||
}
|
||||
@ -193,8 +193,7 @@ class GlobalPoliticsOverviewTable (
|
||||
// declaration of friendships
|
||||
for (otherCiv in civ.getKnownCivs()) {
|
||||
if (civ.diplomacy[otherCiv.civName]?.hasFlag(DiplomacyFlags.DeclarationOfFriendship) == true) {
|
||||
val friendText = "Friends with [${getCivName(otherCiv)}]".toLabel()
|
||||
friendText.color = Color.GREEN
|
||||
val friendText = ColorMarkupLabel("Friends with [${getCivName(otherCiv)}]", Color.GREEN)
|
||||
val turnsLeftText = " (${civ.diplomacy[otherCiv.civName]?.getFlag(DiplomacyFlags.DeclarationOfFriendship)} ${Fonts.turn})".toLabel()
|
||||
politicsTable.add(friendText)
|
||||
politicsTable.add(turnsLeftText).row()
|
||||
@ -205,8 +204,7 @@ class GlobalPoliticsOverviewTable (
|
||||
// denounced civs
|
||||
for (otherCiv in civ.getKnownCivs()) {
|
||||
if (civ.diplomacy[otherCiv.civName]?.hasFlag(DiplomacyFlags.Denunciation) == true) {
|
||||
val denouncedText = "Denounced [${getCivName(otherCiv)}]".toLabel()
|
||||
denouncedText.color = Color.RED
|
||||
val denouncedText = ColorMarkupLabel("Denounced [${getCivName(otherCiv)}]", Color.RED)
|
||||
val turnsLeftText = "(${civ.diplomacy[otherCiv.civName]?.getFlag(DiplomacyFlags.Denunciation)} ${Fonts.turn})".toLabel()
|
||||
politicsTable.add(denouncedText)
|
||||
politicsTable.add(turnsLeftText).row()
|
||||
@ -217,8 +215,7 @@ class GlobalPoliticsOverviewTable (
|
||||
//allied CS
|
||||
for (cityState in gameInfo.getAliveCityStates()) {
|
||||
if (cityState.diplomacy[civ.civName]?.isRelationshipLevelEQ(RelationshipLevel.Ally) == true) {
|
||||
val alliedText = "Allied with [${getCivName(cityState)}]".toLabel()
|
||||
alliedText.color = Color.GREEN
|
||||
val alliedText = ColorMarkupLabel("Allied with [${getCivName(cityState)}]", Color.GREEN)
|
||||
politicsTable.add(alliedText).row()
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,12 @@ import com.unciv.UncivGame
|
||||
import com.unciv.logic.civilization.Civilization
|
||||
import com.unciv.logic.civilization.Notification
|
||||
import com.unciv.logic.civilization.NotificationCategory
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import com.unciv.ui.components.ColorMarkupLabel
|
||||
import com.unciv.ui.components.TabbedPager
|
||||
import com.unciv.ui.components.WrappableLabel
|
||||
import com.unciv.ui.components.extensions.onClick
|
||||
import com.unciv.ui.components.extensions.toLabel
|
||||
import com.unciv.ui.screens.worldscreen.WorldScreen
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
|
||||
class NotificationsOverviewTable(
|
||||
viewingPlayer: Civilization,
|
||||
@ -42,8 +41,6 @@ class NotificationsOverviewTable(
|
||||
private val notificationLog = viewingPlayer.notificationsLog
|
||||
private val notificationTable = Table(BaseScreen.skin)
|
||||
|
||||
private val maxEntryWidth = worldScreen.stage.width - 20f
|
||||
|
||||
val iconSize = 20f
|
||||
|
||||
init {
|
||||
@ -87,10 +84,10 @@ class NotificationsOverviewTable(
|
||||
for (notification in categoryNotifications) {
|
||||
val notificationTable = Table(BaseScreen.skin)
|
||||
|
||||
val labelWidth = maxEntryWidth - iconSize * notification.icons.size - 10f
|
||||
val label = WrappableLabel(notification.text, labelWidth, Color.BLACK, 20)
|
||||
val label = ColorMarkupLabel(notification.text, Color.BLACK, fontSize = 20)
|
||||
.apply { wrap = true }
|
||||
|
||||
notificationTable.add(label)
|
||||
notificationTable.add(label).width(worldScreen.stage.width/2 - iconSize * notification.icons.size)
|
||||
notificationTable.background = BaseScreen.skinStrings.getUiBackground("OverviewScreen/NotificationOverviewTable/Notification", BaseScreen.skinStrings.roundedEdgeRectangleShape)
|
||||
notificationTable.touchable = Touchable.enabled
|
||||
notificationTable.onClick {
|
||||
|
@ -145,7 +145,7 @@ class ResourcesOverviewTab(
|
||||
add(turnImageH)
|
||||
for (resource in resources) {
|
||||
add(getResourceImage(resource.name).apply {
|
||||
addTooltip(resource.name, tipAlign = Align.topLeft)
|
||||
addTooltip(resource.name, tipAlign = Align.topLeft, hideIcons = true)
|
||||
})
|
||||
}
|
||||
addSeparator()
|
||||
|
@ -184,7 +184,8 @@ class UnitOverviewTab(
|
||||
val button = IconTextButton(
|
||||
unit.displayName(),
|
||||
UnitGroup(unit, 20f),
|
||||
fontColor = if (unit.due && unit.isIdle()) Color.WHITE else Color.LIGHT_GRAY
|
||||
fontColor = if (unit.due && unit.isIdle()) Color.WHITE else Color.LIGHT_GRAY,
|
||||
hideIcons = true
|
||||
)
|
||||
button.name = getUnitIdentifier(unit) // Marker to find a unit in select()
|
||||
button.onClick {
|
||||
|
@ -73,7 +73,7 @@ class WonderOverviewTab(
|
||||
// Terrain image padding is a bit unpredictable, they need ~5f more. Ensure equal line spacing on name, not image:
|
||||
add(image).pad(0f, 10f, 0f, 10f)
|
||||
|
||||
add(wonder.getNameColumn().toLabel()).pad(15f, 10f, 15f, 10f)
|
||||
add(wonder.getNameColumn().toLabel(hideIcons = true)).pad(15f, 10f, 15f, 10f)
|
||||
add(wonder.getStatusColumn().toLabel())
|
||||
val locationText = wonder.getLocationColumn()
|
||||
if (locationText.isNotEmpty()) {
|
||||
|
Reference in New Issue
Block a user