[SOLVED] Multiple menu styles in a single game

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
Eco-Mono
Newbie
Posts: 7
Joined: Sat Sep 04, 2010 8:41 am
Contact:

[SOLVED] Multiple menu styles in a single game

#1 Post by Eco-Mono »

Hi all. I'm currently working on a VN project where - due to the format in which a lot of the game takes place - it'd be nice to be able to change the style of menu screens (as in, the ones created by a "menu:" block) from scene to scene of the game, either by having multiple styles or by changing the "default" style on the fly. However, nothing I have tried seems to work; in-line changes to `style.menu_window.yalign` don't seem to take, nor even switching to nvl mode and having different settings in `style.nvl_menu_window` (it seems to always use the `style.menu_window` init-time properties regardless).

Does anyone have a suggestion as to how to do this?
Last edited by Eco-Mono on Sat Sep 04, 2010 10:45 am, edited 1 time in total.

Raijenki
Regular
Posts: 33
Joined: Fri Sep 03, 2010 2:07 pm
Location: Natal, Brazil
Contact:

Re: Multiple menu styles in a single game

#2 Post by Raijenki »

init -2 python:

layout.imagemap_main_menu(
"gui_set_a/gui_main_menu_a.png",
"gui_set_a/gui_main_menu_b.png",
[ (613, 107, 776, 190, "Start Game"),
(613, 207, 776, 291, "Load Game"),
(613, 307, 776, 391, "Preferences"),
(613, 408, 776, 492, "Quit") ],
variant = 'locked'
)

layout.imagemap_main_menu(
"gui_set_b/gui_main_menu_a.png",
"gui_set_b/gui_main_menu_b.png" ,
[
(646, 108, 777, 174, "Start Game"),
(646, 188, 777, 254, "Load Game"),
(646, 267, 777, 334, "Preferences"),
(646, 347, 777, 415, "extras"),
(646, 427, 777, 492, "Quit"),
],
variant = 'unlocked'
)

label main_menu:

if persistent.extra_unlocked:
$ _main_menu_variant = 'unlocked'
else:
$ _main_menu_variant = 'locked'

jump main_menu_screen
I saw this at Ren'Py Wiki, and although it's for mainmenu, I think it can help you.
As you can see, it uses imagemaps with some variables in it. During the game, when certain variable is set, it shows another menu.

Eco-Mono
Newbie
Posts: 7
Joined: Sat Sep 04, 2010 8:41 am
Contact:

Re: [SOLVED] Multiple menu styles in a single game

#3 Post by Eco-Mono »

Found a solution. Apparently the "normal" way to do this is by changing the "menu" variable to a different function that applies the right rules. For instance, to use the alternate NVL-mode menu:

Code: Select all

$ menu = nvl_menu
Or in my case, where I needed an action-mode-like menu but with some style modifications:

Code: Select all

init -1 python hide:
    # ...
    style.create("alternate_choice_window","menu_window","Choice menu in alternate mode")
    style.alternate_choice_window.ypos=450-18
    style.alternate_choice_window.yanchor=1.0
And then, in your script:

Code: Select all

label switch_to_alternate_menu:
  python:
    def display_alternate_menu(items, window_style='alternate_choice_window', interact=True, with_none=None):
      renpy.display_menu(items,window_style,interact,with_none)
    menu = display_alternate_menu
  return
label switch_to_normal_menu:
  $ menu = renpy.display_menu
  return

Code: Select all

label some_stuff_goes_on:
  call switch_to_alternate_menu
  menu:
    "choice 1:"
      call switch_to_normal_menu
      jump menu_choice1
    "choice 2:"
      call switch_to_normal_menu
      jump menu_choice2

call

Post Reply

Who is online

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