use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class SelectModulesScreen method onClosed.
@Override
public void onClosed() {
// moduleConfig passes the module collection to the Create Game Screen.
ModuleConfig moduleConfig = config.getDefaultModSelection();
moduleConfig.clear();
// Fetch all the selected/activated modules using allSortedModules
// instead of fetching only selected/activated modules from filtered collection of modules using sortedModules
allSortedModules.stream().filter(info -> info.isSelected() && info.isExplicitSelection()).forEach(info -> moduleConfig.addModule(info.getMetadata().getId()));
SimpleUri defaultGenerator = config.getWorldGeneration().getDefaultGenerator();
ModuleSelectionInfo info = modulesLookup.get(defaultGenerator.getModuleName());
if (info != null && !info.isSelected()) {
config.getWorldGeneration().setDefaultGenerator(new SimpleUri());
}
worldGenManager.refresh();
config.save();
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class PlayerSettingsScreen method initialise.
@Override
public void initialise() {
setAnimationSystem(MenuAnimationSystems.createDefaultSwipeAnimation());
storageServiceStatus = find("storageServiceStatus", UILabel.class);
storageServiceAction = find("storageServiceAction", UIButton.class);
updateStorageServiceStatus();
nametext = find("playername", UIText.class);
if (nametext != null) {
nametext.setTooltipDelay(0);
nametext.bindTooltipString(new ReadOnlyBinding<String>() {
@Override
public String get() {
return validateScreen();
}
});
}
img = find("image", UIImage.class);
if (img != null) {
ResourceUrn uri = TextureUtil.getTextureUriForColor(Color.WHITE);
Texture tex = Assets.get(uri, Texture.class).get();
img.setImage(tex);
}
slider = find("tone", UISlider.class);
if (slider != null) {
slider.setIncrement(0.01f);
// ensure a certain width
Function<Object, String> constant = Functions.constant(" ");
slider.setLabelFunction(constant);
}
heightSlider = find("height", UISlider.class);
if (heightSlider != null) {
heightSlider.setMinimum(1.5f);
heightSlider.setIncrement(0.1f);
heightSlider.setRange(0.5f);
heightSlider.setPrecision(1);
}
eyeHeightSlider = find("eye-height", UISlider.class);
if (eyeHeightSlider != null) {
eyeHeightSlider.setMinimum(0.5f);
eyeHeightSlider.setIncrement(0.1f);
eyeHeightSlider.setRange(1f);
eyeHeightSlider.setPrecision(1);
}
language = find("language", UIDropdownScrollable.class);
if (language != null) {
SimpleUri menuUri = new SimpleUri("engine:menu");
TranslationProject menuProject = translationSystem.getProject(menuUri);
List<Locale> locales = new ArrayList<>(menuProject.getAvailableLocales());
for (Locale languageExcluded : languagesExcluded) {
locales.remove(languageExcluded);
}
Collections.sort(locales, ((Object o1, Object o2) -> (o1.toString().compareTo(o2.toString()))));
language.setOptions(Lists.newArrayList(locales));
// Set maximum number of options visible for scrolling
language.setVisibleOptions(5);
language.setOptionRenderer(new LocaleRenderer(translationSystem));
}
WidgetUtil.trySubscribe(this, "close", button -> triggerBackAnimation());
IdentityIOHelper identityIOHelper = new IdentityIOHelper(context);
WidgetUtil.trySubscribe(this, "importIdentities", button -> identityIOHelper.importIdentities());
WidgetUtil.trySubscribe(this, "exportIdentities", button -> identityIOHelper.exportIdentities());
WidgetUtil.trySubscribe(this, "storageServiceAction", widget -> {
if (storageService.getStatus() == StorageServiceWorkerStatus.LOGGED_IN) {
ThreeButtonPopup logoutPopup = getManager().pushScreen(ThreeButtonPopup.ASSET_URI, ThreeButtonPopup.class);
logoutPopup.setMessage(translationSystem.translate("${engine:menu#storage-service-log-out}"), translationSystem.translate("${engine:menu#storage-service-log-out-popup}"));
logoutPopup.setLeftButton(translationSystem.translate("${engine:menu#dialog-yes}"), () -> storageService.logout(true));
logoutPopup.setCenterButton(translationSystem.translate("${engine:menu#dialog-no}"), () -> storageService.logout(false));
logoutPopup.setRightButton(translationSystem.translate("${engine:menu#dialog-cancel}"), () -> {
});
} else if (storageService.getStatus() == StorageServiceWorkerStatus.LOGGED_OUT) {
getManager().pushScreen(StorageServiceLoginPopup.ASSET_URI, StorageServiceLoginPopup.class);
}
});
UIButton okButton = find("ok", UIButton.class);
if (okButton != null) {
okButton.subscribe(button -> {
savePlayerSettings();
triggerBackAnimation();
});
okButton.bindEnabled(new ReadOnlyBinding<Boolean>() {
@Override
public Boolean get() {
return Strings.isNullOrEmpty(validateScreen());
}
});
okButton.setTooltipDelay(0);
okButton.bindTooltipString(new ReadOnlyBinding<String>() {
@Override
public String get() {
return validateScreen();
}
});
}
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class DisplayResolutionDependentFBOs method regenerateFbos.
private void regenerateFbos() {
propertyChangeSupport.firePropertyChange(PRE_FBO_REGENERATION, 0, 1);
for (SimpleUri urn : fboConfigs.keySet()) {
FBOConfig fboConfig = getFboConfig(urn);
fboConfig.setDimensions(fullScale.multiplyBy(fboConfig.getScale()));
FBO.recreate(get(urn), getFboConfig(urn));
}
propertyChangeSupport.firePropertyChange(POST_FBO_REGENERATION, 0, 1);
// Note that the "old" and "new" values (0 and 1) in the above calls aren't actually
// used: they are only necessary to ensure that the event is fired up correctly.
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class DisplayResolutionDependentFBOs method generateDefaultFBOs.
private void generateDefaultFBOs() {
FBO gBuffer1 = generateWithDimensions(new FBOConfig(new SimpleUri("engine:fbo.gBuffer1"), FULL_SCALE, FBO.Type.HDR).useDepthBuffer().useNormalBuffer().useLightBuffer().useStencilBuffer(), fullScale);
FBO gBuffer2 = generateWithDimensions(new FBOConfig(new SimpleUri("engine:fbo.gBuffer2"), FULL_SCALE, FBO.Type.HDR).useDepthBuffer().useNormalBuffer().useLightBuffer().useStencilBuffer(), fullScale);
generateWithDimensions(new FBOConfig(FINAL_BUFFER, FULL_SCALE, FBO.Type.DEFAULT), fullScale);
gBufferPair = new SwappableFBO(gBuffer1, gBuffer2);
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class ImmutableFBOs method request.
@Override
public FBO request(FBOConfig fboConfig) {
FBO fbo;
SimpleUri fboName = fboConfig.getName();
if (fboConfigs.containsKey(fboName)) {
if (!fboConfig.equals(fboConfigs.get(fboName))) {
throw new IllegalArgumentException("Requested FBO is already available with different configuration");
}
fbo = fboLookup.get(fboConfig.getName());
} else {
fbo = generateWithDimensions(fboConfig, fboConfig.getDimensions());
}
retain(fboName);
return fbo;
}
Aggregations