Search in sources :

Example 51 with SkinPointer

use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.

the class GuiSkinLibrary method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTickTime) {
    int oldMouseX = mouseX;
    int oldMouseY = mouseY;
    if (isDialogOpen()) {
        mouseX = mouseY = 0;
    }
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    super.drawScreen(mouseX, mouseY, partialTickTime);
    GL11.glPopAttrib();
    ILibraryManager libraryManager = ArmourersWorkshop.proxy.libraryManager;
    ArrayList<LibraryFile> files = libraryManager.getServerPublicFileList().getFileList();
    loadSaveButton.enabled = true;
    if (isLoading()) {
        loadSaveButton.displayString = GuiHelper.getLocalizedControlName(armourLibrary.getInventoryName(), "load");
        if (fileList.getSelectedListEntry() == null || ((GuiFileListItem) fileList.getSelectedListEntry()).getFile().directory) {
            loadSaveButton.displayString = "";
            loadSaveButton.enabled = false;
        }
    } else {
        loadSaveButton.displayString = GuiHelper.getLocalizedControlName(armourLibrary.getInventoryName(), "save");
    }
    if (!((Slot) inventorySlots.inventorySlots.get(36)).getHasStack() & !armourLibrary.isCreativeLibrary()) {
        loadSaveButton.displayString = "";
        loadSaveButton.enabled = false;
    }
    if (fileSwitchType == LibraryFileType.LOCAL) {
        files = libraryManager.getClientPublicFileList().getFileList();
        if (!mc.isIntegratedServerRunning()) {
            loadSaveButton.enabled = false;
            if (isLoading()) {
                loadSaveButton.enabled = ConfigHandler.allowClientsToUploadSkins;
            } else {
                loadSaveButton.enabled = ConfigHandler.allowClientsToDownloadSkins;
            }
        }
    } else {
        loadSaveButton.enabled = true;
    }
    if (fileSwitchType == LibraryFileType.SERVER_PRIVATE) {
        files = libraryManager.getServerPrivateFileList(mc.thePlayer).getFileList();
    }
    String typeFilter = dropDownList.getListSelectedItem().tag;
    ISkinType skinTypeFilter = SkinTypeRegistry.INSTANCE.getSkinTypeFromRegistryName(typeFilter);
    lastSkinType = skinTypeFilter;
    lastSearchText = searchTextbox.getText();
    IGuiListItem selectedItem = fileList.getSelectedListEntry();
    if (selectedItem != null) {
    // deleteButton.enabled = !((GuiFileListItem)selectedItem).getFile().readOnly;
    } else {
    // deleteButton.enabled = false;
    }
    fileList.setSelectedIndex(-1);
    fileList.clearList();
    if (!(currentFolder.equals("/") | currentFolder.equals(getPrivateRoot(player)))) {
        fileList.addListItem(new GuiFileListItem(new LibraryFile("../", "", null, true)));
        if (selectedItem != null && ((GuiFileListItem) selectedItem).getFile().fileName.equals("../")) {
            fileList.setSelectedIndex(0);
        }
    }
    if (files != null) {
        for (int i = 0; i < files.size(); i++) {
            LibraryFile file = files.get(i);
            if (skinTypeFilter == null | skinTypeFilter == file.skinType) {
                if (file.filePath.equals(currentFolder)) {
                    if (!searchTextbox.getText().equals("")) {
                        if (file.fileName.toLowerCase().contains(searchTextbox.getText().toLowerCase())) {
                            fileList.addListItem(new GuiFileListItem(file));
                            if (selectedItem != null && ((GuiFileListItem) selectedItem).getFile() == file) {
                                fileList.setSelectedIndex(fileList.getSize() - 1);
                            }
                        }
                    } else {
                        fileList.addListItem(new GuiFileListItem(file));
                        if (selectedItem != null && ((GuiFileListItem) selectedItem).getFile() == file) {
                            fileList.setSelectedIndex(fileList.getSize() - 1);
                        }
                    }
                }
            }
        }
    }
    scrollAmount = scrollbar.getValue();
    fileList.setScrollPercentage(scrollbar.getPercentageValue());
    for (int i = 0; i < buttonList.size(); i++) {
        GuiButton button = (GuiButton) buttonList.get(i);
        if (button instanceof GuiIconButton) {
            ((GuiIconButton) button).drawRollover(mc, mouseX, mouseY);
        }
    }
    if (showModelPreviews()) {
        GuiFileListItem item = (GuiFileListItem) fileList.getSelectedListEntry();
        if (item != null && !item.getFile().isDirectory()) {
            SkinIdentifier identifier = new SkinIdentifier(0, new LibraryFile(item.getFile().getFullName()), 0, null);
            Skin skin = ClientSkinCache.INSTANCE.getSkin(identifier, true);
            if (skin != null) {
                SkinPointer skinPointer = new SkinPointer(identifier);
                int listRight = this.width - INVENTORY_WIDTH - PADDING * 5;
                listRight = MathHelper.clamp_int(listRight, 0, 200);
                listRight += INVENTORY_WIDTH + PADDING * 2 + 10;
                int listTop = TITLE_HEIGHT + 14 + PADDING * 2;
                int xSize = (this.width - listRight - PADDING) / 2;
                int ySize = (this.height - listTop - PADDING) / 2;
                float x = listRight + xSize;
                float y = listTop + ySize;
                float scale = 1F;
                scale = 1 * Math.min(xSize, ySize);
                ScaledResolution scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
                int startX = listRight + PADDING;
                int startY = listTop + PADDING;
                int tarW = (int) (x + xSize);
                int tarH = (int) (y + ySize);
                drawRect(startX, startY, tarW, tarH, 0x77777777);
                if (scale > 8) {
                    GL11.glPushMatrix();
                    GL11.glTranslatef((float) x, (float) y, 500.0F);
                    GL11.glScalef(10, 10, -10);
                    GL11.glRotatef(30, 1, 0, 0);
                    GL11.glRotatef(45, 0, 1, 0);
                    float rotation = (float) ((double) System.currentTimeMillis() / 10 % 360);
                    GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
                    RenderHelper.enableStandardItemLighting();
                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
                    GL11.glEnable(GL11.GL_NORMALIZE);
                    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
                    ModRenderHelper.enableAlphaBlend();
                    SkinItemRenderHelper.renderSkinAsItem(skin, skinPointer, true, false, tarW - startX, tarH - startY);
                    GL11.glPopAttrib();
                    GL11.glPopMatrix();
                }
            }
        }
    }
    GL11.glColor4f(1, 1, 1, 1);
    if (isDialogOpen()) {
        this.dialog.draw(oldMouseX, oldMouseY, partialTickTime);
    }
}
Also used : IGuiListItem(riskyken.armourersWorkshop.client.gui.controls.IGuiListItem) ISkinType(riskyken.armourersWorkshop.api.common.skin.type.ISkinType) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ILibraryManager(riskyken.armourersWorkshop.common.library.ILibraryManager) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier) ScaledResolution(net.minecraft.client.gui.ScaledResolution) GuiFileListItem(riskyken.armourersWorkshop.client.gui.controls.GuiFileListItem) GuiButton(net.minecraft.client.gui.GuiButton) GuiIconButton(riskyken.armourersWorkshop.client.gui.controls.GuiIconButton) Slot(net.minecraft.inventory.Slot) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile)

Example 52 with SkinPointer

use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.

the class GuiFileListItem method drawListItem.

@Override
public void drawListItem(FontRenderer fontRenderer, int x, int y, int mouseX, int mouseY, boolean selected, int width) {
    int iconOffset = 0;
    if (GuiSkinLibrary.showModelPreviews() | file.isDirectory()) {
        iconOffset = 10;
    }
    int fontColour = UtilColour.getMinecraftColor(8, ColourFamily.MINECRAFT);
    if (isHovering(fontRenderer, x, y, mouseX, mouseY, width)) {
        Gui.drawRect(x, y, x + width - 3, y + 12, 0xFFCCCCCC);
        fontColour = UtilColour.getMinecraftColor(15, ColourFamily.MINECRAFT);
    }
    if (selected) {
        Gui.drawRect(x, y, x + width - 3, y + 12, 0xFFFFFF88);
        fontColour = UtilColour.getMinecraftColor(15, ColourFamily.MINECRAFT);
    }
    if (!file.isDirectory()) {
        fontRenderer.drawString(file.fileName, x + 2 + iconOffset, y + 2, fontColour);
        if (GuiSkinLibrary.showModelPreviews() | file.isDirectory()) {
            IGuiListItem item = this;
            if (item != null) {
                SkinIdentifier identifier = new SkinIdentifier(0, new LibraryFile(file.getFullName()), 0, null);
                Skin skin = ClientSkinCache.INSTANCE.getSkin(identifier, true);
                if (skin != null) {
                    SkinPointer skinPointer = new SkinPointer(identifier);
                    float scale = 10F;
                    GL11.glPushMatrix();
                    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
                    GL11.glTranslatef((float) x + 5, (float) y + 6, 50.0F);
                    GL11.glScalef((float) (-scale), (float) scale, (float) scale);
                    GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
                    GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
                    float rotation = (float) ((double) System.currentTimeMillis() / 10 % 360);
                    GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
                    RenderHelper.enableStandardItemLighting();
                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                    GL11.glEnable(GL11.GL_NORMALIZE);
                    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
                    ModRenderHelper.enableAlphaBlend();
                    // ItemStackRenderHelper.renderItemModelFromSkinPointer(skinPointer, true, false);
                    SkinItemRenderHelper.renderSkinAsItem(skin, skinPointer, true, false, 16, 16);
                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                    GL11.glPopAttrib();
                    GL11.glPopMatrix();
                }
            }
        }
    } else {
        GL11.glColor4f(1, 1, 1, 1);
        Minecraft.getMinecraft().renderEngine.bindTexture(texture);
        if (file.fileName.equals("private")) {
            drawTexturedModalRect(x, y, 32, 0, 12, 12);
            fontRenderer.drawString(file.fileName, x + 2 + iconOffset, y + 2, 0xFF8888FF);
        } else {
            drawTexturedModalRect(x, y, 16, 0, 10, 10);
            fontRenderer.drawString(file.fileName, x + 2 + iconOffset, y + 2, 0xFF88FF88);
        }
        GL11.glColor4f(1, 1, 1, 1);
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Example 53 with SkinPointer

use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.

the class ContainerDyeTable method dyeRemoved.

public void dyeRemoved(int slotId) {
    ItemStack skinStack = getSlot(45).getStack();
    if (skinStack == null) {
        return;
    }
    SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(skinStack);
    ISkinDye skinDye = skinPointer.getSkinDye();
    skinDye.removeDye(slotId);
    SkinNBTHelper.addSkinDataToStack(skinStack, skinPointer);
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ISkinDye(riskyken.armourersWorkshop.api.common.skin.data.ISkinDye) ItemStack(net.minecraft.item.ItemStack)

Example 54 with SkinPointer

use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.

the class ContainerDyeTable method transferStackInSlot.

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotId) {
    Slot slot = getSlot(slotId);
    if (slot != null && slot.getHasStack()) {
        ItemStack stack = slot.getStack();
        ItemStack result = stack.copy();
        if (slotId > 35) {
            // Moving from tile entity to player.
            if (!this.mergeItemStack(stack, 9, 36, false)) {
                if (!this.mergeItemStack(stack, 0, 9, false)) {
                    return null;
                }
            }
        } else {
            // Moving from player to tile entity.
            SkinPointer sp = SkinNBTHelper.getSkinPointerFromStack(stack);
            if (sp != null && (sp.lockSkin | stack.getItem() == ModItems.equipmentSkin)) {
                if (!this.mergeItemStack(stack, 36, 37, false)) {
                    return null;
                }
            } else if (stack.getItem() == ModItems.dyeBottle && getSlot(36).getHasStack() & PaintingHelper.getToolHasPaint(stack)) {
                if (!this.mergeItemStack(stack, 37, 45, false)) {
                    return null;
                }
            } else {
                return null;
            }
        }
        if (stack.stackSize == 0) {
            slot.putStack(null);
        } else {
            slot.onSlotChanged();
        }
        slot.onPickupFromSlot(player, stack);
        return result;
    }
    return null;
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 55 with SkinPointer

use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.

the class ContainerDyeTable method putDyesInSlots.

/**
 * Reads the output slot and adds dye bottles to their slots.
 */
private void putDyesInSlots() {
    if (tileEntity.getWorldObj().isRemote) {
        return;
    }
    ItemStack outStack = getSlot(45).getStack();
    SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(outStack);
    ISkinDye dye = skinPointer.getSkinDye();
    for (int i = 0; i < 8; i++) {
        if (dye.haveDyeInSlot(i)) {
            byte[] rgbt = dye.getDyeColour(i);
            ItemStack bottle = new ItemStack(ModItems.dyeBottle, 1, 1);
            PaintingHelper.setToolPaintColour(bottle, rgbt);
            PaintingHelper.setToolPaint(bottle, PaintType.getPaintTypeFormSKey(rgbt[3]));
            if (dye.hasName(i)) {
                bottle.setStackDisplayName(dye.getDyeName(i));
            }
            putStackInSlot(37 + i, bottle);
        } else {
            putStackInSlot(37 + i, null);
        }
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ISkinDye(riskyken.armourersWorkshop.api.common.skin.data.ISkinDye) ItemStack(net.minecraft.item.ItemStack)

Aggregations

SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)64 ItemStack (net.minecraft.item.ItemStack)28 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)19 ISkinPointer (riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)15 Item (net.minecraft.item.Item)13 ISkinDye (riskyken.armourersWorkshop.api.common.skin.data.ISkinDye)8 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)7 SkinIdentifier (riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)7 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)6 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 ItemSkin (riskyken.armourersWorkshop.common.items.ItemSkin)4 Minecraft (net.minecraft.client.Minecraft)3 ScaledResolution (net.minecraft.client.gui.ScaledResolution)3 ItemBlock (net.minecraft.item.ItemBlock)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 AbstractModelSkin (riskyken.armourersWorkshop.client.model.skin.AbstractModelSkin)3 MessageServerLibrarySendSkin (riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin)3 SkinDye (riskyken.armourersWorkshop.common.skin.data.SkinDye)3 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2