Voice replay button in quick menu/say 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
User avatar
umineko
Regular
Posts: 52
Joined: Sun Jan 09, 2022 7:12 am
Projects: Ikimashou!
Organization: Bagel Poutine
itch: umineko-chan.itch.io
Contact:

Voice replay button in quick menu/say screen

#1 Post by umineko »

Hi, thought I'd like to share a little dilemma I've come into.

I've managed to implement a voice replay button in my history screen, but I don't know how to place it in the quick menu. It would look like this:
Screenshot_20221210_012707.png
For reference, here is the a snippet of the code used on the history screen:

Code: Select all

   if h.voice and h.voice.filename:
                        text what line_spacing 10
                        imagebutton:
                            idle "gui/button/voice.png"
                            hover "gui/button/voice_hover.png"
                            action Play("voice", h.voice.filename)
                            hovered Play("system2", "audio/system/sysse_select.ogg")
                            xpos 1450
I can't place it in the quick menu screen, so I was wondering if there is another way. Thanks in advance!
"I like kemomimi and I cannot lie."

User avatar
Andredron
Miko-Class Veteran
Posts: 719
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Voice replay button in quick menu/say screen

#2 Post by Andredron »

umineko wrote: Sat Dec 10, 2022 2:31 am Hi, thought I'd like to share a little dilemma I've come into.

I've managed to implement a voice replay button in my history screen, but I don't know how to place it in the quick menu. It would look like this:
Screenshot_20221210_012707.png

For reference, here is the a snippet of the code used on the history screen:

Code: Select all

   if h.voice and h.voice.filename:
                        text what line_spacing 10
                        imagebutton:
                            idle "gui/button/voice.png"
                            hover "gui/button/voice_hover.png"
                            action Play("voice", h.voice.filename)
                            hovered Play("system2", "audio/system/sysse_select.ogg")
                            xpos 1450
I can't place it in the quick menu screen, so I was wondering if there is another way. Thanks in advance!
Making a button (text button, image button...) and prescribe her a Voice response action ().
Usually it is better to put it either in the quick menu or in the dialog box, and so that it does not interfere, we need to set a condition. As a result , we get

Code: Select all

if voice_can_replay():
    imagebutton:
        idle "images/GUI/other/log_voice.webp" 
        hover over "images/GUI/other/log_voice.webp" 
        xalign 0.91 yalign 0.99  
        action VoiceReplay ()
     
        

User avatar
umineko
Regular
Posts: 52
Joined: Sun Jan 09, 2022 7:12 am
Projects: Ikimashou!
Organization: Bagel Poutine
itch: umineko-chan.itch.io
Contact:

Re: Voice replay button in quick menu/say screen

#3 Post by umineko »

The code works great! There's just one issue :(

The button can be clicked continuously, even if there is no voice file for the current line of dialogue. It would replay the last voice file, until a line with a voice file comes up.
"I like kemomimi and I cannot lie."

User avatar
Andredron
Miko-Class Veteran
Posts: 719
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Voice replay button in quick menu/say screen

#4 Post by Andredron »

umineko wrote: Sun Dec 11, 2022 2:39 am The code works great! There's just one issue :(

The button can be clicked continuously, even if there is no voice file for the current line of dialogue. It would replay the last voice file, until a line with a voice file comes up.
there is a very dirty and long version

#script.rpy

Code: Select all

label start:
    $ voice_file = 001
    voice "voice/001.ogg"
    "Test"
    
    $ voice_file = 002
    voice "voice/002.ogg"
    "Test2"

Code: Select all

#screen.rpy
screen quick_menu():
    zorder 100

    if quick_menu:
    ................................
imagebutton:
        idle "images/GUI/other/log_voice.webp" 
        hover over "images/GUI/other/log_voice.webp" 
        xalign 0.91 yalign 0.99  
        action [Play("sound", "voice/[voice_file].ogg")]

Something like this, I have never done this before, but I hope it helped you look where in the direction you need






or assign a variable to the button when it plays voice
viewtopic.php?p=556560#p556560
action If(......... here is an example

User avatar
umineko
Regular
Posts: 52
Joined: Sun Jan 09, 2022 7:12 am
Projects: Ikimashou!
Organization: Bagel Poutine
itch: umineko-chan.itch.io
Contact:

Re: Voice replay button in quick menu/say screen

#5 Post by umineko »

Andredron wrote: Sun Dec 11, 2022 5:13 am
umineko wrote: Sun Dec 11, 2022 2:39 am The code works great! There's just one issue :(

The button can be clicked continuously, even if there is no voice file for the current line of dialogue. It would replay the last voice file, until a line with a voice file comes up.
there is a very dirty and long version

#script.rpy

Code: Select all

label start:
    $ voice_file = 001
    voice "voice/001.ogg"
    "Test"
    
    $ voice_file = 002
    voice "voice/002.ogg"
    "Test2"

Code: Select all

#screen.rpy
screen quick_menu():
    zorder 100

    if quick_menu:
    ................................
imagebutton:
        idle "images/GUI/other/log_voice.webp" 
        hover over "images/GUI/other/log_voice.webp" 
        xalign 0.91 yalign 0.99  
        action [Play("sound", "voice/[voice_file].ogg")]

Something like this, I have never done this before, but I hope it helped you look where in the direction you need






or assign a variable to the button when it plays voice
viewtopic.php?p=556560#p556560
action If(......... here is an example

Welp, I guess this is a way, hehe! Thanks for your help :D
"I like kemomimi and I cannot lie."

Post Reply

Who is online

Users browsing this forum: No registered users