Little used features screen Settings

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
Andredron
Miko-Class Veteran
Posts: 700
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Little used features screen Settings

#1 Post by Andredron »

1) How to prescribe the transparency of the text window(sorely lacking in many projects)

https://renpymemo.hateblo.jp/entry/2022/01/10/141203

First, let's go into screens.rpy and write there at the very top.

Code: Select all

define persistent.say_window_alpha = 1.0
Next, scroll down to screen say, and modify it so that under each window there is similar code

Code: Select all

screen say:
    window:
        background Transform(style.window.background, alpha=persistent.say_window_alpha)
my version

Code: Select all

window:
    background Frame(im.Composite((96, 96), (0, 0), im.MatrixColor(im.Crop("images/Window.png", (0, 0, 96, 96)), im.matrix.opacity(persistent.say_window_alpha)), (0, 0), im.Crop("images/Window.png", (0, 97, 96, 94)), (0, 0), im.Crop("images/Window.png", (96, 0, 96, 96))), 14, 14, tile = True)
Next, scroll down even further, to settings, or wherever else you want to set the transparency adjustment, and cram the bar in there:

Code: Select all

bar value FieldValue(persistent, 'say_window_alpha', 1.0, max_is_zero=False, step=1)
2)Changing the image from the volume value

Code: Select all

init python:
    # get the volume in percent
    def getV(mixer):
        return (int)(_preferences.get_volume(mixer)*100)
    # change the picture depending on the volume
    # picture name vol%.png, where % is volume / 25 + 1
    def get_img(st, at):
        return "images/vol" + str(getV("music")/25 + 1) + ".png", None

init:
    # create an image that changes with the get_img function
    image img_vol = DynamicDisplayable(get_img)
    # just add the image to the screen where needed
    # for example in screen preferences in screens.rpy
screen.rpy

Code: Select all

        vbox:
            frame:
                style_group "pref"
                has vbox

                label _("music volume")
                bar value Preference("music volume")
                add "img_vol" # smiley face
And the pictures accordingly vol1.png, vol2.png, vol3.png, vol4.png, vol5.png


3) Choosing a font
viewtopic.php?t=38235

4)Text size
https://www.renpy.org/doc/html/gui_adva ... ml#example

And bar size
viewtopic.php?f=8&t=66750

5) Text Speed Preview
viewtopic.php?f=8&t=14334
viewtopic.php?f=8&t=57516
viewtopic.php?f=8&t=57644

https://www.lezcave.com/text-speed-preview/

6) Rename the M.C. in the preferences menu
viewtopic.php?f=8&t=58039

viewtopic.php?t=61374&sid=ca9c927244bd5 ... 73e223bdd4

7) Different sounds on "check" textbuttons
viewtopic.php?f=8&t=65018&p=554082#p554082

8)Button to restore the default volume

Code: Select all

define config.default_music_volume = 0.5
define config.default_sfx_volume = 0.5
define config.default_voice_volume = 0.5

textbutton _("restore volume"):
    action [Preference("music volume", config.default_music_volume), Preference("sound volume", config.default_sfx_volume), Preference("voice volume", config.default_voice_volume)]
    
9) Volume button instead of the bar

Code: Select all

default mvol = .3
screen euqvi():
    $ renpy.music.set_volume(mvol, channel='music')
    $ mvolreal = int(mvol*100)
    vbox at topleft:
        text 'volume [mvolreal] %'
        textbutton '^' action SetVariable('mvol', mvol + .01 if mvol < .99 else 1.0)
        textbutton 'v' action SetVariable('mvol', mvol - .01 if mvol > .01 else 0.0)

label start:
    play music 'testmusic.mp3'
    show screen euqvi
    pause
or

Code: Select all

init python:
    # find out the volume and convert it to an integer percentage
    def getV(mixer):
        return (int)(_preferences.get_volume(mixer)*100)
 
    # action - add or subtract volume
    class AddVolume(Action):
        def __init__(self, mixer, value):
            self.mixer = mixer
            self.value = value
 
        def __call__(self):
            v = _preferences.get_volume(self.mixer) + self.value
            if v > 1.0:
                v = 1.0
            if v < 0.0:
                v = 0.0
            _preferences.set_volume(self.mixer, v)
 
        def get_selected(self):
            return _preferences.get_volume(self.mixer) == self.value
 
screen preferences:
    tag menu
    ... - here is the code of the standard preferences screen instead of the dots
    # to check, let's change the line of the standard preferences screen and add a couple of buttons
                label _("music volume: %s" % (getV("music")) # show the volume in percent
                # buttons to change the volume by a given amount:
                textbutton _("+") action AddVolume("music", .1)
                textbutton _("-") action AddVolume("music", -.1)
                # standard volume slider:
                bar value Preference("music volume")
10) Disable certain sounds in the settings (smacking, moaning....)
viewtopic.php?f=8&t=53038

11) Programmer-style drop-down menu
https://patreon.renpy.org/dev-2022-05.h ... down-menus

12) Running Line
https://patreon.renpy.org/dev-2021-11.html#marquee

13) How to change text color in say screen after player read it.
👍👍👍 https://www.renpy.cn/forum.php?mod=view ... a=page%3D1

https://www.renpy.org/doc/html/other.html#renpy.is_seen

https://renpymemo.hateblo.jp/entry/2023/02/01/003908

14) Adding Text Box opacity Properties to "Reset to Defaults"
viewtopic.php?p=554002#p554002

15) Setting up an option to toggle dialogue between left and centered.
viewtopic.php?p=548244#p548244

16)Turning on/off vibration in options
viewtopic.php?f=8&t=53284#p502502

17) profanity filter
viewtopic.php?f=8&t=42538

18) "Hentai" option
https://renpy.org/wiki/renpy/doc/cookbo ... s_optional

19) Youtube mode in settings(auto-read mode)
viewtopic.php?f=51&t=65301

20) Brightness in game settings
viewtopic.php?f=51&t=66179

21) Click anywhere to exit window

viewtopic.php?f=8&t=65957

22) Translation languages
viewtopic.php?t=43333


23) How do I have scrolling screens keep their positions after being interacted with

viewtopic.php?f=8&t=66418

viewtopic.php?t=67450

24) How to show a potentially infinite list in a screen
viewtopic.php?f=8&t=66927

25) Cursor Selection.

Code: Select all

init python:
    # function to change the cursor
    # cursors should be in the images folder
    # cur0 is the name for the system cursor
    def cursor(name = "cur0", x=0, y=0):
        if name != "cur0":
            persistent.cur = name
            persistent.cx = 0
            persistent.cy = 0
            config.mouse = {'default' : [('images/' + name + '.png', x, y)]}
        else:
            config.mouse = None
    # turn the function into an action,
    # so we can bind it to button presses, for example:
    # action Cursor("cur0", 2, 4)
    Cursor = renpy.curry(cursor)
    # show/hide cursor menu
    cur_choo = False
    # set the default cursor on the first run
    if persistent.cur is None:
        persistent.cur = "cur0"
        persistent.cx = 0
        persistent.cy = 0
    # at each startup set the last selected cursor
    cursor(persistent.cur, persistent.cx, persistent.cy)

screen cursor_chooser:
    vbox:
        align(1.0, 0.0)
        # button to display/hide the cursor list
        imagebutton auto "cur_%s.png" focus_mask True action SetVariable("cur_choo", not cur_choo) xalign 1.0
        # buttons to change the cursor to a finger
        if cur_choo:
            _("{image=cur0.png}") action Cursor("cur0")
            textbutton _("{image=cur1.png}") action Cursor("cur1", 2, 2)
            textbutton _("{image=cur2.png}") action Cursor("cur2")
            textbutton _("{image=cur3.png}") action Cursor("cur3")
            textbutton _("{image=cur4.png}") action Cursor("cur4", 3)
            textbutton _("{image=cur5.png}") action Cursor("cur5", 3)
            textbutton _("{image=cur6.png}") action Cursor("cur6")

label start:
    # show cursor selection screen
    show cursor_chooser screen
    "Click the button in the corner and select the cursor."
    "The cursor will be saved on the next run."
    return
26) BGM %
https://renpymemo.hateblo.jp/entry/2021/07/19/232257

27) Add “Do not display this screen next time” to some confirmations
https://renpymemo.hateblo.jp/entry/2024/01/22/012035
You may be interested in the following materials:
Last edited by Andredron on Tue Jan 23, 2024 5:10 pm, edited 18 times in total.

Toccame
Newbie
Posts: 6
Joined: Sun Jan 26, 2020 1:03 pm
Contact:

Re: Little used features screen Settings

#2 Post by Toccame »

Thank you very much for putting this together! Really helpful.

User avatar
Moshibit
Regular
Posts: 50
Joined: Wed Oct 16, 2019 1:58 pm
Location: Mexico
Contact:

Re: Little used features screen Settings

#3 Post by Moshibit »

Thank you, your work is very useful, it's been a long time since the Ren'Py Cookbook Directory topic has been updated, this makes it easier to find scripts for specific topics, I hope you plan to do something similar with code for choices.

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

Re: Little used features screen Settings

#4 Post by Andredron »

Moshibit wrote: Thu Jan 26, 2023 1:34 pm Thank you, your work is very useful, it's been a long time since the Ren'Py Cookbook Directory topic has been updated, this makes it easier to find scripts for specific topics, I hope you plan to do something similar with code for choices.
according to the election point, I do not see the point of creating a separate topic in the cookbook when there are detailed patreons of Mr. Python.

https://patreon.renpy.org/menu-argument ... -arguments

Post Reply

Who is online

Users browsing this forum: Google [Bot]