Is there a way to force a redraw of the dialogue window?

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
AVNSnax
Regular
Posts: 35
Joined: Sun Feb 06, 2022 12:11 am
itch: avnsnax
Contact:

Is there a way to force a redraw of the dialogue window?

#1 Post by AVNSnax » Sat Jul 09, 2022 4:33 am

Is there a way to force a redraw of the dialogue window? Long story short, I'm disabling CTC display if the user is in auto-forward mode. When I turn Auto on, it's not a problem because afm will force subsequent screens to appear after a delay. But turning Auto off (and turning the CTC back on) there is no CTC visual cue to remind the user to, uh, click to continue to the next screen until the dialogue refreshes by, um, clicking to continue.

I thought it might be as simple as

Code: Select all

renpy.redraw(renpy.get_screen("say"), 0)
but nothing happens--I assume Ren'Py knows that the screen doesn't have to be redrawn because nothing has changed. Thanks.

User avatar
m_from_space
Veteran
Posts: 302
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Is there a way to force a redraw of the dialogue window?

#2 Post by m_from_space » Sat Jul 09, 2022 5:16 am

You could try:

Code: Select all

renpy.restart_interaction()

User avatar
AVNSnax
Regular
Posts: 35
Joined: Sun Feb 06, 2022 12:11 am
itch: avnsnax
Contact:

Re: Is there a way to force a redraw of the dialogue window?

#3 Post by AVNSnax » Sat Jul 09, 2022 10:32 am

m_from_space wrote:
Sat Jul 09, 2022 5:16 am
You could try:

Code: Select all

renpy.restart_interaction()
That's the first thing I tried. Nothing happens. Does it matter where it's called from? Right now, it's an action from the quick menu:

Code: Select all

    def setupCTC():
        ctcBehavior = None if preferences.afm_enable else renpy.easy.displayable_or_none("ctc_blink")
        for c in allCharacters:
            c.display_args['ctc'] = ctcBehavior
        renpy.restart_interaction()
    . . .
                if _preferences.afm_enable:
                    imagebutton:
                        activate_sound "audio/se_click.mp3"
                        idle "gui/button/auto_hover.png"
                        hover "gui/button/auto_idle.png"
                        action [Preference("auto-forward", "toggle"), Function(setupCTC)]
                        tooltip "Auto disable"
                else:
                    imagebutton:
                        activate_sound "audio/se_click.mp3"
                        idle "gui/button/auto_idle.png"
                        hover "gui/button/auto_hover.png"
                        action [Preference("auto-forward", "toggle"), Function(setupCTC)]
                        tooltip "Auto enable"

User avatar
AVNSnax
Regular
Posts: 35
Joined: Sun Feb 06, 2022 12:11 am
itch: avnsnax
Contact:

Re: Is there a way to force a redraw of the dialogue window?

#4 Post by AVNSnax » Fri Jul 15, 2022 11:38 am

I continue to try to solve this problem. Some people have tried to convince me that this is a "non-issue," but it frustrates me that there isn't a way to do something so common in a video game as redrawing parts of the screen.

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Is there a way to force a redraw of the dialogue window?

#5 Post by Alex » Fri Jul 15, 2022 5:23 pm

AVNSnax wrote:
Fri Jul 15, 2022 11:38 am
...
Try DynamicDisplayable - https://www.renpy.org/doc/html/displaya ... isplayable

Something like

Code: Select all

init python:
    def ctc_return(st, at, ctc):
        if my_var:
            return ctc, 0.1
        return Null(), 0.1
        
define e = Character("Eileen", who_color="#909", ctc=DynamicDisplayable(ctc_return, ctc=Text("A") ) )

        
default my_var = True

# The game starts here.

label start:
    $ my_var = True
    e "..."
    $ my_var = False
    e "... ..."
    $ my_var = True
    e "?!"

User avatar
AVNSnax
Regular
Posts: 35
Joined: Sun Feb 06, 2022 12:11 am
itch: avnsnax
Contact:

Re: Is there a way to force a redraw of the dialogue window?

#6 Post by AVNSnax » Fri Jul 15, 2022 9:50 pm

Alex wrote:
Fri Jul 15, 2022 5:23 pm
...
That was simpler than my brute force method, so thanks! My issue with screen updates remains:
  • If auto-forward is off and enabled, the screen automatically shows the following screen with CTC now disabled. No problem.
  • If auto-forward is on and disabled, the screen displays no CTC icon until the user clicks to the next screen. Issue.
That's why I asked about forcing a redraw of the dialogue window. I could see several instances where such a feature might come in handy. Given the relatively low overhead, I don't think there would need to have a fancy system for buffering requests to redraw, especially with as often as the say screen is called.

Any other suggestions are welcome!

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3636
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Is there a way to force a redraw of the dialogue window?

#7 Post by Imperf3kt » Fri Jul 15, 2022 11:02 pm

Why not just use the default CTC screen and add a single condition check to the CTC screen? If in afm, the screen won't show, if not, it shows.

Does this not work as expected?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

User avatar
AVNSnax
Regular
Posts: 35
Joined: Sun Feb 06, 2022 12:11 am
itch: avnsnax
Contact:

Re: Is there a way to force a redraw of the dialogue window?

#8 Post by AVNSnax » Sat Jul 16, 2022 2:57 am

Imperf3kt wrote:
Fri Jul 15, 2022 11:02 pm
Why not just use the default CTC screen and add a single condition check to the CTC screen? If in afm, the screen won't show, if not, it shows.
Does this not work as expected?
I'm using a nestled-close icon in-line with the text. There is no separate CTC screen.

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Is there a way to force a redraw of the dialogue window?

#9 Post by Alex » Sat Jul 16, 2022 4:27 am

AVNSnax wrote:
Fri Jul 15, 2022 9:50 pm
...
  • If auto-forward is on and disabled, the screen displays no CTC icon until the user clicks to the next screen. Issue.
...
This seems to work for me

Code: Select all

image blue:
    Solid("#00c")
    size(100, 100)

init python:
    def ctc_return(st, at, ctc):
        # if player not skipping text and
        # game not in auto-forward mode
        if not renpy.get_skipping() and not preferences.afm_enable:
            return ctc, 0.1
        return Null(), 0.1

transform test_ctc_anim(t=1.0):
    alpha 0.0
    linear t/2.0 alpha 1.0
    linear t/2.0 alpha 0.0
    repeat
        
image test_ctc:
    "blue"
        
define e = Character("Eileen", who_color="#909", ctc_position="nestled-close", ctc=DynamicDisplayable(ctc_return, ctc=At('test_ctc', test_ctc_anim) ) )


# The game starts here.

label start:
    $ i = 0
    while i < 500:
        $ i += 1
        e "... [i] ...\nText text text some more text..."
    "?!"
https://www.renpy.org/doc/html/other.ht ... t_skipping
https://www.renpy.org/doc/html/preferen ... afm_enable
https://www.renpy.org/doc/html/displayables.html#At

User avatar
AVNSnax
Regular
Posts: 35
Joined: Sun Feb 06, 2022 12:11 am
itch: avnsnax
Contact:

Re: Is there a way to force a redraw of the dialogue window?

#10 Post by AVNSnax » Sat Jul 16, 2022 5:17 am

Alex wrote:
Sat Jul 16, 2022 4:27 am
This seems to work for me
Hmm. The only difference in our code (besides my using an image without applying a transform) was your direct reference to the image, which my code couldn't find which is why I added the calls in the first place to renpy.easy.displayable_or_none() to retrieve the displayable from the name. I moved the image declaration into the file and it all started working. Must have been a scoping error.

Thanks Alex! I really appreciate it!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], minyan