use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.
the class NUIManagerInternal method pushScreen.
@Override
public void pushScreen(UIScreenLayer screen) {
TabbingManager.setInitialized(false);
if (!screen.isLowerLayerVisible()) {
UIScreenLayer current = screens.peek();
if (current != null) {
current.onHide();
}
}
screens.push(screen);
screen.onOpened();
String id = screen.getId();
if (ResourceUrn.isValid(id)) {
ResourceUrn uri = new ResourceUrn(id);
screenLookup.put(uri, screen);
}
}
use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.
the class NUIManagerInternal method invalidate.
@Override
public void invalidate() {
assetManager.getLoadedAssets(UIElement.class).forEach(UIElement::dispose);
boolean hudVisible = isHUDVisible();
if (hudVisible) {
setHUDVisible(false);
}
Deque<ResourceUrn> reverseUrns = new LinkedList<>();
Map<UIScreenLayer, ResourceUrn> inverseLookup = screenLookup.inverse();
for (UIScreenLayer screen : screens) {
screen.onClosed();
reverseUrns.addFirst(inverseLookup.get(screen));
}
screens.clear();
screenLookup.clear();
reverseUrns.forEach(this::pushScreen);
if (hudVisible) {
setHUDVisible(true);
}
}
use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.
the class NUIEditorSettingsScreen method initialise.
@Override
public void initialise() {
WidgetUtil.tryBindCheckbox(this, "disableAutosave", BindHelper.bindBeanProperty("disableAutosave", config.getNuiEditor(), Boolean.TYPE));
WidgetUtil.tryBindCheckbox(this, "disableIcons", BindHelper.bindBeanProperty("disableIcons", config.getNuiEditor(), Boolean.TYPE));
WidgetUtil.trySubscribe(this, "close", button -> getManager().closeScreen(ASSET_URI));
alternativeLocale = find("alternativeLocale", UIDropdownScrollable.class);
if (alternativeLocale != null) {
// Build the list of available locales and set the dropdown's options to them.
TranslationProject menuProject = translationSystem.getProject(new ResourceUrn("engine:menu"));
List<Locale> locales = new ArrayList<>(menuProject.getAvailableLocales());
Collections.sort(locales, ((Object o1, Object o2) -> (o1.toString().compareTo(o2.toString()))));
alternativeLocale.setOptions(Lists.newArrayList(locales));
alternativeLocale.setVisibleOptions(5);
alternativeLocale.setOptionRenderer(new LocaleRenderer(translationSystem));
// If an alternative locale has been previously selected, select it; otherwise select the system locale.
if (config.getNuiEditor().getAlternativeLocale() != null) {
alternativeLocale.setSelection(config.getNuiEditor().getAlternativeLocale());
} else {
alternativeLocale.setSelection(systemConfig.locale.get());
}
}
}
use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.
the class WorldPreGenerationScreen method genTexture.
/**
* Generates a texture and sets it to the image view, thus previewing the world.
*/
private void genTexture() {
int imgWidth = 384;
int imgHeight = 384;
ByteBuffer buffer = ByteBuffer.allocateDirect(imgWidth * imgHeight * Integer.BYTES);
ByteBuffer[] data = new ByteBuffer[] { buffer };
ResourceUrn uri = new ResourceUrn("engine:terrainPreview");
TextureData texData = new TextureData(imgWidth, imgHeight, data, Texture.WrapMode.CLAMP, Texture.FilterMode.LINEAR);
texture = Assets.generateAsset(uri, texData, Texture.class);
previewImage = find("preview", UIImage.class);
previewImage.setImage(texture);
}
use of org.terasology.gestalt.assets.ResourceUrn in project Terasology by MovingBlocks.
the class SelectionScreen method loadPreviewImages.
private void loadPreviewImages(final GameInfo gameInfo) {
List<Texture> textures = new ArrayList<>();
if (gameInfo != null && gameInfo.getSavePath() != null) {
final List<BufferedImage> bufferedImages = GamePreviewImageProvider.getAllPreviewImages(gameInfo.getSavePath());
textures = bufferedImages.stream().map(buffImage -> {
TextureData textureData;
try {
textureData = AWTTextureFormat.convertToTextureData(buffImage, Texture.FilterMode.LINEAR);
} catch (IOException e) {
logger.error("Converting preview image to texture data {} failed", e);
return null;
}
return Assets.generateAsset(new ResourceUrn(PREVIEW_IMAGE_URI_PATTERN + bufferedImages.indexOf(buffImage)), textureData, Texture.class);
}).filter(Objects::nonNull).collect(Collectors.toList());
}
if (textures.isEmpty()) {
textures.add(Assets.getTexture(DEFAULT_PREVIEW_IMAGE_URI).get());
}
previewSlideshow.clean();
textures.forEach(tex -> {
UIImage image = new UIImage(null, tex, true);
previewSlideshow.addImage(image);
});
}
Aggregations