Page 1 of 1

little-used history chips

Posted: Sat Jul 30, 2022 4:53 pm
by Andredron
Image
1)Add a play sound button

Code: Select all

screen history():

    tag menu

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

    use game_menu(_("History"), scroll=("vpgrid" if gui.history_height else "viewport"), yinitial=1.0):

        style_prefix "history"

        for h in _history_list:

            windows:

                ## This will properly equalize if history_height is
                ## is set to None.
                has fixed:
                    yfit True

                if h.who:
############################################################################
                    if h.voice and h.voice.filename:                                          ###Here, of course, it is better to put a graphic button, less hassle with setting its location
                        textbutton "Play" action Play("voice", h.voice.filename)
############################################################################
                    label h.who:
                        style "history_name"
                        substitute False

                        ## Gets the color from the character's who parameter, if it
                        ## installed.
                        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:
                    substitute False

        if not _history_list:
            label _("History of dialogs is empty.")
2)Roll back to this text

Code: Select all

screenhistory():

    tag menu

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

    use game_menu(_("History"), scroll=("vpgrid" if gui.history_height else "viewport"), yinitial=1.0):

        style_prefix "history"

        for h in _history_list:

            windows:

                ## This will properly equalize if history_height is
                ## is set to None.
                has fixed:
                    yfit True

                if h.who:

                    if h.voice and h.voice.filename:
                        textbutton "Play" action Play("voice", h.voice.filename)
#############################################################################################
                       textbutton "ROLL BACK" action Confirm("Jump?", yes=RollbackToIdentifier(h.rollback_identifier), no=None, confirm_selected=False) ​​xpos 0 ypos 30           ##########After pressing the button, you will roll back
############################################################################################
                    label h.who:
                        style "history_name"
                        substitute False

                        ## Gets the color from the character's who parameter, if it
                        ## installed.
                        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:
                    substitute False

        if not _history_list:
            label _("History of dialogs is empty.")
And in the gui file, you will have to change the size of the saved points, and the size of the control points

Code: Select all

define config.hard_rollback_limit = 100
define config.rollback_length = 100

3) How to change the text on the history screen

Code: Select all

label start:
	"Hi! I couldn't wait to see you again!"
	$ _history_list[-1].what = "I hate you. Wish you were dead."
	"If you check history now, you will notice that the last entry changed"


4) Add head

Code: Select all

screenhistory():

    tag menu

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

    use game_menu(_("History"), scroll=("vpgrid" if gui.history_height else "viewport"), yinitial=1.0):

        style_prefix "history"

        for h in _history_list:

            windows:

                ## This will properly equalize if history_height is
                ## is set to None.
                has fixed:
                    yfit True
#####################################################################
                    if h.who:
                        hbox:
                            if h.image_tag:
                                add "history" + h.image_tag
                            else:
                                null width 100
######################################################################

                    if h.voice and h.voice.filename:
                        textbutton "Play" action Play("voice", h.voice.filename)

                    textbutton "ROLL BACK" action RollbackToIdentifier(h.rollback_identifier) ​​xpos 0 ypos 30

                    label h.who:
                        style "history_name"
                        substitute False

                        ## Gets the color from the character's who parameter, if it
                        ## installed.
                        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:
                    substitute False

        if not _history_list:
            label _("History of dialogs is empty.")
script.rpy

Code: Select all

define character.yesod = Character("Yesod", image="yesod")
image yesod smiling = "_YesodSmiling.png"
image history yesod = "yesod-6.png"

label start:
    show yesod smiling
    yesod "Hello"
    yesod ". . ."
    ". . ."
    yesod "Test"
    return
another option viewtopic.php?p=517246#p517246

5) change text color

Code: Select all

$ what = renpy.filter_text_tags(h.what, allow=gui.history_allow_tags)
                 text what:
                     color "#FFD700" ###################color
                     substitute False

         if not _history_list:
             label _("History of dialogs is empty.")
6) Adding choices selected to History without showing to user
viewtopic.php?t=40329

https://old.reddit.com/r/RenPy/comments ... ?context=3

7) Having unselected choices in History?
viewtopic.php?p=548775#p548775

8) disable history

Code: Select all


     $ store._history = True ### history on
     
     voice "voice/003.ogg"
     nez "{w=0.5}How are you feeling?{w=1.0}{nw}"

     $ store._history = False ### # history off
     show mor02
     nez "How do you feel?{fast}"
     
9) Replace rollback with History
viewtopic.php?p=545688#p545688

10) Scrollbar thumb has a white border
viewtopic.php?p=534763#p534763

11) add images to history log [works with layeredimages]
viewtopic.php?p=534271#p534271

12) How to register a mouse call with a wheel

Code: Select all

screen my_keys:
    key "mousedown_5" action ShowMenu("history")
    key 'K_ESCAPE' action ShowMenu('preferences')
    key 'mouseup_3' action ShowMenu('save')
    
label start:
    show screen my_keys
    "text"
13)Implementation of a history scrollbar scrolling to the end to close

Code: Select all

init python:
    class MyAdjustment(renpy.display.behavior.Adjustment):
        def change(self, value):
            if value > self._range and self._value == self._range:
                # *Return to the game screen*
                return Return()
            else:
                # Otherwise, just do what the Adjustment normally does
                return renpy.display.behavior.Adjustment.change(self, value)
screen game_menu add

Code: Select all

default adj = MyAdjustment(range = 100,changed =None,adjustable=True)
viewport

Code: Select all

yadjustment adj
14)Start from latest dialogue

viewtopic.php?f=8&t=50647

15)Changing dialogue history in rollback


viewtopic.php?p=542946#p542946

You may be interested in the following materials:

Re: little-used history chips

Posted: Sun Aug 21, 2022 1:34 pm
by Johan
Oh my god, thank you so much!!
I had used other code for some of these but yours are way simpler, so I'm using it!! Thanks!! ^^

Re: little-used history chips

Posted: Fri Sep 16, 2022 12:14 am
by Tess
This is insanely cool! Thanks so much for writing it up.

Re: little-used history chips

Posted: Wed Feb 21, 2024 10:50 am
by Li yuanlin
13)Implementation of a history scrollbar scrolling to the end to close
This one has no effect in my new project,I don't kown why

Re: little-used history chips

Posted: Thu Feb 22, 2024 11:22 am
by Andredron
Li yuanlin wrote: Wed Feb 21, 2024 10:50 am 13)Implementation of a history scrollbar scrolling to the end to close
This one has no effect in my new project,I don't kown why
Try this, I tried to update the code from my phone, so it's not a sure working method.

Code: Select all


init python:
import renpy.display.behavior.Adjustment

class MyAdjustment(renpy.display.behavior.Adjustment):
    def change(self, value):
        if value > self._range and self._value == self._range:
            # *Return to the game screen*
            return Return()
        else:
            # Otherwise, just do what the Adjustment normally does
            return renpy.display.behavior.Adjustment.change(self, value)

def my_change_function(value):
    if value > self._range and self._value == self._range:
        # 
        renpy.scene("game_menu")

###screen game_menu add
default adj = MyAdjustment(range = 100, changed = my_change_function, adjustable=True)

###viewport
    adj