Several pages for Gallery CG, like an album

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
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

Several pages for Gallery CG, like an album

#1 Post by johandark »

I´ve got this: Image

I´m trying to make a Gallery for my game.

For images, Music and Scenes.

So far I´ve done this code (wich I changed a little bit):

Code: Select all

transform slowpan:
    xpos 0.0
    block:
        easein_quad 2.0 xpos 0.1
        easein_quad 2.0 xpos 0.0
        repeat


init python:

    # Step 1. Create the gallery object.
    g = Gallery()

    # Step 2. Add buttons and images to the gallery.

    # A button that contains an image that automatically unlocks.
    g.button("dawn")
    g.image("dawn1")
    g.unlock("end1")

    # This button has multiple images assocated with it. We use unlock_image
    # so we don't have to call both .image and .unlock. We also apply a
    # transform to the first image.
    g.button("dark")
    g.unlock_image("bigbeach1")
    g.transform(slowpan)
    g.unlock_image("beach1_mary")
    g.unlock_image("beach2")
    g.transform(slowpan)
    g.unlock_image("beach3")

    # This button has a condition associated with it, allowing code
    # to choose which images unlock.
    g.button("end1")
    g.condition("persistent.unlock_1")
    g.image("transfer")
    g.image("moonpic")
    g.image("girlpic")
    g.image("nogirlpic")
    g.image("bad_ending")

    g.button("end2")
    g.condition("persistent.unlock_2")
    g.image("library")
    g.image("beach1 nomoon")
    g.image("bad_ending")

    # The last image in this button has an condition associated with it,
    # so it will only unlock if the user gets both endings.
    g.button("end3")
    g.condition("persistent.unlock_3")
    g.image("littlemary2")
    g.image("littlemary")
    g.image("good_ending")
    g.condition("persistent.unlock_3 and persistent.unlock_4")

    g.button("end4")
    g.condition("persistent.unlock_4")
    g.image("hospital1")
    g.image("hospital1")
    g.image("hospital1")
    g.image("hospital1")
    g.image("hospital1")
    g.image("good_ending")
    g.condition("persistent.unlock_3 and persistent.unlock_4")

    # The final two buttons contain images that show multiple pictures
    # at the same time. This can be used to compose character art onto
    # a background.
    g.button("dawn mary")
    g.unlock_image("dawn1", "mary dawn wistful")
    g.unlock_image("dawn1", "mary dawn smiling")
    g.unlock_image("dawn1", "mary dawn vhappy")

    g.button("dark mary")
    g.unlock_image("beach2", "mary dark wistful")
    g.unlock_image("beach2", "mary dark smiling")
    g.unlock_image("beach2", "mary dark vhappy")

    # The transition used when switching images.
    g.transition = dissolve

# Step 3. The gallery screen we use.
screen gallery():

    # Ensure this replaces the main menu.
    tag menu
    
    use game_menu(_("gallery"), scroll="viewport"):

        style_prefix "gallery"

        # The background.
        #add "dawn1"

        # A grid of buttons.
        grid 3 3:

            xfill True
            yfill True

            # Call make_button to show a particular button.
            add g.make_button("dark", "01.jpg", "05", hover_border="02.jpg", idle_border="03.jpg", xalign=0.0, yalign=0.0)
            add g.make_button("dawn", "02.jpg", "05", hover_border="02.jpg", idle_border="03.jpg", xalign=0.0, yalign=0.0)
            add g.make_button("end1", "03.jpg", "05", hover_border="02.jpg", idle_border="03.jpg", xalign=0.0, yalign=0.0)

            add g.make_button("end2", "04.jpg", hover_border="02.jpg", idle_border="03.jpg", xalign=0.0, yalign=0.0)
            add g.make_button("end3", "05", hover_border="02.jpg", idle_border="03.jpg", xalign=0.0, yalign=0.0)
            add g.make_button("end4", "06.jpg", hover_border="02.jpg", idle_border="03.jpg", xalign=0.0, yalign=0.0)

            add g.make_button("dark mary", "07", hover_border="02.jpg", idle_border="03.jpg", xalign=0.0, yalign=0.0)
            add g.make_button("dawn mary", "08", hover_border="02.jpg", idle_border="03.jpg", xalign=0.0, yalign=0.0)

            # The screen is responsible for returning to the main menu. It could also
            # navigate to other gallery screens.
            textbutton "Return" action Return() xalign 0.25 yalign 0.0
This code works fine if you use this other one on menu:

Code: Select all

textbutton "Gallery" action ShowMenu("gallery")
I would like 2 things when you arrive on this "Gallery" Page.

1) Find 3 different buttons to go to the 3 different galleries, Music, Images and Scenes.

2) If you are in any of these 3, find buttons like the Save page, where you can select different pages for, for example, images, like an album of photos.

Thanks!
Image

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: Several pages for Gallery CG, like an album

#2 Post by SuperbowserX »

I think you would need to adjust screen gallery to pop up three imagebuttons; one leading to images, one to music and one to scenes. When one of those imagebuttons is clicked on, show the appropriate screen, and then do it in there.

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

Re: Several pages for Gallery CG, like an album

#3 Post by gas »

I did so in my game :).

So.
Issue one. You want to add the 3 buttons to the navigation menu?

***EDITED, MORE COMPLEX***
Issue two.
Create naviscreen(), where you have 3 buttons, that show the gallery screen passing the variable "page_gallery".
like...
textbutton "1" action Show("gallery", page_gallery=1)

Declare the gallery screen this way:
screen gallery(page_gallery=0):
Then use conditionals to show the buttons.

Code: Select all

if page_gallery==0:
    add.g.blablabla button 1
    add.g.blablabla button 2
    ...
if page_gallery==1:
    add.g.blablabla button 2
    add.g.blablabla button 3
    ...
(of course you reach first naviscreen() from your navigation, to have the player choose the page!)
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
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

Re: Several pages for Gallery CG, like an album

#4 Post by johandark »

Thanks gas!

I found this problem:

I´ve did this:

Code: Select all

screen gallery_naviscreen():
    textbutton "0" action Show("gallery", page_gallery=0)
    textbutton "1" action Show("gallery", page_gallery=1)
    textbutton "Return" action Return() #xalign 0.25 yalign 0.0
and then at the end of the page I did this:

Code: Select all

            # The screen is responsible for returning to the main menu. It could also
            # navigate to other gallery screens.
            show screen gallery_naviscreen()
This is the message I recive:

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/gallery.rpy", line 156: u'show' is not a keyword argument or valid child for the grid statement.
    show screen gallery_naviscreen()
        ^

Ren'Py Version: Ren'Py 6.99.11.1749
I think it happens because it´s "init python" But I have no clue how to solve this problem...

Thanks!
Image

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

Re: Several pages for Gallery CG, like an album

#5 Post by gas »

No, it's an hinting error.
You've putted the show thing inside the grid.
like

Code: Select all

screen X():
    grid 3 1:
        whatever
        show screen blabla
while need to be

Code: Select all

screen X():
    grid 3 1:
        whatever
    show screen blabla
anyway it's USE SCREEN_NAME to use a screen inside another, not SHOW SCREEN SCREEN_NAME
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
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

Re: Several pages for Gallery CG, like an album

#6 Post by johandark »

After doing what you told me, It keeps me telling this... :( :

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/gallery.rpy", line 157: u'show' is not a keyword argument or valid child for the use statement.
    show screen gallery_naviscreen()     
        ^

Ren'Py Version: Ren'Py 6.99.11.1749
Image

Post Reply

Who is online

Users browsing this forum: No registered users