How do you allow the user to toggle between a custom hardware mouse cursor image?

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
henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

How do you allow the user to toggle between a custom hardware mouse cursor image?

#1 Post by henvu50 »

The user would go into preferences, and click a checkbox that says, "Custom Hardware Mouse Cursor Image".

When they do that, and restart the game, the game begins using a custom hardware mouse cursor image, but if the user goes back into preferences and disables the checkbox: "Custom Hardware Mouse Cursor Image", and then restarts the game, the game will once again use the default windows hardware mouse cursor.

How would you write the code for this?

Note: I can't use MouseDisplayable in conjuction with config.mouse and default_mouse, because it causes lag in some cases. I'd rather stick with hardware mouse cursor only, not overlaying an image over the mouse cursor.

It would work something like this in theory:

Code: Select all

if persistent.UseCustomHardwareMouseCursorImage:
    define config.mouse = { }    
    define config.mouse['default'] = [ ( "gui/c_mous_curs.webp", 0, 0) ]
    # notify user to restart ren'py game for changes to take effect
    # restart ren'py game
else:
    # do nothing, just use default hardware mouse cursor
    # notify user to restart ren'py game for changes to take effect

User avatar
m_from_space
Eileen-Class Veteran
Posts: 1002
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: How do you allow the user to toggle between a custom hardware mouse cursor image?

#2 Post by m_from_space »

So what's your question, since you already posted a solution? Did you test it?

henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: How do you allow the user to toggle between a custom hardware mouse cursor image?

#3 Post by henvu50 »

That is just a code example to demonstrate the theory of what I need. It doesn't work. Wrapping a define with a if then conditional won't work.

I don't think there's anyway to let the user Toggle a custom hardware mouse cursor, even if they restart the game.

This code just won't work.

Code: Select all

init offset = -3

define config.mouse = { }    
define config.mouse['default'] = [ ( "gui/image.webp", 0, 0) ]
default persistent.custCursorMouse = True

init python:
    # when  game first runs
    if persistent.custCursorMouse:
        # use a custom image for hardware mouse cursor
        config.mouse['default'] = [ ( "gui/image.webp", 0, 0) ]
    else:
        # use default white mouse cursor
        config.mouse = None

jeffster
Veteran
Posts: 421
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: How do you allow the user to toggle between a custom hardware mouse cursor image?

#4 Post by jeffster »

Ren'Py initializes its interface in renpy/display/core.py.
https://github.com/renpy/renpy

There is a store variable default_mouse to change default mouse cursor
https://github.com/renpy/renpy/blob/fb4 ... e.py#L3269

Documentation:
https://renpy.org/doc/html/store_variab ... ault_mouse

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], henne