Main Menu "Labels"

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
birdperson
Newbie
Posts: 5
Joined: Thu Nov 23, 2017 12:54 am
Contact:

Main Menu "Labels"

#1 Post by birdperson »

Hey there! I'm relatively new to Ren'Py and Python, however I could find or figure out everything I needed so far. Except the following: How do I create new "labels" on the main menu, like "about" or "preferences"? (I'm sure "label" is not the correct term for it, since it already means something else in Ren'Py, but just to be clear, I'm referring to the button - like 'about' - that takes you to a new screen.)

What I want to do is create two extra "labels", one that takes me to a screen with an image, and the other directly to a website through the default browser.

I've been looking around everywhere on the web for hours to find out how to do that, including this forum. However if the answer to my question exist somewhere here, I apologize. In that case, just point me to the right direction.

Otherwise, thanks for the help in advance!

User avatar
vollschauer
Veteran
Posts: 231
Joined: Sun Oct 11, 2015 9:38 am
Github: vollschauer
Contact:

Re: Main Menu "Labels"

#2 Post by vollschauer »

What you want/mean is called "screens" not "labels"....

https://www.renpy.org/doc/html/screens.html

birdperson
Newbie
Posts: 5
Joined: Thu Nov 23, 2017 12:54 am
Contact:

Re: Main Menu "Labels"

#3 Post by birdperson »

I 'm aware of that site. I've already read through that. It tells you what certain things do, but it's not a cohesive description. And so it is hard to put together what I want using that help only.
Things like: Do I have to work with only the 'screens.rpy' file? Do I have to create a screen for the button and for the actual screen (image and website in my case) that it points to, etc...?

I don't need a step by step guide, but a little help with what to do first, what goes where what comes after what would be greatly appreciated.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Main Menu "Labels"

#4 Post by Imperf3kt »

Code: Select all

# The following is placed in either the main menu screen, or navigation screen depending on where you want it to appear and how, etc.
    textbutton "my text goes here" action("do something")

# The following can be placed anywhere before a label or inside an init block, but common sense says put it in screens.rpy (wherever you want to that doesn't interrupt another screen)

screen myscreen():
#we add () to make the screen faster, despite having nothing between them
    #myscreen contents, anything from the prior link
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

birdperson
Newbie
Posts: 5
Joined: Thu Nov 23, 2017 12:54 am
Contact:

Re: Main Menu "Labels"

#5 Post by birdperson »

Thanks, Imperf3kt!

However I've just realized, that there is a difference between the screens.rpy of the old and new layout. Since I use the new one (as opposed to the 'legacy' one), I can only find textbuttons in the navigation and quick_menu screens..

Your answer might have the same degree of usefulness though, I just have to keep experimenting...

Errilhl
Regular
Posts: 164
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Deviantart: studioerrilhl
Github: studioerrilhl
Contact:

Re: Main Menu "Labels"

#6 Post by Errilhl »

Here's what I did:

(Excerpt from screens.rpy, from the screen navigation() bit)

Code: Select all

        # elif not main_menu:

        #     textbutton _("Main Menu") action MainMenu()

        # textbutton _("About") action ShowMenu("about")
        # textbutton _("Changelog") action [Show ("changelog")]     
The MainMenu() and the ShowMenu("about") was part of the original code. I added the other button, the Changelog. To get that to work, you'll need to add a separate screen as well, I based mine off of screen about():

Code: Select all

screen changelog():
    tag menu

    use game_menu(_("Changelog"), scroll="viewport"):

        style_prefix "about"

        vbox:

            label "[config.name!t]"
            text _("Version [config.version!t]\n")

            ## gui.about is usually set in options.rpy.
            # if gui.about:
            #     text "[gui.about!t]\n"
            if gui.changelog:
                text "[gui.changelog!t]\n"

            # text _("Made with {a=https://www.renpy.org/}Ren'Py{/a} [renpy.version_only].\n\n[renpy.license!t]")


## This is redefined in options.rpy to add text to the about screen.
define gui.changelog = ""

style about_label is gui_label
style about_label_text is gui_label_text
style about_text is gui_text

style about_label_text:
    size gui.label_text_size
Here's the original screen about():

Code: Select all

screen about():

    tag menu

    ## This use statement includes the game_menu screen inside this one. The
    ## vbox child is then included inside the viewport inside the game_menu
    ## screen.
    use game_menu(_("About"), scroll="viewport"):

        style_prefix "about"

        vbox:

            label "[config.name!t]"
            text _("Version [config.version!t]\n")

            ## gui.about is usually set in options.rpy.
            if gui.about:
                text "[gui.about!t]\n"

            text _("Made with {a=https://www.renpy.org/}Ren'Py{/a} [renpy.version_only].\n\n[renpy.license!t]")


## This is redefined in options.rpy to add text to the about screen.
define gui.about = ""


style about_label is gui_label
style about_label_text is gui_label_text
style about_text is gui_text

style about_label_text:
    size gui.label_text_size
Note! For this type of content to work, you'll also have to define the option the (define gui.about / define gui.changelog) in the options.rpy-file - like this:
Original for gui.about:

Code: Select all

define gui.about = _("{b}HSS (or HighSchool Shenaningans){/b} is an adult-themed visual novel, with some randomness, and a lot of sexy content. You're playing as <player> (pick your name, or default to Marten), an 18 year old boy who's finishing high school, and is mildly anxious about his exams, the lack of a girlfriend, noone to take to the dance, and how to get his motorcycle rebuilt properly. Add to this an abundance of hot girls in his vicinity, and you got most of the plot right there. At least if you only knew what opportunities you have right at your feet.\n\nThe game is about discovering those opportunities, and realising what you can do, not to mention WHO you can do!\n\nThe game is in very early development, and currently we're working on the game mechanics, how to modify relationships, how to build a believeable story, and how to decide which characters get to do what with whom.\n\n")
New, from gui.changelog:

Code: Select all

define gui.changelog = _("• Added a Patreon-button on the main starting page\n• Removed the text-title (basing on the logo title on the main screen now)\n• Kept the version-text\n• Fixed the look of the list-items in the changelog-page\n• Added a character image (when speaking) for Juliette\n• Redid the stats-screen, so there's now images for each character (together with name) (note, the images are currently only placeholders, apart from Juliette)\n• Redid the main menu - start of an ongoing project of redesigning the UI of the game\n• Redid the logo in Illustrator, to get a bigger, crispier logo")
Disregard the actual content, that can be anything, I've just included my latest content to show some formatting and such.
Currently working on: Image

birdperson
Newbie
Posts: 5
Joined: Thu Nov 23, 2017 12:54 am
Contact:

Re: Main Menu "Labels"

#7 Post by birdperson »

Thank you Errilhl!

That was a pretty detailed walk-through. I've realized that what I need is just to add: # textbutton _("Whatever") action ShowMenu("whatever")
and then: screen changelog():
tag menu
add "whatever_image"

This works fine, aside from the "small" issue that once the "whatever_image" is shown, there is no way to return to the main menu. Or to do anything for that matter.
Statments like 'return' are not working in screens as far as I understand, so I need to fix that somehow.

As for opening a website.. I couldn't figure that one out yet. I've seen these lines:

init python:
import webbrowser

label launch_mysite:
$ webbrowser.open("http://www.mysite.com/")

but I doubt that it works in a screen.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Main Menu "Labels"

#8 Post by Remix »

textbutton "External Link" action OpenURL( "http: ..... " )

As for the whatever_image bit, you likely either need to use the
tag menu
use game_menu(_("changelog")):
....add "whatver"

or, from guesswork memory, include a 'use navigation' line
Basically try to emulate other menu screens so the navigation stays on the left... or add an overlay button going back to menu main
Frameworks & Scriptlets:

Errilhl
Regular
Posts: 164
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Deviantart: studioerrilhl
Github: studioerrilhl
Contact:

Re: Main Menu "Labels"

#9 Post by Errilhl »

Here's the complete, altered screen for changelog:

Code: Select all

screen changelog():
    tag menu

    use game_menu(_("Changelog"), scroll="viewport"):

        style_prefix "about"

        vbox:

            label "[config.name!t]"
            text _("Version [config.version!t]\n")

            ## gui.about is usually set in options.rpy.
            # if gui.about:
            #     text "[gui.about!t]\n"
            if gui.changelog:
                text "[gui.changelog!t]\n"

            # text _("Made with {a=https://www.renpy.org/}Ren'Py{/a} [renpy.version_only].\n\n[renpy.license!t]")


## This is redefined in options.rpy to add text to the about screen.
define gui.changelog = ""

style about_label is gui_label
style about_label_text is gui_label_text
style about_text is gui_text

style about_label_text:
    size gui.label_text_size
As for external links, I have this as part of the main menu (it's basically a Patreon button located at the right bottom corner of the screen, over the background image:

Code: Select all

    style_prefix "main_menu"

    # add gui.main_menu_background

    ## This empty frame darkens the main menu.
    frame:
        pass

    ## The use statement includes another screen inside this one. The actual
    ## contents of the main menu are in the navigation screen.
    use navigation

    if gui.show_name:
        vbox:
            text "[config.name!t]":
                style "main_menu_title"

    vbox:
        xalign 1.0
        yalign 1.0
        text "[config.version]":
            style "main_menu_version"
            xpos -830
            ypos 65

        imagebutton:
            idle "images/patreon_idle.png"
            hover "images/patreon_hover.png"
            action OpenURL("https://www.patreon.com/errilhl")
Only the actual image-button is pertinent here, I just included the rest to give an inkling on how to use it
Currently working on: Image

birdperson
Newbie
Posts: 5
Joined: Thu Nov 23, 2017 12:54 am
Contact:

Re: Main Menu "Labels"

#10 Post by birdperson »

A BIG thank you for both of you guys (Errilhl and Remix)!

Errilhl that detailed context helped me a lot and Remix, both of your suggestions works perfectly, and is EXACTLY what I wanted/needed.

Thanks again!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], recreation, voluorem