Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit)

Thanks for your work on this extension. It's extremely impressive.
Unfortunately I have ran into an issue with a horizontal bar nested within a controller_viewport. The video should make it clear, but it's that these bars behave differently depending on if they are just in a vbox, in a regular viewport or within a controller_viewport. It behaves normally when used with a controller. The game's resolution is 3840x2160 in case that matters. I've been banging my head against this issue for the last couple of hours and I can't seem to solve it. 

vbox:
    spacing 50
    hbox:
        label _("TEXT SPEED")
        null width 50
        controller_bar value Preference("text speed") alt "Adjust Text Speed" style "preferences_slider" yalign 0.5
        label " <- NOT in controller_viewport" yalign 0.5
    viewport:
        hbox:
            label _("TEXT SPEED")
            null width 50
            controller_bar value Preference("text speed") alt "Adjust Text Speed" style "preferences_slider" yalign 0.5
            label " <- in regular viewport" yalign 0.5
    controller_viewport:
        id "pref_display_vp"
        xsize 2500
        mousewheel True
        draggable renpy.variant("touch")
        vbox:
            spacing 50
            hbox:
                label _("TEXT SPEED")
                null width 50
                controller_bar value Preference("text speed") alt "Adjust Text Speed" style "preferences_slider" yalign 0.5
                label " <- in controller_viewport" yalign 0.5


Thanks for the detailed bug report!

I'm currently investigating this; I don't have any particular answers yet, though the problem appears with a regular bar as well as a controller bar, so it seems to be a problem specific to the controller viewport. Strangely, it doesn't always appear either - you'll notice that the bars that come with the preference screen included in the template don't have this problem. I've been able to tentatively narrow it down to something going wrong in the render method. I'll keep plugging away at it when I have time. In the meantime, you might play around with copying over the preference screen controller_bar layout and adjusting it to find a version that works.

(+1)

Spoke too soon actually; try replacing the following function with these modifications:

def get_all_children(d, xoffset, yoffset, width, height):
    """Return all the children, grandchildren etc of d."""
    children = [ ]
    offsets = [ ]
    sizes = [ ]
    if not hasattr(d, "children"):
        return children, offsets, sizes
    for i, child in enumerate(d.children):
        ## Render it to get the size
        # cr = child.render(width, height, 0, 0) ## Caused some weirdness with bars
        cr = renpy.render(child, width, height, 0, 0)
        sizes.append((cr.width, cr.height))
        children.append(child)
        offsets.append(d.offsets[i])
        if hasattr(child, "children"):
            ch, of, sz = get_all_children(child, d.offsets[i][0], d.offsets[i][1], cr.width, cr.height)
            children.extend(ch)
            offsets.extend(of)
            sizes.extend(sz)
    new_offsets = [ ]
    for of in offsets:
        new_offsets.append((of[0]+xoffset, of[1]+yoffset))
    return children, new_offsets, sizes

Let me know if that fixes your problem. I still need to do a bit more testing to make sure other aspects of the viewport work as expected, but this did solve the bar problems for me.

Thank you so much! This instantly fixed the issue for me!

It's a bit of weird one. The bars with custom bar value objects never exhibited that issue, but the bars using Preference values like the ones for the audio controls definitely did for me. So the ones provided in the expansion like "Left stick sensitivity" never had this problem cause they use custom classes inherited from BarValue. Making python classes inherited from BarValue was the workaround I have found to work. I tried that for the volume sliders, but it can be a bit funky sometimes and the value can sometimes jump around oddly.
Anyways, thanks again and thank you for the effort you put into this project!