Search in sources :

Example 1 with ISkinPartType

use of riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType in project Armourers-Workshop by RiskyKen.

the class GuiDialogCopy method initGui.

@Override
public void initGui() {
    super.initGui();
    buttonList.clear();
    buttonClose = new GuiButtonExt(-1, x + width - 80 - 10, y + height - 30, 80, 20, GuiHelper.getLocalizedControlName(name, "close"));
    buttonCopy = new GuiButtonExt(-1, x + width - 160 - 20, y + height - 30, 80, 20, GuiHelper.getLocalizedControlName(name, "copy"));
    checkMirror = new GuiCheckBox(-1, x + 10, y + height - 50, GuiHelper.getLocalizedControlName(name, "mirror"), false);
    dropDownSrcPart = new GuiDropDownList(0, x + 10, y + 35, 80, "", null);
    dropDownDesPart = new GuiDropDownList(0, x + 100, y + 35, 80, "", null);
    if (skinType != null) {
        if (skinType != SkinTypeRegistry.skinBlock) {
            for (int i = 0; i < skinType.getSkinParts().size(); i++) {
                addPartToDropDown(dropDownSrcPart, skinType.getSkinParts().get(i));
                addPartToDropDown(dropDownDesPart, skinType.getSkinParts().get(i));
            }
        } else {
            boolean multiblock = SkinProperties.PROP_BLOCK_MULTIBLOCK.getValue(skinProperties);
            ISkinPartType partType;
            if (multiblock) {
                partType = ((SkinBlock) SkinTypeRegistry.skinBlock).partMultiblock;
            } else {
                partType = ((SkinBlock) SkinTypeRegistry.skinBlock).partBase;
            }
            addPartToDropDown(dropDownSrcPart, partType);
            addPartToDropDown(dropDownDesPart, partType);
        }
    }
    dropDownSrcPart.setListSelectedIndex(0);
    dropDownDesPart.setListSelectedIndex(0);
    buttonList.add(buttonClose);
    buttonList.add(buttonCopy);
    buttonList.add(checkMirror);
    buttonList.add(dropDownSrcPart);
    buttonList.add(dropDownDesPart);
}
Also used : GuiDropDownList(riskyken.armourersWorkshop.client.gui.controls.GuiDropDownList) ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType) GuiButtonExt(cpw.mods.fml.client.config.GuiButtonExt) GuiCheckBox(riskyken.armourersWorkshop.client.gui.controls.GuiCheckBox)

Example 2 with ISkinPartType

use of riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType in project Armourers-Workshop by RiskyKen.

the class GuiTabArmourerBlockUtils method dialogResult.

@Override
public void dialogResult(AbstractGuiDialog dialog, DialogResult result) {
    if (result == DialogResult.OK & dialog != null) {
        if (dialog instanceof GuiDialogClear) {
            String tag = ((GuiDialogClear) dialog).getClearTag();
            if (!StringUtils.isNullOrEmpty(tag)) {
                ISkinPartType partType = SkinTypeRegistry.INSTANCE.getSkinPartFromRegistryName(tag);
                boolean clearBlocks = ((GuiDialogClear) dialog).isClearBlocks();
                boolean clearPaint = ((GuiDialogClear) dialog).isClearPaint();
                boolean clearMarkers = ((GuiDialogClear) dialog).isClearMarkers();
                MessageClientGuiArmourerBlockUtil message;
                message = new MessageClientGuiArmourerBlockUtil("clear", partType, null, clearBlocks, clearPaint, clearMarkers);
                PacketHandler.networkWrapper.sendToServer(message);
            }
        }
        if (dialog instanceof GuiDialogCopy) {
            ISkinPartType srcPart = ((GuiDialogCopy) dialog).getSrcPart();
            ISkinPartType desPart = ((GuiDialogCopy) dialog).getDesPart();
            boolean mirror = ((GuiDialogCopy) dialog).isMirror();
            MessageClientGuiArmourerBlockUtil message;
            message = new MessageClientGuiArmourerBlockUtil("copy", srcPart, desPart, mirror, false, false);
            PacketHandler.networkWrapper.sendToServer(message);
        }
    }
}
Also used : ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType) MessageClientGuiArmourerBlockUtil(riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiArmourerBlockUtil) GuiDialogCopy(riskyken.armourersWorkshop.client.gui.armourer.dialog.GuiDialogCopy) GuiDialogClear(riskyken.armourersWorkshop.client.gui.armourer.dialog.GuiDialogClear)

Example 3 with ISkinPartType

use of riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType in project Armourers-Workshop by RiskyKen.

the class GuiMiniArmourerBuilding method onDropDownListChanged.

@Override
public void onDropDownListChanged(GuiDropDownList dropDownList) {
    if (dropDownList == dropDownSkins) {
        DropDownListItem listItem = dropDownList.getListSelectedItem();
        ISkinType skinType = SkinTypeRegistry.INSTANCE.getSkinTypeFromRegistryName(listItem.tag);
        updatePartsDropDown(skinType);
        PacketHandler.networkWrapper.sendToServer(new MessageClientGuiSetArmourerSkinType(skinType));
    }
    if (dropDownList == dropDownParts) {
        String partName = dropDownParts.getListSelectedItem().tag;
        ISkinPartType skinPartType = SkinTypeRegistry.INSTANCE.getSkinPartFromRegistryName(partName);
        model.currentSkinPartType = skinPartType;
    }
}
Also used : MessageClientGuiSetArmourerSkinType(riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiSetArmourerSkinType) DropDownListItem(riskyken.armourersWorkshop.client.gui.controls.GuiDropDownList.DropDownListItem) ISkinType(riskyken.armourersWorkshop.api.common.skin.type.ISkinType) ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType)

Example 4 with ISkinPartType

use of riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType in project Armourers-Workshop by RiskyKen.

the class GuiMiniArmourerBuilding method updatePartsDropDown.

private void updatePartsDropDown(ISkinType skinType) {
    ArrayList<ISkinPartType> partsList = skinType.getSkinParts();
    dropDownParts.clearList();
    for (int i = 0; i < partsList.size(); i++) {
        ISkinPartType skinPartType = partsList.get(i);
        String skinLocalizedName = SkinTypeRegistry.INSTANCE.getLocalizedSkinPartTypeName(skinPartType);
        String skinRegistryName = skinPartType.getRegistryName();
        dropDownParts.addListItem(skinLocalizedName, skinRegistryName, true);
    }
    dropDownParts.setListSelectedIndex(0);
    String partName = dropDownParts.getListSelectedItem().tag;
    ISkinPartType skinPartType = SkinTypeRegistry.INSTANCE.getSkinPartFromRegistryName(partName);
    model.currentSkinPartType = skinPartType;
}
Also used : ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType)

Example 5 with ISkinPartType

use of riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType in project Armourers-Workshop by RiskyKen.

the class SkinItemRenderHelper method renderSkinAsItem.

public static void renderSkinAsItem(Skin skin, ISkinPointer skinPointer, boolean showSkinPaint, boolean doLodLoading, int targetWidth, int targetHeight) {
    if (skin == null) {
        return;
    }
    float blockScale = 16F;
    float mcScale = 1F / blockScale;
    ArrayList<IRectangle3D> boundsParts = new ArrayList<IRectangle3D>();
    ArrayList<IRectangle3D> boundsTextures = new ArrayList<IRectangle3D>();
    IRectangle3D boundsTexture = null;
    for (int i = 0; i < skin.getPartCount(); i++) {
        SkinPart skinPart = skin.getParts().get(i);
        if (!(skin.getSkinType() == SkinTypeRegistry.skinBow && i > 0)) {
            Rectangle3D bounds = skinPart.getPartBounds();
            IPoint3D offset = skinPart.getPartType().getItemRenderOffset();
            Rectangle3D rec = new Rectangle3D(bounds.getX() + offset.getX(), bounds.getY() + offset.getY(), bounds.getZ() + offset.getZ(), bounds.getWidth(), bounds.getHeight(), bounds.getDepth());
            boundsParts.add(rec);
        }
    }
    if (skin.hasPaintData()) {
        ArrayList<ISkinPartType> parts = skin.getSkinType().getSkinParts();
        for (int i = 0; i < parts.size(); i++) {
            ISkinPartType part = parts.get(i);
            if (part instanceof ISkinPartTypeTextured) {
                if (part.getItemRenderTextureBounds() != null) {
                    boundsTextures.add(part.getItemRenderTextureBounds());
                }
            }
        }
    }
    int minX = 256;
    int minY = 256;
    int minZ = 256;
    int maxX = -256;
    int maxY = -256;
    int maxZ = -256;
    for (int i = 0; i < boundsParts.size(); i++) {
        IRectangle3D rec = boundsParts.get(i);
        minX = Math.min(minX, rec.getX());
        minY = Math.min(minY, rec.getY());
        minZ = Math.min(minZ, rec.getZ());
        maxX = Math.max(maxX, rec.getWidth() + rec.getX());
        maxY = Math.max(maxY, rec.getHeight() + rec.getY());
        maxZ = Math.max(maxZ, rec.getDepth() + rec.getZ());
    }
    for (int i = 0; i < boundsTextures.size(); i++) {
        IRectangle3D rec = boundsTextures.get(i);
        minX = Math.min(minX, rec.getX());
        minY = Math.min(minY, rec.getY());
        minZ = Math.min(minZ, rec.getZ());
        maxX = Math.max(maxX, rec.getWidth() + rec.getX());
        maxY = Math.max(maxY, rec.getHeight() + rec.getY());
        maxZ = Math.max(maxZ, rec.getDepth() + rec.getZ());
    }
    Rectangle3D maxBounds = new Rectangle3D(minX, minY, minZ, maxX - minX, maxY - minY, maxZ - minZ);
    GL11.glPushMatrix();
    if (debugSpin) {
        float angle = (((System.currentTimeMillis() / 10) % 360));
        GL11.glRotatef(angle, 0, 1, 0);
    }
    // Target bounds
    if (debugShowTargetBounds) {
        drawBounds(new Rectangle3D(-targetWidth / 2, -targetHeight / 2, -targetWidth / 2, targetWidth, targetHeight, targetWidth), 0, 0, 255);
    }
    int biggerSize = Math.max(maxBounds.getWidth(), maxBounds.getHeight());
    biggerSize = Math.max(biggerSize, maxBounds.getDepth());
    float newScaleW = (float) targetWidth / Math.max(maxBounds.getWidth(), maxBounds.getDepth());
    float newScaleH = (float) targetHeight / maxBounds.getHeight();
    float newScale = Math.min(newScaleW, newScaleH);
    GL11.glScalef(newScale, newScale, newScale);
    // Center the skin
    GL11.glTranslated(-(maxBounds.getWidth() / 2F + maxBounds.getX()) * mcScale, 0, 0);
    GL11.glTranslated(0, -(maxBounds.getHeight() / 2F + maxBounds.getY()) * mcScale, 0);
    GL11.glTranslated(0, 0, -(maxBounds.getDepth() / 2F + maxBounds.getZ()) * mcScale);
    renderSkinWithHelper(skin, skinPointer, showSkinPaint, doLodLoading);
    if (debugShowFullBounds) {
        drawBounds(maxBounds, 255, 255, 0);
    }
    if (debugShowPartBounds) {
        for (int i = 0; i < boundsParts.size(); i++) {
            drawBounds(boundsParts.get(i), 255, 0, 0);
        }
    }
    if (debugShowTextureBounds) {
        for (int i = 0; i < boundsTextures.size(); i++) {
            drawBounds(boundsTextures.get(i), 0, 255, 0);
        }
    }
    GL11.glPopMatrix();
}
Also used : ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType) IPoint3D(riskyken.armourersWorkshop.api.common.IPoint3D) IRectangle3D(riskyken.armourersWorkshop.api.common.IRectangle3D) ArrayList(java.util.ArrayList) IRectangle3D(riskyken.armourersWorkshop.api.common.IRectangle3D) Rectangle3D(riskyken.armourersWorkshop.api.common.skin.Rectangle3D) ISkinPartTypeTextured(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartTypeTextured) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart)

Aggregations

ISkinPartType (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType)18 IPoint3D (riskyken.armourersWorkshop.api.common.IPoint3D)5 IRectangle3D (riskyken.armourersWorkshop.api.common.IRectangle3D)4 ArrayList (java.util.ArrayList)3 SkinPart (riskyken.armourersWorkshop.common.skin.data.SkinPart)3 GuiButtonExt (cpw.mods.fml.client.config.GuiButtonExt)2 Rectangle3D (riskyken.armourersWorkshop.api.common.skin.Rectangle3D)2 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)2 GuiCheckBox (riskyken.armourersWorkshop.client.gui.controls.GuiCheckBox)2 GuiDropDownList (riskyken.armourersWorkshop.client.gui.controls.GuiDropDownList)2 CubeMarkerData (riskyken.armourersWorkshop.common.skin.cubes.CubeMarkerData)2 SkinCubeData (riskyken.armourersWorkshop.common.skin.data.SkinCubeData)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 IOException (java.io.IOException)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ISkinPart (riskyken.armourersWorkshop.api.common.skin.data.ISkinPart)1 ISkinPartTypeTextured (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartTypeTextured)1 GuiDialogClear (riskyken.armourersWorkshop.client.gui.armourer.dialog.GuiDialogClear)1 GuiDialogCopy (riskyken.armourersWorkshop.client.gui.armourer.dialog.GuiDialogCopy)1 DropDownListItem (riskyken.armourersWorkshop.client.gui.controls.GuiDropDownList.DropDownListItem)1