[Help] to make changes on a script for a gallery

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
User avatar
elisa-hiwatara
Newbie
Posts: 3
Joined: Thu Aug 02, 2018 4:39 pm
Contact:

[Help] to make changes on a script for a gallery

#1 Post by elisa-hiwatara »

Hi everyone !
To begin , sorry in advance if my english is a little bad, I'm French ^^'.
I'm still quite new on ren'py, I watch tutos of a youtuber :
She showed how to make a gallery ( not the one in example in ren'py documentation).
But I want to go further:
By her script, there is a gallery when a image is locked, it can't be opened in overview and if there is two pictures at the same "imagebutton", if one is unlocked by the player, it can't be seen until the second is unlocked too.
So what I want to change/have : 1. even if the image is locked, the player can open the "overview" but they will see the locked image.
2. if one of the grouped images is unlocked by the player, the player can see this image in "overview" and the places of the others pictures of the group too but with the locked image and not the real images (because they are not unlocked)
3. We can see the first unlocked image of the group instead of the locked image as imagebutton (if there is at least one unlocked).

I try to do this changes by myself but I'm not enough skillfull to do that. :(
So would anyone want to help me make these changes ? :?:

Here the tutos of the youtuber named Elaine : part 1 : https://www.youtube.com/watch?v=GQbLN2i ... X&index=10
part 2 : https://www.youtube.com/watch?v=oAMGlmi ... X&index=11
part 3 : https://www.youtube.com/watch?v=3EhdfEw ... afLcRH0rAX

And here the scripts :

First : gallery.rpy

Code: Select all

screen gallery:
    tag menu

    add "black"

    $ start = gallery_page * maxperpage
    $ end = min(start + maxperpage - 1, len(gallery_items) - 1)

    #grid for images
    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 + 1, start + maxperpage):
            null

    #grid for info
    grid maxnumx maxnumy:
        xfill True
        yfill True

        for i in range(start, end + 1):
            hbox:
                spacing maxthumbx - 70
                xalign 0.5
                yalign 0.1
                $ total = gallery_items[i].num_images()
                $ partial = gallery_items[i].num_unlocked
                text gallery_items[i].name
                text "[partial]/[total]"

        for i in range(end - start + 1, maxperpage):
            null


    # previous/next buttons
    if gallery_page > 0:
        textbutton "Previous":
            action SetVariable("gallery_page", gallery_page - 1)
            xalign 0.1
            yalign 0.98
    if (gallery_page + 1) * maxperpage < len(gallery_items):
        textbutton "Next":
            action SetVariable("gallery_page", gallery_page + 1)
            xalign 0.9
            yalign 0.98       

    #return button
    textbutton "Return":
        action Return()
        xalign 0.5
        yalign 0.98

screen gallery_closeup(images):

    add images[closeup_page] at truecenter

    if closeup_page > 0:
        textbutton "Previous":
            action SetVariable("closeup_page", closeup_page - 1)
            xalign 0.1
            yalign 0.98
            background "black"
    if closeup_page < len(images) - 1:
        textbutton "Next":
            action SetVariable("closeup_page", closeup_page + 1)
            xalign 0.9
            yalign 0.98
            background "black"


    textbutton "Return":
        action [SetVariable("closeup_page",0), Hide("gallery_closeup", dissolve)]
        xalign 0.5
        yalign 0.98
Second : gallery_setup.rpy

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 = 2
    maxnumy = 2
    maxthumbx = config.screen_width / (maxnumx + 1)
    maxthumby = config.screen_width / (maxnumy + 1)
    maxperpage = maxnumx * maxnumy
    gallery_page = 0
    closeup_page = 0


    class GalleryItem:
        def __init__(self, name, images, thumb, locked="lockedthumb"):            ## "lockedthumb" est le nom du lien de l'image de lock
            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", "img1b"], "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"))
Last : gallery_pictures

Code: Select all

image img1 = MaxScale("Pictures/avenue_eos_by_owen_c-d5pyb3t.jpg")
image img1b = MaxScale("Pictures/967fa5a3a518ebd32480ca6560f42c69-d98jcgg.jpg")
image img2 = MaxScale("Pictures/bulletproof_by_destinyblue-d91j72d.jpg")
image img3 = MaxScale("Pictures/magical_girls_adopt_set_by_pyonkotcchi-d5aw9xk.png")
image img4 = MaxScale("Pictures/magical_mlp_applejack_oc_astorm__human__by_skyshek-d86hxt1.jpg")
image img5 = MaxScale("Pictures/sisters_by_mirukawa-d37sb7p.png")
image img6 = MaxScale("Pictures/smooth_plastic_bubbles_by_wolfepaw-d98btka.jpg")
image img7 = MaxScale("Pictures/songling_by_art_zealot-d90sp9r.jpg")
image img8 = MaxScale("Pictures/the_forest_of_secrets_by_owen_c-d7ga523.jpg")
image img9 = MaxScale("Pictures/time_waits_for_no_one_by_mirukawa-d55zvdb.png")
image img10 = MaxScale("Pictures/trick_or_treat__by_mirukawa-d5hpd0z.jpg")
image img11 = MaxScale("Pictures/tristine_by_art_zealot-d8qqecm.jpg")

image black = "#000"

image lockedthumb = MinScale("Pictures/Zahlen_Vorhangschloss_Combi_Lock_80_30-01-1.jpg", maxthumbx, maxthumby)

image thumb1 = MinScale("Pictures/avenue_eos_by_owen_c-d5pyb3t.jpg", maxthumbx, maxthumby)
image thumb2 = MinScale("Pictures/bulletproof_by_destinyblue-d91j72d.jpg", maxthumbx, maxthumby)
image thumb3 = MinScale("Pictures/magical_girls_adopt_set_by_pyonkotcchi-d5aw9xk.png", maxthumbx, maxthumby)
image thumb4 = MinScale("Pictures/magical_mlp_applejack_oc_astorm__human__by_skyshek-d86hxt1.jpg", maxthumbx, maxthumby)
image thumb5 = MinScale("Pictures/sisters_by_mirukawa-d37sb7p.png", maxthumbx, maxthumby)
image thumb6 = MinScale("Pictures/smooth_plastic_bubbles_by_wolfepaw-d98btka.jpg", maxthumbx, maxthumby)
image thumb7 = MinScale("Pictures/songling_by_art_zealot-d90sp9r.jpg", maxthumbx, maxthumby)
image thumb8 = MinScale("Pictures/the_forest_of_secrets_by_owen_c-d7ga523.jpg", maxthumbx, maxthumby)
image thumb9 = MinScale("Pictures/time_waits_for_no_one_by_mirukawa-d55zvdb.png", maxthumbx, maxthumby)
image thumb10 = MinScale("Pictures/trick_or_treat__by_mirukawa-d5hpd0z.jpg", maxthumbx, maxthumby)
image thumb11 = MinScale("Pictures/tristine_by_art_zealot-d8qqecm.jpg", maxthumbx, maxthumby)

sorry in advance for the inconvenience and thanks in advance to those who will be kind enough to help me.
Good bye and have a good day

Post Reply

Who is online

Users browsing this forum: Bing [Bot], MSN [Bot]