Textbuttons changing size in 6.18

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
User avatar
qirien
Miko-Class Veteran
Posts: 538
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Textbuttons changing size in 6.18

#1 Post by qirien » Wed Oct 01, 2014 2:54 pm

I have some textbuttons that are part of the same size_group (I checked the style inspector), and in 6.17 they looked fine, but now in 6.18 they sometimes change size when being deselected. They shrink to the size they would be to fit the text.

Here's the code I'm using (modified from the new DSE). It's the dp_choice buttons that are causing the problem:

Code: Select all

# This contains code for the new day planner. You probably
# don't want to change this file, but it might make sense to
# change many of the variables or styles defined here from
# other files.


init -100 python:
    # The frame containing the day planner.
    style.dp_frame = Style(style.frame)
    style.dp_vbox = Style(style.vbox)
    style.dp_hbox = Style(style.hbox)

    # The frame and vbox containing a single choice.
    style.dp_choice = Style(style.default)
    style.dp_choice_vbox = Style(style.vbox) 
    style.dp_choice.xalign = 0.5
    
    # Buttons.
    style.dp_choice_button = Style(style.button)
    style.dp_choice_button_text = Style(style.button_text)
    style.dp_choice.size_group = "dp_choice_button"

    style.dp_done_button = Style(style.button)
    style.dp_done_button_text = Style(style.button_text)

    # Labels.
    style.dp_label = Style(style.label)
    style.dp_label_text = Style(style.label_text)

    # The title of the done button.
    dp_done_title = "All Done"

    # A map from period name to the information we know about that
    # period.
    __periods = { }

    # The period we're updating.
    __period = None
    
    class __Period(object):

        def __init__(self, name, var):
            self.name = name
            self.var = var
            self.acts = [ ]

    def dp_period(name, var):
        __periods[name] = store.__period = __Period(name, var)

    __None = object()
        
    def dp_choice(name, value=__None, enable="True", show="True"):

        if not __period:
            raise Exception("Choices must be part of a defined period.")

        if value is __None:
            value = name
        
        __period.acts.append((name, value, enable, show))

    def __set_noncurried(var, value):
        setattr(store, var, value)
        return True
        
    __set = renpy.curry(__set_noncurried)
        
# Our Day Planner displays the stats, and buttons for the user to choose what to do
# during each period of time defined in "periods".
screen day_planner(periods):
    # indicate to Ren'Py engine that this is a choice point
    $ renpy.choice_for_skipping()
    window:
        style_group "dp"  
        use display_stats(True, True, True, True)
        use display_planner(periods)            
            
screen display_planner(periods):            
        vbox:
            style_group "dp"        
            label "Focus" yalign 0.0 xalign 0.5 style "cp_label"
            vbox:
                $ can_continue = True
                for p in periods:
                    frame:
                        vbox:
                            label p
                            if p not in __periods:
                                $ raise Exception("Period %r was never defined." % p)
                            $ this_period = __periods[p]
                            $ selected_choice = getattr(store, this_period.var)
                            $ valid_choice = False
                            $ num_choices = len(this_period.acts)
                            $ choice_rows = ((num_choices-1) // 2) + 1
                            grid 2 choice_rows: 
                            # TODO: some buttons change size after being deselected?
                            #vbox:
                                style_group "dp_choice"
                                for name, curr_val, enable, should_show in this_period.acts:
                                    $ show_this = eval(should_show)
                                    $ enable = eval(enable)

                                    $ selected = (selected_choice == curr_val)
                            
                                    if show_this:
                                        if enable:
                                            textbutton name action SetField(store, this_period.var, curr_val)
                                        else:
                                            textbutton name
                
                                    if show_this and enable and selected:
                                        $ valid_choice = True

                                if not valid_choice:
                                    $ can_continue = False
                                    
                                # We need an extra blank spot if there are an odd number of choices
                                # and we didn't fill up our grid
                                if ((2 * choice_rows) != num_choices):
                                    text ""                                
                                                       
            if (can_continue):
                textbutton dp_done_title style "dp_done_button" xalign 1.0 action Jump("job_focus")
            else:
                textbutton dp_done_title style "dp_done_button" xalign 1.0

Finished games:
Image
Image
Image

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Textbuttons changing size in 6.18

#2 Post by PyTom » Wed Oct 01, 2014 8:18 pm

I can't repeat this. Can you put together a replication, and a sequence of steps I need to go through to get this to happen?
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
qirien
Miko-Class Veteran
Posts: 538
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: Textbuttons changing size in 6.18

#3 Post by qirien » Thu Oct 02, 2014 3:23 pm

I had posted a big example, but then I made a smaller test case below that is much simpler. See next post.
Last edited by qirien on Tue Oct 14, 2014 2:17 pm, edited 1 time in total.
Finished games:
Image
Image
Image

User avatar
qirien
Miko-Class Veteran
Posts: 538
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: Textbuttons changing size in 6.18

#4 Post by qirien » Tue Oct 14, 2014 2:08 pm

OK, that example I posted was too complicated. Here's a much simpler example to reproduce this bug. It looks like it has something to do with grids, as it does not manifest if the buttons are not in a grid.

Code: Select all

style our_style_button:
    size_group "our_buttons"
    background "#000"

screen button_grid:
    window:
        frame:
            style_group "our_style"
            vbox:
                grid 3 2:
                    textbutton "Lots of" action NullAction()
                    textbutton "grid buttons of" action NullAction()
                    textbutton "different sizes" action NullAction()
                    textbutton "to" action NullAction()
                    textbutton "test their" action NullAction()
                    textbutton "consistency" action NullAction()
                    
                    
                textbutton "Lots of" action NullAction()
                textbutton "buttons of" action NullAction()
                textbutton "different sizes" action NullAction()
                textbutton "not in a grid" action NullAction()
                    

label start:
    "This is a test of buttons in a grid in the same size_group"
    call screen button_grid
    return

So, start up this script, and you should notice that as you hover over buttons in the first group, that are in a grid, they change size from fitting the text to fitting the sizegroup. This only occurs in 6.18, not in 6.17. Hopefully this is a better test case so that you can reproduce and track down this bug. Thank you!
Finished games:
Image
Image
Image

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Textbuttons changing size in 6.18

#5 Post by PyTom » Tue Oct 14, 2014 2:48 pm

Are you on 6.18.2? This was probably fixed there.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
qirien
Miko-Class Veteran
Posts: 538
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: Textbuttons changing size in 6.18

#6 Post by qirien » Tue Oct 14, 2014 3:40 pm

Yes, it was fixed. Sorry, I didn't know about the new version! Thank you!
Finished games:
Image
Image
Image

Post Reply

Who is online

Users browsing this forum: No registered users