html: GwtApplication cleanup + formatting

This commit is contained in:
Hannes Janetzek 2013-07-01 04:15:37 +02:00
parent ead0594d81
commit 7d225aabba

View File

@ -109,37 +109,23 @@ public abstract class GwtApplication implements EntryPoint, Application {
} }
} }
// initialize SoundManager2 final PreloaderCallback callback = getPreloaderCallback();
//SoundManager.init(GWT.getModuleBaseURL(), 9); preloader = new Preloader();
preloader.preload("assets.txt", new PreloaderCallback() {
// wait for soundmanager to load, this is fugly, but for
// some reason the ontimeout and onerror callbacks are never
// called (function instanceof Function fails, wtf JS?).
new Timer() {
@Override @Override
public void run() { public void error(String file) {
//if (SoundManager.ok()) { callback.error(file);
final PreloaderCallback callback = getPreloaderCallback();
preloader = new Preloader();
preloader.preload("assets.txt", new PreloaderCallback() {
@Override
public void error(String file) {
callback.error(file);
}
@Override
public void update(PreloaderState state) {
callback.update(state);
if (state.hasEnded()) {
root.clear();
setupLoop();
}
}
});
cancel();
//}
} }
}.scheduleRepeating(100);
@Override
public void update(PreloaderState state) {
callback.update(state);
if (state.hasEnded()) {
root.clear();
setupLoop();
}
}
});
} }
private void setupLoop() { private void setupLoop() {
@ -167,14 +153,14 @@ public abstract class GwtApplication implements EntryPoint, Application {
this.net = new GwtNet(); this.net = new GwtNet();
Gdx.net = this.net; Gdx.net = this.net;
final double pixelRatio = GwtGraphics.getDevicePixelRatioJSNI(); final double pixelRatio = GwtGraphics.getDevicePixelRatioJSNI();
consoleLog(">>>> " + config.width + "x"+ config.height + " ratio " + pixelRatio); consoleLog("> " + config.width + "x" + config.height + " ratio:" + pixelRatio);
// tell listener about app creation // tell listener about app creation
try { try {
listener.create(); listener.create();
listener.resize( listener.resize(
(int)(graphics.getWidth()), (int) (graphics.getWidth()),
(int)(graphics.getHeight())); (int) (graphics.getHeight()));
} catch (Throwable t) { } catch (Throwable t) {
error("GwtApplication", "exception: " + t.getMessage(), t); error("GwtApplication", "exception: " + t.getMessage(), t);
t.printStackTrace(); t.printStackTrace();
@ -187,13 +173,13 @@ public abstract class GwtApplication implements EntryPoint, Application {
public void run() { public void run() {
try { try {
graphics.update(); graphics.update();
if (Gdx.graphics.getWidth() != lastWidth if (graphics.getWidth() != lastWidth
|| Gdx.graphics.getHeight() != lastHeight) { || graphics.getHeight() != lastHeight) {
GwtApplication.this.listener.resize(
(int)(Gdx.graphics.getWidth()),
(int)(Gdx.graphics.getHeight()));
lastWidth = graphics.getWidth(); lastWidth = graphics.getWidth();
lastHeight = graphics.getHeight(); lastHeight = graphics.getHeight();
GwtApplication.this.listener.resize(lastWidth, lastHeight);
//Gdx.gl.glViewport(0, 0, lastWidth, lastHeight); //Gdx.gl.glViewport(0, 0, lastWidth, lastHeight);
} }
runnablesHelper.addAll(runnables); runnablesHelper.addAll(runnables);