CursorLoader

Hey, I just wanted to import a few cursors, and replace my own limited handwritten image crap for lwjgl.

Now I can create ico files from gimp, but I can’t find out wich one is the right format for them (or if this even is another icon format), instead I get a crash from the loader, that kinda does not say any cause.

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.rangeCheck(ArrayList.java:635) ~[na:1.7.0_45]
	at java.util.ArrayList.get(ArrayList.java:411) ~[na:1.7.0_45]
	at com.jme3.cursors.plugins.CursorLoader$CursorImageData.<init>(CursorLoader.java:620) ~[bin/:na]
	at com.jme3.cursors.plugins.CursorLoader.loadCursor(CursorLoader.java:223) ~[bin/:na]
	at com.jme3.cursors.plugins.CursorLoader.load(CursorLoader.java:87) ~[bin/:na]
	at com.jme3.cursors.plugins.CursorLoader.load(CursorLoader.java:1) ~[bin/:na]
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:288) ~[bin/:na]
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:342) ~[bin/:na]
	at de.visiongamestudios.shared.jme.surfaces.lwjgl.LWJGLCursorProvider.setup(LWJGLCursorProvider.java:35) ~[bin/:na]
	at de.visiongamestudios.jme.VGSJMEClientApplication.initializeGame(VGSJMEClientApplication.java:166) ~[bin/:na]
	at de.visiongamestudios.jme.RendererApplication$4$1.run(RendererApplication.java:281) ~[bin/:na]
	at de.visiongamestudios.entitysystem.FixedRunningThreadPoolExecutor$Worker.run(FixedRunningThreadPoolExecutor.java:119) ~[bin/:na]

Images I use are 16x16 or 32x32. Is there anything special I need to keep in mind?

I haven’t tried .ico files for cursors. However, I’ve had some success loading .cur files.

1 Like

With what did you convert/generate them?

1 Like

generated using a Windows freeware app called RealWorld Cursor Editor: http://www.rw-designer.com/

1 Like

Well that software is gold for creating cursors, even animated ones :slight_smile: And as a plus it runs perfectly fine inside wine.

Now I’m unsure if this is a bug in the loader or I misuse the program, did you ever try to use a custom hotspot? (eg. for a picking cursor, where width/2 height/2 should be the middle point?)

I tried doing so using the cursor hot spot part, and in the preview it looks fine, the cursor is centerd where I would expect it. But after loading the hotspot is always 0,31 .
Any ideas for this, cause my first attempts to dig into the code where not that succesful :confused:

Edit:

Ok this seems to be indeed an error in the loader, using the same frame two times in an .ani does seem to work tho. Feels a bit hackish however.

1 Like

I always hardcode the hotspot position in Java after loading the cursor. I don’t remember why. Maybe there’s a bug; I don’t know.

1 Like