Images
Code: Select all
##############################CG For Gallery##########################
image img1 = "main_menu.png"
image img2 = "CG1.png"
image img3 = "CG2.jpg"
image img4 = "CG3.jpg"
image img5 = "CG4.jpg"
image img6 = "CG5.png"
image img7 = "CG6.png"
image img8 = "CG7.png"
##############################Thumbnails##############################
image lockedthumb = "thumbnail_locked.png"
image thumb1 = "thumbnail_main_menu.png"
image thumb2 = "thumbnail_CG1.png"
image thumb3 = "thumbnail_CG2.jpg"
image thumb4 = "thumbnail_CG3.jpg"
image thumb5 = "thumbnail_CG4.jpg"
image thumb6 = "thumbnail_CG5.png"
image thumb7 = "thumbnail_CG6.png"
image thumb8 = "thumbnail_CG7.png"Code: Select all
screen gallery:
tag menu
add "gui/game_menu.png"
$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):
$gallery_items[i].refresh_lock()
if gallery_items[i].is_locked:
add gallery_items[i].locked:
xalign 0.5
yalign 0.5
else:
imagebutton idle gallery_items[i].thumb:
action Show("gallery_closeup", dissolve, gallery_items[i].images)
xalign 0.5
yalign 0.5
for i in range(end - start + 1, maxperpage):
null
if gallery_page > 0:
textbutton "Previous":
action SetVariable("gallery_page", gallery_page - 1)
xalign 0.1
yalign 0.95
if (gallery_page + 1) * maxperpage < len(gallery_items):
textbutton "Next":
action SetVariable("gallery_page", gallery_page + 1)
xalign 0.9
yalign 0.95
textbutton "Return" action Return() xalign 0.03 yalign 0.95
screen gallery_closeup(images):
imagebutton idle images[closeup_page] at truecenter:
action [SetVariable("closeup_page", 0), Hide("gallery_closeup", dissolve)]
Code: Select all
init python:
def MaxScale(img, minwidth=config.screen_width, minheight=config.screen_height):
currwidth, currheight = renpy.image_size(img)
xscale = float(minwidth) / currwidth
yscale = float(minheight) / currheight
if xscale > yscale:
maxscale = xscale
else:
maxscale = yscale
return im.FactorScale(img, maxscale, maxscale)
def MinScale(img, maxwidth=config.screen_width, maxheight=config.screen_height):
currwidth, currheight = renpy.image_size(img)
xscale = float(maxwidth) / currwidth
yscale = float(maxheight) / currheight
if xscale < yscale:
minscale = xscale
else:
minscale = yscale
return im.FactorScale(img, minscale, minscale)
maxnumx = 4
maxnumy = 2
maxthumbx = config.screen_width / (maxnumx + 1)
maxthumby = config.screen_height / (maxnumy + 1)
maxperpage = maxnumx * maxnumy
gallery_page = 0
closeup_page = 0
class GalleryItem:
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 refresh_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
gallery_items = []
gallery_items.append(GalleryItem("Image 1", ["img1"], "thumb1"))
gallery_items.append(GalleryItem("Image 2", ["img2"], "thumb2"))
gallery_items.append(GalleryItem("Image 3", ["img3"], "thumb3"))
gallery_items.append(GalleryItem("Image 4", ["img4"], "thumb4"))
gallery_items.append(GalleryItem("Image 5", ["img5"], "thumb5"))
gallery_items.append(GalleryItem("Image 6", ["img6"], "thumb6"))
gallery_items.append(GalleryItem("Image 7", ["img7"], "thumb7"))
gallery_items.append(GalleryItem("Image 8", ["img8"], "thumb8"))