use of com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderCallback in project Mindustry by Anuken.
the class HtmlLauncher method getPreloaderCallback.
@Override
public PreloaderCallback getPreloaderCallback() {
final Panel preloaderPanel = new VerticalPanel();
preloaderPanel.setStyleName("gdx-preloader");
final Image logo = new Image(GWT.getModuleBaseURL() + "logo.png");
logo.setStyleName("logo");
preloaderPanel.add(logo);
final Panel meterPanel = new SimplePanel();
meterPanel.setStyleName("gdx-meter");
meterPanel.addStyleName("red");
final InlineHTML meter = new InlineHTML();
final Style meterStyle = meter.getElement().getStyle();
meterStyle.setWidth(0, Unit.PCT);
meterPanel.add(meter);
preloaderPanel.add(meterPanel);
getRootPanel().add(preloaderPanel);
return new PreloaderCallback() {
@Override
public void error(String file) {
System.out.println("error: " + file);
}
@Override
public void update(PreloaderState state) {
meterStyle.setWidth(100f * state.getProgress(), Unit.PCT);
}
};
}
use of com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderCallback in project libgdx by libgdx.
the class GwtApplication method getPreloaderCallback.
public PreloaderCallback getPreloaderCallback() {
final Panel preloaderPanel = new VerticalPanel();
preloaderPanel.setStyleName("gdx-preloader");
final Image logo = new Image(GWT.getModuleBaseURL() + "logo.png");
logo.setStyleName("logo");
preloaderPanel.add(logo);
final Panel meterPanel = new SimplePanel();
meterPanel.setStyleName("gdx-meter");
meterPanel.addStyleName("red");
final InlineHTML meter = new InlineHTML();
final Style meterStyle = meter.getElement().getStyle();
meterStyle.setWidth(0, Unit.PCT);
meterPanel.add(meter);
preloaderPanel.add(meterPanel);
getRootPanel().add(preloaderPanel);
return new PreloaderCallback() {
@Override
public void error(String file) {
System.out.println("error: " + file);
}
@Override
public void update(PreloaderState state) {
meterStyle.setWidth(100f * state.getProgress(), Unit.PCT);
}
};
}
use of com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderCallback in project libgdx by libgdx.
the class GwtApplication method onModuleLoad.
@Override
public void onModuleLoad() {
GwtApplication.agentInfo = computeAgentInfo();
this.listener = createApplicationListener();
this.config = getConfig();
setApplicationLogger(new GwtApplicationLogger(this.config.log));
addEventListeners();
if (config.rootPanel != null) {
this.root = config.rootPanel;
} else {
Element element = Document.get().getElementById("embed-" + GWT.getModuleName());
if (element == null) {
VerticalPanel panel = new VerticalPanel();
panel.setWidth("" + config.width + "px");
panel.setHeight("" + config.height + "px");
panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
RootPanel.get().add(panel);
RootPanel.get().setWidth("" + config.width + "px");
RootPanel.get().setHeight("" + config.height + "px");
this.root = panel;
} else {
VerticalPanel panel = new VerticalPanel();
panel.setWidth("" + config.width + "px");
panel.setHeight("" + config.height + "px");
panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
element.appendChild(panel.getElement());
root = panel;
}
}
// initialize SoundManager2
SoundManager.init(GWT.getModuleBaseURL(), 9, config.preferFlash, new SoundManager.SoundManagerCallback() {
@Override
public void onready() {
final PreloaderCallback callback = getPreloaderCallback();
preloader = createPreloader();
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()) {
getRootPanel().clear();
if (loadingListener != null)
loadingListener.beforeSetup();
setupLoop();
if (loadingListener != null)
loadingListener.afterSetup();
}
}
});
}
@Override
public void ontimeout(String status, String errorType) {
error("SoundManager", status + " " + errorType);
}
});
}
Aggregations