(How) Is it possible to display multipler_say_window with SideImage?

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.
Message
Author
Deschain
Newbie
Posts: 19
Joined: Thu Sep 28, 2023 9:03 am
Discord: deschain1975
Contact:

Re: (How) Is it possible to display multipler_say_window with SideImage?

#16 Post by Deschain »

m_from_space wrote: Wed Mar 13, 2024 8:42 am

So not using style definitions for background, you could also achieve different backgrounds using this variable. This method is really not necessary for just a different background. I just want to demonstrate it.
Thanks for demonstrating!...
I am always very grateful for any input!

[...] But of course you can also only use 1 persistent variable that changes all the screens.

Code: Select all

default persistent.bg_opacity1 = 1.0
default persistent.bg_opacity2 = 1.0

style block1_multiple2_say_window is multiple2_say_window:
    background Transform(Frame("mybg1", xalign=0.5, yalign=1.0), alpha=persistent.bg_opacity1)

style block2_multiple2_say_window is multiple2_say_window:
    # make sure the screen is drawn with an offset, otherwise it will overlap the other one, don't put the offset into the background!
    xoffset 500
    background Transform(Frame("mybg2", xalign=0.5, yalign=1.0), alpha=persistent.bg_opacity2)
Yes!... THAT is exactly what I wanted, just different bg-images with one transparency slider for ALL (so for the "Say screen" AND ALL in the "Multiple Say screen".) So far so good ... but !!!

And I was quite sure that this was the solution ... but, I still have the problem that the two bg-images for both "block1_multiple2_say_window" and "block2_multiple2_say_window" are displayed but you can't change the transparency.

Somehow it ignores the "alpha=persistent.dialogueBoxOpacity" ... I don't know.

Probably I have an error somewhere ?

I'll post the code again. it does NOT work in the simple Say screen as soon as I change the line from--->

Code: Select all

    window:
        id "window"
        background Transform(Frame("gui/textbox/textbox_mul.webp",xpos=580, yalign=1.0), alpha=persistent.dialogueBoxOpacity)
       
        if who is not None:
[...]

style block1_multiple2_say_window is multiple2_say_window:
    xoffset -1260
    yoffset -50        
        
        
to ->

Code: Select all

    window:
        id "window"
        
        if who is not None:
        
[...]

style block1_multiple2_say_window is multiple2_say_window:
    background Transform(Frame("gui/textbox/textbox_lu.webp",xpos=580, yalign=1.0), alpha=persistent.dialogueBoxOpacity)
    xoffset -1260
    yoffset -50         
somehow it ignores the "alpha=persistent.dialogueBoxOpacity" value (in the "style").

I'll post the complete code:

Code: Select all


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

    window:
        id "window"
        
        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "who"

                # Add a Sideimage to the Namebox
                add SideImage():
                    xalign 0.0 yalign 0.5
                    xoffset -230 
                    
        text what id "what"


## Make the namebox available for styling through the Character object.

init python:
    config.character_id_prefixes.append('namebox')

style window is default
style say_label is default
style say_dialogue is default
style say_thought is say_dialogue

style namebox is default
style namebox_label is say_label


style window:
    xalign 0.5
    xfill True
    yalign gui.textbox_yalign
    ysize 600
    background Transform(Frame("gui/textbox/textbox.webp", xalign=0.5, yalign=1.0), alpha=persistent.dialogueBoxOpacity)

style namebox:
    xpos 500 #gui.name_xpos
    xanchor gui.name_xalign
    xsize gui.namebox_width
    ypos -175 #gui.name_ypos
    ysize gui.namebox_height

    
    padding gui.namebox_borders.padding



style say_label:
    properties gui.text_properties("name", accent=True)
    xalign gui.name_xalign
    yalign 0.5


style say_dialogue:
    properties gui.text_properties("dialogue")

    xpos 600 #gui.dialogue_xpos (884)
    xsize 2792 #gui.dialogue_width (2232)
    ypos 195 #150 +45

    adjust_spacing False


## Multiple Say Screen #########################################################
## 
## This screen sets up the Multiple_say_screen and adds an Sideimage next to
##  the "namebox"


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

    window:
        id "window"
        
        if who is not None:

            window:
                id "namebox"
                style "namebox"
                hbox:
                    add side_images_reference[who]:
                        xalign 0.0 yalign 0.5
                        xoffset 55    #xoffset -30                     

                    text who id "who"

        text what id "what"


#####################################################################
## Multiple 2


style multiple2_say_window is say_window:  # saywindow (hgBild) - position
    xsize 1480 
    ysize 390 

style multiple2_namebox is namebox: # Namebox - position
    ypos -28
    xoffset -200

style multiple2_say_label is say_label: # Namebox - Text - position
    xoffset 90

style multiple2_say_dialogue is say_dialogue: # Textbox - Text - position
    xsize 1400
    xoffset 87
    yoffset -55

style block1_multiple2_say_window is multiple2_say_window:
    background Transform(Frame("gui/textbox/textbox_lu.webp",xpos=580, yalign=1.0), alpha=persistent.dialogueBoxOpacity)
    xoffset -1260
    yoffset -50
style block2_multiple2_say_window is multiple2_say_window:
    background Transform(Frame("gui/textbox/textbox_ru.webp",xpos=580, yalign=1.0), alpha=persistent.dialogueBoxOpacity)
    xoffset 460
    yoffset -50
...and yes ... of course I have that too...

Code: Select all

define persistent.dialogueBoxOpacity = 0.2
So, as I said, the right images are displayed correctly, but weirdly, the transparency can no longer be adjusted / no longer has any effect.
So somehow the "persistent.dialogueBoxOpacity" value doesn't work for me at this position.

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: (How) Is it possible to display multipler_say_window with SideImage?

#17 Post by m_from_space »

Deschain wrote: Thu Mar 14, 2024 1:42 pm I'll post the code again. it does NOT work in the simple Say screen as soon as I change the line from--->

Code: Select all

    window:
        id "window"
        background Transform(Frame("gui/textbox/textbox_mul.webp",xpos=580, yalign=1.0), alpha=persistent.dialogueBoxOpacity)
       
        if who is not None:
[...]

style block1_multiple2_say_window is multiple2_say_window:
    xoffset -1260
    yoffset -50        
        
        
to ->

Code: Select all

    window:
        id "window"
        
        if who is not None:
        
[...]

style block1_multiple2_say_window is multiple2_say_window:
    background Transform(Frame("gui/textbox/textbox_lu.webp",xpos=580, yalign=1.0), alpha=persistent.dialogueBoxOpacity)
    xoffset -1260
    yoffset -50         
The simple say screen will not be called in multiple dialogue when you have a multiple_say screen present in your code. So the block style does not have an effect on the simple say screen in that case.
...and yes ... of course I have that too...

Code: Select all

define persistent.dialogueBoxOpacity = 0.2
So, as I said, the right images are displayed correctly, but weirdly, the transparency can no longer be adjusted / no longer has any effect.
So somehow the "persistent.dialogueBoxOpacity" value doesn't work for me at this position.
Make sure to use "default", not "define", otherwise Renpy treats it as a constant and tries to optimize stuff, some things are not changeable during runtime then. But this is not the actual problem here, it would be for non-persistent variables.

The problem seems to be, that Renpy won't update a background that is defined as a style when it is used. So you have to actually incorporate the background into the multiple_say screen, not a block style. So we have to use the multiple variable after all, when using a dynamic alpha value that you want to change on-the-fly... In your case we can just use a simple if-else-construct.

Code: Select all

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

    window:
        id "window"
        if multiple[0] == 1:
            background Transform(Frame("gui/textbox/textbox_lu.webp",xpos=580, yalign=1.0), alpha=persistent.dialogueBoxOpacity)
        elif multiple[0] == 2:
            background Transform(Frame("gui/textbox/textbox_ru.webp",xpos=580, yalign=1.0), alpha=persistent.dialogueBoxOpacity)
    # ...

Deschain
Newbie
Posts: 19
Joined: Thu Sep 28, 2023 9:03 am
Discord: deschain1975
Contact:

Re: (How) Is it possible to display multipler_say_window with SideImage?

#18 Post by Deschain »

m_from_space wrote: Thu Mar 14, 2024 5:06 pm
The simple say screen will not be called in multiple dialogue when you have a multiple_say screen present in your code. So the block style does not have an effect on the simple say screen in that case.
Oops, that was my mistake. :oops:
When copy/pasting the example, I mixed the two together. I wasn't paying attention.
As you can see below in the complete code, I had the correct style in the say screen, and also for the multiple_say screen.
I was quite sure that the two operates independently to each other.
Make sure to use "default", not "define", otherwise Renpy treats it as a constant and tries to optimize stuff, some things are not changeable during runtime then. But this is not the actual problem here, it would be for non-persistent variables.
Yes, thank you (again) !
I must confess and to my shame, that it's not the first time I've heard that. I've already changed it!
(That you use "default" as base value for changeable values. If it wasn't a persistent value (which is saved) it would always take the base value with "define")
Maybe not quite exact. But I understand, I hope, the point.
The problem seems to be, that Renpy won't update a background that is defined as a style when it is used. So you have to actually incorporate the background into the multiple_say screen, not a block style. So we have to use the multiple variable after all, when using a dynamic alpha value that you want to change on-the-fly... In your case we can just use a simple if-else-construct.
Super!
Thank you very much, as already written in the previous thread, the "multiple[0]" was exactly what I was looking for.
I had assumed "block"... but when I look at it like this, it makes sense again. Since "multiple" is the only additional variable in the screen object (?!) (I hope this is worded correctly)


In any case, everything worked great now!
I even found a workaround how I can place the "third" saybox in the top centre and with four sayboxes it is (with a different HG image) above the first one on the left...

I simply took the fifth saybox as the third saybox.
I now have two: one at the bottom left and one at the bottom right
For three: one at the bottom left and right (the same) and two empty ones and no. 5 above it in the centre
and for four: one at the bottom right and left and one at the top right and left.

I hope it's not getting annoying, but I'm so grateful for your efforts!
If I have any more questions, I'll get in touch!
I'll continue my basic Python course during my next holiday.
I left off at object-orientation ... mhhh ... yes ... I really want to do that ...
That's why some of it looks really familiar to me. I'm just not really good at adapting everything to my problems on my own yet... It will get better.... just have to hang in there ;)

Thanks again & talk to you later (probably :roll: )!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], GetOutOfMyLab, Ocelot