Search in sources :

Example 11 with GuiGlobalLibrary

use of riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary in project Armourers-Workshop by RiskyKen.

the class GuiGlobalLibraryPanelUpload method update.

@Override
public void update() {
    super.update();
    buttonUpload.enabled = false;
    if (!StringUtils.isNullOrEmpty(textName.getText())) {
        SlotHidable slot = ((GuiGlobalLibrary) parent).getInputSlot();
        if (SkinNBTHelper.stackHasSkinData(slot.getStack())) {
            buttonUpload.enabled = true;
        }
    }
    if (taskSkinUpload != null && taskSkinUpload.isDone()) {
        try {
            JsonObject json = taskSkinUpload.get();
            taskSkinUpload = null;
            if (json != null) {
                if (json.has("valid") & json.has("action")) {
                    String action = json.get("action").getAsString();
                    boolean valid = json.get("valid").getAsBoolean();
                    if (valid & action.equals("skin-upload")) {
                        ((GuiGlobalLibrary) parent).panelHome.updateSkinPanels();
                        ((GuiGlobalLibrary) parent).switchScreen(Screen.HOME);
                    }
                } else {
                    if (json.has("reason")) {
                        String reason = json.get("reason").getAsString();
                        error = reason;
                    }
                }
            } else {
            // TODO handle upload failure
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}
Also used : JsonObject(com.google.gson.JsonObject) ExecutionException(java.util.concurrent.ExecutionException) SlotHidable(riskyken.armourersWorkshop.common.inventory.slot.SlotHidable) GuiGlobalLibrary(riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary)

Example 12 with GuiGlobalLibrary

use of riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary in project Armourers-Workshop by RiskyKen.

the class GuiGlobalLibraryPanelUserSkins method draw.

@Override
public void draw(int mouseX, int mouseY, float partialTickTime) {
    if (!visible) {
        return;
    }
    PlushieUser plushieUser = GlobalSkinLibraryUtils.getUserInfo(userId);
    String username = "unknown";
    if (plushieUser != null) {
        username = plushieUser.getUsername();
    }
    drawGradientRect(this.x, this.y, this.x + this.width, this.y + height, 0xC0101010, 0xD0101010);
    super.draw(mouseX, mouseY, partialTickTime);
    int maxPages = totalPages;
    int totalSkins = totalResults;
    String guiName = ((GuiGlobalLibrary) parent).getGuiName();
    String unlocalizedName = "inventory." + LibModInfo.ID.toLowerCase() + ":" + guiName + "." + "userSkins.results";
    String resultsText = TranslateUtils.translate(unlocalizedName, username, currentPageIndex + 1, maxPages, totalSkins);
    if (jsonCurrentPage == null) {
        resultsText = GuiHelper.getLocalizedControlName(guiName, "searchResults.label.searching");
    }
    fontRenderer.drawString(resultsText, x + 5, y + 6, 0xFFEEEEEE);
}
Also used : PlushieUser(riskyken.armourersWorkshop.common.library.global.PlushieUser) GuiGlobalLibrary(riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary)

Example 13 with GuiGlobalLibrary

use of riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary in project Armourers-Workshop by RiskyKen.

the class GuiGlobalLibraryPanelHeader method draw.

@Override
public void draw(int mouseX, int mouseY, float partialTickTime) {
    if (!visible) {
        return;
    }
    drawGradientRect(this.x, this.y, this.x + this.width, this.y + height, 0xC0101010, 0xD0101010);
    super.draw(mouseX, mouseY, partialTickTime);
    // TODO look in YggdrasilMinecraftSessionService
    String username = "player";
    GameProfile gameProfile = mc.thePlayer.getGameProfile();
    if (gameProfile != null) {
        username = gameProfile.getName();
        GuiHelper.drawPlayerHead(x + 4, y + 4, 16, username);
        this.fontRenderer.drawString(" - " + username, this.x + 24, this.y + (height / 2) - fontRenderer.FONT_HEIGHT / 2, 0xAAFFAA);
    } else {
        this.fontRenderer.drawString("Not logged in.", this.x + 90, this.y + (height / 2) - fontRenderer.FONT_HEIGHT / 2, 0xFFAAAA);
    }
    String titleText = ((GuiGlobalLibrary) parent).tileEntity.getBlockType().getLocalizedName();
    drawCenteredString(fontRenderer, titleText, x + (width / 2), this.y + (height / 2) - fontRenderer.FONT_HEIGHT / 2, 0xFFEEEEEE);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) GuiGlobalLibrary(riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary)

Example 14 with GuiGlobalLibrary

use of riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary in project Armourers-Workshop by RiskyKen.

the class GuiGlobalLibraryPanelHome method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    if (button == buttonShowAll) {
        ((GuiGlobalLibrary) parent).panelSearchResults.clearResults();
        ((GuiGlobalLibrary) parent).switchScreen(Screen.SEARCH);
        ((GuiGlobalLibrary) parent).panelSearchResults.doSearch("");
    }
    if (button == skinPanelRecentlyUploaded | button == skinPanelMostDownloaded | button == skinPanelMostLiked) {
        SkinIcon skinIcon = ((GuiControlSkinPanel) button).getLastPressedSkinIcon();
        if (skinIcon != null) {
            ((GuiGlobalLibrary) parent).panelSkinInfo.displaySkinInfo(skinIcon.getSkinJson(), Screen.HOME);
        }
    }
}
Also used : GuiControlSkinPanel(riskyken.armourersWorkshop.client.gui.controls.GuiControlSkinPanel) GuiGlobalLibrary(riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary) SkinIcon(riskyken.armourersWorkshop.client.gui.controls.GuiControlSkinPanel.SkinIcon)

Example 15 with GuiGlobalLibrary

use of riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary in project Armourers-Workshop by RiskyKen.

the class GuiGlobalLibraryPanelSearchBox method initGui.

@Override
public void initGui() {
    super.initGui();
    String guiName = ((GuiGlobalLibrary) parent).getGuiName();
    buttonList.clear();
    searchTextbox = new GuiLabeledTextField(fontRenderer, x + 5, y + 5, width - 10 - 85, 12);
    searchTextbox.setEmptyLabel(GuiHelper.getLocalizedControlName(guiName, "searchBox.typeToSearch"));
    buttonList.add(new GuiButtonExt(0, x + width - 85, y + 3, 80, 16, GuiHelper.getLocalizedControlName(guiName, "searchBox.search")));
}
Also used : GuiLabeledTextField(riskyken.armourersWorkshop.client.gui.controls.GuiLabeledTextField) GuiButtonExt(cpw.mods.fml.client.config.GuiButtonExt) GuiGlobalLibrary(riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary)

Aggregations

GuiGlobalLibrary (riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary)15 JsonObject (com.google.gson.JsonObject)4 PlushieSession (riskyken.armourersWorkshop.common.library.global.auth.PlushieSession)4 GuiButtonExt (cpw.mods.fml.client.config.GuiButtonExt)3 ExecutionException (java.util.concurrent.ExecutionException)2 DownloadJsonObjectCallable (riskyken.armourersWorkshop.common.library.global.DownloadUtils.DownloadJsonObjectCallable)2 PlushieUser (riskyken.armourersWorkshop.common.library.global.PlushieUser)2 GameProfile (com.mojang.authlib.GameProfile)1 GuiScreen (net.minecraft.client.gui.GuiScreen)1 GuiControlSkinPanel (riskyken.armourersWorkshop.client.gui.controls.GuiControlSkinPanel)1 SkinIcon (riskyken.armourersWorkshop.client.gui.controls.GuiControlSkinPanel.SkinIcon)1 GuiIconButton (riskyken.armourersWorkshop.client.gui.controls.GuiIconButton)1 GuiLabeledTextField (riskyken.armourersWorkshop.client.gui.controls.GuiLabeledTextField)1 SlotHidable (riskyken.armourersWorkshop.common.inventory.slot.SlotHidable)1 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)1