Ren'Py How can I put a link to discord and patreon on the main menu screen of the game?

Nov 14, 2020
20
4
Hello,

So I'm running a bit ahead of myself, but the question is stuck in my head and I keep wondering.

So what exactly do I have to do to make links for discord and patreon appear on my main menu screen?

I guess the imagebutton to show the logos of both? Sorry I'm quite the noob, but the community is really helpful so I hope you don't mind!

Thanks in advance guys!
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,569
2,196
You have two options, depending on whether you want to actually use the logo as a hotspot or if you'd rather just have text (like "Load", "Save", "About", etc). This is all assuming you haven't already customized the menus beyond all recognition...

Both are in the screens.rpy file.

Text:

Find the section that deals with the screen navigation(): code. Within the vbox that shows all the other text options, add something like:

Python:
        textbutton _("About") action ShowMenu("about")

        textbutton _("Patreon") action OpenURL("https://www.patreon.com/halloweenoracle")  # <--- added

        if renpy.variant("pc") or (renpy.variant("web") and not renpy.variant("mobile")):

# blah, blah, more code.

You can alter whether the link appears on the main_menu or game_menu (or both) and whether the link is visible when using the in-game replay menu by having code for if main_menu: and/or if _in_replay: in there too.

There's no reason why the game_menu and main_menu need to use textbutton: - but it's what is used by default, so is easier to think about when you're just starting out.


Logo:

Find the section that deals with the screen menu_menu(): code. Somewhere in there, add an imagebutton: to show both the logo and the link you want to use. Again, something like:

Python:
    if gui.show_name:

        vbox:
            #text "[config.name!t]":
            #    style "main_menu_title"

            text "Version [config.version]":
                style "main_menu_version"

    fixed:
        imagebutton:
            pos (1600,115)
            idle ("gui/patreonlogo_idle.png")
            hover ("gui/patreonlogo_hover.png")
            action OpenURL("https://www.patreon.com/halloweenoracle")

# blah, blah, more code.

I'm not even sure the fixed: is needed, but it's included in the example I'm using - so rather than test it, I'm just blindly copy/pasting it.

Obviously, going down this route also requires two images in the /game/gui/ folder for the idle and hover images you are using for Patreon logo (or just the idle image, if you don't need some sort of visual feedback when the mouse moves over the logo by having a version of the same image that is brighter or colored differently or something).

An alternative to explicitly defining both the idle and hover images is to use auto ("gui/patronlogo_%s.png") instead (where the "%s" is automatically filled in with "idle" and "hover", etc if those image exist). Which is actually better practice, but not quite so obvious an example when you first see it.

Python:
        imagebutton:
            pos (1600,115)
            auto ("gui/patreonlogo_%s.png")
            action OpenURL("https://www.patreon.com/halloweenoracle")

If you want to use idle/hover images with transparency (alpha=0) so that the clickable area is only the non-transparent bit rather than a square block - add the focus_mask True statement to the imagebutton: definition. This is a bit more polished and means you can use round buttons, etc - but requires a bit more work beforehand, preparing the images.

If you want both Patreon and Discord... well that's two textbutton: and/or imagebutton: sections of code instead of one.
 
Last edited: