A couple of problems with a CG 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
Hime
Veteran
Posts: 384
Joined: Thu Jun 01, 2006 12:46 pm
Projects: Project Nattsu, Take Rena Home
Contact:

A couple of problems with a CG gallery...

#1 Post by Hime »

So, I'm trying to make a CG gallery, but it isn't quite working in some aspects...

Image
(Red ugly box for the CGs that work... Since I don't feel like spoiling you with the ending CGs of Project Nattsu.)

So, the problems and questions:
1) CGs not unlocking...
So, even though I'm sure the code is right and that I've played through the situations where CGs 05 and 07 are, they won't unlock... Here's the code for the gallery from these CGs:

Code: Select all

        g.button("CG05thumbSEPIA.png")
        #
        # These show images, if they have been unlocked. The image name must
        # have been defined using an image statement.
        g.unlock_image("cg trueend1")
        g.allprior()

Code: Select all

        g.button("CG07thumbSEPIA.png")
        #
        # These show images, if they have been unlocked. The image name must
        # have been defined using an image statement.
        g.unlock_image("cg badend")
        g.allprior()
I'm sure I haven't written any typos either...

2) "Backgrounds"-thing
...I can't make the gallery work without this piece of code:

Code: Select all

        # Show the background page.
        g.page("Backgrounds")
I don't want any background sections, so how can I make the gallery work without this? And possibly just have a "return"-button instead.

3) "Backgrounds"-thing 2
As you can see from the picture, only half of that box is on the screen. How can I change it's position?

4) The positions of the CG thumbs
I'd like to have them on the middle rather than on the left side. But how can I do that?

Gosh, I sure feel helpless. ._.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#2 Post by PyTom »

Hmm.... do you have a "show cg trueend1" somewhere in your program? If you don't, then that's the problem. If you do, then please send me the game/saves/persistent file, so I can pick it apart and see what the problem is.

You can eliminate the pages by adding in a "navigation" function that displays what you want for navigation. For example:

Code: Select all

init python:
    def my_navigation( page_name, page_num, pages):        
            ui.frame(style='gallery_nav_frame')
            ui.vbox(style='gallery_nav_vbox')

            _button_factory("Return", "gallery_nav", clicked=ui.returns(("return
", 0)))

            ui.close()
Then, when you're showing the gallery, you'd have:

Code: Select all

      g  = Gallery()
      g.navigation = my_navigation
You can position the navigation frame by setting various position properties on gallery_nav_frame. To move it to the lower-right corner of the screen, you can write:

Code: Select all

init:
    $ style.gallery_nav_frame.xalign = 0.98
    $ style.gallery_nav_frame.yalign = 0.98
The second argument to g.grid_layout controls where the upper-left corner of the thumbnail grid is placed on the screen. To center it, try:

Code: Select all

    g.grid_layout((3, 4), (160, 12), (160, 124))
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Hime
Veteran
Posts: 384
Joined: Thu Jun 01, 2006 12:46 pm
Projects: Project Nattsu, Take Rena Home
Contact:

#3 Post by Hime »

Thanks for the help, PyTom. :) And I'm 100% sure that I have both "show cg trueend1" and "show cgbadend" in the program. And I have checked that they show in the game, too. But... By sending the "the game/saves/persistent file", do you mean that I should send you the whole thing, or just some specific files? ^^; And if it's some specific files, which ones? (Duh, I'm totally helpless.)

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#4 Post by PyTom »

There is one specific file that I need... go to your game directory, then go to the saves directory under that, and the file is named "persistent".
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Hime
Veteran
Posts: 384
Joined: Thu Jun 01, 2006 12:46 pm
Projects: Project Nattsu, Take Rena Home
Contact:

#5 Post by Hime »

Okay, here it is! :)
Attachments
persistent.zip
(8.13 KiB) Downloaded 81 times

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#6 Post by PyTom »

Hm... can you send me a copy of the game via email? The persistent data looks good, so I think I need to go in and try things out to see what's wrong.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Hime
Veteran
Posts: 384
Joined: Thu Jun 01, 2006 12:46 pm
Projects: Project Nattsu, Take Rena Home
Contact:

#7 Post by Hime »

Yes, it's sent now... (In two parts, by the way.)

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#8 Post by PyTom »

Okay, took a look at this. Your problem is that you're using g.allprior() in places where it doesn't make sense to use it. Basically, g.allprior() should be used when you want an image to unlock if and only if all the images before it have unlocked.

When you write:

Code: Select all

        g.button("CG05thumbSEPIA.png")
        #
        # These show images, if they have been unlocked. The image name must
        # have been defined using an image statement.
        g.unlock_image("cg trueend1")
        g.allprior()
There's no prior image to unlock. So this image will never unlock, and the button will remain locked.

My gut feeling is that if you remove all of the allprior lines in your script, it will do what you want.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Hime
Veteran
Posts: 384
Joined: Thu Jun 01, 2006 12:46 pm
Projects: Project Nattsu, Take Rena Home
Contact:

#9 Post by Hime »

So that was the problem... Oh yesyesyes, it works! Thank you a lot again, PyTom! ^^

IceD
Veteran
Posts: 433
Joined: Sun Feb 01, 2009 6:15 pm
Contact:

Re:

#10 Post by IceD »

PyTom wrote: You can eliminate the pages by adding in a "navigation" function that displays what you want for navigation. For example:

Code: Select all

init python:
    def my_navigation( page_name, page_num, pages):        
            ui.frame(style='gallery_nav_frame')
            ui.vbox(style='gallery_nav_vbox')

            _button_factory("Return", "gallery_nav", clicked=ui.returns(("return
", 0)))

            ui.close()
Hey!

I also found this topic very useful, but want to ask one question - is there a specific place where this part of code should go, like in the gallery label or can it go anywhere else? I just can manage to run this properly and get different types of errors depending on where I wrote this. I also suspect that the

Code: Select all

# Show the background page.
g.page("Backgrounds")
has to be deleted if the gallery wants to be run without sections and only user predetermined interface based upon "navigation" function, as it was written earilier. I'm just curious if I didn't wrote anything wrong, because maybe it's the only reason why the code isn't running. Anyways, normal gallery based on sections works fine, but I also would like to have it without them. I beg for help :)

Post Reply

Who is online

Users browsing this forum: Google [Bot]