How do I change the history screen [not using game_menu]

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
Skaiya
Regular
Posts: 95
Joined: Tue Sep 25, 2012 5:42 pm
Projects: My Lovely Pastry, Crystal Diamonds Shatter, IWSTBMTB
Tumblr: skaiya-art
Deviantart: skaiyaart
Location: The Netherlands
Contact:

How do I change the history screen [not using game_menu]

#1 Post by Skaiya »

Alright, I am probably awful at looking up forum posts because I couldn't find anything and I searched for hours.

This is what I want:
(Except the height of Return, that is fine already in the second screenshot)
Image

So you see everything on the bg.
The history screen is in front.
There's a custom scrollbar on the side.
(I searched but couldn't find it for the new coding, I do not want to change the existing images, I want this screen to have its own one
The text is nicely underneath each other.

If you change the screen it uses game_menu but I want to have different settings for different screens so using game_menu is not doable.
I tried to add the viewport and the vpgrid to the history screen itself.
Image

Here's my code:

Code: Select all

screen history(scroll=("vpgrid" if gui.history_height else "viewport"), yinitial=0.0):

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

    style_prefix "history"
    frame:
        style "history_outer_frame"

        hbox:

            frame:
                style "history_content_frame"

                if scroll == "viewport":

                    viewport:
                        yinitial yinitial
                        scrollbars "vertical"
                        mousewheel True
                        draggable True

                        side_yfill True

                        vbox:
                            transclude
                            
                elif scroll == "vpgrid":

                    vpgrid:
                        cols 1
                        yinitial yinitial

                        scrollbars "vertical"
                        mousewheel True
                        draggable True

                        side_yfill True

                        transclude

                else:

                    transclude
        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"]

                $ what = renpy.filter_text_tags(h.what, allow=gui.history_allow_tags)
                text what

        if not _history_list:
            label _("The dialogue history is empty.")
    textbutton _("Return"):
        xalign 0.5
        yalign 0.9
        action Return()

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

define gui.history_allow_tags = set()

style history_outer_frame is empty
style history_content_frame is empty
style history_side is gui_side
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_scrollbar is gui_vscrollbar
style history_label is gui_label
style history_label_text is gui_label_text

style history_outer_frame:
    xanchor gui.history_outer_frame_xalign
    background "gui/overlay/history_bg.png"
    
style history_content_frame:
    left_margin 40
    right_margin 20
    top_margin 0

style history_viewport:
    xsize 500

style history_vscrollbar:
    unscrollable gui.unscrollable
    
style history_side:
    spacing 540
    
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

Code: Select all

define config.history_length = 10

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

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

## The position, width, and alignment of the dialogue text.
define gui.history_text_xpos = 100
define gui.history_text_ypos = 2
define gui.history_text_width = 450
define gui.history_text_xalign = 0.0
So yea I am sorry for two questions.
Also sorry for the awful coding.
I messed around with it for hours, it probably looks messed up.

Thank you in advance and again I am so sorry.

EDIT: I.. scrolled up and suddenly saw where the scrollbars are getting their .png.
Second EDIT: Nvm, I can't get it to work.
My dA
My Tumblr
Currently working on:
My Lovely Pastry, Crystal Diamonds Shatter, IWSTBMTB.

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: How do I change the history screen [not using game_menu]

#2 Post by Treladon »

Skaiya wrote: Wed Feb 07, 2018 7:50 pm Alright, I am probably awful at looking up forum posts because I couldn't find anything and I searched for hours.
Hi Skaiya. I'm not sure exactly what you want, but I was able to fix the spacing problem you had in your screenshot using the code 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)
        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.")
The only problem with mine is that the text is too big for my window and doesn't fit exactly, and I'm also lacking a Return button, but that doesn't seem to be a problem in your screenshot. Does this help?
WIP: The Tasks of Messengers and Guardians - Progress Page Here!

User avatar
Skaiya
Regular
Posts: 95
Joined: Tue Sep 25, 2012 5:42 pm
Projects: My Lovely Pastry, Crystal Diamonds Shatter, IWSTBMTB
Tumblr: skaiya-art
Deviantart: skaiyaart
Location: The Netherlands
Contact:

Re: How do I change the history screen [not using game_menu]

#3 Post by Skaiya »

@Treladon no, sorry, it doesn't fix things for me.
But thank you for your reply!

I changed my code to this:

Code: Select all

screen history():
    tag menu
    zorder 100
    ## Avoid predicting this screen, as it can be very large.
    predict False

    style_prefix "history"
    
    frame:
        xysize (600, 780)
        xalign .5
        yalign .0
        vpgrid:
            cols 1
            spacing 1
            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.")
    textbutton _("Return"):
        xalign 0.5
        yalign 0.9
        action Return()
But the xysize in the frame messes things up.
If I put # in front of it to rule it out the text shows up entirely on the left taking the 1280x780 screen.
It cuts off the first letter of the names but shows the dialogue.
Now if I make it 600x780 it shows the name partially but deletes the dialogue.
Image
I got the custom scrollbar to show up!
It doesn't work how I want it to work tho but it shows up.

Code: Select all

style history_vscrollbar is gui_historyscrollbar
Excuse me I forgot you also can change things in gui.rpy

Code: Select all

define gui.history_name_xpos = 90
Made the names show their first letter again, lol.

Code: Select all

define gui.history_height = 70
Made them come close together again.
Image
Now my scrollbar is messed up again.
My dA
My Tumblr
Currently working on:
My Lovely Pastry, Crystal Diamonds Shatter, IWSTBMTB.

User avatar
andehP
Newbie
Posts: 2
Joined: Thu Jun 14, 2018 6:56 am
Projects: After Class
itch: andehP
Contact:

Re: How do I change the history screen [not using game_menu]

#4 Post by andehP »

I'm not sure if it's okay to reply to a 4 months old topic, but have you found the way to do it properly?
I was trying to do that too. It worked for me but it kinda messed with a dialogue with 4 lines, I think it has to do with the style (I don't know, I have minimal to none coding knowledge.) Since I couldn't figure it out, here's what I did temporarily:

I copied the game_menu screen and pasted it somewhere (I have it on my custom menu script) then I changed the name screen name to game_menu2. Make sure you change any style/style_prefix from game menu to game_menu2

Because you don't want the navigation panel on the left, you have to remove this line from the game_menu2 screen:

Code: Select all

use navigation

Then you can change everything using the style properties down there. For example, you can move the return button by changing the return_button style.

Code: Select all

style return_button:
    xpos gui.navigation_xpos
    yalign 1.0
    yoffset -45
I know this is not the best solution but at least it works for me. :oops:

I hope it helps.
Image

Post Reply

Who is online

Users browsing this forum: Google [Bot]