Ren'Py [solved] In-game menu question

Modzso

Nephle on board!
Game Developer
Feb 26, 2018
103
56
Howdy!

So I will try to describe my question as clearly as possible, I hope it succeeds.... on the official Ren'Py forum I didn't even get a single simple answer like: No

So I would like to know if it is possible to change the text alignment in the in-game menu some way?
basically the text aligning to the center:

347917

And I would like to separate the words and the number to each side of the button.
Words go to left side, numbers to the right side something like this:

347918

Or even more align to the sides.
Is this possible to do it for example with style properties directly when coding, or have to mess with the UI changing thing?

Update:

What left out: I mean in-game menu of choices shown by using the menu: statement
 
Last edited:

Belgerum

Visual Novel Dev
Game Developer
Mar 29, 2018
134
558
You'll probably want to do something in the screen code like:

Code:
frame background None xsize 800 ysize 80:
    text "Bla Bla Bla Bla Bla" xalign 0.0
    text "(0/10)" xalign 1.0
 

Modzso

Nephle on board!
Game Developer
Feb 26, 2018
103
56
You'll probably want to do something in the screen code like:

Code:
frame background None xsize 800 ysize 80:
    text "Bla Bla Bla Bla Bla" xalign 0.0
    text "(0/10)" xalign 1.0
Okay I left it out a critic part, I wanted to use it only with a few menus in game, not all of the menus. :(
 

Belgerum

Visual Novel Dev
Game Developer
Mar 29, 2018
134
558
Then edit only the screens you want to use it with. Simple code like this doesn't persist between screens.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,576
2,203
It might help if you clarify what you mean by "menu".

The main menu screens? - New Game / Load / Preferences ... that sort of thing?
Or the in-game menu of choices shown by using the menu: statement?
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,655
23,746
since Ren'Py 7.2.0 you can add arguments to choice menus.
you have to edit the screen that displays the choice menu.
Python:
screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            $ value,max = i.kwargs.get("numbers", [None, None])
            if value:
                button:
                    action i.action
                    has hbox:
                        xfill True
                    text i.caption:
                        xalign 0.0
                    text "([value:02d]/[max:02d])":
                        xalign 1.0
            else:
                textbutton i.caption action i.action
in the script you use it like
Python:
menu:
    "1. option" (numbers=[5,10]):
        "some important text"
        jump wherever1
    "2. option" (numbers=[10,10]):
        "more important text"
        jump wherever2
edit: the default value of the kwargs getter has to be a list
 
Last edited:

Modzso

Nephle on board!
Game Developer
Feb 26, 2018
103
56
It might help if you clarify what you mean by "menu".

The main menu screens? - New Game / Load / Preferences ... that sort of thing?
Or the in-game menu of choices shown by using the menu: statement?
Okay your right. :)

I mean in-game menu of choices shown by using the menu: statement. :)
 

Modzso

Nephle on board!
Game Developer
Feb 26, 2018
103
56
since Ren'Py 7.2.0 you can add arguments to choice menus.
you have to edit the screen that displays the choice menu.
Thank you very much, I will definitely test it soon. :)
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,576
2,203
I mean in-game menu of choices shown by using the menu: statement. :)
I think an option in gui.rpy to the effect of gui.choice_button_text_xalign = 0.5 would make ALL menu choices centered. (0.0 being left, 1.0 being right and 0.5 be center).
Which I (again) think is used as the default value for screen choice(items): within screens.rpy.

Which doesn't exactly answer your question... but gives you the rough area to be looking in.

I think the66 is probably closer to the right answer. But it's not something I've used personally since 7.2.0 came out.
 

Modzso

Nephle on board!
Game Developer
Feb 26, 2018
103
56
since Ren'Py 7.2.0 you can add arguments to choice menus.
you have to edit the screen that displays the choice menu.
Python:
screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            $ value,max = i.kwargs.get("numbers", [None, None])
            if value:
                button:
                    action i.action
                    has hbox:
                        xfill True
                    text i.caption:
                        xalign 0.0
                    text "([value:02d]/[max:02d])":
                        xalign 1.0
            else:
                textbutton i.caption action i.action
in the script you use it like
Python:
menu:
    "1. option" (numbers=[5,10]):
        "some important text"
        jump wherever1
    "2. option" (numbers=[10,10]):
        "more important text"
        jump wherever2
edit: the default value of the kwargs getter has to be a list
I tested it, unfortunately this moved every in-game menu to the upper left corner. :(
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,655
23,746
I tested it, unfortunately this moved every in-game menu to the upper left corner. :(
i assume it's for your game Intimate Brothel. the complete choice screen + styles would be this
Python:
screen choice(items):

    window:
        style "menu_window"
        xalign 0.5
        yalign 0.5

        has vbox:
            style "menu"
            spacing 2

        for i in items:
            $ value,max = i.kwargs.get("numbers", [None, None])
            if value:
                button style "menu_choice_button":
                    action i.action
                    hbox:
                        yalign 0.5
                        xfill True
                        text i.caption style "menu_choice":
                            xalign 0.0
                        text "([value:02d]/[max:02d])" style "menu_choice":
                            xalign 1.0
            else:
                button style "menu_choice_button":
                    action i.action
                    text i.caption style "menu_choice"


init -2:
    $ config.narrator_menu = True

    style menu_window is default
    style menu_choice is button_text clear

    style menu_choice_button is button:
        xsize int(config.screen_width * 0.45)
and the result is this
screenshot0001.png
 
  • Like
Reactions: Modzso

Modzso

Nephle on board!
Game Developer
Feb 26, 2018
103
56
i assume it's for your game Intimate Brothel. the complete choice screen + styles would be this
Python:
screen choice(items):

    window:
        style "menu_window"
        xalign 0.5
        yalign 0.5

        has vbox:
            style "menu"
            spacing 2

        for i in items:
            $ value,max = i.kwargs.get("numbers", [None, None])
            if value:
                button style "menu_choice_button":
                    action i.action
                    hbox:
                        yalign 0.5
                        xfill True
                        text i.caption style "menu_choice":
                            xalign 0.0
                        text "([value:02d]/[max:02d])" style "menu_choice":
                            xalign 1.0
            else:
                button style "menu_choice_button":
                    action i.action
                    text i.caption style "menu_choice"


init -2:
    $ config.narrator_menu = True

    style menu_window is default
    style menu_choice is button_text clear

    style menu_choice_button is button:
        xsize int(config.screen_width * 0.45)
and the result is this
View attachment 348892
You are awesome! (y)
 

Modzso

Nephle on board!
Game Developer
Feb 26, 2018
103
56
i assume it's for your game Intimate Brothel. the complete choice screen + styles would be this
Just a tiny little question, it doesn't matter if the numbers are read from a variable?
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,655
23,746
nope, doesn't matter.
Python:
init python:
    class anObject(object):
        def __init__(self, a=0):
            self.a = a

$ maxValue = 10
$ yourObject = anObject(10)

menu:
    "1. option" (numbers=[5,maxValue]):
        "some important text"
        jump wherever1
    "2. option" (numbers=[10,anObject.a]):
        "more important text"
        jump wherever2
it's only limited here because of the formatting :02d
 
  • Like
Reactions: Modzso