* 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
This commit is contained in:
parent
3ed2824cc3
commit
f72d5c20fd
@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
package com.jme3.niftygui;
|
package com.jme3.niftygui;
|
||||||
|
|
||||||
|
import com.jme3.asset.AssetInfo;
|
||||||
|
import com.jme3.asset.AssetKey;
|
||||||
import com.jme3.asset.AssetManager;
|
import com.jme3.asset.AssetManager;
|
||||||
import com.jme3.audio.AudioRenderer;
|
import com.jme3.audio.AudioRenderer;
|
||||||
import com.jme3.input.InputManager;
|
import com.jme3.input.InputManager;
|
||||||
@ -43,8 +45,12 @@ import com.jme3.renderer.queue.RenderQueue;
|
|||||||
import com.jme3.texture.FrameBuffer;
|
import com.jme3.texture.FrameBuffer;
|
||||||
import de.lessvoid.nifty.Nifty;
|
import de.lessvoid.nifty.Nifty;
|
||||||
import de.lessvoid.nifty.tools.TimeProvider;
|
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 boolean inited = false;
|
||||||
protected Nifty nifty;
|
protected Nifty nifty;
|
||||||
@ -55,10 +61,22 @@ public class NiftyJmeDisplay extends TimeProvider implements SceneProcessor {
|
|||||||
protected SoundDeviceJme soundDev;
|
protected SoundDeviceJme soundDev;
|
||||||
protected Renderer renderer;
|
protected Renderer renderer;
|
||||||
protected ViewPort vp;
|
protected ViewPort vp;
|
||||||
|
|
||||||
|
protected ResourceLocationJme resourceLocation;
|
||||||
|
|
||||||
protected int w, h;
|
protected int w, h;
|
||||||
|
|
||||||
public NiftyJmeDisplay() {
|
protected class ResourceLocationJme implements ResourceLocation {
|
||||||
|
|
||||||
|
public InputStream getResourceAsStream(String path) {
|
||||||
|
AssetKey<Object> key = new AssetKey<Object>(path);
|
||||||
|
AssetInfo info = assetManager.locateAsset(key);
|
||||||
|
return info.openStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
public URL getResource(String path) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public NiftyJmeDisplay(AssetManager assetManager,
|
public NiftyJmeDisplay(AssetManager assetManager,
|
||||||
@ -70,13 +88,17 @@ public class NiftyJmeDisplay extends TimeProvider implements SceneProcessor {
|
|||||||
w = vp.getCamera().getWidth();
|
w = vp.getCamera().getWidth();
|
||||||
h = vp.getCamera().getHeight();
|
h = vp.getCamera().getHeight();
|
||||||
|
|
||||||
|
resourceLocation = new ResourceLocationJme();
|
||||||
|
ResourceLoader.removeAllResourceLocations();
|
||||||
|
ResourceLoader.addResourceLocation(resourceLocation);
|
||||||
|
|
||||||
soundDev = new SoundDeviceJme(assetManager, audioRenderer);
|
soundDev = new SoundDeviceJme(assetManager, audioRenderer);
|
||||||
renderDev = new RenderDeviceJme(this);
|
renderDev = new RenderDeviceJme(this);
|
||||||
inputSys = new InputSystemJme(inputManager);
|
inputSys = new InputSystemJme(inputManager);
|
||||||
if (inputManager != null)
|
if (inputManager != null)
|
||||||
inputManager.addRawInputListener(inputSys);
|
inputManager.addRawInputListener(inputSys);
|
||||||
|
|
||||||
nifty = new Nifty(renderDev, soundDev, inputSys, this);
|
nifty = new Nifty(renderDev, soundDev, inputSys, new TimeProvider());
|
||||||
inputSys.setNifty(nifty);
|
inputSys.setNifty(nifty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user