[SOLVED] Custom mouse cursor in 7.4.x
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.
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.
[SOLVED] Custom mouse cursor in 7.4.x
Hi!
In my game I implemented a way to allow the user to switch between the system mouse cursor and a custom mouse cursor in the game's preferences. But since I switched to 7.4.x, this is not working anymore (as said in https://www.renpy.org/dev-doc/html/incompatible.html).
I had a look to docs, but I can't find a new way to implement this again. Is it still possible at all in 7.4.x? If, yes, how?
Thanks in advance,
Vince
In my game I implemented a way to allow the user to switch between the system mouse cursor and a custom mouse cursor in the game's preferences. But since I switched to 7.4.x, this is not working anymore (as said in https://www.renpy.org/dev-doc/html/incompatible.html).
I had a look to docs, but I can't find a new way to implement this again. Is it still possible at all in 7.4.x? If, yes, how?
Thanks in advance,
Vince
Last edited by sonejo on Wed Jan 27, 2021 1:33 pm, edited 1 time in total.
Re: Custom mouse cursor in 7.4.x
You need to use new preference https://www.renpy.org/dev-doc/html/pref ... tem_cursor
- acorn-says-no
- Regular
- Posts: 30
- Joined: Wed Jan 06, 2021 6:10 pm
- Contact:
Re: Custom mouse cursor in 7.4.x
Try this in gui.rpy
Code: Select all
define config.mouse = {"default":[ ("gui/cursor.png", 1, 1) ] }
*CHAOS, CHAOS
Re: Custom mouse cursor in 7.4.x
Thanks a lot for the hints!
This works, of course:
But I would like to allow the user to change the cursor in the preferences. I need this, since on Android, they should use the system cursor, and on pc/mac, they can decide if they want a custom cursor or the one of the system.
The old way was like this (I found it on this forum and it worked on 7.3.x):
And then in the Preferences:
This is not working anymore, even it I put
in the init code.
Any hint to get it to work? Or another way to achieve it?
Thank you so much!!
Al the best,
vince
This works, of course:
Code: Select all
define config.mouse = {"default":[ ("gui/cursor.png", 1, 1) ] }
The old way was like this (I found it on this forum and it worked on 7.3.x):
Code: Select all
init 1 python:
def change_cursor(type="default"):
persistent.mouse = type
if type == "default":
setattr(config, "mouse", None)
elif type == "pnc":
setattr(config, "mouse", {"default" : [("images/cursor_default.png", 30, 30)]})
if not hasattr(persistent, "mouse"):
change_cursor()
else:
change_cursor(persistent.mouse)
Code: Select all
label _("Cursor Style")
textbutton _("System") action [SetVariable("pnc_cursor", False), Function(change_cursor, type="default")]
textbutton _("Retro") action [SetVariable("pnc_cursor", True), Function(change_cursor, type="pnc")]
Code: Select all
$ preferences.system_cursor = False
Any hint to get it to work? Or another way to achieve it?
Thank you so much!!
Al the best,
vince
-
- Regular
- Posts: 159
- Joined: Fri Jan 04, 2019 3:44 pm
- Contact:
Re: Custom mouse cursor in 7.4.x
As Andy said in the first reply, you need to use the new preference. You can do so like this:
There is also Preference('system cursor', 'toggle') if you wish to use the same action to switch between system and custom.
Code: Select all
# This line is an example, and likely doesn't need to change in your code from what was working prior to 7.4.
define config.mouse = {'default': [('gui/cursor.png', 1, 1)]}
[...]
# The new preference to use is "system cursor" as below.
label _('Cursor Style')
textbutton _('System') action Preference('system cursor', 'enable')
textbutton _('Retro') action Preference('system cursor', 'disable')
Re: Custom mouse cursor in 7.4.x
Yeah, that works!
thank you so much!!
All the best,
Vince
thank you so much!!
All the best,
Vince
- m_from_space
- Miko-Class Veteran
- Posts: 975
- Joined: Sun Feb 21, 2021 3:36 am
- Contact:
Re: [SOLVED] Custom mouse cursor in 7.4.x
Just because I needed to change the mouse cursor on demand and it took a long time figuring it out, here is the very simple solution:
# Define all possible mouse cursors here, while 'default' is the default one.
# Switch to another cursor whenever you feel like it, e.g.
# "default_mouse" is a renpy store variable, see https://www.renpy.org/doc/html/store_va ... ault_mouse
# Or inside a screen
I hope this helps some of you.
# Define all possible mouse cursors here, while 'default' is the default one.
Code: Select all
define config.mouse = {
'action':[("images/icons/cursor_action.png",24,24)],
'back':[("images/icons/cursor_back.png",24,24)],
'default':[("images/icons/cursor_default.png",12,12)]
}
# "default_mouse" is a renpy store variable, see https://www.renpy.org/doc/html/store_va ... ault_mouse
Code: Select all
$ default_mouse = "back"
Code: Select all
screen gameover():
on "show" action SetVariable("default_mouse", "action")
on "hide" action SetVariable("default_mouse", "default")
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]