- May 24, 2020
- 160
- 79
Hey everyone,
I was following this guide:
to create an image gallery.
It works nicely, but the buttons aren't hover/autobuttons and I don't know how to implement them correctly, without bruteforcing it, instead of having a "generated" gallery.
I collected the important parts of the code below:
I hope you have a nice holiday and I thank you in advance.
The only way I know, how to implement it, is to bruteforce the grid instead of filling it with a for loop.
So thanks again in advance
I was following this guide:
You must be registered to see the links
to create an image gallery.
It works nicely, but the buttons aren't hover/autobuttons and I don't know how to implement them correctly, without bruteforcing it, instead of having a "generated" gallery.
I collected the important parts of the code below:
Python:
maxnumx = 2 #2 is just an example
maxnumy = 2
maxperpage = maxnumx * maxnumy
class GalleryItem:#probably one of the things, that we have to edit
def_init_(self, name, images, thumb, Locked="lockedthumb"):
self.name = name
self.images = images
self.thumb = thumb
self.locked = locked
self.refresh_lock()
def num_images(self):
return len(self.images)
def return_lock(self):
self.num_unlocked = 0
lockme = False
for img in self.images:
if not renpy.seen_image(img):
lockme = True
else:
self.num_unlocked += 1
self.is_locked = lockme
#insert pictures here
gallery_items = []
gallery_items.append(GalleryItem("Image 1", ["img1", "img1b"], "thumb1"))
gallery_items.append(GalleryItem("Image 2", ["img2", "img2b"], "thumb2"))
[...]
screen gallery:
tag menu
add "black"#just background
$start = gallery_page * maxperpage
$end = min(start + maxperpage - 1, len(gallery_items) - 1)
[...]
grid maxnumx maxnumy:
xfill True
yfill True
for i in range(start, end+1): #I decide to cut the lockfunction for simplicity
imagebutton idle gallery_items[i].thumb:#We have to edit this to auto and make sure, that auto works, but idk how
action Show("gallery_closeup", dissolve, gallery_items[i].images)
textbutton "Return":
[...]
The only way I know, how to implement it, is to bruteforce the grid instead of filling it with a for loop.
So thanks again in advance