More mod list fixes
This commit is contained in:
parent
a77aeedee2
commit
5412be2d76
5 changed files with 107 additions and 13 deletions
|
@ -14,6 +14,10 @@
|
|||
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cpw.mods.fml.common.FMLModContainer;
|
||||
import cpw.mods.fml.common.FMLModLoaderContainer;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -35,6 +39,7 @@ public class GuiModList extends GuiScreen
|
|||
private int selected = -1;
|
||||
private ModContainer selectedMod;
|
||||
private int listWidth;
|
||||
private ArrayList<ModContainer> mods;
|
||||
|
||||
/**
|
||||
* @param guiMainMenu
|
||||
|
@ -42,17 +47,19 @@ public class GuiModList extends GuiScreen
|
|||
public GuiModList(GuiScreen mainMenu)
|
||||
{
|
||||
this.mainMenu=mainMenu;
|
||||
this.mods=new ArrayList<ModContainer>(Loader.getModList());
|
||||
mods.add(new FMLModLoaderContainer());
|
||||
}
|
||||
|
||||
public void func_6448_a()
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList()) {
|
||||
for (ModContainer mod : mods) {
|
||||
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, listWidth);
|
||||
this.modList=new GuiSlotModList(this, mods, listWidth);
|
||||
this.modList.registerScrollButtons(this.field_949_e, 7, 8);
|
||||
}
|
||||
|
||||
|
@ -77,10 +84,19 @@ public class GuiModList extends GuiScreen
|
|||
if (selectedMod!=null) {
|
||||
if (selectedMod.getMetadata()!=null) {
|
||||
this.func_548_a(this.field_6451_g, selectedMod.getMetadata().name, detailCentre, 35, 0xFFFFFF);
|
||||
/* String modInfomation=String.format(
|
||||
"Version: %s\n" +
|
||||
"Credits: %s\n" +
|
||||
"Authors: %s\n" +
|
||||
"URL : %s\n" +
|
||||
"Updates: %s\n" +
|
||||
"Description:\n" +
|
||||
"%s",selectedMod.getMetadata().version,selectedMod.getMetadata().credits,selectedMod.getMetadata().authorList,selectedMod.getMetadata().url,selectedMod.getMetadata().updateUrl,selectedMod.getMetadata().description);*/
|
||||
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.func_548_a(this.field_6451_g, String.format("URL: %s", selectedMod.getMetadata().url), detailCentre, 75, 0xFFFFFF);
|
||||
this.func_548_a(this.field_6451_g, String.format("Updates: %s", selectedMod.getMetadata().updateUrl), detailCentre, 85, 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, selectedMod.getName(), detailCentre, 35, 0xFFFFFF);
|
||||
|
@ -106,8 +122,8 @@ public class GuiModList extends GuiScreen
|
|||
public void selectModIndex(int var1)
|
||||
{
|
||||
this.selected=var1;
|
||||
if (var1>=0 && var1<=Loader.getModList().size()) {
|
||||
this.selectedMod=Loader.getModList().get(selected);
|
||||
if (var1>=0 && var1<=mods.size()) {
|
||||
this.selectedMod=mods.get(selected);
|
||||
} else {
|
||||
this.selectedMod=null;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.ModMetadata;
|
||||
|
@ -30,17 +32,19 @@ import net.minecraft.src.Tessellator;
|
|||
public class GuiSlotModList extends GuiScrollingList
|
||||
{
|
||||
private GuiModList parent;
|
||||
private ArrayList<ModContainer> mods;
|
||||
|
||||
public GuiSlotModList(GuiModList parent, int listWidth)
|
||||
public GuiSlotModList(GuiModList parent, ArrayList<ModContainer> mods, int listWidth)
|
||||
{
|
||||
super(parent.getMinecraftInstance(), listWidth, parent.field_950_d, 32, parent.field_950_d - 65 + 4, 10, 25);
|
||||
this.parent=parent;
|
||||
this.mods=mods;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSize()
|
||||
{
|
||||
return Loader.getModList().size();
|
||||
return mods.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,7 +74,7 @@ public class GuiSlotModList extends GuiScrollingList
|
|||
@Override
|
||||
protected void drawSlot(int listIndex, int var2, int var3, int var4, Tessellator var5)
|
||||
{
|
||||
ModContainer mc=Loader.getModList().get(listIndex);
|
||||
ModContainer mc=mods.get(listIndex);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -453,7 +453,7 @@ public class FMLCommonHandler
|
|||
} catch (Exception ex) {
|
||||
// Ignore - no branding file found
|
||||
}
|
||||
brandings.add(String.format("%d mod%s loaded",Loader.getModList().size(), Loader.getModList().size()>1?"s":""));
|
||||
brandings.add(String.format("%d mod%s loaded",Loader.getModList().size(), Loader.getModList().size()!=1?"s":""));
|
||||
Collections.reverse(brandings);
|
||||
return brandings.toArray(new String[brandings.size()]);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ public class FMLModContainer implements ModContainer
|
|||
private Mod modDescriptor;
|
||||
private Object modInstance;
|
||||
private File source;
|
||||
private ModMetadata modMetadata;
|
||||
|
||||
public FMLModContainer(String dummy)
|
||||
{
|
||||
|
@ -362,8 +363,7 @@ public class FMLModContainer implements ModContainer
|
|||
@Override
|
||||
public ModMetadata getMetadata()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return modMetadata;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#setMetadata(cpw.mods.fml.common.ModMetadata)
|
||||
|
@ -371,8 +371,7 @@ public class FMLModContainer implements ModContainer
|
|||
@Override
|
||||
public void setMetadata(ModMetadata meta)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
this.modMetadata=meta;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#gatherRenderers(java.util.Map)
|
||||
|
|
75
fml/common/cpw/mods/fml/common/FMLModLoaderContainer.java
Normal file
75
fml/common/cpw/mods/fml/common/FMLModLoaderContainer.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* 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 cpw.mods.fml.common;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class FMLModLoaderContainer extends FMLModContainer
|
||||
{
|
||||
|
||||
/**
|
||||
* @param dummy
|
||||
*/
|
||||
public FMLModLoaderContainer()
|
||||
{
|
||||
super("Forge Mod Loader");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.FMLModContainer#getMetadata()
|
||||
*/
|
||||
@Override
|
||||
public ModMetadata getMetadata()
|
||||
{
|
||||
if (super.getMetadata()==null) {
|
||||
ModMetadata md=new ModMetadata(this);
|
||||
setMetadata(md);
|
||||
md.name="Forge Mod Loader";
|
||||
md.version=Loader.instance().getFMLVersionString();
|
||||
md.credits="Made possible with help from many people";
|
||||
md.authorList="cpw, LexManos";
|
||||
md.description="The Forge Mod Loader provides the ability for systems to load mods " +
|
||||
"from the file system. It also provides key capabilities for mods to be able " +
|
||||
"to cooperate and provide a good modding environment." +
|
||||
"The mod loading system is compatible with ModLoader, all your ModLoader" +
|
||||
"mods should work.";
|
||||
md.url="https://github.com/cpw/FML/wiki";
|
||||
md.updateUrl="https://github.com/cpw/FML/wiki";
|
||||
md.screenshots=new String[0];
|
||||
md.logoFile="";
|
||||
}
|
||||
return super.getMetadata();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.FMLModContainer#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Forge Mod Loader";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.FMLModContainer#getVersion()
|
||||
*/
|
||||
@Override
|
||||
public String getVersion()
|
||||
{
|
||||
return Loader.instance().getFMLVersionString();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue