Anyone know how to show save screenshots dynamically?

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
ProgrammerByDefault
Newbie
Posts: 9
Joined: Sun Apr 06, 2014 8:49 pm
Contact:

Anyone know how to show save screenshots dynamically?

#1 Post by ProgrammerByDefault »

I am working on customizing the save/load screen to have a layout similar to an email inbox, with a scrolling list of save name/times on the left, and a large space for a save screenshot on the right.

The goal is to have it set up so that when the user clicks a save file on the left, the associated screenshot will be shown on the right, and they will be able to save/load using the selected slot.

The part where I am getting hung up is proper showing/hiding of the individual file screenshots. I can fetch and show one with FileScreenshot(slot_num), but I can't figure out how to make this work with the button click. Does anyone have suggestions for the best way to get this working? The code for the screen definition I am using is below so you know where I'm at.

(P.S I am fairly experienced at programming, so don't shy away from python-intensive solutions.)

Code: Select all

    def game_saves(x_pos, y_pos, **kwargs):
        ui.frame(xminimum = 950, xmaximum = 950,
                 yminimum = 475, ymaximum = 475,
                 xpos = x_pos, ypos = y_pos)
        ui.viewport(id = "save_port", mousewheel = True)
        ui.vbox(xpos = 30, ypos = 13)
        for i in range(1, 25):
            ui.button(clicked = FileAction(i), #placeholder. Goal is to have this hide prev image and show new one at right
                      xminimum = 300, xmaximum = 300,
                      yminimum = 15, ymaximum = 15)
            file_name = FileSlotName(i, 25)
            file_time = FileTime(i, empty=_("Empty Slot."))
            save_name = FileSaveName(i)
            ui.text("{0} {1}\n{2})".format(file_name, file_time, save_name), size=15)
        ui.close()
        ui.vbar(value = YScrollValue("save_port"), xpos = 300)
    renpy.define_screen("game_saves", game_saves)

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Anyone know how to show save screenshots dynamically?

#2 Post by Asceai »

Make the button action set a screen variable to the appropriate slot number and display that slot with FileScreenshot.

By the way, I recommend using screen language in the future, not the deprecated ui.blah / define_screen approach.

ProgrammerByDefault
Newbie
Posts: 9
Joined: Sun Apr 06, 2014 8:49 pm
Contact:

Re: Anyone know how to show save screenshots dynamically?

#3 Post by ProgrammerByDefault »

How do I handle the display part though? FileScreenshot returns a specially compressed image as far as I can see. "add FileScreenshot(i)" works to show the first, but how do I go about removing it without a proper name (and without 'hide' available since it is a screen, not a label)? Not ruling out the possibility that I am missing something fairly obvious, but I'm still a bit confused.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Anyone know how to show save screenshots dynamically?

#4 Post by xela »

You add:

Code: Select all

default meow = Null()
to the beginning of your screen or to pos arguments if you insist using ui module.

Then you add to you right frame, where the image is displayed:

Code: Select all

add meow
And with those filesave buttons in viewport you do:

Code: Select all

SetScreenVariable("meow", FileScreenshot(i))
(so basically what Asceai said to the letter)

Decent idea would be to use the newest slot for a default instead of null but that's up to you. It should return an image displayable, not "specially compressed image" whatever you meant by that.
Like what we're doing? Support us at:
Image

ProgrammerByDefault
Newbie
Posts: 9
Joined: Sun Apr 06, 2014 8:49 pm
Contact:

Re: Anyone know how to show save screenshots dynamically?

#5 Post by ProgrammerByDefault »

Ah, the way you phrased it cleared things up for me. I misunderstood when he said 'screen variable' and had myself convinced it was like any other variable (the 'screen' prefix shoulda given that away). And thanks as well for steering me away from doing too much using straight python, I can see I was introducing some unnecessary pain here. Many thanks, and happy coding!

Post Reply

Who is online

Users browsing this forum: elcharlo, Semrush [Bot]