mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-10-26 14:34:02 +00:00
Cleanup (#14)
* update gradle+deps * remove bak file clean wci * add back * sa
This commit is contained in:
1 parent
e7524e80f1
commit
9698692020
40 files changed
+57
-2316
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.3.48-GTNH:dev')
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.4.5-GTNH:dev')
|
||||
|
||||
shadowImplementation('au.com.bytecode:opencsv:2.4')
|
||||
}
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,6 +1,9 @@
|
||||
package mcp.mobius.waila.addons.enderio;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.RESET;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package mcp.mobius.waila.addons.enderio;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.RESET;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
public class HUDHandlerTEBaseGenerator implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
try{
|
||||
int storage = -1;
|
||||
int production = -1;
|
||||
|
||||
if (IC2Module.TileEntityBaseGenerator.isInstance(accessor.getTileEntity())){
|
||||
storage = IC2Module.TEBG_MaxStorage.getShort(accessor.getTileEntity());
|
||||
production = IC2Module.TEBG_Production.getInt(accessor.getTileEntity());
|
||||
}
|
||||
else if (IC2Module.TileEntityGeoGenerator.isInstance(accessor.getTileEntity())){
|
||||
storage = IC2Module.TEGG_MaxStorage.getShort(accessor.getTileEntity());
|
||||
production = IC2Module.TEGG_Production.getInt(accessor.getTileEntity());
|
||||
}
|
||||
else if (IC2Module.TileEntitySemifluidGenerator.isInstance(accessor.getTileEntity())){
|
||||
storage = IC2Module.TESG_MaxStorage.getShort(accessor.getTileEntity());
|
||||
production = (int)IC2Module.TESG_Production.getDouble(accessor.getTileEntity());
|
||||
}
|
||||
|
||||
String storedStr = LangUtil.translateG("hud.msg.stored");
|
||||
String outputStr = LangUtil.translateG("hud.msg.output");
|
||||
|
||||
/* EU Storage */
|
||||
if (ConfigHandler.instance().getConfig("ic2.storage")){
|
||||
double stored = IC2Module.getStoredEnergy(accessor);
|
||||
|
||||
if ( stored >= 0.0 && storage > 0)
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
|
||||
|
||||
//else if (stored >= 0.0)
|
||||
// currenttip.add(String.format("Stored : %d EU", stored));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.outputeu")){
|
||||
if ( production > 0)
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", outputStr, TAB + ALIGNRIGHT, production));
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
|
||||
if (te != null)
|
||||
te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
public class HUDHandlerTEElectricBlock implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
try{
|
||||
String storedStr = LangUtil.translateG("hud.msg.stored");
|
||||
String outputStr = LangUtil.translateG("hud.msg.output");
|
||||
|
||||
/* EU Storage */
|
||||
if (ConfigHandler.instance().getConfig("ic2.storage")){
|
||||
double stored = IC2Module.getStoredEnergy(accessor);
|
||||
int storage = IC2Module.TEEB_MaxStorage.getInt(accessor.getTileEntity());
|
||||
|
||||
if ( stored >= 0.0 )
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.outputeu")){
|
||||
int production = IC2Module.TEEB_Output.getInt(accessor.getTileEntity());
|
||||
if ( production > 0)
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", outputStr, TAB + ALIGNRIGHT, production));
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
|
||||
if (te != null)
|
||||
te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
public class HUDHandlerTEStandardMachine implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
try{
|
||||
|
||||
IC2Upgrades upgrades = IC2Module.getUpgrades(accessor);
|
||||
int baseConsumption = IC2Module.TESM_DefaultEnergyConsume.getInt(accessor.getTileEntity());
|
||||
int baseOpTime = IC2Module.TESM_DefaultOperationLength.getInt(accessor.getTileEntity());
|
||||
int baseStorage = IC2Module.TESM_DefaultEnergyStorage.getInt(accessor.getTileEntity());
|
||||
|
||||
long consumption = Math.round(Math.min(baseConsumption * Math.pow(1.6D, upgrades.overclocker), 2147483647));
|
||||
|
||||
double stackOpLen = baseOpTime * 64.0D * Math.pow(0.7D, upgrades.overclocker);
|
||||
int opPerTick = ((int)Math.min(Math.ceil(64.0D / stackOpLen), 2147483647.0D));
|
||||
int opTime = ((int)Math.round(stackOpLen * opPerTick / 64.0D));
|
||||
|
||||
int storage = Math.round(Math.min(baseStorage + 10000 * upgrades.storage + opTime * consumption, 2147483647));;
|
||||
|
||||
|
||||
int maxinput = (Integer)IC2Module.IES_GetMaxSafeInput.invoke(accessor.getTileEntity()) * (int)Math.pow(4.0D, Math.min(4, upgrades.transform));
|
||||
double stored = IC2Module.getStoredEnergy(accessor);
|
||||
|
||||
String storedStr = LangUtil.translateG("hud.msg.stored");
|
||||
String powerStr = LangUtil.translateG("hud.msg.power");
|
||||
String maxPowerStr = LangUtil.translateG("hud.msg.maxpower");
|
||||
|
||||
/* EU Storage */
|
||||
if (ConfigHandler.instance().getConfig("ic2.storage")){
|
||||
if ( stored >= 0.0 )
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.consump")){
|
||||
if ( consumption > 0)
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", powerStr, TAB + ALIGNRIGHT, consumption ));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.inputeu")){
|
||||
if ( maxinput > 0)
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", maxPowerStr, TAB + ALIGNRIGHT, maxinput ));
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
|
||||
if (te != null)
|
||||
te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
public class HUDHandlerTETradeOMat implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack,List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
/*
|
||||
if (!ConfigHandler.instance().getConfig("ic2.tradeomat")) return currenttip;
|
||||
|
||||
NBTTagCompound slots = accessor.getNBTData().getCompoundTag("InvSlots");
|
||||
NBTTagList offer = slots.getCompoundTag("offer").getTagList("Contents");
|
||||
NBTTagList demand = slots.getCompoundTag("demand").getTagList("Contents");
|
||||
String offersStr = LangUtil.translateG("hud.msg.offers");
|
||||
String demandsStr = LangUtil.translateG("hud.msg.demands");
|
||||
|
||||
|
||||
if (offer.tagCount() == 1){
|
||||
NBTTagCompound subtag = (NBTTagCompound)offer.tagAt(0);
|
||||
ItemStack is = new ItemStack(subtag.getShort("id"), subtag.getByte("Count"), subtag.getShort("Damage"));
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r x \u00a7f%s\u00a7r", offersStr, TAB + ALIGNRIGHT, is.stackSize, is.getDisplayName()));
|
||||
}
|
||||
|
||||
if (demand.tagCount() == 1){
|
||||
NBTTagCompound subtag = (NBTTagCompound)demand.tagAt(0);
|
||||
ItemStack is = new ItemStack(subtag.getShort("id"), subtag.getByte("Count"), subtag.getShort("Damage"));
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r x \u00a7f%s\u00a7r", demandsStr, TAB + ALIGNRIGHT, is.stackSize, is.getDisplayName()));
|
||||
}
|
||||
*/
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
|
||||
if (te != null)
|
||||
te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.AccessHelper;
|
||||
|
||||
public class IC2Module {
|
||||
|
||||
public static Class TileEntityStandardMachine = null;
|
||||
public static Field TESM_DefaultEnergyStorage = null;
|
||||
public static Field TESM_DefaultEnergyConsume = null;
|
||||
public static Field TESM_DefaultOperationLength = null;
|
||||
public static Field TESM_MaxEnergy = null;
|
||||
|
||||
public static Class TileEntityBaseGenerator = null;
|
||||
public static Field TEBG_MaxStorage = null;
|
||||
public static Field TEBG_Production = null;
|
||||
|
||||
public static Class TileEntitySemifluidGenerator = null;
|
||||
public static Field TESG_MaxStorage = null;
|
||||
public static Field TESG_Production = null;
|
||||
|
||||
public static Class TileEntityGeoGenerator = null;
|
||||
public static Field TEGG_MaxStorage = null;
|
||||
public static Field TEGG_Production = null;
|
||||
|
||||
public static Class TileEntityElectricBlock = null;
|
||||
public static Field TEEB_MaxStorage = null;
|
||||
public static Field TEEB_Output = null;
|
||||
|
||||
public static Class IEnergySink = null;
|
||||
public static Method IES_GetMaxSafeInput = null;
|
||||
|
||||
public static Class TileEntityTradeOMat = null;
|
||||
|
||||
/* Some required items */
|
||||
public static Class IC2Items = null;
|
||||
public static Field TransformerUpgrade = null;
|
||||
public static ItemStack TransformerUpgradeStack = null;
|
||||
public static Field EnergyStorageUpgrade = null;
|
||||
public static ItemStack EnergyStorageUpgradeStack = null;
|
||||
public static Field OverclockerUpgrade = null;
|
||||
public static ItemStack OverclockerUpgradeStack = null;
|
||||
|
||||
public static void register(){
|
||||
/*
|
||||
|
||||
try{
|
||||
TileEntityStandardMachine = Class.forName("ic2.core.block.machine.tileentity.TileEntityStandardMachine");
|
||||
TESM_DefaultEnergyStorage = TileEntityStandardMachine.getField("defaultEnergyStorage");
|
||||
TESM_DefaultEnergyConsume = TileEntityStandardMachine.getField("defaultEnergyConsume");
|
||||
TESM_DefaultOperationLength = TileEntityStandardMachine.getField("defaultOperationLength");
|
||||
TESM_MaxEnergy = TileEntityStandardMachine.getField("maxEnergy");
|
||||
|
||||
TileEntityBaseGenerator = Class.forName("ic2.core.block.generator.tileentity.TileEntityBaseGenerator");
|
||||
TEBG_MaxStorage = TileEntityBaseGenerator.getField("maxStorage");
|
||||
TEBG_Production = TileEntityBaseGenerator.getField("production");
|
||||
|
||||
TileEntitySemifluidGenerator = Class.forName("ic2.core.block.generator.tileentity.TileEntitySemifluidGenerator");
|
||||
TESG_MaxStorage = TileEntitySemifluidGenerator.getDeclaredField("maxStorage");
|
||||
TESG_Production = TileEntitySemifluidGenerator.getDeclaredField("production");
|
||||
TESG_MaxStorage.setAccessible(true);
|
||||
TESG_Production.setAccessible(true);
|
||||
|
||||
TileEntityGeoGenerator = Class.forName("ic2.core.block.generator.tileentity.TileEntityGeoGenerator");
|
||||
TEGG_MaxStorage = TileEntityGeoGenerator.getField("maxStorage");
|
||||
TEGG_Production = TileEntityGeoGenerator.getField("production");
|
||||
|
||||
TileEntityElectricBlock = Class.forName("ic2.core.block.wiring.TileEntityElectricBlock");
|
||||
TEEB_MaxStorage = TileEntityElectricBlock.getField("maxStorage");
|
||||
TEEB_Output = TileEntityElectricBlock.getField("output");
|
||||
|
||||
IEnergySink = Class.forName("ic2.api.energy.tile.IEnergySink");
|
||||
IES_GetMaxSafeInput = IEnergySink.getMethod("getMaxSafeInput");
|
||||
|
||||
IC2Items = Class.forName("ic2.core.Ic2Items");
|
||||
TransformerUpgrade = IC2Items.getField("transformerUpgrade");
|
||||
EnergyStorageUpgrade = IC2Items.getField("energyStorageUpgrade");
|
||||
OverclockerUpgrade = IC2Items.getField("overclockerUpgrade");
|
||||
|
||||
TransformerUpgradeStack = (ItemStack)TransformerUpgrade.get(null);
|
||||
EnergyStorageUpgradeStack = (ItemStack)EnergyStorageUpgrade.get(null);
|
||||
OverclockerUpgradeStack = (ItemStack)OverclockerUpgrade.get(null);
|
||||
|
||||
TileEntityTradeOMat = Class.forName("ic2.core.block.personal.TileEntityTradeOMat");
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
//e.printStackTrace();
|
||||
Waila.log.log(Level.WARNING, "[IC2] Class not found. " + e);
|
||||
return;
|
||||
} catch (NoSuchMethodException e){
|
||||
//e.printStackTrace();
|
||||
Waila.log.log(Level.WARNING, "[IC2] Method not found." + e);
|
||||
return;
|
||||
} catch (NoSuchFieldException e){
|
||||
//e.printStackTrace();
|
||||
Waila.log.log(Level.WARNING, "[IC2] Field not found." + e);
|
||||
return;
|
||||
} catch (Exception e){
|
||||
//e.printStackTrace();
|
||||
Waila.log.log(Level.WARNING, "[IC2] Unhandled exception." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.storage");
|
||||
ModuleRegistrar.instance().addConfig("IndustrialCraft2", "ic2.outputeu");
|
||||
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.inputeu");
|
||||
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.consump");
|
||||
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.tradeomat");
|
||||
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEStandardMachine(), TileEntityStandardMachine);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntityBaseGenerator);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntitySemifluidGenerator);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntityGeoGenerator);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEElectricBlock(), TileEntityElectricBlock);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTETradeOMat(), TileEntityTradeOMat);
|
||||
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityStandardMachine);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityBaseGenerator);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntitySemifluidGenerator);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityGeoGenerator);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityElectricBlock);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityTradeOMat);
|
||||
*/
|
||||
}
|
||||
|
||||
/* Retuns the current stored energy if available in the nbt and config is true */
|
||||
public static double getStoredEnergy(IWailaDataAccessor accessor){
|
||||
/*
|
||||
if (ConfigHandler.instance().getConfig("ic2.storage")){
|
||||
if (accessor.getNBTData().hasKey("energy"))
|
||||
return accessor.getNBTData().getDouble("energy");
|
||||
else if (accessor.getNBTData().hasKey("storage"))
|
||||
return accessor.getNBTData().getDouble("storage");
|
||||
}
|
||||
*/
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
public static IC2Upgrades getUpgrades(IWailaDataAccessor accessor){
|
||||
|
||||
NBTTagCompound nbt = accessor.getNBTData();
|
||||
IC2Upgrades upgrades = new IC2Upgrades();
|
||||
|
||||
/*
|
||||
if (!nbt.hasKey("InvSlots")) return null;
|
||||
|
||||
NBTTagCompound inventory = nbt.getCompoundTag("InvSlots");
|
||||
if (!inventory.hasKey("upgrade")) return null;
|
||||
|
||||
NBTTagList nbtupgrades = inventory.getCompoundTag("upgrade").getTagList("Contents");
|
||||
|
||||
//List tagList = (List)AccessHelper.getField("net.minecraft.nbt.NBTTagList", "tagList", nbtupgrades);
|
||||
List tagList = ObfuscationReflectionHelper.getPrivateValue(NBTTagList.class, nbtupgrades, "field_74747_a");
|
||||
|
||||
for (Object subobj : tagList){
|
||||
NBTTagCompound subtag = (NBTTagCompound)subobj;
|
||||
int id = subtag.getShort("id");
|
||||
int meta = subtag.getShort("Damage");
|
||||
int count = subtag.getByte("Count");
|
||||
|
||||
//ItemStack is = new ItemStack(id, 1, count);
|
||||
if (TransformerUpgradeStack.getItemDamage() == meta && TransformerUpgradeStack.itemID == id)
|
||||
upgrades.transform += count;
|
||||
if (EnergyStorageUpgradeStack.getItemDamage() == meta && EnergyStorageUpgradeStack.itemID == id)
|
||||
upgrades.storage += count;
|
||||
if (OverclockerUpgradeStack.getItemDamage() == meta && OverclockerUpgradeStack.itemID == id)
|
||||
upgrades.overclocker += count;
|
||||
}
|
||||
*/
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
public class IC2Upgrades {
|
||||
public int transform = 0;
|
||||
public int storage = 0;
|
||||
public int overclocker = 0;
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package mcp.mobius.waila.addons.projectred;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package mcp.mobius.waila.addons.statues;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.BLUE;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package mcp.mobius.waila.addons.thaumcraft;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.RENDER;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WailaStyle;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class SpecialChars {
|
||||
|
||||
@@ -1,235 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import mcp.mobius.waila.gui_old.widget.IWidget;
|
||||
import mcp.mobius.waila.gui_old.widget_old.Button2States;
|
||||
import mcp.mobius.waila.gui_old.widget_old.ButtonChangeScreen;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
|
||||
public class BaseWailaScreen extends GuiScreen{
|
||||
|
||||
protected GuiScreen parentGui; // GUI we will return to in the case we are call from a GUI
|
||||
public ScaledResolution res;
|
||||
protected HashMap<String, IWidget> widgets = new HashMap<String, IWidget>();
|
||||
|
||||
/* Custom mouse handling */
|
||||
private int lastMouseButton = -1;
|
||||
private long lastMouseEvent = -1;
|
||||
private int lastMousePosX = -1;
|
||||
private int lastMousePosY = -1;
|
||||
private static int buttonCount = Mouse.getButtonCount();
|
||||
private boolean[] lastButtonStates = new boolean[buttonCount];
|
||||
private IWidget[] focusWidget = new IWidget[buttonCount];
|
||||
private IWidget mainFocusWidget = null;
|
||||
|
||||
|
||||
|
||||
public BaseWailaScreen(GuiScreen _parentGui) {
|
||||
this.parentGui = _parentGui;
|
||||
res = new ScaledResolution(Minecraft.getMinecraft().gameSettings,
|
||||
Minecraft.getMinecraft().displayWidth,
|
||||
Minecraft.getMinecraft().displayHeight);
|
||||
Mouse.getDWheel();
|
||||
}
|
||||
|
||||
@Override
|
||||
/* Here we draw anything special, and super takes care of the buttons for us */
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
drawDefaultBackground();
|
||||
super.drawScreen(i, j, f);
|
||||
}
|
||||
|
||||
@Override
|
||||
/* Here we handle key presses. Super will just close the gui on ESC, and we like it like that */
|
||||
public void keyTyped(char keyChar, int keyID)
|
||||
{
|
||||
if (keyID == 1)
|
||||
{
|
||||
if (this.parentGui == null){
|
||||
this.mc.displayGuiScreen((GuiScreen)null);
|
||||
this.mc.setIngameFocus();
|
||||
} else {
|
||||
this.mc.displayGuiScreen(this.parentGui);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
if (guibutton instanceof ButtonChangeScreen)
|
||||
((ButtonChangeScreen)guibutton).pressButton();
|
||||
|
||||
else if (guibutton instanceof Button2States)
|
||||
((Button2States)guibutton).pressButton();
|
||||
}
|
||||
|
||||
protected int getXCentered(int width){
|
||||
return (this.res.getScaledWidth() - width)/ 2;
|
||||
}
|
||||
|
||||
public void addWidget(String name, IWidget widget){
|
||||
this.widgets.put(name, widget);
|
||||
}
|
||||
|
||||
public Collection<IWidget> getWidgets(){
|
||||
return this.widgets.values();
|
||||
}
|
||||
|
||||
public IWidget getWidget(String name){
|
||||
return this.widgets.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int buttonID)
|
||||
{
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null && widget.mouseClicked(mouseX, mouseY, buttonID)){
|
||||
if (buttonID == 0)
|
||||
this.mainFocusWidget = widget;
|
||||
this.focusWidget[buttonID] = widget;
|
||||
}
|
||||
else
|
||||
super.mouseClicked(mouseX, mouseY, buttonID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMovedOrUp(int mouseX, int mouseY, int buttonID)
|
||||
{
|
||||
if (buttonID == 0)
|
||||
this.mainFocusWidget = null;
|
||||
|
||||
if (this.focusWidget[buttonID] != null){
|
||||
this.focusWidget[buttonID].mouseReleased(mouseX, mouseY, buttonID);
|
||||
this.focusWidget[buttonID] = null;
|
||||
} else {
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget == null || !widget.mouseReleased(mouseX, mouseY, buttonID))
|
||||
super.mouseMovedOrUp(mouseX, mouseY, buttonID);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseWheel(int mouseX, int mouseY, int mouseZ){
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
widget.mouseWheel(mouseX, mouseY, mouseZ);
|
||||
|
||||
}
|
||||
|
||||
public void mouseMoved(int mouseX, int mouseY){
|
||||
if (this.mainFocusWidget != null)
|
||||
this.mainFocusWidget.mouseMoved(mouseX, mouseY);
|
||||
else{
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
widget.mouseMoved(mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public void mouseDragged(int mouseX, int mouseY, int buttonID, long deltaTime){
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
widget.mouseDragged(mouseX, mouseY, buttonID, deltaTime);
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void handleMouseInput()
|
||||
{
|
||||
int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
|
||||
int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
|
||||
int mouseZ = Mouse.getEventDWheel();
|
||||
boolean[] buttonChanged = new boolean[buttonCount];
|
||||
|
||||
if (mouseZ != 0)
|
||||
this.mouseWheel(mouseX, mouseY, mouseZ);
|
||||
|
||||
int changedButton = -1;
|
||||
boolean hasStateChanged = false;
|
||||
if (Mouse.getEventButtonState()){
|
||||
hasStateChanged = true;
|
||||
changedButton = Mouse.getEventButton();
|
||||
}
|
||||
for (int i = 0; i < buttonCount; i++){
|
||||
buttonChanged[i] = Mouse.isButtonDown(i) != this.lastButtonStates[i];
|
||||
this.lastButtonStates[i] = Mouse.isButtonDown(i);
|
||||
|
||||
if (buttonChanged[i] && Mouse.isButtonDown(i))
|
||||
this.mouseClicked(mouseX, mouseY, i);
|
||||
else if (buttonChanged[i] && !Mouse.isButtonDown(i))
|
||||
this.mouseMovedOrUp(mouseX, mouseY, i);
|
||||
}
|
||||
|
||||
if ((mouseX != this.lastMousePosX) || (mouseY != this.lastMousePosY)){
|
||||
this.mouseMoved(mouseX, mouseY);
|
||||
this.lastMousePosX = mouseX;
|
||||
this.lastMousePosY = mouseY;
|
||||
}
|
||||
|
||||
/*
|
||||
if (changedButton != -1){
|
||||
if (Mouse.isButtonDown(changedButton)){
|
||||
this.mouseClicked(mouseX, mouseY, changedButton);
|
||||
this.lastMouseButton = changedButton;
|
||||
}
|
||||
else if (!Mouse.isButtonDown(changedButton)){
|
||||
this.mouseMovedOrUp(mouseX, mouseY, changedButton);
|
||||
this.lastMouseButton = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((mouseX != this.lastMousePosX) || (mouseY != this.lastMousePosY)){
|
||||
this.mouseMoved(mouseX, mouseY);
|
||||
this.lastMousePosX = mouseX;
|
||||
this.lastMousePosY = mouseY;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
if (hasStateChanged)
|
||||
{
|
||||
this.lastMouseButton = changedButton;
|
||||
this.lastMouseEvent = Minecraft.getSystemTime();
|
||||
this.mouseClicked(mouseX, mouseY, this.lastMouseButton);
|
||||
}
|
||||
else if (changedButton != -1)
|
||||
{
|
||||
this.lastMouseButton = -1;
|
||||
this.mouseMovedOrUp(mouseX, mouseY, changedButton);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
else if (this.lastMouseButton != -1 && this.lastMouseEvent > 0L)
|
||||
{
|
||||
long deltaTime = Minecraft.getSystemTime() - this.lastMouseEvent;
|
||||
this.mouseDragged(mouseX, mouseY, this.lastMouseButton, deltaTime);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
else if ((mouseX != this.lastMousePosX) || (mouseY != this.lastMousePosY)){
|
||||
this.mouseMoved(mouseX, mouseY);
|
||||
this.lastMousePosX = mouseX;
|
||||
this.lastMousePosY = mouseY;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private IWidget getWidgetAtCoordinates(int posX, int posY){
|
||||
for (IWidget widget : this.getWidgets())
|
||||
if ((posX >= widget.getPosX()) &&
|
||||
(posX <= widget.getPosX() + widget.getWidth()) &&
|
||||
(posY >= widget.getPosY()) &&
|
||||
(posY <= widget.getPosY() + widget.getHeight()))
|
||||
return widget;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old;
|
||||
|
||||
import mcp.mobius.waila.gui_old.widget.ContainerTable;
|
||||
import mcp.mobius.waila.gui_old.widget.Label;
|
||||
import mcp.mobius.waila.gui_old.widget.StackDisplay;
|
||||
import mcp.mobius.waila.gui_old.widget.WikiReader;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiIngameWiki extends BaseWailaScreen {
|
||||
|
||||
public WikiReader widReader = null;
|
||||
public StackDisplay widStack = null;
|
||||
public ContainerTable widTable = null;
|
||||
public Label widItemName = null;
|
||||
|
||||
public GuiIngameWiki(GuiScreen _parentGui) {
|
||||
super(_parentGui);
|
||||
|
||||
this.widReader = new WikiReader(this);
|
||||
this.widStack = new StackDisplay(this);
|
||||
this.widTable = new ContainerTable(this);
|
||||
this.widItemName = new Label("");
|
||||
|
||||
this.widReader.setWidth(this.res.getScaledWidth()-this.res.getScaledWidth()/3 - 16);
|
||||
this.widReader.setHeight(this.res.getScaledHeight() - 24);
|
||||
this.widReader.setBackgroundColor(0x66888888);
|
||||
|
||||
this.widStack.setScale(4.0f);
|
||||
|
||||
this.widTable.setAutosize(false);
|
||||
this.widTable.setWidth(this.res.getScaledWidth()/3 - 8);
|
||||
this.widTable.setHeight(this.res.getScaledHeight() - 16 - this.widStack.getHeight());
|
||||
this.widTable.setColumns(8, "\u00a7a\u00a7oEntry", "\u00a7a\u00a7oValue");
|
||||
|
||||
this.addWidget("wikireader", this.widReader);
|
||||
this.addWidget("stackdisplay", this.widStack);
|
||||
this.addWidget("datatable", this.widTable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
super.drawScreen(i, j, f);
|
||||
widTable.draw(4, this.widStack.getHeight() + 16, 1000);
|
||||
widItemName.draw(this.res.getScaledWidth()/6-widItemName.getWidth()/2, this.widStack.getHeight(), 0);
|
||||
widReader.draw(this.res.getScaledWidth()/3 + 8, 8, 0);
|
||||
widStack.draw(this.res.getScaledWidth()/6-widStack.getWidth()/2, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawDefaultBackground()
|
||||
{
|
||||
this.drawGradientRect(0, 0, this.width, this.height, 0xdd000000, 0xdd000000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old;
|
||||
|
||||
import mcp.mobius.waila.gui_old.widget.DraggableViewport;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiTechTree extends BaseWailaScreen {
|
||||
|
||||
public DraggableViewport widViewport = null;
|
||||
public int topOffset = 16;
|
||||
|
||||
public GuiTechTree(GuiScreen _parentGui) {
|
||||
super(_parentGui);
|
||||
|
||||
this.widViewport = new DraggableViewport(this);
|
||||
this.widViewport.setWidth(this.res.getScaledWidth() - 32);
|
||||
this.widViewport.setHeight(this.res.getScaledHeight() - 32);
|
||||
this.widViewport.setBackgroundColor(0x66888888);
|
||||
|
||||
this.addWidget("viewport", this.widViewport);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
super.drawScreen(i, j, f);
|
||||
this.widViewport.draw(16,topOffset,0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawDefaultBackground()
|
||||
{
|
||||
this.drawGradientRect(0, 0, this.width, this.height, 0xdd000000, 0xdd000000);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.NEI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import codechicken.core.ReflectionManager;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.FuelRecipeHandler;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.ICraftingHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class CraftingTreeNode {
|
||||
|
||||
CraftingTreeNode topNode = null;
|
||||
LinkedHashMap<ItemStack, ArrayList<CraftingTreeNode>> bottomNodes = new LinkedHashMap<ItemStack, ArrayList<CraftingTreeNode>>();
|
||||
|
||||
//Item stacks we have in the node.
|
||||
public ArrayList<ItemStack> elements = new ArrayList<ItemStack>();
|
||||
//Item stacks we are filtering the recipes with. (Previous stacks in the tree)
|
||||
ArrayList<CachedRecipe> excRecipes = new ArrayList<CachedRecipe>();
|
||||
//List of recipes available for a given stack
|
||||
HashMap<ItemStack, ArrayList<CachedRecipe>> recipesMap = new HashMap<ItemStack, ArrayList<CachedRecipe>>();
|
||||
//Components sorted by recipes for a given item stack
|
||||
HashMap<ItemStack, ArrayList<ArrayList<ItemStack>>> componentsMap = new HashMap<ItemStack, ArrayList<ArrayList<ItemStack>>>();
|
||||
|
||||
int layer;
|
||||
LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers;
|
||||
|
||||
public CraftingTreeNode(CraftingTreeNode topNode, ArrayList<ItemStack> elements, int layer, LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers) {
|
||||
this.topNode = topNode;
|
||||
this.layer = layer;
|
||||
this.layers = layers;
|
||||
this.addSelfToLayers();
|
||||
this.setElements(elements);
|
||||
System.out.printf("%s\n", this.toString());
|
||||
}
|
||||
|
||||
public CraftingTreeNode(CraftingTreeNode topNode, ArrayList<ItemStack> elements, ArrayList<CachedRecipe> excluded, int layer, LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers) {
|
||||
this.topNode = topNode;
|
||||
this.layer = layer;
|
||||
this.layers = layers;
|
||||
this.addSelfToLayers();
|
||||
this.excRecipes = excluded;
|
||||
this.setElements(elements);
|
||||
System.out.printf("%s\n", this.toString());
|
||||
}
|
||||
|
||||
public CraftingTreeNode(CraftingTreeNode topNode, ItemStack stack, int layer, LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers) {
|
||||
this.topNode = topNode;
|
||||
this.layer = layer;
|
||||
this.layers = layers;
|
||||
this.addSelfToLayers();
|
||||
this.addElement(stack);
|
||||
System.out.printf("%s\n", this.toString());
|
||||
}
|
||||
|
||||
public void addSelfToLayers(){
|
||||
if (!(this.layers.containsKey(layer)))
|
||||
this.layers.put(this.layer, new ArrayList<CraftingTreeNode>());
|
||||
this.layers.get(this.layer).add(this);
|
||||
}
|
||||
|
||||
public void addElement(ItemStack stack){
|
||||
this.elements.add(stack);
|
||||
this.recipesMap.put(stack, this.getRecipes(stack, this.excRecipes));
|
||||
this.componentsMap.put(stack, new ArrayList<ArrayList<ItemStack>>());
|
||||
for (CachedRecipe recipe: this.recipesMap.get(stack)){
|
||||
this.excRecipes.add(recipe);
|
||||
ArrayList<ItemStack> subComposants = new ArrayList<ItemStack>();
|
||||
for (PositionedStack substack : recipe.getIngredients())
|
||||
subComposants.add(substack.item);
|
||||
|
||||
if (subComposants.size() > 0){
|
||||
if (!this.bottomNodes.containsKey(stack))
|
||||
this.bottomNodes.put(stack, new ArrayList<CraftingTreeNode>());
|
||||
this.bottomNodes.get(stack).add(new CraftingTreeNode(this, this.cleanupRecipe(subComposants), this.excRecipes, this.layer+1, this.layers));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setElements(ArrayList<ItemStack> elements){
|
||||
for (ItemStack is : elements)
|
||||
this.addElement(is);
|
||||
}
|
||||
|
||||
public ArrayList<CachedRecipe> getRecipes(ItemStack stack, ArrayList<CachedRecipe> excluded){
|
||||
ArrayList<ICraftingHandler> craftinghandlers = ReflectionManager.getField(GuiCraftingRecipe.class, ArrayList.class, null, "craftinghandlers");
|
||||
ArrayList<CachedRecipe> cachedRecipes = new ArrayList<CachedRecipe>();
|
||||
|
||||
for (ICraftingHandler handler : craftinghandlers)
|
||||
if (handler instanceof TemplateRecipeHandler && !(handler instanceof FuelRecipeHandler)){
|
||||
((TemplateRecipeHandler) handler).arecipes = new ArrayList<CachedRecipe>();
|
||||
((TemplateRecipeHandler) handler).loadCraftingRecipes(stack);
|
||||
for (CachedRecipe recipe : ((TemplateRecipeHandler)handler).arecipes){
|
||||
boolean found = false;
|
||||
for (CachedRecipe exc : excluded)
|
||||
if (this.areRecipesIdentical(recipe, exc))
|
||||
found = true;
|
||||
if (found)
|
||||
continue;
|
||||
|
||||
cachedRecipes.add(recipe);
|
||||
}
|
||||
}
|
||||
return cachedRecipes;
|
||||
}
|
||||
|
||||
public boolean areRecipesIdentical(CachedRecipe recipe1, CachedRecipe recipe2){
|
||||
if (recipe1.getResult().items.length != recipe2.getResult().items.length)
|
||||
return false;
|
||||
if (recipe1.getIngredients().size() != recipe1.getIngredients().size())
|
||||
return false;
|
||||
for (int i = 0; i < recipe1.getResult().items.length; i++)
|
||||
if (!recipe1.getResult().items[i].isItemEqual(recipe2.getResult().items[i]))
|
||||
return false;
|
||||
for (int i = 0; i < recipe1.getIngredients().size(); i++)
|
||||
for (int j = 0; j < recipe1.getIngredients().get(i).items.length; j++)
|
||||
if (!recipe1.getIngredients().get(i).items[j].isItemEqual(recipe2.getIngredients().get(i).items[j]))
|
||||
return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> cleanupRecipe(ArrayList<ItemStack> stacks){
|
||||
ArrayList<ItemStack> curratedStacks = new ArrayList<ItemStack>();
|
||||
for (ItemStack is : stacks){
|
||||
boolean found = false;
|
||||
for (ItemStack isc : curratedStacks){
|
||||
//if (OreDictionary.itemMatches(is, isc, false)){
|
||||
if ((isc.isItemEqual(is)) ||
|
||||
((OreDictionary.getOreID(isc) != -1) &&
|
||||
(OreDictionary.getOreID(is) != -1) &&
|
||||
(OreDictionary.getOreID(isc) == OreDictionary.getOreID(is))
|
||||
)){
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found){
|
||||
ItemStack isc = is.copy();
|
||||
isc.stackSize = 0;
|
||||
curratedStacks.add(isc);
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack is : stacks)
|
||||
for (ItemStack isc : curratedStacks)
|
||||
if ((isc.isItemEqual(is)) ||
|
||||
((OreDictionary.getOreID(isc) != -1) &&
|
||||
(OreDictionary.getOreID(is) != -1) &&
|
||||
(OreDictionary.getOreID(isc) == OreDictionary.getOreID(is))
|
||||
))
|
||||
//if (isc.isItemEqual(is) || OreDictionary.getOreID(isc) == OreDictionary.getOreID(is))
|
||||
isc.stackSize += is.stackSize;
|
||||
|
||||
return curratedStacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return this.elements.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.NEI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import mcp.mobius.waila.Constants;
|
||||
import mcp.mobius.waila.gui_old.GuiTechTree;
|
||||
import mcp.mobius.waila.gui_old.widget.ComponentDisplay;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.forge.IContainerInputHandler;
|
||||
|
||||
public class HandlerTechTree implements IContainerInputHandler {
|
||||
|
||||
public HandlerTechTree() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
ItemStack stackover = gui.manager.getStackMouseOver();
|
||||
if(stackover == null)
|
||||
return false;
|
||||
|
||||
if(keyID == NEIClientConfig.getKeyBinding(Constants.BIND_SCREEN_TECH)){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
GuiTechTree techScreen = new GuiTechTree(mc.currentScreen);
|
||||
|
||||
LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers = new LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> ();
|
||||
CraftingTreeNode tree = new CraftingTreeNode(null, stackover, 0, layers);
|
||||
|
||||
/*
|
||||
LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> curratedLayers = new LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> ();
|
||||
|
||||
for (int layer : layers.keySet())
|
||||
curratedLayers.put(layer, new ArrayList<CraftingTreeNode>());
|
||||
|
||||
for (int i = 0; i < (layers.size() - 1) ; i++)
|
||||
for (CraftingTreeNode node : layers.get(i)){
|
||||
if (node.bottomNodes.size() != 0){
|
||||
curratedLayers.get(i).add(node);
|
||||
|
||||
}
|
||||
else{
|
||||
node.layer += 1;
|
||||
layers.get(i+1).add(node);
|
||||
}
|
||||
}
|
||||
|
||||
for (CraftingTreeNode node : layers.get(layers.keySet().size()-1))
|
||||
curratedLayers.get(layers.keySet().size()-1).add(node);
|
||||
|
||||
System.out.printf("%s\n", curratedLayers);
|
||||
*/
|
||||
|
||||
/*
|
||||
for (int layer = curratedLayers.keySet().size() - 1; layer >= 0; layer--){
|
||||
int offsetX = 0;
|
||||
for (int icompo = 0; icompo < curratedLayers.get(layer).size(); icompo++){
|
||||
ComponentDisplay componentDisplay = new ComponentDisplay(techScreen, curratedLayers.get(layer).get(icompo));
|
||||
componentDisplay.setBackgroundColor(0xddeeeed1);
|
||||
techScreen.widViewport.addWidget(componentDisplay, offsetX, layer*32, 0);
|
||||
offsetX += componentDisplay.getWidth() + 8;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
for (int layer = layers.keySet().size() - 1; layer >= 0; layer--){
|
||||
int offsetX = 0;
|
||||
for (int icompo = 0; icompo < layers.get(layer).size(); icompo++){
|
||||
ComponentDisplay componentDisplay = new ComponentDisplay(techScreen, layers.get(layer).get(icompo));
|
||||
componentDisplay.setBackgroundColor(0xddeeeed1);
|
||||
if (layer != 0)
|
||||
componentDisplay.setDrawOverlay(true);
|
||||
|
||||
techScreen.widViewport.addWidget(componentDisplay, offsetX, layer*32, 0);
|
||||
offsetX += componentDisplay.getWidth() + 8;
|
||||
}
|
||||
}
|
||||
|
||||
mc.displayGuiScreen(techScreen);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey,
|
||||
int button) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseClicked(GuiContainer gui, int mousex, int mousey,
|
||||
int button) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey,
|
||||
int scrolled) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey,
|
||||
int scrolled) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseDragged(GuiContainer gui, int mousex, int mousey,
|
||||
int button, long heldTime) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.NEI;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import mcp.mobius.waila.Constants;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.gui_old.GuiIngameWiki;
|
||||
import mcp.mobius.waila.gui_old.widget.Label;
|
||||
import mcp.mobius.waila.handlers.SummaryProvider;
|
||||
import mcp.mobius.waila.tools.ModIdentification;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.forge.IContainerInputHandler;
|
||||
|
||||
public class HandlerWiki implements IContainerInputHandler {
|
||||
|
||||
public String getDescriptionString(String modid, String name, String meta){
|
||||
if (ModuleRegistrar.instance().hasDocTextModID(modid)){
|
||||
//Do we have an direct entry for this item ?
|
||||
if (ModuleRegistrar.instance().hasDocTextItem(modid, name)){
|
||||
//We check if we have an exact match, a wildcard match and finally, an meta 0 match
|
||||
if (ModuleRegistrar.instance().hasDocTextMeta(modid, name, meta)){
|
||||
return ModuleRegistrar.instance().getDocText(modid, name, meta);
|
||||
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, name, "*")){
|
||||
return ModuleRegistrar.instance().getDocText(modid, name, "*");
|
||||
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, name, "0")){
|
||||
return ModuleRegistrar.instance().getDocText(modid, name, "0");
|
||||
}
|
||||
|
||||
} else if (ModuleRegistrar.instance().getDoxTextWildcardMatch(modid, name) != null) {
|
||||
String key = ModuleRegistrar.instance().getDoxTextWildcardMatch(modid, name);
|
||||
if (ModuleRegistrar.instance().hasDocTextMeta(modid, key, meta)){
|
||||
return ModuleRegistrar.instance().getDocText(modid, key, meta);
|
||||
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, key, "*")){
|
||||
return ModuleRegistrar.instance().getDocText(modid, key, "*");
|
||||
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, key, "0")){
|
||||
return ModuleRegistrar.instance().getDocText(modid, key, "0");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return String.format("No description for %s$$%s",modid, name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
ItemStack stackover = gui.manager.getStackMouseOver();
|
||||
if(stackover == null)
|
||||
return false;
|
||||
|
||||
if(keyID == NEIClientConfig.getKeyBinding(Constants.BIND_SCREEN_WIKI)){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
GuiIngameWiki wikiScreen = new GuiIngameWiki(mc.currentScreen);
|
||||
|
||||
wikiScreen.widReader.setText(this.getDescriptionString(ModIdentification.idFromStack(stackover), stackover.getItemName(), String.valueOf(stackover.getItemDamage())));
|
||||
wikiScreen.widStack.setStack(stackover);
|
||||
wikiScreen.widItemName.setLabel(stackover.getDisplayName());
|
||||
|
||||
LinkedHashMap<String, String> entries = SummaryProvider.instance().getSummary(stackover, (ConfigHandler.instance()));
|
||||
int nvalidentries = 0;
|
||||
for (String s : entries.keySet())
|
||||
if (entries.get(s) != null)
|
||||
nvalidentries += 1;
|
||||
|
||||
if (nvalidentries == 0)
|
||||
for (int i = 0; i < 6; i++)
|
||||
wikiScreen.widTable.addRow(new Label(""), new Label(entries.get("")));
|
||||
else
|
||||
for (String s : entries.keySet())
|
||||
if (entries.get(s) != null)
|
||||
wikiScreen.widTable.addRow(new Label(s), new Label(entries.get(s)));
|
||||
|
||||
mc.displayGuiScreen(wikiScreen);
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey,
|
||||
int button) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseClicked(GuiContainer gui, int mousex, int mousey,
|
||||
int button) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey,
|
||||
int scrolled) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey,
|
||||
int scrolled) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseDragged(GuiContainer gui, int mousex, int mousey,
|
||||
int button, long heldTime) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
|
||||
public abstract class BaseWidget implements IWidget {
|
||||
|
||||
protected int width, height;
|
||||
protected String label;
|
||||
protected int posX, posY, posZ;
|
||||
protected GuiScreen parent;
|
||||
protected FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;;
|
||||
protected TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
|
||||
protected HashMap<String, IWidget> widgets = new HashMap<String, IWidget>();
|
||||
protected IWidget[] focusWidget = new IWidget[Mouse.getButtonCount()];
|
||||
protected IWidget mainFocusWidget = null;
|
||||
protected int backgroundColor = 0;
|
||||
|
||||
public BaseWidget(){}
|
||||
|
||||
@Override
|
||||
public abstract int getWidth();
|
||||
@Override
|
||||
public abstract int getHeight();
|
||||
@Override
|
||||
public void setWidth(int width) { this.width = width; }
|
||||
@Override
|
||||
public void setHeight(int height) { this.height = height; }
|
||||
|
||||
@Override
|
||||
public void setPos (int posX, int posY, int posZ){
|
||||
this.posX = posX;
|
||||
this.posY = posY;
|
||||
this.posZ = posZ;
|
||||
}
|
||||
@Override
|
||||
public int getPosX(){return this.posX;}
|
||||
@Override
|
||||
public int getPosY(){return this.posY;}
|
||||
|
||||
@Override
|
||||
public String getLabel(){ return this.label;}
|
||||
@Override
|
||||
public void setLabel(String label){ this.label = label; }
|
||||
|
||||
@Override
|
||||
public abstract void draw();
|
||||
@Override
|
||||
public void draw(int x, int y, int z){
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
this.posZ = z;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0f,0.0f, this.posZ);
|
||||
this.draw();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
@Override
|
||||
public void draw(float scale){
|
||||
int oldX = this.posX;
|
||||
int oldY = this.posY;
|
||||
this.posX /= scale;
|
||||
this.posY /= scale;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0f,0.0f, this.posZ);
|
||||
this.draw();
|
||||
GL11.glPopMatrix();
|
||||
this.posX = oldX;
|
||||
this.posY = oldY;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(int mouseX, int mouseY, int buttonID){
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null){
|
||||
if (buttonID == 0)
|
||||
this.mainFocusWidget = widget;
|
||||
this.focusWidget[buttonID] = widget;
|
||||
return widget.mouseClicked(mouseX, mouseY, buttonID);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean mouseReleased(int mouseX, int mouseY, int buttonID){
|
||||
if (buttonID == 0)
|
||||
this.mainFocusWidget = null;
|
||||
|
||||
if (this.focusWidget[buttonID] != null){
|
||||
boolean retval = this.focusWidget[buttonID].mouseReleased(mouseX, mouseY, buttonID);
|
||||
this.focusWidget[buttonID] = null;
|
||||
return retval;
|
||||
}
|
||||
this.focusWidget[buttonID] = null;
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean mouseWheel(int mouseX, int mouseY, int mouseZ){
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
return widget.mouseWheel(mouseX, mouseY, mouseZ);
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean mouseMoved(int mouseX, int mouseY){
|
||||
if (this.mainFocusWidget != null)
|
||||
return this.mainFocusWidget.mouseMoved(mouseX, mouseY);
|
||||
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
return widget.mouseMoved(mouseX, mouseY);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public boolean mouseDragged(int mouseX, int mouseY, int buttonID, long deltaTime){
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
return widget.mouseDragged(mouseX, mouseY, buttonID, deltaTime);
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
public void startScissorFilter(int posX, int posY, int width, int height){
|
||||
ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft().gameSettings,
|
||||
Minecraft.getMinecraft().displayWidth,
|
||||
Minecraft.getMinecraft().displayHeight);
|
||||
int scaleFactor = res.getScaleFactor();
|
||||
|
||||
int glLeft = posX * scaleFactor;
|
||||
int glBottom = (res.getScaledHeight() - (posY + height)) * scaleFactor;
|
||||
|
||||
GL11.glScissor(posX*scaleFactor, glBottom, width*scaleFactor, height*scaleFactor);
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
public void stopScissorFilter(){
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget getWidgetAtCoordinates(int posX, int posY){
|
||||
for (IWidget widget : this.getWidgets())
|
||||
if ((posX >= widget.getPosX()) &&
|
||||
(posX <= widget.getPosX() + widget.getWidth()) &&
|
||||
(posY >= widget.getPosY()) &&
|
||||
(posY <= widget.getPosY() + widget.getHeight()))
|
||||
return widget;
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void addWidget(String name, IWidget widget){
|
||||
this.widgets.put(name, widget);
|
||||
}
|
||||
@Override
|
||||
public Collection<IWidget> getWidgets(){
|
||||
return this.widgets.values();
|
||||
}
|
||||
@Override
|
||||
public IWidget getWidget(String name){
|
||||
return this.widgets.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundColor(int color){
|
||||
this.backgroundColor = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(){
|
||||
if (this.backgroundColor != 0)
|
||||
this.drawGradientRect(this.posX, this.posY, this.posX+this.getWidth(), this.posY+this.getHeight(), 0.0, this.backgroundColor, this.backgroundColor);
|
||||
}
|
||||
|
||||
public void drawGradientRect(int left, int top, int right, int bottom, double zlevel, int colorStart, int colorStop)
|
||||
{
|
||||
float f = (colorStart >> 24 & 255) / 255.0F;
|
||||
float f1 = (colorStart >> 16 & 255) / 255.0F;
|
||||
float f2 = (colorStart >> 8 & 255) / 255.0F;
|
||||
float f3 = (colorStart & 255) / 255.0F;
|
||||
float f4 = (colorStop >> 24 & 255) / 255.0F;
|
||||
float f5 = (colorStop >> 16 & 255) / 255.0F;
|
||||
float f6 = (colorStop >> 8 & 255) / 255.0F;
|
||||
float f7 = (colorStop & 255) / 255.0F;
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(f1, f2, f3, f);
|
||||
tessellator.addVertex(right, top, zlevel);
|
||||
tessellator.addVertex(left, top, zlevel);
|
||||
tessellator.setColorRGBA_F(f5, f6, f7, f4);
|
||||
tessellator.addVertex(left, bottom, zlevel);
|
||||
tessellator.addVertex(right, bottom, zlevel);
|
||||
tessellator.draw();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mcp.mobius.waila.gui_old.NEI.CraftingTreeNode;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ComponentDisplay extends BaseWidget {
|
||||
|
||||
ArrayList<ItemStack> components = null;
|
||||
CraftingTreeNode node = null;
|
||||
int spacingX = 4;
|
||||
int spacingY = 4;
|
||||
int stackDisplayWidth = 0;
|
||||
boolean drawOverlay = false;
|
||||
|
||||
public ComponentDisplay(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
this.components = new ArrayList<ItemStack>();
|
||||
};
|
||||
|
||||
public ComponentDisplay(GuiScreen parent, CraftingTreeNode node){
|
||||
this.parent = parent;
|
||||
this.node = node;
|
||||
this.setComponents(node.elements);
|
||||
};
|
||||
|
||||
public void setDrawOverlay(boolean value){
|
||||
for(IWidget widget : this.getWidgets())
|
||||
if(widget instanceof StackDisplay)
|
||||
((StackDisplay)widget).setDrawOverlay(value);
|
||||
}
|
||||
|
||||
public void setComponents(ArrayList<ItemStack> components){
|
||||
this.components = components;
|
||||
this.stackDisplayWidth = 0;
|
||||
|
||||
for (ItemStack component : components)
|
||||
this.addWidget(String.format("widget_%03d", this.getWidgets().size()), new StackDisplay(this.parent, component));
|
||||
|
||||
for (IWidget widget:this.getWidgets())
|
||||
this.stackDisplayWidth = Math.max(this.stackDisplayWidth, widget.getWidth());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
int width = 0;
|
||||
for (IWidget widget:this.getWidgets())
|
||||
width += widget.getWidth();
|
||||
width += (this.getWidgets().size() + 1) * this.spacingX;
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
int height = 0;
|
||||
for (IWidget widget:this.getWidgets())
|
||||
height = Math.max(widget.getHeight(), height);
|
||||
height += this.spacingY * 2;
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
//this.drawBackground();
|
||||
int index = 0;
|
||||
for (IWidget widget: this.getWidgets()){
|
||||
widget.setPos(this.posX + (this.spacingX * (index + 1)) + ( index * this.stackDisplayWidth ), this.posY + this.spacingY, 0);
|
||||
widget.draw();
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class ContainerTable extends BaseWidget{
|
||||
int rowHeight;
|
||||
int ncolumns;
|
||||
//int viewportYPos = 0;
|
||||
int tableHeight = 0;
|
||||
int tableWidth = 0;
|
||||
int scrollWidth = 8;
|
||||
int scrollButtonHeight = 16;
|
||||
boolean isScrollActive = false;
|
||||
FontRenderer fontRender;
|
||||
int[] columnPos;
|
||||
int[] columnWidth;
|
||||
ArrayList<IWidget[]> table = new ArrayList<IWidget[]>();
|
||||
VerticalScrollBar scrollbar = new VerticalScrollBar();
|
||||
Label[] columnnames;
|
||||
boolean autosize = true;
|
||||
|
||||
public ContainerTable(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
this.addWidget("VScrollBar", this.scrollbar);
|
||||
};
|
||||
|
||||
public ContainerTable( GuiScreen parent, int height, int ncolumns, String[] columnnames) {
|
||||
this.parent = parent;
|
||||
this.height = height;
|
||||
this.rowHeight = 8;
|
||||
this.fontRender = Minecraft.getMinecraft().fontRenderer;
|
||||
this.ncolumns = ncolumns;
|
||||
this.columnPos = new int[this.ncolumns];
|
||||
this.columnWidth = new int[this.ncolumns];
|
||||
this.columnnames = new Label[this.ncolumns];
|
||||
|
||||
for (int i = 0; i < this.ncolumns; i++){
|
||||
Label labelHeader = new Label(columnnames[i]);
|
||||
this.columnnames[i] = labelHeader;
|
||||
this.addWidget(String.format("header_%s", i), labelHeader);
|
||||
}
|
||||
this.addWidget("VScrollBar", this.scrollbar);
|
||||
}
|
||||
|
||||
public void setAutosize(boolean value){
|
||||
this.autosize = value;
|
||||
}
|
||||
|
||||
public void setColumns(int rowHeight, String... header){
|
||||
this.rowHeight = rowHeight;
|
||||
this.ncolumns = header.length;
|
||||
this.columnPos = new int[this.ncolumns];
|
||||
this.columnWidth = new int[this.ncolumns];
|
||||
this.columnnames = new Label[this.ncolumns];
|
||||
|
||||
for (int i = 0; i < this.ncolumns; i++){
|
||||
Label labelHeader = new Label(header[i]);
|
||||
this.columnnames[i] = labelHeader;
|
||||
this.addWidget(String.format("header_%s", i), labelHeader);
|
||||
|
||||
this.columnWidth[i] = Math.max(labelHeader.getWidth() + 8, this.columnWidth[i]);
|
||||
this.columnWidth[i] = Math.max(this.columnnames[i].getWidth() + 8, this.columnWidth[i]);
|
||||
}
|
||||
this.columnPos[0] = 0;
|
||||
for (int i = 1; i < this.ncolumns; i++)
|
||||
this.columnPos[i] = this.columnPos[i-1] + this.columnWidth[i-1];
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return this.table.size();
|
||||
}
|
||||
|
||||
public void addRow(IWidget... data){
|
||||
this.table.add(data);
|
||||
for (int i = 0; i < data.length; i++)
|
||||
this.addWidget(String.format("row_%s_%s", this.table.size(), i), data[i]);
|
||||
|
||||
for (int i = 0; i < ncolumns; i++){
|
||||
this.columnWidth[i] = Math.max(data[i].getWidth() + 8, this.columnWidth[i]);
|
||||
this.columnWidth[i] = Math.max(this.columnnames[i].getWidth() + 8, this.columnWidth[i]);
|
||||
}
|
||||
|
||||
this.columnPos[0] = 0;
|
||||
for (int i = 1; i < this.ncolumns; i++)
|
||||
this.columnPos[i] = this.columnPos[i-1] + this.columnWidth[i-1];
|
||||
|
||||
this.isScrollActive = (this.getViewportHeight() < this.getTableHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(1.0f, 1.0f, this.posZ);
|
||||
this.drawBackground();
|
||||
this.drawTitle(this.posX, this.posY);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0, this.scrollbar.getCurrentValue() * -1.0F, 0);
|
||||
this.startScissorFilter(this.posX, this.posY + this.rowHeight, this.getWidth(), this.getViewportHeight());
|
||||
|
||||
for (int i = 0; i < this.table.size(); i++)
|
||||
this.drawRow(i, this.posX, this.posY+(i+1)*this.rowHeight);
|
||||
|
||||
this.stopScissorFilter();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (this.isScrollActive){
|
||||
this.updateScrollBar();
|
||||
this.scrollbar.draw();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void updateScrollBar(){
|
||||
int scrollbarX = this.posX + this.getWidth() - this.scrollWidth;
|
||||
int scrollbarY = this.posY + this.rowHeight;
|
||||
int scrollbarW = this.scrollWidth;
|
||||
int scrollbarH = this.getViewportHeight();
|
||||
int maxvalue = this.getTableHeight() - this.getViewportHeight();
|
||||
|
||||
this.scrollbar.setup(this.parent, scrollbarX, scrollbarY, scrollbarW, scrollbarH, this.scrollButtonHeight, maxvalue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth(){
|
||||
if (!autosize)
|
||||
return this.width;
|
||||
|
||||
int width = 0;
|
||||
for (int i: this.columnWidth)
|
||||
width += i;
|
||||
|
||||
if (this.isScrollActive)
|
||||
width += this.scrollWidth;
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getTableHeight(){
|
||||
return this.rowHeight * this.getSize();
|
||||
}
|
||||
|
||||
public int getViewportHeight(){
|
||||
return this.getHeight() - this.rowHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(){
|
||||
return this.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeight(int height){
|
||||
this.height = height;
|
||||
this.isScrollActive = (this.getViewportHeight() < this.getTableHeight());
|
||||
}
|
||||
|
||||
public void drawTitle(int rowleft, int rowtop)
|
||||
{
|
||||
for (int j = 0; j < this.ncolumns; j++){
|
||||
this.columnnames[j].setWidth(this.columnWidth[j]);
|
||||
this.columnnames[j].draw(rowleft + this.columnPos[j], rowtop, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawRow(int index, int rowleft, int rowtop)
|
||||
{
|
||||
if (index%2 == 0)
|
||||
this.parent.drawGradientRect(rowleft, rowtop, rowleft+this.getWidth(), rowtop+this.rowHeight, 0xff333333, 0xff333333);
|
||||
else
|
||||
this.parent.drawGradientRect(rowleft, rowtop, rowleft+this.getWidth(), rowtop+this.rowHeight, 0xff000000, 0xff000000);
|
||||
|
||||
IWidget[] data = this.table.get(index);
|
||||
for (int j = 0; j < this.ncolumns; j++){
|
||||
data[j].setWidth(this.columnWidth[j]);
|
||||
data[j].draw(rowleft + this.columnPos[j], rowtop, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseWheel(int mouseX, int mouseY, int mouseZ){
|
||||
this.scrollbar.addCurrentValue((mouseZ / -120) * this.scrollbar.getStep());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class DraggableViewport extends BaseWidget {
|
||||
|
||||
//public StackDisplay widStack = null;;
|
||||
private int offsetX = 0;
|
||||
private int offsetY = 0;
|
||||
private int prevMouseX = 0;
|
||||
private int prevMouseY = 0;
|
||||
private float scale = 1.0f;
|
||||
private boolean dragging = false;
|
||||
|
||||
|
||||
public DraggableViewport(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
/*
|
||||
widStack = new StackDisplay(parent);
|
||||
widStack.setStack(new ItemStack(Item.axeDiamond));
|
||||
widStack.setPos(80, 80, 0);
|
||||
|
||||
this.addWidget("stackdisplay", this.widStack);
|
||||
*/
|
||||
}
|
||||
|
||||
public void addWidget(IWidget widget, int posX, int posY, int posZ){
|
||||
this.addWidget(String.format("widget_%s", this.widgets.size()), widget);
|
||||
widget.setPos(posX, posY, posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
this.drawBackground();
|
||||
|
||||
this.drawBackground();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(offsetX, offsetY, 0);
|
||||
GL11.glScalef(this.scale, this.scale, 1.0f);
|
||||
this.startScissorFilter(this.posX, this.posY, this.getWidth(), this.getHeight());
|
||||
|
||||
for (IWidget widget : this.getWidgets())
|
||||
widget.drawBackground();
|
||||
|
||||
for (IWidget widget : this.getWidgets())
|
||||
//widget.draw(this.scale);
|
||||
widget.draw();
|
||||
|
||||
|
||||
this.stopScissorFilter();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(int mouseX, int mouseY, int buttonID){
|
||||
if (buttonID == 0){
|
||||
this.dragging = true;
|
||||
this.prevMouseX = mouseX;
|
||||
this.prevMouseY = mouseY;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(int mouseX, int mouseY, int buttonID){
|
||||
if (buttonID == 0)
|
||||
this.dragging = false;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean mouseMoved(int mouseX, int mouseY){
|
||||
if (this.dragging){
|
||||
this.offsetX -= (this.prevMouseX - mouseX);
|
||||
this.offsetY -= (this.prevMouseY - mouseY);
|
||||
this.prevMouseX = mouseX;
|
||||
this.prevMouseY = mouseY;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseWheel(int mouseX, int mouseY, int mouseZ){
|
||||
if (mouseZ > 0)
|
||||
this.scale *= Math.abs((mouseZ / -120)*2);
|
||||
else
|
||||
this.scale /= Math.abs((mouseZ / -120)*2);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IWidget {
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
String getLabel();
|
||||
int getPosX();
|
||||
int getPosY();
|
||||
|
||||
void setWidth(int width);
|
||||
void setHeight(int height);
|
||||
void setLabel(String label);
|
||||
void setPos(int posX, int posY, int posZ);
|
||||
|
||||
boolean mouseClicked(int mouseX, int mouseY, int buttonID);
|
||||
boolean mouseReleased(int mouseX, int mouseY, int buttonID);
|
||||
boolean mouseWheel(int mouseX, int mouseY, int mouseZ);
|
||||
boolean mouseMoved(int mouseX, int mouseY);
|
||||
//boolean mouseDragged(int mouseX, int mouseY, int buttonID, long deltaTime);
|
||||
|
||||
void draw();
|
||||
void draw(int x, int y, int z);
|
||||
void draw(float scale);
|
||||
|
||||
IWidget getWidgetAtCoordinates(int posX, int posY);
|
||||
public void addWidget(String name, IWidget widget);
|
||||
public Collection<IWidget> getWidgets();
|
||||
public IWidget getWidget(String name);
|
||||
|
||||
void drawBackground();
|
||||
void setBackgroundColor(int color);
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class Label extends BaseWidget {
|
||||
|
||||
public Label(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Label(GuiScreen parent, String label){
|
||||
this.parent = parent;
|
||||
this.setLabel(label);
|
||||
}
|
||||
|
||||
public Label(String label){
|
||||
this.parent = null;
|
||||
this.setLabel(label);
|
||||
}
|
||||
|
||||
public Label(int label){
|
||||
this.parent = null;
|
||||
this.setLabel(String.valueOf(label));
|
||||
}
|
||||
|
||||
public Label(float label){
|
||||
this.parent = null;
|
||||
this.setLabel(String.valueOf(label));
|
||||
}
|
||||
|
||||
public int getCharWidth(){
|
||||
return this.fontRenderer.getCharWidth((char)32);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
this.drawBackground();
|
||||
this.renderString(this.posX, this.posY, 0, 0xffffffff);
|
||||
}
|
||||
|
||||
public String getTrimLabel(){
|
||||
int maxchars = this.width / this.getCharWidth();
|
||||
return this.label.substring(0, Math.min(this.label.length(), maxchars));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth(){
|
||||
return this.fontRenderer.getStringWidth(this.label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLabel(String label){
|
||||
this.label = label;
|
||||
this.width = this.fontRenderer.getStringWidth(this.label);
|
||||
}
|
||||
|
||||
public void renderString(int x, int y, int z, int color){
|
||||
//this.fontrender.drawString(this.getTrimLabel(), x, y, color);
|
||||
this.fontRenderer.drawString(this.getLabel(), x, y, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class StackDisplay extends BaseWidget {
|
||||
|
||||
protected static RenderItem drawItems = new RenderItem();
|
||||
protected ItemStack stack;
|
||||
protected Icon icon;
|
||||
protected float scale = 1.0F;
|
||||
protected boolean drawOverlay = false;
|
||||
|
||||
public StackDisplay(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
StackDisplay.drawItems.zLevel = 500.0f;
|
||||
};
|
||||
|
||||
public StackDisplay(GuiScreen parent, ItemStack stack){
|
||||
this.parent = parent;
|
||||
this.setStack(stack);
|
||||
};
|
||||
|
||||
public void setDrawOverlay(boolean value){
|
||||
this.drawOverlay = value;
|
||||
}
|
||||
|
||||
public void setStack(ItemStack stack){
|
||||
this.stack = stack;
|
||||
this.icon = stack.getIconIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
this.drawBackground();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(scale, scale, 1.0f);
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
drawItems.renderItemAndEffectIntoGUI(this.fontRenderer, this.renderEngine, this.stack, (int)(this.posX/scale), (int)(this.posY/scale));
|
||||
if (this.drawOverlay)
|
||||
drawItems.renderItemOverlayIntoGUI(this.fontRenderer, this.renderEngine, this.stack, (int)(this.posX/scale), (int)(this.posY/scale), String.valueOf(stack.stackSize));
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getWidth(){
|
||||
return (int)(16 * this.scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(){
|
||||
return (int)(16 * this.scale);
|
||||
}
|
||||
|
||||
public void setScale(float scale_){
|
||||
this.scale = scale_;
|
||||
}
|
||||
|
||||
public float getScale(){
|
||||
return this.scale;
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class VerticalScrollBar extends BaseWidget {
|
||||
|
||||
private int maxvalue;
|
||||
private int currvalue = 0;
|
||||
private int buttonH;
|
||||
private int buttonTop;
|
||||
private int step = 6;
|
||||
public boolean dragging = false;
|
||||
|
||||
public VerticalScrollBar(){};
|
||||
|
||||
public void setup(GuiScreen parent, int posX, int posY, int width, int height, int buttonH, int maxvalue) {
|
||||
this.parent = parent;
|
||||
this.posX = posX;
|
||||
this.posY = posY;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.maxvalue = maxvalue;
|
||||
this.buttonH = buttonH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
this.drawBackground();
|
||||
this.parent.drawGradientRect(this.posX,
|
||||
this.posY,
|
||||
this.posX + this.getWidth(),
|
||||
this.posY + this.getHeight(),
|
||||
0xff999999, 0xff999999);
|
||||
|
||||
float currentRatio = (float)(this.currvalue) / (float)(this.maxvalue);
|
||||
this.buttonTop = (int)((this.getHeight() - this.buttonH) * currentRatio) + this.posY;
|
||||
|
||||
this.parent.drawGradientRect(this.posX,
|
||||
buttonTop,
|
||||
this.posX + this.getWidth(),
|
||||
buttonTop + this.buttonH,
|
||||
0xffffffff, 0xffffffff);
|
||||
|
||||
}
|
||||
|
||||
public void setCurrentValue(int currvalue){
|
||||
this.currvalue = currvalue;
|
||||
this.currvalue = Math.max(0, this.currvalue);
|
||||
this.currvalue = Math.min(this.maxvalue, this.currvalue);
|
||||
}
|
||||
|
||||
public void addCurrentValue(int value){
|
||||
this.currvalue += value;
|
||||
this.currvalue = Math.max(0, this.currvalue);
|
||||
this.currvalue = Math.min(this.maxvalue, this.currvalue);
|
||||
}
|
||||
|
||||
public int getCurrentValue(){
|
||||
return this.currvalue;
|
||||
}
|
||||
|
||||
public int getStep(){
|
||||
return this.step;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(int mouseX, int mouseY, int buttonID){
|
||||
if(mouseY < this.buttonTop)
|
||||
this.addCurrentValue(-1 * this.step);
|
||||
else if (mouseY > this.buttonTop + this.buttonH)
|
||||
this.addCurrentValue(this.step);
|
||||
else if (buttonID == 0)
|
||||
this.dragging = true;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(int mouseX, int mouseY, int buttonID){
|
||||
if (buttonID == 0)
|
||||
this.dragging = false;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean mouseMoved(int mouseX, int mouseY){
|
||||
if (this.dragging){
|
||||
int value = (int)((float)((mouseY - this.buttonH/2) - this.posY)/(float)(this.getHeight()-this.buttonH)*this.maxvalue);
|
||||
this.setCurrentValue(value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class WikiReader extends BaseWidget {
|
||||
|
||||
private VerticalScrollBar scrollbar = new VerticalScrollBar();
|
||||
private String text = "";
|
||||
int textHeight = 0;
|
||||
int lineHeight = 8;
|
||||
int scrollWidth = 8;
|
||||
int scrollButtonHeight = 16;
|
||||
boolean isScrollActive = false;
|
||||
|
||||
|
||||
public WikiReader(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
this.addWidget("VScrollBar", this.scrollbar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
if (!this.isScrollActive)
|
||||
return this.width;
|
||||
else
|
||||
return this.width - this.scrollWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
this.drawBackground();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0, this.scrollbar.getCurrentValue() * -1.0F, 0);
|
||||
this.startScissorFilter(this.posX, this.posY, this.getWidth(), this.getViewportHeight());
|
||||
|
||||
int offset = this.posY;
|
||||
|
||||
for (String s : this.getTailoredText()){
|
||||
this.fontRenderer.drawString(s, this.posX, offset, 0xFFFFFFFF);
|
||||
offset += this.lineHeight;
|
||||
}
|
||||
|
||||
this.stopScissorFilter();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (this.isScrollActive){
|
||||
this.updateScrollBar();
|
||||
this.scrollbar.draw();
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(String text){
|
||||
this.text = text;
|
||||
this.textHeight = this.getTailoredText().size() * this.lineHeight;
|
||||
if (this.textHeight > this.getHeight()){
|
||||
this.isScrollActive = true;
|
||||
//this.setWidth(this.getWidth() - this.scrollWidth);
|
||||
this.textHeight = this.getTailoredText().size() * this.lineHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public int getTextHeight(){
|
||||
return this.getTailoredText().size() * this.lineHeight;
|
||||
}
|
||||
|
||||
public String getText(){
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public ArrayList<String> getTailoredText(){
|
||||
String[] splittedText = this.text.split("\r?\n");
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
for (String s : splittedText){
|
||||
ArrayList<Integer> whiteSpaces = this.getWhiteSpaces(s);
|
||||
int lastCutIndex = 0;
|
||||
for (int i = 0; i < whiteSpaces.size(); i++){
|
||||
String substring = s.substring(lastCutIndex, whiteSpaces.get(i));
|
||||
if (this.fontRenderer.getStringWidth(substring) > this.getWidth()){
|
||||
lines.add(s.substring(lastCutIndex, whiteSpaces.get(i-1)));
|
||||
lastCutIndex = whiteSpaces.get(i-1) + 1;
|
||||
}
|
||||
}
|
||||
lines.add(s.substring(lastCutIndex));
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
private ArrayList<Integer> getWhiteSpaces(String input){
|
||||
ArrayList<Integer> indexes = new ArrayList<Integer>();
|
||||
int index = 0;
|
||||
while (index != -1){
|
||||
index = input.indexOf(" ", index + 1);
|
||||
if (index != -1)
|
||||
indexes.add(index);
|
||||
}
|
||||
return indexes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseWheel(int mouseX, int mouseY, int mouseZ){
|
||||
this.scrollbar.addCurrentValue((mouseZ / -120) * this.scrollbar.getStep());
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getViewportHeight(){
|
||||
return this.getHeight();
|
||||
}
|
||||
|
||||
public void updateScrollBar(){
|
||||
int scrollbarX = this.posX + this.getWidth();
|
||||
int scrollbarY = this.posY;
|
||||
int scrollbarW = this.scrollWidth;
|
||||
int scrollbarH = this.getViewportHeight();
|
||||
int maxvalue = this.getTextHeight() - this.getViewportHeight();
|
||||
|
||||
this.scrollbar.setup(this.parent, scrollbarX, scrollbarY, scrollbarW, scrollbarH, this.scrollButtonHeight, maxvalue);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package mcp.mobius.waila.handlers;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.BLUE;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.RENDER;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package mcp.mobius.waila.handlers;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.BLUE;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
import static mcp.mobius.waila.api.SpecialChars.getRenderString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternIcon;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternMinecraft;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternRender;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternWaila;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WailaIcon;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WailaStyle;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNCENTER;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternIcon;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternLineSplit;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternRender;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternTab;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
Reference in new issue
Block a user