Definition popups that don't replace the dialogue window

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
SleepKirby
Veteran
Posts: 255
Joined: Mon Aug 09, 2010 10:02 pm
Projects: Eastern Starlight Romance, Touhou Mecha
Organization: Dai-Sukima Dan
Location: California, USA
Contact:

Definition popups that don't replace the dialogue window

#1 Post by SleepKirby »

As demonstrated by the Tutorial, section "Fonts and Text Tags":
tutorial_hyperlink-defn_1.png
After clicking the hyperlink.
After clicking the hyperlink.

Code: Select all

    $ definition = Character(None,
                             window_yfill=True,
                             window_xmargin=20,
                             window_ymargin=30)
...
    e "{a=define_hyperlink}Hyperlinks{/a} let buttons be defined using text tags."
...
label define_hyperlink:

    definition "A hyperlink is a button that is defined inside text, using text tags. They're ideal for including definitions of words used in the script, but they shouldn't be used in place of menus."

    return
I want to change the definition box (in the second screen) to be as non-intrusive as possible, by (1) making it smaller, and (2) putting it in a separate box from the say window, so that the previous dialogue doesn't disappear in the process.

I can do (1), and for (2) I can at least put the definition in a separate box (by using a separate text displayable, instead of the tutorial's method of treating it like a line of dialogue). But even when the definition's in a separate box, showing the separate box causes the say window to disappear - so I can't get the previous dialogue to stay. How would I make a separate definition box that appears alongside the say window, instead of replacing the say window?

User avatar
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:

Re: Definition popups that don't replace the dialogue window

#2 Post by PyTom »

You can change config.hyperlink_callback to do whatever you want. (I'd suggest having it popup an appropriate screen.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
SleepKirby
Veteran
Posts: 255
Joined: Mon Aug 09, 2010 10:02 pm
Projects: Eastern Starlight Romance, Touhou Mecha
Organization: Dai-Sukima Dan
Location: California, USA
Contact:

Re: Definition popups that don't replace the dialogue window

#3 Post by SleepKirby »

Hmm... okay, I tried this, and it's a bit closer but not quite there:

Code: Select all

init python:
    esr_definitions = {'kotatsu': 'A low table with a heat source underneath.'}
    
    def esr_hyperlink_function(target):
        term_to_define = target
        defn_text = "{b}%s{/b}\n%s" % (term_to_define, esr_definitions[term_to_define])
        renpy.show_screen("definition", definition_text=defn_text)
        # renpy.show_screen("definition", _transient=True, definition_text=defn_text)
    
    config.hyperlink_callback = esr_hyperlink_function
    
screen definition:
    
    frame xalign 0.5 yalign 0.5 background "#0003":
        vbox:
            text definition_text
            imagebutton idle "gui_images/Icon_x_idle.png" hover "gui_images/Icon_x_hover.png" clicked Return()
It doesn't replace the say screen now, as desired. Two other issues though:

(1) The definition doesn't show up right after I click the hyperlink. After clicking the link, if I advance the text once (mouseclick, space, or enter), the definition appears. (Funny, I think I had a very similar problem before, but can't seem to get the hang of it. >_>;)

(2) I can't close the definition, even when I click on the imagebutton (last line in code above). I guess I'm unable to interact with the definition - when I click, the definition stays and the dialogue advances.

Also, if I show the screen with _transient=True, the definition never shows up. Might be related to problem (1) though.

I guess I should've mentioned it before, but I'm thinking the interaction with the definition popup should be the same as in the tutorial - click anywhere to close. Only the appearance (smaller, not hiding say window) would be different. (Though if needed, clicking the imagebutton to close is fine too.)

User avatar
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:

Re: Definition popups that don't replace the dialogue window

#4 Post by PyTom »

For (1), you want to call renpy.restart_interaction() after the call to show_screen().
For (2), you want to have clicked do Hide('definition'), rather than just Return().
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
SleepKirby
Veteran
Posts: 255
Joined: Mon Aug 09, 2010 10:02 pm
Projects: Eastern Starlight Romance, Touhou Mecha
Organization: Dai-Sukima Dan
Location: California, USA
Contact:

Re: Definition popups that don't replace the dialogue window

#5 Post by SleepKirby »

Ahh, I see. Problems solved - thank you very much!

Post Reply

Who is online

Users browsing this forum: Google [Bot]