Spacing between lines in history 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
pfranzen
Regular
Posts: 42
Joined: Fri Apr 01, 2016 2:39 pm
Completed: Cat President 1+2, Internet Court, Too Many Santas, The Awkward Steve Duology, The Pizza Delivery Boy Who Saved the World, Francy Droo & Friends
Organization: Oh, a Rock! Studios
itch: oharock
Contact:

Spacing between lines in history screen

#1 Post by pfranzen »

Hello! I'm working on my history screen, and the entries are getting all bunched together. Right now, it looks like this:

Image

If you scroll down more, it gets worse:

Image

It seems like it's allotting the same amount of space for each history entry, regardless of whether the entry has one, two, three or more lines in it. Looking online it seems like setting "define gui.history_height" to "None" in gui.rpy should fix it(?), but I did that, and it didn't change anything.

Is it possible something else in my code is overwriting it? I made several changes to the history screen coding, so it's definitely possible I did something weird that messed it up. Here's my code:

screens.rpy:

Code: Select all

## History screen ##############################################################
##
## This is a screen that displays the dialogue history to the player. While
## there isn't anything special about this screen, it does have to access the
## dialogue history stored in _history_list.
##
## https://www.renpy.org/doc/html/history.html

screen history():
    tag menu

    modal True

    ## Avoid predicting this screen, as it can be very large.
    predict False

    style_prefix "history"
    
    add "images/backgrounds/evidence background.png" # Cover up whatever the current background is.
    
    frame:
        xysize (650, 600)
        xalign .5
        yalign .5
        
        vpgrid:
            cols 1
            spacing 5
            draggable True
            mousewheel True
            scrollbars "vertical"

            for h in _history_list:

                window:
                    
                    xpadding 15
                    
                    text h.what:
                        color "#05b387"
                        font "fonts/Perfect DOS VGA 437.ttf"                    
                    
            if not _history_list:
                label _("The dialogue history is empty.")
            
        background "#0e0e0e"
        
    imagebutton:
        idle "images/gui/x - ground.png"
        hover "images/gui/x - hover.png"
        
        action Hide("history"), Return()
        
        xpos 305
        ypos 65

init -2 python:
    style.status_frame.background = "#223333"

## This determines what tags are allowed to be displayed on the history screen.

define gui.history_allow_tags = set()

style history_window is empty

style history_name is gui_label
style history_name_text is gui_label_text
style history_text is gui_text

style history_text is gui_text

style history_label is gui_label
style history_label_text is gui_label_text

style history_window:
    xfill True
    ysize 50

style history_name:
    xpos gui.history_name_xpos
    xanchor gui.history_name_xalign
    ypos gui.history_name_ypos
    xsize gui.history_name_width

style history_name_text:
    min_width gui.history_name_width
    text_align gui.history_name_xalign

style history_text:
    xpos 3
    ypos 11
    xanchor gui.history_text_xalign
    xsize gui.history_text_width
    min_width gui.history_text_width
    text_align gui.history_text_xalign
    layout ("subtitle" if gui.history_text_xalign else "tex")
        
style history_label:
    xfill True

style history_label_text:
    xalign 0.5
gui.rpy:

Code: Select all

## History #####################################################################
##
## The history screen displays dialogue that the player has already dismissed.

## The number of blocks of dialogue history Ren'Py will keep.
define config.history_length = 250

## The height of a history screen entry, or None to make the height variable at
## the cost of performance.
define gui.history_height = None

## The position, width, and alignment of the label giving the name of the
## speaking character.
define gui.history_name_xpos = 155
define gui.history_name_ypos = 0
define gui.history_name_width = 155
define gui.history_name_xalign = 1.0

## The position, width, and alignment of the dialogue text.
define gui.history_text_xpos = 170
#define gui.history_text_ypos = 2
define gui.history_text_width = 740
define gui.history_text_xalign = 0.0
Thanks for any help anyone can provide!

pfranzen
Regular
Posts: 42
Joined: Fri Apr 01, 2016 2:39 pm
Completed: Cat President 1+2, Internet Court, Too Many Santas, The Awkward Steve Duology, The Pizza Delivery Boy Who Saved the World, Francy Droo & Friends
Organization: Oh, a Rock! Studios
itch: oharock
Contact:

Re: Spacing between lines in history screen

#2 Post by pfranzen »

Update: I haven't figured it out yet. Is it possible it has to do with the way I'm adding lines to the history list?

The game doesn't have traditional Ren'py/VN dialogue (since it's all FMV footage, rather than static characters talking on a background), so I've been adding dialogue to the history list manually, using this code:

Code: Select all

$ narrator.add_history(kind="adv", who="Judge Doodles", what="Oh, are we starting?")
Could that be messing up the spacing somehow?

User avatar
komehara
Regular
Posts: 36
Joined: Fri Jan 31, 2020 10:08 pm
Projects: Spirit Link
Tumblr: hsandt
Deviantart: hsandt
Github: hsandt
itch: komehara
Contact:

Re: Spacing between lines in history screen

#3 Post by komehara »

Personally setting `gui.history_height = None` worked for me (I didn't use add_history though).

However, it places every history entry one after the other with 0 margin / vertical spacing, so not great for some uses.

I opened a ticket to suggest adding a config variable `gui.history_spacing` to customize this: https://github.com/renpy/renpy/issues/4766

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Spacing between lines in history screen

#4 Post by _ticlock_ »

pfranzen wrote: Tue Nov 13, 2018 5:50 pm Looking online it seems like setting "define gui.history_height" to "None" in gui.rpy should fix it(?), but I did that, and it didn't change anything.
The default history screen uses:

Code: Select all

use game_menu(_("History"), scroll=("vpgrid" if gui.history_height else "viewport"), yinitial=1.0):
It uses vpgrid if gui.history_height != None and or viewport if gui.history_height = None

In your code, you use vpgrid. A vpgrid assumes that all children are the same size.

1) you can increase height of each entry. Currently you set it to 50:

Code: Select all

 style history_window:
    xfill True
    ysize 50
2) you may use viewport and vbox instead to have variable height of each entry. In this case you may consider using yminimum to set the minimal height of the entry. Something like:

Code: Select all

    frame:
        xysize (650, 600)
        xalign .5
        yalign .5
        
        viewport:
            yinitial yinitial
            scrollbars "vertical"
            mousewheel True
            draggable True
            pagekeys True

            side_yfill True

            vbox:
                spacing 5
                for h in _history_list:
                    …

Code: Select all

 style history_window:
    xfill True
    yminimum 50

User avatar
komehara
Regular
Posts: 36
Joined: Fri Jan 31, 2020 10:08 pm
Projects: Spirit Link
Tumblr: hsandt
Deviantart: hsandt
Github: hsandt
itch: komehara
Contact:

Re: Spacing between lines in history screen

#5 Post by komehara »

My suggestion: add history entry vertical spacing gui.history_spacing to gui configuration variables (https://github.com/renpy/renpy/issues/4766) has been implemented for Renpy 8.2 / 7.7 Prerelease, so you will be able to configure gui.history_spacing (default 0) to define spacing *between* entries with those versions.

Post Reply

Who is online

Users browsing this forum: Google [Bot]