Nifty 1.3.1 Lack of Unregister Screen Controller

Is there any sort of more effective workaround for this? I know that in 1.3.2, the Screen Controller stuff was changed to a Hashmap, but in Nifty 1.3.1 (or 1.3, it’s difficult to tell which version I have), you can’t unregister a screen controller. So when I try to use a new instantiation of something that’s a screen controller, the old variables are maintained (at least in the onStartScreen() method). I’ve tried tinkering around with changing the libs to 1.3.2 libs, but that ends up breaking a large amount of code I have (it compiles, just doesn’t work as intended).

I’ve considered trying to rebuild the Nifty.class file within Nifty.jar, using the Hashmap instead of whatever it is, but I have no idea what else that would break.

Any sort of guidance would be greatly appreciated.

I made that change to a hashmap, and this reason was a large part of it. (I also added an unregister method which may have gone in a few patches sooner, I don’t remember off hand). I didn’t experience any compatibility problems with upgrading though and more recent versions of jme (I believe) use that version of nifty as standard.

It could have to do with how I attempted to upgrade (I went into the libs and added some jars in there). Or it could have to do with my unorthodox ways of doing a lot of things.

Also, due to fixing centered elements (when there’s multiples), it ends up making something I’m using not work as intended (I’m currently abusing a bug; just so I can get my draggables to stay where I leave them in a droppable, while still activating it).

Either way, I tried doing 1.3.2, but a lot of stuff I had stopped working, so I dunno.

If there isn’t a feasible workaround, how do I get a version of JME with Nifty 1.3.2? I uninstalled and reinstalled it yesterday, but it was still using Nifty 1.3/1.3.1 (I can never tell which, because the JMonkey versions never seem to match the official versions :/).

I downloaded the libs from the nifty site and used these instead of the JME-provided ones.
I think that has always been working for 1.3.x. (I used 1.4 because that did some things better than 1.3, but that broke one day and didn’t get fixed before I dropped Nifty in disgust.)

Isn’t there some JME specific one too, though? There are six libraries, I think…

Either way, when I tried switching over to 1.3.2, none of the NiftyMouseEvents ever registered a click, which is a problem for my main menu (I’m not using onClick on that because I was hoping to confine my clicks and hovers to one thing [I don’t use onHover because I have non-rectangular buttons, and I had some issues between the two, if you clicked in the area that should have been clickable]).

For the specific case I’m doing, Static variables seem to help out with my issues, due to their nature.

I don’t think there is a workaround for this in 1.3.1.

Nifty 1.3.2 has been added to jme3 on Oct 7, 2012 and the latest
Nifty 1.3.3 has been added to jme3 on Jun 21, 2013.

You can check the Nifty version you have using the getVersion() method on the Nifty instance which returns a version String:

[java]String version = nifty.getVersion();[/java]

Iirc this method was introduced with Nifty 1.3.2 so if you don’t have it you have a version < 1.3.2.

In general all Nifty versions 1.3.x should be very compatible with each other so I’m not sure what caused your trouble :confused:

If possible it might be best to try with the latest nightly build of jme3 which contains the latest Nifty and see if it works there.

@void256: Well, using static variables seems like a decent enough workaround, for me at least.

I’m using the version of JME which is on the download page; which was uploaded Oct. 3, 2012, so I’m guessing I’m using 1.3.1.

As for why it broke, I’m guessing it’s because I do things differently than most people would (e.g. Using a mouse catcher to do hover effects rather than the actual hover effect); due to some of the things I’m trying to achieve. Although, when I tried going to 1.3.2 (or at least what I believe was 1.3.2, one of the other programmers on my team had gotten that, while I still had 1.3.1, somehow), it never seemed to register mouse clicks, but it registered the movement, if I recall correctly.

Also, the droppers didn’t work as I’d wanted, because you guys fixed centering multiple things in one element (and I was using the fact that was broken to get my draggables to stay where I dropped them in a droppable; no idea why that works, but it does). I’m not sure if that was changed to be the default behavior of setting the droppable’s childLayout to absolute or not, but if it wasn’t, I don’t think I’d want to upgrade anyway.

But yeah; probably not a problem with Nifty, probably more of a reliance on insane methods to get what I want done.