ID:136925
 
I may be missing something, so if there is already a smooth way to do this, please let me know.

For a game where objects are draggable, it's nice to have the cursor change into same icon as the dragged object (with the same icon_state and overlays as well). The only way I can see to do this is to set the mouse_drag_pointer for each object. There are two problems with this:

1. Explicitly setting a mouse_drag_pointer for an object means that the complete icon for that pointer is saved with the object in any save file you use. This greatly increases the size (and load time) of save files.

2. Last I used this (319) it was bugged in that very often you could not set the pointer if it had already been set. In other words, set it once, and you can't change it later.

I would love it if there were a simple flag to set to make the mouse_drag_pointer mimic the object, without setting it explicitely. Either that, or add a new built-in pointer value that will mean "take on the icon+state of the attached object."
Actually, both Destiny Online and Dragon Quest Online do exactly that. I'll check my code and tell you exactly how I did it, but as I recall it was a very minor thing.....

-James
In response to Jmurph
Jmurph wrote:
Actually, both Destiny Online and Dragon Quest Online do exactly that. I'll check my code and tell you exactly how I did it, but as I recall it was a very minor thing.....

-James

I'd be curious what your approach was. I had no problem making the pointer do what I wanted, but when I took a peek inside my save files, I was horrified to find that it was saving the entire icon for each drag-cursor for every object.
Skysaw wrote:

For a game where objects are draggable, it's nice to have the cursor change into same icon as the dragged object (with the same icon_state and overlays as well). The only way I can see to do this is to set the mouse_drag_pointer for each object.

Unfortunately there is no simple way to copy the overlays over to a mouse-pointer. You'd have to create a new/icon whenever you change overlays and use that for your pointer-- inefficient and cumbersome. However, we'll correct this deficiency in a future release (it's not a big deal for us). I suggest using the following syntax for copying the mouse pointers:
atom/proc/set_pointer()
mouse_drag_pointer = src
// currently only uses src.icon and icon_state;
// eventually it will account for overlays too

The other limitation is that these pointers will not stay in sync whever you change the atom's icon, icon_state, and so forth. That is easier for you to overcome, obviously (just call set_pointer whenever those change), but we should handle that on the backend too.

1. Explicitly setting a mouse_drag_pointer for an object means that the complete icon for that pointer is saved with the object in any save file you use. This greatly increases the size (and load time) of save files.

Good point. Perhaps the above assignment should account fo rthis. For now, you can override your mob/Write() routine to set the pointers to null at the beginning and reset them back at the end, eg:
mob/Write(F)
var/old = mouse_drag_pointer
mouse_drag_pointer = null
. = ..()
mouse_drag_pointer = old


2. Last I used this (319) it was bugged in that very often you could not set the pointer if it had already been set. In other words, set it once, and you can't change it later.

I was unable to reproduce this problem in the latest release. We have not futzed with the pointer code for a while though, so I doubt anything has changed. If you are still having trouble reassigning pointers, please post a snippet or send us an example.

I would love it if there were a simple flag to set to make the mouse_drag_pointer mimic the object, without setting it explicitely. Either that, or add a new built-in pointer value that will mean "take on the icon+state of the attached object."

Right, I think that the 'mouse_pointer = usr' assignment should handle it this way.
In response to Tom
Tom wrote:
I would love it if there were a simple flag to set to make the mouse_drag_pointer mimic the object, without setting it explicitely. Either that, or add a new built-in pointer value that will mean "take on the icon+state of the attached object."

Right, I think that the 'mouse_pointer = usr' assignment should handle it this way.

I may take your suggestion on setting pointers to null before saving... that may be the ticket.

mouse_pointer = src (you did mean source, right?) would be a lot more helpful for me if I didn't keep changing icon states. I guess I'll write up a little proc to keep pointers in sync.

Thanks for the response!
Skysaw wrote:
For a game where objects are draggable, it's nice to have the cursor change into same icon as the dragged object (with the same icon_state and overlays as well). The only way I can see to do this is to set the mouse_drag_pointer for each object.

There might be some other requirement I don't realize, but why not just set the player's cursor when they start dragging?

That's what DragonSnot and my dormant Checkers program do, and it works fine. When they start dragging I set their cursor, when they stop dragging, I reset it.
In response to Deadron
Deadron wrote:
Skysaw wrote:
For a game where objects are draggable, it's nice to have the cursor change into same icon as the dragged object (with the same icon_state and overlays as well). The only way I can see to do this is to set the mouse_drag_pointer for each object.

There might be some other requirement I don't realize, but why not just set the player's cursor when they start dragging?

That's what DragonSnot and my dormant Checkers program do, and it works fine. When they start dragging I set their cursor, when they stop dragging, I reset it.

Ah... it's those last three words that lit a little lightbulb in my head. Of course! Just set them to null when you're done dragging!

Many thanks for the idea!
In response to Skysaw
Yeah,I checked my code last night and that's exactly what I did, but I found it could be really annoying with small, oddly shaped, or dark objects. So for now I just have a generic cursor, a clicked down cursor, and a dragging cursor.

-James
In response to Jmurph
Jmurph wrote:
Yeah,I checked my code last night and that's exactly what I did, but I found it could be really annoying with small, oddly shaped, or dark objects. So for now I just have a generic cursor, a clicked down cursor, and a dragging cursor.

-James

In Murder Most Beautiful I have the drag cursur turn into the object, with an overlay of a grasping hand. The effect is very cool, and since the game doesn't use save files, I'm happy :-)
In response to Skysaw
Skysaw when will you be hosting Murder Most Beautiful again.
In response to Exadv1
Exadv1 wrote:
Skysaw when will you be hosting Murder Most Beautiful again.

As soon as people stop requesting things for MLAAS :-P

Actually, I am hoping to get the bulk of MLAAS finished within the next three weeks, then go to MMB, which should be much faster to code, as it's less open-ended.