Search in sources :

Example 6 with ButtonImage

use of com.ldtteam.blockout.controls.ButtonImage in project minecolonies by Minecolonies.

the class GuardTaskSetting method render.

@Override
public void render(final ISettingKey<?> key, final Pane pane, final ISettingsModuleView settingsModuleView, final IBuildingView building, final Window window) {
    final String setting = getSettings().get(getCurrentIndex());
    final ButtonImage targetButton = pane.findPaneOfTypeByID("setTarget", ButtonImage.class);
    final Text mineLabel = pane.findPaneOfTypeByID("minePos", Text.class);
    if (setting.equals(PATROL_MINE) && building instanceof AbstractBuildingGuards.View) {
        mineLabel.setVisible(true);
        if (((AbstractBuildingGuards.View) building).getMinePos() != null) {
            mineLabel.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.worherhuts.patrollingmine", ((AbstractBuildingGuards.View) building).getMinePos().toShortString()));
        } else {
            mineLabel.setText(new TranslationTextComponent("com.minecolonies.coremod.job.guard.assignmine"));
        }
        targetButton.setVisible(false);
    } else if (!setting.equals(FOLLOW)) {
        mineLabel.setVisible(false);
        targetButton.setVisible(true);
        if (setting.equals(PATROL)) {
            if (!settingsModuleView.getSetting(AbstractBuildingGuards.PATROL_MODE).getValue().equals(PatrolModeSetting.MANUAL)) {
                targetButton.setVisible(false);
            } else {
                targetButton.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.workerhuts.targetpatrol"));
            }
        } else {
            targetButton.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.workerhuts.targetguard"));
        }
        targetButton.setHandler(button -> building.getModuleView(ToolModuleView.class).getWindow().open());
    } else {
        mineLabel.setVisible(false);
        targetButton.setVisible(false);
    }
    pane.findPaneOfTypeByID("trigger", ButtonImage.class).setText(new TranslationTextComponent(setting));
}
Also used : ISettingsModuleView(com.minecolonies.api.colony.buildings.modules.settings.ISettingsModuleView) Window(com.ldtteam.blockout.views.Window) AbstractBuildingGuards(com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) ISettingKey(com.minecolonies.api.colony.buildings.modules.settings.ISettingKey) Pane(com.ldtteam.blockout.Pane) View(com.ldtteam.blockout.views.View) Text(com.ldtteam.blockout.controls.Text) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Dist(net.minecraftforge.api.distmarker.Dist) Loader(com.ldtteam.blockout.Loader) List(java.util.List) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) ButtonImage(com.ldtteam.blockout.controls.ButtonImage) ToolModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.ToolModuleView) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) AbstractBuildingGuards(com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards) ButtonImage(com.ldtteam.blockout.controls.ButtonImage) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Text(com.ldtteam.blockout.controls.Text)

Example 7 with ButtonImage

use of com.ldtteam.blockout.controls.ButtonImage in project minecolonies by ldtteam.

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 8 with ButtonImage

use of com.ldtteam.blockout.controls.ButtonImage in project minecolonies by ldtteam.

the class GuardTaskSetting method render.

@Override
public void render(final ISettingKey<?> key, final Pane pane, final ISettingsModuleView settingsModuleView, final IBuildingView building, final Window window) {
    final String setting = getSettings().get(getCurrentIndex());
    final ButtonImage targetButton = pane.findPaneOfTypeByID("setTarget", ButtonImage.class);
    final Text mineLabel = pane.findPaneOfTypeByID("minePos", Text.class);
    if (setting.equals(PATROL_MINE) && building instanceof AbstractBuildingGuards.View) {
        mineLabel.setVisible(true);
        if (((AbstractBuildingGuards.View) building).getMinePos() != null) {
            mineLabel.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.worherhuts.patrollingmine", ((AbstractBuildingGuards.View) building).getMinePos().toShortString()));
        } else {
            mineLabel.setText(new TranslationTextComponent("com.minecolonies.coremod.job.guard.assignmine"));
        }
        targetButton.setVisible(false);
    } else if (!setting.equals(FOLLOW)) {
        mineLabel.setVisible(false);
        targetButton.setVisible(true);
        if (setting.equals(PATROL)) {
            if (!settingsModuleView.getSetting(AbstractBuildingGuards.PATROL_MODE).getValue().equals(PatrolModeSetting.MANUAL)) {
                targetButton.setVisible(false);
            } else {
                targetButton.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.workerhuts.targetpatrol"));
            }
        } else {
            targetButton.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.workerhuts.targetguard"));
        }
        targetButton.setHandler(button -> building.getModuleView(ToolModuleView.class).getWindow().open());
    } else {
        mineLabel.setVisible(false);
        targetButton.setVisible(false);
    }
    pane.findPaneOfTypeByID("trigger", ButtonImage.class).setText(new TranslationTextComponent(setting));
}
Also used : ISettingsModuleView(com.minecolonies.api.colony.buildings.modules.settings.ISettingsModuleView) Window(com.ldtteam.blockout.views.Window) AbstractBuildingGuards(com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) ISettingKey(com.minecolonies.api.colony.buildings.modules.settings.ISettingKey) Pane(com.ldtteam.blockout.Pane) View(com.ldtteam.blockout.views.View) Text(com.ldtteam.blockout.controls.Text) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Dist(net.minecraftforge.api.distmarker.Dist) Loader(com.ldtteam.blockout.Loader) List(java.util.List) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) ButtonImage(com.ldtteam.blockout.controls.ButtonImage) ToolModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.ToolModuleView) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) AbstractBuildingGuards(com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards) ButtonImage(com.ldtteam.blockout.controls.ButtonImage) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Text(com.ldtteam.blockout.controls.Text)

Aggregations

ButtonImage (com.ldtteam.blockout.controls.ButtonImage)8 Text (com.ldtteam.blockout.controls.Text)6 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)6 Box (com.ldtteam.blockout.views.Box)4 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)4 Loader (com.ldtteam.blockout.Loader)2 Pane (com.ldtteam.blockout.Pane)2 ItemIcon (com.ldtteam.blockout.controls.ItemIcon)2 View (com.ldtteam.blockout.views.View)2 Window (com.ldtteam.blockout.views.Window)2 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 ISettingKey (com.minecolonies.api.colony.buildings.modules.settings.ISettingKey)2 ISettingsModuleView (com.minecolonies.api.colony.buildings.modules.settings.ISettingsModuleView)2 IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)2 IInteractionResponseHandler (com.minecolonies.api.colony.interactionhandling.IInteractionResponseHandler)2 AbstractBuildingGuards (com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards)2 ToolModuleView (com.minecolonies.coremod.colony.buildings.moduleviews.ToolModuleView)2 MarkBuildingDirtyMessage (com.minecolonies.coremod.network.messages.server.colony.building.MarkBuildingDirtyMessage)2 List (java.util.List)2 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2