[Bug] Gallery span_buttons + unlocked_advance likely not working as intended
Posted: Fri Jan 05, 2024 8:51 am
I ran into an issue where I do not believe the gallary object in '00gallery.rpy' is working as intended.
Here we have two gallery buttons defined like so (with the red one unlocked):
From here clicking on the red square goes into a picture of that same red square and clicking the grey square does nothing, as expected.
However, in the menu of the red square, the menu enabled by 'g.navigation = True', it is posible to navigate into the blue square by clicking next, dispite blue remaining locked.
I looked closer into the gallery source code, 00gallery.rpy, and found the part handeling the navigation behavior:
Now, 'image' should only contain the red image at the time of the bug, since 'unlocked_images' should only contain the red image. That way, once 'index' is incrimented, it should fall out of range and the loop should break. This is not what happens however, so 'images' and 'unlocked_images' must contain more images than is intended.
I would like to do more research, but I am unable to get the state of 'unlocked_images' at runtime. Does anyone have an idear of what the problem could be and how I could get to the value at runtime?
Here we have two gallery buttons defined like so (with the red one unlocked):
Code: Select all
default file_dict = {"red_file": False, "blue_file": False}
init python:
global file_dict
g = Gallery()
g.navigation = True
g.span_buttons = True
g.unlocked_advance = True
g.button("red_square")
g.condition("file_dict['red_file']")
g.image("Red_50x50.png")
g.button("blue_square")
g.condition("file_dict['blue_file']")
g.image("Blue_50x50.png")
screen file_gallery:
tag menu
use game_menu(_("Files")):
grid 3 3:
xfill True
yfill True
add g.make_button("red_square", "Red_50x50.png", locked = "Gray_50x50.png", xalign = 0.5, yalign = 0.5)
add g.make_button("blue_square", "Blue_50x50.png", locked = "Gray_50x50.png", xalign = 0.5, yalign = 0.5)
However, in the menu of the red square, the menu enabled by 'g.navigation = True', it is posible to navigate into the blue square by clicking next, dispite blue remaining locked.
I looked closer into the gallery source code, 00gallery.rpy, and found the part handeling the navigation behavior:
Code: Select all
def show(self, button=0, image=0):
# 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:
...
# 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
I would like to do more research, but I am unable to get the state of 'unlocked_images' at runtime. Does anyone have an idear of what the problem could be and how I could get to the value at runtime?