2013-08-27 00:49:32 +02:00
|
|
|
package mekanism.client.gui;
|
2012-08-15 22:41:41 +02:00
|
|
|
|
2013-12-01 06:03:40 +01:00
|
|
|
import mekanism.api.EnumColor;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.client.ThreadClientUpdate;
|
2013-04-06 19:28:59 +02:00
|
|
|
import mekanism.common.IModule;
|
2012-11-05 20:29:04 +01:00
|
|
|
import mekanism.common.Mekanism;
|
2013-04-06 19:28:59 +02:00
|
|
|
import mekanism.common.Version;
|
2013-08-27 00:57:08 +02:00
|
|
|
import mekanism.common.util.MekanismUtils;
|
2012-12-20 22:53:39 +01:00
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
import net.minecraft.client.gui.GuiScreen;
|
2013-06-29 01:43:45 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2012-08-15 22:41:41 +02:00
|
|
|
|
2013-04-13 16:33:37 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-03-18 17:23:57 +01:00
|
|
|
public class GuiCredits extends GuiScreen
|
|
|
|
{
|
2012-08-15 22:41:41 +02:00
|
|
|
private static String updateProgress = "";
|
2013-04-05 22:26:48 +02:00
|
|
|
private boolean updatedRecently;
|
|
|
|
private boolean notified = false;
|
2012-08-15 22:41:41 +02:00
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public void initGui()
|
|
|
|
{
|
2013-03-18 17:23:57 +01:00
|
|
|
buttonList.clear();
|
|
|
|
buttonList.add(new GuiButton(0, width / 2 - 100, height / 4 + 72 + 12, "Update"));
|
|
|
|
buttonList.add(new GuiButton(1, width / 2 - 100, height / 4 + 96 + 12, "Cancel"));
|
2013-04-06 19:28:59 +02:00
|
|
|
((GuiButton)buttonList.get(0)).enabled = !MekanismUtils.noUpdates() && !ThreadClientUpdate.hasUpdated;
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void onFinishedDownloading()
|
|
|
|
{
|
|
|
|
updateProgress = "Successfully updated. Restart Minecraft to load.";
|
2013-04-05 22:26:48 +02:00
|
|
|
System.out.println("[Mekanism] Successfully updated to latest version (" + Mekanism.latestVersionNumber + ").");
|
|
|
|
ThreadClientUpdate.hasUpdated = true;
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void onErrorDownloading()
|
|
|
|
{
|
2012-11-05 16:52:56 +01:00
|
|
|
updateProgress = EnumColor.DARK_RED + "Error updating.";
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
protected void actionPerformed(GuiButton guibutton)
|
|
|
|
{
|
|
|
|
if(!guibutton.enabled)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-01-21 02:15:59 +01:00
|
|
|
if(guibutton.id == 0)
|
2012-08-15 22:41:41 +02:00
|
|
|
{
|
2013-04-06 19:28:59 +02:00
|
|
|
if(!MekanismUtils.noUpdates())
|
2012-08-15 22:41:41 +02:00
|
|
|
{
|
2013-04-05 22:26:48 +02:00
|
|
|
updatedRecently = true;
|
2012-08-15 22:41:41 +02:00
|
|
|
updateProgress = "Downloading latest version...";
|
|
|
|
guibutton.enabled = false;
|
2013-04-05 22:26:48 +02:00
|
|
|
|
2013-04-06 19:28:59 +02:00
|
|
|
if(Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) == -1)
|
2013-04-05 22:26:48 +02:00
|
|
|
{
|
2013-04-06 19:28:59 +02:00
|
|
|
new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/Mekanism-v" + Mekanism.latestVersionNumber + ".jar", "");
|
2013-04-05 22:26:48 +02:00
|
|
|
}
|
|
|
|
|
2013-04-06 19:28:59 +02:00
|
|
|
for(IModule module : Mekanism.modulesLoaded)
|
2013-04-05 22:26:48 +02:00
|
|
|
{
|
2013-04-06 19:28:59 +02:00
|
|
|
if(module.getVersion().comparedState(Version.get(Mekanism.latestVersionNumber)) == -1)
|
|
|
|
{
|
|
|
|
new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/Mekanism" + module.getName() + "-v" + Mekanism.latestVersionNumber + ".jar", module.getName());
|
|
|
|
}
|
2013-04-05 22:26:48 +02:00
|
|
|
}
|
2012-08-17 22:40:28 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
updateProgress = "You already have the latest version.";
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(guibutton.id == 1)
|
|
|
|
{
|
|
|
|
mc.displayGuiScreen(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void writeText(String text, int yAxis)
|
|
|
|
{
|
|
|
|
drawString(fontRenderer, text, width / 2 - 140, (height / 4 - 60) + 20 + yAxis, 0xa0a0a0);
|
|
|
|
}
|
|
|
|
|
2012-11-23 03:22:11 +01:00
|
|
|
@Override
|
2012-11-07 21:01:46 +01:00
|
|
|
public boolean doesGuiPauseGame()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2013-11-27 02:11:26 +01:00
|
|
|
public void drawScreen(int mouseX, int mouseY, float partialTick)
|
2012-08-15 22:41:41 +02:00
|
|
|
{
|
2013-04-05 22:26:48 +02:00
|
|
|
if(updatedRecently && ThreadClientUpdate.modulesBeingDownloaded == 0 && !updateProgress.contains("Error"))
|
|
|
|
{
|
|
|
|
if(!notified)
|
|
|
|
{
|
|
|
|
onFinishedDownloading();
|
|
|
|
notified = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ThreadClientUpdate.hasUpdated && !notified)
|
|
|
|
{
|
|
|
|
updateProgress = "You have already downloaded the update. Restart MC!";
|
|
|
|
}
|
|
|
|
|
2012-08-15 22:41:41 +02:00
|
|
|
drawDefaultBackground();
|
2012-11-05 20:29:04 +01:00
|
|
|
drawCenteredString(fontRenderer, EnumColor.DARK_BLUE + "Mekanism" + EnumColor.GREY + " by aidancbrady", width / 2, (height / 4 - 60) + 20, 0xffffff);
|
2013-11-23 01:32:06 +01:00
|
|
|
|
|
|
|
if(Mekanism.latestVersionNumber != null && !Mekanism.latestVersionNumber.equals("null"))
|
|
|
|
{
|
|
|
|
writeText(EnumColor.INDIGO + "Mekanism " + (Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) == -1 ? EnumColor.DARK_RED : EnumColor.GREY) + Mekanism.versionNumber, 36);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
writeText(EnumColor.INDIGO + "Mekanism " + EnumColor.GREY + Mekanism.versionNumber, 36);
|
|
|
|
}
|
2013-04-06 19:28:59 +02:00
|
|
|
|
|
|
|
int size = 36;
|
|
|
|
|
|
|
|
for(IModule module : Mekanism.modulesLoaded)
|
|
|
|
{
|
|
|
|
size += 9;
|
2013-11-23 01:32:06 +01:00
|
|
|
|
|
|
|
if(Mekanism.latestVersionNumber != null && !Mekanism.latestVersionNumber.equals("null"))
|
|
|
|
{
|
|
|
|
writeText(EnumColor.INDIGO + "Mekanism" + module.getName() + (module.getVersion().comparedState(Version.get(Mekanism.latestVersionNumber)) == -1 ? EnumColor.DARK_RED : EnumColor.GREY) + " " + module.getVersion(), size);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
writeText(EnumColor.INDIGO + "Mekanism" + module.getName() + EnumColor.GREY + " " + module.getVersion(), size);
|
|
|
|
}
|
|
|
|
}
|
2013-04-06 19:28:59 +02:00
|
|
|
|
|
|
|
writeText(EnumColor.GREY + "Newest version: " + Mekanism.latestVersionNumber, size+9);
|
|
|
|
writeText(EnumColor.GREY + "*Developed on Mac OS X 10.8 Mountain Lion", size+18);
|
|
|
|
writeText(EnumColor.GREY + "*Code, textures, and ideas by aidancbrady", size+27);
|
|
|
|
writeText(EnumColor.GREY + "Recent news: " + EnumColor.DARK_BLUE + (!Mekanism.recentNews.contains("null") ? Mekanism.recentNews : "couldn't access."), size+36);
|
|
|
|
writeText(EnumColor.GREY + updateProgress, size+45);
|
2013-11-27 02:11:26 +01:00
|
|
|
|
|
|
|
super.drawScreen(mouseX, mouseY, partialTick);
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
|
|
|
}
|