Positioning & customizing in-game menu

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
reaktor
Regular
Posts: 27
Joined: Wed Jun 04, 2008 7:25 am
Contact:

Positioning & customizing in-game menu

#1 Post by reaktor »

I'v been trying to customize ingame menu for different positioning and size, unfortunately with no luck.

How can I set choice-menu to appear only in, say, left top part of screen? I'v tried something like:

Code: Select all

    style.menu_window.left_margin=100
    style.menu_window.top_margin=100
    style.menu_window.right_margin=500
    style.menu_window.bottom_margin=500
Shouldn't this make menu_window appear at top left side of screen with certain height/width which depends on resolution?

Is there some easy way to set width & height of object and just position this object with xpos&ypos? (or in case there isn't, why isn't there?)


reaktor
Regular
Posts: 27
Joined: Wed Jun 04, 2008 7:25 am
Contact:

Re: Positioning & customizing in-game menu

#3 Post by reaktor »

I have read this thread already, but for some reason i'm still having lots of hard time with styling...

Edit:

Now I'm really confused. I got margins to work with following code:

Code: Select all

    style.menu_window.background=Solid("#c71585")
    style.menu_window.xalign = 0
    style.menu_window.yalign = 0
    style.menu_window.left_margin = 50
    style.menu_window.right_margin = 200
    style.menu_window.top_margin = 50
    style.menu_window.bottom_margin = 150
    style.menu_window.xfill = True
    style.menu_window.yfill = True
The strange thing is that I have fiddled with UI-margin-positioning before and done exactly same "top/right/bottom/left" defining as I was now trying to do for menu_window. Still, for some reason, menu_window didn't want to position properly before using xalign=0 and yalign=0. After this I could use both absolute and floatpoint positioning for margins. I had even tried putting offsets to zero and xpos to zero, but didn't get this to work. Strangely enough with aligns zeroed menu_window positioning seems to work like a charm... I wonder if this is going to put me into trouble and some point.

reaktor
Regular
Posts: 27
Joined: Wed Jun 04, 2008 7:25 am
Contact:

Re: Positioning & customizing in-game menu

#4 Post by reaktor »

Ok, little more advanced sequel to original subject...

I have modified in-game menu so that menu reminds more default main menu ( = it's positioned to certain part of screen ). As before, I have code similar to this:

Code: Select all

    
style.menu_window.background=RoundRect("#000000bb")
    style.menu_window.xalign = 0
    style.menu_window.yalign = 0
    style.menu_window.left_margin = 50
    style.menu_window.right_margin = 200
    style.menu_window.xfill = True
... now, I'd like to make dialog appear at over the menu (or in other words, menu should be showing after dialogue):

Code: Select all

    
style.menu_window.background=RoundRect("#000000bb")
    style.say_window.xalign = 0
    style.say_window.yalign = 0
    style.say_window.left_margin = 50
    style.say_window.top_margin = 50
    style.say_window.right_margin = 200
    style.say_window.xfill = True
Question is: Is there a way to write something similar to this (because say_window's height might change depending on amount of text) ? :

Code: Select all

 
    style.menu_window.top_margin = 50 + style.say_window.height
As far as I know, styles are static and cannot be changed dynamically, but is there some solution for this? How about is there way to get/set window height/width with absolute values (without using some calculation based on resolution and margin-positions) ?

EDIT:
These two "screenshots" should explain question more visually:
Image

JQuartz
Eileen-Class Veteran
Posts: 1265
Joined: Fri Aug 31, 2007 7:02 am
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Contact:

Re: Positioning & customizing in-game menu

#5 Post by JQuartz »

reaktor wrote:As far as I know, styles are static and cannot be changed dynamically,
Yeah, I think so too. If you want to have a dynamically positioned menu, maybe you should use ui like so:

Code: Select all

init:
    $ menu_width=200
    $ say_window_height=400
label start:
    $ ui.vbox(xpos=10, ypos=10)
    $ ui.frame(xminimum=menu_width, yminimum=say_window_height, xmaximum=menu_width)
    $ ui.text("This is the stuff in say_win. ")
    $ ui.null(height=10)
    $ ui.textbutton("Choice 1", ui.jumps("choice_1_chosen"), xminimum=menu_width,xmaximum=menu_width)
    $ ui.textbutton("Choice 2", ui.jumps("choice_2_chosen"), xminimum=menu_width,xmaximum=menu_width)
    $ ui.textbutton("Choice 3", ui.returns("Choice 3"), xminimum=menu_width,xmaximum=menu_width)
    $ ui.close()
    
    $ choice=ui.interact()
    if choice=="Choice 3":
        "You selected choice 3."
        jump continue_story
    
label choice_1_chosen:
    "You selected choice 1."
    jump continue_story
label choice_2_chosen:
    "You selected choice 2."
    jump continue_story
    
label continue_story:
    $ menu_width=200
    $ say_window_height=200
    jump start
You can read about uis here:http://www.renpy.org/wiki/renpy/doc/ref ... _Functions
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.

Guest

Re: Positioning & customizing in-game menu

#6 Post by Guest »

Sure, that's one option. The thing just is that I recently changed code from UI back to menu-based :)

Well, with good preplanning I believe I can live with static positioning too, and if not, I'll rollback to ui-positioning.

- Reaktor

Post Reply

Who is online

Users browsing this forum: decocloud