[solved] GUI: slider max/min labels

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

Post Reply
white_haired_uncle
Posts: 1203
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

[solved] GUI: slider max/min labels

Post by white_haired_uncle »

Trying to use the minimum/maximum_value_label on a slider. I can't get the text to fit. I thought maybe the right_offset would reserve space, but no. Tried every combination of the variables I can come up with, with or without horizontal_grow and friends. devdocs is confusing (what is 'positioner'?, I though 'the sliding part' until I noticed something else is referred to as 'the sliding part').

1.16.10
1.16.10
Screenshot_2024-01-08_07-07-42.png (47.57 KiB) Viewed 1760 times

In 1.17.24 the labels are compressed to almost fit in the tiny little space they are allowed.
In 1.17.24 the labels are compressed to almost fit in the tiny little space they are allowed.
Screenshot_2024-01-08_09-01-41.png (33.31 KiB) Viewed 1760 times


Code: Select all

          wml.tag.grid {
                        wml.tag.row {
                                wml.tag.column {
                                        wml.tag.label { label = _"How much gold will you pay for this old rusty sword?" }
                                }
                        },
                        wml.tag.row {
                                wml.tag.column {
                                        horizontal_grow = true,
                                        grow_factor = 1,
                                        wml.tag.slider {
                                                id = "gold_sl",
                                                right_offset = 120,
                                                minimum_value = 0,
                                                minimum_value_label = _"Nothing!",
                                                maximum_value = wesnoth.sides[wesnoth.current.side].gold,
                                                maximum_value_label = _"Take everything!",
                                                value = wesnoth.sides[wesnoth.current.side].gold/2
                                        }
                                }
                        },
...
Last edited by white_haired_uncle on January 9th, 2024, 5:17 am, edited 1 time in total.
Speak softly, and carry Doombringer.
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: GUI: slider max/min labels

Post by gfgtdf »

from a quick look at the code this doesn't seem to be possible. If it isn't you have two options:
1) use your own label and update it accordingly via a callback to the slider (this is what the multiplayer create game code does, also because it shows the label above the sliders),
2) add a custom slider_definition that draws the slider differently
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
white_haired_uncle
Posts: 1203
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: GUI: slider max/min labels

Post by white_haired_uncle »

If I understand you correctly, the issue is that the amount of space available for the min/maximum_value_label string is fixed, and pretty small. And from the looks of it, between 1.16.10 and 1.17.24, someone has tried to address this by adjusting the text width accordingly (but not enough).

If this is correct:
1) It seems rather useless (though I hate to use that word about something someone else spent their time on) as it's so small.
2) The example for maximum_value_label at https://devdocs.wesnoth.org/classgui2_1_1slider.html is misleading, as "unlimited" wouldn't fit.

Fortunately, I'm only looking to document how sliders work, so I can just leave this part out.

Thanks, at least now I can stop trying to figure it out (I'm stubborn that way).
Speak softly, and carry Doombringer.
Post Reply