Search in sources :

Example 1 with ItemIcon

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);
    }
}
Also used : ButtonImage(com.ldtteam.blockout.controls.ButtonImage) ItemIcon(com.ldtteam.blockout.controls.ItemIcon) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Box(com.ldtteam.blockout.views.Box) Text(com.ldtteam.blockout.controls.Text) StringTextComponent(net.minecraft.util.text.StringTextComponent) ItemStack(net.minecraft.item.ItemStack) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 2 with ItemIcon

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);
        }
    }
}
Also used : ItemIcon(com.ldtteam.blockout.controls.ItemIcon) View(com.ldtteam.blockout.views.View) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 3 with ItemIcon

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);
        }
    }
}
Also used : ItemIcon(com.ldtteam.blockout.controls.ItemIcon) View(com.ldtteam.blockout.views.View) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 4 with ItemIcon

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());
        }
    });
}
Also used : AbstractBuildingGuards(com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards) ILocation(com.minecolonies.api.colony.requestsystem.location.ILocation) ButtonImage(com.ldtteam.blockout.controls.ButtonImage) ItemIcon(com.ldtteam.blockout.controls.ItemIcon) Text(com.ldtteam.blockout.controls.Text) ItemStack(net.minecraft.item.ItemStack) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pair(com.mojang.datafixers.util.Pair)

Example 5 with ItemIcon

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());
        }
    });
}
Also used : AbstractBuildingGuards(com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards) ILocation(com.minecolonies.api.colony.requestsystem.location.ILocation) ButtonImage(com.ldtteam.blockout.controls.ButtonImage) ItemIcon(com.ldtteam.blockout.controls.ItemIcon) Text(com.ldtteam.blockout.controls.Text) ItemStack(net.minecraft.item.ItemStack) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pair(com.mojang.datafixers.util.Pair)

Aggregations

ItemIcon (com.ldtteam.blockout.controls.ItemIcon)6 ButtonImage (com.ldtteam.blockout.controls.ButtonImage)4 Text (com.ldtteam.blockout.controls.Text)4 ItemStack (net.minecraft.item.ItemStack)4 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)4 Box (com.ldtteam.blockout.views.Box)2 ScrollingList (com.ldtteam.blockout.views.ScrollingList)2 View (com.ldtteam.blockout.views.View)2 ILocation (com.minecolonies.api.colony.requestsystem.location.ILocation)2 AbstractBuildingGuards (com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards)2 Pair (com.mojang.datafixers.util.Pair)2 StringTextComponent (net.minecraft.util.text.StringTextComponent)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2