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