mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-11 11:28:03 +07:00
Tweak UncivSlider and make the one on NewGameScreen permanently show the value tip (#4728)
This commit is contained in:
parent
1ac10813bc
commit
e7bf1fad7c
@ -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) {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user