Pop-up menu?
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.
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.
-
- Regular
- Posts: 62
- Joined: Mon Oct 25, 2004 2:26 pm
- Location: The city of snow (Qc, CA)
- Contact:
Pop-up menu?
As I don't really like the look of a menu in the dialogue box, I've been playing around with UI functions to create some form of pop-up menu, like this. Now, that's probably one of the dumbest question ever, but... how do I jump to a label using an UI function? Looking at the tutorial, I read something about a variable returned by renpy.interact() and used in a series of if statements, but having about the ability of your average toenail when it comes to programming, everything I tried miserably failed and took me to an empty screen with only a background instead.
I also tried something involving a different window for the menus, but that window replaced the dialogue window, so I was left with only the menu window in the middle of the screen. Is there a way to use window styles instead of UI functions to display two windows at once like in the screenshot?
I also tried something involving a different window for the menus, but that window replaced the dialogue window, so I was left with only the menu window in the middle of the screen. Is there a way to use window styles instead of UI functions to display two windows at once like in the screenshot?
I'm not a meat bun ~nya
Code: Select all
$ ui.window(xfill=800, yfill=600, xmargin=0, ymargin=0, background=Solid((0,0,0,255)))
$ ui.vbox(padding=10, xpos=0.5, ypos=0.5, xanchor="center", yanchor="center")
$ ui.text("Please choose if you want a fullscreen or window:", color=(255,255,255,255))
$ ui.textbutton("Fullscreen", clicked=ui.returns("f"))
$ ui.textbutton("Window", clicked=ui.returns("w"))
$ ui.close()
$ choice = renpy.interact(suppress_overlay=True)
if choice == "f":
$ _preferences.fullscreen = True
elif choice == "w":
$ _preferences.fullscreen = False
- PyTom
- Ren'Py Creator
- Posts: 16096
- 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:
There are two main ways in Ren'Py to jump to computed locations. You can use ui.jumps in python code, or the new (in 4.4) jump expression statement.
ui.jumps() is used as the clicked argument to a button, and causes control to go to the label when the button is clicked.
For example:
Alternatively, you can express this using ui.menu and a jump expression statement. (This is probably preferred, as Ren'Py menus support the arrow keys.)
Either of these should jump to the appropriate location.
Right now, there's no good way to have both a menu and a say statement on the screen at the same time. The problem with this is that the two respond differently to (for example) mouse clicks, which can confuse the system.
Probably the best way to handle this is to fake the say statement with ui functions. If you'd like, I can supply the code to show a say box without hooking up the say behavior to it. Let me know if this would help you.
Good to see you're still alive.
ui.jumps() is used as the clicked argument to a button, and causes control to go to the label when the button is clicked.
For example:
Code: Select all
python:
ui.window()
ui.vbox()
ui.text("Are you sure you want to lick that electrical outlet?")
ui.textbutton("Yes", clicked=ui.jumps("bad_shock"))
ui.textbutton("No", clicked=ui.jumps.("good_idea"))
ui.close()
ui.interact()
Code: Select all
python:
ui.window()
ui.menu([
("Are you sure you want to lick that electrical outlet?", None),
("Yes", "bad_shock"),
("No.", "good_idea")])
rv = ui.interact()
jump expression rv
Right now, there's no good way to have both a menu and a say statement on the screen at the same time. The problem with this is that the two respond differently to (for example) mouse clicks, which can confuse the system.
Probably the best way to handle this is to fake the say statement with ui functions. If you'd like, I can supply the code to show a say box without hooking up the say behavior to it. Let me know if this would help you.
Good to see you're still alive.
-
- Regular
- Posts: 62
- Joined: Mon Oct 25, 2004 2:26 pm
- Location: The city of snow (Qc, CA)
- Contact:
Ahah, thanks! So that's why I was taken to an empty window... I was using something similar to what Tage posted, but... I had a say statement just before the renpy.interact() part <^^;; It *did* allow me to see both the menu and the dialogue box, but it also confused the system. Well, if it can't be done like that, something that could emulate the say box like you suggested would be much appreciated, please.
Last edited by Piroshiki on Thu Dec 30, 2004 4:42 pm, edited 1 time in total.
I'm not a meat bun ~nya
- PyTom
- Ren'Py Creator
- Posts: 16096
- 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:
Okay, here's a function that can fake up a say window.
When called, this function will add a new say window the screen, but not call the interact function. (And, BTW, it's ui.interact, not renpy.interact. ui.interact does some additional checking.)
For example:
Sorry, but say is right now a fairly complicated process, and it's hard to hook into it in the way that you want. In the next major version of Ren'Py, I'll add a "interact" flag to the character object, so it'll be easy to make character objects that display their window without causing an interaction to take place.
It just wasn't really something I planned for, and the correct fix is just a bit too difficult for a monkeypatch.
Code: Select all
init:
python:
def fake_say(who, what, who_style='say_label',
what_style='say_dialogue',
window_style='say_window',
who_prefix='',
who_suffix=': ',
what_prefix='',
what_suffix='',
**properties):
"""
@param who: Who is saying the dialogue, or None if it's not being
said by anyone.
@param what: What is being said.
For documentation of the various prefixes, suffixes, and styles,
please read the documentation for Character.
"""
if who is not None:
who = who_prefix + who + who_suffix
what = what_prefix + what + what_suffix
ui.window(style=window_style)
ui.vbox(padding=10)
if who is not None:
ui.text(who, style=who_style, **properties)
ui.text(what, style=what_style, slow=True)
ui.close()
For example:
Code: Select all
$ fake_say("Nanase", "Are those correct? Name %(name)s" % globals(), color=(123, 123, 123, 255))
# Menu code goes here.
It just wasn't really something I planned for, and the correct fix is just a bit too difficult for a monkeypatch.
-
- Regular
- Posts: 62
- Joined: Mon Oct 25, 2004 2:26 pm
- Location: The city of snow (Qc, CA)
- Contact:
Working perfectly, thanks a lot!
And, while being at it... Is there any way to change the disposition of the items in the game menu, main menu and preferences options? Say, if I want to have two lines of image buttons instead of a column of text buttons, or something like that...
And, while being at it... Is there any way to change the disposition of the items in the game menu, main menu and preferences options? Say, if I want to have two lines of image buttons instead of a column of text buttons, or something like that...
I'm not a meat bun ~nya
- PyTom
- Ren'Py Creator
- Posts: 16096
- 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:
The main menu can be easily rewritten... IIRC, there's a section on that in newer versions of the tutorial.
The game menu is harder. There's a limited amount of support for it. (IIRC, there's a variable under library that lets you add/remove buttons from the game menu.) But you'd have to rewrite quite a bit of the library to change (for example) a textbutton to an imagebutton.
Sorry there isn't a really good answer to this. Maybe in the future I'll add more hooks into the library... But there's only so much I can do before you just have to start rewriting library.rpy yourself... and that's going to be a pain to keep up to date.
The game menu is harder. There's a limited amount of support for it. (IIRC, there's a variable under library that lets you add/remove buttons from the game menu.) But you'd have to rewrite quite a bit of the library to change (for example) a textbutton to an imagebutton.
Sorry there isn't a really good answer to this. Maybe in the future I'll add more hooks into the library... But there's only so much I can do before you just have to start rewriting library.rpy yourself... and that's going to be a pain to keep up to date.
-
- Regular
- Posts: 62
- Joined: Mon Oct 25, 2004 2:26 pm
- Location: The city of snow (Qc, CA)
- Contact:
Ah, I see... I already knew about adding stuff to menus, I played around with that a little while trying to change their layout - I could change the position and content, but nothing else, and I wondered if it was possible. Seems like it would be a a pain though, so... I'll try and find something else. Thanks anyway!
I'm not a meat bun ~nya
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], Ocelot