mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -04: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) {
|
val slider = UncivSlider(0f,numberOfCityStates.toFloat(),1f) {
|
||||||
gameParameters.numberOfCityStates = it.toInt()
|
gameParameters.numberOfCityStates = it.toInt()
|
||||||
}
|
}
|
||||||
slider.value = gameParameters.numberOfCityStates.toFloat()
|
slider.permanentTip = true
|
||||||
slider.isDisabled = locked
|
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) {
|
private fun Table.addSelectBox(text: String, values: Collection<String>, initialState: String, onChange: (newValue: String) -> Unit) {
|
||||||
|
@ -81,7 +81,9 @@ class UncivSlider (
|
|||||||
|
|
||||||
// Value tip format
|
// Value tip format
|
||||||
var tipFormat = "%.1f"
|
var tipFormat = "%.1f"
|
||||||
|
|
||||||
|
var permanentTip = false
|
||||||
|
|
||||||
// Detect changes in isDragging
|
// Detect changes in isDragging
|
||||||
private var hasFocus = false
|
private var hasFocus = false
|
||||||
|
|
||||||
@ -153,7 +155,8 @@ class UncivSlider (
|
|||||||
tipLabel.setText(getTipText!!(slider.value))
|
tipLabel.setText(getTipText!!(slider.value))
|
||||||
if (!tipHideTask.isScheduled) showTip()
|
if (!tipHideTask.isScheduled) showTip()
|
||||||
tipHideTask.cancel()
|
tipHideTask.cancel()
|
||||||
Timer.schedule(tipHideTask, hideDelay)
|
if (!permanentTip)
|
||||||
|
Timer.schedule(tipHideTask, hideDelay)
|
||||||
|
|
||||||
val enableMinus = slider.value > slider.minValue
|
val enableMinus = slider.value > slider.minValue
|
||||||
minusButton?.touchable = if(enableMinus) Touchable.enabled else Touchable.disabled
|
minusButton?.touchable = if(enableMinus) Touchable.enabled else Touchable.disabled
|
||||||
@ -210,6 +213,7 @@ class UncivSlider (
|
|||||||
private fun showTip() {
|
private fun showTip() {
|
||||||
if (tipContainer.hasParent()) return
|
if (tipContainer.hasParent()) return
|
||||||
tipContainer.pack()
|
tipContainer.pack()
|
||||||
|
if (needsLayout()) pack()
|
||||||
val pos = slider.localToParentCoordinates(Vector2(slider.width / 2, slider.height))
|
val pos = slider.localToParentCoordinates(Vector2(slider.width / 2, slider.height))
|
||||||
tipContainer.run {
|
tipContainer.run {
|
||||||
setOrigin(Align.bottom)
|
setOrigin(Align.bottom)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user