Separated History Screen

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
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:

Separated History Screen

#1 Post by BáiYù » Mon Feb 26, 2018 8:59 pm

ImageImage
This is a code snippet that will change the way that the History Screen is shown. Instead of being a part of the Game Menu, it will be a stand-alone screen that can be pulled up from the quickmenu while playing.

You may have to adjust some of the numbers to fit your needs. The project has a 1920x1080 resolution that can be either reduced or expanded. The screen should automatically re-scale itself accordingly.

Using CTRL + F, locate the vscrollbar style definition and replace that block with the following:

Code: Select all

style vscrollbar:
    xsize gui.scrollbar_size
    base_bar Frame("gui/scrollbar/vertical_[prefix_]bar.png", gui.vscrollbar_borders, tile=gui.scrollbar_tile)
    thumb Frame("gui/scrollbar/vertical_[prefix_]thumb.png", gui.vscrollbar_borders, tile=gui.scrollbar_tile)
    unscrollable "hide"
    ## Prevents Ren'Py from showing a scrollbar when there's nothing to scroll
Locate the History screen definition and replace that block with the following:

Code: Select all

screen history():

    tag menu

    predict False

    frame:

        style_prefix "history"

        label _("History")

        left_margin 200
        right_margin 200
        top_margin 50
        bottom_margin 50

        left_padding 50
        right_padding 100
        top_padding 150
        bottom_padding 100

        vpgrid:

            cols 1
            yinitial 1.0

            draggable True
            mousewheel True
            scrollbars "vertical"

            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:

                text "The dialogue history is empty." line_spacing 10
                ## Adding line_spacing prevents the bottom of the text
                ## from getting cut off. Adjust when replacing the
                ## default fonts.

        textbutton _("Return") action Return() yalign 1.1 xalign 1.0


## 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 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
    ypos -100
    size gui.label_text_size
If you'd like to download a sample project with the code implemented, please download it over at itch.io here.
Last edited by BáiYù on Tue Mar 06, 2018 10:57 am, edited 2 times in total.
ImageImageImage
Commissions Closed

User avatar
Andredron
Veteran
Posts: 336
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Separated History Screen

#2 Post by Andredron » Tue Feb 27, 2018 2:51 pm

Thank you for a great example!!!
I know, I'm writing terribly in English.

I'm writing a Renpy textbook (in Russian). https://yadi.sk/d/ZX_DonP63USRru Update 22.06.18

Translating to Russian language

Honest Critique

User avatar
rayminator
Veteran
Posts: 225
Joined: Fri Feb 09, 2018 12:05 am
Projects: Redoing games to fix spelling mistakes other companys that don't care
Location: Canada
Contact:

Re: Separated History Screen

#3 Post by rayminator » Fri Mar 02, 2018 10:19 pm

thanks for sharing

User avatar
wyverngem
Miko-Class Veteran
Posts: 594
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: Separated History Screen

#4 Post by wyverngem » Sat Mar 03, 2018 12:34 am

Should you keep or toss the defined styles from the screens menu for this?

User avatar
rayminator
Veteran
Posts: 225
Joined: Fri Feb 09, 2018 12:05 am
Projects: Redoing games to fix spelling mistakes other companys that don't care
Location: Canada
Contact:

Re: Separated History Screen

#5 Post by rayminator » Sat Mar 03, 2018 11:35 am

wyverngem wrote:
Sat Mar 03, 2018 12:34 am
Should you keep or toss the defined styles from the screens menu for this?
you should keep the defined style they will help to style the history page

like moving text and textname up or down and left to right

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: Separated History Screen

#6 Post by BáiYù » Sat Mar 03, 2018 6:31 pm

rayminator wrote:
Sat Mar 03, 2018 11:35 am
wyverngem wrote:
Sat Mar 03, 2018 12:34 am
Should you keep or toss the defined styles from the screens menu for this?
you should keep the defined style they will help to style the history page

like moving text and textname up or down and left to right
Yes, keep the default defined styles unless your personalized GUI customization calls for it.

Also, I am pushing a very minor update to the code that fixes a few things:
  • The scrollbar no longer appears when there aren't enough entries to scroll through
  • When there are no entries, the screen will say "The dialogue history is empty."
  • Added the Label back on the screen to indicate function
The first post has been updated accordingly. If you want to see a sample project where this is implemented, you can download that here at my itch.io page.

Thanks for checking it out!
ImageImageImage
Commissions Closed

HikariJake
Newbie
Posts: 6
Joined: Thu Mar 01, 2018 9:29 pm
Contact:

Re: Separated History Screen

#7 Post by HikariJake » Sun Mar 11, 2018 8:51 pm

This is amazing, thank you!

Now this may be too much to ask, but just in case you do know how to do this: would it be possible to activate the History screen by scrolling up with the mouse? Like most visual novels.

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: Separated History Screen

#8 Post by BáiYù » Wed Jul 04, 2018 12:02 pm

HikariJake wrote:
Sun Mar 11, 2018 8:51 pm
This is amazing, thank you!

Now this may be too much to ask, but just in case you do know how to do this: would it be possible to activate the History screen by scrolling up with the mouse? Like most visual novels.
Hi, I apologize for not answering your question earlier. It should be possible to do this by custom binding the keymap. However, the mouseup binding is already linked to the Rollback feature, so I did not add that to the default version of my history screen.
ImageImageImage
Commissions Closed

Post Reply

Who is online

Users browsing this forum: No registered users