    001    package net.minecraft.client.gui;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import net.minecraft.util.IProgressUpdate;
    006
    007    @SideOnly(Side.CLIENT)
    008    public class GuiProgress extends GuiScreen implements IProgressUpdate
    009    {
    010        private String progressMessage = "";
    011        private String workingMessage = "";
    012        private int currentProgress = 0;
    013        private boolean noMoreProgress;
    014
    015        /**
    016         * "Saving level", or the loading,or downloading equivelent
    017         */
    018        public void displayProgressMessage(String par1Str)
    019        {
    020            this.resetProgressAndMessage(par1Str);
    021        }
    022
    023        /**
    024         * this string, followed by "working..." and then the "% complete" are the 3 lines shown. This resets progress to 0,
    025         * and the WorkingString to "working...".
    026         */
    027        public void resetProgressAndMessage(String par1Str)
    028        {
    029            this.progressMessage = par1Str;
    030            this.resetProgresAndWorkingMessage("Working...");
    031        }
    032
    033        /**
    034         * This is called with "Working..." by resetProgressAndMessage
    035         */
    036        public void resetProgresAndWorkingMessage(String par1Str)
    037        {
    038            this.workingMessage = par1Str;
    039            this.setLoadingProgress(0);
    040        }
    041
    042        /**
    043         * Updates the progress bar on the loading screen to the specified amount. Args: loadProgress
    044         */
    045        public void setLoadingProgress(int par1)
    046        {
    047            this.currentProgress = par1;
    048        }
    049
    050        /**
    051         * called when there is no more progress to be had, both on completion and failure
    052         */
    053        public void onNoMoreProgress()
    054        {
    055            this.noMoreProgress = true;
    056        }
    057
    058        /**
    059         * Draws the screen and all the components in it.
    060         */
    061        public void drawScreen(int par1, int par2, float par3)
    062        {
    063            if (this.noMoreProgress)
    064            {
    065                this.mc.displayGuiScreen((GuiScreen)null);
    066            }
    067            else
    068            {
    069                this.drawDefaultBackground();
    070                this.drawCenteredString(this.fontRenderer, this.progressMessage, this.width / 2, 70, 16777215);
    071                this.drawCenteredString(this.fontRenderer, this.workingMessage + " " + this.currentProgress + "%", this.width / 2, 90, 16777215);
    072                super.drawScreen(par1, par2, par3);
    073            }
    074        }
    075    }