A different preferences/load/save menu for the ma...(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
clannadman

A different preferences/load/save menu for the ma...(SOLVED)

#1 Post by clannadman » Thu Apr 14, 2011 10:07 am

Is it possible to get a different menu screen for preferences etc on the main menu to the one in the in-game menu. I want to use a transparent background so that selecting the preferences/load/save menu in the game will make it seem as though it just floats on top. However, doing this makes it so that the main menu one has the transparent background and the checked transparency squares. Any way to get two different menus, one for the main menu and one for in game?
Last edited by clannadman on Fri Aug 05, 2011 8:54 am, edited 1 time in total.

User avatar
Wright1000
Miko-Class Veteran
Posts: 629
Joined: Thu Mar 31, 2011 10:20 am
Completed: Finding A Murderer, Memory Loss, Crime Investigation, Stay away from the graveyard, Last Day at School, Lonesome, Email, Hired Gun, Dusk, Hired Gun 2, Man-at-arms, Hired Gun 3, The Phantom Caller, Street Girl, Free love, The Story of Isabel Claudia
Contact:

Re: A different preferences/load/save menu for the main menu

#2 Post by Wright1000 » Fri Apr 15, 2011 5:26 am

Can you give me an example of a game that uses two in-game menus?

I do not think it is possible in Ren'py.
He who doesn't care about the environment doesn't care about his grandchildren.

User avatar
Ellume
Regular
Posts: 36
Joined: Tue Apr 06, 2010 2:57 am
Contact:

Re: A different preferences/load/save menu for the main menu

#3 Post by Ellume » Sat Apr 16, 2011 5:57 am

I don't have too much experience with renpy yet, but I would probably build a preference lookalike page and then link the main menu 'preferences' button to that instead of the normal preferences. There is likely an easier way too, I just don't know it off hand.

User avatar
PyTom
Ren'Py Creator
Posts: 15469
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: A different preferences/load/save menu for the main menu

#4 Post by PyTom » Sat Apr 16, 2011 2:14 pm

Ellum's approach is the right one - you'll need to use screen language for it, and then just change ShowMenu("preferences") to ShowMenu("altpreferences"). Making a preference lookalike can be done by copying the preferences screen, and then changing it.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

clannadman

Re: A different preferences/load/save menu for the main menu

#5 Post by clannadman » Sun Apr 17, 2011 2:19 pm

How do I access the screen language that allows me to link altpreferences to ShowMenu? I'm still a bit of a novice at programming and a search through options.rpy hasn't turned up anything.

clannadman

Re: A different preferences/load/save menu for the main menu

#6 Post by clannadman » Sun Jun 19, 2011 2:29 pm

Any help?

User avatar
Alex
Lemma-Class Veteran
Posts: 2491
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: A different preferences/load/save menu for the main menu

#7 Post by Alex » Sun Jun 19, 2011 2:58 pm

a search through options.rpy hasn't turned up anything
You need "screens.rpy" and Ren'Py 6.12.x to use them. (if you don't have this file yet - you can copy it from ".../renpy-6.12.x/template").

clannadman

Re: A different preferences/load/save menu for the main menu

#8 Post by clannadman » Mon Jun 20, 2011 12:35 pm

Alex wrote:
a search through options.rpy hasn't turned up anything
You need "screens.rpy" and Ren'Py 6.12.x to use them. (if you don't have this file yet - you can copy it from ".../renpy-6.12.x/template").
Right. I'm on Renpy 11. Will downloading 12 affect my files?

User avatar
Alex
Lemma-Class Veteran
Posts: 2491
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: A different preferences/load/save menu for the main menu

#9 Post by Alex » Mon Jun 20, 2011 3:14 pm

Will downloading 12 affect my files?
Ren'py will not change your code. Anyway, if you'll find any problem using 6.12 you could use 6.11. If you will not use update feature, but instead download 6.12.x release and install it separately from 6.11.x, then you'll be able to run one or another version.
Also, http://lemmasoft.renai.us/forums/viewto ... =8&t=10239

clannadman

Re: A different preferences/load/save menu for the main menu

#10 Post by clannadman » Mon Jun 20, 2011 5:10 pm

Okay. I have the file now, except I'm a little lost. I can't find ShowMenu on this thing although I can clearly see where it lists my current menus in use. Do I simply need to copy and paste my preferences menu and rename it? Is there a certain command somewhere I can use?

User avatar
Alex
Lemma-Class Veteran
Posts: 2491
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: A different preferences/load/save menu for the main menu

#11 Post by Alex » Tue Jun 21, 2011 4:02 pm

Mmm, I'll try to explain...
In "screens.rpy" you have all the codes for main and game menus. If you find "main_menu" screen (line about 170), you'll see the textbuttons for main menu - one of them

Code: Select all

textbutton _("Preferences") action ShowMenu("preferences")
This button shows "preferences" when clicked. You can make your own preferences screen, let's say, "my_preferences" (copy/paste screen "preferences", rename it and change code). And if you want to access it from main menu, you should change this text button to

Code: Select all

textbutton _("Preferences") action ShowMenu("my_preferences")
If you need an access to "my_preferences" from ingame, then you can make onscreen button with "action ShowMenu("my_preferences")" or make right click to lead to that screen

Code: Select all

init:
    $_game_menu_screen = "my_preferences"
If you need a transparent background for your custom preferences screen, then you should made screen "my_navigation" (copy/paste screen "navigation", rename it and change code)

Code: Select all

screen my_navigation:

    # The background of the game menu.
    window:
        background None
    # rest of code is unchanged
So, you could use it in your "my_preferences"

Code: Select all

screen my_preferences:

    tag menu

    # Include the navigation.
    use my_navigation
Also, you need to use "my_navigation" in your custom "save" and "load" screens, so you'll have to make them, and use them from your "my_preferences" screen. So in screen "my_navigation" change the buttons actions to show "my_preferences", "my_save" and "my_load" screens.
And finaly, make "my_save" and "my_load" screens.
If you just copy / paste the code and rename them - it won't work, 'cause <FileAction> function, used in them, ""Does the right thing" with the file. This means loading it if the load screen is showing, and saving to it otherwise."(c) But you renamed the screens...(
So, a bit of extra changes: instead of using "file_picker" screen, make a similar code for "my_save" and "my_load" screens, but change <FileAction> function to <FileSave> and <FileLoad> respectively.

As result, you'll have this additional labels in your "screens.rpy"

Code: Select all

screen my_navigation:

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

    # The various buttons.
    frame:
        style_group "gm_nav"
        xalign .98
        yalign .98
        
        has vbox

        textbutton _("Return") action Return()
        textbutton _("Preferences") action ShowMenu("my_preferences")
        textbutton _("Save Game") action ShowMenu("my_save")
        textbutton _("Load Game") action ShowMenu("my_load")
        textbutton _("Main Menu") action MainMenu()
        textbutton _("Help") action Help()
        textbutton _("Quit") action Quit()
        
screen my_save:

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

    use my_navigation
    frame:
        has vbox

        # The buttons at the top allow the user to pick a
        # page of files.
        hbox:
            textbutton _("Previous") action FilePagePrevious()
            textbutton _("Auto") action FilePage("auto")

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

            textbutton _("Next") action FilePageNext()

        # Display a grid of file slots.
        grid 2 5:
            transpose True
            xfill True

            # Display ten file slots, numbered 1 - 10.
            for i in range(1, 11):

                # Each file slot is a button.
                button:
                    action FileSave(i)
                    xfill True
                    style "large_button"

                    has hbox

                    # Add the screenshot and the description to the
                    # button.
                    add FileScreenshot(i)
                    text ( " %2d. " % i
                           + FileTime(i, empty=_("Empty Slot."))
                           + "\n"
                           + FileSaveName(i)) style "large_button_text"

screen my_load:

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

    use my_navigation
    frame:
        has vbox

        # The buttons at the top allow the user to pick a
        # page of files.
        hbox:
            textbutton _("Previous") action FilePagePrevious()
            textbutton _("Auto") action FilePage("auto")

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

            textbutton _("Next") action FilePageNext()

        # Display a grid of file slots.
        grid 2 5:
            transpose True
            xfill True

            # Display ten file slots, numbered 1 - 10.
            for i in range(1, 11):

                # Each file slot is a button.
                button:
                    action FileLoad(i)
                    xfill True
                    style "large_button"

                    has hbox

                    # Add the screenshot and the description to the
                    # button.
                    add FileScreenshot(i)
                    text ( " %2d. " % i
                           + FileTime(i, empty=_("Empty Slot."))
                           + "\n"
                           + FileSaveName(i)) style "large_button_text"
    
screen my_preferences:

    tag menu

    # Include the navigation.
    use my_navigation

    # Put the navigation columns in a three-wide grid.
    grid 3 1:
        style_group "prefs"
        xfill True

        # The left column.
        vbox:
            frame:
                style_group "pref"
                has vbox

                label _("Display")
                textbutton _("Window") action Preference("display", "window")
                textbutton _("Fullscreen") action Preference("display", "fullscreen")

            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

                textbutton _("Joystick...") action ShowMenu("joystick_preferences")

        vbox:
            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

                textbutton _("Begin Skipping") action Skip()

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

            frame:
                style_group "pref"
                has vbox

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

        vbox:
            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"

            frame:
                style_group "pref"
                has vbox

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

                if config.sample_voice:
                    textbutton "Test":
                        action Play("voice", config.sample_voice)
                        style "soundtest_button" 
and in your script:

Code: Select all

init:
    $_game_menu_screen = "my_preferences"
This seems to work for me, but may be there is another (more easier) way to do so.

http://www.renpy.org/doc/html/screen_ac ... le-actions
http://www.renpy.org/doc/html/screen_special.html#save

clannadman

Re: A different preferences/load/save menu for the main menu

#12 Post by clannadman » Wed Jun 22, 2011 1:47 pm

I've gotten a little lost. I did as you suggested although I'm using imagemaps and I'm wondering how I link my alternate preferences/load screens to the new ones. I've only changed the navigation images for the alternate menus so far since a problem with the menus was that the 'Save Game' and 'Main Menu' buttons went missing, leaving blank spaces on the screen.

Here's the code for my current alternate imagemap:

Code: Select all

    layout.imagemap_altnavigation(
        "gm_ground.png",
        "altgm_idle.png",
        "altgm_hover.png",
        "altgm_selected_idle.png",
        "altgm_selected_hover.png",
        [
            (27, 124, 111, 154, "Return"),
            (27, 156, 183, 184, "Preferences"),
            (27, 185, 184, 214, "Load Game"),
            (27, 216, 187, 245, "Help"),
            (27, 275, 177, 310, "Quit"),            
            ])
    
Is there any way to link this through screens? I'm still new to this and I followed your advice but was that applicable to imagemaps or to the default menus?

I get the following error message but it seems to be complaining about the new imagemap that I have saved in my options.rpy:

Code: Select all

While executing init code:
  File "game/options.rpy", line 284, in script
    init -2 python:
  File "game/options.rpy", line 313, in python
        layout.imagemap_altnavigation(
AttributeError: Layout instance has no attribute 'imagemap_altnavigation'

User avatar
Alex
Lemma-Class Veteran
Posts: 2491
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: A different preferences/load/save menu for the main menu

#13 Post by Alex » Wed Jun 22, 2011 4:23 pm

Oh, mmm... well...
My example was about changing of the default menus.
Changing layouts is an old style of customising the main and game menus. If you want to use imagemaps with screens, then you should change the default code of main menu, preferences, load and save screens for imagemaps. In screen language they looks a bit different, but in general they still the same.
So, comment all your "layout.imagemap_smth"s or cut them out and store somewhere if you'll need them in future. Then start to change screens to imagemaps. The main menu might looks like this:

Code: Select all

screen main_menu:

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

    imagemap:
        ground "menu2.jpg"
        hover "menu2.jpg"
        idle "menu.jpg"
        
        hotspot (10, 300, 400, 100) action Start()
        hotspot (10, 400, 400, 100) action ShowMenu("my_preferences")
http://www.renpy.org/doc/html/screens.h ... statements
(read first about new imagemaps, 'cause hotspots definition has changed).

clannadman

Re: A different preferences/load/save menu for the main menu

#14 Post by clannadman » Wed Jun 22, 2011 4:46 pm

And do I delete the init2 statement beneath:

Code: Select all

screen navigation:

    # The background of the game menu.
    imagemap:
        ground "gm_ground.png"
        idle "gm_idle.png"
        hover "gm_hover.png"
        selected_idle "gm_selected_idle.png"
        selected_hover "gm_selected_hover.png"
        
        hotspot (27, 124, 111, 154) clicked Navigation ("Return")
        hotspot (27, 156, 183, 184) clicked Navigation ("Preferences")
        hotspot (27, 185, 184, 214) clicked Navigation ("Save Game")
        hotspot (27, 216, 187, 245) clicked Navigation ("Load Game")
        hotspot (27, 246, 177, 273) clicked Navigation ("Main Menu")
        hotspot (27, 275, 177, 310) clicked Navigation ("Help")
        hotspot (26, 331, 89, 370) clicked Navigation("Quit")          
    
init -2 python:
    style.gm_nav_button.size_group = "gm_nav"
Or do I leave it or place something else in there? Just did a test and the game ran but it's showing default buttons instead of my overlayed navigation.

User avatar
Alex
Lemma-Class Veteran
Posts: 2491
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: A different preferences/load/save menu for the main menu

#15 Post by Alex » Wed Jun 22, 2011 4:48 pm

I think you should comment it, 'cause you don't have buttons at all, just imagemaps.

Post Reply

Who is online

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