1

I have a PlayN game that I'm compiling to HTML5. I've build a UI in GWT, using normal DOM elements. This UI hosts the canvas on which the game is rendered.

Given a string that describes an image location, I'd like to use PlayN's client bundles to look up the image. Currently, HtmlAssetManager has a function that does something similar:

  @Override
  protected Image loadImage(String path) {
    String url = pathPrefix + path;

    AutoClientBundleWithLookup clientBundle = getBundle(path);
    if (clientBundle != null) {
      String key = getKey(path);
      ImageResource resource = (ImageResource) getResource(key, clientBundle);
      if (resource != null) {
        url = resource.getURL();
      }
    }

    return adaptImage(url);
  }

I just want the url, so I can construct an Image widget:

  @Override
  protected String loadImage(String path) {
    String url = pathPrefix + path;

    AutoClientBundleWithLookup clientBundle = getBundle(path);
    if (clientBundle != null) {
      String key = getKey(path);
      ImageResource resource = (ImageResource) getResource(key, clientBundle);
      if (resource != null) {
        url = resource.getURL();
      }
    }

    return url;
  }

Is there any way I can access this from my GWT UI code? I suppose that I could fork PlayN and subclass HtmlAssetManager, then cast PlayN.assetManager() to HtmlAssetManager, but I'd rather not.

Nick Heiner
  • 119,074
  • 188
  • 476
  • 699

0 Answers0