Android Screen Problem [solved]

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.
Message
Author
Lightworker
Regular
Posts: 99
Joined: Sun Dec 13, 2015 2:06 pm
Projects: Detroit.exe
Skype: badthai
Contact:

Android Screen Problem [solved]

#1 Post by Lightworker » Tue Dec 15, 2015 3:40 pm

So... I borrowed code from akakyouryuu http://lemmasoft.renai.us/forums/viewto ... 51&t=26257

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
However, the problem is that once I launch the project I get this error.

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.
Could anyone help me?
Last edited by Lightworker on Wed Dec 30, 2015 9:59 pm, edited 1 time in total.

User avatar
Zetsubou
Veteran
Posts: 490
Joined: Wed Mar 05, 2014 1:00 am
Completed: See my signature
Github: koroshiya
itch: zetsuboushita
Contact:

Re: Android Screen Problem

#2 Post by Zetsubou » Tue Dec 15, 2015 7:52 pm

Do you have a "preference_page" screen that isn't a "phone" variant?
Other screens like "yesno_prompt" are in your screens.rpy file by default, but there is no "preference_page" (there should be "preferences" though).
So I'm guessing you need a "preference_page" screen for non-phone devices. This could be as simple as renaming the "preferences" screen (and any references to it) to "preference_page", or vice-versa.
Finished games
-My games: Sickness, Wander No More, Max Massacre, Humanity Must Perish, Tomboys Need Love Too, Sable's Grimoire
-Commissions: No One But You, Written In The Sky, Diamond Rose, To Libertad, Catch Canvas, Love Ribbon, Happy Campers, Wolf Tails

Working on:
Circadian Loop, My Heart Grows Fonder + VN writing commissions

Image

Lightworker
Regular
Posts: 99
Joined: Sun Dec 13, 2015 2:06 pm
Projects: Detroit.exe
Skype: badthai
Contact:

Re: Android Screen Problem

#3 Post by Lightworker » Tue Dec 15, 2015 10:55 pm

How do I rename the "preferences" screen to "preference_page"? Is the file in my library?

User avatar
Zetsubou
Veteran
Posts: 490
Joined: Wed Mar 05, 2014 1:00 am
Completed: See my signature
Github: koroshiya
itch: zetsuboushita
Contact:

Re: Android Screen Problem

#4 Post by Zetsubou » Tue Dec 15, 2015 11:04 pm

Ah... forget about that. On closer inspection, that isn't what you want.
I think you need a "preference_page" screen that doesn't have "touch" as the variant.

eg. In that file, try adding:

Code: Select all

screen preference_page:
    key "game_menu" action Return()

    # The background of the game menu.
    window:
        style "gm_root"
Finished games
-My games: Sickness, Wander No More, Max Massacre, Humanity Must Perish, Tomboys Need Love Too, Sable's Grimoire
-Commissions: No One But You, Written In The Sky, Diamond Rose, To Libertad, Catch Canvas, Love Ribbon, Happy Campers, Wolf Tails

Working on:
Circadian Loop, My Heart Grows Fonder + VN writing commissions

Image

Lightworker
Regular
Posts: 99
Joined: Sun Dec 13, 2015 2:06 pm
Projects: Detroit.exe
Skype: badthai
Contact:

Re: Android Screen Problem

#5 Post by Lightworker » Wed Dec 16, 2015 4:08 pm

I added your code and got this error.

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/screens.rpy", line 215: screen expects a non-empty block.
    screen preference_page:
                           ^

Ren'Py Version: Ren'Py 6.99.6.739
What does this mean? Did I put the code in the wrong place?

User avatar
Zetsubou
Veteran
Posts: 490
Joined: Wed Mar 05, 2014 1:00 am
Completed: See my signature
Github: koroshiya
itch: zetsuboushita
Contact:

Re: Android Screen Problem

#6 Post by Zetsubou » Wed Dec 16, 2015 4:13 pm

"screen expects a non-empty block" means you either didn't put any content in the screen, or your indentation is wrong.
eg. If you have

Code: Select all

    screen preference_page:
    key "game_menu" action Return()

    window:
        style "gm_root"
or

Code: Select all

screen preference_page:
key "game_menu" action Return()

window:
    style "gm_root"
then it isn't going to work.
Finished games
-My games: Sickness, Wander No More, Max Massacre, Humanity Must Perish, Tomboys Need Love Too, Sable's Grimoire
-Commissions: No One But You, Written In The Sky, Diamond Rose, To Libertad, Catch Canvas, Love Ribbon, Happy Campers, Wolf Tails

Working on:
Circadian Loop, My Heart Grows Fonder + VN writing commissions

Image

Lightworker
Regular
Posts: 99
Joined: Sun Dec 13, 2015 2:06 pm
Projects: Detroit.exe
Skype: badthai
Contact:

Re: Android Screen Problem

#7 Post by Lightworker » Wed Dec 16, 2015 6:16 pm

Oh I see, I have it done in the first one. How do I fix it?

User avatar
Zetsubou
Veteran
Posts: 490
Joined: Wed Mar 05, 2014 1:00 am
Completed: See my signature
Github: koroshiya
itch: zetsuboushita
Contact:

Re: Android Screen Problem

#8 Post by Zetsubou » Wed Dec 16, 2015 6:20 pm

Unindent the "screen" line, so it matches [url=http://lemmasoft.renai.us/forums/viewto ... 02#p396209]my first example.
It should match the other screen blocks in your file.
Finished games
-My games: Sickness, Wander No More, Max Massacre, Humanity Must Perish, Tomboys Need Love Too, Sable's Grimoire
-Commissions: No One But You, Written In The Sky, Diamond Rose, To Libertad, Catch Canvas, Love Ribbon, Happy Campers, Wolf Tails

Working on:
Circadian Loop, My Heart Grows Fonder + VN writing commissions

Image

Lightworker
Regular
Posts: 99
Joined: Sun Dec 13, 2015 2:06 pm
Projects: Detroit.exe
Skype: badthai
Contact:

Re: Android Screen Problem

#9 Post by Lightworker » Wed Dec 16, 2015 8:22 pm

Something does not make sense. The game is launches as though I never changed anything. I added your code to screens.rpy however, it does not look like https://www.youtube.com/watch?v=RxtCK3pO6vQI have no idea what's going on with this code.
Attachments
screens.rpy
Take a look.
(11.34 KiB) Downloaded 80 times

User avatar
Zetsubou
Veteran
Posts: 490
Joined: Wed Mar 05, 2014 1:00 am
Completed: See my signature
Github: koroshiya
itch: zetsuboushita
Contact:

Re: Android Screen Problem

#10 Post by Zetsubou » Wed Dec 16, 2015 8:30 pm

The "preference_page" I posted was to stop the crash you were getting.

Does your game still crash?
If not, what is the problem with your game currently?
Finished games
-My games: Sickness, Wander No More, Max Massacre, Humanity Must Perish, Tomboys Need Love Too, Sable's Grimoire
-Commissions: No One But You, Written In The Sky, Diamond Rose, To Libertad, Catch Canvas, Love Ribbon, Happy Campers, Wolf Tails

Working on:
Circadian Loop, My Heart Grows Fonder + VN writing commissions

Image

User avatar
Donmai
Eileen-Class Veteran
Posts: 1836
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question
Projects: Slumberland
Location: Brazil
Contact:

Re: Android Screen Problem

#11 Post by Donmai » Thu Dec 17, 2015 12:16 am

Ah, I see. The game runs, but not with the big buttons and sub-menus. And it throwed me another error when I clicked on the Start button.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

Lightworker
Regular
Posts: 99
Joined: Sun Dec 13, 2015 2:06 pm
Projects: Detroit.exe
Skype: badthai
Contact:

Re: Android Screen Problem

#12 Post by Lightworker » Thu Dec 17, 2015 12:45 am

The problem is that nothing changed; I am back at square one. Originally it just keep crashing because in the original code, there was no preference_page without a phone variant. When I fixed that, the game appears the same way as though I did not use akakyouryuu's code at all. I grabbed his screenshots to illustrate exactly what I am trying to accomplish.
Attachments
screenshot0005.png
This is what I want part 5
screenshot0005.png (8.58 KiB) Viewed 891 times
screenshot0004.png
This is what I want part 4
screenshot0004.png (15.86 KiB) Viewed 891 times
screenshot0003.png
This is what I want part 3
screenshot0003.png (21.46 KiB) Viewed 891 times
screenshot0002.png
This is what I want part 2
screenshot0002.png (17.27 KiB) Viewed 891 times
Mymenu.PNG
This is what I have.
Mymenu.PNG (3.67 KiB) Viewed 891 times
screenshot0001.png
This is what I want.
screenshot0001.png (7.74 KiB) Viewed 891 times

philat
Eileen-Class Veteran
Posts: 1635
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Android Screen Problem

#13 Post by philat » Thu Dec 17, 2015 10:20 pm

You are misunderstanding what the code you implemented actually does. It's not meant to be run on the PC. It's meant to be run on Android. The variant "phone" means that those screens are ONLY USED if you are running the game on Android. You can certainly emulate an Android environment using RAPT, but if you're just launching the game, then of course it's not going to work.

Lightworker
Regular
Posts: 99
Joined: Sun Dec 13, 2015 2:06 pm
Projects: Detroit.exe
Skype: badthai
Contact:

Re: Android Screen Problem

#14 Post by Lightworker » Thu Dec 17, 2015 10:55 pm

Holy crap. That makes so much sense now. Ohhh.... What exactly is RAPT and how do I emulate an andriod environment?

User avatar
Zetsubou
Veteran
Posts: 490
Joined: Wed Mar 05, 2014 1:00 am
Completed: See my signature
Github: koroshiya
itch: zetsuboushita
Contact:

Re: Android Screen Problem

#15 Post by Zetsubou » Fri Dec 18, 2015 12:26 am

Lightworker wrote:What exactly is RAPT and how do I emulate an andriod environment?
http://www.renpy.org/doc/html/android.html
RAPT = Ren'Py Android Packaging Tool

In the Renpy Launcher, click on "Android".
Before you can start building games for and launching on Android, Renpy will ask if you want to download RAPT.

In the Android section, up the top left is the text "Emulation", with Phone, Tablet and Television listed.
Click on one of those and you'll receive information/prompts about emulating Android.
Finished games
-My games: Sickness, Wander No More, Max Massacre, Humanity Must Perish, Tomboys Need Love Too, Sable's Grimoire
-Commissions: No One But You, Written In The Sky, Diamond Rose, To Libertad, Catch Canvas, Love Ribbon, Happy Campers, Wolf Tails

Working on:
Circadian Loop, My Heart Grows Fonder + VN writing commissions

Image

Post Reply

Who is online

Users browsing this forum: No registered users