Page 1 of 1

Separated History Screen

Posted: Mon Feb 26, 2018 8:59 pm
by BáiYù
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.

Re: Separated History Screen

Posted: Tue Feb 27, 2018 2:51 pm
by Andredron
Thank you for a great example!!!

Re: Separated History Screen

Posted: Fri Mar 02, 2018 10:19 pm
by rayminator
thanks for sharing

Re: Separated History Screen

Posted: Sat Mar 03, 2018 12:34 am
by wyverngem
Should you keep or toss the defined styles from the screens menu for this?

Re: Separated History Screen

Posted: Sat Mar 03, 2018 11:35 am
by rayminator
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

Re: Separated History Screen

Posted: Sat Mar 03, 2018 6:31 pm
by BáiYù
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!

Re: Separated History Screen

Posted: Sun Mar 11, 2018 8:51 pm
by HikariJake
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.

Re: Separated History Screen

Posted: Wed Jul 04, 2018 12:02 pm
by BáiYù
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.