CG Gallery: span_buttons and unlocked_advance not working together

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
goldo
Regular
Posts: 127
Joined: Mon Jan 23, 2017 8:23 am
Contact:

CG Gallery: span_buttons and unlocked_advance not working together

#1 Post by goldo »

Hi guys,

I'm trying to make a CG gallery using the Gallery object:
https://www.renpy.org/doc/html/rooms.html

I want every picture displayed in the gallery as buttons, and the slideshow to advance between buttons. So I'm using:
span_buttons

If true, the gallery will advance between buttons.
I also want the slideshow to advance only through unlocked pictures. So I use:
unlocked_advance

If true, the gallery will only advance through unlocked images.
However, both attributes do not seem to play nice together. The slideshow advances between button as expected, but completely ignores unlocked_advance and shows every picture.

Do you guys know a way around this?

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

Re: CG Gallery: span_buttons and unlocked_advance not working together

#2 Post by gas »

I think, but not quite sure, that depend on the Next() and Previous() actions "unlocked" properties you find in actual navigation screen in common/00gallery.rpy (i can't check it right now, give a try)
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

goldo
Regular
Posts: 127
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Re: CG Gallery: span_buttons and unlocked_advance not working together

#3 Post by goldo »

Both properties seem to be handled within the show method in common/00gallery.rpy:

Code: Select all

def show(self, button=0, image=0):
            """
            Starts showing gallery images.

            `button`
                The index of the button to start showing.
            """

            # A list of (button, image) index pairs for all of the images we know
            # about.
            all_images = [ ]

            # A list of (button, image) index pairs for all of the unlocked
            # images.
            unlocked_images = [ ]

            for bi, b in enumerate(self.button_list):

                all_unlocked = True

                for ii, i in enumerate(b.images):

                    all_images.append((bi, ii))

                    unlocked = i.check_unlock(all_unlocked)

                    if unlocked:
                        unlocked_images.append((bi, ii))
                    else:
                        all_unlocked = False

                        if self.unlocked_advance and (button == bi) and (image == ii):
                            image += 1

            self.slideshow = False

            # Loop, displaying the images.
            while True:

                if button >= len(self.button_list):
                    break

                b = self.button_list[button]

                if image >= len(b.images):
                    break

                i = b.images[image]

                result = i.show((button, image) not in unlocked_images, image, len(b.images))

                # Default action for click.

                if result is True:
                    result = "next"

                if result == 'return':
                    break

                # At this point, result is either 'next', "next_unlocked", "previous", or "previous_unlocked"
                # Go through the common advance code.

                if self.unlocked_advance:
                    images = unlocked_images
                else:
                    images = all_images

                if (button, image) in images:
                    index = images.index((button, image))
                else:
                    index = -1

                if result.startswith('previous'):
                    index -= 1
                else:
                    index += 1

                if index < 0 or index >= len(images):
                    break

                new_button, new_image = images[index]

                if not self.span_buttons:
                    if new_button != button:
                        break

                button = new_button
                image = new_image

            renpy.transition(self.transition)
I don't understand the code enough to tinker with it though, ideas would be welcome.

Also, how should I go about overriding this specific method for the Gallery object without having to redo all of common/00gallery.rpy in my script?

Post Reply

Who is online

Users browsing this forum: No registered users