More tweaks to stuff: mod list, branding, more hooks

This commit is contained in:
Christian Weeks 2012-05-11 01:45:36 -04:00
parent abc7b3f2a6
commit 7735567ce0
6 changed files with 239 additions and 0 deletions

View file

@ -0,0 +1,77 @@
/*
* 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.client;
import net.minecraft.client.Minecraft;
import net.minecraft.src.FontRenderer;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.GuiSmallButton;
import net.minecraft.src.StringTranslate;
/**
* @author cpw
*
*/
public class GuiModList extends GuiScreen
{
private GuiScreen mainMenu;
private GuiSlotModList modList;
/**
* @param guiMainMenu
*/
public GuiModList(GuiScreen mainMenu)
{
this.mainMenu=mainMenu;
}
public void func_6448_a()
{
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.func_22240_a(this.field_949_e, 7, 8);
}
protected void func_572_a(GuiButton button) {
if (button.field_937_g)
{
switch (button.field_938_f)
{
case 6:
this.field_945_b.func_6272_a(this.mainMenu);
}
}
}
public void func_571_a(int p_571_1_, int p_571_2_, float p_571_3_)
{
this.modList.func_22243_a(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);
super.func_571_a(p_571_1_, p_571_2_, p_571_3_);
}
Minecraft getMinecraftInstance() {
return field_945_b;
}
FontRenderer getFontRenderer() {
return field_6451_g;
}
}

View 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.client;
import cpw.mods.fml.common.Loader;
import net.minecraft.client.Minecraft;
import net.minecraft.src.GuiLanguage;
import net.minecraft.src.GuiSlot;
import net.minecraft.src.StringTranslate;
import net.minecraft.src.Tessellator;
/**
* @author cpw
*
*/
public class GuiSlotModList extends GuiSlot
{
private GuiModList parent;
public GuiSlotModList(GuiModList parent)
{
super(parent.getMinecraftInstance(), parent.field_951_c, parent.field_950_d, 32, parent.field_950_d - 65 + 4, 18);
this.parent=parent;
}
@Override
protected int func_22249_a()
{
return Loader.getModList().size();
}
@Override
protected void func_22247_a(int var1, boolean var2)
{
// TODO Auto-generated method stub
}
@Override
protected boolean func_22246_a(int var1)
{
return false;
}
@Override
protected void func_22248_c()
{
this.parent.func_578_i();
}
@Override
protected int func_22245_b()
{
return this.func_22249_a() * 18;
}
@Override
protected void func_22242_a(int listIndex, int var2, int var3, int var4, Tessellator var5)
{
this.parent.func_548_a(this.parent.getFontRenderer(), Loader.getModList().get(listIndex).getName(), this.parent.field_951_c / 2, var3 + 1, 16777215);
}
}

View file

@ -16,6 +16,8 @@ package cpw.mods.fml.common;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -403,4 +405,30 @@ public class FMLCommonHandler
throw new RuntimeException(exception);
}
/**
* @param string
* @return
*/
public String[] getBrandingStrings(String mcVersion)
{
ArrayList<String> brandings=new ArrayList<String>();
brandings.add(mcVersion);
brandings.add(Loader.instance().getFMLVersionString());
try {
brandings.add((String)Class.forName("forge.MinecraftForge").getMethod("getVersionString").invoke(null));
} catch (Exception ex) {
// Ignore- forge isn't loaded
}
try {
Properties props=new Properties();
props.load(FMLCommonHandler.class.getClassLoader().getResourceAsStream("fmlbranding.properties"));
brandings.add(props.getProperty("fmlbranding"));
} catch (Exception ex) {
// Ignore - no branding file found
}
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()]);
}
}

View file

@ -614,4 +614,12 @@ public class Loader
}
return ret.toString();
}
/**
* @return
*/
public String getFMLVersionString()
{
return String.format("FML v%s.%s.%s.%s", major, minor, rev, build);
}
}

View file

@ -35,6 +35,11 @@
<type>2</type>
<locationURI>MCP_LOC/src-work/minecraft</locationURI>
</link>
<link>
<name>common/fmlversion.properties</name>
<type>1</type>
<location>/home/cpw/projects/mcworkspace/fmltestbed/FML/fmlversion.properties</location>
</link>
</linkedResources>
<filteredResources>
<filter>

View file

@ -0,0 +1,46 @@
--- ../src-base/minecraft/net/minecraft/src/GuiMainMenu.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft/net/minecraft/src/GuiMainMenu.java 0000-00-00 00:00:00.000000000 -0000
@@ -11,6 +11,9 @@
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.GLU;
+import cpw.mods.fml.client.GuiModList;
+import cpw.mods.fml.common.FMLCommonHandler;
+
public class GuiMainMenu extends GuiScreen
{
private static final Random field_6463_h = new Random();
@@ -91,7 +94,8 @@
int var4 = this.field_950_d / 4 + 48;
this.field_949_e.add(new GuiButton(1, this.field_951_c / 2 - 100, var4, var2.func_20163_a("menu.singleplayer")));
this.field_949_e.add(this.field_25096_l = new GuiButton(2, this.field_951_c / 2 - 100, var4 + 24, var2.func_20163_a("menu.multiplayer")));
- this.field_949_e.add(new GuiButton(3, this.field_951_c / 2 - 100, var4 + 48, var2.func_20163_a("menu.mods")));
+ this.field_949_e.add(new GuiButton(3, this.field_951_c / 2 - 100, var4 + 48, 98, 20, var2.func_20163_a("menu.mods")));
+ this.field_949_e.add(new GuiButton(6, this.field_951_c / 2 + 2, var4 + 48, 98, 20, "Mods"));
if (this.field_945_b.field_6317_l)
{
@@ -142,6 +146,11 @@
{
this.field_945_b.func_6244_d();
}
+
+ if (p_572_1_.field_938_f == 6)
+ {
+ this.field_945_b.func_6272_a(new GuiModList(this));
+ }
}
private void func_35355_b(int p_35355_1_, int p_35355_2_, float p_35355_3_)
@@ -324,7 +333,10 @@
GL11.glScalef(var8, var8, var8);
this.func_548_a(this.field_6451_g, this.field_6462_l, 0, -8, 16776960);
GL11.glPopMatrix();
- this.func_547_b(this.field_6451_g, "Minecraft 1.2.5", 2, this.field_950_d - 10, 16777215);
+ String[] brandings=FMLCommonHandler.instance().getBrandingStrings("Minecraft 1.2.5");
+ for (int i=0; i<brandings.length; i++) {
+ this.func_547_b(this.field_6451_g, brandings[i], 2, this.field_950_d - ( 10 + i * (this.field_6451_g.field_41063_b +1)), 16777215);
+ }
String var9 = "Copyright Mojang AB. Do not distribute!";
this.func_547_b(this.field_6451_g, var9, this.field_951_c - this.field_6451_g.func_871_a(var9) - 2, this.field_950_d - 10, 16777215);
super.func_571_a(p_571_1_, p_571_2_, p_571_3_);