Screens for Android phone

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
akakyouryuu
Regular
Posts: 162
Joined: Fri Nov 30, 2012 10:29 am
Contact:

Screens for Android phone

#1 Post by akakyouryuu »

I rewrote default screens for "phone". I got these buttons bigger and adapt it.



These works in Ren'Py v6.17 or later.
And this file is in the public domain.

Code: Select all

##############################################################################
# These screens are for "phone".
# These work in ren'py 6.17 or later.
# This file is in the public domain.

# 2014/04/21
##############################################################################
# Main Menu
#
# Screen that's used to display the main menu, when Ren'Py first starts
# http://www.renpy.org/doc/html/screen_special.html#main-menu

screen main_menu:

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

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

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

        has hbox

        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 -2:
    style mm_button:
        variant "phone"
        yminimum 100

##############################################################################
# Navigation
#
screen navigation:
    
    tag menu
    variant "phone"

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

    # The various buttons.
    frame:
        style_group "gm_nav"
        xalign .5
        yalign .5
        xminimum .9
        yminimum .9

        has vbox

        hbox:
            textbutton _("Save") action ShowMenu('save')
            textbutton _("Load Game") action ShowMenu("load")
            textbutton _("Q.Save") action QuickSave()
            textbutton _("Q.Load") action QuickLoad()
        hbox:
            textbutton _("Auto") action [Preference("auto-forward", "toggle"), Return()]
            textbutton _("Skip") action Skip()
            textbutton _("F.Skip") action Skip(fast=True, confirm=True)
        hbox:
            textbutton _("Preferences") action ShowMenu("preferences")
            textbutton _("Main Menu") action MainMenu()
            textbutton _("Help") action Help()
            textbutton _("Quit") action Quit()

init -1:

    style gm_nav_vbox:
        variant "phone"
        spacing 60
    style gm_nav_hbox:
        variant "phone"
        spacing 10
        xalign .5
    style gm_nav_button:
        variant "phone"
        xminimum int(( config.screen_width / 4 ) - 20)
        yminimum int(( config.screen_height / 3 ) - 60)
    style gm_nav_button_text:
        variant "phone"
        size 25
    # If "phone", a "menu" button opens the "navigation" screen.
    if renpy.variant("phone"):
        $ _game_menu_screen = "navigation"

##############################################################################
# Save, Load
#
# Screens that allow the user to save and load the game.
# http://www.renpy.org/doc/html/screen_special.html#save
# http://www.renpy.org/doc/html/screen_special.html#load

# Since saving and loading are so similar, we combine them into
# a single screen, file_picker. We then use the file_picker screen
# from simple load and save screens.

screen file_picker:

    variant "phone"
    key "game_menu" action Return()

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

    frame:
        style "file_picker_frame"

        has vbox

        # The buttons at the top allow the user to pick a
        # page of files.
        hbox:
            style_group "file_picker_nav1"
            xfill True
            xalign .5

            textbutton _("Previous"):
                action FilePagePrevious()

            textbutton _("Auto"):
                action FilePage("auto")

            textbutton _("Quick"):
                action FilePage("quick")

            textbutton _("Next"):
                action FilePageNext()
            
        hbox:
            style_group "file_picker_nav2"
            xfill True
            xalign .5

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

        $ columns = 2
        $ rows = 5

        # Display a grid of file slots.
        grid columns rows:
            transpose True
            xfill True
            yfill True
            style_group "file_picker"

            # Display ten file slots, numbered 1 - 10.
            for i in range(1, columns * rows + 1):

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

                    has hbox

                    # Add the screenshot.
                    add FileScreenshot(i)

                    $ file_name = FileSlotName(i, columns * rows)
                    $ file_time = FileTime(i, empty=_("Empty Slot."))
                    $ save_name = FileSaveName(i)

                    text "[file_name]. [file_time!t]\n[save_name!t]"

                    key "save_delete" action FileDelete(i)

screen save:

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

    use file_picker

screen load:

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

    use file_picker

init -1:
    style file_picker_nav1_button:
        variant "phone"
        xsize int(( config.screen_width / 4 ) - 5)
    style file_picker_nav2_button:
        variant "phone"
        xsize int(config.screen_width / 8 - 5)

##############################################################################
# Preferences
#
# Screen that allows the user to change the preferences.
# http://www.renpy.org/doc/html/screen_special.html#prefereces

screen preference_page:

    variant "phone"
    key "game_menu" action Return()

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

        vbox:
            textbutton _("Display") action ShowMenu("preferences")
            textbutton _("Skip") action ShowMenu("preference2")
            textbutton _("Sound") action ShowMenu("preference3")

screen preferences:

    variant "phone"
    tag menu
    use preference_page

    vbox:
        style_group "prefs"
        xfill True

        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

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

            if config.has_voice:
                textbutton _("Wait for Voice") action Preference("wait for voice", "toggle")

screen preference2:

    tag menu
    variant "phone"

    use preference_page

    vbox:
        style_group "prefs"
        xfill True

        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

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

screen preference3:

    tag menu
    variant "phone"

    use preference_page

    vbox:
        style_group "prefs"
        xfill True

        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")

            if config.sample_sound:
                textbutton _("Test"):
                    action Play("sound", config.sample_sound)
                    style "soundtest_button"

        if config.has_voice:
            frame:
                style_group "pref"
                has vbox

                label _("Voice Volume")
                bar value Preference("voice volume")

                textbutton _("Voice Sustain") action Preference("voice sustain", "toggle")
                if config.sample_voice:
                    textbutton _("Test"):
                        action Play("voice", config.sample_voice)
                        style "soundtest_button"

        # Can a phone have a joystick?
        # frame:
        #     style_group "pref"
        #     has vbox
        #
        #     textbutton _("Joystick...") action Preference("joystick")

init -1:
    style pref_button_text:
        variant "phone"
        size 30
    style pref_button:
        variant "phone"
        xminimum 300
        yminimum 100
    style pref_label_text:
        variant "phone"
        size 30
    style pref_frame:
        variant "phone"
        xsize int(config.screen_width - 350)
    style pref_page_frame:
        variant "phone"
        xalign .98
        yalign .98
        xmaximum 340
    style pref_page_button:
        variant "phone"
        xminimum 300
        yminimum 100
    style pref_slider:
        variant "phone"
        xsize 350
    style pref_page_button_text:
        variant "phone"
        size 30
##############################################################################
# Yes/No Prompt
#
# Screen that asks the user a yes or no question.
# http://www.renpy.org/doc/html/screen_special.html#yesno-prompt

screen yesno_prompt:

    modal True
    variant "phone"

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

    frame:
        style_group "yesno"

        xfill True
        xmargin .05
        ypos .1
        xalign .5
        yanchor 0
        ypadding .05
        xsize .99
        ysize .8

        label _(message):
            xalign 0.1
            yalign 0.1

        vbox:
            xalign 0.98
            yalign 0.98

            textbutton _("Yes") action yes_action
            textbutton _("No") action no_action

    # Right-click and escape answer "no".
    key "game_menu" action no_action

init -1:
    style yesno_label_text:
        variant "phone"
        size 30
    style yesno_button:
        variant "phone"
        xminimum 300
        yminimum 100
    style yesno_button_text:
        variant "phone"
        size 30

##############################################################################
# Quick Menu
#
# Quick Menu doesn't used in the screens for Phone.
screen quick_menu:
    variant "phone"
    fixed:
        null

init -1:
    style menu_choice_button:
        variant "phone"
        yminimum 100

Attachments
screens_phone.rpy
(11.14 KiB) Downloaded 117 times
screenshot0003.png
screenshot0002.png
screenshot0004.png
screenshot0001.png
screenshot0005.png

User avatar
Enokiiii
Newbie
Posts: 7
Joined: Wed Mar 05, 2014 8:49 pm
Contact:

Re: Screens for Android phone

#2 Post by Enokiiii »

These look really great! I'm defiantly going to try it out.

Lightworker
Regular
Posts: 104
Joined: Sun Dec 13, 2015 2:06 pm
Projects: Detroit.exe
Discord: Happiness+#1168
Contact:

Re: Screens for Android phone

#3 Post by Lightworker »

Hey. I got this error when I downloaded and tested your code.

Code: Select all

I'm sorry, but an uncaught exception occurred.

After initialization, but before game start.
  File "game/screens.rpy", line 265, in prepare_screen
    screen preference2:
  File "game/screens.rpy", line 265, in prepare
    screen preference2:
Exception: A screen named preference_page does not exist.

Post Reply

Who is online

Users browsing this forum: No registered users