/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014
 *
 * See LICENSE for full License
 */
package uk.kihira.tails.client.gui;

import uk.kihira.foxlib.client.gui.GuiBaseScreen;
import uk.kihira.foxlib.client.toast.ToastManager;
import uk.kihira.tails.common.PartInfo;
import uk.kihira.tails.common.PartsData;
import uk.kihira.tails.common.Tails;
import uk.kihira.tails.common.network.PlayerDataMessage;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;

public class ControlsPanel extends Panel<GuiEditor> {

    @SuppressWarnings("unchecked")
    public ControlsPanel(GuiEditor parent, int left, int top, int right, int bottom) {
        super(parent, left, top, right, bottom);
    }

    @Override
    @SuppressWarnings("unchecked")
    public void initGui() {
        int spacing = (width - 51) / 3;
        //Mode Switch
        buttonList.add(new GuiButton(0, 3, height - 25, 46, 20, I18n.format("gui.button.mode.library")));
        //Reset/Save
        buttonList.add(new GuiButton(1, 3 + spacing * 2, height - 25, 46, 20, I18n.format("gui.button.reset")));
        buttonList.add(new GuiButton(2, 3 + spacing * 3, height - 25, 46, 20, I18n.format("gui.done")));

        //Export
        buttonList.add(new GuiBaseScreen.GuiButtonTooltip(3, 3 + spacing, height - 25, 46, 20, I18n.format("gui.button.export"),
                (width / 2) - 20, I18n.format("gui.button.export.0.tooltip")));
    }

    @Override
    public void drawScreen(int mouseX, int mouseY, float partialTicks) {
        drawRect(0, 0, width, height, 0xDD000000);

        super.drawScreen(mouseX, mouseY, partialTicks);
    }

    @Override
    protected void actionPerformed(GuiButton button) {
        PartsData partsData = parent.getPartsData();
        //Mode Switch
        if (button.id == 0) {
            //>.> You see nothing!
            //TODO change parts data when switching? clear libraryinfo panel?
            boolean libraryMode = button.displayString.equals(I18n.format("gui.button.mode.library"));
            parent.partsPanel.enabled = !libraryMode;
            parent.texturePanel.enabled = !libraryMode;
            parent.tintPanel.enabled = !libraryMode;

            parent.libraryInfoPanel.enabled = libraryMode;
            parent.libraryPanel.enabled = libraryMode;
            parent.libraryImportPanel.enabled = libraryMode;

            parent.partsPanel.selectDefaultListEntry();
            parent.libraryPanel.initList();
            parent.libraryInfoPanel.setEntry(null);
            parent.clearCurrTintEdit();
            parent.refreshTintPane();

            if (!libraryMode) {
                Tails.setLocalPartsData(parent.getPartsData());
            }
            parent.setPartsData(Tails.localPartsData);

            button.displayString = (libraryMode ? I18n.format("gui.button.mode.editor") : I18n.format("gui.button.mode.library"));
        }
        //Reset All
        else if (button.id == 1) {
            PartInfo partInfo = parent.originalPartInfo.deepCopy();
            parent.partsPanel.selectDefaultListEntry();
            parent.libraryPanel.initList();
            parent.libraryInfoPanel.setEntry(null);
            parent.clearCurrTintEdit();
            parent.refreshTintPane();
            parent.setPartsInfo(partInfo);
        }
        //Save All
        else if (button.id == 2) {
            //Update part info, set local and send it to the server
            Tails.setLocalPartsData(partsData);
            Tails.proxy.addPartsData(mc.thePlayer.getPersistentID(), partsData);
            Tails.networkWrapper.sendToServer(new PlayerDataMessage(mc.getSession().getProfile().getId(), partsData, false));
            ToastManager.INSTANCE.createCenteredToast(parent.width / 2, parent.height - 40, 100, TextFormatting.GREEN + "Saved!");
            this.mc.displayGuiScreen(null);
        }
        //Export
        else if (button.id == 3) {
            mc.displayGuiScreen(new GuiExport(parent, partsData));
        }
    }
}

@@ -133,49 +133,133 @@
 ort 
-uk.kihira.foxlib.client.gui.GuiBaseScreen
+net.minecraft.client.gui.GuiButton;%0Aimport net.minecraft.client.resources.I18n;%0Aimport net.minecraft.util.text.TextFormatting
 ;%0Aim
@@ -485,142 +485,8 @@
 age;
-%0Aimport net.minecraft.client.gui.GuiButton;%0Aimport net.minecraft.client.resources.I18n;%0Aimport net.minecraft.util.text.TextFormatting;
 %0A%0Apu
@@ -797,48 +797,8 @@
 ) %7B%0A
-        int spacing = (width - 51) / 3;%0A
     
@@ -986,23 +986,20 @@
 (1, 
-3 + spacing *
+width/2 -
  2
+3
 , he
@@ -1096,294 +1096,62 @@
 (2, 
-3 + spacing * 3, height - 25, 46, 20, I18n.format(%22gui.done%22)));%0A%0A        //Export%0A        buttonList.add(new GuiBaseScreen.GuiButtonTooltip(3, 3 + spacing, height - 25, 46, 20, I18n.format(%22gui.button.export%22),%0A                (width / 2) - 20, I18n.format(%22gui.button.export.0.tooltip
+width - 49, height - 25, 46, 20, I18n.format(%22gui.done
 %22)))
@@ -3601,137 +3601,8 @@
   %7D%0A
-        //Export%0A        else if (button.id == 3) %7B%0A            mc.displayGuiScreen(new GuiExport(parent, partsData));%0A        %7D%0A
     

Remove export button as it's no longer used