Page 1 of 1

CG Gallery: span_buttons and unlocked_advance not working together

Posted: Sat Jun 09, 2018 5:51 am
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?

Re: CG Gallery: span_buttons and unlocked_advance not working together

Posted: Sat Jun 09, 2018 8:04 am
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)

Re: CG Gallery: span_buttons and unlocked_advance not working together

Posted: Sat Jun 09, 2018 8:47 pm
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?