Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Problem regarding resource locations

HariboTer
2013-01-27
2013-02-09
  • HariboTer
    HariboTer
    2013-01-27

    After I got Nifty GUI finally running with Slick in my Eclipse workspace (not without a lot of research and still external help after all), Nifty doesn't find the resourcebundle (some primitive dialog file). Where do they have to be located, relative to the main-xml-file or the nifty library? According to that, how would the filename have to be "built"? Does this also apply to custom style files, or do their paths have to follow other rules?
    Any help would be deeply appreciated.

     
    Last edit: HariboTer 2013-01-27
  • HariboTer
    HariboTer
    2013-01-27

    Registering the font outgoing from the code itself worked, but I'd still prefer it if this could be done in the xml. Nevertheless, Nifty keeps crashing, now with the exception

    Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.newdawn.slick.Font.getWidth(Ljava/lang/String;)I

    Interestingly do I neither try to add a font, nor try to use an existing one. I use the newest version of Slick (Build #264) and NiftyGUI (1.3.2) (that I could find), should I use other ones?

     
    Last edit: HariboTer 2013-02-09
  • void256
    void256
    2013-02-06

    I can't remember exactly if we had dicussed this problem before somewhere - I'm pretty sure we did but I can't find it right now :/

    You'll need to use the slick2d version that the Nifty renderer was build for. At the moment that is this one: http://slick.cokeandcode.com/mavenrepo/slick/slick/274/

     
  • HariboTer
    HariboTer
    2013-02-09

    With the maven build I got it ... well, at least not to crash seemingly spontaneously. But unfortunately, I am still struggling with major problems with ResourceLocation. Since I still had no actual clue regarding that matter, I tried looking it up in the jME3 source code via its SDK, which pointed me to the ResourceLocation class.
    Since I have all resources in a folder called "data" among the .class files, I tried to add a ResourceLocation like the following (code shortened a bit):

    nifty.getResourceLoader().addResourceLocation(new ResourceLocation(){
    @Override
    public InputStream getResourceAsStream(String ref) { Logger.print(ref);
    return getClass().getResourceAsStream("data/" + ref);
    });

    This causes it to find the xml when I let Nifty read from xml per

    nifty.fromXml("interface/nifty/main.xml", "start");

    But when it comes to the xml line which is

    it crashes with a MissingResourceException due to exactly that line.
    When I let my custom ResourceLocation print out the path with which it was called, I was afraid that Nifty does not even look the file up in that ResourceLocation object before it crashes! Removing all resource locations seems clearly not advisable to me, I wouldn't know with what kind of ResourceLocations to refill it and it's an unpredictable operation to me too.
    Trying to load the dialog file per code does not throw an exception

    nifty.registerResourceBundle("dialog", getClass().getResource("data/interface/nifty/lang/dialog.properties").getFile());

    but I found out that I could point it to whereever I'd like to, it stays nice and calm and does not cause the resourcebundle to be used anyway, so I get the {dialog.something} strings on the menu nevertheless.

    So once again I am fully relying on your help and am really stuck there, with only a backwards option that I don't like at all. Help would be much appreciated, again ....