Search in sources :

Example 1 with ButtonImage

use of com.ldtteam.blockout.controls.ButtonImage 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 ButtonImage

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

the class WindowInteraction method setupInteraction.

/**
 * Setup the current interaction.
 */
private void setupInteraction() {
    if (currentInteraction >= interactions.size()) {
        close();
        return;
    }
    final IInteractionResponseHandler handler = interactions.get(currentInteraction);
    final Box group = findPaneOfTypeByID(RESPONSE_BOX_ID, Box.class);
    int y = 0;
    int x = 0;
    final Text chatText = findPaneOfTypeByID(CHAT_LABEL_ID, Text.class);
    chatText.setTextAlignment(Alignment.TOP_LEFT);
    chatText.setAlignment(Alignment.TOP_LEFT);
    chatText.setText(citizen.getName() + ": " + handler.getInquiry().getString());
    int responseIndex = 1;
    for (final ITextComponent component : handler.getPossibleResponses()) {
        final ButtonImage button = new ButtonImage();
        button.setImage(new ResourceLocation(Constants.MOD_ID, MEDIUM_SIZED_BUTTON_RES));
        button.setSize(BUTTON_LENGTH, BUTTON_HEIGHT);
        button.setColors(SLIGHTLY_BLUE);
        button.setPosition(x, y);
        button.setID(BUTTON_RESPONSE_ID + responseIndex);
        button.setTextRenderBox(BUTTON_LENGTH, BUTTON_HEIGHT);
        button.setTextAlignment(Alignment.MIDDLE);
        button.setText(component);
        group.addChild(button);
        y += button.getHeight();
        if (y + button.getHeight() >= group.getHeight()) {
            y = 0;
            x += BUTTON_HEIGHT + BUTTON_BUFFER + button.getWidth();
        }
        responseIndex++;
    }
    handler.onWindowOpened(this, citizen);
}
Also used : IInteractionResponseHandler(com.minecolonies.api.colony.interactionhandling.IInteractionResponseHandler) ResourceLocation(net.minecraft.util.ResourceLocation) ITextComponent(net.minecraft.util.text.ITextComponent) ButtonImage(com.ldtteam.blockout.controls.ButtonImage) Box(com.ldtteam.blockout.views.Box) Text(com.ldtteam.blockout.controls.Text)

Example 3 with ButtonImage

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

the class WarehouseOptionsModuleWindow method onOpened.

@Override
public void onOpened() {
    if (buildingView.getBuildingLevel() < BUILDING_LEVEL_FOR_SORTING) {
        final ButtonImage sortButton = findPaneOfTypeByID(SORT_WAREHOUSE_BUTTON, ButtonImage.class);
        PaneBuilders.tooltipBuilder().append(new TranslationTextComponent("com.minecolonies.coremod.gui.warehouse.sort.disabled.1", BUILDING_LEVEL_FOR_SORTING)).appendNL(new TranslationTextComponent("com.minecolonies.coremod.gui.warehouse.sort.disabled.2", BUILDING_LEVEL_FOR_SORTING)).hoverPane(sortButton).build();
        sortButton.disable();
    }
    super.onOpened();
    updateResourcePane();
    // Make sure we have a fresh view
    Network.getNetwork().sendToServer(new MarkBuildingDirtyMessage(this.buildingView));
}
Also used : ButtonImage(com.ldtteam.blockout.controls.ButtonImage) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) MarkBuildingDirtyMessage(com.minecolonies.coremod.network.messages.server.colony.building.MarkBuildingDirtyMessage)

Example 4 with ButtonImage

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

the class WindowInteraction method setupInteraction.

/**
 * Setup the current interaction.
 */
private void setupInteraction() {
    if (currentInteraction >= interactions.size()) {
        close();
        return;
    }
    final IInteractionResponseHandler handler = interactions.get(currentInteraction);
    final Box group = findPaneOfTypeByID(RESPONSE_BOX_ID, Box.class);
    int y = 0;
    int x = 0;
    final Text chatText = findPaneOfTypeByID(CHAT_LABEL_ID, Text.class);
    chatText.setTextAlignment(Alignment.TOP_LEFT);
    chatText.setAlignment(Alignment.TOP_LEFT);
    chatText.setText(citizen.getName() + ": " + handler.getInquiry().getString());
    int responseIndex = 1;
    for (final ITextComponent component : handler.getPossibleResponses()) {
        final ButtonImage button = new ButtonImage();
        button.setImage(new ResourceLocation(Constants.MOD_ID, MEDIUM_SIZED_BUTTON_RES));
        button.setSize(BUTTON_LENGTH, BUTTON_HEIGHT);
        button.setColors(SLIGHTLY_BLUE);
        button.setPosition(x, y);
        button.setID(BUTTON_RESPONSE_ID + responseIndex);
        button.setTextRenderBox(BUTTON_LENGTH, BUTTON_HEIGHT);
        button.setTextAlignment(Alignment.MIDDLE);
        button.setText(component);
        group.addChild(button);
        y += button.getHeight();
        if (y + button.getHeight() >= group.getHeight()) {
            y = 0;
            x += BUTTON_HEIGHT + BUTTON_BUFFER + button.getWidth();
        }
        responseIndex++;
    }
    handler.onWindowOpened(this, citizen);
}
Also used : IInteractionResponseHandler(com.minecolonies.api.colony.interactionhandling.IInteractionResponseHandler) ResourceLocation(net.minecraft.util.ResourceLocation) ITextComponent(net.minecraft.util.text.ITextComponent) ButtonImage(com.ldtteam.blockout.controls.ButtonImage) Box(com.ldtteam.blockout.views.Box) Text(com.ldtteam.blockout.controls.Text)

Example 5 with ButtonImage

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

the class WarehouseOptionsModuleWindow method onOpened.

@Override
public void onOpened() {
    if (buildingView.getBuildingLevel() < BUILDING_LEVEL_FOR_SORTING) {
        final ButtonImage sortButton = findPaneOfTypeByID(SORT_WAREHOUSE_BUTTON, ButtonImage.class);
        PaneBuilders.tooltipBuilder().append(new TranslationTextComponent("com.minecolonies.coremod.gui.warehouse.sort.disabled.1", BUILDING_LEVEL_FOR_SORTING)).appendNL(new TranslationTextComponent("com.minecolonies.coremod.gui.warehouse.sort.disabled.2", BUILDING_LEVEL_FOR_SORTING)).hoverPane(sortButton).build();
        sortButton.disable();
    }
    super.onOpened();
    updateResourcePane();
    // Make sure we have a fresh view
    Network.getNetwork().sendToServer(new MarkBuildingDirtyMessage(this.buildingView));
}
Also used : ButtonImage(com.ldtteam.blockout.controls.ButtonImage) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) MarkBuildingDirtyMessage(com.minecolonies.coremod.network.messages.server.colony.building.MarkBuildingDirtyMessage)

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