====================
Special Screen Names
====================

There are two kinds of special screen names in Ren'Py. The first are
screens that will be automatically displayed when Ren'Py script
language commands (or their programmatic equivalents) are run. The
other type are menu screens. These have conventional names for
conventional functionality, but screens can be omitted or changed as
is deemed necessary.

On this page, we'll give example screens. It's important to realize
that, while some screens must have minimal functionality, the screen
system makes it possible to add additional functionality to
screens. For example, while the standard say screen only displays
text, the screen systen makes it easy to add features like skipping,
auto-forward mode, or muting.

Some special screens take parameters. These parameters can be accessed
as variables in the screen's scope.

Some of the screens also have special ids associated with them. A
special id should be assigned to a displayable of a given type. It can
cause properties to be assigned to that displayable, and can make that
displayable accessible to calling code.

In-Game Screens
===============

These screens are automatically displayed when certain Ren'Py
statements execute.

Say
---

The ``say`` screen is called by the say statement, when displaying
ADV-mode dialogue. It is displayed with the following parameters:

`who`
    The text of the name of the speaking character.
`what`
    The dialogue being said by the speaking character.

It's expected to declare displayables with the following ids:

"who"
    A text displayable, displaying the name of the speaking
    character. The character object can be given arguments that style
    this displayable.

"what"
    A text displayable, displaying the dialogue being said by the
    speaking character. The character object can be given arguments that style
    this displayable. **A displayable with this id must be defined**,
    as Ren'Py uses it to calculate auto-forward-mode time,
    click-to-continue, and other things.

"window"
    A window or frame. This conventionally contains the who and what
    text. The character object can be given arguments that style
    this displayable.

::

    screen say:

        window id "window":
            has vbox
            
            if who:
                text who id "who"

            text what id "what"


Choice
------

The ``choice`` screen is used to display the in-game choices created
with the menu statement. It is given the following parameter:

`items`
    This is a list of (`label`, `action`) tuples, corresponding to
    menu choices. `Label` is text, and the screen is expected to
    display that text in a way that causes `action` to be invoked when
    it is selected.

::

    screen choice:

        vbox:        
            ypos .25
            spacing 5

            # Create one textbutton per label, action pair.
            for label, action in items:
                textbutton label:
                    action action
                    xmargin 50
                    xfill True

Input
-----

The ``input`` screen is used to display :func:`renpy.input`. It is given one
parameter:

`prompt`
    The prompt text supplied to renpy.input.

It is expected to declare a displayable with the following id:

"input"
    An input displayable, which must exist. This is given all the
    parameters supplied to renpy.input, so it must exist.

::

    screen input:

        window:
            has vbox

            text prompt
            input id "input"



NVL
---

The ``nvl`` screen is used to display NVL-mode dialogue. It is given
the following parameter:

`dialogue`
    This is a list of ( `who`, `what`, `who_id`, `what_id`,
    `window_id`) tuples, each of which corresponds to a line of
    dialogue on the screen. `Who` and `what` are strings containing
    the speaking character and the line of dialogue, respectively. The
    ids should be assigned to the who and what text displayables, and
    a window containing each unit of dialogue.


NVL_Choice
----------

The ``nvl_choice`` screen is used to display an NVL-mode menu. Its two
parameters are a combination of those of the ``nvl`` and ``choice``
screens. 


`dialogue`
    This is a list of ( `who`, `what`, `who_id`, `what_id`,
    `window_id`) tuples, each of which corresponds to a line of
    dialogue on the screen. `Who` and `what` are strings containing
    the speaking character and the line of dialogue, respectively. The
    ids should be assigned to the who and what text displayables, and
    a window containing each unit of dialogue.

`items`
    This is a list of (`label`, `action`) tuples, corresponding to
    menu choices. `Label` is text, and the screen is expected to
    display that text in a way that causes `action` to be invoked when
    it is selected.


Menu Screens
============

These are the menu screens. The ``main_menu`` and ``yesno_prompt`` are
invoked implictly.  When the user invokes the game menu, the screen
named in :data:`_game_menu_screen` will be displayed. (This defaults
to ``save``.)

Remember, menu screens can be combined and modified fairly freely.

Main Menu
---------

The ``main_menu`` screen is the first screen shown when the game
begins.

::

    screen main_menu:
        # The background of the main menu.
        window:
            style "mm_root"

        # The main menu buttons.
        frame:
            style_group "mm"
            xalign .98
            yalign .98

            has vbox

            textbutton _("Start Game") action Start()
            textbutton _("Load Game") action ShowMenu("load")
            textbutton _("Preferences") action ShowMenu("preferences")
            textbutton _("Help") action Help()
            textbutton _("Quit") action Quit(confirm=False)

    init python:

        # Make all the main menu buttons be the same size.
        style.mm_button.size_group = "mm"

Navigation
----------

The ``navigation`` screen isn't special to Ren'Py. But by convention,
we place the game menu navigation in a screen named ``navigation``, and
then use that screen from the save, load and preferences screens.

::

    screen navigation:

        # The background of the game menu.
        window:
            style "gm_root"

        # The various buttons.
        frame:
            style_group "gm_nav"
            xalign .98
            yalign .98

            has vbox

            textbutton _("Return") action Return()
            textbutton _("Preferences") action ShowMenu("preferences")
            textbutton _("Save Game") action ShowMenu("save")
            textbutton _("Load Game") action ShowMenu("load")
            textbutton _("Main Menu") action MainMenu()
            textbutton _("Help") action Help()
            textbutton _("Quit") action Quit()

    init python:
        style.gm_nav_button.size_group = "gm_nav"
                
Save
----

The ``save`` screen is used to select a file in which to save the
game. 

::

    screen save:

        # This ensures that any other menu screen is replaced.
        tag menu

        use navigation

        frame:
            has vbox

            # The buttons at the top allow the user to pick a
            # page of files.
            hbox:
                textbutton _("Previous") action FilePagePrevious()
                textbutton _("Auto") action FilePage("auto")

                for i in range(1, 9):
                    textbutton str(i) action FilePage(i)

                textbutton _("Next") action FilePageNext()

            # Display a grid of file slots.
            grid 2 5:
                transpose True
                xfill True

                # Display ten file slots, numbered 1 - 10.
                for i in range(1, 11):

                    # Each file slot is a button.
                    button:
                        action FileAction(i)
                        xfill True
                        style "large_button"

                        has hbox

                        # Add the screenshot and the description to the
                        # button.
                        add FileScreenshot(i)
                        text ( " %2d. " % i
                               + FileTime(i, empty=_("Empty Slot."))
                               + "\n"
                               + FileSaveName(i)) style "large_button_text"

Load
----

The ``load`` screen is used to select a file from which to load the
game.

::

    screen load:

        # This ensures that any other menu screen is replaced.
        tag menu

        use navigation

        frame:
            has vbox

            # The buttons at the top allow the user to pick a
            # page of files.
            hbox:
                textbutton _("Previous") action FilePagePrevious()
                textbutton _("Auto") action FilePage("auto")

                for i in range(1, 9):
                    textbutton str(i) action FilePage(i)

                textbutton _("Next") action FilePageNext()

            # Display a grid of file slots.
            grid 2 5:
                transpose True
                xfill True

                # Display ten file slots, numbered 1 - 10.
                for i in range(1, 11):

                    # Each file slot is a button.
                    button:
                        action FileAction(i)
                        xfill True
                        style "large_button"

                        has hbox

                        # Add the screenshot and the description to the
                        # button.
                        add FileScreenshot(i)
                        text ( " %2d. " % i
                               + FileTime(i, empty=_("Empty Slot."))
                               + "\n"
                               + FileSaveName(i)) style "large_button_text"
        
Preferences
-----------

The ``preferences`` screen is used to select options that control the
display of the game.

::

    screen preferences:

        tag menu

        # Include the navigation.
        use navigation

        # Put the navigation columns in a three-wide grid.
        grid 3 1:
            style_group "prefs"
            xfill True

            # The left column.
            vbox:
                frame:
                    style_group "pref"
                    has vbox

                    label _("Display")
                    textbutton _("Window") action Preference("display", "window")
                    textbutton _("Fullscreen") action Preference("display", "fullscreen")

                frame:
                    style_group "pref"
                    has vbox

                    label _("Transitions")
                    textbutton _("All") action Preference("transitions", "all")
                    textbutton _("None") action Preference("transitions", "none")

                frame:
                    style_group "pref"
                    has vbox

                    label _("Text Speed")
                    bar value Preference("text speed")

                frame:
                    style_group "pref"
                    has vbox

                    textbutton _("Joystick...") action ShowMenu("joystick_preferences")

            vbox:

                frame:
                    style_group "pref"
                    has vbox

                    label _("Skip")
                    textbutton _("Seen Messages") action Preference("skip", "seen")
                    textbutton _("All Messages") action Preference("skip", "all")

                frame:
                    style_group "pref"
                    has vbox

                    textbutton _("Begin Skipping") action Skip()

                frame:
                    style_group "pref"
                    has vbox

                    label _("After Choices")
                    textbutton _("Stop Skipping") action Preference("after choices", "stop")
                    textbutton _("Keep Skipping") action Preference("after choices", "skip")

                frame:
                    style_group "pref"
                    has vbox

                    label _("Auto-Forward Time")
                    bar value Preference("auto-forward time")

            vbox:

                frame:
                    style_group "pref"
                    has vbox

                    label _("Music Volume")
                    bar value Preference("music volume")

                frame:
                    style_group "pref"
                    has vbox

                    label _("Sound Volume")
                    bar value Preference("sound volume")
                    textbutton "Test" action Play("sound", "sound_test.ogg") style "soundtest_button"

                frame:
                    style_group "pref"
                    has vbox

                    label _("Voice Volume")
                    bar value Preference("voice volume")
                    textbutton "Test" action Play("voice", "voice_test.ogg") style "soundtest_button"

    init python:

        style.pref_frame.xfill = True
        style.pref_frame.xmargin = 5
        style.pref_frame.top_margin = 5

        style.pref_vbox.xfill = True

        style.pref_button.size_group = "pref"
        style.pref_button.xalign = 1.0

        style.pref_slider.xmaximum = 192
        style.pref_slider.xalign = 1.0

        style.soundtest_button.xalign = 1.0


Yesno_Prompt
------------

The ``yesno_prompt`` message is used to ask yes/no choices of the
user. It takes the following parameters:

`message`
    The message to display to the user. This is one of:

    * layout.ARE_YOU_SURE - "Are you sure?" This should be
      the default if the message is unknown.    
    * layout.DELETE_SAVE - "Are you sure you want to delete this save?"
    * layout.OVERWRITE_SAVE - "Are you sure you want to overwrite your save?"
    * layout.LOADING - "Loading will lose unsaved progress.\nAre you sure you want to do this?"
    * layout.QUIT - "Are you sure you want to quit?"
    * layout.MAIN_MENU - "Are you sure you want to return to the main\nmenu? This will lose unsaved progress."

    The values of the variables are strings, which means they can be
    displayed using a text displayable.

`yes_action`
    The action to run when the user picks "Yes".

`no_action`
    The action to run when the user picks "No".

::

    screen yesno_prompt:

        modal True

        window:
            style "gm_root"

        frame:
            style_group "yesno_prompt"

            xfill True
            xmargin 50
            ypadding 25
            yalign .25

            vbox:
                xfill True
                spacing 25

                text _(message):
                    text_align 0.5
                    xalign 0.5

                hbox:
                    spacing 100
                    xalign .5 
                    textbutton _("Yes") action yes_action                
                    textbutton _("No") action no_action
