Page 1 of 1

Youtube mode in settings

Posted: Sat Sep 03, 2022 2:38 pm
by Andredron
The idea of creating such a regime was inspired by Mr. Python's article:

https://patreon.renpy.org/dev-2021-09.html

Where he suggests to create a screen mode in the character.

To create such a mode, you will need to create screen

Code: Select all

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

    use my_keys

    if not persistent.youtube_mode:
        window:
            id "window"

            # копия обычного сэйбокса
            if who is not None:
                window:
                    id "namebox"
                    style "namebox"
                    text who id "who"
            text what id "what"
            if not renpy.variant("small"):
                add SideImage() xalign 0.0 yalign 1.0
    else:
        frame:
            style "empty"               # The empty style resets the frame to no background, margins, or padding.
            background "#000"           # Set the background to black.
            padding (5, 5)              # Add a bit of padding.
            align (.5, 1.)
            yoffset -25

            text what:
                id "what"               # Ren'Py needs this for a say screen to work.
                pos (0, 0)              # This screen needs the text to be positioned at (0, 0)
                layout "subtitle"       # Subtitle layout tries to make all lines even.
                text_align 0.5          # Center the text within the text block.
                size 25                 # Set the text size.


We prescribe a function thanks to which we can turn on YouTube mode,

Code: Select all

init python:
     if persistent.youtube_mode is None:
         persistent.youtube_mode = False

     # toggle (None) or set (True/False) sub mode
     def youtube_toggle(on=None):
         # if toggle:
         if on is None:
             on = not persistent.youtube_mode
         # set a new value
         persistent.youtube_mode = on
         # enable autoread. At pleasure
         #if on:
             #_preferences.afm_enable = True
             #_preferences.afm_after_click = True
         # or turn off
         #else:
             #_preferences.afm_enable = False
     YoutubeToggle = renpy.curry(youtube_toggle)
     
###Activate auto read mode
init:
    if not persistent.set_afm_time:
        $ persistent.set_afm_time = True
        $ preferences.afm_enable = True
        $ _preferences.afm_time = 10
default persistent.youtuber_mode = False
Write characters

Code: Select all

define au = Character(None, screen="say2")
define nez = Character('???', screen="say2", color="#f7f4f4", what_color="#f7f4f4")
In the settings, we will write the auto-read mode and YouTube mod

Code: Select all

screen preferences():
    add "images/pref.png"
    tag menu
    fixed:
        label _("{size=24}{color=#ffffff}Skip"):
            xalign 0.23 yalign 0.24
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
        textbutton _("Viewed text only"):
            xalign 0.5 yalign 0.24
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
            action Preference("skip", "seen")
        textbutton _("All text"):
            xalign 0.75 yalign 0.24
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
            action Preference("skip", "all")
        
        label _("{size=22}{color=#ffffff}AutoRead"):
            xalign 0.23 yalign 0.32
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
        textbutton _("Enable"):
            xalign 0.5 yalign 0.32
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
            action [Preference("auto-forward", "toggle"), Preference("auto-forward after click", "enable")]  
        textbutton _("Disable"):
            xalign 0.75 yalign 0.32
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
            action [Preference("auto-forward", "disable"), Preference("auto-forward after click", "disable") ]
        
        label _("{size=22}{color=#ffffff}Youtub\nmode"):
            xalign 0.23 yalign 0.4
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
        textbutton _("Enable"):
            xalign 0.5 yalign 0.4
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
            action [SetField(persistent, "youtuber_mode", True), YoutubeToggle(True)]
        textbutton _("Disable"):
            xalign 0.75 yalign 0.4
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
            action [SetField(persistent, "youtuber_mode", False), YoutubeToggle(False)]
Preference("auto-forward", "toggle") - Auto reading turn on,
Preference("auto-forward after click", "enable") - after clicking the mouse on the choice so that the mode is not reset

And we get such a wonderful mode

Videos - https://vk.com/video189145553_456239691

Special thanks to Ruslan Nebykov from 7 DOTS https://vk.com/seven_dots