use of com.ldtteam.blockout.controls.ItemIcon in project minecolonies by Minecolonies.
the class RecruitmentInteraction method onWindowOpened.
@Override
@OnlyIn(Dist.CLIENT)
public void onWindowOpened(final Window window, final ICitizenDataView dataView) {
final ButtonImage recruitButton = window.findPaneOfTypeByID(BUTTON_RESPONSE_ID + 2, ButtonImage.class);
final Box group = window.findPaneOfTypeByID(RESPONSE_BOX_ID, Box.class);
if (recruitButton != null && dataView instanceof IVisitorViewData) {
final ItemStack recruitCost = ((IVisitorViewData) dataView).getRecruitCost();
final IColonyView colony = ((IVisitorViewData) dataView).getColonyView();
window.findPaneOfTypeByID(CHAT_LABEL_ID, Text.class).setText(PaneBuilders.textBuilder().append(new StringTextComponent(dataView.getName() + ": ")).append(this.getInquiry()).emptyLines(1).append(new TranslationTextComponent(colony.getCitizens().size() < colony.getCitizenCountLimit() ? "com.minecolonies.coremod.gui.chat.recruitcost" : "com.minecolonies.coremod.gui.chat.nospacerecruit", dataView.getName().split(" ")[0], recruitCost.getCount() + " " + recruitCost.getHoverName().getString())).getText());
int iconPosX = recruitButton.getX() + recruitButton.getWidth() - 28;
int iconPosY = recruitButton.getY() + recruitButton.getHeight() - 18;
ItemIcon icon = new ItemIcon();
icon.setID(RECRUITMENT_ICON);
icon.setSize(15, 15);
group.addChild(icon);
icon.setItem(((IVisitorViewData) dataView).getRecruitCost());
icon.setPosition(iconPosX, iconPosY);
icon.setVisible(true);
}
}
use of com.ldtteam.blockout.controls.ItemIcon in project minecolonies by ldtteam.
the class RequestBasedInteraction method onWindowOpened.
@Override
@OnlyIn(Dist.CLIENT)
public void onWindowOpened(final Window window, final ICitizenDataView dataView) {
final IColony colony = IColonyManager.getInstance().getColonyView(dataView.getColonyId(), Minecraft.getInstance().player.level.dimension());
if (colony != null) {
final IRequest<?> request = colony.getRequestManager().getRequestForToken(token);
if (request != null) {
final View group = window.findPaneOfTypeByID("interactionView", View.class);
ItemIcon icon = window.findPaneOfTypeByID("request_item", ItemIcon.class);
if (icon == null) {
icon = new ItemIcon();
group.addChild(icon);
}
icon.setID("request_item");
icon.setSize(32, 32);
if (!request.getDisplayStacks().isEmpty()) {
icon.setItem((request.getDisplayStacks().get(0)));
}
icon.setPosition(30, 60);
icon.setVisible(true);
}
}
}
use of com.ldtteam.blockout.controls.ItemIcon in project minecolonies by Minecolonies.
the class RequestBasedInteraction method onWindowOpened.
@Override
@OnlyIn(Dist.CLIENT)
public void onWindowOpened(final Window window, final ICitizenDataView dataView) {
final IColony colony = IColonyManager.getInstance().getColonyView(dataView.getColonyId(), Minecraft.getInstance().player.level.dimension());
if (colony != null) {
final IRequest<?> request = colony.getRequestManager().getRequestForToken(token);
if (request != null) {
final View group = window.findPaneOfTypeByID("interactionView", View.class);
ItemIcon icon = window.findPaneOfTypeByID("request_item", ItemIcon.class);
if (icon == null) {
icon = new ItemIcon();
group.addChild(icon);
}
icon.setID("request_item");
icon.setSize(32, 32);
if (!request.getDisplayStacks().isEmpty()) {
icon.setItem((request.getDisplayStacks().get(0)));
}
icon.setPosition(30, 60);
icon.setVisible(true);
}
}
}
use of com.ldtteam.blockout.controls.ItemIcon in project minecolonies by Minecolonies.
the class WindowBannerRallyGuards method onOpened.
@Override
public void onOpened() {
guardTowerList = findPaneOfTypeByID(LIST_GUARDTOWERS, ScrollingList.class);
if (isActive(banner)) {
findPaneOfTypeByID(BUTTON_RALLY, ButtonImage.class).setText(LanguageHandler.format(COM_MINECOLONIES_BANNER_RALLY_GUARDS_GUI_DISMISS));
} else {
findPaneOfTypeByID(BUTTON_RALLY, ButtonImage.class).setText(LanguageHandler.format(COM_MINECOLONIES_BANNER_RALLY_GUARDS_GUI_RALLY));
}
guardTowerList.setDataProvider(() -> getGuardTowerViews(banner).size(), (index, rowPane) -> {
final List<Pair<ILocation, AbstractBuildingGuards.View>> guardTowers = getGuardTowerViews(banner);
if (index < 0 || index >= guardTowers.size()) {
return;
}
final Pair<ILocation, AbstractBuildingGuards.View> guardTower = guardTowers.get(index);
// todo we probably want to display the exact mix.
final ItemIcon exampleStackDisplay = rowPane.findPaneOfTypeByID(ICON_GUARD, ItemIcon.class);
final AbstractBuildingGuards.View guardTowerView = guardTower.getSecond();
if (guardTowerView != null) {
exampleStackDisplay.setItem(new ItemStack(Items.IRON_SWORD));
rowPane.findPaneOfTypeByID(LABEL_GUARDTYPE, Text.class).setText(LanguageHandler.format(ModGuardTypes.knight.getJobTranslationKey()) + "|" + LanguageHandler.format(ModGuardTypes.ranger.getJobTranslationKey()) + ": " + guardTowerView.getGuards().size());
rowPane.findPaneOfTypeByID(LABEL_POSITION, Text.class).setText(guardTower.getFirst().toString());
} else {
exampleStackDisplay.setItem(new ItemStack(Items.COOKIE));
rowPane.findPaneOfTypeByID(LABEL_GUARDTYPE, Text.class).setText(LanguageHandler.format(COM_MINECOLONIES_BANNER_RALLY_GUARDS_GUI_TOWERMISSING));
rowPane.findPaneOfTypeByID(LABEL_GUARDTYPE, Text.class).setColors(Color.rgbaToInt(255, 0, 0, 1));
rowPane.findPaneOfTypeByID(LABEL_POSITION, Text.class).setText(guardTower.getFirst().toString());
}
});
}
use of com.ldtteam.blockout.controls.ItemIcon in project minecolonies by ldtteam.
the class WindowBannerRallyGuards method onOpened.
@Override
public void onOpened() {
guardTowerList = findPaneOfTypeByID(LIST_GUARDTOWERS, ScrollingList.class);
if (isActive(banner)) {
findPaneOfTypeByID(BUTTON_RALLY, ButtonImage.class).setText(LanguageHandler.format(COM_MINECOLONIES_BANNER_RALLY_GUARDS_GUI_DISMISS));
} else {
findPaneOfTypeByID(BUTTON_RALLY, ButtonImage.class).setText(LanguageHandler.format(COM_MINECOLONIES_BANNER_RALLY_GUARDS_GUI_RALLY));
}
guardTowerList.setDataProvider(() -> getGuardTowerViews(banner).size(), (index, rowPane) -> {
final List<Pair<ILocation, AbstractBuildingGuards.View>> guardTowers = getGuardTowerViews(banner);
if (index < 0 || index >= guardTowers.size()) {
return;
}
final Pair<ILocation, AbstractBuildingGuards.View> guardTower = guardTowers.get(index);
// todo we probably want to display the exact mix.
final ItemIcon exampleStackDisplay = rowPane.findPaneOfTypeByID(ICON_GUARD, ItemIcon.class);
final AbstractBuildingGuards.View guardTowerView = guardTower.getSecond();
if (guardTowerView != null) {
exampleStackDisplay.setItem(new ItemStack(Items.IRON_SWORD));
rowPane.findPaneOfTypeByID(LABEL_GUARDTYPE, Text.class).setText(LanguageHandler.format(ModGuardTypes.knight.getJobTranslationKey()) + "|" + LanguageHandler.format(ModGuardTypes.ranger.getJobTranslationKey()) + ": " + guardTowerView.getGuards().size());
rowPane.findPaneOfTypeByID(LABEL_POSITION, Text.class).setText(guardTower.getFirst().toString());
} else {
exampleStackDisplay.setItem(new ItemStack(Items.COOKIE));
rowPane.findPaneOfTypeByID(LABEL_GUARDTYPE, Text.class).setText(LanguageHandler.format(COM_MINECOLONIES_BANNER_RALLY_GUARDS_GUI_TOWERMISSING));
rowPane.findPaneOfTypeByID(LABEL_GUARDTYPE, Text.class).setColors(Color.rgbaToInt(255, 0, 0, 1));
rowPane.findPaneOfTypeByID(LABEL_POSITION, Text.class).setText(guardTower.getFirst().toString());
}
});
}
Aggregations