Page 1 of 1

"Speech bubbles" with left and right variation? [SOLVED]

Posted: Tue Sep 04, 2018 6:17 am
by TAEKO
What I am trying to is this:
When Character A is speaking and is on the left portion of the screen, the speech bubble faces said character. But when Character B arrives, his namebox appears without Character A's namebox disappearing and the speech bubble turns to face him instead along with the changing of the corresponding image of the speech bubble.
Image
Image

I was wondering if there is a way how to let the other namebox stay while the other character is speaking?

Here's what I've done so far, I defined two characters, one for the left and one for the right, both using the same image.

Code: Select all

define yuki = Character("Mochizuki, Yuki", callback=speaker("Mochizuki, Yuki"), who_color="#1E3D54", image="yuki", namebox_background = "gui/box/namebox.png", window_background="gui/box/blue_L.png")

define yuki_flip = Character("Mochizuki, Yuki", callback=speaker("Mochizuki, Yuki"), who_color="#1E3D54", image="yuki flip", namebox_background = "gui/box/namebox.png", window_background="gui/box/blue_R.png")

Code: Select all

image yuki flip shy= im.Flip("images/sprites/yuki/yuki_shy.png", horizontal=True, xalign=1.0)
image yuki shy= Image("images/sprites/yuki/yuki_shy.png", horizontal=True, xalign=0.0)
Here are the styles of the left and right nameboxes

Code: Select all

style namebox: #left
    xpos 10
    xalign 0.0
    xsize gui.namebox_width
    ypos gui.name_ypos
    ysize gui.namebox_height
    padding gui.namebox_borders.padding

style namebox2: #right
    xpos 964
    xsize gui.namebox_width
    ypos gui.name_ypos
    ysize gui.namebox_height
    padding gui.namebox_borders.padding
And finally the namebox transition...
This is where I had problems aside from retaining the appearances of the two nameboxes.
Is there a way to assign a value to whenever the flipped character is called?

Code: Select all

screen say(who, what):
    style_prefix "say"

    window:
        id "window"
        if who is not None:
            window:
                if flipped == True: #Is it possible to assign a value like this whenever the flipped speaker shows up?
                    if nameboxtrans == "In_trans":
                        at name_ease
                    else:
                        pass
                    id "namebox"
                    style "namebox"
                    text who id "who"
                else:
                    if nameboxtrans == "In_trans":
                        at name_ease_flipped
                    else:
                        pass
                    id "namebox"
                    style "namebox2"
                    text who id "who"

Re: "Speech bubbles" with left and right variation?

Posted: Tue Sep 04, 2018 6:30 am
by Andredron

Re: "Speech bubbles" with left and right variation?

Posted: Tue Sep 04, 2018 2:45 pm
by Donmai

Re: "Speech bubbles" with left and right variation?

Posted: Tue Sep 04, 2018 4:07 pm
by TAEKO
Donmai wrote:
Tue Sep 04, 2018 2:45 pm
You can also look here:
https://www.patreon.com/posts/automatic-speech-17867321
Hi! Thanks for both of your answers. I find both of those links really helpful, but right now my main problem is how to show the second namebox without the first one disappearing. I've just fixed the transitions and the automatic facing of the chat bubbles a while after I originally posted this, (which I may or may not have written in the noobiest way possible btw, but hey at least it works), and pretty much that is my only problem...

I tried doing the first method, but I just can't seem to tie it with the custom nameboxes I've prepared. It's like a fixed dialogue box, but at the moment I'm still going to work on it until I figure it out (but if I don't, I think what it can do now is pretty much cool anyway so it might be already fine without the extra feature), anyway thanks again for trying to help!

Should I put a [Solved] in the title now or...? Well since it's not really fully 'solved' I guess Partially Solved would be more appropriate huh

Re: "Speech bubbles" with left and right variation?

Posted: Tue Sep 04, 2018 4:31 pm
by MaydohMaydoh
You could try this, whether it works or not or if it's the right way to do it or whatever, I don't know.
Using two variables, one for left and one for right

Code: Select all

default left_speaker = ""
default right_speaker = ""
Put the name of each person into their respective variables

Code: Select all

label start:
    $ left_speaker = "Some dude"
    $ right_speaker = "A cat"
    left_speaker "Hey look, it's a cat."
    right_speaker "Meow"
Then in the say screen, just check if the variable is empty or not and show the appropriate namebox.

Code: Select all

screen say(who, what):
    if left_speaker: ## if right_speaker is not empty string, show namebox left
        window id 'namebox':
            style 'namebox'
            text "[left_speaker]"
    
    if right_speaker: ## if right_speaker is not empty string, show namebox right
        window id 'namebox':
            style 'namebox2'
            text "[right_speaker]"
           
    ## plus whatever else you want
Then when you want to hide the namebox, just give the variable an empty string or False or None or whatever or give it a new name to show something different.

Code: Select all

$ left_speaker = ""
$ right_speaker = "A dog"
right_speaker "I was a dog all along."

Re: "Speech bubbles" with left and right variation?

Posted: Wed Sep 05, 2018 8:13 am
by TAEKO
MaydohMaydoh wrote:
Tue Sep 04, 2018 4:31 pm
You could try this, whether it works or not or if it's the right way to do it or whatever, I don't know.
Using two variables, one for left and one for right

Code: Select all

default left_speaker = ""
default right_speaker = ""
Put the name of each person into their respective variables

Code: Select all

label start:
    $ left_speaker = "Some dude"
    $ right_speaker = "A cat"
    left_speaker "Hey look, it's a cat."
    right_speaker "Meow"
Then in the say screen, just check if the variable is empty or not and show the appropriate namebox.

Code: Select all

screen say(who, what):
    if left_speaker: ## if right_speaker is not empty string, show namebox left
        window id 'namebox':
            style 'namebox'
            text "[left_speaker]"
    
    if right_speaker: ## if right_speaker is not empty string, show namebox right
        window id 'namebox':
            style 'namebox2'
            text "[right_speaker]"
           
    ## plus whatever else you want
Then when you want to hide the namebox, just give the variable an empty string or False or None or whatever or give it a new name to show something different.

Code: Select all

$ left_speaker = ""
$ right_speaker = "A dog"
right_speaker "I was a dog all along."
Hey I tried your way and it works btw! But a new problem arised for me...
The two nameboxes now appear, but the second one is copied to the first one as if the same person is on both sides.
Also, when I implemented this, the styles I made especially for the textboxes' text seems to not be read...?
Here is a video of the effect:
[youtube]https://youtu.be/dIsELc2k0Iw[/youtube]

Any idea how to fix this?
I'd appreciate it if anyone could tell me what I did wrong

Here's what I did:
if who is not None:

Code: Select all

            if left_speaker is not None:
                window:
                    if nameboxtrans == "In_trans":
                        at name_ease
                    else:
                        pass
                    id "namebox"
                    text who id left_speaker
                    style "namebox"

            if right_speaker is not None:
                window:
                    if nameboxtrans == "In_trans":
                        at name_ease_flipped
                    else:
                        pass
                    id "namebox"
                    text who id right_speaker
                    style "namebox2"

Code: Select all

label start:
    show yuki L shy
    $ left_speaker = yuki
    yuki "... boop?"
    show momo R neutral
    $ right_speaker = momo
    momo "Boop bap?"

Code: Select all

    def yuki(what, **kwargs):
        global right_speaker, left_speaker

        if left_speaker is yuki:
            yuki_L(what, **kwargs)
        elif right_speaker is yuki:
            yuki_R(what,**kwargs)
EDIT:
Decided to work with just only one namebox in the end. I mean it looks pretty much okay at this point anyway
Marked question as solved, thanks everyone!