From f72d5c20fd6a6815d8ae7ee2d09bf6902f69918f Mon Sep 17 00:00:00 2001 From: "sha..rd" Date: Sun, 1 May 2011 05:00:04 +0000 Subject: [PATCH] * Nifty Gui now uses jME3 AssetManager to find XML files git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7378 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../com/jme3/niftygui/NiftyJmeDisplay.java | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/engine/src/niftygui/com/jme3/niftygui/NiftyJmeDisplay.java b/engine/src/niftygui/com/jme3/niftygui/NiftyJmeDisplay.java index 4f30be8be..df2cd6494 100644 --- a/engine/src/niftygui/com/jme3/niftygui/NiftyJmeDisplay.java +++ b/engine/src/niftygui/com/jme3/niftygui/NiftyJmeDisplay.java @@ -32,6 +32,8 @@ package com.jme3.niftygui; +import com.jme3.asset.AssetInfo; +import com.jme3.asset.AssetKey; import com.jme3.asset.AssetManager; import com.jme3.audio.AudioRenderer; import com.jme3.input.InputManager; @@ -43,8 +45,12 @@ import com.jme3.renderer.queue.RenderQueue; import com.jme3.texture.FrameBuffer; import de.lessvoid.nifty.Nifty; import de.lessvoid.nifty.tools.TimeProvider; +import de.lessvoid.nifty.tools.resourceloader.ResourceLoader; +import de.lessvoid.nifty.tools.resourceloader.ResourceLocation; +import java.io.InputStream; +import java.net.URL; -public class NiftyJmeDisplay extends TimeProvider implements SceneProcessor { +public class NiftyJmeDisplay implements SceneProcessor { protected boolean inited = false; protected Nifty nifty; @@ -55,10 +61,22 @@ public class NiftyJmeDisplay extends TimeProvider implements SceneProcessor { protected SoundDeviceJme soundDev; protected Renderer renderer; protected ViewPort vp; + + protected ResourceLocationJme resourceLocation; protected int w, h; - public NiftyJmeDisplay() { + protected class ResourceLocationJme implements ResourceLocation { + + public InputStream getResourceAsStream(String path) { + AssetKey key = new AssetKey(path); + AssetInfo info = assetManager.locateAsset(key); + return info.openStream(); + } + + public URL getResource(String path) { + throw new UnsupportedOperationException(); + } } public NiftyJmeDisplay(AssetManager assetManager, @@ -70,13 +88,17 @@ public class NiftyJmeDisplay extends TimeProvider implements SceneProcessor { w = vp.getCamera().getWidth(); h = vp.getCamera().getHeight(); + resourceLocation = new ResourceLocationJme(); + ResourceLoader.removeAllResourceLocations(); + ResourceLoader.addResourceLocation(resourceLocation); + soundDev = new SoundDeviceJme(assetManager, audioRenderer); renderDev = new RenderDeviceJme(this); inputSys = new InputSystemJme(inputManager); if (inputManager != null) inputManager.addRawInputListener(inputSys); - nifty = new Nifty(renderDev, soundDev, inputSys, this); + nifty = new Nifty(renderDev, soundDev, inputSys, new TimeProvider()); inputSys.setNifty(nifty); }