Changing ShowMenu transitions for certain screens

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
Arowana
Miko-Class Veteran
Posts: 531
Joined: Thu May 31, 2012 11:17 pm
Completed: a2 ~a due~
Projects: AXIOM.01, The Pirate Mermaid
Organization: Variable X, Navigame
Tumblr: navigame-media
itch: navigame
Contact:

Changing ShowMenu transitions for certain screens

#1 Post by Arowana » Thu Sep 27, 2012 12:32 am

Hey, all! I was wondering if there is any way to switch the transitions used by ShowMenu for specific screens.

As far as I can tell, the transitions used by ShowMenu are controlled by config.enter_transition and config.exit_transition, so any screens called by ShowMenu can only be shown with the same "default" transitions (in my case, "fade"). But I want certain screens to have different transitions (e.g. "None") when they are shown/replaced.

I tried switching the default transition with [SetField(config,"enter_transition", None), SetField(config,"exit_transition", None)] when I enter the screen, then resetting the default transition with [SetField(config,"enter_transition", fade), SetField(config,"exit_transition", fade)] when I exit the screen. Resetting the exit transition while leaving the screen, however, causes the screen to exit with "fade," rather than "None" as I want. Not sure how I get around this. Surely there must be a better way to switch the transitions for a particular screen?
Complete: a2 ~a due~ (music, language, love)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)

Image

Levrex
Veteran
Posts: 280
Joined: Mon Jun 18, 2012 12:16 pm
Contact:

Re: Changing ShowMenu transitions for certain screens

#2 Post by Levrex » Thu Sep 27, 2012 5:20 am

Take a look at 00screens.rpy. You should figure out how to do this.
Hint: compare Show(action) and ShowMenu(action).
If your question is solved, please add [Solved] to theme's name by editing its first post, so that the helpful guys out there wouldn't mistakenly think the problem is still unanswered and waste their time.

User avatar
Arowana
Miko-Class Veteran
Posts: 531
Joined: Thu May 31, 2012 11:17 pm
Completed: a2 ~a due~
Projects: AXIOM.01, The Pirate Mermaid
Organization: Variable X, Navigame
Tumblr: navigame-media
itch: navigame
Contact:

Re: Changing ShowMenu transitions for certain screens

#3 Post by Arowana » Fri Sep 28, 2012 3:57 am

Cool, thanks for the tip - I managed to get it working the way I want, e.g. I can now use ShowMenu(“myscreen”, transition = fade) to have “myscreen” appear/exit with the fade transition rather than the default. I’ll record my solution here in case anyone else is interested. It requires modification of both 00screen.rpy and 00library.rpy.

In 00screen.rpy, modify several lines of the ShowMenu class:

Code: Select all

class ShowMenu(Action):
    def __init__(self, screen=None, transition=None):
        self.screen = screen
        self.transition = transition
         (…)
        else: # if not in game menu (e.g. showing screen from game)
            renpy.call_in_new_context("_game_menu", _game_menu_screen=screen, transition=self.transition)
         (…)
In 00library, modify the contents of the “_game_menu” label to use the transition given by ShowMenu, instead of the default enter and exit transitions:

Code: Select all

# Entry points from the game into menu-space.
label _game_menu(_game_menu_screen=_game_menu_screen, transition=None):
    if not _game_menu_screen:
        return
    
    call _enter_game_menu(transition) from _call__enter_game_menu_0  # use the transition when entering game menu
    
    if renpy.has_label("game_menu"):
        jump expression "game_menu"

    if renpy.has_screen(_game_menu_screen): # this is the part we’re interested in, because we’re using ShowMenu on a screen
        $ renpy.show_screen(_game_menu_screen)
        $ ui.interact()
        
        if transition is not None: # if we have a transition we want to use
            #copy of _noisy_return (not sure how to pass arguments to jump ^^;)
            $ renpy.play(config.exit_sound)
            
            #copy of _return
            if renpy.context()._main_menu:
                $ renpy.transition(config.game_main_transition)
                jump _main_menu_screen

            if transition == "none": # no transition case
                pass
            else:
                $ renpy.transition(transition) # specified transition

            return
            
        else: # no transition specified, use default
            jump _noisy_return
        
    jump expression _game_menu_screen
The "_enter_game_menu" label is also slightly modified to:

Code: Select all

label _enter_game_menu(transition=None):
    $ _enter_menu()

    if transition == "none": # no transition case
        pass
    elif transition is not None:
        $ renpy.transition(transition)
    else:
        $ renpy.transition(config.enter_transition)

    if renpy.has_label("enter_game_menu"):
        call expression "enter_game_menu" from _call_enter_game_menu_1

    if config.game_menu_music:
        $ renpy.music.play(config.game_menu_music, if_changed=True)

    return

Modifying the common Renpy files makes me a bit nervous, but at least it works for now... xD
Complete: a2 ~a due~ (music, language, love)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)

Image

Post Reply

Who is online

Users browsing this forum: _ticlock_