Merge pull request #2616 from iTitus/updateNotificationIcon

Add update notification icon made by @gigaherz, closes #2582
This commit is contained in:
LexManos 2016-04-03 18:22:27 -07:00
commit 1811d88266
6 changed files with 180 additions and 28 deletions

View File

@ -1,16 +1,32 @@
--- ../src-base/minecraft/net/minecraft/client/gui/GuiMainMenu.java
+++ ../src-work/minecraft/net/minecraft/client/gui/GuiMainMenu.java
@@ -216,7 +216,8 @@
@@ -67,6 +67,8 @@
private GuiButton field_175372_K;
private boolean field_183502_L;
private GuiScreen field_183503_M;
+ private GuiButton modButton;
+ private net.minecraftforge.client.gui.NotificationModUpdateScreen modUpdateNotification;
public GuiMainMenu()
{
@@ -210,13 +212,15 @@
this.field_183503_M.func_183500_a(this.field_146294_l, this.field_146295_m);
this.field_183503_M.func_73866_w_();
}
+ modUpdateNotification = net.minecraftforge.client.gui.NotificationModUpdateScreen.init(this, modButton);
}
private void func_73969_a(int p_73969_1_, int p_73969_2_)
{
this.field_146292_n.add(new GuiButton(1, this.field_146294_l / 2 - 100, p_73969_1_, I18n.func_135052_a("menu.singleplayer", new Object[0])));
this.field_146292_n.add(new GuiButton(2, this.field_146294_l / 2 - 100, p_73969_1_ + p_73969_2_ * 1, I18n.func_135052_a("menu.multiplayer", new Object[0])));
- this.field_146292_n.add(this.field_175372_K = new GuiButton(14, this.field_146294_l / 2 - 100, p_73969_1_ + p_73969_2_ * 2, I18n.func_135052_a("menu.online", new Object[0])));
+ this.field_146292_n.add(this.field_175372_K = new GuiButton(14, this.field_146294_l / 2 + 2, p_73969_1_ + p_73969_2_ * 2, 98, 20, I18n.func_135052_a("menu.online", new Object[0]).replace("Minecraft", "").trim()));
+ this.field_146292_n.add(new GuiButton(6, this.field_146294_l / 2 - 100, p_73969_1_ + p_73969_2_ * 2, 98, 20, I18n.func_135052_a("fml.menu.mods")));
+ this.field_146292_n.add(modButton = new GuiButton(6, this.field_146294_l / 2 - 100, p_73969_1_ + p_73969_2_ * 2, 98, 20, I18n.func_135052_a("fml.menu.mods")));
}
private void func_73972_b(int p_73972_1_, int p_73972_2_)
@@ -264,6 +265,11 @@
@@ -264,6 +268,11 @@
this.field_146297_k.func_71400_g();
}
@ -22,7 +38,7 @@
if (p_146284_1_.field_146127_k == 11)
{
this.field_146297_k.func_71371_a("Demo_World", "Demo_World", DemoWorldServer.field_73071_a);
@@ -512,7 +518,16 @@
@@ -512,7 +521,16 @@
s = s + ("release".equalsIgnoreCase(this.field_146297_k.func_184123_d()) ? "" : "/" + this.field_146297_k.func_184123_d());
}
@ -40,3 +56,11 @@
String s1 = "Copyright Mojang AB. Do not distribute!";
this.func_73731_b(this.field_146289_q, s1, this.field_146294_l - this.field_146289_q.func_78256_a(s1) - 2, this.field_146295_m - 10, -1);
@@ -529,6 +547,7 @@
{
this.field_183503_M.func_73863_a(p_73863_1_, p_73863_2_, p_73863_3_);
}
+ modUpdateNotification.func_73863_a(p_73863_1_, p_73863_2_, p_73863_3_);
}
protected void func_73864_a(int p_73864_1_, int p_73864_2_, int p_73864_3_) throws IOException

View File

@ -0,0 +1,83 @@
package net.minecraftforge.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeModContainer;
import net.minecraftforge.common.ForgeVersion;
import net.minecraftforge.common.ForgeVersion.Status;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class NotificationModUpdateScreen extends GuiScreen
{
private static final ResourceLocation VERSION_CHECK_ICONS = new ResourceLocation("forge", "textures/gui/version_check_icons.png");
private final GuiButton modButton;
private Status showNotification = null;
private boolean hasCheckedForUpdates = false;
public NotificationModUpdateScreen(GuiButton modButton)
{
this.modButton = modButton;
}
@Override
public void initGui()
{
if (!hasCheckedForUpdates)
{
if (modButton != null)
{
for (ModContainer mod : Loader.instance().getModList())
{
Status status = ForgeVersion.getResult(mod).status;
if (status == Status.OUTDATED || status == Status.BETA_OUTDATED)
{
// TODO: Needs better visualization, maybe stacked icons
// drawn in a terrace-like pattern?
showNotification = Status.OUTDATED;
}
}
}
hasCheckedForUpdates = true;
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
if (showNotification == null || !showNotification.shouldDraw() || ForgeModContainer.disableVersionCheck)
{
return;
}
Minecraft.getMinecraft().getTextureManager().bindTexture(VERSION_CHECK_ICONS);
GlStateManager.color(1, 1, 1, 1);
GlStateManager.pushMatrix();
int x = modButton.xPosition;
int y = modButton.yPosition;
int w = modButton.width;
int h = modButton.height;
drawModalRectWithCustomSizedTexture(x + w - (h / 2 + 4), y + (h / 2 - 4), showNotification.getSheetOffset() * 8, (showNotification.isAnimated() && ((System.currentTimeMillis() / 800 & 1) == 1)) ? 8 : 0, 8, 8, 64, 16);
GlStateManager.popMatrix();
}
public static NotificationModUpdateScreen init(GuiMainMenu guiMainMenu, GuiButton modButton)
{
NotificationModUpdateScreen notificationModUpdateScreen = new NotificationModUpdateScreen(modButton);
notificationModUpdateScreen.setGuiSize(guiMainMenu.width, guiMainMenu.height);
notificationModUpdateScreen.initGui();
return notificationModUpdateScreen;
}
}

View File

@ -85,13 +85,54 @@ public class ForgeVersion
public static enum Status
{
PENDING,
FAILED,
UP_TO_DATE,
OUTDATED,
AHEAD,
BETA,
BETA_OUTDATED
PENDING(),
FAILED(),
UP_TO_DATE(),
OUTDATED(3, true),
AHEAD(),
BETA(),
BETA_OUTDATED(6, true);
final int sheetOffset;
final boolean draw, animated;
Status()
{
this(0, false, false);
}
Status(int sheetOffset)
{
this(sheetOffset, true, false);
}
Status(int sheetOffset, boolean animated)
{
this(sheetOffset, true, animated);
}
Status(int sheetOffset, boolean draw, boolean animated)
{
this.sheetOffset = sheetOffset;
this.draw = draw;
this.animated = animated;
}
public int getSheetOffset()
{
return sheetOffset;
}
public boolean shouldDraw()
{
return draw;
}
public boolean isAnimated()
{
return animated;
}
}
public static class CheckResult

View File

@ -153,13 +153,14 @@ public class GuiModList extends GuiScreen
@Override
public void initGui()
{
int slotHeight = 35;
for (ModContainer mod : mods)
{
listWidth = Math.max(listWidth,getFontRenderer().getStringWidth(mod.getName()) + 10);
listWidth = Math.max(listWidth,getFontRenderer().getStringWidth(mod.getVersion()) + 10);
listWidth = Math.max(listWidth,getFontRenderer().getStringWidth(mod.getVersion()) + 5 + slotHeight);
}
listWidth = Math.min(listWidth, 150);
this.modList = new GuiSlotModList(this, mods, listWidth);
this.modList = new GuiSlotModList(this, mods, listWidth, slotHeight);
this.buttonList.add(new GuiButton(6, ((modList.right + this.width) / 2) - 100, this.height - 38, I18n.format("gui.done")));
configModButton = new GuiButton(20, 10, this.height - 49, this.listWidth, 20, "Config");

View File

@ -14,8 +14,12 @@ package net.minecraftforge.fml.client;
import java.util.ArrayList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils;
import net.minecraftforge.common.ForgeVersion;
import net.minecraftforge.common.ForgeVersion.CheckResult;
@ -29,12 +33,15 @@ import net.minecraftforge.fml.common.ModContainer;
*/
public class GuiSlotModList extends GuiScrollingList
{
private static final ResourceLocation VERSION_CHECK_ICONS = new ResourceLocation("forge", "textures/gui/version_check_icons.png");
private GuiModList parent;
private ArrayList<ModContainer> mods;
public GuiSlotModList(GuiModList parent, ArrayList<ModContainer> mods, int listWidth)
public GuiSlotModList(GuiModList parent, ArrayList<ModContainer> mods, int listWidth, int slotHeight)
{
super(parent.getMinecraftInstance(), listWidth, parent.height, 32, parent.height - 88 + 4, 10, 35, parent.width, parent.height);
super(parent.getMinecraftInstance(), listWidth, parent.height, 32, parent.height - 88 + 4, 10, slotHeight, parent.width, parent.height);
this.parent = parent;
this.mods = mods;
}
@ -86,27 +93,23 @@ public class GuiSlotModList extends GuiScrollingList
if (Loader.instance().getModState(mc) == ModState.DISABLED)
{
font.drawString(font.trimStringToWidth(name, listWidth - 10), this.left + 3 , top + 2, 0xFF2222);
font.drawString(font.trimStringToWidth(version, listWidth - 10), this.left + 3 , top + 12, 0xFF2222);
font.drawString(font.trimStringToWidth(version, listWidth - (5 + height)), this.left + 3 , top + 12, 0xFF2222);
font.drawString(font.trimStringToWidth("DISABLED", listWidth - 10), this.left + 3 , top + 22, 0xFF2222);
}
else
{
font.drawString(font.trimStringToWidth(name, listWidth - 10), this.left + 3 , top + 2, 0xFFFFFF);
font.drawString(font.trimStringToWidth(version, listWidth - 10), this.left + 3 , top + 12, 0xCCCCCC);
font.drawString(font.trimStringToWidth(version, listWidth - (5 + height)), this.left + 3 , top + 12, 0xCCCCCC);
font.drawString(font.trimStringToWidth(mc.getMetadata() != null ? mc.getMetadata().getChildModCountString() : "Metadata not found", listWidth - 10), this.left + 3 , top + 22, 0xCCCCCC);
switch(vercheck.status) //TODO: Change to icons?
if (vercheck.status.shouldDraw())
{
case BETA_OUTDATED:
case OUTDATED:
font.drawString("U", right - font.getCharWidth('U') - 1, top+height-font.FONT_HEIGHT+2, 0x22FF22);
break;
case AHEAD:
case BETA:
case FAILED:
case PENDING:
case UP_TO_DATE:
break;
//TODO: Consider adding more icons for visualization
Minecraft.getMinecraft().getTextureManager().bindTexture(VERSION_CHECK_ICONS);
GlStateManager.color(1, 1, 1, 1);
GlStateManager.pushMatrix();
Gui.drawModalRectWithCustomSizedTexture(right - (height / 2 + 4), top + (height / 2 - 4), vercheck.status.getSheetOffset() * 8, (vercheck.status.isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
GlStateManager.popMatrix();
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B