Cursor "hotspots"

Cursor "hotspots"

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
Erom
Posts: 1115
Joined: 25 Apr 2006, 05:08

Cursor "hotspots"

Post by Erom »

So I'm part way through creating a new set of cursors, just to move away from one bit of OTA IP, and to give mod makers a choice of cursors to use. The problem I am having is that the "hotspot", IE the actual pixel of the cursor image that is the location of the click, seems to be hardcoded to where it is in the OTA images.

For example, the default cursor (the arrow when you have nothing selected) has an active point at the top left pixel. This is all well and good when making a normal, windows-esque arrow for a cursor, but it would be nice if it was modifiable.

The active pixel for each type of cursors appears to be a set distance, in pixels from the top left of the image. Therefore unless our custom cursors follow the same general size as the OTA cursors they replace, they will not have the click point correctly positioned. Is there a configuration file somewhere I can edit, or is this hardcoded behavior?

If it's hardcoded, a patch such that Spring reads the active locations from a file in the anims directory might be in order. I know I will probably have to wright this myself, which will take a while (as I only know Java and Ada, chances are I'll have to learn a new language...)
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

It's hardcoded and it's either TopLeft (0,0) or Center (width/2, height/2).

The default cursor has it's hotspot TopLeft, all others have it in Center.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

For the centre ones, couldnt you just make th image 4x bigger and work in the bottom right corner?
User avatar
Erom
Posts: 1115
Joined: 25 Apr 2006, 05:08

Post by Erom »

The fact that it is coded as width/2, height/2 and not set numbers is good enough for me to work with. That was a smart way to set it up devs. Shame I'll have to make a more traditional default cursor than I was planning, but maybe that's for the best anyway. More traditional == easier to use.

And yes AF, that would work for moving the ones set to center.
User avatar
Erom
Posts: 1115
Joined: 25 Apr 2006, 05:08

Post by Erom »

Hah, new issue. The number of frames in each animation has to at least be the number of frames in the OTA animation, doesn't it?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

Hm, don't see anything hardcoded regarding # of frames, it just continues loading frames until all numbered bmps for that cursor are loaded.
User avatar
Comp1337
Posts: 2434
Joined: 12 Oct 2005, 17:32

Post by Comp1337 »

Meh, in the worst case just doulble it.
User avatar
Erom
Posts: 1115
Joined: 25 Apr 2006, 05:08

Post by Erom »

Yeah, I think the problem isn't in the code, it's just that I don't know how to remove the old cursors, so I'm not overwritting some of the OTA data. No matter, duplicating frames to fill the space only increases the fize by a matter of kilobytes.

Thank you for all the help, Tobi.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

cool, glad to hear it is going well erom!
esteroth12
Posts: 501
Joined: 18 May 2006, 21:19

Post by esteroth12 »

Erom wrote:Yeah, I think the problem isn't in the code, it's just that I don't know how to remove the old cursors, so I'm not overwritting some of the OTA data. No matter, duplicating frames to fill the space only increases the fize by a matter of kilobytes.

Thank you for all the help, Tobi.
wow... didnt expect you to actually start using that word... :P

out of curiousity, what cursors are you making?
User avatar
Tim Blokdijk
Posts: 1242
Joined: 29 May 2005, 11:18

Post by Tim Blokdijk »

Xect vs. Mynn has custom cursors, you can take a look at it if you like to see how it's done.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

I think you need to remove some otacontent dependency (the one with the cursors obviously) from the mod you are testing with (modinfo.tdf).
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post by Gnomre »

Yeah... it's quite easy and possible to change the cursors without any source change whatsoever. It has been since day one.

http://taspring.clan-sy.com/wiki/Mod_De ... nt:Cursors
Post Reply

Return to “Engine”