[SOLVED] Choice menu with additional info pane

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
Queex
Regular
Posts: 46
Joined: Sat Mar 14, 2015 9:47 am
Contact:

[SOLVED] Choice menu with additional info pane

#1 Post by Queex »

This seems like it should be a question that already has an answer, but my googling has let me down.

What I want is something that behaves like the standard choice menu, except that there is an additional window providing more information on the currently highlighted choice. So when a new option is highlighted, by whatever means, that information panel updates. Think menu-driven RPG combat system.

I can see how to do something a little similar using a 2-step process, where selecting a menu item presents the extra information and a confirm/back pair of options, but that would be very clunky and involve a lot of extra clicking/hitting return.

This doesn't seem like something that easy to patch in to the existing screen as it might involve monkeying about with the programme flow. Is there an example knocking about someone can steer me to, or failing that has anyone got an idea where to start implementing it?
Last edited by Queex on Thu Apr 13, 2017 11:21 am, edited 1 time in total.

User avatar
Queex
Regular
Posts: 46
Joined: Sat Mar 14, 2015 9:47 am
Contact:

Re: Choice menu with additional info pane

#2 Post by Queex »

So some further digging in https://www.renpy.org/doc/html/screens.html suggests that I can give the items a hover action to change a screen variable. Then, I think, I can reference that screen variable and display it in a window, as defined in the choice window. However, I think then I need to manually invoke the screen rather than let Renpy do it the usual way.

User avatar
indoneko
Miko-Class Veteran
Posts: 528
Joined: Sat Sep 03, 2016 4:00 am
Contact:

Re: Choice menu with additional info pane

#3 Post by indoneko »

What I want is something that behaves like the standard choice menu, except that there is an additional window providing more information on the currently highlighted choice
It would be awesome if we could really do that with the default renpy choice system. AFAIK, Renpy only uses 2 item pairs for the choices (which is caption + action). How would we supply the highlight info?
My avatar is courtesy of Mellanthe

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2405
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Choice menu with additional info pane

#4 Post by Ocelot »

indoneko wrote:AFAIK, Renpy only uses 2 item pairs for the choices (which is caption + action). How would we supply the highlight info?
Store it in external global variable(s) and pass handle to info for current set of choices encoded in caption string. Or one of the choices themselves.
< < insert Rick Cook quote here > >

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Choice menu with additional info pane

#5 Post by trooper6 »

Do you want a pop up screen or a screen that is ever present?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
indoneko
Miko-Class Veteran
Posts: 528
Joined: Sat Sep 03, 2016 4:00 am
Contact:

Re: Choice menu with additional info pane

#6 Post by indoneko »

Ocelot wrote:Store it in external global variable(s) and pass handle to info for current set of choices encoded in caption string. Or one of the choices themselves.
Ahh! I never thought of that idea. :D
So basically we could use a delimiter in the menu's choice like this?

Code: Select all

menu weekend:
    "Hit the book | You will gain some intelligence":
        "You spend your weekend at the local library"
        $int +=1
    "Play basketball | You will gain some power":
        "You spend your weekend practicing slam dunk with your friends"
        $pow +=1


@trooper6 : how would you code it if it is a pop-up screen/tooltip?
And do you use something similar to Ocelot's method above, or something different?
My avatar is courtesy of Mellanthe

User avatar
Queex
Regular
Posts: 46
Joined: Sat Mar 14, 2015 9:47 am
Contact:

Re: Choice menu with additional info pane

#7 Post by Queex »

trooper6 wrote:Do you want a pop up screen or a screen that is ever present?
Ideally something that quietly hides itself if there is no context data. Eventually I want to style the choice menus so they're nice and compact in one corner, with the contextual panel in the facing corner if present.

I tried to get fancy and arrived at something that I thought would work, but didn't.

I changed the choice screen as follows:

Code: Select all

screen choice(items, **kwargs):
    default choice_context=None
    style_prefix "choice"

    frame:
        has vbox
        if 'hovered' in kwargs:
            for i in items:
                textbutton i.caption action i.action hovered SetScreenVariable("choice_context",kwargs['hovered'][i])
        else:
            for i in items:
                textbutton i.caption action i.action
        
        if choice_context is not None:
            label choice_context
It would be invoked via:

Code: Select all

    python:
        hovered={"Item 1":"Hover 1", "Item 2":"Hover 2"}
        mout=renpy.display_menu([("Context menu",None),("Item 1",1),("Item 2",2)],hovered=hovered)
However this does not appear to work, perhaps because the kwargs is not getting passed through. The delimiter approach is probably much, much cleaner, however.

User avatar
Queex
Regular
Posts: 46
Joined: Sat Mar 14, 2015 9:47 am
Contact:

Re: Choice menu with additional info pane

#8 Post by Queex »

I believe I have it licked, functionally.

Code: Select all

screen choice(items):
    default choice_context=None
    style_prefix "choice"

    frame:
        has vbox
        for i in items:
            if '|' in i.caption:
                textbutton i.caption.split('|')[0] action i.action hovered SetScreenVariable("choice_context", i.caption.split('|')[1])
            else:
                textbutton i.caption action i.action hovered SetScreenVariable("choice_context", None)
        
        if choice_context is not None:
            label choice_context
You use '|' as a delimiter in the menu choice caption. In this implementation, it will also hide the extra info label if the menu item has no extra info given. Of course, the styling will need improvement but the functionality is there.

ETA: You can probably be more efficient and avoid splitting multiple times, but I wasn't sure how much raw python I could get away with in screen language so played it safe.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Choice menu with additional info pane

#9 Post by trooper6 »

This is similar to what I was thinking. But I was thinking of using renpy.notify
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Saltome
Veteran
Posts: 244
Joined: Sun Oct 26, 2014 1:07 pm
Deviantart: saltome
Contact:

Re: Choice menu with additional info pane

#10 Post by Saltome »

trooper6 wrote:This is similar to what I was thinking. But I was thinking of using renpy.notify
Um, why would you use renpy.notify for anything? In my experience it's horrible. And it usually bugs out.
Deviant Art: Image
Discord: saltome
Itch: Phoenix Start

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Choice menu with additional info pane

#11 Post by trooper6 »

Saltome wrote:
trooper6 wrote:This is similar to what I was thinking. But I was thinking of using renpy.notify
Um, why would you use renpy.notify for anything? In my experience it's horrible. And it usually bugs out.
I've never had a problem with it being buggy. I customize this screen (especially to include animations) and use it in all sorts of different ways. I use it to note hit point losses, or increases in affection...and the what the OP described sounded like a perfect case for renpy.notify.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Majestic-12 [Bot], snotwurm