Lots of cleanup on the mod list, pretend we're the mcpatcher for mod HD detection.

This commit is contained in:
Christian Weeks 2012-05-15 15:52:19 -04:00
parent bc23e7a657
commit a77aeedee2
9 changed files with 118 additions and 20 deletions

View file

@ -0,0 +1,30 @@
/*
* The FML Forge Mod Loader suite.
* Copyright (C) 2012 cpw
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package com.pclewis.mcpatcher.mod;
/**
* @author cpw
*
*/
@Deprecated
public class TileSize
{
@Deprecated
public static int int_numPixels;
@Deprecated
public static int int_size;
@Deprecated
public static int int_sizeMinus1;
}

View file

@ -19,12 +19,14 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
@ -779,8 +781,32 @@ public class FMLClientHandler implements IFMLSidedHandler
{
JsonNode root=new JdomParser().func_27366_a(new InputStreamReader(input));
ModMetadata meta=new ModMetadata(mod);
meta.name=root.func_27213_a("name");
meta.description=root.func_27213_a("description");
try {
meta.name=root.func_27213_a("name");
meta.description=root.func_27213_a("description");
meta.version=root.func_27213_a("version");
meta.credits=root.func_27213_a("credits");
List authors=root.func_27217_b("authors");
StringBuilder sb=new StringBuilder();
for (int i=0; i<authors.size(); i++) {
sb.append(((JsonNode)authors.get(i)).func_27216_b());
if (i<authors.size()-1) {
sb.append(", ");
}
}
meta.authorList=sb.toString();
meta.logoFile=root.func_27213_a("logoFile");
meta.url=root.func_27213_a("url");
meta.updateUrl=root.func_27213_a("updateUrl");
meta.parent=root.func_27213_a("parent");
List screenshots=root.func_27217_b("screenshots");
meta.screenshots=new String[screenshots.size()];
for (int i=0; i<screenshots.size(); i++) {
meta.screenshots[i]=((JsonNode)screenshots.get(i)).func_27216_b();
}
} catch (Exception e) {
FMLCommonHandler.instance().getFMLLogger().log(Level.FINE, String.format("An error occured reading the info file for %s",mod.getName()), e);
}
return meta;
}

View file

@ -34,6 +34,7 @@ public class GuiModList extends GuiScreen
private GuiSlotModList modList;
private int selected = -1;
private ModContainer selectedMod;
private int listWidth;
/**
* @param guiMainMenu
@ -45,9 +46,13 @@ public class GuiModList extends GuiScreen
public void func_6448_a()
{
for (ModContainer mod : Loader.getModList()) {
listWidth=Math.max(listWidth,getFontRenderer().func_871_a(mod.getName())+10);
listWidth=Math.max(listWidth,getFontRenderer().func_871_a(mod.getVersion())+10);
}
StringTranslate translations = StringTranslate.func_20162_a();
this.field_949_e.add(new GuiSmallButton(6, this.field_951_c / 2 - 75, this.field_950_d - 38, translations.func_20163_a("gui.done")));
this.modList=new GuiSlotModList(this);
this.modList=new GuiSlotModList(this, listWidth);
this.modList.registerScrollButtons(this.field_949_e, 7, 8);
}
@ -67,14 +72,21 @@ public class GuiModList extends GuiScreen
public void func_571_a(int p_571_1_, int p_571_2_, float p_571_3_)
{
this.modList.drawScreen(p_571_1_, p_571_2_, p_571_3_);
this.func_548_a(this.field_6451_g, "Mod List", this.field_951_c / 2, 16, 16777215);
this.func_548_a(this.field_6451_g, "Mod List", this.field_951_c / 2, 16, 0xFFFFFF);
int detailCentre = this.listWidth / 2 + this.field_951_c / 2;
if (selectedMod!=null) {
this.func_548_a(this.field_6451_g, selectedMod.getName(), this.field_951_c / 2 + 60, 28, 16777215);
this.func_548_a(this.field_6451_g, String.format("Version %s",selectedMod.getVersion()), this.field_951_c / 2 + 60, 38, 16777215);
if (selectedMod.getMetadata()!=null) {
this.func_548_a(this.field_6451_g, selectedMod.getMetadata().description, this.field_951_c / 2 + 60, 48, 0xFFFFFF);
this.func_548_a(this.field_6451_g, selectedMod.getMetadata().name, detailCentre, 35, 0xFFFFFF);
this.func_548_a(this.field_6451_g, String.format("Version: %s", selectedMod.getMetadata().version), detailCentre, 45, 0xFFFFFF);
this.func_548_a(this.field_6451_g, String.format("Credits: %s", selectedMod.getMetadata().credits), detailCentre, 55, 0xFFFFFF);
this.func_548_a(this.field_6451_g, String.format("Authors: %s", selectedMod.getMetadata().authorList), detailCentre, 65, 0xFFFFFF);
this.func_548_a(this.field_6451_g, String.format("URL: %s Updates: %s", selectedMod.getMetadata().url, selectedMod.getMetadata().updateUrl), detailCentre, 75, 0xFFFFFF);
this.getFontRenderer().func_27278_a(selectedMod.getMetadata().description, this.listWidth + 15, 100, this.field_951_c - this.listWidth - 30, 0xDDDDDD);
} else {
this.func_548_a(this.field_6451_g, "No mod information found", this.field_951_c / 2 + 60, 48, 0xDDDDDD);
this.func_548_a(this.field_6451_g, selectedMod.getName(), detailCentre, 35, 0xFFFFFF);
this.func_548_a(this.field_6451_g, String.format("Version: %s",selectedMod.getVersion()), detailCentre, 45, 0xFFFFFF);
this.func_548_a(this.field_6451_g, "No mod information found", detailCentre, 55, 0xDDDDDD);
this.func_548_a(this.field_6451_g, "Ask your mod author to provide a mod .info file", detailCentre, 65, 0xDDDDDD);
}
}
super.func_571_a(p_571_1_, p_571_2_, p_571_3_);

View file

@ -40,7 +40,7 @@ public abstract class GuiScrollingList
this.bottom = bottom;
this.slotHeight = entryHeight;
this.left = left;
this.right = width;
this.right = width + this.left;
}
public void func_27258_a(boolean p_27258_1_)
@ -140,7 +140,7 @@ public abstract class GuiScrollingList
this.mouseY = mouseY;
this.drawBackground();
int listLength = this.getSize();
int scrollBarXStart = this.listWidth -6;
int scrollBarXStart = this.left + this.listWidth - 6;
int scrollBarXEnd = scrollBarXStart + 6;
int boxLeft = this.left;
int boxRight = scrollBarXStart-1;

View file

@ -31,9 +31,9 @@ public class GuiSlotModList extends GuiScrollingList
{
private GuiModList parent;
public GuiSlotModList(GuiModList parent)
public GuiSlotModList(GuiModList parent, int listWidth)
{
super(parent.getMinecraftInstance(), 120, parent.field_950_d, 32, parent.field_950_d - 65 + 4, 10, 18);
super(parent.getMinecraftInstance(), listWidth, parent.field_950_d, 32, parent.field_950_d - 65 + 4, 10, 25);
this.parent=parent;
}
@ -64,15 +64,15 @@ public class GuiSlotModList extends GuiScrollingList
@Override
protected int getContentHeight()
{
return this.getSize() * 3 * (this.parent.getFontRenderer().field_41063_b +1);
return (1 + this.getSize()) * 25;
}
@Override
protected void drawSlot(int listIndex, int var2, int var3, int var4, Tessellator var5)
{
ModContainer mc=Loader.getModList().get(listIndex);
ModMetadata meta=mc.getMetadata();
this.parent.func_547_b(this.parent.getFontRenderer(), mc.getName(), this.left+3, var3 + 3, 16777215);
this.parent.getFontRenderer().func_873_b(mc.getName(), this.left + 3 , var3 + 2, 0xFFFFFF);
this.parent.getFontRenderer().func_873_b(mc.getVersion(), this.left + 3 , var3 + 12, 0xCCCCCC);
}
}

View file

@ -467,7 +467,7 @@ public class FMLCommonHandler
try
{
ZipFile jar = new ZipFile(mod.getSource());
ZipEntry infoFile=jar.getEntry("/mcmod.info");
ZipEntry infoFile=jar.getEntry("mcmod.info");
if (infoFile!=null) {
InputStream input=jar.getInputStream(infoFile);
ModMetadata data=sidedDelegate.readMetadataFrom(input, mod);
@ -481,7 +481,10 @@ public class FMLCommonHandler
} else {
try
{
InputStream input=FMLCommonHandler.class.getClassLoader().getResourceAsStream("/"+mod.getName()+".info");
InputStream input=Loader.instance().getModClassLoader().getResourceAsStream(mod.getName()+".info");
if (input==null) {
input=Loader.instance().getModClassLoader().getResourceAsStream("net/minecraft/src/"+mod.getName()+".info");
}
if (input!=null) {
ModMetadata data=sidedDelegate.readMetadataFrom(input, mod);
mod.setMetadata(data);

View file

@ -623,4 +623,12 @@ public class Loader
{
return String.format("FML v%s.%s.%s.%s", major, minor, rev, build);
}
/**
* @return
*/
public ClassLoader getModClassLoader()
{
return modClassLoader;
}
}

View file

@ -17,6 +17,7 @@ package cpw.mods.fml.common;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.zip.ZipInputStream;
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
@ -37,6 +38,11 @@ public class ModMetadata
public String updateUrl;
public String logoFile;
public String version;
public String authorList;
public String credits;
public String parent;
public String[] screenshots;
/**
* @param mod2

View file

@ -9,7 +9,7 @@
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
@@ -13,9 +16,13 @@
@@ -13,9 +16,15 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -18,12 +18,22 @@
+
import org.lwjgl.opengl.GL11;
+import com.pclewis.mcpatcher.mod.TileSize;
+
+import cpw.mods.fml.common.FMLCommonHandler;
+
public class RenderEngine
{
public static boolean field_1609_a = false;
@@ -459,23 +466,40 @@
@@ -452,6 +461,7 @@
p_1066_1_.func_783_a();
}
+ @SuppressWarnings("deprecation")
public void func_1067_a()
{
int var1 = -1;
@@ -459,23 +469,43 @@
for (int var2 = 0; var2 < this.field_1604_f.size(); ++var2)
{
TextureFX var3 = (TextureFX)this.field_1604_f.get(var2);
@ -36,6 +46,9 @@
+ int tileSize = GL11.glGetTexLevelParameteri(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH ) >>4;
+ var3.textureGridSize = tileSize * tileSize;
+ var3.textureLength = tileSize;
+ TileSize.int_numPixels=var3.textureGridSize;
+ TileSize.int_size=tileSize;
+ TileSize.int_sizeMinus1=tileSize-1;
+ if (var3.field_1127_a==null || var3.field_1127_a.length!= var3.textureGridSize << 2) {
+ var3.field_1127_a = new byte[var3.textureGridSize << 2];
+ }
@ -70,7 +83,7 @@
}
}
}
@@ -635,4 +659,8 @@
@@ -635,4 +665,8 @@
GL11.glBindTexture(GL11.GL_TEXTURE_2D, p_1076_1_);
}
}