}
});
}
WidgetUtil.trySubscribe(this, "close", new ActivateEventListener() {
@Override
public void onActivated(UIWidget button) {
getManager().popScreen();
}
});
WidgetUtil.trySubscribe(this, "play", new ActivateEventListener() {
@Override
public void onActivated(UIWidget button) {
if (worldGenerator.getSelection() == null) {
MessagePopup errorMessagePopup = getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class);
if (errorMessagePopup != null) {
errorMessagePopup.setMessage("No World Generator Selected", "Select a world generator (you may need to activate a mod with a generator first).");
}
} else {
GameManifest gameManifest = new GameManifest();
gameManifest.setTitle(worldName.getText());
gameManifest.setSeed(seed.getText());
DependencyResolver resolver = new DependencyResolver(moduleManager.getRegistry());
ResolutionResult result = resolver.resolve(config.getDefaultModSelection().listModules());
if (!result.isSuccess()) {
MessagePopup errorMessagePopup = getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class);
if (errorMessagePopup != null) {
errorMessagePopup.setMessage("Invalid Module Selection", "Please review your module seleciton and try again");
}
return;
}
for (Module module : result.getModules()) {
gameManifest.addModule(module.getId(), module.getVersion());
}
float timeOffset = 0.25f + 0.025f; // Time at dawn + little offset to spawn in a brighter env.
WorldInfo worldInfo = new WorldInfo(TerasologyConstants.MAIN_WORLD, gameManifest.getSeed(),
(long) (WorldTime.DAY_LENGTH * timeOffset), worldGenerator.getSelection().getUri());
gameManifest.addWorld(worldInfo);
gameEngine.changeState(new StateLoading(gameManifest, (loadingAsServer) ? NetworkMode.DEDICATED_SERVER : NetworkMode.NONE));
}
}
});
UIButton previewSeed = find("previewSeed", UIButton.class);
ReadOnlyBinding<Boolean> worldGeneratorSelected = new ReadOnlyBinding<Boolean>() {
@Override
public Boolean get() {
return worldGenerator != null && worldGenerator.getSelection() != null;
}
};
previewSeed.bindEnabled(worldGeneratorSelected);
WidgetUtil.trySubscribe(this, "previewSeed", new ActivateEventListener() {
@Override
public void onActivated(UIWidget button) {
PreviewWorldScreen screen = getManager().pushScreen("engine:previewWorldScreen", PreviewWorldScreen.class);
if (screen != null) {
screen.bindSeed(BindHelper.bindBeanProperty("text", seed, String.class));
}
}
});
UIButton configButton = find("config", UIButton.class);
if (configButton != null) {
configButton.subscribe(new ActivateEventListener() {
@Override
public void onActivated(UIWidget button) {
getManager().pushScreen("engine:configWorldGen");
}
});
configButton.bindEnabled(worldGeneratorSelected);
}
WidgetUtil.trySubscribe(this, "mods", new ActivateEventListener() {
@Override
public void onActivated(UIWidget button) {
getManager().pushScreen("engine:selectModsScreen");
}
});