Search in sources :

Example 1 with SwipeMenuAnimationSystem

use of org.terasology.rendering.nui.animation.SwipeMenuAnimationSystem 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();
        }
    });
}
Also used : SwipeMenuAnimationSystem(org.terasology.rendering.nui.animation.SwipeMenuAnimationSystem) Message(org.terasology.logic.console.Message) ScrollableArea(org.terasology.rendering.nui.layouts.ScrollableArea) UIText(org.terasology.rendering.nui.widgets.UIText) List(java.util.List)

Aggregations

List (java.util.List)1 Message (org.terasology.logic.console.Message)1 SwipeMenuAnimationSystem (org.terasology.rendering.nui.animation.SwipeMenuAnimationSystem)1 ScrollableArea (org.terasology.rendering.nui.layouts.ScrollableArea)1 UIText (org.terasology.rendering.nui.widgets.UIText)1