@@ -0,0 +1,1978 @@
+package net.mgsx.game.core.helpers;%0A%0Aimport java.io.IOException;%0A%0Aimport com.badlogic.gdx.Gdx;%0Aimport com.badlogic.gdx.graphics.Texture;%0Aimport com.badlogic.gdx.graphics.g2d.TextureRegion;%0Aimport com.badlogic.gdx.scenes.scene2d.ui.Image;%0Aimport com.badlogic.gdx.scenes.scene2d.utils.BaseDrawable;%0Aimport com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;%0Aimport com.badlogic.gdx.utils.Align;%0Aimport com.badlogic.gdx.utils.Scaling;%0A%0Aimport net.mgsx.game.core.helpers.DownloadHelper.DownloadCallback;%0A%0Apublic class RemoteImage extends Image%0A%7B%0A%09/**%0A%09 * Replace image texture by a remote texture.%0A%09 * @param image%0A%09 * @param url%0A%09 */%0A%09public static void load(final Image image, final String url)%0A%09%7B%0A%09%09DownloadHelper.enqueueJob(new Runnable() %7B%0A%09%09%09@Override%0A%09%09%09public void run() %7B%0A%09%09%09%09try %7B%0A%09%09%09%09%09DownloadHelper.downloadTextureDirect(url, new DownloadCallback%3CTexture%3E() %7B%0A%09%09%09%09%09%09@Override%0A%09%09%09%09%09%09public void onSuccess(Texture texture) %7B%0A%09%09%09%09%09%09%09image.setDrawable(new TextureRegionDrawable(new TextureRegion(texture)));%0A%09%09%09%09%09%09%09image.invalidate();%0A%09%09%09%09%09%09%7D%0A%0A%09%09%09%09%09%09@Override%0A%09%09%09%09%09%09public void onError(Throwable e) %7B%0A%09%09%09%09%09%09%09Gdx.app.error(%22Net%22, %22Error downloading URL %22 + url, e);%0A%09%09%09%09%09%09%7D%0A%09%09%09%09%09%7D);%0A%09%09%09%09%7D catch (IOException e) %7B%0A%09%09%09%09%09Gdx.app.error(%22Net%22, %22Error downloading URL %22 + url, e);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D);%0A%09%7D%0A%09%0A%09public RemoteImage(String url, final int width, final int height, Scaling scaling, int align) %7B%0A%09%09super(new BaseDrawable()%7B%0A%09%09%09@Override%0A%09%09%09public float getMinWidth() %7B%0A%09%09%09%09return width;%0A%09%09%09%7D%0A%09%09%09@Override%0A%09%09%09public float getMinHeight() %7B%0A%09%09%09%09return height;%0A%09%09%09%7D%0A%09%09%7D, scaling, align);%0A%09%09load(this, url);%0A%09%7D%0A%09%0A%09public RemoteImage(String url, final int width, final int height, Scaling scaling) %7B%0A%09%09this(url, width, height, scaling, Align.center);%0A%09%7D%0A%09public RemoteImage(String url, final int width, final int height) %7B%0A%09%09this(url, width, height, Scaling.stretch, Align.center);%0A%09%7D%0A%09public RemoteImage(String url) %7B%0A%09%09this(url, 0, 0, Scaling.stretch, Align.center);%0A%09%7D%0A%7D%0A

add remote image helper