Tweak UncivSlider and make the one on NewGameScreen permanently show the value tip (#4728)

This commit is contained in:
SomeTroglodyte 2021-08-02 18:01:08 +02:00 committed by GitHub
parent 1ac10813bc
commit e7bf1fad7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -96,9 +96,10 @@ class GameOptionsTable(
val slider = UncivSlider(0f,numberOfCityStates.toFloat(),1f) {
gameParameters.numberOfCityStates = it.toInt()
}
slider.value = gameParameters.numberOfCityStates.toFloat()
slider.permanentTip = true
slider.isDisabled = locked
add(slider).row()
add(slider).padTop(10f).row()
slider.value = gameParameters.numberOfCityStates.toFloat()
}
private fun Table.addSelectBox(text: String, values: Collection<String>, initialState: String, onChange: (newValue: String) -> Unit) {

View File

@ -81,7 +81,9 @@ class UncivSlider (
// Value tip format
var tipFormat = "%.1f"
var permanentTip = false
// Detect changes in isDragging
private var hasFocus = false
@ -153,7 +155,8 @@ class UncivSlider (
tipLabel.setText(getTipText!!(slider.value))
if (!tipHideTask.isScheduled) showTip()
tipHideTask.cancel()
Timer.schedule(tipHideTask, hideDelay)
if (!permanentTip)
Timer.schedule(tipHideTask, hideDelay)
val enableMinus = slider.value > slider.minValue
minusButton?.touchable = if(enableMinus) Touchable.enabled else Touchable.disabled
@ -210,6 +213,7 @@ class UncivSlider (
private fun showTip() {
if (tipContainer.hasParent()) return
tipContainer.pack()
if (needsLayout()) pack()
val pos = slider.localToParentCoordinates(Vector2(slider.width / 2, slider.height))
tipContainer.run {
setOrigin(Align.bottom)