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

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

public class ControlsPanel extends Panel<GuiEditor> {

    private GuiButton partTypeButton;

    @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() {
        //Reset/Save
        buttonList.add(new GuiButton(12, width - 83, height - 25, 40, 20, I18n.format("gui.button.reset")));
        buttonList.add(new GuiButton(13, width - 43, height - 25, 40, 20, I18n.format("gui.done")));

        //Export
        buttonList.add(new GuiBaseScreen.GuiButtonTooltip(14, (width / 2) - 20, height - 25, 40, 20, I18n.format("gui.button.export"),
                (width / 2) - 20, I18n.format("gui.button.export.0.tooltip")));

        //PartType Select
        buttonList.add(partTypeButton = new GuiButton(20, 3, height - 25, 40, 20, parent.getPartType().name()));
    }

    @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();
        //Reset All
        if (button.id == 12) {
            PartInfo partInfo = parent.originalPartInfo.deepCopy();
            parent.partsPanel.selectDefaultListEntry();
            parent.setCurrTintEdit(0);
            parent.refreshTintPane();
            parent.setPartsInfo(partInfo);
        }
        //Save All
        else if (button.id == 13) {
            //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().func_148256_e().getId(), partsData, false));
            ToastManager.INSTANCE.createCenteredToast(parent.width / 2, parent.height - 40, 100, EnumChatFormatting.GREEN + "Saved!");
            this.mc.displayGuiScreen(null);
        }
        //Export
        else if (button.id == 14) {
            mc.displayGuiScreen(new GuiExport(parent, partsData));
        }
        //PartType
        else if (button.id == 20) {
            if (parent.getPartType().ordinal() + 1 >= PartsData.PartType.values().length) {
                parent.setPartType(PartsData.PartType.values()[0]);
            }
            else {
                parent.setPartType(PartsData.PartType.values()[parent.getPartType().ordinal() + 1]);
            }

            partTypeButton.displayString = parent.getPartType().name();
        }
    }
}<commit_msg>Add in button to switch between library and editor mode<commit_after>/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014
 *
 * See LICENSE for full License
 */
package kihira.tails.client.gui;

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

public class ControlsPanel extends Panel<GuiEditor> {

    private GuiButton partTypeButton;

    @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() {
        //Mode Switch
        buttonList.add(new GuiButton(0, 38, height - 25, 45, 20, "Library"));
        //Reset/Save
        buttonList.add(new GuiButton(1, width - 83, height - 25, 40, 20, I18n.format("gui.button.reset")));
        buttonList.add(new GuiButton(2, width - 43, height - 25, 40, 20, I18n.format("gui.done")));

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

        //PartType Select
        buttonList.add(partTypeButton = new GuiButton(4, 3, height - 25, 35, 20, parent.getPartType().name()));
    }

    @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!
            boolean libraryMode = button.displayString.equals("Library");
            parent.partsPanel.enabled = !libraryMode;
            parent.texturePanel.enabled = !libraryMode;
            parent.tintPanel.enabled = !libraryMode;

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

            button.displayString = (libraryMode ? "Editor" : "Library");
        }
        //Reset All
        else if (button.id == 1) {
            PartInfo partInfo = parent.originalPartInfo.deepCopy();
            parent.partsPanel.selectDefaultListEntry();
            parent.setCurrTintEdit(0);
            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().func_148256_e().getId(), partsData, false));
            ToastManager.INSTANCE.createCenteredToast(parent.width / 2, parent.height - 40, 100, EnumChatFormatting.GREEN + "Saved!");
            this.mc.displayGuiScreen(null);
        }
        //Export
        else if (button.id == 3) {
            mc.displayGuiScreen(new GuiExport(parent, partsData));
        }
        //PartType
        else if (button.id == 4) {
            if (parent.getPartType().ordinal() + 1 >= PartsData.PartType.values().length) {
                parent.setPartType(PartsData.PartType.values()[0]);
            }
            else {
                parent.setPartType(PartsData.PartType.values()[parent.getPartType().ordinal() + 1]);
            }

            partTypeButton.displayString = parent.getPartType().name();
        }
    }
}
{'fraction_non_alphanumeric': 0.12313432835820895, 'fraction_numerical': 0.02542841348811498, 'mean_word_length': 2.60587942202292, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4889473', 'n_tokens_mistral': 2306, 'n_tokens_neox': 2133, 'n_words': 445}