Search in sources :

Example 1 with ImageElement

use of slimeknights.mantle.client.screen.book.element.ImageElement in project TinkersConstruct by SlimeKnights.

the class ContentModifier method buildAndAddRecipeDisplay.

/**
 * Builds the recipe display to show in the book's gui and adds it so that the user can see the recipes.
 *
 * @param book   the book data
 * @param list   the list of book elements
 * @param recipe recipe to display
 * @param parent the parent book screen, only used when there is multiple recipes
 */
public void buildAndAddRecipeDisplay(BookData book, ArrayList<BookElement> list, @Nullable IDisplayModifierRecipe recipe, @Nullable BookScreen parent) {
    if (recipe != null) {
        List<List<ItemStack>> inputs = recipe.getDisplayItems();
        ImageData img = IMG_SLOTS[Math.min(inputs.size() - 2, 4)];
        if (inputs.size() > 6) {
            TConstruct.LOG.warn("Too many inputs in recipe {}, size {}", recipe, inputs.size() - 2);
        }
        int[] slotsX = SLOTS_X;
        int[] slotsY = SLOTS_Y;
        if (inputs.size() == 5) {
            slotsX = SLOTS_X_4;
            slotsY = SLOTS_Y_4;
        }
        int imgX = BookScreen.PAGE_WIDTH / 2 + 20;
        int imgY = BookScreen.PAGE_HEIGHT / 2 + 30;
        imgX = imgX + 29 - img.width / 2;
        imgY = imgY + 20 - img.height / 2;
        ImageElement table = new ImageElement(imgX + (img.width - IMG_TABLE.width) / 2, imgY - 24, -1, -1, IMG_TABLE);
        if (parent != null)
            table.parent = parent;
        this.parts.add(table);
        // TODO ADD TABLE TO TEXTURE?
        list.add(table);
        ImageElement slot = new ImageElement(imgX, imgY, -1, -1, img, book.appearance.slotColor);
        if (parent != null)
            slot.parent = parent;
        this.parts.add(slot);
        list.add(slot);
        ItemStackList demo = getDemoTools(recipe.getToolWithModifier());
        TinkerItemElement demoTools = new TinkerItemElement(imgX + (img.width - 16) / 2, imgY - 24, 1f, demo);
        if (parent != null)
            demoTools.parent = parent;
        this.parts.add(demoTools);
        list.add(demoTools);
        ImageElement image = new ImageElement(imgX + (img.width - 22) / 2, imgY - 27, -1, -1, IMG_SLOT_1, 0xffffff);
        if (parent != null)
            image.parent = parent;
        this.parts.add(image);
        list.add(image);
        for (int i = 1; i < Math.min(inputs.size(), 6); i++) {
            TinkerItemElement part = new TinkerItemElement(imgX + slotsX[i - 1], imgY + slotsY[i - 1], 1f, inputs.get(i));
            if (parent != null)
                part.parent = parent;
            this.parts.add(part);
            list.add(part);
        }
    }
}
Also used : ItemStackList(slimeknights.mantle.util.ItemStackList) ImageData(slimeknights.mantle.client.book.data.element.ImageData) ImageElement(slimeknights.mantle.client.screen.book.element.ImageElement) TinkerItemElement(slimeknights.tconstruct.library.client.book.elements.TinkerItemElement) ArrayList(java.util.ArrayList) ItemStackList(slimeknights.mantle.util.ItemStackList) List(java.util.List)

Example 2 with ImageElement

use of slimeknights.mantle.client.screen.book.element.ImageElement in project TinkersConstruct by SlimeKnights.

the class ContentModifier method build.

@Override
public void build(BookData book, ArrayList<BookElement> list, boolean brightSide) {
    Modifier modifier = getModifier();
    if (modifier == TinkerModifiers.empty.get() || this.recipes.isEmpty()) {
        list.add(new ImageElement(0, 0, 32, 32, ImageData.MISSING));
        System.out.println("Modifier with id " + modifierID + " not found");
        return;
    }
    this.addTitle(list, getTitle(), true, modifier.getColor());
    // description
    int y = getTitleHeight();
    int h = more_text_space ? BookScreen.PAGE_HEIGHT * 2 / 5 : BookScreen.PAGE_HEIGHT * 2 / 7;
    list.add(new TextElement(5, y, BookScreen.PAGE_WIDTH - 10, h, text));
    if (this.effects.length > 0) {
        TextData head = new TextData(I18n.get(KEY_EFFECTS));
        head.underlined = true;
        list.add(new TextElement(5, y + h, BookScreen.PAGE_WIDTH / 2 - 5, BookScreen.PAGE_HEIGHT - h - 20, head));
        List<TextData> effectData = Lists.newArrayList();
        for (String e : this.effects) {
            effectData.add(new TextData("\u25CF "));
            effectData.add(new TextData(e));
            effectData.add(new TextData("\n"));
        }
        list.add(new TextElement(5, y + 14 + h, BookScreen.PAGE_WIDTH / 2 + 5, BookScreen.PAGE_HEIGHT - h - 20, effectData));
    }
    if (recipes.size() > 1) {
        int col = book.appearance.structureButtonColor;
        int colHover = book.appearance.structureButtonColorHovered;
        list.add(new CycleRecipeElement(BookScreen.PAGE_WIDTH - ArrowButton.ArrowType.RIGHT.w - 32, 160, ArrowButton.ArrowType.RIGHT, col, colHover, this, book, list));
    }
    this.buildAndAddRecipeDisplay(book, list, this.recipes.get(this.currentRecipe), null);
}
Also used : TextElement(slimeknights.mantle.client.screen.book.element.TextElement) ImageElement(slimeknights.mantle.client.screen.book.element.ImageElement) TextData(slimeknights.mantle.client.book.data.element.TextData) CycleRecipeElement(slimeknights.tconstruct.library.client.book.elements.CycleRecipeElement) Modifier(slimeknights.tconstruct.library.modifiers.Modifier)

Aggregations

ImageElement (slimeknights.mantle.client.screen.book.element.ImageElement)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ImageData (slimeknights.mantle.client.book.data.element.ImageData)1 TextData (slimeknights.mantle.client.book.data.element.TextData)1 TextElement (slimeknights.mantle.client.screen.book.element.TextElement)1 ItemStackList (slimeknights.mantle.util.ItemStackList)1 CycleRecipeElement (slimeknights.tconstruct.library.client.book.elements.CycleRecipeElement)1 TinkerItemElement (slimeknights.tconstruct.library.client.book.elements.TinkerItemElement)1 Modifier (slimeknights.tconstruct.library.modifiers.Modifier)1