use of com.minecolonies.blockout.views.Box in project minecolonies by Minecolonies.
the class WindowRequestDetail method onOpened.
/**
* Called when the GUI has been opened.
* Will fill the fields and lists.
*/
@Override
public void onOpened() {
final String[] labels = new String[] { request.getLongDisplayString().getFormattedText() };
final Box box = findPaneOfTypeByID(BOX_ID_REQUEST, Box.class);
int y = Y_OFFSET_EACH_TEXTFIELD;
final int availableLabelWidth = box.getInteriorWidth() - 1 - box.getX();
for (final String s : labels) {
final String labelText = "§r§0" + s;
// Temporary workaround until Labels support multi-line rendering
final List<String> multilineLabelStrings = mc.fontRenderer.listFormattedStringToWidth(labelText, availableLabelWidth);
for (final String splitLabelText : multilineLabelStrings) {
final Label descriptionLabel = new Label();
descriptionLabel.setColor(BLACK, BLACK);
descriptionLabel.setLabelText(splitLabelText);
box.addChild(descriptionLabel);
descriptionLabel.setPosition(1, y);
y += Y_OFFSET_EACH_TEXTFIELD;
}
}
final ItemIcon exampleStackDisplay = findPaneOfTypeByID(LIST_ELEMENT_ID_REQUEST_STACK, ItemIcon.class);
final List<ItemStack> displayStacks = request.getDisplayStacks();
if (!displayStacks.isEmpty()) {
exampleStackDisplay.setItem(displayStacks.get((lifeCount / LIFE_COUNT_DIVIDER) % displayStacks.size()));
} else {
final Image logo = findPaneOfTypeByID(DELIVERY_IMAGE, Image.class);
logo.setVisible(true);
logo.setImage(request.getDisplayIcon());
}
final ColonyView view = ColonyManager.getColonyView(colonyId);
findPaneOfTypeByID(REQUESTER, Label.class).setLabelText(request.getRequester().getDisplayName(view.getRequestManager(), request.getToken()).getFormattedText());
final Label targetLabel = findPaneOfTypeByID(LIST_ELEMENT_ID_REQUEST_LOCATION, Label.class);
targetLabel.setLabelText(request.getRequester().getDeliveryLocation().toString());
final ColonyView colony = ColonyManager.getColonyView(colonyId);
if (colony == null) {
Log.getLogger().warn("---Colony Null in WindowRequestDetail---");
return;
}
try {
final IRequestResolver resolver = colony.getRequestManager().getResolverForRequest(request.getToken());
if (resolver == null) {
Log.getLogger().warn("---IRequestResolver Null in WindowRequestDetail---");
return;
}
findPaneOfTypeByID(RESOLVER, Label.class).setLabelText("Resolver: " + resolver.getDisplayName(view.getRequestManager(), request.getToken()).getFormattedText());
} catch (@SuppressWarnings(EXCEPTION_HANDLERS_SHOULD_PRESERVE_THE_ORIGINAL_EXCEPTIONS) final IllegalArgumentException e) {
/**
* Do nothing we just need to know if it has a resolver or not.
*/
Log.getLogger().warn("---IRequestResolver Null in WindowRequestDetail---", e);
}
box.setSize(box.getWidth(), y);
}
Aggregations