Trying to customize the 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.
Message
Author
Maou Zenigame
Newbie
Posts: 23
Joined: Thu Nov 09, 2017 3:09 am
Contact:

Trying to customize the History screen

#1 Post by Maou Zenigame » Fri Dec 08, 2017 6:57 am

I'd managed to code the rest of this thing without having to ask for help, but this where I've finally broken down.

For the past two days, I've been trying and failing to customize the history screen. It's intended to be a transparent overlay over the current scene, with the text shown in the center area of the screen and scrollable with a bar like so:
pg_history.png
But every time I actually try to mess around with the existing History screen, it messes up in some way or another. I've gotten fairly close a couple of times, but then the text vanishes when I try to put the sliders in or some random bug shows up and I just give up.

The barebones of my latest retry:

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
        
    add "gui/History/pg_history.png"

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

    vpgrid:
        style_prefix "history"

        cols 1
        yinitial 1.0

        mousewheel True
        draggable True

        side_ysize 552
        side_xsize 940
        side_xpos 300
        side_ypos 120

        for h in _history_list:

            window:
                

                ## This lays things out properly if history_height is None.
                has fixed:
                    yfit True

                if h.who:

                    label h.who:
                        style "history_name"

                        ## Take the color of the who text from the Character, if
                        ## set.
                        if "color" in h.who_args:
                            text_color h.who_args["color"]

                text h.what

        if not _history_list:
            label _("The dialogue history is empty.")


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 gui.history_height

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 gui.history_text_xpos
    ypos gui.history_text_ypos
    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
which shows up like this:
currenthistory.png
...which has magically stopped bunching up at the top of the screen for some reason despite my not having touched the code in a couple of days. Fun.

Any help would be immensely appreciated.

User avatar
Scribbles
Miko-Class Veteran
Posts: 620
Joined: Wed Sep 21, 2016 4:15 pm
Completed: Pinewood Island
Projects: As We Know It, In Blood
Organization: Jaime Scribbles Games
Deviantart: breakfastdoodles
itch: scribbles
Location: Ohio
Contact:

Re: Trying to customize the History screen

#2 Post by Scribbles » Fri Dec 08, 2017 9:30 am

this might be messing with your code a bit:

Code: Select all

style history_text:
    xpos gui.history_text_xpos
    ypos gui.history_text_ypos
    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")
have you adjusted anything in the gui.rpy ? There are options under the History area, and you can make some changes there or adjust the styles? That could possibly help. I can only manage screen language through a lot of trial and error so I don't have a specific solution for you :-/
Image - Image -Image

Maou Zenigame
Newbie
Posts: 23
Joined: Thu Nov 09, 2017 3:09 am
Contact:

Re: Trying to customize the History screen

#3 Post by Maou Zenigame » Mon Dec 11, 2017 5:28 am

Yeah, trial and error is pretty much the only thing I can do when it comes to the History screen since there aren't any real tutorials for how to mess around with it.

Presently, the gui.rpy settings are as follows:

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 = 170

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

## The position, width, and alignment of the dialogue text.
define gui.history_text_xpos = 300
define gui.history_text_ypos = 30
define gui.history_text_width = 700
define gui.history_text_xalign = 0.0

which results in the History screen looking like this:
presenthistory.png
This is the proper width for how I wanted it, but I have no idea how to keep the text from covering the screen vertically.
Nor can I figure out how to code in the sliders to scroll with.

User avatar
Scribbles
Miko-Class Veteran
Posts: 620
Joined: Wed Sep 21, 2016 4:15 pm
Completed: Pinewood Island
Projects: As We Know It, In Blood
Organization: Jaime Scribbles Games
Deviantart: breakfastdoodles
itch: scribbles
Location: Ohio
Contact:

Re: Trying to customize the History screen

#4 Post by Scribbles » Mon Dec 11, 2017 9:11 am

This should bring back the scroll bar, and allow you to control the adjust the height of the history text... I think

Code: Select all

use scroll=("vpgrid" if gui.history_height else "viewport")):

Code: Select all

define gui.history_height = 170
Image - Image -Image

Maou Zenigame
Newbie
Posts: 23
Joined: Thu Nov 09, 2017 3:09 am
Contact:

Re: Trying to customize the History screen

#5 Post by Maou Zenigame » Mon Dec 11, 2017 7:06 pm

Scribbles wrote:
Mon Dec 11, 2017 9:11 am
This should bring back the scroll bar, and allow you to control the adjust the height of the history text... I think

Code: Select all

use scroll=("vpgrid" if gui.history_height else "viewport")):
Where exactly in the code would this go?

Code: Select all

define gui.history_height = 170
This adjusts the length of the displayed area of text, not where it appears on the screen itself.

Maou Zenigame
Newbie
Posts: 23
Joined: Thu Nov 09, 2017 3:09 am
Contact:

Re: Trying to customize the History screen

#6 Post by Maou Zenigame » Mon Dec 18, 2017 3:20 am

Bumping for help.

Maou Zenigame
Newbie
Posts: 23
Joined: Thu Nov 09, 2017 3:09 am
Contact:

Re: Trying to customize the History screen

#7 Post by Maou Zenigame » Mon Dec 25, 2017 3:21 am

Christmas bump of desperation.

User avatar
Treladon
Regular
Posts: 40
Joined: Sat Dec 31, 2016 3:20 pm
Projects: ToMaG, Feinted Game
Organization: Kuehler-Corrada Productions
Deviantart: Journie
Contact:

Re: Trying to customize the History screen

#8 Post by Treladon » Wed Feb 14, 2018 12:10 am

Maou Zenigame wrote:
Fri Dec 08, 2017 6:57 am
I'd managed to code the rest of this thing without having to ask for help, but this where I've finally broken down.
Hi Maou Zenigame. Considering the scrolling problem and the text moving over your lettering, I've had some luck putting the vpgrid in a frame and using the "scrollbars" keyword. See below:

Code: Select all

screen history():
    tag menu

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

    style_prefix "history"
    frame:
        xysize (600, 800) #Change to suit your background image
        xalign .5
        yalign .5
        
        vpgrid:
            cols 1
            spacing 5
            draggable True
            mousewheel True
            scrollbars "vertical"
            xalign .5
            for h in _history_list:

                window:

                    ## This lays things out properly if history_height is None.
                    has fixed:
                        yfit True

                    if h.who:

                        label h.who:
                            style "history_name"

                            ## Take the color of the who text from the Character, if
                            ## set.
                            if "color" in h.who_args:
                                text_color h.who_args["color"]

                    text h.what

            if not _history_list:
                label _("The dialogue history is empty.")
Does this help at all?
WIP: The Tasks of Messengers and Guardians - Progress Page Here!

Maou Zenigame
Newbie
Posts: 23
Joined: Thu Nov 09, 2017 3:09 am
Contact:

Re: Trying to customize the History screen

#9 Post by Maou Zenigame » Thu Feb 15, 2018 6:05 pm

Unfortunately, it doesn't.

Copypasting your code as-is and then adjusting the xysize to fit the window just results in this:
historyscreen.png
As you can see, text doesn't show up at all now.


EDIT:

Messing around with the code, the text disappearing seems to be directly caused by the

Code: Select all

scrollbars "vertical"
part.

When I disable it, the screen goes back to the same deal as before where the text shows up but goes all the way up and down the screen:
otherhistory.png

philat
Eileen-Class Veteran
Posts: 1635
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Trying to customize the History screen

#10 Post by philat » Thu Feb 15, 2018 10:05 pm

Just ditch all the premade styles if they're hanging you up. (For example, are you using history_height? Do you know what that does? If not, why do you need the fixed?)

All you need is a viewport with a vbox in it, then iterate over history_list.

Some examples: https://www.renpy.org/doc/html/screens.html#viewport
viewtopic.php?f=8&t=27128

Maou Zenigame
Newbie
Posts: 23
Joined: Thu Nov 09, 2017 3:09 am
Contact:

Re: Trying to customize the History screen

#11 Post by Maou Zenigame » Fri Feb 16, 2018 1:06 am

I'm actually completely lost as to how I'd go about starting that. ._.

philat
Eileen-Class Veteran
Posts: 1635
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Trying to customize the History screen

#12 Post by philat » Sun Feb 18, 2018 9:10 pm

Code: Select all

screen history_new():
    tag menu
    predict False

    side "c r":
        area (100, 100, 600, 400)

        viewport id "vp":
            draggable True
            mousewheel True
            
            vbox:
                for h in _history_list:
                    if h.who:
                        label h.who:
                            style "history_name"
                            ## Take the color of the who text from the Character, if
                            ## set.
                            if "color" in h.who_args:
                                text_color h.who_args["color"]
                    text h.what

                if not _history_list:
                    label _("The dialogue history is empty.")

        vbar value YScrollValue("vp")
This has no styles whatsoever (other than defaults, obviously). It's very simple -- the history items are all simply items in a vbox. The viewport area is defined by the area statement.

Maou Zenigame
Newbie
Posts: 23
Joined: Thu Nov 09, 2017 3:09 am
Contact:

Re: Trying to customize the History screen

#13 Post by Maou Zenigame » Mon Feb 19, 2018 4:50 am

Alright, I just tried the code you posted as-is and it's giving me another blank screen.

User avatar
BáiYù
Regular
Posts: 116
Joined: Fri Apr 01, 2016 10:02 am
Completed: Voeux, Plain, 8=D~<3
Projects: Love Lime!, Talk To Me
Organization: tofurocks, Dream Team, Boop Studios
itch: tofurocks
Contact:

Re: Trying to customize the History screen

#14 Post by BáiYù » Mon Feb 19, 2018 6:22 pm

Hey, I've managed to make it so that the text history will not go past the window and onto the top and bottom of the screen. The trick is to add yalign 0.5 and ymaximum within the vpgrid block.

Here's what my code looks like. Nothing in gui.rpy had to be altered for the most part.

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
        
    add "gui/history_frame.png" xalign 0.5 yalign 0.5 #your image here

    predict False

    vpgrid:

        style_prefix "history"

        cols 1
        yinitial 1.0

        mousewheel True
        draggable True

        yalign 0.5 #to ensure that the history log is in the middle of the screen
        ymaximum 800 #change the number to adjust to the size of your window


        for h in _history_list:

            window:
		
		#change these numbers accordingly
                left_padding 285
                right_padding 200
                top_padding 100
                bottom_padding 100

                ## This lays things out properly if history_height is None.
                has fixed:
                    yfit True

                if h.who:

                    label h.who:
                        style "history_name"

                        ## Take the color of the who text from the Character, if
                        ## set.
                        if "color" in h.who_args:
                            text_color h.who_args["color"]

                text h.what

        if not _history_list:
            label _("The dialogue history is empty.")

    textbutton _("Return") action Return() yalign 0.9 xalign 0.13

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 gui.history_height

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 gui.history_text_xpos
    ypos gui.history_text_ypos
    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")
    justify True

style history_label:
    xfill True

style history_label_text:
    xalign 0.5
You get something like this.
screenshot0004.png
Unfortunately the scrollbar is still missing, but you can still drag and scroll with your mouse.
ImageImageImage
Commissions Closed

Maou Zenigame
Newbie
Posts: 23
Joined: Thu Nov 09, 2017 3:09 am
Contact:

Re: Trying to customize the History screen

#15 Post by Maou Zenigame » Mon Feb 19, 2018 10:21 pm

Just tried your code (with some adjustments) and it did work somewhat, but it also repeats one of the dead ends that I'd previously encountered where the final line of text is cut off by the boundary of the displayable area.

I tried messing around with the viewport code that philat posted some more though:

Code: Select all

screen history():
    tag menu
    add "gui/History/pg_history.png"
    predict False

    side "c r":
        area (100, 100, 600, 400)
        
        viewport id "vp":
            draggable True
            mousewheel True
            arrowkeys True
            yinitial 1.0
            area (230, 80, 1000, 470)
            
            vbox:
                for h in _history_list:
                    if h.who:
                        label h.who:
                            style "history_name"
                            ## Take the color of the who text from the Character, if
                            ## set.
                            if "color" in h.who_args:
                                text_color h.who_args["color"]
                    text h.what

                if not _history_list:
                    label _("The dialogue history is empty.")

        vbar value YScrollValue("vp")
This finally got something to show up, but now there's another problem to try to get past.
whatnow.png
As you can see, the character name position is off, the text itself is only listing one word per line and there still aren't any scrollbars.

Post Reply

Who is online

Users browsing this forum: senisanti