Custom Viewport Screen Transition With Use

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
orian34
Newbie
Posts: 14
Joined: Tue Aug 24, 2021 3:42 am
Github: orian34
itch: orian34
Discord: orian34
Contact:

Custom Viewport Screen Transition With Use

#1 Post by orian34 »

I've been using a custom screen menu to handle extras in the game, but I figured there was no transitions so I tried adding dissolve, but I can't make it work anywhere.
After looking more, I could use action ShowMenu() but I can't use actions in a viewport and use doesn't take parameters for transitions.

I feel like I lost brain cells because I can't figure out how to make it work.

glossary, gallery, glossary_desc, and library are 4 simple screens with a vbox and textbuttons.

Code: Select all

screen extras():
    tag menu

    use game_menu(_("Extras")):
        vbox:
            spacing 25
            hbox:
                style_prefix "radio"
                spacing 45
                xpos .2
                textbutton _("Glossary") action SetVariable('extras_mode', 0)
                textbutton _("Gallery") action SetVariable('extras_mode', 1)
                textbutton _("Library") action SetVariable('extras_mode', 2)
            viewport:
                scrollbars "vertical"
                vscrollbar_unscrollable "hide"
                mousewheel True
                draggable True
                xmaximum 1.0
                xpos .2

                if extras_mode == 0:
                    xpos .0
                    use glossary
                elif extras_mode == 1:
                    xpos .3
                    ypos .3
                    use gallery
                elif extras_mode == 2:
                    use library
        if extras_mode == 0:
            viewport:
                scrollbars "vertical"
                vscrollbar_unscrollable "hide"
                mousewheel True
                draggable True
                xmaximum 1.0
                ymaximum .85
                xpos .2
                ypos .15
                use glossary_desc

User avatar
orian34
Newbie
Posts: 14
Joined: Tue Aug 24, 2021 3:42 am
Github: orian34
itch: orian34
Discord: orian34
Contact:

Re: Custom Viewport Screen Transition With Use

#2 Post by orian34 »

I managed to make it work, albeit with a fairly cursed solution, but it works.
I'm just making the action for the textbuttons refresh the menu through ShowMenu so it forces the transition.
Yay.

Code: Select all

		textbutton _("Glossary"):
                    action [SetVariable('extras_mode', 0),ShowMenu("extras")]
                    if not extras_mode == 0:
                        selected False
                textbutton _("Gallery"):
                    action [SetVariable('extras_mode', 1),ShowMenu("extras")]
                    if not extras_mode == 1:
                        selected False
                textbutton _("Library"):
                    action [SetVariable('extras_mode', 2),ShowMenu("extras")]
                    if not extras_mode == 2:
                        selected False

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Custom Viewport Screen Transition With Use

#3 Post by m_from_space »

orian34 wrote: Sat Dec 16, 2023 12:59 pm I managed to make it work, albeit with a fairly cursed solution, but it works.
I'm just making the action for the textbuttons refresh the menu through ShowMenu so it forces the transition.
Yay.
If you don't need the variable "extras_mode" outside of the screen, you could just make it an argument instead.

Code: Select all

screen extras(mode):
    ...
    textbutton _("Glossary") action ShowMenu('extras', mode=0)
    ...
    if mode == 0:
       ...

User avatar
orian34
Newbie
Posts: 14
Joined: Tue Aug 24, 2021 3:42 am
Github: orian34
itch: orian34
Discord: orian34
Contact:

Re: Custom Viewport Screen Transition With Use

#4 Post by orian34 »

m_from_space wrote: Sat Dec 16, 2023 3:21 pm

If you don't need the variable "extras_mode" outside of the screen, you could just make it an argument instead.

Code: Select all

screen extras(mode):
    ...
    textbutton _("Glossary") action ShowMenu('extras', mode=0)
    ...
    if mode == 0:
       ...
Thanks! Didn't know arguments were a thing.

User avatar
orian34
Newbie
Posts: 14
Joined: Tue Aug 24, 2021 3:42 am
Github: orian34
itch: orian34
Discord: orian34
Contact:

Re: Custom Viewport Screen Transition With Use

#5 Post by orian34 »

After trying, I don't think it works for what I need anyway. It being an external variable means it saves even if you change menus and come back, so it's nice qol to have. Also I can't remove the if not condition because showmenu even with an argument will count all the buttons as selected since extras menu is already displayed.

Post Reply

Who is online

Users browsing this forum: Li yuanlin