Resizing a frame

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
Lezalith
Regular
Posts: 82
Joined: Mon Dec 21, 2015 6:45 pm
Contact:

Resizing a frame

#1 Post by Lezalith » Mon Jul 18, 2016 11:58 am

Sorry for asking this, I just can't seem to understand how Frames work. Atleast I think I need Frame for this.
I want to resize skillcheck.png (Which is just a blue box at the moment) to be covering the entire text in vbox.
As I will have multiple versions of the text, I don't want to make a different box for each of them.

Code: Select all

screen skillcheck:
    frame:
        background "skillcheck.png"
        left_padding 10
        right_padding 10
        yminimum 55
        xminimum 232
        at skillcheckTransform
        vbox:
            text "This is => Some sort of text"
This is what I came up with, but the image stays the same.

User avatar
morg
Regular
Posts: 95
Joined: Sun May 10, 2015 7:35 am
Projects: Cupid's Affair
Tumblr: n-morg
Contact:

Re: Resizing a frame

#2 Post by morg » Mon Jul 18, 2016 12:22 pm

go to options.rpy and type

Code: Select all

style.frame.background = Frame("skillcheck.png", 10, 10)
Frame resizes the image to fit everything inside, the 10s are margins I believe.
Image

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Resizing a frame

#3 Post by chocoberrie » Mon Jul 18, 2016 12:43 pm

morg is correct!

From Aleema's textbox customization tutorial:

Dialogue boxes that use Frame look for the corners of the image, and then stretch whatever's in between to fit the proportions you give it in the code.

Image

The numbers are the width and height of each corner of the box, in pixels. :)

User avatar
Lezalith
Regular
Posts: 82
Joined: Mon Dec 21, 2015 6:45 pm
Contact:

Re: Resizing a frame

#4 Post by Lezalith » Mon Jul 18, 2016 1:09 pm

Sorry, but that doesn't work. It changes the box with all the buttons in Main Menu (As I am still using the very default, not changed menu) and the "Are you sure you want to quit" thing, but it doesn't do anything to that vbox that I need.

It should work though, right? I mean,
I was reading through this, doesn't seem like I took much from it.

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Resizing a frame

#5 Post by chocoberrie » Mon Jul 18, 2016 2:06 pm

Ah, okay. Well, I did find this page in the documentation about vbox, maybe something there will help you?

Here are the box style properties that vbox can have, but I don't see Frame anywhere in the list. It seems to me that you might need to make your box image the size that you want the vbox to be... Frame is supposed to automatically resize the box, but from what I gather, it applies to the ADV dialogue box, and not to vbox... :?

The position style properties for vbox include these:

xsize - int
Equivalent to setting xminimum and xmaximum to the same value. This has the effect of setting the width of the displayable.

ysize - int
Equivalent to setting yminimum and ymaximum to the same value. This has the effect of setting the height of the displayable.

(This may be what you want, since the documentation says that xminimum and yminimum only work with displayables that can vary in size.)

I've never messed with vbox coding before, but I hope this helps in some way. ^^;;

User avatar
Lezalith
Regular
Posts: 82
Joined: Mon Dec 21, 2015 6:45 pm
Contact:

Re: Resizing a frame

#6 Post by Lezalith » Mon Jul 18, 2016 2:33 pm

I need the frame to be there, as vbox doesn't have any "background" option. The xsize and ysize does change the vbox height and widht (change the space the text is in), but doesn't do anything to the image itself.

I can't even change the size of the image with frame, when I use xsize and ysize.

Gash, I really wanna avoid having to do 96 versions of the same picture. Anyway chocoberrie, thank you for the effort.

User avatar
Lezalith
Regular
Posts: 82
Joined: Mon Dec 21, 2015 6:45 pm
Contact:

Re: Resizing a frame

#7 Post by Lezalith » Mon Jul 18, 2016 3:05 pm

I could avoid having to do 96 versions of the same picture, if only I could resize it with frame.
Not to automatically fit the text in vbox, just resize it.
Then I'd only have to do 96 versions of the frame parameters about which size it should be.

It still sucks, but it would beat the hours of editing the pictures...

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Resizing a frame

#8 Post by chocoberrie » Mon Jul 18, 2016 3:57 pm

Hmmm... Here is the documentation for Frame. It points out that Frame also takes these common properties, which includes style.

style
The name of the style applied to this displayable. This may be a string name, or a style object. The style gives default values for style properties.

So based on this, I would think that

Code: Select all

style.frame.background = Frame("skillcheck.png", 10, 10)
would still work, you would just have to define your own style for this particular Frame box (e.g. style "skillcheck"):

Code: Select all

screen skillcheck:
    frame:
        style "skillcheck"
        left_padding 10
        right_padding 10
        yminimum 55
        xminimum 232
        at skillcheckTransform
        vbox:
            text "This is => Some sort of text"
And then you can define that style in options.rpy. Here is the documentation on styles.

I have no idea how you could define a style that lets you use Frame to resize skillcheck.png. This is just my wild guess:

Code: Select all

style skillcheck:
    background = Frame("skillcheck.png", 10, 10)

User avatar
Lezalith
Regular
Posts: 82
Joined: Mon Dec 21, 2015 6:45 pm
Contact:

Re: Resizing a frame

#9 Post by Lezalith » Mon Jul 18, 2016 4:13 pm

YES! I've reached the Promised Land!

Code: Select all

transform skillcheckTransform:
    xalign 0.5 yalign 0.5 alpha 1.0
    linear 1.5 yalign 0.0 alpha 0.0
    
style skillcheckStyle:
    background Frame("skillcheck.png", 10, 10)
    
screen skillcheck:
    frame:
        style "skillcheckStyle"
        at skillcheckTransform
        vbox:
            text "This is => Some sort of text"
Works perfectly. Now to work out the padding, borders... You saved me tons of time (Also made my work look more professional). I couldn't be more grateful, chocoberrie! <3

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Resizing a frame

#10 Post by chocoberrie » Mon Jul 18, 2016 4:16 pm

Holy bananas!! That actually worked? Woohoo!! ;v; You're super welcome! :D <3

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Resizing a frame

#11 Post by xavimat » Tue Jul 19, 2016 12:59 pm

The styles are useful when you need different frames to have the same properties.
If you have only that frame with that background you could put directly the property in the screen.

Code: Select all

screen skillcheck:
    frame:
        background Frame("skillcheck.png", 10, 10)
        at skillcheckTransform
        vbox:
            text "This is => Some sort of text"
(Defining the transform, obviously)

I think this way is easier to read and mantain in the future.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: _ticlock_