New CG Gallery

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
PyTom
Ren'Py Creator
Posts: 16096
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:

New CG Gallery

#1 Post by PyTom »

http://www.renpy.org/wiki/renpy/doc/coo ... CG_Gallery

I've posted code for a new CG gallery up in the Ren'Py cookbook. This gallery should be as powerful as the one in Ori, Ochi, Onoe, and a bit more flexible.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

#2 Post by DaFool »

Yay! Thank you!

(Although, very few games actually have enough pictures to even warrant a gallery :? )

chisa-chan
Regular
Posts: 197
Joined: Fri Nov 10, 2006 3:25 am
Location: at a village near Bandung, Indonesia
Contact:

#3 Post by chisa-chan »

Riiii~~~ght, finally!

Btw, I do not understand about the Gallery.condition...
Does it apply condition to buttons or image?
Kalau tidak suka ya jangan diladeni, gitu aja kok repot™.
Cynanthia's Blog (Indonesian)

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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:

#4 Post by PyTom »

It can apply to either buttons or images. If you call it immediately after a button, then it applies to that button. If you call it after an image, then it applys to only that image. For example:

Code: Select all

g = Gallery()

...

g.page("Secret Stuff")
g.button("thumb_secret.png")
g.condition("persistent.secret")

g.display("secret1.png")
g.display("secret2.png")

g.display("secret3.png")
g.condition("persistent.super_secret")
This will unlock the secret button, and hence secret1 and secret2, if persistent.secret has been set. secret3 is only unlocked if both persistent.secret and persistent.super_secret have been set.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

chisa-chan
Regular
Posts: 197
Joined: Fri Nov 10, 2006 3:25 am
Location: at a village near Bandung, Indonesia
Contact:

#5 Post by chisa-chan »

PyTom wrote:It can apply to either buttons or images. If you call it immediately after a button, then it applies to that button. If you call it after an image, then it applys to only that image. For example:

Code: Select all

g = Gallery()

...

g.page("Secret Stuff")
g.button("thumb_secret.png")
g.condition("persistent.secret")

g.display("secret1.png")
g.display("secret2.png")

g.display("secret3.png")
g.condition("persistent.super_secret")
This will unlock the secret button, and hence secret1 and secret2, if persistent.secret has been set. secret3 is only unlocked if both persistent.secret and persistent.super_secret have been set.
Ara, I see...

But...how if we want to apply different condition? (ie. img1 with persistent.end1 and img2 with persistent.end2)

Sorry for asking too much...
Kalau tidak suka ya jangan diladeni, gitu aja kok repot™.
Cynanthia's Blog (Indonesian)

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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:

#6 Post by PyTom »

You would just apply conditions to those images, and not the button.

Code: Select all

g = Gallery()

...

g.page("Secret Stuff")
g.button("thumb_secret.png")

g.display("secret1.png")
g.condition("persistent.end_1")

g.display("secret2.png")
g.condition("persistent.end_2")

g.display("secret3.png")
g.condition("persistent.end_3") 
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

chisa-chan
Regular
Posts: 197
Joined: Fri Nov 10, 2006 3:25 am
Location: at a village near Bandung, Indonesia
Contact:

#7 Post by chisa-chan »

Right, thanks a lot!
Kalau tidak suka ya jangan diladeni, gitu aja kok repot™.
Cynanthia's Blog (Indonesian)

NetGenSuperstar
Regular
Posts: 113
Joined: Sun Oct 08, 2006 1:29 am
Location: BEHIND YOU!!!
Contact:

#8 Post by NetGenSuperstar »

Just found a bug in the new gallery code; line 125:

Code: Select all

ui.imagebutton(self.gallery.hover_border,
               self.gallery.idle_border,
               clicked=ui.returns(("button", i)),
               **props)
Shouldn't idle_border and hover_border be switched?

Otherwise, I love the new gallery code.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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:

#9 Post by PyTom »

Looks like it, thanks. A fixed version has been uploaded.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Nio
Regular
Posts: 160
Joined: Mon Jan 03, 2005 4:37 am
Projects: ??????
Location: In his own little world.
Contact:

Re: New CG Gallery

#10 Post by Nio »

What would be the command to call the gallery from an imagebutton?

I tried this:
clicked=_intra_jumps("_gallery", "main_game_transition")

but got an error.

PrettySammy09
Veteran
Posts: 313
Joined: Sat Oct 21, 2006 4:18 pm
Contact:

Re: New CG Gallery

#11 Post by PrettySammy09 »

*hugs PyTom*

:) Everyone needs hugs!

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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: New CG Gallery

#12 Post by PyTom »

Assuming you're using the code given on the website, it will be:

clicked=_intra_jumps("gallery", "main_game_transition")

without the leading underscore. Note that you define the label containing the gallery code, so you can change that label to anything you want.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Nio
Regular
Posts: 160
Joined: Mon Jan 03, 2005 4:37 am
Projects: ??????
Location: In his own little world.
Contact:

Re: New CG Gallery

#13 Post by Nio »

Another thing, I'm trying to hardcode my own menu buttons for the gallery. I figured out how to add a button to the gallery vbox easy enough, but to get the correct clicked command I can't figure out. Of course it would have to correlate with the gallery pages I make.

So if I have a Character page what would the clicked command be for an imagebutton?

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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: New CG Gallery

#14 Post by PyTom »

It cares about page numbers, rather than page names. To update the navigation, you want to have something like:

Code: Select all

init python:
    def gallery_navigation(page_name, page_num, pages):
          ui.imagebutton("page0_idle.png", "page0_hover.png", clicked=ui.returns(("page", 0)), xpos=..., ypos=...)
          ui.imagebutton("page1_idle.png", "page1_hover.png", clicked=ui.returns(("page", 1)), xpos=..., ypos=...)
          ui.imagebutton("page2_idle.png", "page2_hover.png", clicked=ui.returns(("page", 2)), xpos=..., ypos=...)

          ui.imagebutton("return_idle.png", "return_hover.png", clicked=ui.returns(("return", 0)), xpos=..., ypos=...)

label gallery:
    python hide:

        # Construct a new gallery object.
        g = Gallery()
        g.navigation = gallery_navigation
Remember, pages are numbered starting from zero, like Turing intended.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Nio
Regular
Posts: 160
Joined: Mon Jan 03, 2005 4:37 am
Projects: ??????
Location: In his own little world.
Contact:

Re: New CG Gallery

#15 Post by Nio »

Nice. Got it working. Thank!

I know about starting at 0 from my PHP experience. ^^

Post Reply

Who is online

Users browsing this forum: Google [Bot]