001package net.minecraft.client.gui;
002
003import cpw.mods.fml.relauncher.Side;
004import cpw.mods.fml.relauncher.SideOnly;
005import java.io.IOException;
006import java.text.SimpleDateFormat;
007import java.util.GregorianCalendar;
008import java.util.TimeZone;
009import net.minecraft.client.mco.ExceptionMcoService;
010import net.minecraft.client.mco.McoClient;
011import net.minecraft.client.mco.McoServer;
012import net.minecraft.client.mco.ValueObjectSubscription;
013import net.minecraft.util.StringTranslate;
014import org.lwjgl.input.Keyboard;
015
016@SideOnly(Side.CLIENT)
017public class GuiScreenSubscription extends GuiScreen
018{
019    private final GuiScreen field_98067_a;
020    private final McoServer field_98065_b;
021    private final int field_98066_c = 0;
022    private final int field_98064_d = 1;
023    private int field_98068_n;
024    private String field_98069_o;
025
026    public GuiScreenSubscription(GuiScreen par1GuiScreen, McoServer par2McoServer)
027    {
028        this.field_98067_a = par1GuiScreen;
029        this.field_98065_b = par2McoServer;
030    }
031
032    /**
033     * Called from the main game loop to update the screen.
034     */
035    public void updateScreen() {}
036
037    /**
038     * Adds the buttons (and other controls) to the screen in question.
039     */
040    public void initGui()
041    {
042        this.func_98063_a(this.field_98065_b.field_96408_a);
043        StringTranslate stringtranslate = StringTranslate.getInstance();
044        Keyboard.enableRepeatEvents(true);
045        this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, stringtranslate.translateKey("gui.cancel")));
046    }
047
048    private void func_98063_a(long par1)
049    {
050        McoClient mcoclient = new McoClient(this.mc.session);
051
052        try
053        {
054            ValueObjectSubscription valueobjectsubscription = mcoclient.func_98177_f(par1);
055            this.field_98068_n = valueobjectsubscription.field_98170_b;
056            this.field_98069_o = this.func_98062_b(valueobjectsubscription.field_98171_a);
057        }
058        catch (ExceptionMcoService exceptionmcoservice)
059        {
060            ;
061        }
062        catch (IOException ioexception)
063        {
064            ;
065        }
066    }
067
068    private String func_98062_b(long par1)
069    {
070        GregorianCalendar gregoriancalendar = new GregorianCalendar(TimeZone.getDefault());
071        gregoriancalendar.setTimeInMillis(par1);
072        return SimpleDateFormat.getDateTimeInstance().format(gregoriancalendar.getTime());
073    }
074
075    /**
076     * Called when the screen is unloaded. Used to disable keyboard repeat events
077     */
078    public void onGuiClosed()
079    {
080        Keyboard.enableRepeatEvents(false);
081    }
082
083    /**
084     * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
085     */
086    protected void actionPerformed(GuiButton par1GuiButton)
087    {
088        if (par1GuiButton.enabled)
089        {
090            if (par1GuiButton.id == 0)
091            {
092                this.mc.displayGuiScreen(this.field_98067_a);
093            }
094            else if (par1GuiButton.id == 1)
095            {
096                ;
097            }
098        }
099    }
100
101    /**
102     * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
103     */
104    protected void keyTyped(char par1, int par2) {}
105
106    /**
107     * Called when the mouse is clicked.
108     */
109    protected void mouseClicked(int par1, int par2, int par3)
110    {
111        super.mouseClicked(par1, par2, par3);
112    }
113
114    /**
115     * Draws the screen and all the components in it.
116     */
117    public void drawScreen(int par1, int par2, float par3)
118    {
119        StringTranslate stringtranslate = StringTranslate.getInstance();
120        this.drawDefaultBackground();
121        this.drawCenteredString(this.fontRenderer, stringtranslate.translateKey("mco.configure.world.subscription.title"), this.width / 2, 17, 16777215);
122        this.drawString(this.fontRenderer, stringtranslate.translateKey("mco.configure.world.subscription.start"), this.width / 2 - 100, 53, 10526880);
123        this.drawString(this.fontRenderer, this.field_98069_o, this.width / 2 - 100, 66, 16777215);
124        this.drawString(this.fontRenderer, stringtranslate.translateKey("mco.configure.world.subscription.daysleft"), this.width / 2 - 100, 85, 10526880);
125        this.drawString(this.fontRenderer, String.valueOf(this.field_98068_n), this.width / 2 - 100, 98, 16777215);
126        super.drawScreen(par1, par2, par3);
127    }
128}