showing side images only on 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.
Post Reply
Message
Author
Gazza
Newbie
Posts: 24
Joined: Wed Sep 19, 2018 5:18 pm
Contact:

showing side images only on the history screen

#1 Post by Gazza »

is there a way to implement a small portrait of the character near the dialogue in the history screen?

i think i have to mess with the history entry in some sort of way but i'm really not sure how

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: showing side images only on the history screen

#2 Post by namastaii »

There's probably a better solution for this but you could do this: (and probably include some sizing, spacing or whatever is needed)

Code: Select all

screen history():

    tag menu

    ## Avoid predicting this screen, as it can be very large.
    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:

            window:

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

                if h.who:
                    add "sideimage_[h.who].png"

                    label h.who:
                        style "history_name"
                        substitute False

                        ## 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:
                    substitute False


        if not _history_list:
            label _("The dialogue history is empty.")
The line I added in here is

Code: Select all

add "sideimage_[h.who].png"
You would store the images you want for each character as
sideimage_jessica.png
sideimage_robert.png

and that name would need to match the character's name and it should pull the right picture accordingly. To not have anything overlap, you could try putting this in an hbox?

Code: Select all

for h in _history_list:

            window:
                has hbox:
and probably take off the history style_prefix at the top and create your own to have everything fit the way you want. You could also take off the h.who name if you wanted just the image to show. Hope this wasn't confusing

Gazza
Newbie
Posts: 24
Joined: Wed Sep 19, 2018 5:18 pm
Contact:

Re: showing side images only on the history screen

#3 Post by Gazza »

for the code itself, it works very well, thank you so much <3

the only problem is that, if i don't define a side image for a character, the whole history screen crashes
how should i approach it so i can choose what characters has what images and preventing an error?

thank you again for the answer

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: showing side images only on the history screen

#4 Post by namastaii »

Probably an if statement and or a variable

The easiest solution is have a filler image for those without a picture. So have a tiny transparent box be their image or a transparent box the same size as the other images if you wanted all the elements to line up together in the history screen

Post Reply

Who is online

Users browsing this forum: henne, Ocelot, snotwurm