Predict text height in a screen

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
Amethysts
Regular
Posts: 41
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

Predict text height in a screen

#1 Post by Amethysts »

Hello everyone ! :)

I'm making a list of windows with different heights, is it possible to do it a clean and precise way on Ren'Py ?

All I have for now is :

1) Irrelevant
Image

2) Or not precise (and display errors appears because it's not the good way to do it)

Code: Select all

$ lines= int(len(string)/30)+1
$ height= 35 + 55*lines

I looked for answers on internet during like an hour, but nothing relevant... But it must be a frequent question (and already answered maybe) , sorry if I disturb you !

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Predict text height in a screen

#2 Post by Kia »

try vbox:

Code: Select all

vbox:
    text "title 1"
    text "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod"
    text "title 2"
    text "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

User avatar
Amethysts
Regular
Posts: 41
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

Re: Predict text height in a screen

#3 Post by Amethysts »

That's what I have done : a vbox in a window (in a viewport but i don't think it is important)

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Predict text height in a screen

#4 Post by Kia »

it is possible you've got their order wrong inf they are showing on top of each other, it's better to show your code and ask to spot the mistake

User avatar
Amethysts
Regular
Posts: 41
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

Re: Predict text height in a screen

#5 Post by Amethysts »

This code works, but without the window and the effect I wanted.

Code: Select all

viewport id "events_vp":
        at xslide(x_depart=-120, x_final=360)
        xysize (600, 517) xalign 0.5 ypos 550
        draggable True mousewheel True scrollbars "vertical"
        vbox:
            for i in liste_events:
                if i["actif"]:
                    hbox:
                        xalign 0.5
                        text _("Day") italic True color "#bbb" size 22
                        text str(i["day"]) italic True color "#bbb" size 22
                        text " - "+i["hour"] italic True color "#bbb" size 22
                    text i["details"] justify True
		    text ""
This does not fit, but with the effect I wanted (a window grey, then a window dark, then a grey etc...):

Code: Select all

viewport id "events_vp":
        at xslide(x_depart=-120, x_final=360)
        xysize (600, 517) xalign 0.5 ypos 550
        draggable True mousewheel True scrollbars "vertical"
        vbox:
            for i in liste_events:
                if i["actif"]:
                    $ flip = not(flip)
                    window:
                        ymargin 2
                        if flip:
                            background "#1115"
                        else:
                            background "#3335"
             
	                hbox:
        	            xalign 0.5
                	    text _("Day") italic True color "#bbb" size 22
                            text str(i["day"]) italic True color "#bbb" size 22
                            text " - "+i["hour"] italic True color "#bbb" size 22
                    	text i["details"] justify True
                    	text ""

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Predict text height in a screen

#6 Post by Kia »

the problem is where you have put multiple objects inside a window, if you want the window to get it's size automatically, you can only have one object in it:

Code: Select all

viewport id "events_vp":
        at xslide(x_depart=-120, x_final=360)
        xysize (600, 517) xalign 0.5 ypos 550
        draggable True mousewheel True scrollbars "vertical"
        vbox:
            for i in liste_events:
                if i["actif"]:
                    $ flip = not(flip)
                    window:
                        ymargin 2
                        if flip:
                            background "#1115"
                        else:
                            background "#3335"
                        vbox:
	                    hbox:
        	                xalign 0.5
                	        text _("Day") italic True color "#bbb" size 22
                                text str(i["day"]) italic True color "#bbb" size 22
                                text " - "+i["hour"] italic True color "#bbb" size 22
                            text i["details"] justify True
                            text ""

User avatar
Amethysts
Regular
Posts: 41
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

Re: Predict text height in a screen

#7 Post by Amethysts »

It doesn't work neither, but thank you anyway for giving your time :)

I will just use a monochromatic window behind the viewport, that's not really important !

Post Reply

Who is online

Users browsing this forum: apocolocyntose