My Preferences screen layout is broken and I'm not sure why

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Ultra_HR
Regular
Posts: 39
Joined: Tue Dec 02, 2014 4:50 pm
Completed: Surkea, Arcadia, Cerulean
Projects: Missing Stars
Organization: Somnova Studios
IRC Nick: Ultra_HR
Contact:

My Preferences screen layout is broken and I'm not sure why

#1 Post by Ultra_HR » Fri Jul 10, 2015 8:33 am

Hey there,

I'm trying to code a custom preferences menu. It's supposed to look like this mockup:
Image

I figure the easiest way to get that layout would be to use a grid with 1 column and 4 rows, then split each row up with hboxes and frames. This is the code I've cobbled together to try to achieve that:

Code: Select all

grid 1 4:
    style_group "prefs"
    xfill True

    hbox:
        frame:
            style_group "pref"
            has vbox

            label "display"
            hbox:
                textbutton "window" action Preference("display", "window")
                textbutton "fullscreen" action Preference("display", "fullscreen")

        frame:
            style_group "pref"
            has vbox

            label "transitions"
            hbox:
                textbutton "show all" action Preference("transitions", "all")
                textbutton "show none" action Preference("transitions", "none")

    hbox:
        frame:
            style_group "pref"
            has vbox

            label "skip"
            hbox:
                textbutton "all messages" action Preference("skip", "seen")
                textbutton "seen messages" action Preference("skip", "all")

        frame:
            style_group "pref"
            has vbox

            label "font size"
            hbox:
                textbutton "14" action StylePreference("size", "14")
                textbutton "18" action StylePreference("size", "18")
                textbutton "22" action StylePreference("size", "22")

        frame:
            style_group "pref"
            has vbox

            label "after choices"
            hbox:
                textbutton "stop skipping" action Preference("after choices", "stop")
                textbutton "keep skipping" action Preference("after choices", "skip")
    hbox:
        frame:
            style_group "pref"
            has vbox

            label "auto-forward speed"
            bar value Preference("auto-forward time")

        frame:
            style_group "pref"
            has vbox

            label "music volume"
            bar value Preference("music volume")

    hbox:
        frame:
            style_group "pref"
            has vbox

            label "text speed"
            bar value Preference("text speed")

        frame:
            style_group "pref"
            has vbox

            label "sound volume"
            bar value Preference("sound volume")
Which, in my head, should work fine. But this is what I get out of it:
Image

Clearly I've done something wrong, but I don't understand what. I thought the hboxes in each row would spread the frames evenly across the row, but the first frame in each hbox is taking up all of the row. What should I do to fix that? (I'm not worried about the navigation menu by the way, I've already fixed that since taking that screenshot.)

I could just cheat and use an imagemap of course - but probably some stuff will be added to this menu later, and I would like to learn how to do it properly.

Thanks in advance for any advice!
I'm the writing lead for Somnova Studios and the Annaliese route writer for Missing Stars. You can play Act 1 now. I also co-wrote Arcadia and did programming for Cerulean.

User avatar
78909087
Veteran
Posts: 277
Joined: Sat Aug 16, 2014 2:33 pm
Completed: Dungeons and Don't Do It, Wake Up
Projects: Lethe
IRC Nick: Pacermist
Contact:

Re: My Preferences screen layout is broken and I'm not sure

#2 Post by 78909087 » Fri Jul 10, 2015 11:54 am

I would recommend using imagemaps regardless!
(Even if you change things around, all you need to do is change the x,y position, it's simple, and it's really not worth the hassle to use unruly code...)

They're really not that hard to learn to use, and there are helpful tutorials out there for customizing screens, like this one.

Sorry that I can't be of assistance with your current problem, but happy coding!
I am not friends with the sun.
Image

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: My Preferences screen layout is broken and I'm not sure

#3 Post by xela » Fri Jul 10, 2015 12:19 pm

Recommending to use imagemaps unless you believe yourself to be absolutely inept at coding and not willing to learn is a bad idea. You'd be giving up way too much with no real benefit.

As to the layout, you are expecting unreasonable things from your code, there is no need for evil grid here, you're expecting hboxes to do something without telling them how and etc.

Although you may be supplying all the data with style group... It's hard to tell just from the code you posted.
Like what we're doing? Support us at:
Image

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: My Preferences screen layout is broken and I'm not sure

#4 Post by nyaatrap » Fri Jul 10, 2015 12:46 pm

Actually, grid is one of the hardest way. It looks easy at the first glance, but it has zero flexibility. And It's better not to use style group before you fully understand about styles.

User avatar
SinnyROM
Regular
Posts: 166
Joined: Mon Jul 08, 2013 12:25 am
Projects: Blue Birth
Organization: Cosmic Static Games
Contact:

Re: My Preferences screen layout is broken and I'm not sure

#5 Post by SinnyROM » Tue Jul 14, 2015 7:21 pm

Assuming you haven't changed the default preferences style groups, xela is right in that the cause is in the style group:

Code: Select all

init -2:
    style pref_frame:
        xfill True
        xmargin 5
        top_margin 5

    style pref_vbox:
        xfill True
Note that xfill determines whether the element takes up the horizontal space (http://www.renpy.org/doc/html/style_pro ... erty-xfill). I agree that a grid won't be used to its full potential in this case; for single columns, a vbox works just fine.

Post Reply

Who is online

Users browsing this forum: Ocelot