use of org.terasology.nui.layouts.CardLayout in project Terasology by MovingBlocks.
the class CardLayoutTest method setup.
@BeforeEach
public void setup() {
cardLayout = new CardLayout();
widget1 = mock(UIWidget.class);
widget2 = mock(UIWidget.class);
widget3 = mock(UIWidget.class);
canvas = mock(Canvas.class);
// +-----------------------------------+ +---+ +-------+
// | | |1x2| | |
// | 1x1 | +---+ | |
// | | | 1x3 |
// +-----------------------------------+ | |
// | |
// +-------+
when(widget1.getPreferredContentSize(eq(canvas), any(Vector2i.class))).thenReturn(new Vector2i(50, 10));
when(widget2.getPreferredContentSize(eq(canvas), any(Vector2i.class))).thenReturn(new Vector2i(5, 5));
when(widget3.getPreferredContentSize(eq(canvas), any(Vector2i.class))).thenReturn(new Vector2i(10, 15));
when(widget1.getId()).thenReturn("widget1");
when(widget2.getId()).thenReturn("widget2");
when(widget3.getId()).thenReturn("widget3");
Vector2i availableSize = new Vector2i(200, 200);
when(canvas.size()).thenReturn(availableSize);
cardLayout.addWidget(widget1);
cardLayout.addWidget(widget2);
cardLayout.addWidget(widget3);
}
use of org.terasology.nui.layouts.CardLayout in project Terasology by MovingBlocks.
the class JoinGameScreen method initialise.
@Override
public void initialise() {
setAnimationSystem(MenuAnimationSystems.createDefaultSwipeAnimation());
downloader = new ServerListDownloader(config.getNetwork().getMasterServer());
CardLayout cards = find("cards", CardLayout.class);
UIList<ServerInfo> customServerList = find("customServerList", UIList.class);
if (customServerList != null) {
customServerList.setList(config.getNetwork().getServerInfos());
configureServerList(customServerList);
}
UIList<ServerInfo> onlineServerList = find("onlineServerList", UIList.class);
if (onlineServerList != null) {
onlineServerList.setList(listedServers);
configureServerList(onlineServerList);
}
ActivateEventListener activateCustom = e -> {
cards.setDisplayedCard("customServerListScrollArea");
find("customButton", UIButton.class).setFamily("highlight");
find("onlineButton", UIButton.class).setFamily("default");
visibleList = customServerList;
refresh();
};
WidgetUtil.trySubscribe(this, "customButton", activateCustom);
ActivateEventListener activateOnline = e -> {
cards.setDisplayedCard("onlineServerListScrollArea");
find("customButton", UIButton.class).setFamily("default");
find("onlineButton", UIButton.class).setFamily("highlight");
visibleList = onlineServerList;
refresh();
};
WidgetUtil.trySubscribe(this, "onlineButton", activateOnline);
bindCustomButtons();
bindInfoLabels();
WidgetUtil.trySubscribe(this, "close", button -> {
config.save();
triggerBackAnimation();
});
activateOnline.onActivated(null);
}
Aggregations