Can't load multiple xml files with screens

Hi,



I have separate xml files for each screen. To keep code clean and not having to scroll for a decade everytime I work with it.

Anyways, if I load two, one of them is excluded.

This is how I load them:

[java]private void setupMenu() {

NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(getAsset(),getInput(), getAudio(), getGuiViewPort());

nifty = niftyDisplay.getNifty();



nifty.fromXml(“MainMenu.xml”, “end”);

nifty.fromXml(“Maps.xml”,“Maps”);

getGuiViewPort().addProcessor(niftyDisplay);

nifty.addControls();

nifty.gotoScreen(“MainMenu”);

}[/java]

This does not work.



If I have the maps.xml with then it will not go to “MainMenu” but simply stay at maps.

If I load maps.xml before MainMenu.xml it will still be stuck at maps.

If I load maps.xml using nifty.fromXmlWithoutStartScreen(“Maps.xml”); then it will complan and say “MainMenu” not found.

But if I remove the whole maps.xml line, then it loads MainMenu with no problem what so ever.



Can someone explain to me why and how to fix it?

Use AddXML

1 Like

[java]nifty.fromXml("MainMenu.xml", "end");[/java]



loads the MainMenu.xml…Ok but before loading it, fromXml method remove all nifty components…so when you load map.xml, you remove MainMenu before display Maps.



If you want mix some nifty xml files you need to load the main screen like MainMenu.xml and then just use the AddXml method which load the new xml file without erase data which are already loaded.



So you might be try something like that :

[java] nifty.fromXml("MainMenu.xml", "end");

nifty.addXml("Maps.xml");[/java]



EDIT : 2 minutes late (post writing) :wink:

1 Like

Ahh thanks guys :smiley:

This is one of the first things covered in the Nifty Bible, might be worth reading it again :smiley:

@haze said:
EDIT : 2 minutes late (post writing) ;)


yh but your answer is a bit better, than my "Sneak on jME with my phone at work while on the bog" responses :)