| 1 | package net.minecraft.client.gui;
|
| 2 |
|
| 3 | import java.io.IOException;
|
| 4 | import net.minecraft.client.resources.I18n;
|
| 5 | import net.minecraft.entity.player.EnumPlayerModelParts;
|
| 6 |
|
| 7 | public class GuiCustomizeSkin extends GuiScreen
|
| 8 | {
|
| 9 | /** The parent GUI for this GUI */
|
| 10 | private final GuiScreen parentScreen;
|
| 11 |
|
| 12 | /** The title of the GUI. */
|
| 13 | private String title;
|
| 14 |
|
| 15 | public GuiCustomizeSkin(GuiScreen parentScreenIn)
|
| 16 | {
|
| 17 | this.parentScreen = parentScreenIn;
|
| 18 | }
|
| 19 |
|
| 20 | /**
|
| 21 | * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
|
| 22 | * window resizes, the buttonList is cleared beforehand.
|
| 23 | */
|
| 24 | public void initGui()
|
| 25 | {
|
| 26 | int i = 0;
|
| 27 | this.title = I18n.format("options.skinCustomisation.title", new Object[0]);
|
| 28 |
|
| 29 | for (EnumPlayerModelParts enumplayermodelparts : EnumPlayerModelParts.values())
|
| 30 | {
|
| 31 | this.buttonList.add(new GuiCustomizeSkin.ButtonPart(enumplayermodelparts.getPartId(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), 150, 20, enumplayermodelparts));
|
| 32 | ++i;
|
| 33 | }
|
| 34 |
|
| 35 | if (i % 2 == 1)
|
| 36 | {
|
| 37 | ++i;
|
| 38 | }
|
| 39 |
|
| 40 | this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 24 * (i >> 1), I18n.format("gui.done", new Object[0])));
|
| 41 | }
|
| 42 |
|
| 43 | /**
|
| 44 | * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
|
| 45 | */
|
| 46 | protected void actionPerformed(GuiButton button) throws IOException
|
| 47 | {
|
| 48 | if (button.enabled)
|
| 49 | {
|
| 50 | if (button.id == 200)
|
| 51 | {
|
| 52 | this.mc.gameSettings.saveOptions();
|
| 53 | this.mc.displayGuiScreen(this.parentScreen);
|
| 54 | }
|
| 55 | else if (button instanceof GuiCustomizeSkin.ButtonPart)
|
| 56 | {
|
| 57 | EnumPlayerModelParts enumplayermodelparts = ((GuiCustomizeSkin.ButtonPart)button).playerModelParts;
|
| 58 | this.mc.gameSettings.switchModelPartEnabled(enumplayermodelparts);
|
| 59 | button.displayString = this.func_175358_a(enumplayermodelparts);
|
| 60 | }
|
| 61 | }
|
| 62 | }
|
| 63 |
|
| 64 | /**
|
| 65 | * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
|
| 66 | */
|
| 67 | public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
| 68 | {
|
| 69 | this.drawDefaultBackground();
|
| 70 | this.drawCenteredString(this.fontRendererObj, this.title, this.width / 2, 20, 16777215);
|
| 71 | super.drawScreen(mouseX, mouseY, partialTicks);
|
| 72 | }
|
| 73 |
|
| 74 | private String func_175358_a(EnumPlayerModelParts playerModelParts)
|
| 75 | {
|
| 76 | String s;
|
| 77 |
|
| 78 | if (this.mc.gameSettings.getModelParts().contains(playerModelParts))
|
| 79 | {
|
| 80 | s = I18n.format("options.on", new Object[0]);
|
| 81 | }
|
| 82 | else
|
| 83 | {
|
| 84 | s = I18n.format("options.off", new Object[0]);
|
| 85 | }
|
| 86 |
|
| 87 | return playerModelParts.func_179326_d().getFormattedText() + ": " + s;
|
| 88 | }
|
| 89 |
|
| 90 | class ButtonPart extends GuiButton
|
| 91 | {
|
| 92 | private final EnumPlayerModelParts playerModelParts;
|
| 93 |
|
| 94 | private ButtonPart(int p_i45514_2_, int p_i45514_3_, int p_i45514_4_, int p_i45514_5_, int p_i45514_6_, EnumPlayerModelParts playerModelParts)
|
| 95 | {
|
| 96 | super(p_i45514_2_, p_i45514_3_, p_i45514_4_, p_i45514_5_, p_i45514_6_, GuiCustomizeSkin.this.func_175358_a(playerModelParts));
|
| 97 | this.playerModelParts = playerModelParts;
|
| 98 | }
|
| 99 | }
|
| 100 | }
|
| 101 |
|