(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:

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

#1 Post by Deschain »

Hello !


As stated in the subject line, I would like to know how to set or change the multiple_say_window to show up with SideImage.
So, I'm making one last desperate attempt to find a solution. I already got a tip in the Discord, but somehow it doesn't work out.

In detail, I have very small avatar images as side images directly next to the "namebox". These could also be used without problems in a multiple_say_window

Image

I had already found an old thread whose conclusion was ... probably not possible...(more or less)
viewtopic.php?t=59155

My current "say_screen":

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"


    ## If there's a side image, display it above the text. Do not display on the
    ## phone variant - there's no room.
    #    if not renpy.variant("small"):		# I have commented this out as there will be no phone variant
    #        add SideImage() xalign 0.0 yalign 1.0

## 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 gui.textbox_height

    #background Image("gui/textbox.png", xalign=0.5, yalign=1.0)

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

    #background Frame("gui/namebox.png", gui.namebox_borders, tile=gui.namebox_tile, xalign=gui.name_xalign)
    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 gui.dialogue_ypos

    adjust_spacing False



#########################
## Multiple Say Windows #
#########################


style block2_multiple4_say_window:
    xpos 2600
    xfill True
    yalign gui.textbox_yalign
    ysize gui.textbox_height

style block3_multiple4_say_window:
    xpos 3250
    xfill True
    yalign gui.textbox_yalign
    ysize gui.textbox_height

style block4_multiple4_say_window:
    xpos 3900
    xfill True
    yalign gui.textbox_yalign
    ysize gui.textbox_height

Works very well for a single Saybox...

Image

...but not with the multiple.

Image

The tip I got in the Discord was the following:

At first the side image has the same name as the character, so the image would be `'side amanda.png'` if the character was `define amd = Character("Amanda", image = "amanda")`

and the setup for the say_screen as a <multiple_say(who, what, multiple)> like this:

Code: Select all



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

    window:
        id "window"

        if who is not None:

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

                # Add a side-image to the namebox
                add "side " + who.lower():
                    xalign 0.0 yalign 0.5
                    xoffset +230 
                    
        text what id "what"


However, this did not result in a SideImage being displayed. It even led to the (single) namebox always having xallign 0.0.... and I didn't manage to change the position either (neither via <style namebox:> nor directly under <add "side " + who.lower():>).

Image Image

If anyone else has a tip that I could use, it would finally let me sleep peacefully again ... :cry:

Thanks in advance for the effort!

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?

#2 Post by m_from_space »

Deschain wrote: Tue Feb 20, 2024 11:35 am If anyone else has a tip that I could use, it would finally let me sleep peacefully again ... :cry:

Thanks in advance for the effort!
I'm actually a bit confused that the side image is not retrieved. I consider this a bug to be honest. You could raise an issue here: https://github.com/renpy/renpy/issues

But here is the workaround in a way it was suggested. Make sure to style the screen using the multiple variable etc.

Code: Select all

screen multiple_say(who, what, multiple):
    default side_image = f"side {who.lower()}"

    style_prefix "say"

    window:
        id "window"

        if who is not None:

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

            add side_image

        text what id "what"

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?

#3 Post by Deschain »

First of all: Sorry that I am so late to get back to you, the last few days have been a bit stressful.
Secondly (unfortunately) it still doesn't work... not at all...
I created a new game and only changed the following:

Code: Select all

##
## https://www.renpy.org/doc/html/screen_special.html#say


screen multiple_say(who, what, multiple):
    default side_image = f"side {who.lower()}"

    style_prefix "say"

    window:
        id "window"

        if who is not None:

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

            add side_image

        text what id "what"

#########################
## Multiple Say Windows #
#########################

style block2_multiple4_say_window:
    xpos 2600

style block3_multiple4_say_window:
    xpos 3250

style block4_multiple4_say_window:
    xpos 3900

#########################
## Multiple Say Windows #
#########################

## Machen Sie das Namensfeld für die Gestaltung durch das Character-Objekt
## verfügbar.
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 gui.textbox_height

    background Image("gui/textbox.png", xalign=0.5, yalign=1.0)

style namebox:
    xpos gui.name_xpos
    xanchor gui.name_xalign
    xsize gui.namebox_width
    ypos gui.name_ypos
    ysize gui.namebox_height

    background Frame("gui/textbox.png", gui.namebox_borders, tile=gui.namebox_tile, xalign=gui.name_xalign)
    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 gui.dialogue_xpos
    xsize gui.dialogue_width
    ypos gui.dialogue_ypos

    adjust_spacing False
    

This is my complete "say window screen" (with all styles)



And that's my complete "script.rpy"

Code: Select all


image white = "#ffffff"
image side Eileen = "Sabrina.png"

define e = Character('Eileen', image = "Eileen", color="#c8ffc8")
define a = Character("Amanda", image = "amanda")


label start:

    scene white 

    e "Du hast ein neues Ren'Py Spiel erstellt."

    e "Sobald du eine Geschichte, Bilder und Musik hinzufügst, kannst du es für alle veröffentlichen!"

    a "Thats a single say_screen"

    a "Thats multiple1 say_screen" (multiple=4)
    e "Thats multiple2 say_screen" (multiple=4)
    a "Thats multiple3 say_screen" (multiple=4)
    e "Thats multiple4 say_screen" (multiple=4)



    a "Thats a multiple1" (multiple=4)
    "" (multiple=4)
    "" (multiple=4)
    "" (multiple=4)

    "" (multiple=4)
    e "Thats multiple2" (multiple=4)
    "" (multiple=4)
    "" (multiple=4)

    "" (multiple=4)
    "" (multiple=4)
    a "Thats multiple3" (multiple=4)
    "" (multiple=4)

    "" (multiple=4)
    "" (multiple=4)
    "" (multiple=4)
    a "Thats multiple4" (multiple=4)


    e "ende"

    return

I have not changed anything else!
No SideImage is displayed.

It is also not possible for me to change the position via "style namebox:"
from the default xpos 720 (or gui.name_xpos) to xpos 2000 makes no difference the "namebox" always sticks to the left edge (xpos 0.0)

Image

Image

Image


Or am I misunderstanding something, can I no longer change the position of the single namebox via the style "style namebox:"? Because the variable "multiple" from "screen()" takes effect? Naaaa I think I'm confusing myself right now.

I am using a current version of Renpy (8.2.0)
(just a wild speculation, it can't be related to the fact that something was recently changed with the SideImages?)
viewtopic.php?t=67279
I had problems with "frozen sideimages" and had reported a bug on GIT which was fixed with around V 8.2.0...
I'll attach the "game" to the thread...

Nevertheless, many thanks for the tips... and the effort. Maybe there will be a solution ...
Thanks!
https://gofile.io/d/1NV8m5

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?

#4 Post by m_from_space »

Deschain wrote: Thu Feb 22, 2024 10:47 am Or am I misunderstanding something, can I no longer change the position of the single namebox via the style "style namebox:"? Because the variable "multiple" from "screen()" takes effect? Naaaa I think I'm confusing myself right now.
The variable "multiple" is just for a better control of certain features inside the screen besides using just a style using the blockX_multipleY_say_window styles. So ignore it for now.

No clue why your namebox is always aligned to 0.0 of the say screen. But nevertheless, there still should be a side image visible, even if it doesn't exist (Renpy would show a text instead). Here look at my implementation, that works like expected:

multiple_say.png
(19.33 KiB) Not downloaded yet

Code: Select all

style block2_multiple2_say_window:
    xoffset 200

define a = Character("Amanda", image="amanda")
define e = Character('Eileen', image="eileen", color="#c8ffc8")

image side amanda = Solid("#f0f", xysize=(32, 32))
image side eileen = Solid("#ff0", xysize=(32, 32))

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

    window:
        id "window"

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                hbox:
                    $ side_image = f"side {who.lower()}"
                    add side_image

                    text who id "who"

        text what id "what"

label start:
    e "I am Eileen." (multiple=2)
    a "I am Amanda." (multiple=2)
edit: Created an issue here: https://github.com/renpy/renpy/issues/5378
Let's see what Tom says about it. Maybe it's not a bug, but a feature.

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?

#5 Post by Deschain »

Ok, first of all, thanks for all your support!

...and yes, I'll just go and slap myself...;)
It works (of course) as you described!
I just assumed that the new sayscreen replaces the old one! ...and commented out the standard "screen say(who, what):" the whole time....

I just created a new game and wanted to see what happens if I just copy the codeblock into the script.rpy. Whether the old SayScreen is then simply replaced, or whether it crashes... and what do I see? It actually works!

Image

I then commented out the original sayscreen again and ... yep exactly my problem occurred again ...(no pictures&all left-aligned)

Image

I don't want to talk about it :oops: (but I really didn't realise it either)

So thanks again for the effort, also on GIT. I think I can work with it now ...If I still get problems ... maybe I will ask for help again. THANK YOU!

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?

#6 Post by Deschain »

Sorry, but I still have one question ;)

I started styling the Sayboxes today. However, I didn't find much about this in the guide or here in the forum. I tried a bit with what I found and at least managed to get the horizontal spacing of the SayBoxes that I wanted. I also managed to get the same position of the SideImages next to the names.
So I'm almost finished!
What I can't change, however, is the position of the "NameBox"... If I change the style: "multiple2_say_namebox" nothing changes. Apparently the "Namebox" style does not address the Multiple_Namebox? ... how is that supposed to work?

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 gui.textbox_height

    background Image("gui/textbox.png", xalign=0.5, yalign=1.0)

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

    #background Frame("gui/namebox.png", gui.namebox_borders, tile=gui.namebox_tile, xalign=gui.name_xalign)
    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 gui.dialogue_ypos

    adjust_spacing False


## Multiple Say Screen #########################################################
##


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

    window:
        id "window"

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                hbox:
                    $ side_image = f"side {who.lower()}"
                    add side_image:
                        xalign 0.0 yalign 0.5
                        xoffset -230                         

                    text who id "who"

        text what id "what"



style multiple2_say_window is say_window:
    background Image("gui/textbox.png", xalign=0.5, yalign=1.0)
    xsize 1100

style multiple2_say_namebox is say_namebox:
    ypos 0.1                                    # <--- I just tried to change the position somehow !
    xpos 1500                                   # <--- I just tried to change the position somehow !

style block1_multiple2_say_window is multiple2_say_window:
    xalign 0.0

style block2_multiple2_say_window is multiple2_say_window:
    xalign 0.5
Image

Image

That would be the last thing I would need ... because the NameBox is not even inside the Saybox (for whatever reason, the window of the namebox IS inside the window of the Saybox?!).


How can you change the style of the "multiple namebox"?

Hopefully ... ;)

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?

#7 Post by m_from_space »

Deschain wrote: Sat Mar 02, 2024 8:13 am How can you change the style of the "multiple namebox"?
If you don't quote at least something from me, I don't get a notification, but here is the solution:

Code: Select all

style multiple2_namebox:
    ...

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?

#8 Post by Deschain »

m_from_space wrote: Sun Mar 03, 2024 5:58 am If you don't quote at least something from me, I don't get a notification, but here is the solution:
Hello!
Oh ok, I didn't know about the quoting, but it sounds understandable.
Yes, to the answer, THANK YOU. It worked.

I really feel like an idiot. It's certainly not as if I haven't gone through what feels like 100 versions of this tag.
I don't know, I must have spent 5-6 hours trying.
I even tried to rename the styles of the multiple screens "namebox" to "namebox2" to somehow access it directly...etc..

I thought because the manual -> https://www.renpy.org/dev-doc/html/multiple.html#styles
always talks about "blockX_multipleX_say_window", I thought "_say" should always come before the "window" or "namebox" because of the style prefix.
Learned something again ...

So...Thanks again!

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?

#9 Post by m_from_space »

Deschain wrote: Mon Mar 04, 2024 1:16 pm I thought because the manual -> https://www.renpy.org/dev-doc/html/multiple.html#styles
always talks about "blockX_multipleX_say_window", I thought "_say" should always come before the "window" or "namebox" because of the style prefix.
Learned something again ...
Yeah, I was thinking that as well. But style prefixes are applied to displayables and all their children, not to other styles. And "namebox" is not a displayable, it's a style. (Displayables are things like "window", "vbox", "button" etc.) So if you have a style prefix called "say", then all "window" will use a style with the name "say_window". But if you specify another style for any of the children (e.g. you give the style "namebox" to a window, the prefix is ignored). You can read about it here: https://www.renpy.org/dev-doc/html/scre ... yle-prefix

And a multiple dialogue style expects the form "multipleX_STYLENAME", and "namebox" is the name of the style, since you specified it like that.

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?

#10 Post by Deschain »

m_from_space wrote: Mon Mar 04, 2024 4:07 pm
Yeah, I was thinking that as well. But style prefixes are applied to displayables and all their children, not to other styles. And "namebox" is not a displayable, it's a style. (Displayables are things like "window", "vbox", "button" etc.) So if you have a style prefix called "say", then all "window" will use a style with the name "say_window". But if you specify another style for any of the children (e.g. you give the style "namebox" to a window, the prefix is ignored). You can read about it here: https://www.renpy.org/dev-doc/html/scre ... yle-prefix

And a multiple dialogue style expects the form "multipleX_STYLENAME", and "namebox" is the name of the style, since you specified it like that.



Ok, thanks, I'll have another good look at the styles. I've also seen this page before and the entry looks familiar. But I couldn't recall it at the time.
I understand more and more, but a lot of things are still a mystery to me. I've only been doing all this for a year, I'm still very eager to learn and I think/hope that I'll be able to see through things a bit better next year.

I was able to add the side images and place them as I wanted...
I also made one for multiple2_, one for multiple3_ and one for multiple4_... you never know :wink:


I also learnt a few things about how exactly the two different functions access the side image.
the one from the <say_screen()>

Code: Select all

add SideImage():
and the one from the <multiple_say_screen()>

Code: Select all

$ side_image = f "side {who.lower()}"
                    add side_image:

This also fixed one of the problems that came up.
Short example:

I have a Character "Frau Miller"

Code: Select all

define m = Character(_('Frau Miller'), image="miller1")
So I made an "avatar" definition for each of my characters:

Code: Select all

image side miller1 = "avatars/01.webp"
That works just fine with <add Sideimage()> function from the <say_sreen()> because it grabs the Sideimage via <image="miller1">
But it does not work for the <add side_image:> function from the <multiple_say_sreen()> because this function only checks, if the name in the definition <image side miller1> is the same (case insensitive) as in the defined character name.


So I had to change the avatar definition to <image side frau miller = "avatars/01.webp">.
and thus of course also the <image="miller1"> definition in the character definition.

two words in the definition <image="frau miller"> doesn't work for the <add SideImage():> function so I now had an avatar in the "multiple" but no longer in the "normal" say_screen()

So now I have two different definitions for the Sideimage:

Code: Select all

image side miller1 = "avatars/01.webp"
image side frau miller = "avatars/01.webp"
THEN I have the english translation :

Code: Select all

image side mrs miller = "avatars/01.webp"
AND then another "thinking" avatar:

Code: Select all

image side miller1_think = "avatars/01_think.webp"
It works...but... so much redundant code...
what a mess, but can't (I think?) do any better?!


In the end I also gave up on one thing (as good as).
My "thinking" avatar has the exact "name":

Code: Select all

define mt = Character(_('Frau Miller {size=-45}(thinking){/size}'), image="miller1_think"
This doesn't seem to work at all with the <add side_image> function.
I've also tried it with :

Code: Select all

image side 'Frau Miller {size=-45}(thinking){/size}' = "avatars/01_think.webp"
image side ('Frau Miller {size=-45}(thinking){/size}') = "avatars/01_think.webp"
image side ['Frau Miller {size=-45}(thinking){/size}'] = "avatars/01_think.webp"
tried with and without ""... nope...

i got a tip to try it with the <kind=> and <suffix> function like:

Code: Select all

define m = Character(_('Frau Miller'), image="miller1")
define mt = Character(_(kind=m, who_suffix='{size=-45}(thinking){/size}')
image side frau miller = "avatars/01.webp"
but that doesn't work either. Apparently the <add side_image> even accesses the WHOLE name through the suffix function, because ingame it still says
"picture 'Frau Miller {size=-45}(thinking){/size}' not found...

Is there still a way to get this going with the <add side_image> function?

If not, it's not sooo bad, I don't think I need "thinking" speakers in the multiple_say_screen... but something like that always annoys me... like a spot you can't scratch ...
I hope this wall of text wasn't too annoying either..
Anyway, thanks again for the tips and the links!

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?

#11 Post by m_from_space »

Deschain wrote: Sat Mar 09, 2024 8:37 am Is there still a way to get this going with the <add side_image> function?
It's not really a function. We just take the name of the speaking character and then use it as the image name, it's a workaround, since you cannot use the SideImage() function and Tom said, it's not going to change for multiple dialogue. Your examples are messy, you don't seem to quite understand what we're doing here. ^^

But of course we can make things way better, so instead of using the name for the image name, look up the image name in our own little reference dictionary.

Not sure if you even need the translated versions, is the name already translated when it enters the screen? As far as I know, Renpy will translate it the moment when it displays it. Didn't test it. Anyway, let's assume the "who" argument comes in translated...

Code: Select all

define m = Character(_("Frau Miller"), image="miller1")
define mt = Character(_("Frau Miller (denkend)"), image="miller1_think")

image side miller1 = "avatars/01.webp"
image side miller1_think = "avatars/01_think.webp"

# it's possible you don't need the translated versions, try removing them and see if it works!
define side_images_reference = {
    "Frau Miller": "side miller1",
    "Mrs Miller": "side miller1",
    "Frau Miller (denkend)": "side miller1_think",
    "Mrs Miller (thinking)": "side miller1_think"
}

screen multiple_say(who, what, multiple):
    # ...
    add side_images_reference[who]

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?

#12 Post by Deschain »

m_from_space wrote: Mon Mar 11, 2024 6:20 am

It's not really a function. [...] Your examples are messy, you don't seem to quite understand what we're doing here. ^^
Yes, and you're probably right about that.
I still don't understand a lot of things, which of course, as I said at the beginning, is because I've only been working with Renpy or coding in general for a year.
And everyone has probably a different amounts of free time and a different learning curve....

For the first two or three months, I was happy to be able to insert text and change the text size and colour... well ...
I always try not to simply copy code, but to understand how it works. But it's not always that easy, even in the manual you can't find everything. and as a non native english speaker there is a certain language barrier... Deepl supports realy good .. but ...

I try it under the motto ... just do it, try to change things, read the Renpy manual (renpy.org/doc), ask a lot of questions and try to remember as much as possible ... yes... so far..

There are a few things in the following line alone that I don't completely understand, for example:
(even that I had to delete this line now, was not something I immediately realised.)

Code: Select all

$ side_image = f "side {who.lower()}"
(the .lower() why does all characters (of the speaker-name) have to be in lower case? just to give an example)
You can, but certainly don't have to answer such a detailed question, it's just an example.

Anyway, thank you again for your help, I really appreciate it. :!:

But therefore I would like to ask one or the other question again.
I even have another one, but I don't want to annoy you too much :lol: I'll try a little more by myself first!

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?

#13 Post by m_from_space »

Deschain wrote: Mon Mar 11, 2024 1:22 pm I still don't understand a lot of things, which of course, as I said at the beginning, is because I've only been working with Renpy or coding in general for a year.
Sorry if I came across as rude, was not my intention. I like helping people with problems. And just doing trial and error is a good strategy, I use it myself quite often when I don't know every detail. :)
There are a few things in the following line alone that I don't completely understand, for example:
(even that I had to delete this line now, was not something I immediately realised.)

Code: Select all

$ side_image = f "side {who.lower()}"
(the .lower() why does all characters (of the speaker-name) have to be in lower case? just to give an example)
You can, but certainly don't have to answer such a detailed question, it's just an example.
So we didn't have to make it lowercase, I was just using your example in the original post. And as you realized it doesn't work for any full names properly.

If the character's name would be "Eileen", we then assume there is a side image called "side eileen", so we get there by making the name lowercase and then combining it with the word "side" + a space in between. The easy way is doing that inside an f-string. We could have also written:

Code: Select all

$ side_image = "side " + who.lower()

# or

$ side_image = "side {}".format(who.lower())
But that's a bit... beginner like, f-strings are faster during runtime.
I even have another one, but I don't want to annoy you too much :lol: I'll try a little more by myself first!
Don't be shy now haha, I don't mind.

Did the dictionary variant work out for you so far?

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?

#14 Post by Deschain »

m_from_space wrote: Mon Mar 11, 2024 1:57 pm Sorry if I came across as rude, was not my intention. I like helping people with problems. And just doing trial and error is a good strategy, I use it myself quite often when I don't know every detail. :)
Hi!

All good! Really!
I usually search here in the forum before asking questions myself. It's my ambition to do it myself somehow. I often read your name in threads when searching. I can well imagine that you sometimes lose track of how much knowledge the person asking the question has. (especially if parts of the code indicate this) Certainly because code is often simply copied. I always try to be able to understand the code, because otherwise you can never be sure - if you change something somewhere else - that the "unknown code" part will no longer work...

So no problem, I didn't think it was rude, I didn't even want to justify myself, I just wanted to explain again what level I have... (even if it's hard to quantify something like that).
[...]The easy way is doing that inside an f-string. We could have also written:

Code: Select all

$ side_image = "side " + who.lower()

# or

$ side_image = "side {}".format(who.lower())
But that's a bit... beginner like, f-strings are faster during runtime.
Thanks for the explanation. I also had another look at this page https://www.w3schools.com/python/ref_string_format.asp. together with your explanation, I now understand it quite well ... (I'm sure I'll forget it again if I don't need it so often, but the longer you do it, the more logical things become. And the easier it is to find the solution yourself. As with any foreign language you learn, it's best to just speak it a lot...)
Did the dictionary variant work out for you so far?
The dictionary worked very well.
But I actually had to make an entry for the "translated" names, otherwise I had "Picture Mrs Miller not found" again, although that was the smallest problem.
I have now assigned all characters (I think they say "{Key: Value}" ?).
And do I understand correctly that with <add side_images_reference[who]:> in the dictionary the "value" is queried with the "key" [who], which is the respective charater name?
Don't be shy now haha, I don't mind.
Naaa... np!

But in that case, here it comes :lol: :

I have added a "transparency slider" for the textbox backgrounds.

Code: Select all

define persistent.dialogueBoxOpacity = 0.2
with a slider in the pref-menu

Code: Select all

label _("Dialogbox transparency")
bar value FieldValue(persistent, "dialogueBoxOpacity", range=1.0, style="slider")
I have inserted the line

Code: Select all

# 1)
    window:
        id "window"
        background Transform(Frame("gui/textbox/textbox.webp",xalign=0.5, yalign=1.0), alpha=persistent.dialogueBoxOpacity)
# [...]
# 2)
    window:
        id "window"
        background Transform(Frame("gui/textbox/multiple.webp",xalign=0.5, yalign=1.0), alpha=persistent.dialogueBoxOpacity)



in both sayscreens. With two different background images for 1) "Say box" and 2) "Multiple say box"
Then I came up with the glorious idea that if I could do that, I could also individualise EVERY text box background (in the Multiple say screen).
I've tried to get the individual bg-images via styles: (and as I said, I'm just messing around here, it probably all looks completely stupid)

Code: Select all

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

    window:
        id "window"
        window background Transform(child=None, alpha=persistent.dialogueBoxOpacity, style="window")

# [...]


style multiple2_say_window is say_window:
    xsize 1480 #1500
    ysize 390

style block1_multiple2_say_window is multiple2_say_window:
    background Image("gui/textbox/textbox_lu.webp", xalign=0.5, yalign=0.5,)

style block2_multiple2_say_window is multiple2_say_window:
    background Image("gui/textbox/textbox_ru.webp", xoffset=500, yalign=0.5)


I am aware that a new window is created but otherwise it does not show the background images. I can access the respective background images via the style, but the transparency will no longer change.

Maybe you can also use an IF loop somehow? if "window" == "block1"
Or by entering the bg-images also into a dictionary?
I just don't know how to call them.

I hope it was at least understandable what I wanted to achieve?
(Different bg-images for the multiple_say_windows, whose transparencies can still be changed)
In principle, I don't care which method or how it works, the main thing is that I understand it (at least roughly)...and it works.


Thank you, once again, in advance!

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?

#15 Post by m_from_space »

Deschain wrote: Tue Mar 12, 2024 8:58 am And do I understand correctly that with <add side_images_reference[who]:> in the dictionary the "value" is queried with the "key" [who], which is the respective charater name?
Exactly. And I was wondering if the character's name which is stored inside "who" is already translated when it arrives as an argument, since normally Renpy will translate stuff the moment it displays it. But it seems you had to leave the translated keys inside, so there is my answer I guess. (I actually should have known, since the screen would display the name with "[who!t]" if it translates when showing, but ignore that thought if it doesn't make sense to you.)
Then I came up with the glorious idea that if I could do that, I could also individualise EVERY text box background (in the Multiple say screen).
...
I am aware that a new window is created but otherwise it does not show the background images.

Code: Select all

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

    window:
        id "window"

        # delete this line, also the word "window" is misplaced here entirely
        window background Transform(child=None, alpha=persistent.dialogueBoxOpacity, style="window")

Don't put the (empty) background inside the multiple_say screen, because it will overwrite the style definition. Just use your style definition that you already created for the multiple say screen. Delete that line and your backgrounds will show up!

Let's assume you have different backgrounds called "mybg1.png" and "mybg2.png" in the images folder. So simple background difference would be:

Code: Select all

block1_multiple2_say_window:
    background "mybg1"
block1_multiple2_say_window:
    background "mybg2"
Maybe you can also use an IF loop somehow? if "window" == "block1"
Or by entering the bg-images also into a dictionary?
I just don't know how to call them.
That's another method and the moment the argument that is called "multiple" comes into play (the one next to "who" and "what" as part of the multiple_say screen). "multiple" is a tuple containing (X, Y), where X is the current screen (block) number and Y is the total screen number. So when the screen is drawn as part of a dialogue of 2 people, the first time it is drawn, X will be 1 and Y will be 2, and the second time, X will be 2 and Y will be 2. (For four people talking, it would be X = 1, 2, 3, 4 and Y would always be 4).

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.

Code: Select all

screen multiple_say(who, what, multiple):
    # ...
    window:
        # the current block number is stored inside multiple[0]
        background f"mybg{multiple[0]}"
I can access the respective background images via the style, but the transparency will no longer change.
I don't know what you mean by saying that you can access the background images. Your block style definitions don't contain any alpha values, so how are they supposed to change? If you want different alpha levels for each screen, you would need multiple persistent variables, that can store the alpha level for each screen. 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)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot], Milkymalk