CTC and Auto Mode

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
BlueStylus
Newbie
Posts: 13
Joined: Thu Aug 02, 2018 12:18 am
Completed: Nihil: The Watcher
itch: bluestylus
Contact:

CTC and Auto Mode

#1 Post by BlueStylus »

Hello, I am trying to customize my click-to-continue button using my UI.

Image

So I have a quick menu that consists of the rollback button (rolls back by 1 dialogue), the history button (shows the dialogue logs screen), the fast forward button (currently disabled), and the automatic mode button. Here's the code for the auto mode button:

Code: Select all

screen quick_menu():

    ## Ensure this appears on top of other screens.
    zorder 100
    modal quick_menu_modal
    if quick_menu: ##this variable is so that the quick menu can be turned off during tutorial

        hbox:
            style_prefix "quick"

            xalign 0.175
            yalign 0.98
            spacing 9
                
            if auto_mode_button:
                imagebutton: #auto mode button
                    idle "gui/textbox/auto.png"
                    hover "gui/textbox/auto interact.png"
                    hovered [SetField(mtt, 'redraw', True), mtt.Action(Text("Auto Mode", size=25, font="fonts/GARAIT.TTF", color="#ffffff"))]
                    ##this hovered thing is for a custom mouse tooltip, I have a post about how to do this actually
                    action [Preference("auto-forward", "toggle"), ToggleVariable("autoOn")]
                    
        if autoOn:
            hbox:
                xalign 0.8
                yalign 0.98
                text "Auto Mode is On." size 20

        if not autoOn:
            hbox:
                xalign 0.8
                yalign 0.98
                #add "ctc_icon"
And of course 'autoOn' is defined as false by default in the normal code. So the problem is that the CTC icon, as it's usually defined, doesn't go away when I have auto mode turned on. As you can see from the above code, I am attempting to only have the CTC icon appear when auto mode is turned off. What would be extremely useful is an variable native to Ren'py that turns true whenever the dialogue is finished being revealed, so whatever is triggering the CTC icon normally.

By the way, here's how the CTC icon is normally defined (and how I initially defined it):

Code: Select all

image ctc_icon:
    "gui/textbox/continue.png"
    xalign 0.8 yalign 0.98 ##this position is fixed, and it could be different for each ui setup
    linear 0.75 alpha 1.0
    linear 0.75 alpha 0.0
    repeat
    
define jo = Character("Joshua", who_color= "#8f8f8f", image = "jo", ctc="ctc_icon", ctc_position="fixed")
This method would work if I didn't want to add an auto mode button, but it has another problem too: normal narration, like dialogue that doesn't have any specific speaker, doesn't have the CTC icon because it's not defined in the character. Because there is no narration character. Yes, I think there actually is some way you can define a narrator but it just seems unnecessary if I could instead make a CTC screen. Another minor problem is that when auto mode is turned on the CTC icon sometimes abruptly appears instead of the dissolve transform I gave it, I guess the transform is just always running in the background and it's just hidden when the text is being revealed.

So, in my head, the solution is to utilize a variable that turns true once the dialogue is done being revealed (or false, it doesn't matter). When this variable is triggered, then the CTC image is added onto the quick_menu screen until you click and the next dialogue starts being revealed again, which makes the CTC image disappear, repeat. And by turning auto mode on, I can turn this variable off permanently so that the CTC image doesn't appear at all, and instead I have the text "Auto Mode is On." displayed in its place (this part is already defined and works great), until auto mode is turned off. Is there such a variable already? If not, how would I go about defining this variable?

Thank you!!
BlueStylus

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: CTC and Auto Mode

#2 Post by philat »


User avatar
BlueStylus
Newbie
Posts: 13
Joined: Thu Aug 02, 2018 12:18 am
Completed: Nihil: The Watcher
itch: bluestylus
Contact:

Re: CTC and Auto Mode

#3 Post by BlueStylus »

Ok wow, that link was actually enough to solve my problem!! I didn't know about it, so thank you very much. Let me explain how I solved the issue:

So instead of defining for each character ctc="ctc_icon", ctc_position="fixed", you can just create a ctc screen and turn it off and on using a variable. You CANNOT turn off the screen by simply clicking a button that does ToggleScreen("ctc"). THIS WILL NOT WORK BECAUSE the screen is hidden while text is scrolling, and it's shown when it's finished. Which means if you were to click a button that just hides the screen, the screen will automatically be shown again at the next dialogue.

So here is the actual screen definition I used:

Code: Select all

screen ctc(arg=None):

    zorder 100

    if ctcOn:
        hbox:
            xalign 0.82
            yalign 0.97

            add "gui/textbox/continue.png" at ctcblink
Basically, by clicking the auto-mode button, you turn ctcOn (the variable) off. That way when the ctc screen shows automatically, the hbox is not displayed, effectively hiding your ctc icon. Super duper simple. Here is the updated imagebutton for the auto mode, by the way.

Code: Select all

if auto_mode_button:
    imagebutton: #auto mode button
        idle "gui/textbox/auto.png"
        hover "gui/textbox/auto interact.png"
        hovered [SetField(mtt, 'redraw', True), mtt.Action(Text("Auto Mode", size=25, font="fonts/GARAIT.TTF", color="#ffffff"))]
        action [Preference("auto-forward", "toggle"), ToggleVariable("autoOn"), ToggleVariable("ctcOn")]
                    
if autoOn:
    hbox:
        xalign 0.8
        yalign 0.98
        text "Auto Mode is On." size 20
Hope this helps in case anyone finds this thread!! Thank you philat for your simple yet extremely helpful response <3

User avatar
BlueStylus
Newbie
Posts: 13
Joined: Thu Aug 02, 2018 12:18 am
Completed: Nihil: The Watcher
itch: bluestylus
Contact:

Re: CTC and Auto Mode

#4 Post by BlueStylus »

***adding on

As always, make sure to define your ctcOn variable outside of the screens and everything, preferably in script.rpy
Something like this:

Code: Select all

default ctcOn = False

Post Reply

Who is online

Users browsing this forum: No registered users