Redesign the ModList GUI to use a scrolling list for the main body content.

Allowing for larger information to be displayed.
URLs are auto-detected and now clickable.
Mod Logos are now centered, it looks better.
This commit is contained in:
Lex Manos 2015-11-04 13:57:47 -08:00
parent d0a33c4d9d
commit 479c7f8b54
8 changed files with 527 additions and 372 deletions

View file

@ -57,6 +57,7 @@ import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.IChatComponent; import net.minecraft.util.IChatComponent;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
@ -442,12 +443,13 @@ public class ForgeHooks
"((?:[a-z0-9]{2,}:\\/\\/)?(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3}|(?:[-\\w_\\.]{1,}\\.[a-z]{2,}?))(?::[0-9]{1,5})?.*?(?=[!\"\u00A7 \n]|$))", "((?:[a-z0-9]{2,}:\\/\\/)?(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3}|(?:[-\\w_\\.]{1,}\\.[a-z]{2,}?))(?::[0-9]{1,5})?.*?(?=[!\"\u00A7 \n]|$))",
Pattern.CASE_INSENSITIVE); Pattern.CASE_INSENSITIVE);
public static IChatComponent newChatWithLinks(String string) public static IChatComponent newChatWithLinks(String string){ return newChatWithLinks(string, true); }
public static IChatComponent newChatWithLinks(String string, boolean allowMissingHeader)
{ {
// Includes ipv4 and domain pattern // Includes ipv4 and domain pattern
// Matches an ip (xx.xxx.xx.xxx) or a domain (something.com) with or // Matches an ip (xx.xxx.xx.xxx) or a domain (something.com) with or
// without a protocol or path. // without a protocol or path.
IChatComponent ichat = new ChatComponentText(""); IChatComponent ichat = null;
Matcher matcher = URL_PATTERN.matcher(string); Matcher matcher = URL_PATTERN.matcher(string);
int lastEnd = 0; int lastEnd = 0;
String remaining = string; String remaining = string;
@ -459,7 +461,14 @@ public class ForgeHooks
int end = matcher.end(); int end = matcher.end();
// Append the previous left overs. // Append the previous left overs.
ichat.appendText(string.substring(lastEnd, start)); String part = string.substring(lastEnd, start);
if (part.length() > 0)
{
if (ichat == null)
ichat = new ChatComponentText(part);
else
ichat.appendText(part);
}
lastEnd = end; lastEnd = end;
String url = string.substring(start, end); String url = string.substring(start, end);
IChatComponent link = new ChatComponentText(url); IChatComponent link = new ChatComponentText(url);
@ -468,23 +477,43 @@ public class ForgeHooks
{ {
// Add schema so client doesn't crash. // Add schema so client doesn't crash.
if ((new URI(url)).getScheme() == null) if ((new URI(url)).getScheme() == null)
{
if (!allowMissingHeader)
{
if (ichat == null)
ichat = new ChatComponentText(url);
else
ichat.appendText(url);
continue;
}
url = "http://" + url; url = "http://" + url;
}
} }
catch (URISyntaxException e) catch (URISyntaxException e)
{ {
// Bad syntax bail out! // Bad syntax bail out!
ichat.appendText(url); if (ichat == null) ichat = new ChatComponentText(url);
else ichat.appendText(url);
continue; continue;
} }
// Set the click event and append the link. // Set the click event and append the link.
ClickEvent click = new ClickEvent(ClickEvent.Action.OPEN_URL, url); ClickEvent click = new ClickEvent(ClickEvent.Action.OPEN_URL, url);
link.getChatStyle().setChatClickEvent(click); link.getChatStyle().setChatClickEvent(click);
ichat.appendSibling(link); link.getChatStyle().setUnderlined(true);
link.getChatStyle().setColor(EnumChatFormatting.BLUE);
if (ichat == null)
ichat = link;
else
ichat.appendSibling(link);
} }
// Append the rest of the message. // Append the rest of the message.
ichat.appendText(string.substring(lastEnd)); String end = string.substring(lastEnd);
if (ichat == null)
ichat = new ChatComponentText(end);
else if (end.length() > 0)
ichat.appendText(string.substring(lastEnd));
return ichat; return ichat;
} }

View file

@ -21,7 +21,7 @@ public class GuiIngameModOptions extends GuiScreen
public void initGui() public void initGui()
{ {
this.optionList=new GuiModOptionList(this); this.optionList=new GuiModOptionList(this);
this.optionList.registerScrollButtons(this.buttonList, 7, 8); //this.optionList.registerScrollButtons(this.buttonList, 7, 8);
this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, I18n.format("gui.done", new Object[0]))); this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, I18n.format("gui.done", new Object[0])));
} }

View file

@ -30,6 +30,7 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.GuiUtilRenderComponents;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.WorldRenderer;
@ -37,15 +38,18 @@ import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.client.resources.IResourcePack; import net.minecraft.client.resources.IResourcePack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils; import net.minecraft.util.StringUtils;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.ModContainer.Disableable; import net.minecraftforge.fml.common.ModContainer.Disableable;
import static net.minecraft.util.EnumChatFormatting.*;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
import org.lwjgl.opengl.GL11;
import com.google.common.base.Strings; import com.google.common.base.Strings;
@ -93,14 +97,13 @@ public class GuiModList extends GuiScreen
private GuiScreen mainMenu; private GuiScreen mainMenu;
private GuiSlotModList modList; private GuiSlotModList modList;
private GuiScrollingList modInfo;
private int selected = -1; private int selected = -1;
private ModContainer selectedMod; private ModContainer selectedMod;
private int listWidth; private int listWidth;
private ArrayList<ModContainer> mods; private ArrayList<ModContainer> mods;
private GuiButton configModButton; private GuiButton configModButton;
private GuiButton disableModButton; private GuiButton disableModButton;
private ResourceLocation cachedLogo;
private Dimension cachedLogoDimensions;
private int buttonMargin = 1; private int buttonMargin = 1;
private int numButtons = SortType.values().length; private int numButtons = SortType.values().length;
@ -152,7 +155,6 @@ public class GuiModList extends GuiScreen
} }
listWidth = Math.min(listWidth, 150); listWidth = Math.min(listWidth, 150);
this.modList = new GuiSlotModList(this, mods, listWidth); this.modList = new GuiSlotModList(this, mods, listWidth);
this.modList.registerScrollButtons(this.buttonList, 7, 8);
this.buttonList.add(new GuiButton(6, ((modList.right + this.width) / 2) - 100, this.height - 38, I18n.format("gui.done"))); 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"); configModButton = new GuiButton(20, 10, this.height - 49, this.listWidth, 20, "Config");
@ -173,6 +175,8 @@ public class GuiModList extends GuiScreen
buttonList.add(new GuiButton(SortType.A_TO_Z.buttonID, x, y, width - buttonMargin, 20, "A-Z")); buttonList.add(new GuiButton(SortType.A_TO_Z.buttonID, x, y, width - buttonMargin, 20, "A-Z"));
x += width + buttonMargin; x += width + buttonMargin;
buttonList.add(new GuiButton(SortType.Z_TO_A.buttonID, x, y, width - buttonMargin, 20, "Z-A")); buttonList.add(new GuiButton(SortType.Z_TO_A.buttonID, x, y, width - buttonMargin, 20, "Z-A"));
updateCache();
} }
@Override @Override
@ -230,14 +234,15 @@ public class GuiModList extends GuiScreen
} }
@Override @Override
protected void actionPerformed(GuiButton button) throws IOException { protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled) if (button.enabled)
{ {
SortType type = SortType.getTypeForButton(button); SortType type = SortType.getTypeForButton(button);
if (type != null) if (type != null)
{ {
for (GuiButton b : (List<GuiButton>) buttonList) for (GuiButton b : (List<GuiButton>)buttonList)
{ {
if (SortType.getTypeForButton(b) != null) if (SortType.getTypeForButton(b) != null)
{ {
@ -254,9 +259,12 @@ public class GuiModList extends GuiScreen
switch (button.id) switch (button.id)
{ {
case 6: case 6:
{
this.mc.displayGuiScreen(this.mainMenu); this.mc.displayGuiScreen(this.mainMenu);
return; return;
}
case 20: case 20:
{
try try
{ {
IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(selectedMod); IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(selectedMod);
@ -269,6 +277,7 @@ public class GuiModList extends GuiScreen
} }
return; return;
} }
}
} }
} }
super.actionPerformed(button); super.actionPerformed(button);
@ -281,147 +290,15 @@ public class GuiModList extends GuiScreen
} }
@Override @Override
public void drawScreen(int p_571_1_, int p_571_2_, float p_571_3_) public void drawScreen(int mouseX, int mouseY, float partialTicks)
{ {
this.modList.drawScreen(p_571_1_, p_571_2_, p_571_3_); this.modList.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRendererObj, "Mod List", this.width / 2, 16, 0xFFFFFF); if (this.modInfo != null)
int offset = this.listWidth + 20; this.modInfo.drawScreen(mouseX, mouseY, partialTicks);
if (selectedMod != null)
{
GlStateManager.enableBlend();
if (!selectedMod.getMetadata().autogenerated)
{
configModButton.visible = true;
disableModButton.visible = true;
disableModButton.packedFGColour = 0xFF3377;
configModButton.enabled = false;
int shifty = 35;
String logoFile = selectedMod.getMetadata().logoFile;
if (!logoFile.isEmpty())
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
TextureManager tm = mc.getTextureManager();
IResourcePack pack = FMLClientHandler.instance().getResourcePackFor(selectedMod.getModId());
try
{
if (cachedLogo == null)
{
BufferedImage logo = null;
if (pack!=null)
{
logo = pack.getPackImage();
}
else
{
InputStream logoResource = getClass().getResourceAsStream(logoFile);
if (logoResource != null)
{
logo = ImageIO.read(logoResource);
}
}
if (logo != null)
{
cachedLogo = tm.getDynamicTextureLocation("modlogo", new DynamicTexture(logo));
cachedLogoDimensions = new Dimension(logo.getWidth(), logo.getHeight());
}
}
if (cachedLogo != null)
{
this.mc.renderEngine.bindTexture(cachedLogo);
double scaleX = cachedLogoDimensions.width / 200.0;
double scaleY = cachedLogoDimensions.height / 65.0;
double scale = 1.0;
if (scaleX > 1 || scaleY > 1)
{
scale = 1.0 / Math.max(scaleX, scaleY);
}
cachedLogoDimensions.width *= scale;
cachedLogoDimensions.height *= scale;
int top = 32;
Tessellator tess = Tessellator.getInstance();
WorldRenderer world = tess.getWorldRenderer();
world.startDrawingQuads();
world.addVertexWithUV(offset, top + cachedLogoDimensions.height, zLevel, 0, 1);
world.addVertexWithUV(offset + cachedLogoDimensions.width, top + cachedLogoDimensions.height, zLevel, 1, 1);
world.addVertexWithUV(offset + cachedLogoDimensions.width, top, zLevel, 1, 0);
world.addVertexWithUV(offset, top, zLevel, 0, 0);
tess.draw();
shifty += 65; int left = ((this.width - this.listWidth - 38) / 2) + this.listWidth + 30;
} this.drawCenteredString(this.fontRendererObj, "Mod List", left, 16, 0xFFFFFF);
} super.drawScreen(mouseX, mouseY, partialTicks);
catch (IOException e)
{
;
}
}
this.fontRendererObj.drawStringWithShadow(selectedMod.getMetadata().name, offset, shifty, 0xFFFFFF);
shifty += 12;
shifty = drawLine(String.format("Version: %s (%s)", selectedMod.getDisplayVersion(), selectedMod.getVersion()), offset, shifty);
shifty = drawLine(String.format("Mod ID: '%s' Mod State: %s", selectedMod.getModId(), Loader.instance().getModState(selectedMod)), offset, shifty);
if (!selectedMod.getMetadata().credits.isEmpty())
{
shifty = drawLine(String.format("Credits: %s", selectedMod.getMetadata().credits), offset, shifty);
}
shifty = drawLine(String.format("Authors: %s", selectedMod.getMetadata().getAuthorList()), offset, shifty);
shifty = drawLine(String.format("URL: %s", selectedMod.getMetadata().url), offset, shifty);
shifty = drawLine(selectedMod.getMetadata().childMods.isEmpty() ? "No child mods for this mod" : String.format("Child mods: %s", selectedMod.getMetadata().getChildModList()), offset, shifty);
int rightSide = this.width - offset - 20;
if (rightSide > 20)
{
this.getFontRenderer().drawSplitString(selectedMod.getMetadata().description, offset, shifty + 10, rightSide, 0xDDDDDD);
}
Disableable disableable = selectedMod.canBeDisabled();
if (disableable == Disableable.RESTART)
{
disableModButton.enabled = true;
disableModButton.visible = true;
disableModButton.packedFGColour = 0xFF3377;
}
else if (disableable == Disableable.YES)
{
disableModButton.enabled = true;
disableModButton.visible = true;
disableModButton.packedFGColour = 0;
}
else
{
disableModButton.packedFGColour = 0;
disableModButton.visible = true;
disableModButton.enabled = false;
}
IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(selectedMod);
if (guiFactory == null || guiFactory.mainConfigGuiClass() == null)
{
configModButton.visible = true;
configModButton.enabled = false;
}
else
{
configModButton.visible = true;
configModButton.enabled = true;
}
}
else
{
offset = ( this.listWidth + this.width ) / 2;
this.drawCenteredString(this.fontRendererObj, selectedMod.getName(), offset, 35, 0xFFFFFF);
this.drawCenteredString(this.fontRendererObj, String.format("Version: %s",selectedMod.getVersion()), offset, 45, 0xFFFFFF);
this.drawCenteredString(this.fontRendererObj, String.format("Mod State: %s",Loader.instance().getModState(selectedMod)), offset, 55, 0xFFFFFF);
this.drawCenteredString(this.fontRendererObj, "No mod information found", offset, 65, 0xDDDDDD);
this.drawCenteredString(this.fontRendererObj, "Ask your mod author to provide a mod mcmod.info file", offset, 75, 0xDDDDDD);
configModButton.visible = false;
disableModButton.visible = false;
}
GlStateManager.disableBlend();
}
else
{
configModButton.visible = false;
disableModButton.visible = false;
}
super.drawScreen(p_571_1_, p_571_2_, p_571_3_);
String text = I18n.format("fml.menu.mods.search"); String text = I18n.format("fml.menu.mods.search");
int x = ((10 + modList.right) / 2) - (getFontRenderer().getStringWidth(text) / 2); int x = ((10 + modList.right) / 2) - (getFontRenderer().getStringWidth(text) / 2);
@ -441,13 +318,267 @@ public class GuiModList extends GuiScreen
public void selectModIndex(int index) public void selectModIndex(int index)
{ {
if (index == this.selected)
return;
this.selected = index; this.selected = index;
this.selectedMod = (index >= 0 && index <= mods.size()) ? mods.get(selected) : null; this.selectedMod = (index >= 0 && index <= mods.size()) ? mods.get(selected) : null;
cachedLogo = null;
updateCache();
} }
public boolean modIndexSelected(int index) public boolean modIndexSelected(int index)
{ {
return index == selected; return index == selected;
} }
private void updateCache()
{
configModButton.visible = false;
disableModButton.visible = false;
modInfo = null;
if (selectedMod == null)
return;
ResourceLocation logoPath = null;
Dimension logoDims = new Dimension(0, 0);
List<String> lines = new ArrayList<String>();
//CheckResult vercheck = ForgeVersion.getResult(selectedMod);
String logoFile = selectedMod.getMetadata().logoFile;
if (!logoFile.isEmpty())
{
TextureManager tm = mc.getTextureManager();
IResourcePack pack = FMLClientHandler.instance().getResourcePackFor(selectedMod.getModId());
try
{
BufferedImage logo = null;
if (pack != null)
{
logo = pack.getPackImage();
}
else
{
InputStream logoResource = getClass().getResourceAsStream(logoFile);
if (logoResource != null)
logo = ImageIO.read(logoResource);
}
if (logo != null)
{
logoPath = tm.getDynamicTextureLocation("modlogo", new DynamicTexture(logo));
logoDims = new Dimension(logo.getWidth(), logo.getHeight());
}
}
catch (IOException e) { }
}
if (!selectedMod.getMetadata().autogenerated)
{
disableModButton.visible = true;
disableModButton.enabled = true;
disableModButton.packedFGColour = 0;
Disableable disableable = selectedMod.canBeDisabled();
if (disableable == Disableable.RESTART)
{
disableModButton.packedFGColour = 0xFF3377;
}
else if (disableable != Disableable.YES)
{
disableModButton.enabled = false;
}
IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(selectedMod);
configModButton.visible = true;
configModButton.enabled = guiFactory != null && guiFactory.mainConfigGuiClass() != null;
lines.add(selectedMod.getMetadata().name);
lines.add(String.format("Version: %s (%s)", selectedMod.getDisplayVersion(), selectedMod.getVersion()));
lines.add(String.format("Mod ID: '%s' Mod State: %s", selectedMod.getModId(), Loader.instance().getModState(selectedMod)));
if (!selectedMod.getMetadata().credits.isEmpty())
{
lines.add("Credits: " + selectedMod.getMetadata().credits);
}
lines.add("Authors: " + selectedMod.getMetadata().getAuthorList());
lines.add("URL: " + selectedMod.getMetadata().url);
if (selectedMod.getMetadata().childMods.isEmpty())
lines.add("No child mods for this mod");
else
lines.add("Child mods: " + selectedMod.getMetadata().getChildModList());
//if (vercheck.status == Status.OUTDATED || vercheck.status == Status.BETA_OUTDATED)
// lines.add("Update Avalible: " + (vercheck.url == null ? "" : vercheck.url));
lines.add(null);
lines.add(selectedMod.getMetadata().description);
}
else
{
lines.add(WHITE + selectedMod.getName());
lines.add(WHITE + "Version: " + selectedMod.getVersion());
lines.add(WHITE + "Mod State: " + Loader.instance().getModState(selectedMod));
//if (vercheck.status == Status.OUTDATED || vercheck.status == Status.BETA_OUTDATED)
// lines.add("Update Avalible: " + (vercheck.url == null ? "" : vercheck.url));
lines.add(null);
lines.add(RED + "No mod information found");
lines.add(RED + "Ask your mod author to provide a mod mcmod.info file");
}
/*if ((vercheck.status == Status.OUTDATED || vercheck.status == Status.BETA_OUTDATED) && vercheck.changes.size() > 0)
{
lines.add(null);
lines.add("Changes:");
for (Entry<ComparableVersion, String> entry : vercheck.changes.entrySet())
{
lines.add(" " + entry.getKey() + ":");
lines.add(entry.getValue());
lines.add(null);
}
}*/
modInfo = new Info(this.width - this.listWidth - 30, lines, logoPath, logoDims);
}
private class Info extends GuiScrollingList
{
private ResourceLocation logoPath;
private Dimension logoDims;
private List<IChatComponent> lines = null;
public Info(int width, List<String> lines, ResourceLocation logoPath, Dimension logoDims)
{
super(GuiModList.this.getMinecraftInstance(),
width,
GuiModList.this.height,
32, GuiModList.this.height - 88 + 4,
GuiModList.this.listWidth + 20, 60,
GuiModList.this.width,
GuiModList.this.height);
this.lines = resizeContent(lines);
this.logoPath = logoPath;
this.logoDims = logoDims;
this.setHeaderInfo(true, getHeaderHeight());
}
@Override protected int getSize() { return 0; }
@Override protected void elementClicked(int index, boolean doubleClick) { }
@Override protected boolean isSelected(int index) { return false; }
@Override protected void drawBackground() {}
@Override protected void drawSlot(int slotIdx, int entryRight, int slotTop, int slotBuffer, Tessellator tess) { }
private List<String> splitLines(String line)
{
return null;
}
private List<IChatComponent> resizeContent(List<String> lines)
{
List<IChatComponent> ret = new ArrayList<IChatComponent>();
for (String line : lines)
{
if (line == null)
{
ret.add(null);
continue;
}
IChatComponent chat = ForgeHooks.newChatWithLinks(line, false);
ret.addAll(GuiUtilRenderComponents.func_178908_a(chat, this.listWidth-8, GuiModList.this.fontRendererObj, false, true));
}
return ret;
}
private int getHeaderHeight()
{
int height = 0;
if (logoPath != null)
{
double scaleX = logoDims.width / 200.0;
double scaleY = logoDims.height / 65.0;
double scale = 1.0;
if (scaleX > 1 || scaleY > 1)
{
scale = 1.0 / Math.max(scaleX, scaleY);
}
logoDims.width *= scale;
logoDims.height *= scale;
height += logoDims.height;
height += 10;
}
height += (lines.size() * 10);
if (height < this.bottom - this.top - 8) height = this.bottom - this.top - 8;
return height;
}
protected void drawHeader(int entryRight, int relativeY, Tessellator tess)
{
int top = relativeY;
if (logoPath != null)
{
GlStateManager.enableBlend();
GuiModList.this.mc.renderEngine.bindTexture(logoPath);
WorldRenderer world = tess.getWorldRenderer();
int offset = (this.left + this.listWidth/2) - (logoDims.width / 2);
world.startDrawingQuads();
world.addVertexWithUV(offset, top + logoDims.height, zLevel, 0, 1);
world.addVertexWithUV(offset + logoDims.width, top + logoDims.height, zLevel, 1, 1);
world.addVertexWithUV(offset + logoDims.width, top, zLevel, 1, 0);
world.addVertexWithUV(offset, top, zLevel, 0, 0);
tess.draw();
GlStateManager.disableBlend();
top += logoDims.height + 10;
}
for (IChatComponent line : lines)
{
if (line != null)
{
GlStateManager.enableBlend();
GuiModList.this.fontRendererObj.drawStringWithShadow(line.getFormattedText(), this.left + 4, top, 0xFFFFFF);
GlStateManager.disableAlpha();
GlStateManager.disableBlend();
}
top += 10;
}
}
@Override
protected void clickHeader(int x, int y)
{
int offset = y;
if (logoPath != null) {
offset -= logoDims.height + 10;
}
if (offset <= 0)
return;
int lineIdx = offset / 10;
if (lineIdx >= lines.size())
return;
IChatComponent line = lines.get(lineIdx);
if (line != null)
{
int k = -4;
for (IChatComponent part : (Iterable<IChatComponent>)line) {
if (!(part instanceof ChatComponentText))
continue;
k += GuiModList.this.fontRendererObj.getStringWidth(((ChatComponentText)part).getChatComponentText_TextValue());
if (k >= x)
{
System.out.println(part);
GuiModList.this.func_175276_a(part);
break;
}
}
}
}
}
} }

View file

@ -8,7 +8,7 @@ public class GuiModOptionList extends GuiScrollingList {
public GuiModOptionList(GuiIngameModOptions parent) public GuiModOptionList(GuiIngameModOptions parent)
{ {
super(parent.mc, 150, parent.height, 32, parent.height - 65 + 4, 10, 35); super(parent.mc, 150, parent.height, 32, parent.height - 65 + 4, 10, 35, parent.width, parent.height);
this.parent = parent; this.parent = parent;
} }
@ -37,11 +37,11 @@ public class GuiModOptionList extends GuiScrollingList {
} }
@Override @Override
protected void drawSlot(int var1, int var2, int var3, int var4, Tessellator var5) protected void drawSlot(int slotIdx, int entryRight, int slotTop, int slotBuffer, Tessellator tess)
{ {
this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth("Test 1", listWidth - 10), this.left + 3 , var3 + 2, 0xFF2222); this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth("Test 1", listWidth - 10), this.left + 3 , slotTop + 2, 0xFF2222);
this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth("TEST 2", listWidth - 10), this.left + 3 , var3 + 12, 0xFF2222); this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth("TEST 2", listWidth - 10), this.left + 3 , slotTop + 12, 0xFF2222);
this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth("DISABLED", listWidth - 10), this.left + 3 , var3 + 22, 0xFF2222); this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth("DISABLED", listWidth - 10), this.left + 3 , slotTop + 22, 0xFF2222);
} }
} }

View file

@ -18,7 +18,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.WorldRenderer;
@ -30,6 +29,8 @@ public abstract class GuiScrollingList
private final Minecraft client; private final Minecraft client;
protected final int listWidth; protected final int listWidth;
protected final int listHeight; protected final int listHeight;
protected final int screenWidth;
protected final int screenHeight;
protected final int top; protected final int top;
protected final int bottom; protected final int bottom;
protected final int right; protected final int right;
@ -44,11 +45,17 @@ public abstract class GuiScrollingList
private float scrollDistance; private float scrollDistance;
protected int selectedIndex = -1; protected int selectedIndex = -1;
private long lastClickTime = 0L; private long lastClickTime = 0L;
private boolean field_25123_p = true; private boolean highlightSelected = true;
private boolean field_27262_q; private boolean hasHeader;
private int field_27261_r; private int headerHeight;
protected boolean captureMouse = true;
@Deprecated // We need to know screen size.
public GuiScrollingList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight) public GuiScrollingList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight)
{
this(client, width, height, top, bottom, left, entryHeight, width, height);
}
public GuiScrollingList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight, int screenWidth, int screenHeight)
{ {
this.client = client; this.client = client;
this.listWidth = width; this.listWidth = width;
@ -58,22 +65,21 @@ public abstract class GuiScrollingList
this.slotHeight = entryHeight; this.slotHeight = entryHeight;
this.left = left; this.left = left;
this.right = width + this.left; this.right = width + this.left;
this.screenWidth = screenWidth;
this.screenHeight = screenHeight;
} }
public void func_27258_a(boolean p_27258_1_) public void func_27258_a(boolean p_27258_1_)
{ {
this.field_25123_p = p_27258_1_; this.highlightSelected = p_27258_1_;
} }
protected void func_27259_a(boolean p_27259_1_, int p_27259_2_) @Deprecated protected void func_27259_a(boolean hasFooter, int footerHeight){ setHeaderInfo(hasFooter, footerHeight); }
protected void setHeaderInfo(boolean hasHeader, int headerHeight)
{ {
this.field_27262_q = p_27259_1_; this.hasHeader = hasHeader;
this.field_27261_r = p_27259_2_; this.headerHeight = headerHeight;
if (!hasHeader) this.headerHeight = 0;
if (!p_27259_1_)
{
this.field_27261_r = 0;
}
} }
protected abstract int getSize(); protected abstract int getSize();
@ -84,42 +90,44 @@ public abstract class GuiScrollingList
protected int getContentHeight() protected int getContentHeight()
{ {
return this.getSize() * this.slotHeight + this.field_27261_r; return this.getSize() * this.slotHeight + this.headerHeight;
} }
protected abstract void drawBackground(); protected abstract void drawBackground();
protected abstract void drawSlot(int var1, int var2, int var3, int var4, Tessellator var5); protected abstract void drawSlot(int slotIdx, int entryRight, int slotTop, int slotBuffer, Tessellator tess);
protected void func_27260_a(int p_27260_1_, int p_27260_2_, Tessellator p_27260_3_) {} @Deprecated protected void func_27260_a(int entryRight, int relativeY, Tessellator tess) {}
protected void drawHeader(int entryRight, int relativeY, Tessellator tess) { func_27260_a(entryRight, relativeY, tess); }
protected void func_27255_a(int p_27255_1_, int p_27255_2_) {} @Deprecated protected void func_27255_a(int x, int y) {}
protected void clickHeader(int x, int y) { func_27255_a(x, y); }
protected void func_27257_b(int p_27257_1_, int p_27257_2_) {} @Deprecated protected void func_27257_b(int mouseX, int mouseY) {}
protected void drawScreen(int mouseX, int mouseY) { func_27257_b(mouseX, mouseY); }
public int func_27256_c(int p_27256_1_, int p_27256_2_)
public int func_27256_c(int x, int y)
{ {
int var3 = this.left + 1; int left = this.left + 1;
int var4 = this.left + this.listWidth - 7; int right = this.left + this.listWidth - 7;
int var5 = p_27256_2_ - this.top - this.field_27261_r + (int)this.scrollDistance - 4; int relativeY = y - this.top - this.headerHeight + (int)this.scrollDistance - 4;
int var6 = var5 / this.slotHeight; int entryIndex = relativeY / this.slotHeight;
return p_27256_1_ >= var3 && p_27256_1_ <= var4 && var6 >= 0 && var5 >= 0 && var6 < this.getSize() ? var6 : -1; return x >= left && x <= right && entryIndex >= 0 && relativeY >= 0 && entryIndex < this.getSize() ? entryIndex : -1;
} }
public void registerScrollButtons(@SuppressWarnings("rawtypes") List p_22240_1_, int p_22240_2_, int p_22240_3_) public void registerScrollButtons(@SuppressWarnings("rawtypes") List buttons, int upActionID, int downActionID)
{ {
this.scrollUpActionId = p_22240_2_; this.scrollUpActionId = upActionID;
this.scrollDownActionId = p_22240_3_; this.scrollDownActionId = downActionID;
} }
private void applyScrollLimits() private void applyScrollLimits()
{ {
int var1 = this.getContentHeight() - (this.bottom - this.top - 4); int listHeight = this.getContentHeight() - (this.bottom - this.top - 4);
if (var1 < 0) if (listHeight < 0)
{ {
var1 /= 2; listHeight /= 2;
} }
if (this.scrollDistance < 0.0F) if (this.scrollDistance < 0.0F)
@ -127,9 +135,9 @@ public abstract class GuiScrollingList
this.scrollDistance = 0.0F; this.scrollDistance = 0.0F;
} }
if (this.scrollDistance > (float)var1) if (this.scrollDistance > (float)listHeight)
{ {
this.scrollDistance = (float)var1; this.scrollDistance = (float)listHeight;
} }
} }
@ -152,82 +160,63 @@ public abstract class GuiScrollingList
} }
} }
public void drawScreen(int mouseX, int mouseY, float p_22243_3_) public void drawScreen(int mouseX, int mouseY, float partialTicks)
{ {
this.mouseX = mouseX; this.mouseX = mouseX;
this.mouseY = mouseY; this.mouseY = mouseY;
this.drawBackground(); this.drawBackground();
int listLength = this.getSize();
int scrollBarXStart = this.left + this.listWidth - 6; boolean isHovering = mouseX >= this.left && mouseX <= this.left + this.listWidth &&
int scrollBarXEnd = scrollBarXStart + 6; mouseY >= this.top && mouseY <= this.bottom;
int boxLeft = this.left; int listLength = this.getSize();
int boxRight = scrollBarXStart-1; int scrollBarWidth = 6;
int var10; int scrollBarRight = this.left + this.listWidth;
int var11; int scrollBarLeft = scrollBarRight - scrollBarWidth;
int var13; int entryLeft = this.left;
int var19; int entryRight = scrollBarLeft - 1;
int viewHeight = this.bottom - this.top;
int border = 4;
if (Mouse.isButtonDown(0)) if (Mouse.isButtonDown(0))
{ {
if (this.initialMouseClickY == -1.0F) if (this.initialMouseClickY == -1.0F)
{ {
boolean var7 = true; if (isHovering)
if (mouseY >= this.top && mouseY <= this.bottom)
{ {
var10 = mouseY - this.top - this.field_27261_r + (int)this.scrollDistance - 4; int mouseListY = mouseY - this.top - this.headerHeight + (int)this.scrollDistance - border;
var11 = var10 / this.slotHeight; int slotIndex = mouseListY / this.slotHeight;
if (mouseX >= boxLeft && mouseX <= boxRight && var11 >= 0 && var10 >= 0 && var11 < listLength) if (mouseX >= entryLeft && mouseX <= entryRight && slotIndex >= 0 && mouseListY >= 0 && slotIndex < listLength)
{ {
boolean var12 = var11 == this.selectedIndex && System.currentTimeMillis() - this.lastClickTime < 250L; this.elementClicked(slotIndex, slotIndex == this.selectedIndex && System.currentTimeMillis() - this.lastClickTime < 250L);
this.elementClicked(var11, var12); this.selectedIndex = slotIndex;
this.selectedIndex = var11;
this.lastClickTime = System.currentTimeMillis(); this.lastClickTime = System.currentTimeMillis();
} }
else if (mouseX >= boxLeft && mouseX <= boxRight && var10 < 0) else if (mouseX >= entryLeft && mouseX <= entryRight && mouseListY < 0)
{ {
this.func_27255_a(mouseX - boxLeft, mouseY - this.top + (int)this.scrollDistance - 4); this.clickHeader(mouseX - entryLeft, mouseY - this.top + (int)this.scrollDistance - border);
var7 = false;
} }
if (mouseX >= scrollBarXStart && mouseX <= scrollBarXEnd) if (mouseX >= scrollBarLeft && mouseX <= scrollBarRight)
{ {
this.scrollFactor = -1.0F; this.scrollFactor = -1.0F;
var19 = this.getContentHeight() - (this.bottom - this.top - 4); int scrollHeight = this.getContentHeight() - viewHeight - border;
if (scrollHeight < 1) scrollHeight = 1;
if (var19 < 1) int var13 = (int)((float)(viewHeight * viewHeight) / (float)this.getContentHeight());
{
var19 = 1;
}
var13 = (int)((float)((this.bottom - this.top) * (this.bottom - this.top)) / (float)this.getContentHeight()); if (var13 < 32) var13 = 32;
if (var13 > viewHeight - border*2)
var13 = viewHeight - border*2;
if (var13 < 32) this.scrollFactor /= (float)(viewHeight - var13) / (float)scrollHeight;
{
var13 = 32;
}
if (var13 > this.bottom - this.top - 8)
{
var13 = this.bottom - this.top - 8;
}
this.scrollFactor /= (float)(this.bottom - this.top - var13) / (float)var19;
} }
else else
{ {
this.scrollFactor = 1.0F; this.scrollFactor = 1.0F;
} }
if (var7) this.initialMouseClickY = mouseY;
{
this.initialMouseClickY = (float)mouseY;
}
else
{
this.initialMouseClickY = -2.0F;
}
} }
else else
{ {
@ -242,22 +231,15 @@ public abstract class GuiScrollingList
} }
else else
{ {
while (Mouse.next()) while (isHovering && Mouse.next())
{ {
int var16 = Mouse.getEventDWheel(); int scroll = Mouse.getEventDWheel();
if (scroll != 0)
if (var16 != 0)
{ {
if (var16 > 0) if (scroll > 0) scroll = -1;
{ else if (scroll < 0) scroll = 1;
var16 = -1;
}
else if (var16 < 0)
{
var16 = 1;
}
this.scrollDistance += (float)(var16 * this.slotHeight / 2); this.scrollDistance += (float)(scroll * this.slotHeight / 2);
} }
} }
@ -265,76 +247,76 @@ public abstract class GuiScrollingList
} }
this.applyScrollLimits(); this.applyScrollLimits();
Tessellator tess = Tessellator.getInstance(); Tessellator tess = Tessellator.getInstance();
WorldRenderer worldr = tess.getWorldRenderer(); WorldRenderer worldr = tess.getWorldRenderer();
if (this.client.theWorld != null) if (this.client.theWorld != null)
{ {
this.drawGradientRect(this.left, this.top, this.right, this.bottom, -1072689136, -804253680); this.drawGradientRect(this.left, this.top, this.right, this.bottom, 0xC0101010, 0xD0101010);
} }
else else // Draw dark dirt background
{ {
GlStateManager.disableLighting(); GlStateManager.disableLighting();
GlStateManager.disableFog(); GlStateManager.disableFog();
this.client.renderEngine.bindTexture(Gui.optionsBackground); this.client.renderEngine.bindTexture(Gui.optionsBackground);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
float var17 = 32.0F; float scale = 32.0F;
worldr.startDrawingQuads(); worldr.startDrawingQuads();
worldr.setColorOpaque_I(2105376); worldr.setColorOpaque_I(2105376);
worldr.addVertexWithUV((double)this.left, (double)this.bottom, 0.0D, (double)((float)this.left / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17)); worldr.addVertexWithUV(this.left, this.bottom, 0.0D, this.left / scale, (this.bottom + (int)this.scrollDistance) / scale);
worldr.addVertexWithUV((double)this.right, (double)this.bottom, 0.0D, (double)((float)this.right / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17)); worldr.addVertexWithUV(this.right, this.bottom, 0.0D, this.right / scale, (this.bottom + (int)this.scrollDistance) / scale);
worldr.addVertexWithUV((double)this.right, (double)this.top, 0.0D, (double)((float)this.right / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17)); worldr.addVertexWithUV(this.right, this.top, 0.0D, this.right / scale, (this.top + (int)this.scrollDistance) / scale);
worldr.addVertexWithUV((double)this.left, (double)this.top, 0.0D, (double)((float)this.left / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17)); worldr.addVertexWithUV(this.left, this.top, 0.0D, this.left / scale, (this.top + (int)this.scrollDistance) / scale);
tess.draw(); tess.draw();
} }
// boxRight = this.listWidth / 2 - 92 - 16;
var10 = this.top + 4 - (int)this.scrollDistance;
if (this.field_27262_q) int baseY = this.top + border - (int)this.scrollDistance;
{
this.func_27260_a(boxRight, var10, tess); if (this.hasHeader) {
this.drawHeader(entryRight, baseY, tess);
} }
int var14; for (int slotIdx = 0; slotIdx < listLength; ++slotIdx)
for (var11 = 0; var11 < listLength; ++var11)
{ {
var19 = var10 + var11 * this.slotHeight + this.field_27261_r; int slotTop = baseY + slotIdx * this.slotHeight + this.headerHeight;
var13 = this.slotHeight - 4; int slotBuffer = this.slotHeight - border;
if (var19 <= this.bottom && var19 + var13 >= this.top) if (slotTop <= this.bottom && slotTop + slotBuffer >= this.top)
{ {
if (this.field_25123_p && this.isSelected(var11)) if (this.highlightSelected && this.isSelected(slotIdx))
{ {
var14 = boxLeft; int min = this.left;
int var15 = boxRight; int max = entryRight;
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableTexture2D(); GlStateManager.disableTexture2D();
worldr.startDrawingQuads(); worldr.startDrawingQuads();
worldr.setColorOpaque_I(8421504); worldr.setColorOpaque_I(0x808080);
worldr.addVertexWithUV((double)var14, (double)(var19 + var13 + 2), 0.0D, 0.0D, 1.0D); worldr.addVertexWithUV(min, slotTop + slotBuffer + 2, 0.0D, 0.0D, 1.0D);
worldr.addVertexWithUV((double)var15, (double)(var19 + var13 + 2), 0.0D, 1.0D, 1.0D); worldr.addVertexWithUV(max, slotTop + slotBuffer + 2, 0.0D, 1.0D, 1.0D);
worldr.addVertexWithUV((double)var15, (double)(var19 - 2), 0.0D, 1.0D, 0.0D); worldr.addVertexWithUV(max, slotTop - 2, 0.0D, 1.0D, 0.0D);
worldr.addVertexWithUV((double)var14, (double)(var19 - 2), 0.0D, 0.0D, 0.0D); worldr.addVertexWithUV(min, slotTop - 2, 0.0D, 0.0D, 0.0D);
worldr.setColorOpaque_I(0); worldr.setColorOpaque_I(0);
worldr.addVertexWithUV((double)(var14 + 1), (double)(var19 + var13 + 1), 0.0D, 0.0D, 1.0D); worldr.addVertexWithUV(min + 1, slotTop + slotBuffer + 1, 0.0D, 0.0D, 1.0D);
worldr.addVertexWithUV((double)(var15 - 1), (double)(var19 + var13 + 1), 0.0D, 1.0D, 1.0D); worldr.addVertexWithUV(max - 1, slotTop + slotBuffer + 1, 0.0D, 1.0D, 1.0D);
worldr.addVertexWithUV((double)(var15 - 1), (double)(var19 - 1), 0.0D, 1.0D, 0.0D); worldr.addVertexWithUV(max - 1, slotTop - 1, 0.0D, 1.0D, 0.0D);
worldr.addVertexWithUV((double)(var14 + 1), (double)(var19 - 1), 0.0D, 0.0D, 0.0D); worldr.addVertexWithUV(min + 1, slotTop - 1, 0.0D, 0.0D, 0.0D);
tess.draw(); tess.draw();
GlStateManager.enableTexture2D(); GlStateManager.enableTexture2D();
} }
this.drawSlot(var11, boxRight, var19, var13, tess); this.drawSlot(slotIdx, entryRight, slotTop, slotBuffer, tess);
} }
} }
GlStateManager.disableDepth(); GlStateManager.disableDepth();
byte border = 4;
if (this.client.theWorld == null) if (this.client.theWorld == null)
{ {
this.overlayBackground(0, this.top, 255, 255); this.overlayBackground(0, this.top, 255, 255);
this.overlayBackground(this.bottom, this.listHeight, 255, 255); this.overlayBackground(this.bottom, this.listHeight, 255, 255);
} }
// Render the entire background over everything but our view
GlStateManager.enableBlend(); GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.disableAlpha(); GlStateManager.disableAlpha();
@ -342,100 +324,95 @@ public abstract class GuiScrollingList
GlStateManager.disableTexture2D(); GlStateManager.disableTexture2D();
worldr.startDrawingQuads(); worldr.startDrawingQuads();
worldr.setColorRGBA_I(0, 0); worldr.setColorRGBA_I(0, 0);
worldr.addVertexWithUV((double)this.left, (double)(this.top + border), 0.0D, 0.0D, 1.0D); worldr.addVertexWithUV(this.left, this.top + border, 0.0D, 0.0D, 1.0D);
worldr.addVertexWithUV((double)this.right, (double)(this.top + border), 0.0D, 1.0D, 1.0D); worldr.addVertexWithUV(this.right, this.top + border, 0.0D, 1.0D, 1.0D);
worldr.setColorRGBA_I(0, 255); worldr.setColorRGBA_I(0, 255);
worldr.addVertexWithUV((double)this.right, (double)this.top, 0.0D, 1.0D, 0.0D); worldr.addVertexWithUV(this.right, this.top, 0.0D, 1.0D, 0.0D);
worldr.addVertexWithUV((double)this.left, (double)this.top, 0.0D, 0.0D, 0.0D); worldr.addVertexWithUV(this.left, this.top, 0.0D, 0.0D, 0.0D);
tess.draw(); tess.draw();
worldr.startDrawingQuads(); worldr.startDrawingQuads();
worldr.setColorRGBA_I(0, 255); worldr.setColorRGBA_I(0, 255);
worldr.addVertexWithUV((double)this.left, (double)this.bottom, 0.0D, 0.0D, 1.0D); worldr.addVertexWithUV(this.left, this.bottom, 0.0D, 0.0D, 1.0D);
worldr.addVertexWithUV((double)this.right, (double)this.bottom, 0.0D, 1.0D, 1.0D); worldr.addVertexWithUV(this.right, this.bottom, 0.0D, 1.0D, 1.0D);
worldr.setColorRGBA_I(0, 0); worldr.setColorRGBA_I(0, 0);
worldr.addVertexWithUV((double)this.right, (double)(this.bottom - border), 0.0D, 1.0D, 0.0D); worldr.addVertexWithUV(this.right, this.bottom - border, 0.0D, 1.0D, 0.0D);
worldr.addVertexWithUV((double)this.left, (double)(this.bottom - border), 0.0D, 0.0D, 0.0D); worldr.addVertexWithUV(this.left, this.bottom - border, 0.0D, 0.0D, 0.0D);
tess.draw(); tess.draw();
var19 = this.getContentHeight() - (this.bottom - this.top - 4);
if (var19 > 0) int extraHeight = this.getContentHeight() - viewHeight - border;
if (extraHeight > 0)
{ {
var13 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight(); int height = viewHeight * viewHeight / this.getContentHeight();
if (var13 < 32) if (height < 32) height = 32;
if (height > viewHeight - border*2)
height = viewHeight - border*2;
int barTop = (int)this.scrollDistance * (viewHeight - height) / extraHeight + this.top;
if (barTop < this.top)
{ {
var13 = 32; barTop = this.top;
}
if (var13 > this.bottom - this.top - 8)
{
var13 = this.bottom - this.top - 8;
}
var14 = (int)this.scrollDistance * (this.bottom - this.top - var13) / var19 + this.top;
if (var14 < this.top)
{
var14 = this.top;
} }
worldr.startDrawingQuads(); worldr.startDrawingQuads();
worldr.setColorRGBA_I(0, 255); worldr.setColorRGBA_I(0, 255);
worldr.addVertexWithUV((double)scrollBarXStart, (double)this.bottom, 0.0D, 0.0D, 1.0D); worldr.addVertexWithUV(scrollBarLeft, this.bottom, 0.0D, 0.0D, 1.0D);
worldr.addVertexWithUV((double)scrollBarXEnd, (double)this.bottom, 0.0D, 1.0D, 1.0D); worldr.addVertexWithUV(scrollBarRight, this.bottom, 0.0D, 1.0D, 1.0D);
worldr.addVertexWithUV((double)scrollBarXEnd, (double)this.top, 0.0D, 1.0D, 0.0D); worldr.addVertexWithUV(scrollBarRight, this.top, 0.0D, 1.0D, 0.0D);
worldr.addVertexWithUV((double)scrollBarXStart, (double)this.top, 0.0D, 0.0D, 0.0D); worldr.addVertexWithUV(scrollBarLeft, this.top, 0.0D, 0.0D, 0.0D);
tess.draw(); tess.draw();
worldr.startDrawingQuads(); worldr.startDrawingQuads();
worldr.setColorRGBA_I(8421504, 255); worldr.setColorRGBA_I(0x808080, 255);
worldr.addVertexWithUV((double)scrollBarXStart, (double)(var14 + var13), 0.0D, 0.0D, 1.0D); worldr.addVertexWithUV(scrollBarLeft, barTop + height, 0.0D, 0.0D, 1.0D);
worldr.addVertexWithUV((double)scrollBarXEnd, (double)(var14 + var13), 0.0D, 1.0D, 1.0D); worldr.addVertexWithUV(scrollBarRight, barTop + height, 0.0D, 1.0D, 1.0D);
worldr.addVertexWithUV((double)scrollBarXEnd, (double)var14, 0.0D, 1.0D, 0.0D); worldr.addVertexWithUV(scrollBarRight, barTop, 0.0D, 1.0D, 0.0D);
worldr.addVertexWithUV((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D); worldr.addVertexWithUV(scrollBarLeft, barTop, 0.0D, 0.0D, 0.0D);
tess.draw(); tess.draw();
worldr.startDrawingQuads(); worldr.startDrawingQuads();
worldr.setColorRGBA_I(12632256, 255); worldr.setColorRGBA_I(0xC0C0C0, 255);
worldr.addVertexWithUV((double)scrollBarXStart, (double)(var14 + var13 - 1), 0.0D, 0.0D, 1.0D); worldr.addVertexWithUV(scrollBarLeft, barTop + height - 1, 0.0D, 0.0D, 1.0D);
worldr.addVertexWithUV((double)(scrollBarXEnd - 1), (double)(var14 + var13 - 1), 0.0D, 1.0D, 1.0D); worldr.addVertexWithUV(scrollBarRight - 1, barTop + height - 1, 0.0D, 1.0D, 1.0D);
worldr.addVertexWithUV((double)(scrollBarXEnd - 1), (double)var14, 0.0D, 1.0D, 0.0D); worldr.addVertexWithUV(scrollBarRight - 1, barTop, 0.0D, 1.0D, 0.0D);
worldr.addVertexWithUV((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D); worldr.addVertexWithUV(scrollBarLeft, barTop, 0.0D, 0.0D, 0.0D);
tess.draw(); tess.draw();
} }
this.func_27257_b(mouseX, mouseY); this.drawScreen(mouseX, mouseY);
GlStateManager.enableTexture2D(); GlStateManager.enableTexture2D();
GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.shadeModel(GL11.GL_FLAT);
GlStateManager.enableAlpha(); GlStateManager.enableAlpha();
GlStateManager.disableBlend(); GlStateManager.disableBlend();
} }
private void overlayBackground(int p_22239_1_, int p_22239_2_, int p_22239_3_, int p_22239_4_) private void overlayBackground(int top, int height, int alpha1, int alpah2)
{ {
Tessellator var5 = Tessellator.getInstance(); Tessellator tess = Tessellator.getInstance();
WorldRenderer worldr = var5.getWorldRenderer(); WorldRenderer worldr = tess.getWorldRenderer();
this.client.renderEngine.bindTexture(Gui.optionsBackground); this.client.renderEngine.bindTexture(Gui.optionsBackground);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
float var6 = 32.0F; float scale = 32.0F;
double startUV = (screenWidth / scale) / screenWidth * (left-0);
worldr.startDrawingQuads(); worldr.startDrawingQuads();
worldr.setColorRGBA_I(4210752, p_22239_4_); worldr.setColorRGBA_I(0x404040, alpah2);
worldr.addVertexWithUV(0.0D, (double)p_22239_2_, 0.0D, 0.0D, (double)((float)p_22239_2_ / var6)); worldr.addVertexWithUV(left, height, 0.0D, startUV, height / scale);
worldr.addVertexWithUV((double)this.listWidth + 30, (double)p_22239_2_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_2_ / var6)); worldr.addVertexWithUV(left+listWidth+8, height, 0.0D, (left+listWidth+8) / scale, height / scale);
worldr.setColorRGBA_I(4210752, p_22239_3_); worldr.setColorRGBA_I(0x404040, alpha1);
worldr.addVertexWithUV((double)this.listWidth + 30, (double)p_22239_1_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_1_ / var6)); worldr.addVertexWithUV(left+listWidth+8, top, 0.0D, (left+listWidth+8) / scale, top / scale);
worldr.addVertexWithUV(0.0D, (double)p_22239_1_, 0.0D, 0.0D, (double)((float)p_22239_1_ / var6)); worldr.addVertexWithUV(left, top, 0.0D, startUV, top / scale);
var5.draw(); tess.draw();
} }
protected void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6) protected void drawGradientRect(int left, int top, int right, int bottom, int color1, int color2)
{ {
float f = (float)(par5 >> 24 & 255) / 255.0F; float a1 = (float)(color1 >> 24 & 255) / 255.0F;
float f1 = (float)(par5 >> 16 & 255) / 255.0F; float r1 = (float)(color1 >> 16 & 255) / 255.0F;
float f2 = (float)(par5 >> 8 & 255) / 255.0F; float g1 = (float)(color1 >> 8 & 255) / 255.0F;
float f3 = (float)(par5 & 255) / 255.0F; float b1 = (float)(color1 & 255) / 255.0F;
float f4 = (float)(par6 >> 24 & 255) / 255.0F; float a2 = (float)(color2 >> 24 & 255) / 255.0F;
float f5 = (float)(par6 >> 16 & 255) / 255.0F; float r2 = (float)(color2 >> 16 & 255) / 255.0F;
float f6 = (float)(par6 >> 8 & 255) / 255.0F; float g2 = (float)(color2 >> 8 & 255) / 255.0F;
float f7 = (float)(par6 & 255) / 255.0F; float b2 = (float)(color2 & 255) / 255.0F;
GlStateManager.disableTexture2D(); GlStateManager.disableTexture2D();
GlStateManager.enableBlend(); GlStateManager.enableBlend();
GlStateManager.disableAlpha(); GlStateManager.disableAlpha();
@ -444,12 +421,12 @@ public abstract class GuiScrollingList
Tessellator tessellator = Tessellator.getInstance(); Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer(); WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.startDrawingQuads(); worldrenderer.startDrawingQuads();
worldrenderer.setColorRGBA_F(f1, f2, f3, f); worldrenderer.setColorRGBA_F(r1, g1, b1, a1);
worldrenderer.addVertex((double)par3, (double)par2, 0.0D); worldrenderer.addVertex(right, top, 0.0D);
worldrenderer.addVertex((double)par1, (double)par2, 0.0D); worldrenderer.addVertex(left, top, 0.0D);
worldrenderer.setColorRGBA_F(f5, f6, f7, f4); worldrenderer.setColorRGBA_F(r2, g2, b2, a2);
worldrenderer.addVertex((double)par1, (double)par4, 0.0D); worldrenderer.addVertex(left, bottom, 0.0D);
worldrenderer.addVertex((double)par3, (double)par4, 0.0D); worldrenderer.addVertex(right, bottom, 0.0D);
tessellator.draw(); tessellator.draw();
GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.shadeModel(GL11.GL_FLAT);
GlStateManager.disableBlend(); GlStateManager.disableBlend();

View file

@ -14,6 +14,7 @@ package net.minecraftforge.fml.client;
import java.util.ArrayList; import java.util.ArrayList;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.StringUtils; import net.minecraft.util.StringUtils;
import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Loader;
@ -31,9 +32,9 @@ public class GuiSlotModList extends GuiScrollingList
public GuiSlotModList(GuiModList parent, ArrayList<ModContainer> mods, int listWidth) public GuiSlotModList(GuiModList parent, ArrayList<ModContainer> mods, int listWidth)
{ {
super(parent.getMinecraftInstance(), listWidth, parent.height, 32, parent.height - 88 + 4, 10, 35); super(parent.getMinecraftInstance(), listWidth, parent.height, 32, parent.height - 88 + 4, 10, 35, parent.width, parent.height);
this.parent=parent; this.parent = parent;
this.mods=mods; this.mods = mods;
} }
@Override @Override
@ -43,15 +44,15 @@ public class GuiSlotModList extends GuiScrollingList
} }
@Override @Override
protected void elementClicked(int var1, boolean var2) protected void elementClicked(int index, boolean doubleClick)
{ {
this.parent.selectModIndex(var1); this.parent.selectModIndex(index);
} }
@Override @Override
protected boolean isSelected(int var1) protected boolean isSelected(int index)
{ {
return this.parent.modIndexSelected(var1); return this.parent.modIndexSelected(index);
} }
@Override @Override
@ -72,22 +73,39 @@ public class GuiSlotModList extends GuiScrollingList
} }
@Override @Override
protected void drawSlot(int listIndex, int var2, int var3, int var4, Tessellator var5) protected void drawSlot(int idx, int right, int top, int height, Tessellator tess)
{ {
ModContainer mc=mods.get(listIndex); ModContainer mc = mods.get(idx);
String name = StringUtils.stripControlCodes(mc.getName()); String name = StringUtils.stripControlCodes(mc.getName());
String version = StringUtils.stripControlCodes(mc.getDisplayVersion()); String version = StringUtils.stripControlCodes(mc.getDisplayVersion());
if (Loader.instance().getModState(mc)==ModState.DISABLED) FontRenderer font = this.parent.getFontRenderer();
//CheckResult vercheck = ForgeVersion.getResult(mc);
if (Loader.instance().getModState(mc) == ModState.DISABLED)
{ {
this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(name, listWidth - 10), this.left + 3 , var3 + 2, 0xFF2222); font.drawString(font.trimStringToWidth(name, listWidth - 10), this.left + 3 , top + 2, 0xFF2222);
this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(version, listWidth - 10), this.left + 3 , var3 + 12, 0xFF2222); font.drawString(font.trimStringToWidth(version, listWidth - 10), this.left + 3 , top + 12, 0xFF2222);
this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth("DISABLED", listWidth - 10), this.left + 3 , var3 + 22, 0xFF2222); font.drawString(font.trimStringToWidth("DISABLED", listWidth - 10), this.left + 3 , top + 22, 0xFF2222);
} }
else else
{ {
this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(name, listWidth - 10), this.left + 3 , var3 + 2, 0xFFFFFF); font.drawString(font.trimStringToWidth(name, listWidth - 10), this.left + 3 , top + 2, 0xFFFFFF);
this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(version, listWidth - 10), this.left + 3 , var3 + 12, 0xCCCCCC); font.drawString(font.trimStringToWidth(version, listWidth - 10), this.left + 3 , top + 12, 0xCCCCCC);
this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getMetadata() !=null ? mc.getMetadata().getChildModCountString() : "Metadata not found", listWidth - 10), this.left + 3 , var3 + 22, 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?
{
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;
}*/
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -4,11 +4,11 @@
"name": "Minecraft Coder Pack", "name": "Minecraft Coder Pack",
"description": "Modding toolkit to decompile and deobfuscate the Minecraft client and server files.", "description": "Modding toolkit to decompile and deobfuscate the Minecraft client and server files.",
"version": "9.05", "version": "9.05",
"mcversion": "1.7.10", "mcversion": "1.8.0",
"logoFile": "/mcplogo.png", "logoFile": "/mcplogo.png",
"url": "http://mcp.ocean-labs.de/", "url": "http://www.modcoderpack.com/website/",
"updateUrl": "", "updateUrl": "",
"authors": ["Searge", "ProfMobius", "IngisKahn", "Fesh0r", "ZeuX", "R4wk", "Others"], "authors": ["Searge", "ProfMobius", "IngisKahn", "Fesh0r", "ZeuX", "R4wk", "LexManos", "Bspkrs", "Others"],
"credits": "Made by the MCP team", "credits": "Made by the MCP team",
"parent": "", "parent": "",
"screenshots": [], "screenshots": [],