Can anyone explain to me how does it work? Thanks and sorry
![Neutral :|](./images/smilies/icon_neutral.gif)
Just insert a persistent variable somewhere in your script to show that the game is completed, e.g.Soraminako wrote: Using that code + another bit I got from a past thread I am able to have a page show up saying that the gallery hasn't been unlocked yet, but that's all. I can't make it work the way I imagine it should. It's frustrating. ^^;
Code: Select all
$ persistent.beat_game = True
Code: Select all
init:
# Position the navigation on the right side of the screen.
$ style.gallery_nav_frame.xpos = 800 - 10
$ style.gallery_nav_frame.xanchor = 1.0
$ style.gallery_nav_frame.ypos = 12
# Add the gallery to the main menu.
$ config.main_menu.insert(2, ('Gallery', "gallery", "True"))
# The entry point to the gallery code.
label gallery:
python hide:
# Construct a new gallery object.
g = Gallery()
# The image used for locked buttons.
g.locked_button = "gallery_locked.png"
# The background of a locked image.
g.locked_background = "gallery_lockedbg.jpg"
# Frames added over unlocked buttons, in hover and idle states.
g.hover_border = "gallery_hover.png"
g.idle_border = "gallery_idle.png"
# An images used as the background of the various gallery pages.
g.background = "gallery_background.jpg"
# Lay out the gallery images on the screen.
# These settings lay images out 3 across and 4 down.
# The upper left corner of the gird is at xpos 10, ypos 20.
# They expect button images to be 155x112 in size.
g.grid_layout((3, 4), (10, 12), (160, 124))
# Show the background page.
g.page("Backgrounds")
# Our first button is a picture of the beach.
g.button("thumb_beach.jpg")
#
# These show images, if they have been unlocked. The image name must
# have been defined using an image statement.
g.unlock_image("bg beach daytime")
g.unlock_image("bg beach nighttime")
#
# This shows a displayable...
g.display("beach_sketch.jpg")
# ... if all prior images have been show.
g.allprior()
# A second set of images.
g.button("thumb_lighthouse.jpg")
g.unlock_image("bg lighthouse day")
g.unlock_image("bg lighthouse night")
g.display("lighthouse_sketch.jpg")
g.allprior()
# We can use g.page to introduce a second page.
g.page("Characters")
g.button("thumb_eileen.jpg")
#
# Note that we can give image and unlock image more than one image
# at a time.
g.unlock_image("bg lighthouse day", "eileen day happy")
g.unlock_image("bg lighthouse day", "eileen day mad")
# Another page, this one for concept art.
g.page("Concept Art")
g.button("thumb_concepts.jpg")
#
# We can apply conditions to buttons as well as to images.
# The "condition" condition checks an arbitrary expression.
g.condition("persistent.beat_game")
#
g.display("concept1.jpg")
g.display("concept2.jpg")
g.display("concept3.jpg")
# Now, show the gallery.
g.show()
jump main_menu_screen
Code: Select all
textbutton _("Start Game") action Start()
textbutton _("Load Game") action ShowMenu("load")
textbutton _("Preferences") action ShowMenu("preferences")
textbutton _("Help") action Help()
textbutton _("Quit") action Quit(confirm=False)
Code: Select all
textbutton _("CG Gallery") action ShowMenu("gallery")
Code: Select all
def __init__(self):
self.pages = [ ]
self.page_ = None
self.button_ = None
self.image_ = None
self.unlockable = None
def page(self, name, background=None):
Code: Select all
background ="mybackground.jpg"
OMG YOU ARE AWESOME!! *____* Thank you so much!Abeiramar wrote:I used the gallery from the cookbook and it works for me. Here's how I did it...
[...]
I hope this was useful in some way, if you have any questions please ask me...I'm a newbie and my python skills are poor. However, I will try to help you guys the best I can!
**For some reason the word "return" makes the game start. I replaced with "jump main_menu_screen" so the user can go back to the main menu
To go to the preferences screen...Edit to add a little question: I see you can jump to the main menu using "jump main_menu_screen", and was wondering what would be the names to jump to the load and preferences menus. And whether it would be best to customize their looks through the screens.rpy or by using custom menus?
I have a weird little problem now, because I wasn't using the screens.rpy before (even though I'm using the latest ren'py, but I just don't understand screens), and now that I've added it to my folder, when I click the button to return to the main menu (from the preferences menu, or load menu), it sends me to a basic main menu rather than to my custom one.
Is there something I should replace in the screen files so that it all goes back to my custom main menu? (Which is in a label in the script.rpy)
Code: Select all
jump preferences_screen
Code: Select all
jump load_screen
Thank you for the explanation & link!Abeiramar wrote:[...]
Anyway, are you using hotspots for customizing your main menu? Maybe you should send me the code.
Are you using a custom menu? You could always have a button in the main menu to send the players to the bonus area (instead of a gallery button), and then have the button to the gallery being in that bonus area instead of being in the main menu itself.Lumen_Astrum wrote:One question though -- I don't really want to call the CG gallery from the main menu, tehehe.
In my main menu, there's a button there that calls a menu (for the bonuses), and I was planning that menu to call the CG gallery from one of the choices.
How to do that? O:
Code: Select all
label main_menu:
scene mainmenu
$ ui.hbox(xpos=70, ypos=350)
$ ui.imagebutton("newgame1.png", "newgame2.png", clicked=ui.returns("start"))
$ ui.imagebutton("loadgame1.png", "loadgame2.png", clicked=ui.returns("load"))
$ ui.imagebutton("cg1.png", "cg2.png", clicked=ui.returns("gallery"))
$ ui.imagebutton("options1.png", "options2.png", clicked=ui.returns("prefs"))
$ ui.imagebutton("exit1.png", "exit2.png", clicked=ui.returns("quit"))
$ ui.close()
$ result = ui.interact()
if result == "start":
hide mainmenu
$ renpy.jump_out_of_context("start")
elif result == "load":
jump load_screen
elif result == "gallery":
jump gallery
elif result == "prefs":
jump preferences_screen
elif result == "quit":
$ renpy.quit()
I built a bonus area like that tonight, from which the player can go to either the gallery or to the music room. (Or return to the main menu.)Lumen_Astrum wrote:Yes, yes, that's what I'm talking about.
The CG gallery should be in the bonus area, but I dunno how to call it.
Code: Select all
## Somewhere around the beginning of script.rpy
####################
# MUSIC ROOM part 1 of 2
init python:
def set_playing_(track):
store.playing = track
return True
set_playing = renpy.curry(set_playing_)
# Call this with a button name and a track to define a music
# button.
def music_button(name, track):
if store.playing == track:
role = "selected_"
else:
role = ""
if not renpy.seen_audio(track):
name = "???"
clicked = None
else:
clicked = set_playing(track)
ui.textbutton(
name,
clicked=clicked,
role=role,
size_group="music")
# Add to the main menu.
config.main_menu.insert(3, ("Music Room", "music_room", "True"))
############################
# GALLERY
init:
# Position the navigation on the right side of the screen.
$ style.gallery_nav_frame.xpos = 800 - 10
$ style.gallery_nav_frame.xanchor = 1.0
$ style.gallery_nav_frame.ypos = 12
# Add the gallery to the main menu.
$ config.main_menu.insert(2, ('Gallery', "gallery", "True"))
# The entry point to the gallery code.
label gallery:
if not persistent.gallery_unlocked:
show lockedG_background
centered "You haven't unlocked this gallery yet."
$ renpy.full_restart()
python hide:
# Construct a new gallery object.
g = Gallery()
# The image used for locked buttons.
g.locked_button = "gallery_locked.png"
# The background of a locked image.
g.locked_background = "gallery_lockedbg.jpg"
# Frames added over unlocked buttons, in hover and idle states.
g.hover_border = "gallery_hover.png"
g.idle_border = "gallery_idle.png"
# An images used as the background of the various gallery pages.
g.background = "gallery_background.jpg"
# Lay out the gallery images on the screen.
# These settings lay images out 3 across and 4 down.
# The upper left corner of the gird is at xpos 10, ypos 20.
# They expect button images to be 155x112 in size.
g.grid_layout((3, 4), (10, 12), (160, 124))
# Show the background page.
g.page("Backgrounds")
# Our first button is a picture of the beach.
g.button("thumb_beach.jpg")
#
# These show images, if they have been unlocked. The image name must
# have been defined using an image statement.
g.unlock_image("bg beach daytime")
g.unlock_image("bg beach nighttime")
#
# This shows a displayable...
g.display("beach_sketch.jpg")
# ... if all prior images have been show.
g.allprior()
# A second set of images.
g.button("thumb_beach.jpg")
g.display("beach_sketch.jpg")
g.unlock_image("bg beach nighttime")
g.unlock_image("bg beach daytime")
g.allprior()
# We can use g.page to introduce a second page.
g.page("Characters")
g.button("thumb_guy.jpg")
#
# Note that we can give image and unlock image more than one image
# at a time.
g.unlock_image("bg beach daytime", "guy01")
g.unlock_image("bg beach nighttime", "guy02")
# Another page, this one for concept art.
g.page("Concept Art")
g.button("thumb_beach.jpg")
#
# We can apply conditions to buttons as well as to images.
# The "condition" condition checks an arbitrary expression.
g.condition("persistent.gallery_unlocked")
#
g.display("bg01.jpg")
g.display("bg02.jpg")
# Now, show the gallery.
g.show()
jump main_menu
########################
# MUSIC ROOM part 2 of 2
label music_room:
scene black
python:
_game_menu_screen = None
# The default track of music.
playing = "music1.wav"
label music_room_loop:
# Play the playing music, if it changed.
python:
renpy.music.play(playing, if_changed=True, fadeout=1)
# Display the various music buttons.
ui.vbox(xalign=0.5, ypos=100)
music_button("music 1", "music1.wav")
music_button("music 2", "music2.mp3")
music_button("music 3", "music3.mp3")
ui.close()
# This is how we return to the main menu.
ui.textbutton(
"Return",
clicked=ui.returns(False),
xalign=0.5,
ypos=450,
size_group="music")
if ui.interact():
jump music_room_loop
else:
$ _game_menu_screen = "save_screen"
jump main_menu
################################
# LABEL BONUS ROOM
################################
label bonus:
scene black
$ ui.hbox(xpos=150, ypos=350)
$ ui.imagebutton("gallery1.png", "gallery2.png", clicked=ui.returns("gallery"))
$ ui.imagebutton("musicroom1.png", "musicroom2.png", clicked=ui.returns("music"))
$ ui.imagebutton("back1.png", "back2.png", clicked=ui.returns("back"))
$ ui.close()
$ result = ui.interact()
if result == "gallery":
jump gallery
elif result == "music":
jump music_room
elif result == "back":
jump main_menu
##############
label main_menu:
scene mainmenu
$ ui.hbox(xpos=69, ypos=350)
$ ui.imagebutton("newgame1.png", "newgame2.png", clicked=ui.returns("start"))
$ ui.imagebutton("loadgame1.png", "loadgame2.png", clicked=ui.returns("load"))
$ ui.imagebutton("bonusbutton1.png", "bonusbutton2.png", clicked=ui.returns("bonus"))
$ ui.imagebutton("options1.png", "options2.png", clicked=ui.returns("prefs"))
$ ui.imagebutton("exit1.png", "exit2.png", clicked=ui.returns("quit"))
$ ui.close()
$ result = ui.interact()
if result == "start":
hide mainmenu
$ renpy.jump_out_of_context("start")
elif result == "load":
jump load_screen
elif result == "bonus":
jump bonus
elif result == "prefs":
jump preferences_screen
elif result == "quit":
$ renpy.quit()
Aleema-sama!Aleema wrote:Heh. That main menu code is old. Screen language (screens.rpy) has a main menu screen just like that but with SL.
To keep the SL screens and your screens from clashing, delete the SL screens you don't want. Meaning, delete "screen main_menu" completely and the bugs should stop happening. You can always get the code again later, it's always in your "template" game and in the documentation.
Users browsing this forum: No registered users