Search in sources :

Example 1 with IGuiListItem

use of riskyken.armourersWorkshop.client.gui.controls.IGuiListItem in project Armourers-Workshop by RiskyKen.

the class GuiSkinLibrary method setupLibraryEditButtons.

private void setupLibraryEditButtons() {
    IGuiListItem listItem = fileList.getSelectedListEntry();
    reloadButton.enabled = newFolderButton.enabled = openFolderButton.enabled = deleteButton.enabled = false;
    if (fileSwitchType == LibraryFileType.LOCAL) {
        reloadButton.enabled = openFolderButton.enabled = newFolderButton.enabled = true;
        reloadButton.enabled = true;
        if (listItem != null && !listItem.getDisplayName().equals("../")) {
            deleteButton.enabled = true;
        } else {
            deleteButton.setDisableText(GuiHelper.getLocalizedControlName(armourLibrary.getInventoryName(), "rollover.deleteSkinSelect"));
        }
    }
    if (fileSwitchType == LibraryFileType.SERVER_PUBLIC) {
        openFolderButton.setDisableText("");
        reloadButton.setDisableText("");
        deleteButton.setDisableText("");
        newFolderButton.setDisableText("");
    }
    if (fileSwitchType == LibraryFileType.SERVER_PRIVATE) {
        openFolderButton.setDisableText("");
        reloadButton.setDisableText("");
        newFolderButton.enabled = true;
        if (listItem != null && !listItem.getDisplayName().equals("../")) {
            deleteButton.enabled = true;
        } else {
            deleteButton.setDisableText(GuiHelper.getLocalizedControlName(armourLibrary.getInventoryName(), "rollover.deleteSkinSelect"));
        }
    }
}
Also used : IGuiListItem(riskyken.armourersWorkshop.client.gui.controls.IGuiListItem)

Example 2 with IGuiListItem

use of riskyken.armourersWorkshop.client.gui.controls.IGuiListItem 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)

Aggregations

IGuiListItem (riskyken.armourersWorkshop.client.gui.controls.IGuiListItem)2 GuiButton (net.minecraft.client.gui.GuiButton)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 Slot (net.minecraft.inventory.Slot)1 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)1 GuiFileListItem (riskyken.armourersWorkshop.client.gui.controls.GuiFileListItem)1 GuiIconButton (riskyken.armourersWorkshop.client.gui.controls.GuiIconButton)1 ILibraryManager (riskyken.armourersWorkshop.common.library.ILibraryManager)1 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)1 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)1 SkinIdentifier (riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)1 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)1