How to change Choice menu? [SOLVED]

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
Kaireen
Regular
Posts: 27
Joined: Mon Aug 27, 2012 7:41 pm
Location: Poland
Contact:

How to change Choice menu? [SOLVED]

#1 Post by Kaireen » Fri Aug 31, 2012 9:23 am

We have the test part in our game. It works perfectly...

but we have problem with customising Choice menu.
We want to have all possible answers divided in two columns in place of one column.
I was looking for answer in cookbook or tutorial (and some parts of this forum) but I couldn't find an answer :<

I would be grateful for any help, I have no idea how to change screens.rpy and customise that ;3;
Last edited by Kaireen on Fri Aug 31, 2012 5:41 pm, edited 2 times in total.
Hire me ~!
Shared account of illustration artist team !
our DA

User avatar
athenastar17
Regular
Posts: 57
Joined: Fri Aug 31, 2012 10:56 am
Contact:

Re: How to change Choice menu?

#2 Post by athenastar17 » Fri Aug 31, 2012 1:23 pm

Under choices in screens, you should change the vbox to hbox. vbox will stack items in a window vertically; hbox will stack them up horizontally.

You can also get "grids" by putting hbox's inside of vbox's and vice versa. Think of it as having a bookshelf. You have a bookshelf with each shelf stacked vertically, one on top of the other, and then the books ON the shelves are stacked horizontally, from left to right.

Note that just changing this won't cause your choices to display COMPLETELY right...you'll have to go in and mess with the styles to make them the proper width on your screen.

User avatar
Kaireen
Regular
Posts: 27
Joined: Mon Aug 27, 2012 7:41 pm
Location: Poland
Contact:

Re: How to change Choice menu?

#3 Post by Kaireen » Fri Aug 31, 2012 3:04 pm

Thank you for an answer..but I'm afraid I'm still slightly clueless xD;;;

I would like to make a greed so one answer go for left, next one for right and next one for the left but the row lower.

Code: Select all

window: 
        style "menu_window"        
        xalign 0.5
        yalign 0.5
        
        hbox:
          if i==1:
             vbox:
                 style "menu"
                 spacing 2
                 for caption, action, chosen in items:
                     if action:  
                         button:
                             action action
                             style "menu_choice_button" 
                             text caption style "menu_choice"         
                     else:
                         text caption style "menu_caption"
               $ i += 1
        else:
             vbox:
                 style "menu"
                 spacing 2
                 for caption, action, chosen in items:
                     if action:  
                         button:
                             action action
                             style "menu_choice_button" 
                             text caption style "menu_choice"         
                     else:
                         text caption style "menu_caption"
              $ i -=1
              
Obviously it do not work right xD; (it looked like it was only one vbox) I was that maybe I could add each vbox a place (like 0.25 and 0.75) or.. I don't know... I'm probably just lacking of experience to make it right. ;3;

the same code without " i " looks like in attachment but it only duplicate quiz xD;
Attachments
Obrazek 1.png

User avatar
athenastar17
Regular
Posts: 57
Joined: Fri Aug 31, 2012 10:56 am
Contact:

Re: How to change Choice menu?

#4 Post by athenastar17 » Fri Aug 31, 2012 3:39 pm

Ah...we're talking about many more choices than just two. I'll mess around with it a bit and see what I can come up with. I'm not that familiar with the Choice section of screens.rpy myself, but I will look.

User avatar
Kaireen
Regular
Posts: 27
Joined: Mon Aug 27, 2012 7:41 pm
Location: Poland
Contact:

Re: How to change Choice menu?

#5 Post by Kaireen » Fri Aug 31, 2012 4:01 pm

athenastar17 wrote:Ah...we're talking about many more choices than just two. I'll mess around with it a bit and see what I can come up with. I'm not that familiar with the Choice section of screens.rpy myself, but I will look.
Thank you so much!!

User avatar
athenastar17
Regular
Posts: 57
Joined: Fri Aug 31, 2012 10:56 am
Contact:

Re: How to change Choice menu?

#6 Post by athenastar17 » Fri Aug 31, 2012 4:09 pm

Here we go. What I'm doing here is, basically, within each vbox, telling it to only display every OTHER item (increment i...if i is even, display the choice; if not, do nothing...and vice versa for the other vbox). So, if you numbered your choices, the left vbox only displays the odd items, and the right vbox only displays the even ones. It also works for odd numbers of choices, of course. :)

Code: Select all

window: 
        style "menu_window"        
        xalign 0.5
        yalign 0.5
        
        $i = 0
        
        hbox:
            vbox:
                style "menu"
                spacing 2
                 
                for caption, action, chosen in items:
                    $i += 1
                    if i % 2 == 1:
                        if action:  
                             
                            button:
                                action action
                                style "menu_choice_button"                        
                                
                                text caption style "menu_choice"
                             
                        else:
                            text caption style "menu_caption"
            
            vbox:
                style "menu"
                spacing 2
                 
                for caption, action, chosen in items:
                    $i += 1
                    if i % 2 == 1:
                        if action:  
                             
                            button:
                                action action
                                style "menu_choice_button"                        
                                
                                text caption style "menu_choice"
                             
                        else:
                            text caption style "menu_caption"
By using %, you can actually add more vboxes to get more columns if you like, by making it i%3, i%4, etc...but you might have to mess with the i value a bit to do that, idunno. Haven't tested it.

The original problem with your code is that the if i==1 statement was BEFORE you declared your vbox... So whether the vbox displayed at all was dependent on your i value. Since it says "if i==1," display a vbox, and otherwise, display a different vbox...you're only ever going to get one vbox, not two...because i can't be both 1 and not 1. :? Not a good thing at all.
# ---------------------------------------------------
# Name's Gene. You're welcome to call me that, too.
# ---------------------------------------------------

User avatar
Kaireen
Regular
Posts: 27
Joined: Mon Aug 27, 2012 7:41 pm
Location: Poland
Contact:

Re: How to change Choice menu?

#7 Post by Kaireen » Fri Aug 31, 2012 4:33 pm

I see.. thank you so so much. I knew I'm doing something wrong xD now it makes much more sense!

I tried your code and it works perfectly... for OTHER number of answer!

When there is EVEN number of answers it's duplicates every second answer @.@;;;;;; I have no idea why it should work differently for different number of answer... but it does .___.''
Attachments
Obrazek 4.png

User avatar
athenastar17
Regular
Posts: 57
Joined: Fri Aug 31, 2012 10:56 am
Contact:

Re: How to change Choice menu?

#8 Post by athenastar17 » Fri Aug 31, 2012 4:39 pm

Ohhhh...yes. It does. How strange...AH! I know why that is. Let me give it another go.

EDIT: Sorry for the derp. Here...add this in between the vboxes (make sure it isn't inside the first box!) :

Code: Select all

if i % 2 == 0:
    $i = 0
This checks to see if we're on track to START putting even numbers in there, and changes i if we're not. Optionally, if you care enough about resetting i, you could write this:

Code: Select all

if i % 2 == 0;
    $i = 0
else:
    $i = 1
# ---------------------------------------------------
# Name's Gene. You're welcome to call me that, too.
# ---------------------------------------------------

User avatar
Kaireen
Regular
Posts: 27
Joined: Mon Aug 27, 2012 7:41 pm
Location: Poland
Contact:

Re: How to change Choice menu?

#9 Post by Kaireen » Fri Aug 31, 2012 5:12 pm

now it stopped working for odd number of answers. It's really strange....... ;3; ''''''
For some reason it worked for even when I used 2nd code.
EDIT : I change values 1 and 0 in 2nd code, then It started working for even!!! copy+paste - typo ( ; = : ) didn't change the way it behave!! sorry forgot to add this info

EDIT 2: 1st one with change:

Code: Select all

if i % 2 == 0:
    $i = 1
works perfectly!!!!!!! thank you so much!!! you really saved my day ;3;!!!!!!

User avatar
athenastar17
Regular
Posts: 57
Joined: Fri Aug 31, 2012 10:56 am
Contact:

Re: How to change Choice menu? [SOLVED]

#10 Post by athenastar17 » Fri Aug 31, 2012 8:42 pm

Yay! I helped! :D Good luck with your game. BTW your graphics so far look pretty nice. :)
# ---------------------------------------------------
# Name's Gene. You're welcome to call me that, too.
# ---------------------------------------------------

User avatar
athenastar17
Regular
Posts: 57
Joined: Fri Aug 31, 2012 10:56 am
Contact:

Re: How to change Choice menu? [SOLVED]

#11 Post by athenastar17 » Mon Sep 03, 2012 10:00 pm

Ah! Just thought you should know, I was looking around in the screen documentation a little more, and if you ever want more rows/columns, you can use this:
Grid

This displays its children in a grid. Each child is given an area of the same size, the size of the largest child.

It takes two parameters. The first is the number of columns in the grid, and the second is the number of rows in the grid. It takes the following property:

transpose
If False (the default), rows are filled before columns. If True, then columns are filled before rows.
spacing
The spacing between the rows and columns of the grid.

Code: Select all

screen grid_test:
     grid 2 3: #columns, rows
         text "Top-Left"
         text "Top-Right"

         text "Center-Left"
         text "Center-Right"

         text "Bottom-Left"
         text "Bottom-Right"
It works just like a v-box or h-box, except much simpler than what we did. Play around with it and see how how it goes.
# ---------------------------------------------------
# Name's Gene. You're welcome to call me that, too.
# ---------------------------------------------------

Post Reply

Who is online

Users browsing this forum: Bing [Bot]