[SOLVED] Different Menu Custom Backgrounds?

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
User avatar
5ugarcrash
Newbie
Posts: 9
Joined: Tue Dec 22, 2020 12:52 am
Contact:

[SOLVED] Different Menu Custom Backgrounds?

#1 Post by 5ugarcrash »

Hi!

I'm fairly new to renpy and have looked at forum posts both on here and reddit but nothing seems to be working. I am trying to set a different custom background for each screen in my menu (load, preferences, about, help) instead of having just one background for all of them. I've mainly been messing with putting "add image" in different parts of the screen code as shown below, but it either doesn't make a difference or just adds the image inside of the text box.

Thank you for any help in advance!

Code: Select all

screen about():

    tag menu

    add "images/iabout.png"
    
    use game_menu(_("About"), scroll="viewport"):


        style_prefix "about"

        vbox:
        ...
Last edited by 5ugarcrash on Sun Dec 27, 2020 4:30 am, edited 1 time in total.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Different Menu Custom Backgrounds?

#2 Post by gas »

EDIT: understood. You want to change the overall background, not just the frame. 'Right.
Try change the game_menu like below:

Code: Select all

screen game_menu(title, scroll=None):

    style_prefix "game_menu"

    if main_menu:
        add gui.main_menu_background
    elif renpy.get_screen("about"):
        add "about_bg.jpg"
    else:
        add gui.game_menu_background
Repeat the elif part for each screen you want to change the background.

The reasons for that:
A) The game_menu is responsible to determne the background to show in the default interface, not each single screen. The renpy.get_screen() function return True if that screen is shown.
B) Reddit IS NOT AND WILL BE NEVER a reliant source for renpy (and barely YouTube is).
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
5ugarcrash
Newbie
Posts: 9
Joined: Tue Dec 22, 2020 12:52 am
Contact:

Re: Different Menu Custom Backgrounds?

#3 Post by 5ugarcrash »

gas wrote: Sun Dec 27, 2020 3:51 am EDIT: understood. You want to change the overall background, not just the frame. 'Right.
Try change the game_menu like below:

Code: Select all

screen game_menu(title, scroll=None):

    style_prefix "game_menu"

    if main_menu:
        add gui.main_menu_background
    elif renpy.get_screen("about"):
        add "about_bg.jpg"
    else:
        add gui.game_menu_background
Repeat the elif part for each screen you want to change the background.
Thank you so much for responding! I tried out the code (below) and even though there are no errors, the background hasn't changed in the slightest. I also double-checked my image names just in case but they were labeled correctly so I'm not sure why it is still using the default menu background.

(I also tried deleting the yinitial=0.0 part in the first line to match your code but that caused a bunch of errors so I just put it back)

Code: Select all

screen game_menu(title, scroll=None, yinitial=0.0):

    style_prefix "game_menu"

    if main_menu:
        add gui.main_menu_background
    elif renpy.get_screen("load"):
        add "images/iload.png"
    elif renpy.get_screen("preferences"):
        add "images/isettings.png"
    elif renpy.get_screen("about"):
        add "images/iabout.png"
    elif renpy.get_screen("help"):
        add "images/ihelp.png"
    else:
        add gui.game_menu_background
Full code of game menu screen:

Code: Select all

screen game_menu(title, scroll=None, yinitial=0.0):

    style_prefix "game_menu"

    if main_menu:
        add gui.main_menu_background
    elif renpy.get_screen("load"):
        add "images/iload.png"
    elif renpy.get_screen("preferences"):
        add "images/isettings.png"
    elif renpy.get_screen("about"):
        add "images/iabout.png"
    elif renpy.get_screen("help"):
        add "images/ihelp.png"
    else:
        add gui.game_menu_background

    frame:
        style "game_menu_outer_frame"

        hbox:

            ## Reserve space for the navigation section.
            frame:
                style "game_menu_navigation_frame"

            frame:
                style "game_menu_content_frame"

                if scroll == "viewport":

                    viewport:
                        yinitial yinitial
                        scrollbars "vertical"
                        mousewheel True
                        draggable True
                        pagekeys True

                        side_yfill True

                        vbox:
                            transclude

                elif scroll == "vpgrid":

                    vpgrid:
                        cols 1
                        yinitial yinitial

                        scrollbars "vertical"
                        mousewheel True
                        draggable True
                        pagekeys True

                        side_yfill True

                        transclude

                else:

                    transclude

    use navigation

    textbutton _("Return"):
        style "return_button"

        action Return()

    label title

    if main_menu:
        key "game_menu" action ShowMenu("main_menu")


style game_menu_outer_frame is empty
style game_menu_navigation_frame is empty
style game_menu_content_frame is empty
style game_menu_viewport is gui_viewport
style game_menu_side is gui_side
style game_menu_scrollbar is gui_vscrollbar

style game_menu_label is gui_label
style game_menu_label_text is gui_label_text

style return_button is navigation_button
style return_button_text is navigation_button_text

style game_menu_outer_frame:
    bottom_padding 45
    top_padding 180

    background "gui/overlay/game_menu.png"

style game_menu_navigation_frame:
    xsize 420
    yfill True

style game_menu_content_frame:
    left_margin 20
    right_margin 30
    top_margin 15

style game_menu_viewport:
    xsize 1380

style game_menu_vscrollbar:
    unscrollable gui.unscrollable

style game_menu_side:
    spacing 15

style game_menu_label:
    xpos 75
    ysize 180

style game_menu_label_text:
    size gui.title_text_size
    color gui.accent_color
    yalign 0.5

style return_button:
    xpos gui.navigation_xpos
    yalign 1.0
    yoffset -45

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Different Menu Custom Backgrounds?

#4 Post by gas »

Ok, my bad. Is SO SILLY as an error I feel embarassed.
The first if check the context XD.
So as long you're in the main menu, it show the first condition.

Try this.

Code: Select all

screen game_menu(title, scroll=None, yinitial=0.0):

    style_prefix "game_menu"

    if renpy.get_screen("load"):
        add "images/iload.png"
    elif renpy.get_screen("preferences"):
        add "images/isettings.png"
    elif renpy.get_screen("about"):
        add "images/iabout.png"
    elif renpy.get_screen("help"):
        add "images/ihelp.png"
    else:
        add gui.main_menu_background
It SHOULD work now (or I had to sleep some more XD).
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
5ugarcrash
Newbie
Posts: 9
Joined: Tue Dec 22, 2020 12:52 am
Contact:

Re: Different Menu Custom Backgrounds?

#5 Post by 5ugarcrash »

OMG you're a lifesaver, all of it works !!!! Thank you soooo so so much, I've been spending hours on this LOL XD

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Ocelot