renpy / renpy

The Ren'Py Visual Novel Engine
http://www.renpy.org/
5.05k stars 705 forks source link

Side images modifying identifiers #5189

Open ParadoxalDeviant opened 10 months ago

ParadoxalDeviant commented 10 months ago

Hi o/

We recently wanted to add side images for a few of our characters in our game. No problem using side images but we realized that adding a side image to a character line changes the identifier of the line.

Here's the characters and their side images that I'll use for an example:

define afia = Character("Afia", image="afia_side" )
define toya = Character("Toya", image="toya_side")

layeredimage side afia_side:
    group exp auto:
        attribute none default null
        attribute happy
        attribute sad

layeredimage side toya_side:
    group exp auto:
        attribute none default null
        attribute smirk
        attribute sad

So here's what we previously had for the intro:

label intro:
    afia "Ahoy!"
    afia "Back on board as I see, hey?"
    toya "I know I have missed you Afia."        # Identifier will be something like intro_2949d4a4
    return

And here's what we have now:

label intro:
    afia "Ahoy!"
    afia "Back on board as I see, hey?"
    toya smirk "I know I have missed you Afia."        # Identifier will be something like intro_6be997f3
    return

In the project files, reading the dialogue.tab shows me that the same line has now a different identifier just by adding a side image to that line, so our voice file named intro_2949d4a4.ogg is not played anymore. The Character, Dialogue, Filename, Line Number are the same and only the Identifier and Ren'Py Script are different (changed from toya "[what]" to toya smirk "[what]").

So yeah, that's not a real problem when you have 1 file to rename, but we already have our game fully voiced and adding side images here and there is now a really painful thing to do due to the identifiers changing. And what if at some point one of the side image used does not please us anymore and we want to use another one, will the identifier change again?

renpytom commented 1 week ago

Considering this as an enhancement, but there may be an issue with existing games.

ParadoxalDeviant commented 1 week ago

Funny you replied at the same time I sink back into side images ^^

I've also noticed that animated side images are being cut off when passing from a say statement to another. Here's an example of my code for better understanding:

init python:

    ### Here's a bunch of code to declare all my images in my project etc.
    ### ...

    def animate_image(image_prefix, frames=60, fps=30):
        animation_list=[]
        for i in range(frames):
            animation_list.append(f"{image_prefix}_{i}")
            animation_list.append(1.0/fps)
        return Animation(*animation_list)

layeredimage eileen:
    always "eileen_body"
    group exp:
        attribute smile default
        attribute happy
        attribute surprised

layeredimage side _eileen:    # `_eileen` to prevent `unknown attribute` from previous layered and vice versa
    group exp:
        attribute pat:
            animate_image("side_eileen_pat")    # loop on `side_eileen_pat_0`, `side_eileen_pat_1`, `side_eileen_pat_2`, etc.

define e = Character("Eileen", image="_eileen")

label start:
    show eileen
    e "Hello World!"
    show eileen happy    # can't do `e happy` on next line cause linked character image is `_eileen` and not `eileen` (intended behavior)
    e "I'm happy to be here!"
    show eileen surprised    # same as previously
    e pat "Oh..."
    e "It's so nice to be pat!"    # `pat` will restart its animation from the start
    return

This issue also happen on monologue mode:

label start:
    show eileen surprised
    e pat """
    Oh...

    It's so nice to be pat!
    """
    return

Showing the side image with a show before the sentences does not reset the animation though:

label start:
    show eileen surprised
    show side _eileen pat at side_image_pos    # fictive transform to have side images at the right place
    e "Oh..."
    e "It's so nice to be pat!"    # `pat` animation does not restart
    return

I don't really know if this is the way I do thing that is wrong or if at some point arguments are cleared or just not kept properly from a say statement to another...