use of org.terasology.nui.layouts.ScrollableArea in project Terasology by MovingBlocks.
the class TelemetryScreen method refreshContent.
private void refreshContent() {
ColumnLayout mainLayout = new ColumnLayout();
mainLayout.setHorizontalSpacing(8);
mainLayout.setVerticalSpacing(8);
fetchTelemetryCategoriesFromEngineOnlyEnvironment();
for (Map.Entry<TelemetryCategory, Class> telemetryCategory : telemetryCategories.entrySet()) {
Class metricClass = telemetryCategory.getValue();
Optional<Metric> optional = metrics.getMetric(metricClass);
if (optional.isPresent()) {
Metric metric = optional.get();
Map<String, ?> map = metric.createTelemetryFieldToValue();
if (map != null) {
addTelemetrySection(telemetryCategory.getKey(), mainLayout, map);
}
}
}
ScrollableArea area = find("area", ScrollableArea.class);
if (area != null) {
area.setContent(mainLayout);
}
}
use of org.terasology.nui.layouts.ScrollableArea in project Terasology by MovingBlocks.
the class ChatScreen method initialise.
@Override
public void initialise() {
final ScrollableArea scrollArea = find("scrollArea", ScrollableArea.class);
scrollArea.moveToBottom();
commandLine = find("commandLine", UIText.class);
getManager().setFocus(commandLine);
commandLine.subscribe(widget -> {
String text = commandLine.getText();
if (StringUtils.isNotBlank(text)) {
String command = "say";
List<String> params = Collections.singletonList(text);
// TODO: move command execution to separate class
console.execute(new Name(command), params, localPlayer.getClientEntity());
commandLine.setText("");
scrollArea.moveToBottom();
NotificationOverlay overlay = nuiManager.addOverlay(NotificationOverlay.ASSET_URI, NotificationOverlay.class);
overlay.setVisible(true);
nuiManager.closeScreen(this);
} else {
commandLine.setText("");
nuiManager.closeScreen(this);
}
});
final UILabel history = find("messageHistory", UILabel.class);
history.bindText(new ReadOnlyBinding<String>() {
@Override
public String get() {
Iterable<Message> messageIterable = console.getMessages(CoreMessageType.CHAT, CoreMessageType.NOTIFICATION);
Stream<Message> messageStream = StreamSupport.stream(messageIterable.spliterator(), false);
return messageStream.map(Message::getMessage).collect(Collectors.joining(Console.NEW_LINE));
}
});
}
use of org.terasology.nui.layouts.ScrollableArea in project Terasology by MovingBlocks.
the class ConsoleScreen method initialise.
@Override
public void initialise() {
setAnimationSystem(new SwipeMenuAnimationSystem(0.2f, Direction.TOP_TO_BOTTOM));
final ScrollableArea scrollArea = find("scrollArea", ScrollableArea.class);
scrollArea.moveToBottom();
commandLine = find("commandLine", UICommandEntry.class);
getManager().setFocus(commandLine);
commandLine.setTabCompletionEngine(new CyclingTabCompletionEngine(console, localPlayer));
commandLine.bindCommandHistory(new ReadOnlyBinding<List<String>>() {
@Override
public List<String> get() {
return console.getPreviousCommands();
}
});
commandLine.subscribe(widget -> {
String text = commandLine.getText();
if (StringUtils.isNotBlank(text)) {
console.execute(text, localPlayer.getClientEntity());
}
scrollArea.moveToBottom();
});
final UIText history = find("messageHistory", UIText.class);
history.bindText(new ReadOnlyBinding<String>() {
@Override
public String get() {
StringBuilder messageList = new StringBuilder();
for (Message message : console.getMessages()) {
messageList.append(FontColor.getColored(message.getMessage(), message.getType().getColor()));
if (message.hasNewLine()) {
messageList.append(Console.NEW_LINE);
}
}
return messageList.toString();
}
});
}
use of org.terasology.nui.layouts.ScrollableArea in project Terasology by MovingBlocks.
the class CoreScreenLayer method iterateThrough.
private void iterateThrough(Iterator<UIWidget> widgets) {
modifyingList = true;
while (widgets.hasNext()) {
UIWidget next = widgets.next();
boolean setParent = false;
if (next instanceof ScrollableArea) {
parentToSet = (ScrollableArea) next;
}
if (next instanceof WidgetWithOrder) {
TabbingManager.addToWidgetsList((WidgetWithOrder) next);
TabbingManager.addToUsedNums(((WidgetWithOrder) next).getOrder());
((WidgetWithOrder) next).setParent(parentToSet);
}
if (next.iterator().hasNext()) {
iterateThrough(next.iterator());
} else if (next instanceof UIRadialRing) {
Iterator<UIRadialSection> iter = ((UIRadialRing) next).getSections().iterator();
while (iter.hasNext()) {
next = iter.next();
TabbingManager.addToWidgetsList((WidgetWithOrder) next);
TabbingManager.addToUsedNums(((WidgetWithOrder) next).getOrder());
if (setParent) {
((WidgetWithOrder) next).setParent(parentToSet);
}
}
}
}
modifyingList = false;
}
Aggregations