mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-20 20:22:35 +00:00
Update buildscript & spotlessApply
This commit is contained in:
1 parent
e4329e2b8f
commit
8683a345c3
818 files changed
+51123
-49403
No files matched your search
@@ -11,133 +11,132 @@ import binnie.core.proxy.IProxyCore;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public abstract class AbstractMod implements IPacketProvider, IInitializable {
|
||||
private SimpleNetworkWrapper wrapper;
|
||||
private final LinkedHashSet<Field> fields;
|
||||
protected final List<IInitializable> modules;
|
||||
private SimpleNetworkWrapper wrapper;
|
||||
private final LinkedHashSet<Field> fields;
|
||||
protected final List<IInitializable> modules;
|
||||
|
||||
public AbstractMod() {
|
||||
fields = new LinkedHashSet<>();
|
||||
modules = new ArrayList<>();
|
||||
BinnieCore.registerMod(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
public AbstractMod() {
|
||||
fields = new LinkedHashSet<>();
|
||||
modules = new ArrayList<>();
|
||||
BinnieCore.registerMod(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
public abstract boolean isActive();
|
||||
public abstract boolean isActive();
|
||||
|
||||
@Override
|
||||
public abstract String getChannel();
|
||||
@Override
|
||||
public abstract String getChannel();
|
||||
|
||||
@Override
|
||||
public IPacketID[] getPacketIDs() {
|
||||
return new IPacketID[0];
|
||||
}
|
||||
@Override
|
||||
public IPacketID[] getPacketIDs() {
|
||||
return new IPacketID[0];
|
||||
}
|
||||
|
||||
public IBinnieGUID[] getGUIDs() {
|
||||
return new IBinnieGUID[0];
|
||||
}
|
||||
public IBinnieGUID[] getGUIDs() {
|
||||
return new IBinnieGUID[0];
|
||||
}
|
||||
|
||||
public Class[] getConfigs() {
|
||||
return new Class[0];
|
||||
}
|
||||
public Class[] getConfigs() {
|
||||
return new Class[0];
|
||||
}
|
||||
|
||||
public abstract IProxyCore getProxy();
|
||||
public abstract IProxyCore getProxy();
|
||||
|
||||
public abstract String getModID();
|
||||
public abstract String getModID();
|
||||
|
||||
public SimpleNetworkWrapper getNetworkWrapper() {
|
||||
return wrapper;
|
||||
}
|
||||
public SimpleNetworkWrapper getNetworkWrapper() {
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
protected abstract Class<? extends BinniePacketHandler> getPacketHandler();
|
||||
protected abstract Class<? extends BinniePacketHandler> getPacketHandler();
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
if (!isActive()) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void preInit() {
|
||||
if (!isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getConfigs() != null) {
|
||||
for (Class cls : getConfigs()) {
|
||||
Binnie.Configuration.registerConfiguration(cls, this);
|
||||
}
|
||||
}
|
||||
if (getConfigs() != null) {
|
||||
for (Class cls : getConfigs()) {
|
||||
Binnie.Configuration.registerConfiguration(cls, this);
|
||||
}
|
||||
}
|
||||
|
||||
getProxy().preInit();
|
||||
for (IInitializable module : modules) {
|
||||
module.preInit();
|
||||
}
|
||||
|
||||
// TODO what does it mean?
|
||||
Collections.addAll(fields, getClass().getFields());
|
||||
for (Class cls : getClass().getClasses()) {
|
||||
Collections.addAll(fields, getClass().getFields());
|
||||
}
|
||||
for (IInitializable module : modules) {
|
||||
Collections.addAll(fields, module.getClass().getFields());
|
||||
}
|
||||
for (Field field4 : fields) {
|
||||
try {
|
||||
FieldParser.preInitParse(field4, this);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
getProxy().preInit();
|
||||
for (IInitializable module : modules) {
|
||||
module.preInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
if (!isActive()) {
|
||||
return;
|
||||
}
|
||||
getProxy().init();
|
||||
// TODO what does it mean?
|
||||
Collections.addAll(fields, getClass().getFields());
|
||||
for (Class cls : getClass().getClasses()) {
|
||||
Collections.addAll(fields, getClass().getFields());
|
||||
}
|
||||
for (IInitializable module : modules) {
|
||||
Collections.addAll(fields, module.getClass().getFields());
|
||||
}
|
||||
for (Field field4 : fields) {
|
||||
try {
|
||||
FieldParser.preInitParse(field4, this);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wrapper = NetworkRegistry.INSTANCE.newSimpleChannel(getChannel());
|
||||
wrapper.registerMessage(getPacketHandler(), MessageBinnie.class, 1, Side.CLIENT);
|
||||
wrapper.registerMessage(getPacketHandler(), MessageBinnie.class, 1, Side.SERVER);
|
||||
for (IInitializable module : modules) {
|
||||
module.init();
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
if (!isActive()) {
|
||||
return;
|
||||
}
|
||||
getProxy().init();
|
||||
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
FieldParser.initParse(field, this);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
wrapper = NetworkRegistry.INSTANCE.newSimpleChannel(getChannel());
|
||||
wrapper.registerMessage(getPacketHandler(), MessageBinnie.class, 1, Side.CLIENT);
|
||||
wrapper.registerMessage(getPacketHandler(), MessageBinnie.class, 1, Side.SERVER);
|
||||
for (IInitializable module : modules) {
|
||||
module.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
if (!isActive()) {
|
||||
return;
|
||||
}
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
FieldParser.initParse(field, this);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getProxy().postInit();
|
||||
for (IInitializable module : modules) {
|
||||
module.postInit();
|
||||
}
|
||||
@Override
|
||||
public void postInit() {
|
||||
if (!isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
FieldParser.postInitParse(field, this);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
getProxy().postInit();
|
||||
for (IInitializable module : modules) {
|
||||
module.postInit();
|
||||
}
|
||||
|
||||
protected void addModule(IInitializable init) {
|
||||
modules.add(init);
|
||||
MinecraftForge.EVENT_BUS.register(init);
|
||||
}
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
FieldParser.postInitParse(field, this);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void addModule(IInitializable init) {
|
||||
modules.add(init);
|
||||
MinecraftForge.EVENT_BUS.register(init);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package binnie.core;
|
||||
|
||||
import static binnie.core.BinnieCore.*;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.block.MultipassBlockRenderer;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
@@ -38,194 +40,199 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.core.ForestryEvent;
|
||||
import forestry.plugins.PluginManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static binnie.core.BinnieCore.*;
|
||||
|
||||
@Mod(modid = "BinnieCore", name = "Binnie Core", version = VERSION, useMetadata = true, dependencies = "after:Forestry@[4.2,)")
|
||||
@Mod(
|
||||
modid = "BinnieCore",
|
||||
name = "Binnie Core",
|
||||
version = VERSION,
|
||||
useMetadata = true,
|
||||
dependencies = "after:Forestry@[4.2,)")
|
||||
public class BinnieCore extends AbstractMod {
|
||||
@Mod.Instance("BinnieCore")
|
||||
public static BinnieCore instance;
|
||||
@SidedProxy(clientSide = "binnie.core.proxy.BinnieProxyClient", serverSide = "binnie.core.proxy.BinnieProxyServer")
|
||||
public static BinnieProxy proxy;
|
||||
public static int multipassRenderID;
|
||||
private static List<AbstractMod> modList = new ArrayList<>();
|
||||
public static MachineGroup packageCompartment;
|
||||
public static ItemGenesis genesis;
|
||||
public static ItemFieldKit fieldKit;
|
||||
public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||
@Mod.Instance("BinnieCore")
|
||||
public static BinnieCore instance;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent evt) {
|
||||
Binnie.Configuration.registerConfiguration(ConfigurationMods.class, this);
|
||||
for (ManagerBase baseManager : Binnie.Managers) {
|
||||
addModule(baseManager);
|
||||
}
|
||||
@SidedProxy(clientSide = "binnie.core.proxy.BinnieProxyClient", serverSide = "binnie.core.proxy.BinnieProxyServer")
|
||||
public static BinnieProxy proxy;
|
||||
|
||||
addModule(new ModuleCraftGUI());
|
||||
addModule(new ModuleStorage());
|
||||
addModule(new ModuleItems());
|
||||
if (Loader.isModLoaded("BuildCraft|Silicon")) {
|
||||
addModule(new ModuleTrigger());
|
||||
}
|
||||
preInit();
|
||||
}
|
||||
public static int multipassRenderID;
|
||||
private static List<AbstractMod> modList = new ArrayList<>();
|
||||
public static MachineGroup packageCompartment;
|
||||
public static ItemGenesis genesis;
|
||||
public static ItemFieldKit fieldKit;
|
||||
public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent evt) {
|
||||
init();
|
||||
}
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent evt) {
|
||||
Binnie.Configuration.registerConfiguration(ConfigurationMods.class, this);
|
||||
for (ManagerBase baseManager : Binnie.Managers) {
|
||||
addModule(baseManager);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent evt) {
|
||||
postInit();
|
||||
}
|
||||
addModule(new ModuleCraftGUI());
|
||||
addModule(new ModuleStorage());
|
||||
addModule(new ModuleItems());
|
||||
if (Loader.isModLoaded("BuildCraft|Silicon")) {
|
||||
addModule(new ModuleTrigger());
|
||||
}
|
||||
preInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinnieGUID[] getGUIDs() {
|
||||
return BinnieCoreGUI.values();
|
||||
}
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent evt) {
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
instance = this;
|
||||
for (FluidContainer container : FluidContainer.values()) {
|
||||
Item item = new ItemFluidContainer(container);
|
||||
GameRegistry.registerItem(item, item.getUnlocalizedName().substring(5));
|
||||
}
|
||||
FieldParser.parsers.add(new ItemParser());
|
||||
super.preInit();
|
||||
}
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent evt) {
|
||||
postInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
for (AbstractMod mod : getActiveMods()) {
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(mod, new BinnieGUIHandler(mod));
|
||||
}
|
||||
@Override
|
||||
public IBinnieGUID[] getGUIDs() {
|
||||
return BinnieCoreGUI.values();
|
||||
}
|
||||
|
||||
multipassRenderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(new MultipassBlockRenderer());
|
||||
GameRegistry.registerTileEntity(TileEntityMetadata.class, "binnie.tile.metadata");
|
||||
}
|
||||
@Override
|
||||
public void preInit() {
|
||||
instance = this;
|
||||
for (FluidContainer container : FluidContainer.values()) {
|
||||
Item item = new ItemFluidContainer(container);
|
||||
GameRegistry.registerItem(item, item.getUnlocalizedName().substring(5));
|
||||
}
|
||||
FieldParser.parsers.add(new ItemParser());
|
||||
super.preInit();
|
||||
}
|
||||
|
||||
public static boolean isLepidopteryActive() {
|
||||
return PluginManager.Module.LEPIDOPTEROLOGY.isEnabled();
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
for (AbstractMod mod : getActiveMods()) {
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(mod, new BinnieGUIHandler(mod));
|
||||
}
|
||||
|
||||
public static boolean isApicultureActive() {
|
||||
return PluginManager.Module.APICULTURE.isEnabled();
|
||||
}
|
||||
multipassRenderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(new MultipassBlockRenderer());
|
||||
GameRegistry.registerTileEntity(TileEntityMetadata.class, "binnie.tile.metadata");
|
||||
}
|
||||
|
||||
public static boolean isArboricultureActive() {
|
||||
return PluginManager.Module.ARBORICULTURE.isEnabled();
|
||||
}
|
||||
public static boolean isLepidopteryActive() {
|
||||
return PluginManager.Module.LEPIDOPTEROLOGY.isEnabled();
|
||||
}
|
||||
|
||||
public static boolean isBotanyActive() {
|
||||
return ConfigurationMods.botany;
|
||||
}
|
||||
public static boolean isApicultureActive() {
|
||||
return PluginManager.Module.APICULTURE.isEnabled();
|
||||
}
|
||||
|
||||
public static boolean isGeneticsActive() {
|
||||
return ConfigurationMods.genetics;
|
||||
}
|
||||
public static boolean isArboricultureActive() {
|
||||
return PluginManager.Module.ARBORICULTURE.isEnabled();
|
||||
}
|
||||
|
||||
public static boolean isExtraBeesActive() {
|
||||
return ConfigurationMods.extraBees && isApicultureActive();
|
||||
}
|
||||
public static boolean isBotanyActive() {
|
||||
return ConfigurationMods.botany;
|
||||
}
|
||||
|
||||
public static boolean isExtraTreesActive() {
|
||||
return ConfigurationMods.extraTrees && isArboricultureActive();
|
||||
}
|
||||
public static boolean isGeneticsActive() {
|
||||
return ConfigurationMods.genetics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
super.postInit();
|
||||
}
|
||||
public static boolean isExtraBeesActive() {
|
||||
return ConfigurationMods.extraBees && isApicultureActive();
|
||||
}
|
||||
|
||||
static void registerMod(AbstractMod mod) {
|
||||
modList.add(mod);
|
||||
}
|
||||
public static boolean isExtraTreesActive() {
|
||||
return ConfigurationMods.extraTrees && isArboricultureActive();
|
||||
}
|
||||
|
||||
private static List<AbstractMod> getActiveMods() {
|
||||
List<AbstractMod> list = new ArrayList<>();
|
||||
for (AbstractMod mod : modList) {
|
||||
if (mod.isActive()) {
|
||||
list.add(mod);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@Override
|
||||
public void postInit() {
|
||||
super.postInit();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleSpeciesDiscovered(ForestryEvent.SpeciesDiscovered event) {
|
||||
try {
|
||||
EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(event.username.getName());
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
event.tracker.synchToPlayer(player);
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setString("species", event.species.getUID());
|
||||
} catch (Exception ex) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
static void registerMod(AbstractMod mod) {
|
||||
modList.add(mod);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannel() {
|
||||
return "BIN";
|
||||
}
|
||||
private static List<AbstractMod> getActiveMods() {
|
||||
List<AbstractMod> list = new ArrayList<>();
|
||||
for (AbstractMod mod : modList) {
|
||||
if (mod.isActive()) {
|
||||
list.add(mod);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinnieProxy getProxy() {
|
||||
return proxy;
|
||||
}
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleSpeciesDiscovered(ForestryEvent.SpeciesDiscovered event) {
|
||||
try {
|
||||
EntityPlayerMP player =
|
||||
MinecraftServer.getServer().getConfigurationManager().func_152612_a(event.username.getName());
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
event.tracker.synchToPlayer(player);
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setString("species", event.species.getUID());
|
||||
} catch (Exception ex) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "binniecore";
|
||||
}
|
||||
@Override
|
||||
public String getChannel() {
|
||||
return "BIN";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacketID[] getPacketIDs() {
|
||||
return BinnieCorePacketID.values();
|
||||
}
|
||||
@Override
|
||||
public IBinnieProxy getProxy() {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleTextureRemap(TextureStitchEvent.Pre event) {
|
||||
if (event.map.getTextureType() == 0) {
|
||||
Binnie.Liquid.reloadIcons(event.map);
|
||||
}
|
||||
Binnie.Resource.registerIcons(event.map, event.map.getTextureType());
|
||||
}
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "binniecore";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?>[] getConfigs() {
|
||||
return new Class[]{ConfigurationMain.class};
|
||||
}
|
||||
@Override
|
||||
public IPacketID[] getPacketIDs() {
|
||||
return BinnieCorePacketID.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BinniePacketHandler> getPacketHandler() {
|
||||
return PacketHandler.class;
|
||||
}
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleTextureRemap(TextureStitchEvent.Pre event) {
|
||||
if (event.map.getTextureType() == 0) {
|
||||
Binnie.Liquid.reloadIcons(event.map);
|
||||
}
|
||||
Binnie.Resource.registerIcons(event.map, event.map.getTextureType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public Class<?>[] getConfigs() {
|
||||
return new Class[] {ConfigurationMain.class};
|
||||
}
|
||||
|
||||
public static class PacketHandler extends BinniePacketHandler {
|
||||
public PacketHandler() {
|
||||
super(instance);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected Class<? extends BinniePacketHandler> getPacketHandler() {
|
||||
return PacketHandler.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class PacketHandler extends BinniePacketHandler {
|
||||
public PacketHandler() {
|
||||
super(instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package binnie.core;
|
||||
|
||||
public interface IInitializable {
|
||||
void preInit();
|
||||
void preInit();
|
||||
|
||||
void init();
|
||||
void init();
|
||||
|
||||
void postInit();
|
||||
void postInit();
|
||||
}
|
||||
@@ -3,22 +3,22 @@ package binnie.core;
|
||||
import binnie.Binnie;
|
||||
|
||||
public abstract class ManagerBase implements IInitializable {
|
||||
public ManagerBase() {
|
||||
Binnie.Managers.add(this);
|
||||
}
|
||||
public ManagerBase() {
|
||||
Binnie.Managers.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void preInit() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void postInit() {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
@@ -7,69 +7,69 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class Mods {
|
||||
public static Mod forestry;
|
||||
public static Mod ic2;
|
||||
public static Mod botania;
|
||||
public static Mod forestry;
|
||||
public static Mod ic2;
|
||||
public static Mod botania;
|
||||
|
||||
private static Item findItem(String modId, String name) {
|
||||
Item stack = GameRegistry.findItem(modId, name);
|
||||
if (stack == null && modId.equals("Forestry")) {
|
||||
throw new RuntimeException("Item not found: " + modId + ":" + name);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
private static Item findItem(String modId, String name) {
|
||||
Item stack = GameRegistry.findItem(modId, name);
|
||||
if (stack == null && modId.equals("Forestry")) {
|
||||
throw new RuntimeException("Item not found: " + modId + ":" + name);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static ItemStack findItemStack(String modId, String name, int stackSize) {
|
||||
ItemStack stack = GameRegistry.findItemStack(modId, name, stackSize);
|
||||
if (stack == null && modId.equals("Forestry")) {
|
||||
throw new RuntimeException("Stack not found: " + modId + ":" + name);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
private static ItemStack findItemStack(String modId, String name, int stackSize) {
|
||||
ItemStack stack = GameRegistry.findItemStack(modId, name, stackSize);
|
||||
if (stack == null && modId.equals("Forestry")) {
|
||||
throw new RuntimeException("Stack not found: " + modId + ":" + name);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static Block findBlock(String modId, String name) {
|
||||
Block stack = GameRegistry.findBlock(modId, name);
|
||||
if (stack == null && modId.equals("Forestry")) {
|
||||
throw new RuntimeException("Block not found: " + modId + ":" + name);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
private static Block findBlock(String modId, String name) {
|
||||
Block stack = GameRegistry.findBlock(modId, name);
|
||||
if (stack == null && modId.equals("Forestry")) {
|
||||
throw new RuntimeException("Block not found: " + modId + ":" + name);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
static {
|
||||
Mods.forestry = new Mod("Forestry");
|
||||
Mods.ic2 = new Mod("IC2");
|
||||
Mods.botania = new Mod("Botania");
|
||||
}
|
||||
static {
|
||||
Mods.forestry = new Mod("Forestry");
|
||||
Mods.ic2 = new Mod("IC2");
|
||||
Mods.botania = new Mod("Botania");
|
||||
}
|
||||
|
||||
public static class Mod {
|
||||
private String id;
|
||||
public static class Mod {
|
||||
private String id;
|
||||
|
||||
private Mod(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
private Mod(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Item item(String name) {
|
||||
return findItem(id, name);
|
||||
}
|
||||
public Item item(String name) {
|
||||
return findItem(id, name);
|
||||
}
|
||||
|
||||
public Block block(String name) {
|
||||
return findBlock(id, name);
|
||||
}
|
||||
public Block block(String name) {
|
||||
return findBlock(id, name);
|
||||
}
|
||||
|
||||
public ItemStack stack(String name, int stackSize) {
|
||||
return findItemStack(id, name, stackSize);
|
||||
}
|
||||
public ItemStack stack(String name, int stackSize) {
|
||||
return findItemStack(id, name, stackSize);
|
||||
}
|
||||
|
||||
public ItemStack stack(String name) {
|
||||
return stack(name, 1);
|
||||
}
|
||||
public ItemStack stack(String name) {
|
||||
return stack(name, 1);
|
||||
}
|
||||
|
||||
public ItemStack stack(String string, int i, int j) {
|
||||
return new ItemStack(item(string), i, j);
|
||||
}
|
||||
public ItemStack stack(String string, int i, int j) {
|
||||
return new ItemStack(item(string), i, j);
|
||||
}
|
||||
|
||||
public boolean active() {
|
||||
return Loader.isModLoaded(id);
|
||||
}
|
||||
}
|
||||
public boolean active() {
|
||||
return Loader.isModLoaded(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package binnie.core.block;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -13,114 +15,115 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockMetadata extends BlockContainer implements IBlockMetadata {
|
||||
public BlockMetadata(Material material) {
|
||||
super(material);
|
||||
}
|
||||
public BlockMetadata(Material material) {
|
||||
super(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) {
|
||||
return getBlockDropped(this, world, x, y, z, blockMeta);
|
||||
}
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) {
|
||||
return getBlockDropped(this, world, x, y, z, blockMeta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
|
||||
return breakBlock(this, player, world, x, y, z);
|
||||
}
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
|
||||
return breakBlock(this, player, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int i) {
|
||||
return new TileEntityMetadata();
|
||||
}
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int i) {
|
||||
return new TileEntityMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(int meta) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean hasTileEntity(int meta) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockEventReceived(World world, int x, int y, int z, int par5, int par6) {
|
||||
super.onBlockEventReceived(world, x, y, z, par5, par6);
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
return tileentity != null && tileentity.receiveClientEvent(par5, par6);
|
||||
}
|
||||
@Override
|
||||
public boolean onBlockEventReceived(World world, int x, int y, int z, int par5, int par6) {
|
||||
super.onBlockEventReceived(world, x, y, z, par5, par6);
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
return tileentity != null && tileentity.receiveClientEvent(par5, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess block, int x, int y, int z, int par5) {
|
||||
int metadata = TileEntityMetadata.getTileMetadata(block, x, y, z);
|
||||
return getIcon(par5, metadata);
|
||||
}
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess block, int x, int y, int z, int par5) {
|
||||
int metadata = TileEntityMetadata.getTileMetadata(block, x, y, z);
|
||||
return getIcon(par5, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockName(ItemStack itemStack) {
|
||||
return getLocalizedName();
|
||||
}
|
||||
@Override
|
||||
public String getBlockName(ItemStack itemStack) {
|
||||
return getLocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlockTooltip(ItemStack itemStack, List tooltip) {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void addBlockTooltip(ItemStack itemStack, List tooltip) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) {
|
||||
return TileEntityMetadata.getItemDamage(itemStack);
|
||||
}
|
||||
@Override
|
||||
public int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) {
|
||||
return TileEntityMetadata.getItemDamage(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDroppedMeta(int blockMeta, int tileMeta) {
|
||||
return blockMeta;
|
||||
}
|
||||
@Override
|
||||
public int getDroppedMeta(int blockMeta, int tileMeta) {
|
||||
return blockMeta;
|
||||
}
|
||||
|
||||
public static ArrayList<ItemStack> getBlockDropped(IBlockMetadata block, World world, int x, int y, int z, int blockMeta) {
|
||||
ArrayList<ItemStack> array = new ArrayList<>();
|
||||
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
|
||||
if (tile != null && !tile.hasDroppedBlock()) {
|
||||
int meta = block.getDroppedMeta(world.getBlockMetadata(x, y, z), tile.getTileMetadata());
|
||||
array.add(TileEntityMetadata.getItemStack((Block) block, meta));
|
||||
}
|
||||
return array;
|
||||
}
|
||||
public static ArrayList<ItemStack> getBlockDropped(
|
||||
IBlockMetadata block, World world, int x, int y, int z, int blockMeta) {
|
||||
ArrayList<ItemStack> array = new ArrayList<>();
|
||||
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
|
||||
if (tile != null && !tile.hasDroppedBlock()) {
|
||||
int meta = block.getDroppedMeta(world.getBlockMetadata(x, y, z), tile.getTileMetadata());
|
||||
array.add(TileEntityMetadata.getItemStack((Block) block, meta));
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public static boolean breakBlock(IBlockMetadata block, EntityPlayer player, World world, int i, int j, int k) {
|
||||
List<ItemStack> drops = new ArrayList<>();
|
||||
Block block2 = (Block) block;
|
||||
TileEntityMetadata tile = TileEntityMetadata.getTile(world, i, j, k);
|
||||
if (tile != null && !tile.hasDroppedBlock()) {
|
||||
drops = block2.getDrops(world, i, j, k, world.getBlockMetadata(i, j, k), 0);
|
||||
}
|
||||
public static boolean breakBlock(IBlockMetadata block, EntityPlayer player, World world, int i, int j, int k) {
|
||||
List<ItemStack> drops = new ArrayList<>();
|
||||
Block block2 = (Block) block;
|
||||
TileEntityMetadata tile = TileEntityMetadata.getTile(world, i, j, k);
|
||||
if (tile != null && !tile.hasDroppedBlock()) {
|
||||
drops = block2.getDrops(world, i, j, k, world.getBlockMetadata(i, j, k), 0);
|
||||
}
|
||||
|
||||
boolean hasBeenBroken = world.setBlockToAir(i, j, k);
|
||||
if (hasBeenBroken && BinnieCore.proxy.isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
|
||||
for (ItemStack drop : drops) {
|
||||
block.dropAsStack(world, i, j, k, drop);
|
||||
}
|
||||
tile.dropBlock();
|
||||
}
|
||||
return hasBeenBroken;
|
||||
}
|
||||
boolean hasBeenBroken = world.setBlockToAir(i, j, k);
|
||||
if (hasBeenBroken
|
||||
&& BinnieCore.proxy.isSimulating(world)
|
||||
&& drops.size() > 0
|
||||
&& (player == null || !player.capabilities.isCreativeMode)) {
|
||||
for (ItemStack drop : drops) {
|
||||
block.dropAsStack(world, i, j, k, drop);
|
||||
}
|
||||
tile.dropBlock();
|
||||
}
|
||||
return hasBeenBroken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropAsStack(World world, int x, int y, int z, ItemStack itemStack) {
|
||||
dropBlockAsItem(world, x, y, z, itemStack);
|
||||
}
|
||||
@Override
|
||||
public void dropAsStack(World world, int x, int y, int z, ItemStack itemStack) {
|
||||
dropBlockAsItem(world, x, y, z, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
public static ItemStack getPickBlock(World world, int x, int y, int z) {
|
||||
IBlockMetadata block = (IBlockMetadata) world.getBlock(x, y, z);
|
||||
List<ItemStack> list = getBlockDropped(block, world, x, y, z, world.getBlockMetadata(x, y, z));
|
||||
return list.isEmpty() ? null : list.get(0);
|
||||
}
|
||||
public static ItemStack getPickBlock(World world, int x, int y, int z) {
|
||||
IBlockMetadata block = (IBlockMetadata) world.getBlock(x, y, z);
|
||||
List<ItemStack> list = getBlockDropped(block, world, x, y, z, world.getBlockMetadata(x, y, z));
|
||||
return list.isEmpty() ? null : list.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
|
||||
return getPickBlock(world, x, y, z);
|
||||
}
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
|
||||
return getPickBlock(world, x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,19 @@
|
||||
package binnie.core.block;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IBlockMetadata extends ITileEntityProvider {
|
||||
int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction);
|
||||
int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction);
|
||||
|
||||
int getDroppedMeta(int blockMeta, int tileMeta);
|
||||
int getDroppedMeta(int blockMeta, int tileMeta);
|
||||
|
||||
String getBlockName(ItemStack itemStack);
|
||||
String getBlockName(ItemStack itemStack);
|
||||
|
||||
void addBlockTooltip(ItemStack itemStack, List tooltip);
|
||||
void addBlockTooltip(ItemStack itemStack, List tooltip);
|
||||
|
||||
void dropAsStack(World world, int x, int y, int z, ItemStack itemStack);
|
||||
void dropAsStack(World world, int x, int y, int z, ItemStack itemStack);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package binnie.core.block;
|
||||
|
||||
public interface IMultipassBlock {
|
||||
int getNumberOfPasses();
|
||||
int getNumberOfPasses();
|
||||
|
||||
int colorMultiplier(int meta);
|
||||
int colorMultiplier(int meta);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package binnie.core.block;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
@@ -10,55 +11,64 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemMetadata extends ItemBlock {
|
||||
public ItemMetadata(Block block) {
|
||||
super(block);
|
||||
}
|
||||
public ItemMetadata(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getMetadata(int damage) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
|
||||
Block block = field_150939_a;
|
||||
if (!(block instanceof IBlockMetadata)) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean placeBlockAt(
|
||||
ItemStack stack,
|
||||
EntityPlayer player,
|
||||
World world,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ,
|
||||
int metadata) {
|
||||
Block block = field_150939_a;
|
||||
if (!(block instanceof IBlockMetadata)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int placedMeta = ((IBlockMetadata) block).getPlacedMeta(stack, world, x, y, z, ForgeDirection.values()[side]);
|
||||
if (placedMeta < 0 || !world.setBlock(x, y, z, block, metadata, 3)) {
|
||||
return false;
|
||||
}
|
||||
int placedMeta = ((IBlockMetadata) block).getPlacedMeta(stack, world, x, y, z, ForgeDirection.values()[side]);
|
||||
if (placedMeta < 0 || !world.setBlock(x, y, z, block, metadata, 3)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlock(x, y, z) == block) {
|
||||
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
|
||||
if (tile != null) {
|
||||
tile.setTileMetadata(placedMeta, false);
|
||||
}
|
||||
block.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
block.onPostBlockPlaced(world, x, y, z, metadata);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (world.getBlock(x, y, z) == block) {
|
||||
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
|
||||
if (tile != null) {
|
||||
tile.setTileMetadata(placedMeta, false);
|
||||
}
|
||||
block.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
block.onPostBlockPlaced(world, x, y, z, metadata);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getItemStackDisplayName(ItemStack par1ItemStack) {
|
||||
return ((IBlockMetadata) field_150939_a).getBlockName(par1ItemStack);
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getItemStackDisplayName(ItemStack par1ItemStack) {
|
||||
return ((IBlockMetadata) field_150939_a).getBlockName(par1ItemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List tooltip, boolean advanced) {
|
||||
((IBlockMetadata) field_150939_a).addBlockTooltip(itemStack, tooltip);
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List tooltip, boolean advanced) {
|
||||
((IBlockMetadata) field_150939_a).addBlockTooltip(itemStack, tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int damage) {
|
||||
return field_150939_a.getIcon(1, damage);
|
||||
}
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int damage) {
|
||||
return field_150939_a.getIcon(1, damage);
|
||||
}
|
||||
}
|
||||
@@ -8,43 +8,45 @@ import net.minecraftforge.client.IItemRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ItemMetadataRenderer implements IItemRenderer {
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) {
|
||||
return type == IItemRenderer.ItemRenderType.INVENTORY
|
||||
|| type == IItemRenderer.ItemRenderType.ENTITY
|
||||
|| type == IItemRenderer.ItemRenderType.EQUIPPED
|
||||
|| type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON;
|
||||
}
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) {
|
||||
return type == IItemRenderer.ItemRenderType.INVENTORY
|
||||
|| type == IItemRenderer.ItemRenderType.ENTITY
|
||||
|| type == IItemRenderer.ItemRenderType.EQUIPPED
|
||||
|| type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) {
|
||||
if (type == IItemRenderer.ItemRenderType.INVENTORY) {
|
||||
return helper == IItemRenderer.ItemRendererHelper.INVENTORY_BLOCK;
|
||||
}
|
||||
if (type == IItemRenderer.ItemRenderType.ENTITY) {
|
||||
return helper == IItemRenderer.ItemRendererHelper.ENTITY_BOBBING
|
||||
|| helper == IItemRenderer.ItemRendererHelper.ENTITY_ROTATION;
|
||||
}
|
||||
return (type == IItemRenderer.ItemRenderType.EQUIPPED || type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON)
|
||||
&& helper == IItemRenderer.ItemRendererHelper.EQUIPPED_BLOCK;
|
||||
}
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(
|
||||
IItemRenderer.ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) {
|
||||
if (type == IItemRenderer.ItemRenderType.INVENTORY) {
|
||||
return helper == IItemRenderer.ItemRendererHelper.INVENTORY_BLOCK;
|
||||
}
|
||||
if (type == IItemRenderer.ItemRenderType.ENTITY) {
|
||||
return helper == IItemRenderer.ItemRendererHelper.ENTITY_BOBBING
|
||||
|| helper == IItemRenderer.ItemRendererHelper.ENTITY_ROTATION;
|
||||
}
|
||||
return (type == IItemRenderer.ItemRenderType.EQUIPPED
|
||||
|| type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON)
|
||||
&& helper == IItemRenderer.ItemRendererHelper.EQUIPPED_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
|
||||
GL11.glPushMatrix();
|
||||
Block block = Block.getBlockFromItem(item.getItem());
|
||||
if (type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
GL11.glTranslated(0.5, 0.5, 0.5);
|
||||
}
|
||||
@Override
|
||||
public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
|
||||
GL11.glPushMatrix();
|
||||
Block block = Block.getBlockFromItem(item.getItem());
|
||||
if (type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
GL11.glTranslated(0.5, 0.5, 0.5);
|
||||
}
|
||||
|
||||
if (type == IItemRenderer.ItemRenderType.INVENTORY && block.getRenderBlockPass() != 0) {
|
||||
GL11.glAlphaFunc(516, 0.1f);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
}
|
||||
GL11.glPushMatrix();
|
||||
((RenderBlocks) data[0]).renderBlockAsItem(block, TileEntityMetadata.getItemDamage(item), 1.0f);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
if (type == IItemRenderer.ItemRenderType.INVENTORY && block.getRenderBlockPass() != 0) {
|
||||
GL11.glAlphaFunc(516, 0.1f);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
}
|
||||
GL11.glPushMatrix();
|
||||
((RenderBlocks) data[0]).renderBlockAsItem(block, TileEntityMetadata.getItemDamage(item), 1.0f);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -9,91 +9,92 @@ import net.minecraft.world.IBlockAccess;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class MultipassBlockRenderer implements ISimpleBlockRenderingHandler {
|
||||
public static MultipassBlockRenderer instance;
|
||||
private static int layer = 0;
|
||||
public static MultipassBlockRenderer instance;
|
||||
private static int layer = 0;
|
||||
|
||||
public MultipassBlockRenderer() {
|
||||
MultipassBlockRenderer.instance = this;
|
||||
}
|
||||
public MultipassBlockRenderer() {
|
||||
MultipassBlockRenderer.instance = this;
|
||||
}
|
||||
|
||||
public static int getLayer() {
|
||||
return MultipassBlockRenderer.layer;
|
||||
}
|
||||
public static int getLayer() {
|
||||
return MultipassBlockRenderer.layer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
|
||||
block.setBlockBoundsForItemRender();
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
GL11.glTranslatef(-0.5f, -0.5f, -0.5f);
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
|
||||
block.setBlockBoundsForItemRender();
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
GL11.glTranslatef(-0.5f, -0.5f, -0.5f);
|
||||
|
||||
MultipassBlockRenderer.layer = 0;
|
||||
while (MultipassBlockRenderer.layer < ((IMultipassBlock) block).getNumberOfPasses()) {
|
||||
renderItem(block, renderer, meta);
|
||||
MultipassBlockRenderer.layer++;
|
||||
}
|
||||
MultipassBlockRenderer.layer = 0;
|
||||
}
|
||||
MultipassBlockRenderer.layer = 0;
|
||||
while (MultipassBlockRenderer.layer < ((IMultipassBlock) block).getNumberOfPasses()) {
|
||||
renderItem(block, renderer, meta);
|
||||
MultipassBlockRenderer.layer++;
|
||||
}
|
||||
MultipassBlockRenderer.layer = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
boolean r = true;
|
||||
MultipassBlockRenderer.layer = 0;
|
||||
while (MultipassBlockRenderer.layer < ((IMultipassBlock) block).getNumberOfPasses()) {
|
||||
r = renderer.renderStandardBlock(block, x, y, z);
|
||||
MultipassBlockRenderer.layer++;
|
||||
}
|
||||
MultipassBlockRenderer.layer = 0;
|
||||
return r;
|
||||
}
|
||||
@Override
|
||||
public boolean renderWorldBlock(
|
||||
IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
boolean r = true;
|
||||
MultipassBlockRenderer.layer = 0;
|
||||
while (MultipassBlockRenderer.layer < ((IMultipassBlock) block).getNumberOfPasses()) {
|
||||
r = renderer.renderStandardBlock(block, x, y, z);
|
||||
MultipassBlockRenderer.layer++;
|
||||
}
|
||||
MultipassBlockRenderer.layer = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int i) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return BinnieCore.multipassRenderID;
|
||||
}
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return BinnieCore.multipassRenderID;
|
||||
}
|
||||
|
||||
public void renderItem(Block block, RenderBlocks renderer, int meta) {
|
||||
setColor(((IMultipassBlock) block).colorMultiplier(meta));
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0f, -1.0f, 0.0f);
|
||||
renderer.renderFaceYNeg(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 0, meta));
|
||||
tessellator.draw();
|
||||
public void renderItem(Block block, RenderBlocks renderer, int meta) {
|
||||
setColor(((IMultipassBlock) block).colorMultiplier(meta));
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0f, -1.0f, 0.0f);
|
||||
renderer.renderFaceYNeg(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 0, meta));
|
||||
tessellator.draw();
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0f, 1.0f, 0.0f);
|
||||
renderer.renderFaceYPos(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 1, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0f, 1.0f, 0.0f);
|
||||
renderer.renderFaceYPos(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 1, meta));
|
||||
tessellator.draw();
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0f, 0.0f, -1.0f);
|
||||
renderer.renderFaceZNeg(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 2, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0f, 0.0f, -1.0f);
|
||||
renderer.renderFaceZNeg(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 2, meta));
|
||||
tessellator.draw();
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0f, 0.0f, 1.0f);
|
||||
renderer.renderFaceZPos(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 3, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0f, 0.0f, 1.0f);
|
||||
renderer.renderFaceZPos(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 3, meta));
|
||||
tessellator.draw();
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0f, 0.0f, 0.0f);
|
||||
renderer.renderFaceXNeg(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 4, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0f, 0.0f, 0.0f);
|
||||
renderer.renderFaceXNeg(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 4, meta));
|
||||
tessellator.draw();
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0f, 0.0f, 0.0f);
|
||||
renderer.renderFaceXPos(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 5, meta));
|
||||
tessellator.draw();
|
||||
}
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0f, 0.0f, 0.0f);
|
||||
renderer.renderFaceXPos(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 5, meta));
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public void setColor(int l) {
|
||||
float f = (l >> 16 & 0xFF) / 255.0f;
|
||||
float f2 = (l >> 8 & 0xFF) / 255.0f;
|
||||
float f3 = (l & 0xFF) / 255.0f;
|
||||
GL11.glColor3f(f, f2, f3);
|
||||
}
|
||||
public void setColor(int l) {
|
||||
float f = (l >> 16 & 0xFF) / 255.0f;
|
||||
float f2 = (l >> 8 & 0xFF) / 255.0f;
|
||||
float f3 = (l & 0xFF) / 255.0f;
|
||||
GL11.glColor3f(f, f2, f3);
|
||||
}
|
||||
}
|
||||
@@ -9,55 +9,57 @@ import net.minecraftforge.client.IItemRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class MultipassItemRenderer implements IItemRenderer {
|
||||
private void render(RenderBlocks renderer, ItemStack item, float f, float g, float h) {
|
||||
GL11.glTranslatef(f, g, h);
|
||||
Block block = ((ItemBlock) item.getItem()).field_150939_a;
|
||||
GL11.glEnable(3008);
|
||||
if (block.getRenderBlockPass() != 0) {
|
||||
GL11.glAlphaFunc(516, 0.1f);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
} else {
|
||||
GL11.glAlphaFunc(516, 0.5f);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
private void render(RenderBlocks renderer, ItemStack item, float f, float g, float h) {
|
||||
GL11.glTranslatef(f, g, h);
|
||||
Block block = ((ItemBlock) item.getItem()).field_150939_a;
|
||||
GL11.glEnable(3008);
|
||||
if (block.getRenderBlockPass() != 0) {
|
||||
GL11.glAlphaFunc(516, 0.1f);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
} else {
|
||||
GL11.glAlphaFunc(516, 0.5f);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
MultipassBlockRenderer.instance.renderInventoryBlock(block, TileEntityMetadata.getItemDamage(item), 0, renderer);
|
||||
if (block.getRenderBlockPass() == 0) {
|
||||
GL11.glAlphaFunc(516, 0.1f);
|
||||
}
|
||||
GL11.glTranslatef(-f, -g, -h);
|
||||
}
|
||||
MultipassBlockRenderer.instance.renderInventoryBlock(
|
||||
block, TileEntityMetadata.getItemDamage(item), 0, renderer);
|
||||
if (block.getRenderBlockPass() == 0) {
|
||||
GL11.glAlphaFunc(516, 0.1f);
|
||||
}
|
||||
GL11.glTranslatef(-f, -g, -h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) {
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
case EQUIPPED:
|
||||
case INVENTORY:
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) {
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
case EQUIPPED:
|
||||
case INVENTORY:
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(
|
||||
IItemRenderer.ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
|
||||
switch (type) {
|
||||
case INVENTORY:
|
||||
case ENTITY:
|
||||
render((RenderBlocks) data[0], item, 0.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
@Override
|
||||
public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
|
||||
switch (type) {
|
||||
case INVENTORY:
|
||||
case ENTITY:
|
||||
render((RenderBlocks) data[0], item, 0.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
|
||||
case EQUIPPED:
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
render((RenderBlocks) data[0], item, 0.5f, 0.5f, 0.5f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
case EQUIPPED:
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
render((RenderBlocks) data[0], item, 0.5f, 0.5f, 0.5f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,96 +10,96 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class TileEntityMetadata extends TileEntity {
|
||||
private int meta;
|
||||
private boolean droppedBlock;
|
||||
private int meta;
|
||||
private boolean droppedBlock;
|
||||
|
||||
public TileEntityMetadata() {
|
||||
droppedBlock = false;
|
||||
}
|
||||
public TileEntityMetadata() {
|
||||
droppedBlock = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean receiveClientEvent(int id, int meta) {
|
||||
// TODO fix magic const
|
||||
if (id == 42) {
|
||||
this.meta = meta;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean receiveClientEvent(int id, int meta) {
|
||||
// TODO fix magic const
|
||||
if (id == 42) {
|
||||
this.meta = meta;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
meta = nbt.getInteger("meta");
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
meta = nbt.getInteger("meta");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("meta", meta);
|
||||
}
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("meta", meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getTileMetadata() {
|
||||
return meta;
|
||||
}
|
||||
public int getTileMetadata() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public void setTileMetadata(int meta, boolean notify) {
|
||||
if (this.meta == meta) {
|
||||
return;
|
||||
}
|
||||
public void setTileMetadata(int meta, boolean notify) {
|
||||
if (this.meta == meta) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.meta = meta;
|
||||
if (notify) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
this.meta = meta;
|
||||
if (notify) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
MessageMetadata message = new MessageMetadata(xCoord, yCoord, zCoord, meta);
|
||||
return BinnieCore.instance.getNetworkWrapper().getPacketFrom(message.getMessage());
|
||||
}
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
MessageMetadata message = new MessageMetadata(xCoord, yCoord, zCoord, meta);
|
||||
return BinnieCore.instance.getNetworkWrapper().getPacketFrom(message.getMessage());
|
||||
}
|
||||
|
||||
public static TileEntityMetadata getTile(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityMetadata) {
|
||||
return (TileEntityMetadata) tile;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static TileEntityMetadata getTile(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityMetadata) {
|
||||
return (TileEntityMetadata) tile;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getItemStack(Block block, int damage) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("meta", damage);
|
||||
public static ItemStack getItemStack(Block block, int damage) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("meta", damage);
|
||||
|
||||
ItemStack item = new ItemStack(block, 1, 0);
|
||||
item.setItemDamage(Math.min(damage, 16387));
|
||||
item.setTagCompound(tag);
|
||||
return item;
|
||||
}
|
||||
ItemStack item = new ItemStack(block, 1, 0);
|
||||
item.setItemDamage(Math.min(damage, 16387));
|
||||
item.setTagCompound(tag);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static int getItemDamage(ItemStack item) {
|
||||
if (item.hasTagCompound() && item.getTagCompound().hasKey("meta")) {
|
||||
return item.getTagCompound().getInteger("meta");
|
||||
}
|
||||
return item.getItemDamage();
|
||||
}
|
||||
public static int getItemDamage(ItemStack item) {
|
||||
if (item.hasTagCompound() && item.getTagCompound().hasKey("meta")) {
|
||||
return item.getTagCompound().getInteger("meta");
|
||||
}
|
||||
return item.getItemDamage();
|
||||
}
|
||||
|
||||
public static int getTileMetadata(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntityMetadata tile = getTile(world, x, y, z);
|
||||
return (tile == null) ? 0 : tile.getTileMetadata();
|
||||
}
|
||||
public static int getTileMetadata(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntityMetadata tile = getTile(world, x, y, z);
|
||||
return (tile == null) ? 0 : tile.getTileMetadata();
|
||||
}
|
||||
|
||||
public boolean hasDroppedBlock() {
|
||||
return droppedBlock;
|
||||
}
|
||||
public boolean hasDroppedBlock() {
|
||||
return droppedBlock;
|
||||
}
|
||||
|
||||
public void dropBlock() {
|
||||
droppedBlock = true;
|
||||
}
|
||||
public void dropBlock() {
|
||||
droppedBlock = true;
|
||||
}
|
||||
}
|
||||
@@ -3,85 +3,84 @@ package binnie.core.circuits;
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuit;
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BinnieCircuit implements ICircuit {
|
||||
private String uid;
|
||||
private int limit;
|
||||
private List<String> tooltips;
|
||||
private String uid;
|
||||
private int limit;
|
||||
private List<String> tooltips;
|
||||
|
||||
public BinnieCircuit(String uid, int limit, ICircuitLayout layout, ItemStack itemStack) {
|
||||
tooltips = new ArrayList<>();
|
||||
this.uid = "binnie.circuit." + uid;
|
||||
this.limit = limit;
|
||||
public BinnieCircuit(String uid, int limit, ICircuitLayout layout, ItemStack itemStack) {
|
||||
tooltips = new ArrayList<>();
|
||||
this.uid = "binnie.circuit." + uid;
|
||||
this.limit = limit;
|
||||
|
||||
ChipsetManager.circuitRegistry.registerCircuit(this);
|
||||
if (itemStack != null) {
|
||||
ChipsetManager.solderManager.addRecipe(layout, itemStack, this);
|
||||
}
|
||||
}
|
||||
ChipsetManager.circuitRegistry.registerCircuit(this);
|
||||
if (itemStack != null) {
|
||||
ChipsetManager.solderManager.addRecipe(layout, itemStack, this);
|
||||
}
|
||||
}
|
||||
|
||||
public BinnieCircuit(String uid, int limit, ICircuitLayout layout, Item item, int itemMeta) {
|
||||
this(uid, limit, layout, new ItemStack(item, 1, itemMeta));
|
||||
}
|
||||
public BinnieCircuit(String uid, int limit, ICircuitLayout layout, Item item, int itemMeta) {
|
||||
this(uid, limit, layout, new ItemStack(item, 1, itemMeta));
|
||||
}
|
||||
|
||||
public void addTooltipString(String string) {
|
||||
tooltips.add(string);
|
||||
}
|
||||
public void addTooltipString(String string) {
|
||||
tooltips.add(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUID() {
|
||||
return uid;
|
||||
}
|
||||
@Override
|
||||
public String getUID() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresDiscovery() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean requiresDiscovery() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
@Override
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return uid;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTooltip(List<String> list) {
|
||||
for (String string : tooltips) {
|
||||
list.add(" - " + string);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void addTooltip(List<String> list) {
|
||||
for (String string : tooltips) {
|
||||
list.add(" - " + string);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCircuitable(Object arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isCircuitable(Object arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInsertion(int arg0, Object arg1) {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void onInsertion(int arg0, Object arg1) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad(int arg0, Object arg1) {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void onLoad(int arg0, Object arg1) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoval(int arg0, Object arg1) {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void onRemoval(int arg0, Object arg1) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(int arg0, Object arg1) {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void onTick(int arg0, Object arg1) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
@@ -8,33 +8,33 @@ import forestry.api.circuits.ICircuitLayout;
|
||||
import forestry.api.circuits.ICircuitSocketType;
|
||||
|
||||
public class BinnieCircuitLayout implements ICircuitLayout {
|
||||
private String uid;
|
||||
private AbstractMod mod;
|
||||
private String uid;
|
||||
private AbstractMod mod;
|
||||
|
||||
public BinnieCircuitLayout(AbstractMod mod, String uid) {
|
||||
this.uid = uid;
|
||||
this.mod = mod;
|
||||
ChipsetManager.circuitRegistry.registerLayout(this);
|
||||
}
|
||||
public BinnieCircuitLayout(AbstractMod mod, String uid) {
|
||||
this.uid = uid;
|
||||
this.mod = mod;
|
||||
ChipsetManager.circuitRegistry.registerLayout(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUID() {
|
||||
return "binnie.circuitLayout" + uid;
|
||||
}
|
||||
@Override
|
||||
public String getUID() {
|
||||
return "binnie.circuitLayout" + uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return I18N.localise(mod.getModID() + ".circuit.layout." + uid.toLowerCase());
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return I18N.localise(mod.getModID() + ".circuit.layout." + uid.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return I18N.localise(mod.getModID() + ".circuit.layout." + uid.toLowerCase() + ".usage");
|
||||
}
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return I18N.localise(mod.getModID() + ".circuit.layout." + uid.toLowerCase() + ".usage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICircuitSocketType getSocketType() {
|
||||
// TODO hmm? CircuitSocketType
|
||||
return CircuitSocketType.NONE;
|
||||
}
|
||||
@Override
|
||||
public ICircuitSocketType getSocketType() {
|
||||
// TODO hmm? CircuitSocketType
|
||||
return CircuitSocketType.NONE;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,6 @@ import binnie.core.craftgui.renderer.Renderer;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUIResourceManager;
|
||||
|
||||
public class CraftGUI {
|
||||
public static CraftGUIResourceManager resourceManager;
|
||||
public static Renderer render;
|
||||
public static CraftGUIResourceManager resourceManager;
|
||||
public static Renderer render;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
package binnie.core.craftgui;
|
||||
|
||||
public interface ITooltip {
|
||||
void getTooltip(Tooltip tooltip);
|
||||
void getTooltip(Tooltip tooltip);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
package binnie.core.craftgui;
|
||||
|
||||
public interface ITooltipHelp {
|
||||
void getHelpTooltip(Tooltip tooltip);
|
||||
void getHelpTooltip(Tooltip tooltip);
|
||||
}
|
||||
@@ -3,25 +3,25 @@ package binnie.core.craftgui;
|
||||
import binnie.core.craftgui.geometry.IPoint;
|
||||
|
||||
public interface ITopLevelWidget extends IWidget {
|
||||
void setMousePosition(int x, int y);
|
||||
void setMousePosition(int x, int y);
|
||||
|
||||
IPoint getAbsoluteMousePosition();
|
||||
IPoint getAbsoluteMousePosition();
|
||||
|
||||
IWidget getFocusedWidget();
|
||||
IWidget getFocusedWidget();
|
||||
|
||||
IWidget getMousedOverWidget();
|
||||
IWidget getMousedOverWidget();
|
||||
|
||||
IWidget getDraggedWidget();
|
||||
IWidget getDraggedWidget();
|
||||
|
||||
boolean isFocused(IWidget widget);
|
||||
boolean isFocused(IWidget widget);
|
||||
|
||||
boolean isMouseOver(IWidget widget);
|
||||
boolean isMouseOver(IWidget widget);
|
||||
|
||||
boolean isDragged(IWidget widget);
|
||||
boolean isDragged(IWidget widget);
|
||||
|
||||
void updateTopLevel();
|
||||
void updateTopLevel();
|
||||
|
||||
void widgetDeleted(IWidget widget);
|
||||
void widgetDeleted(IWidget widget);
|
||||
|
||||
IPoint getDragDistance();
|
||||
IPoint getDragDistance();
|
||||
}
|
||||
@@ -4,135 +4,134 @@ import binnie.core.craftgui.events.Event;
|
||||
import binnie.core.craftgui.events.EventHandler;
|
||||
import binnie.core.craftgui.geometry.IArea;
|
||||
import binnie.core.craftgui.geometry.IPoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IWidget {
|
||||
IWidget getParent();
|
||||
IWidget getParent();
|
||||
|
||||
void deleteChild(IWidget child);
|
||||
void deleteChild(IWidget child);
|
||||
|
||||
void deleteAllChildren();
|
||||
void deleteAllChildren();
|
||||
|
||||
ITopLevelWidget getSuperParent();
|
||||
ITopLevelWidget getSuperParent();
|
||||
|
||||
boolean isTopLevel();
|
||||
boolean isTopLevel();
|
||||
|
||||
IPoint getPosition();
|
||||
IPoint getPosition();
|
||||
|
||||
IPoint pos();
|
||||
IPoint pos();
|
||||
|
||||
void setPosition(IPoint position);
|
||||
void setPosition(IPoint position);
|
||||
|
||||
IPoint getSize();
|
||||
IPoint getSize();
|
||||
|
||||
IPoint size();
|
||||
IPoint size();
|
||||
|
||||
void setSize(IPoint size);
|
||||
void setSize(IPoint size);
|
||||
|
||||
IPoint getOriginalPosition();
|
||||
IPoint getOriginalPosition();
|
||||
|
||||
IPoint getAbsolutePosition();
|
||||
IPoint getAbsolutePosition();
|
||||
|
||||
IPoint getOriginalAbsolutePosition();
|
||||
IPoint getOriginalAbsolutePosition();
|
||||
|
||||
IPoint getOffset();
|
||||
IPoint getOffset();
|
||||
|
||||
IArea getArea();
|
||||
IArea getArea();
|
||||
|
||||
IArea area();
|
||||
IArea area();
|
||||
|
||||
void setOffset(IPoint offset);
|
||||
void setOffset(IPoint offset);
|
||||
|
||||
IPoint getMousePosition();
|
||||
IPoint getMousePosition();
|
||||
|
||||
IPoint getRelativeMousePosition();
|
||||
IPoint getRelativeMousePosition();
|
||||
|
||||
void setColor(int color);
|
||||
void setColor(int color);
|
||||
|
||||
int getColor();
|
||||
int getColor();
|
||||
|
||||
void render();
|
||||
void render();
|
||||
|
||||
void updateClient();
|
||||
void updateClient();
|
||||
|
||||
void enable();
|
||||
void enable();
|
||||
|
||||
void disable();
|
||||
void disable();
|
||||
|
||||
void show();
|
||||
void show();
|
||||
|
||||
void hide();
|
||||
void hide();
|
||||
|
||||
boolean calculateIsMouseOver();
|
||||
boolean calculateIsMouseOver();
|
||||
|
||||
boolean isEnabled();
|
||||
boolean isEnabled();
|
||||
|
||||
boolean isVisible();
|
||||
boolean isVisible();
|
||||
|
||||
boolean isFocused();
|
||||
boolean isFocused();
|
||||
|
||||
boolean isMouseOver();
|
||||
boolean isMouseOver();
|
||||
|
||||
boolean isDragged();
|
||||
boolean isDragged();
|
||||
|
||||
boolean isChildVisible(IWidget child);
|
||||
boolean isChildVisible(IWidget child);
|
||||
|
||||
boolean isChildEnabled(IWidget child);
|
||||
boolean isChildEnabled(IWidget child);
|
||||
|
||||
boolean canMouseOver();
|
||||
boolean canMouseOver();
|
||||
|
||||
boolean canFocus();
|
||||
boolean canFocus();
|
||||
|
||||
IWidget addWidget(IWidget widget);
|
||||
IWidget addWidget(IWidget widget);
|
||||
|
||||
List<IWidget> getWidgets();
|
||||
List<IWidget> getWidgets();
|
||||
|
||||
void callEvent(Event event);
|
||||
void callEvent(Event event);
|
||||
|
||||
void recieveEvent(Event event);
|
||||
void recieveEvent(Event event);
|
||||
|
||||
void onUpdateClient();
|
||||
void onUpdateClient();
|
||||
|
||||
void delete();
|
||||
void delete();
|
||||
|
||||
void onDelete();
|
||||
void onDelete();
|
||||
|
||||
<T> T getWidget(Class<T> p0);
|
||||
<T> T getWidget(Class<T> p0);
|
||||
|
||||
IArea getCroppedZone();
|
||||
IArea getCroppedZone();
|
||||
|
||||
void setCroppedZone(IWidget relative, IArea area);
|
||||
void setCroppedZone(IWidget relative, IArea area);
|
||||
|
||||
boolean isCroppedWidget();
|
||||
boolean isCroppedWidget();
|
||||
|
||||
IWidget getCropWidget();
|
||||
IWidget getCropWidget();
|
||||
|
||||
boolean isMouseOverWidget(IPoint p0);
|
||||
boolean isMouseOverWidget(IPoint p0);
|
||||
|
||||
int getLevel();
|
||||
int getLevel();
|
||||
|
||||
boolean isDescendant(IWidget widget);
|
||||
boolean isDescendant(IWidget widget);
|
||||
|
||||
List<WidgetAttribute> getAttributes();
|
||||
List<WidgetAttribute> getAttributes();
|
||||
|
||||
boolean hasAttribute(WidgetAttribute attribute);
|
||||
boolean hasAttribute(WidgetAttribute attribute);
|
||||
|
||||
boolean addAttribute(WidgetAttribute attribute);
|
||||
boolean addAttribute(WidgetAttribute attribute);
|
||||
|
||||
<E extends Event> void addEventHandler(EventHandler<E> handler);
|
||||
<E extends Event> void addEventHandler(EventHandler<E> handler);
|
||||
|
||||
<E extends Event> void addSelfEventHandler(EventHandler<E> handler);
|
||||
<E extends Event> void addSelfEventHandler(EventHandler<E> handler);
|
||||
|
||||
boolean contains(IPoint p0);
|
||||
boolean contains(IPoint p0);
|
||||
|
||||
float x();
|
||||
float x();
|
||||
|
||||
float y();
|
||||
float y();
|
||||
|
||||
float w();
|
||||
float w();
|
||||
|
||||
float h();
|
||||
float h();
|
||||
|
||||
void onRender(RenderStage stage);
|
||||
void onRender(RenderStage stage);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package binnie.core.craftgui;
|
||||
|
||||
public enum RenderStage {
|
||||
PreChildren,
|
||||
PostChildren,
|
||||
PostSiblings
|
||||
PreChildren,
|
||||
PostChildren,
|
||||
PostSiblings
|
||||
}
|
||||
@@ -1,76 +1,74 @@
|
||||
package binnie.core.craftgui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Tooltip {
|
||||
public int maxWidth;
|
||||
public int maxWidth;
|
||||
|
||||
protected List<String> tooltip;
|
||||
protected ITooltipType type;
|
||||
protected List<String> tooltip;
|
||||
protected ITooltipType type;
|
||||
|
||||
public Tooltip() {
|
||||
tooltip = new ArrayList<>();
|
||||
type = Type.STANDARD;
|
||||
maxWidth = 256;
|
||||
}
|
||||
public Tooltip() {
|
||||
tooltip = new ArrayList<>();
|
||||
type = Type.STANDARD;
|
||||
maxWidth = 256;
|
||||
}
|
||||
|
||||
public void add(String string) {
|
||||
tooltip.add(string);
|
||||
}
|
||||
public void add(String string) {
|
||||
tooltip.add(string);
|
||||
}
|
||||
|
||||
public void add(ItemStack item, String string) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
item.writeToNBT(nbt);
|
||||
nbt.setByte("nbt-type", (byte) 105);
|
||||
add("~~~" + nbt.toString() + "~~~" + string);
|
||||
}
|
||||
public void add(ItemStack item, String string) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
item.writeToNBT(nbt);
|
||||
nbt.setByte("nbt-type", (byte) 105);
|
||||
add("~~~" + nbt.toString() + "~~~" + string);
|
||||
}
|
||||
|
||||
public void add(FluidStack item, String string) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
item.writeToNBT(nbt);
|
||||
nbt.setByte("nbt-type", (byte) 102);
|
||||
add("~~~" + nbt.toString() + "~~~" + string);
|
||||
}
|
||||
public void add(FluidStack item, String string) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
item.writeToNBT(nbt);
|
||||
nbt.setByte("nbt-type", (byte) 102);
|
||||
add("~~~" + nbt.toString() + "~~~" + string);
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
return tooltip.size() > 0;
|
||||
}
|
||||
public boolean exists() {
|
||||
return tooltip.size() > 0;
|
||||
}
|
||||
|
||||
public void add(List list) {
|
||||
for (Object obj : list) {
|
||||
tooltip.add((String) obj);
|
||||
}
|
||||
}
|
||||
public void add(List list) {
|
||||
for (Object obj : list) {
|
||||
tooltip.add((String) obj);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getList() {
|
||||
return tooltip;
|
||||
}
|
||||
public List<String> getList() {
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
public void setType(ITooltipType type) {
|
||||
this.type = type;
|
||||
}
|
||||
public void setType(ITooltipType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setMaxWidth(int w) {
|
||||
maxWidth = w;
|
||||
}
|
||||
public void setMaxWidth(int w) {
|
||||
maxWidth = w;
|
||||
}
|
||||
|
||||
public ITooltipType getType() {
|
||||
return type;
|
||||
}
|
||||
public ITooltipType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public enum Type implements ITooltipType {
|
||||
STANDARD,
|
||||
HELP,
|
||||
INFORMATION,
|
||||
USER,
|
||||
POWER
|
||||
}
|
||||
public enum Type implements ITooltipType {
|
||||
STANDARD,
|
||||
HELP,
|
||||
INFORMATION,
|
||||
USER,
|
||||
POWER
|
||||
}
|
||||
|
||||
public interface ITooltipType {
|
||||
}
|
||||
public interface ITooltipType {}
|
||||
}
|
||||
@@ -3,229 +3,234 @@ package binnie.core.craftgui;
|
||||
import binnie.core.craftgui.events.EventMouse;
|
||||
import binnie.core.craftgui.events.EventWidget;
|
||||
import binnie.core.craftgui.geometry.IPoint;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
public abstract class TopLevelWidget extends Widget implements ITopLevelWidget {
|
||||
protected IWidget mousedOverWidget;
|
||||
protected IWidget draggedWidget;
|
||||
protected IWidget focusedWidget;
|
||||
protected IPoint mousePosition;
|
||||
protected IPoint dragStart;
|
||||
protected IWidget mousedOverWidget;
|
||||
protected IWidget draggedWidget;
|
||||
protected IWidget focusedWidget;
|
||||
protected IPoint mousePosition;
|
||||
protected IPoint dragStart;
|
||||
|
||||
public TopLevelWidget() {
|
||||
super(null);
|
||||
mousePosition = new IPoint(0.0f, 0.0f);
|
||||
dragStart = IPoint.ZERO;
|
||||
public TopLevelWidget() {
|
||||
super(null);
|
||||
mousePosition = new IPoint(0.0f, 0.0f);
|
||||
dragStart = IPoint.ZERO;
|
||||
|
||||
addEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
setDraggedWidget(mousedOverWidget, event.getButton());
|
||||
setFocusedWidget(mousedOverWidget);
|
||||
}
|
||||
});
|
||||
addEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
setDraggedWidget(mousedOverWidget, event.getButton());
|
||||
setFocusedWidget(mousedOverWidget);
|
||||
}
|
||||
});
|
||||
|
||||
addEventHandler(new EventMouse.Up.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Up event) {
|
||||
setDraggedWidget(null);
|
||||
}
|
||||
});
|
||||
addEventHandler(new EventMouse.Up.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Up event) {
|
||||
setDraggedWidget(null);
|
||||
}
|
||||
});
|
||||
|
||||
addEventHandler(new EventWidget.StartDrag.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventWidget.StartDrag event) {
|
||||
dragStart = getRelativeMousePosition();
|
||||
}
|
||||
});
|
||||
}
|
||||
addEventHandler(new EventWidget.StartDrag.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventWidget.StartDrag event) {
|
||||
dragStart = getRelativeMousePosition();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setMousedOverWidget(IWidget widget) {
|
||||
if (mousedOverWidget == widget) {
|
||||
return;
|
||||
}
|
||||
public void setMousedOverWidget(IWidget widget) {
|
||||
if (mousedOverWidget == widget) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mousedOverWidget != null) {
|
||||
callEvent(new EventWidget.EndMouseOver(mousedOverWidget));
|
||||
}
|
||||
if (mousedOverWidget != null) {
|
||||
callEvent(new EventWidget.EndMouseOver(mousedOverWidget));
|
||||
}
|
||||
|
||||
mousedOverWidget = widget;
|
||||
if (mousedOverWidget != null) {
|
||||
callEvent(new EventWidget.StartMouseOver(mousedOverWidget));
|
||||
}
|
||||
}
|
||||
mousedOverWidget = widget;
|
||||
if (mousedOverWidget != null) {
|
||||
callEvent(new EventWidget.StartMouseOver(mousedOverWidget));
|
||||
}
|
||||
}
|
||||
|
||||
public void setDraggedWidget(IWidget widget) {
|
||||
setDraggedWidget(widget, -1);
|
||||
}
|
||||
public void setDraggedWidget(IWidget widget) {
|
||||
setDraggedWidget(widget, -1);
|
||||
}
|
||||
|
||||
public void setDraggedWidget(IWidget widget, int button) {
|
||||
if (draggedWidget == widget) {
|
||||
return;
|
||||
}
|
||||
public void setDraggedWidget(IWidget widget, int button) {
|
||||
if (draggedWidget == widget) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (draggedWidget != null) {
|
||||
callEvent(new EventWidget.EndDrag(draggedWidget));
|
||||
}
|
||||
if (draggedWidget != null) {
|
||||
callEvent(new EventWidget.EndDrag(draggedWidget));
|
||||
}
|
||||
|
||||
draggedWidget = widget;
|
||||
if (draggedWidget != null) {
|
||||
callEvent(new EventWidget.StartDrag(draggedWidget, button));
|
||||
}
|
||||
}
|
||||
draggedWidget = widget;
|
||||
if (draggedWidget != null) {
|
||||
callEvent(new EventWidget.StartDrag(draggedWidget, button));
|
||||
}
|
||||
}
|
||||
|
||||
public void setFocusedWidget(IWidget widget) {
|
||||
IWidget newWidget = widget;
|
||||
if (focusedWidget == newWidget) {
|
||||
return;
|
||||
}
|
||||
public void setFocusedWidget(IWidget widget) {
|
||||
IWidget newWidget = widget;
|
||||
if (focusedWidget == newWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newWidget != null && !newWidget.canFocus()) {
|
||||
newWidget = null;
|
||||
}
|
||||
if (focusedWidget != null) {
|
||||
callEvent(new EventWidget.LoseFocus(focusedWidget));
|
||||
}
|
||||
if (newWidget != null && !newWidget.canFocus()) {
|
||||
newWidget = null;
|
||||
}
|
||||
if (focusedWidget != null) {
|
||||
callEvent(new EventWidget.LoseFocus(focusedWidget));
|
||||
}
|
||||
|
||||
focusedWidget = newWidget;
|
||||
if (focusedWidget != null) {
|
||||
callEvent(new EventWidget.GainFocus(focusedWidget));
|
||||
}
|
||||
}
|
||||
focusedWidget = newWidget;
|
||||
if (focusedWidget != null) {
|
||||
callEvent(new EventWidget.GainFocus(focusedWidget));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget getMousedOverWidget() {
|
||||
return mousedOverWidget;
|
||||
}
|
||||
@Override
|
||||
public IWidget getMousedOverWidget() {
|
||||
return mousedOverWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget getDraggedWidget() {
|
||||
return draggedWidget;
|
||||
}
|
||||
@Override
|
||||
public IWidget getDraggedWidget() {
|
||||
return draggedWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget getFocusedWidget() {
|
||||
return focusedWidget;
|
||||
}
|
||||
@Override
|
||||
public IWidget getFocusedWidget() {
|
||||
return focusedWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMouseOver(IWidget widget) {
|
||||
return getMousedOverWidget() == widget;
|
||||
}
|
||||
@Override
|
||||
public boolean isMouseOver(IWidget widget) {
|
||||
return getMousedOverWidget() == widget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDragged(IWidget widget) {
|
||||
return getDraggedWidget() == widget;
|
||||
}
|
||||
@Override
|
||||
public boolean isDragged(IWidget widget) {
|
||||
return getDraggedWidget() == widget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFocused(IWidget widget) {
|
||||
return getFocusedWidget() == widget;
|
||||
}
|
||||
@Override
|
||||
public boolean isFocused(IWidget widget) {
|
||||
return getFocusedWidget() == widget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTopLevel() {
|
||||
setMousedOverWidget(calculateMousedOverWidget());
|
||||
if (getFocusedWidget() != null && (!getFocusedWidget().isVisible() || !getFocusedWidget().isEnabled())) {
|
||||
setFocusedWidget(null);
|
||||
}
|
||||
@Override
|
||||
public void updateTopLevel() {
|
||||
setMousedOverWidget(calculateMousedOverWidget());
|
||||
if (getFocusedWidget() != null
|
||||
&& (!getFocusedWidget().isVisible() || !getFocusedWidget().isEnabled())) {
|
||||
setFocusedWidget(null);
|
||||
}
|
||||
|
||||
if (!Mouse.isButtonDown(0)) {
|
||||
if (draggedWidget != null) {
|
||||
setDraggedWidget(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Mouse.isButtonDown(0)) {
|
||||
if (draggedWidget != null) {
|
||||
setDraggedWidget(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IWidget calculateMousedOverWidget() {
|
||||
Deque<IWidget> queue = calculateMousedOverWidgets();
|
||||
while (!queue.isEmpty()) {
|
||||
IWidget widget = queue.removeFirst();
|
||||
if (widget.isEnabled() && widget.isVisible()) {
|
||||
if (!widget.canMouseOver()) {
|
||||
continue;
|
||||
}
|
||||
if (widget.isEnabled() && widget.isVisible() && widget.canMouseOver() && widget.calculateIsMouseOver()) {
|
||||
return widget;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private IWidget calculateMousedOverWidget() {
|
||||
Deque<IWidget> queue = calculateMousedOverWidgets();
|
||||
while (!queue.isEmpty()) {
|
||||
IWidget widget = queue.removeFirst();
|
||||
if (widget.isEnabled() && widget.isVisible()) {
|
||||
if (!widget.canMouseOver()) {
|
||||
continue;
|
||||
}
|
||||
if (widget.isEnabled()
|
||||
&& widget.isVisible()
|
||||
&& widget.canMouseOver()
|
||||
&& widget.calculateIsMouseOver()) {
|
||||
return widget;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Deque<IWidget> calculateMousedOverWidgets() {
|
||||
Deque<IWidget> list = new ArrayDeque<>();
|
||||
for (IWidget widget : getQueuedWidgets(this)) {
|
||||
if (widget.calculateIsMouseOver()) {
|
||||
list.addLast(widget);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public Deque<IWidget> calculateMousedOverWidgets() {
|
||||
Deque<IWidget> list = new ArrayDeque<>();
|
||||
for (IWidget widget : getQueuedWidgets(this)) {
|
||||
if (widget.calculateIsMouseOver()) {
|
||||
list.addLast(widget);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private Collection<IWidget> getQueuedWidgets(IWidget widget) {
|
||||
List<IWidget> widgets = new ArrayList<>();
|
||||
boolean addChildren = true;
|
||||
if (widget.isCroppedWidget()) {
|
||||
addChildren = widget.getCroppedZone().contains(widget.getCropWidget().getRelativeMousePosition());
|
||||
}
|
||||
private Collection<IWidget> getQueuedWidgets(IWidget widget) {
|
||||
List<IWidget> widgets = new ArrayList<>();
|
||||
boolean addChildren = true;
|
||||
if (widget.isCroppedWidget()) {
|
||||
addChildren =
|
||||
widget.getCroppedZone().contains(widget.getCropWidget().getRelativeMousePosition());
|
||||
}
|
||||
|
||||
if (addChildren) {
|
||||
ListIterator<IWidget> li = widget.getWidgets().listIterator(widget.getWidgets().size());
|
||||
while (li.hasPrevious()) {
|
||||
IWidget child = li.previous();
|
||||
widgets.addAll(getQueuedWidgets(child));
|
||||
}
|
||||
}
|
||||
widgets.add(widget);
|
||||
return widgets;
|
||||
}
|
||||
if (addChildren) {
|
||||
ListIterator<IWidget> li =
|
||||
widget.getWidgets().listIterator(widget.getWidgets().size());
|
||||
while (li.hasPrevious()) {
|
||||
IWidget child = li.previous();
|
||||
widgets.addAll(getQueuedWidgets(child));
|
||||
}
|
||||
}
|
||||
widgets.add(widget);
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMousePosition(int x, int y) {
|
||||
float dx = x - mousePosition.x();
|
||||
float dy = y - mousePosition.y();
|
||||
if (dx != 0.0f || dy != 0.0f) {
|
||||
if (getDraggedWidget() != null) {
|
||||
callEvent(new EventMouse.Drag(getDraggedWidget(), dx, dy));
|
||||
} else {
|
||||
callEvent(new EventMouse.Move(this, dx, dy));
|
||||
}
|
||||
}
|
||||
|
||||
if (mousePosition.x() != x || mousePosition.y() != y) {
|
||||
mousePosition = new IPoint(x, y);
|
||||
setMousedOverWidget(calculateMousedOverWidget());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setMousePosition(int x, int y) {
|
||||
float dx = x - mousePosition.x();
|
||||
float dy = y - mousePosition.y();
|
||||
if (dx != 0.0f || dy != 0.0f) {
|
||||
if (getDraggedWidget() != null) {
|
||||
callEvent(new EventMouse.Drag(getDraggedWidget(), dx, dy));
|
||||
} else {
|
||||
callEvent(new EventMouse.Move(this, dx, dy));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPoint getAbsoluteMousePosition() {
|
||||
return mousePosition;
|
||||
}
|
||||
if (mousePosition.x() != x || mousePosition.y() != y) {
|
||||
mousePosition = new IPoint(x, y);
|
||||
setMousedOverWidget(calculateMousedOverWidget());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDeleted(IWidget widget) {
|
||||
if (isMouseOver(widget)) {
|
||||
setMousedOverWidget(null);
|
||||
}
|
||||
if (isDragged(widget)) {
|
||||
setDraggedWidget(null);
|
||||
}
|
||||
if (isFocused(widget)) {
|
||||
setFocusedWidget(null);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public IPoint getAbsoluteMousePosition() {
|
||||
return mousePosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPoint getDragDistance() {
|
||||
return getRelativeMousePosition().sub(dragStart);
|
||||
}
|
||||
@Override
|
||||
public void widgetDeleted(IWidget widget) {
|
||||
if (isMouseOver(widget)) {
|
||||
setMousedOverWidget(null);
|
||||
}
|
||||
if (isDragged(widget)) {
|
||||
setDraggedWidget(null);
|
||||
}
|
||||
if (isFocused(widget)) {
|
||||
setFocusedWidget(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPoint getDragDistance() {
|
||||
return getRelativeMousePosition().sub(dragStart);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,9 +1,9 @@
|
||||
package binnie.core.craftgui;
|
||||
|
||||
public enum WidgetAttribute {
|
||||
MOUSE_OVER,
|
||||
CAN_FOCUS,
|
||||
NEEDS_DELETION,
|
||||
ALWAYS_ON_TOP,
|
||||
BLOCK_TOOLTIP
|
||||
MOUSE_OVER,
|
||||
CAN_FOCUS,
|
||||
NEEDS_DELETION,
|
||||
ALWAYS_ON_TOP,
|
||||
BLOCK_TOOLTIP
|
||||
}
|
||||
@@ -31,6 +31,11 @@ import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -38,263 +43,272 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class WindowFieldKit extends Window {
|
||||
private float glassOffsetX;
|
||||
private float glassOffsetY;
|
||||
private float glassVX;
|
||||
private float glassVY;
|
||||
private Random glassRand;
|
||||
private Control GlassControl;
|
||||
private ControlChromosome chromo;
|
||||
private ControlText text;
|
||||
private float analyseProgress;
|
||||
private boolean isAnalysing;
|
||||
private Map<IChromosomeType, String> info;
|
||||
private float glassOffsetX;
|
||||
private float glassOffsetY;
|
||||
private float glassVX;
|
||||
private float glassVY;
|
||||
private Random glassRand;
|
||||
private Control GlassControl;
|
||||
private ControlChromosome chromo;
|
||||
private ControlText text;
|
||||
private float analyseProgress;
|
||||
private boolean isAnalysing;
|
||||
private Map<IChromosomeType, String> info;
|
||||
|
||||
public WindowFieldKit(EntityPlayer player, IInventory inventory, Side side) {
|
||||
super(280.0f, 230.0f, player, inventory, side);
|
||||
glassOffsetX = 0.0f;
|
||||
glassOffsetY = 0.0f;
|
||||
glassVX = 0.0f;
|
||||
glassVY = 0.0f;
|
||||
glassRand = new Random();
|
||||
analyseProgress = 1.0f;
|
||||
isAnalysing = false;
|
||||
info = new HashMap<>();
|
||||
}
|
||||
public WindowFieldKit(EntityPlayer player, IInventory inventory, Side side) {
|
||||
super(280.0f, 230.0f, player, inventory, side);
|
||||
glassOffsetX = 0.0f;
|
||||
glassOffsetY = 0.0f;
|
||||
glassVX = 0.0f;
|
||||
glassVY = 0.0f;
|
||||
glassRand = new Random();
|
||||
analyseProgress = 1.0f;
|
||||
isAnalysing = false;
|
||||
info = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return BinnieCore.instance;
|
||||
}
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return BinnieCore.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return I18N.localise("binniecore.gui.fieldKit");
|
||||
}
|
||||
@Override
|
||||
protected String getName() {
|
||||
return I18N.localise("binniecore.gui.fieldKit");
|
||||
}
|
||||
|
||||
private void setupValidators() {
|
||||
getWindowInventory().setValidator(0, new SlotValidator(null) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack object) {
|
||||
return AlleleManager.alleleRegistry.isIndividual(object)
|
||||
|| Binnie.Genetics.getConversion(object) != null;
|
||||
}
|
||||
private void setupValidators() {
|
||||
getWindowInventory().setValidator(0, new SlotValidator(null) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack object) {
|
||||
return AlleleManager.alleleRegistry.isIndividual(object)
|
||||
|| Binnie.Genetics.getConversion(object) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return I18N.localise("binniecore.gui.tooltip.individual");
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return I18N.localise("binniecore.gui.tooltip.individual");
|
||||
}
|
||||
});
|
||||
|
||||
getWindowInventory().setValidator(1, new SlotValidator(null) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack object) {
|
||||
return object.getItem() == Items.paper;
|
||||
}
|
||||
getWindowInventory().setValidator(1, new SlotValidator(null) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack object) {
|
||||
return object.getItem() == Items.paper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return I18N.localise("binniecore.gui.tooltip.paper");
|
||||
}
|
||||
});
|
||||
getWindowInventory().disableAutoDispense(1);
|
||||
}
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return I18N.localise("binniecore.gui.tooltip.paper");
|
||||
}
|
||||
});
|
||||
getWindowInventory().disableAutoDispense(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
setTitle(getName());
|
||||
CraftGUI.render.stylesheet(new StyleSheetPunnett());
|
||||
getWindowInventory().createSlot(0);
|
||||
getWindowInventory().createSlot(1);
|
||||
setupValidators();
|
||||
new ControlPlayerInventory(this);
|
||||
IPoint handGlass = new IPoint(16.0f, 32.0f);
|
||||
GlassControl = new ControlImage(this, handGlass.x(), handGlass.y(), new StandardTexture(0, 160, 96, 96, ExtraBeeTexture.GUIPunnett));
|
||||
new ControlSlot(this, handGlass.x() + 54.0f, handGlass.y() + 26.0f).assign(InventoryType.Window, 0);
|
||||
new ControlSlot(this, 208.0f, 8.0f).assign(InventoryType.Window, 1);
|
||||
(text = new ControlText(this, new IPoint(232.0f, 13.0f), I18N.localise("binniecore.gui.tooltip.paper"))).setColor(0x222222);
|
||||
(text = new ControlText(this, new IArea(0.0f, 120.0f, w(), 24.0f), "", TextJustification.MIDDLE_CENTER)).setColor(0x222222);
|
||||
chromo = new ControlChromosome(this, 150.0f, 24.0f);
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
setTitle(getName());
|
||||
CraftGUI.render.stylesheet(new StyleSheetPunnett());
|
||||
getWindowInventory().createSlot(0);
|
||||
getWindowInventory().createSlot(1);
|
||||
setupValidators();
|
||||
new ControlPlayerInventory(this);
|
||||
IPoint handGlass = new IPoint(16.0f, 32.0f);
|
||||
GlassControl = new ControlImage(
|
||||
this, handGlass.x(), handGlass.y(), new StandardTexture(0, 160, 96, 96, ExtraBeeTexture.GUIPunnett));
|
||||
new ControlSlot(this, handGlass.x() + 54.0f, handGlass.y() + 26.0f).assign(InventoryType.Window, 0);
|
||||
new ControlSlot(this, 208.0f, 8.0f).assign(InventoryType.Window, 1);
|
||||
(text = new ControlText(this, new IPoint(232.0f, 13.0f), I18N.localise("binniecore.gui.tooltip.paper")))
|
||||
.setColor(0x222222);
|
||||
(text = new ControlText(this, new IArea(0.0f, 120.0f, w(), 24.0f), "", TextJustification.MIDDLE_CENTER))
|
||||
.setColor(0x222222);
|
||||
chromo = new ControlChromosome(this, 150.0f, 24.0f);
|
||||
|
||||
addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
IChromosomeType type = (IChromosomeType) event.getValue();
|
||||
if (type != null && info.containsKey(type)) {
|
||||
String t = info.get(type);
|
||||
text.setValue(t);
|
||||
} else {
|
||||
text.setValue("");
|
||||
}
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.DirectChild, chromo));
|
||||
}
|
||||
addEventHandler(
|
||||
new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
IChromosomeType type = (IChromosomeType) event.getValue();
|
||||
if (type != null && info.containsKey(type)) {
|
||||
String t = info.get(type);
|
||||
text.setValue(t);
|
||||
} else {
|
||||
text.setValue("");
|
||||
}
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.DirectChild, chromo));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseServer() {
|
||||
ItemStack kit = getPlayer().getHeldItem();
|
||||
int sheets = 64 - kit.getItemDamage();
|
||||
if (sheets != 0) {
|
||||
getWindowInventory().setInventorySlotContents(1, new ItemStack(Items.paper, sheets));
|
||||
}
|
||||
setupValidators();
|
||||
}
|
||||
@Override
|
||||
public void initialiseServer() {
|
||||
ItemStack kit = getPlayer().getHeldItem();
|
||||
int sheets = 64 - kit.getItemDamage();
|
||||
if (sheets != 0) {
|
||||
getWindowInventory().setInventorySlotContents(1, new ItemStack(Items.paper, sheets));
|
||||
}
|
||||
setupValidators();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
if (isAnalysing) {
|
||||
analyseProgress += 0.01f;
|
||||
if (analyseProgress >= 1.0f) {
|
||||
isAnalysing = false;
|
||||
analyseProgress = 1.0f;
|
||||
ItemStack stack = getWindowInventory().getStackInSlot(0);
|
||||
if (stack != null) {
|
||||
sendClientAction("analyse", new NBTTagCompound());
|
||||
}
|
||||
refreshSpecies();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
if (isAnalysing) {
|
||||
analyseProgress += 0.01f;
|
||||
if (analyseProgress >= 1.0f) {
|
||||
isAnalysing = false;
|
||||
analyseProgress = 1.0f;
|
||||
ItemStack stack = getWindowInventory().getStackInSlot(0);
|
||||
if (stack != null) {
|
||||
sendClientAction("analyse", new NBTTagCompound());
|
||||
}
|
||||
refreshSpecies();
|
||||
}
|
||||
}
|
||||
|
||||
glassVX += glassRand.nextFloat() - 0.5f - glassOffsetX * 0.2f;
|
||||
glassVY += glassRand.nextFloat() - 0.5f - glassOffsetY * 0.2f;
|
||||
glassOffsetX += glassVX;
|
||||
glassOffsetX *= 1.0f - analyseProgress;
|
||||
glassOffsetY += glassVY;
|
||||
glassOffsetY *= 1.0f - analyseProgress;
|
||||
GlassControl.setOffset(new IPoint(glassOffsetX, glassOffsetY));
|
||||
}
|
||||
glassVX += glassRand.nextFloat() - 0.5f - glassOffsetX * 0.2f;
|
||||
glassVY += glassRand.nextFloat() - 0.5f - glassOffsetY * 0.2f;
|
||||
glassOffsetX += glassVX;
|
||||
glassOffsetX *= 1.0f - analyseProgress;
|
||||
glassOffsetY += glassVY;
|
||||
glassOffsetY *= 1.0f - analyseProgress;
|
||||
GlassControl.setOffset(new IPoint(glassOffsetX, glassOffsetY));
|
||||
}
|
||||
|
||||
private void refreshSpecies() {
|
||||
ItemStack item = getWindowInventory().getStackInSlot(0);
|
||||
if (item == null || !AlleleManager.alleleRegistry.isIndividual(item)) {
|
||||
return;
|
||||
}
|
||||
private void refreshSpecies() {
|
||||
ItemStack item = getWindowInventory().getStackInSlot(0);
|
||||
if (item == null || !AlleleManager.alleleRegistry.isIndividual(item)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IIndividual ind = AlleleManager.alleleRegistry.getIndividual(item);
|
||||
if (ind == null) {
|
||||
return;
|
||||
}
|
||||
IIndividual ind = AlleleManager.alleleRegistry.getIndividual(item);
|
||||
if (ind == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(item);
|
||||
chromo.setRoot(root);
|
||||
Random rand = new Random();
|
||||
info.clear();
|
||||
for (IChromosomeType type : root.getKaryotype()) {
|
||||
if (!Binnie.Genetics.isInvalidChromosome(type)) {
|
||||
IAllele allele = ind.getGenome().getActiveAllele(type);
|
||||
List<String> infos = new ArrayList<>();
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(item);
|
||||
chromo.setRoot(root);
|
||||
Random rand = new Random();
|
||||
info.clear();
|
||||
for (IChromosomeType type : root.getKaryotype()) {
|
||||
if (!Binnie.Genetics.isInvalidChromosome(type)) {
|
||||
IAllele allele = ind.getGenome().getActiveAllele(type);
|
||||
List<String> infos = new ArrayList<>();
|
||||
|
||||
int i = 0;
|
||||
for (String pref = root.getUID() + ".fieldkit." + type.getName().toLowerCase() + "."; I18N.canLocalise(pref + i); ++i) {
|
||||
infos.add(I18N.localise(pref + i));
|
||||
}
|
||||
int i = 0;
|
||||
for (String pref = root.getUID() + ".fieldkit." + type.getName().toLowerCase() + ".";
|
||||
I18N.canLocalise(pref + i);
|
||||
++i) {
|
||||
infos.add(I18N.localise(pref + i));
|
||||
}
|
||||
|
||||
String text = Binnie.Genetics.getSystem(root).getAlleleName(type, allele);
|
||||
if (!infos.isEmpty()) {
|
||||
text = infos.get(rand.nextInt(infos.size()));
|
||||
}
|
||||
String text = Binnie.Genetics.getSystem(root).getAlleleName(type, allele);
|
||||
if (!infos.isEmpty()) {
|
||||
text = infos.get(rand.nextInt(infos.size()));
|
||||
}
|
||||
|
||||
info.put(type, text);
|
||||
chromo.setRoot(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
info.put(type, text);
|
||||
chromo.setRoot(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowInventoryChanged() {
|
||||
super.onWindowInventoryChanged();
|
||||
if (isServer()) {
|
||||
ItemStack kit = getPlayer().getHeldItem();
|
||||
if(kit == null || !kit.getItem().equals(BinnieCore.fieldKit)) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void onWindowInventoryChanged() {
|
||||
super.onWindowInventoryChanged();
|
||||
if (isServer()) {
|
||||
ItemStack kit = getPlayer().getHeldItem();
|
||||
if (kit == null || !kit.getItem().equals(BinnieCore.fieldKit)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int sheets = 64 - kit.getItemDamage();
|
||||
int size = (getWindowInventory().getStackInSlot(1) == null) ? 0 : getWindowInventory().getStackInSlot(1).stackSize;
|
||||
if (sheets != size) {
|
||||
kit.setItemDamage(64 - size);
|
||||
}
|
||||
((EntityPlayerMP) getPlayer()).updateHeldItem();
|
||||
}
|
||||
int sheets = 64 - kit.getItemDamage();
|
||||
int size = (getWindowInventory().getStackInSlot(1) == null)
|
||||
? 0
|
||||
: getWindowInventory().getStackInSlot(1).stackSize;
|
||||
if (sheets != size) {
|
||||
kit.setItemDamage(64 - size);
|
||||
}
|
||||
((EntityPlayerMP) getPlayer()).updateHeldItem();
|
||||
}
|
||||
|
||||
if (!isClient()) {
|
||||
return;
|
||||
}
|
||||
if (!isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack item = getWindowInventory().getStackInSlot(0);
|
||||
text.setValue("");
|
||||
ItemStack item = getWindowInventory().getStackInSlot(0);
|
||||
text.setValue("");
|
||||
|
||||
if (item != null && !Analyser.isAnalysed(item)) {
|
||||
if (getWindowInventory().getStackInSlot(1) == null) {
|
||||
text.setValue(I18N.localise("binniecore.gui.tooltip.noPaper"));
|
||||
isAnalysing = false;
|
||||
analyseProgress = 1.0f;
|
||||
} else {
|
||||
startAnalysing();
|
||||
chromo.setRoot(null);
|
||||
}
|
||||
} else if (item != null) {
|
||||
isAnalysing = false;
|
||||
analyseProgress = 1.0f;
|
||||
refreshSpecies();
|
||||
} else {
|
||||
isAnalysing = false;
|
||||
analyseProgress = 1.0f;
|
||||
chromo.setRoot(null);
|
||||
}
|
||||
}
|
||||
if (item != null && !Analyser.isAnalysed(item)) {
|
||||
if (getWindowInventory().getStackInSlot(1) == null) {
|
||||
text.setValue(I18N.localise("binniecore.gui.tooltip.noPaper"));
|
||||
isAnalysing = false;
|
||||
analyseProgress = 1.0f;
|
||||
} else {
|
||||
startAnalysing();
|
||||
chromo.setRoot(null);
|
||||
}
|
||||
} else if (item != null) {
|
||||
isAnalysing = false;
|
||||
analyseProgress = 1.0f;
|
||||
refreshSpecies();
|
||||
} else {
|
||||
isAnalysing = false;
|
||||
analyseProgress = 1.0f;
|
||||
chromo.setRoot(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void startAnalysing() {
|
||||
glassVX = 0.0f;
|
||||
glassVY = 0.0f;
|
||||
glassOffsetX = 0.0f;
|
||||
glassOffsetY = 0.0f;
|
||||
isAnalysing = true;
|
||||
analyseProgress = 0.0f;
|
||||
}
|
||||
private void startAnalysing() {
|
||||
glassVX = 0.0f;
|
||||
glassVY = 0.0f;
|
||||
glassOffsetX = 0.0f;
|
||||
glassOffsetY = 0.0f;
|
||||
isAnalysing = true;
|
||||
analyseProgress = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showHelpButton() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean showHelpButton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String showInfoButton() {
|
||||
return I18N.localise("binniecore.gui.fieldKit.info");
|
||||
}
|
||||
@Override
|
||||
public String showInfoButton() {
|
||||
return I18N.localise("binniecore.gui.fieldKit.info");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
|
||||
super.recieveGuiNBT(side, player, name, nbt);
|
||||
if (side != Side.SERVER || !name.equals("analyse")) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
|
||||
super.recieveGuiNBT(side, player, name, nbt);
|
||||
if (side != Side.SERVER || !name.equals("analyse")) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = getWindowInventory().getStackInSlot(0);
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
ItemStack stack = getWindowInventory().getStackInSlot(0);
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
getWindowInventory().setInventorySlotContents(0, Analyser.analyse(stack));
|
||||
getWindowInventory().decrStackSize(1, 1);
|
||||
}
|
||||
getWindowInventory().setInventorySlotContents(0, Analyser.analyse(stack));
|
||||
getWindowInventory().decrStackSize(1, 1);
|
||||
}
|
||||
|
||||
static class StyleSheetPunnett extends StyleSheet {
|
||||
public StyleSheetPunnett() {
|
||||
textures.put(CraftGUITexture.Window, new PaddedTexture(0, 0, 160, 160, 0, ExtraBeeTexture.GUIPunnett, 32, 32, 32, 32));
|
||||
textures.put(CraftGUITexture.Slot, new StandardTexture(160, 0, 18, 18, 0, ExtraBeeTexture.GUIPunnett));
|
||||
textures.put(ExtraBeeGUITexture.Chromosome, new StandardTexture(160, 36, 16, 16, 0, ExtraBeeTexture.GUIPunnett));
|
||||
textures.put(ExtraBeeGUITexture.Chromosome2, new StandardTexture(160, 52, 16, 16, 0, ExtraBeeTexture.GUIPunnett));
|
||||
textures.put(CraftGUITexture.HelpButton, new StandardTexture(178, 0, 16, 16, 0, ExtraBeeTexture.GUIPunnett));
|
||||
textures.put(CraftGUITexture.InfoButton, new StandardTexture(178, 16, 16, 16, 0, ExtraBeeTexture.GUIPunnett));
|
||||
}
|
||||
}
|
||||
static class StyleSheetPunnett extends StyleSheet {
|
||||
public StyleSheetPunnett() {
|
||||
textures.put(
|
||||
CraftGUITexture.Window,
|
||||
new PaddedTexture(0, 0, 160, 160, 0, ExtraBeeTexture.GUIPunnett, 32, 32, 32, 32));
|
||||
textures.put(CraftGUITexture.Slot, new StandardTexture(160, 0, 18, 18, 0, ExtraBeeTexture.GUIPunnett));
|
||||
textures.put(
|
||||
ExtraBeeGUITexture.Chromosome, new StandardTexture(160, 36, 16, 16, 0, ExtraBeeTexture.GUIPunnett));
|
||||
textures.put(
|
||||
ExtraBeeGUITexture.Chromosome2,
|
||||
new StandardTexture(160, 52, 16, 16, 0, ExtraBeeTexture.GUIPunnett));
|
||||
textures.put(
|
||||
CraftGUITexture.HelpButton, new StandardTexture(178, 0, 16, 16, 0, ExtraBeeTexture.GUIPunnett));
|
||||
textures.put(
|
||||
CraftGUITexture.InfoButton, new StandardTexture(178, 16, 16, 16, 0, ExtraBeeTexture.GUIPunnett));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,9 @@ import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -34,212 +37,216 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WindowGenesis extends Window {
|
||||
private ISpeciesRoot root;
|
||||
private IAllele[] template;
|
||||
private ControlListBox<Gene> geneList;
|
||||
private ControlListBox<Gene> geneOptions;
|
||||
private Panel panelPickup;
|
||||
private ISpeciesRoot root;
|
||||
private IAllele[] template;
|
||||
private ControlListBox<Gene> geneList;
|
||||
private ControlListBox<Gene> geneOptions;
|
||||
private Panel panelPickup;
|
||||
|
||||
public WindowGenesis(EntityPlayer player, IInventory inventory, Side side) {
|
||||
super(342.0f, 228.0f, player, inventory, side);
|
||||
}
|
||||
public WindowGenesis(EntityPlayer player, IInventory inventory, Side side) {
|
||||
super(342.0f, 228.0f, player, inventory, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return BinnieCore.instance;
|
||||
}
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return BinnieCore.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return I18N.localise("binniecore.gui.genesis");
|
||||
}
|
||||
@Override
|
||||
protected String getName() {
|
||||
return I18N.localise("binniecore.gui.genesis");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
new ControlPlayerInventory(this);
|
||||
setTitle(getName());
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
new ControlPlayerInventory(this);
|
||||
setTitle(getName());
|
||||
|
||||
ControlTabBar<BreedingSystem> tabSystems = new BreedingSystemControlTabBar();
|
||||
tabSystems.setValues(Binnie.Genetics.getActiveSystems());
|
||||
root = Binnie.Genetics.getActiveSystems().iterator().next().getSpeciesRoot();
|
||||
template = root.getDefaultTemplate();
|
||||
IArea one = new IArea(32.0f, 28.0f, 170.0f, 100.0f);
|
||||
IArea two = new IArea(214.0f, 28.0f, 100.0f, 100.0f);
|
||||
new Panel(this, one.outset(1), MinecraftGUI.PanelType.Black);
|
||||
new Panel(this, two.outset(1), MinecraftGUI.PanelType.Black);
|
||||
ControlTabBar<BreedingSystem> tabSystems = new BreedingSystemControlTabBar();
|
||||
tabSystems.setValues(Binnie.Genetics.getActiveSystems());
|
||||
root = Binnie.Genetics.getActiveSystems().iterator().next().getSpeciesRoot();
|
||||
template = root.getDefaultTemplate();
|
||||
IArea one = new IArea(32.0f, 28.0f, 170.0f, 100.0f);
|
||||
IArea two = new IArea(214.0f, 28.0f, 100.0f, 100.0f);
|
||||
new Panel(this, one.outset(1), MinecraftGUI.PanelType.Black);
|
||||
new Panel(this, two.outset(1), MinecraftGUI.PanelType.Black);
|
||||
|
||||
geneList = new ControlListBox<Gene>(this, one.x(), one.y(), one.w(), one.h(), 10.0f) {
|
||||
@Override
|
||||
public IWidget createOption(Gene value, int y) {
|
||||
return new ControlGenesisOption(getContent(), value, y);
|
||||
}
|
||||
};
|
||||
geneList = new ControlListBox<Gene>(this, one.x(), one.y(), one.w(), one.h(), 10.0f) {
|
||||
@Override
|
||||
public IWidget createOption(Gene value, int y) {
|
||||
return new ControlGenesisOption(getContent(), value, y);
|
||||
}
|
||||
};
|
||||
|
||||
geneOptions = new ControlListBox<Gene>(this, two.x(), two.y(), two.w(), two.h(), 10.0f) {
|
||||
@Override
|
||||
public IWidget createOption(Gene value, int y) {
|
||||
return new ControlTextOption<>(getContent(), value, y);
|
||||
}
|
||||
};
|
||||
geneOptions = new ControlListBox<Gene>(this, two.x(), two.y(), two.w(), two.h(), 10.0f) {
|
||||
@Override
|
||||
public IWidget createOption(Gene value, int y) {
|
||||
return new ControlTextOption<>(getContent(), value, y);
|
||||
}
|
||||
};
|
||||
|
||||
tabSystems.addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
root = ((BreedingSystem) event.getValue()).getSpeciesRoot();
|
||||
template = root.getDefaultTemplate();
|
||||
refreshTemplate(null);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, tabSystems));
|
||||
tabSystems.addEventHandler(
|
||||
new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
root = ((BreedingSystem) event.getValue()).getSpeciesRoot();
|
||||
template = root.getDefaultTemplate();
|
||||
refreshTemplate(null);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, tabSystems));
|
||||
|
||||
geneList.addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
Map<IChromosomeType, List<IAllele>> map = Binnie.Genetics.getChromosomeMap(root);
|
||||
List<Gene> opts = new ArrayList<>();
|
||||
IChromosomeType chromo = event.value != null ? ((Gene) event.value).getChromosome() : null;
|
||||
if (chromo != null) {// fix NPE
|
||||
for (IAllele allele : map.get(chromo)) {
|
||||
opts.add(new Gene(allele, chromo, root));
|
||||
}
|
||||
}
|
||||
geneOptions.setOptions(opts);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, geneList));
|
||||
geneList.addEventHandler(
|
||||
new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
Map<IChromosomeType, List<IAllele>> map = Binnie.Genetics.getChromosomeMap(root);
|
||||
List<Gene> opts = new ArrayList<>();
|
||||
IChromosomeType chromo = event.value != null ? ((Gene) event.value).getChromosome() : null;
|
||||
if (chromo != null) { // fix NPE
|
||||
for (IAllele allele : map.get(chromo)) {
|
||||
opts.add(new Gene(allele, chromo, root));
|
||||
}
|
||||
}
|
||||
geneOptions.setOptions(opts);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, geneList));
|
||||
|
||||
geneOptions.addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
if (event.value == null) {
|
||||
return;
|
||||
}
|
||||
geneOptions.addEventHandler(
|
||||
new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
if (event.value == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IChromosomeType chromo = ((Gene) event.value).getChromosome();
|
||||
template[chromo.ordinal()] = ((Gene) event.value).getAllele();
|
||||
if (chromo == ((Gene) event.value).getSpeciesRoot().getKaryotypeKey()) {
|
||||
template = ((Gene) event.value).getSpeciesRoot().getTemplate(((Gene) event.value).getAllele().getUID());
|
||||
}
|
||||
refreshTemplate(chromo);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, geneOptions));
|
||||
panelPickup = new Panel(this, 16.0f, 140.0f, 60.0f, 42.0f, MinecraftGUI.PanelType.Black);
|
||||
refreshTemplate(null);
|
||||
}
|
||||
IChromosomeType chromo = ((Gene) event.value).getChromosome();
|
||||
template[chromo.ordinal()] = ((Gene) event.value).getAllele();
|
||||
if (chromo == ((Gene) event.value).getSpeciesRoot().getKaryotypeKey()) {
|
||||
template = ((Gene) event.value)
|
||||
.getSpeciesRoot()
|
||||
.getTemplate(
|
||||
((Gene) event.value).getAllele().getUID());
|
||||
}
|
||||
refreshTemplate(chromo);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, geneOptions));
|
||||
panelPickup = new Panel(this, 16.0f, 140.0f, 60.0f, 42.0f, MinecraftGUI.PanelType.Black);
|
||||
refreshTemplate(null);
|
||||
}
|
||||
|
||||
private void refreshTemplate(IChromosomeType selection) {
|
||||
List<Gene> genes = new ArrayList<>();
|
||||
IChromosomeType[] chromos = Binnie.Genetics.getChromosomeMap(root).keySet().toArray(new IChromosomeType[0]);
|
||||
private void refreshTemplate(IChromosomeType selection) {
|
||||
List<Gene> genes = new ArrayList<>();
|
||||
IChromosomeType[] chromos =
|
||||
Binnie.Genetics.getChromosomeMap(root).keySet().toArray(new IChromosomeType[0]);
|
||||
|
||||
for (IChromosomeType type : chromos) {
|
||||
IAllele allele = template[type.ordinal()];
|
||||
if (allele == null) {
|
||||
throw new NullPointerException("Allele missing for Chromosome " + type.getName());
|
||||
}
|
||||
genes.add(new Gene(allele, type, root));
|
||||
}
|
||||
for (IChromosomeType type : chromos) {
|
||||
IAllele allele = template[type.ordinal()];
|
||||
if (allele == null) {
|
||||
throw new NullPointerException("Allele missing for Chromosome " + type.getName());
|
||||
}
|
||||
genes.add(new Gene(allele, type, root));
|
||||
}
|
||||
|
||||
geneList.setOptions(genes);
|
||||
if (selection != null) {
|
||||
geneList.setValue(new Gene(template[selection.ordinal()], selection, root));
|
||||
} else {
|
||||
geneOptions.setOptions(new ArrayList<>());
|
||||
}
|
||||
refreshPickup();
|
||||
}
|
||||
geneList.setOptions(genes);
|
||||
if (selection != null) {
|
||||
geneList.setValue(new Gene(template[selection.ordinal()], selection, root));
|
||||
} else {
|
||||
geneOptions.setOptions(new ArrayList<>());
|
||||
}
|
||||
refreshPickup();
|
||||
}
|
||||
|
||||
private void refreshPickup() {
|
||||
panelPickup.deleteAllChildren();
|
||||
int i = 0;
|
||||
for (int type : Binnie.Genetics.getSystem(root).getActiveTypes()) {
|
||||
IIndividual ind = root.templateAsIndividual(template);
|
||||
ind.analyze();
|
||||
ItemStack stack = root.getMemberStack(ind, type);
|
||||
ControlItemDisplay display = new ControlItemDisplay(panelPickup, 4 + i % 3 * 18, 4 + i / 3 * 18);
|
||||
display.setItemStack(stack);
|
||||
display.setTooltip();
|
||||
display.addEventHandler(new MouseDownHandler(stack).setOrigin(EventHandler.Origin.Self, display));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
private void refreshPickup() {
|
||||
panelPickup.deleteAllChildren();
|
||||
int i = 0;
|
||||
for (int type : Binnie.Genetics.getSystem(root).getActiveTypes()) {
|
||||
IIndividual ind = root.templateAsIndividual(template);
|
||||
ind.analyze();
|
||||
ItemStack stack = root.getMemberStack(ind, type);
|
||||
ControlItemDisplay display = new ControlItemDisplay(panelPickup, 4 + i % 3 * 18, 4 + i / 3 * 18);
|
||||
display.setItemStack(stack);
|
||||
display.setTooltip();
|
||||
display.addEventHandler(new MouseDownHandler(stack).setOrigin(EventHandler.Origin.Self, display));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
|
||||
super.recieveGuiNBT(side, player, name, nbt);
|
||||
if (side == Side.SERVER && name.equals("genesis")) {
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
|
||||
InventoryPlayer playerInv = player.inventory;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
|
||||
super.recieveGuiNBT(side, player, name, nbt);
|
||||
if (side == Side.SERVER && name.equals("genesis")) {
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
|
||||
InventoryPlayer playerInv = player.inventory;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerInv.getItemStack() == null) {
|
||||
playerInv.setItemStack(stack);
|
||||
} else if (playerInv.getItemStack().isItemEqual(stack) && ItemStack.areItemStackTagsEqual(playerInv.getItemStack(), stack)) {
|
||||
int fit = stack.getMaxStackSize() - (stack.stackSize + playerInv.getItemStack().stackSize);
|
||||
if (fit >= 0) {
|
||||
ItemStack itemStack;
|
||||
ItemStack rec = itemStack = stack;
|
||||
itemStack.stackSize += playerInv.getItemStack().stackSize;
|
||||
playerInv.setItemStack(rec);
|
||||
}
|
||||
}
|
||||
if (playerInv.getItemStack() == null) {
|
||||
playerInv.setItemStack(stack);
|
||||
} else if (playerInv.getItemStack().isItemEqual(stack)
|
||||
&& ItemStack.areItemStackTagsEqual(playerInv.getItemStack(), stack)) {
|
||||
int fit = stack.getMaxStackSize() - (stack.stackSize + playerInv.getItemStack().stackSize);
|
||||
if (fit >= 0) {
|
||||
ItemStack itemStack;
|
||||
ItemStack rec = itemStack = stack;
|
||||
itemStack.stackSize += playerInv.getItemStack().stackSize;
|
||||
playerInv.setItemStack(rec);
|
||||
}
|
||||
}
|
||||
|
||||
player.openContainer.detectAndSendChanges();
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) player).updateHeldItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
player.openContainer.detectAndSendChanges();
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) player).updateHeldItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class MouseDownHandler extends EventMouse.Down.Handler {
|
||||
private final ItemStack stack;
|
||||
private static class MouseDownHandler extends EventMouse.Down.Handler {
|
||||
private final ItemStack stack;
|
||||
|
||||
public MouseDownHandler(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
public MouseDownHandler(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
stack.writeToNBT(nbt);
|
||||
Window.get(event.getOrigin()).sendClientAction("genesis", nbt);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
stack.writeToNBT(nbt);
|
||||
Window.get(event.getOrigin()).sendClientAction("genesis", nbt);
|
||||
}
|
||||
}
|
||||
|
||||
private class BreedingSystemControlTabBar extends ControlTabBar<BreedingSystem> {
|
||||
public BreedingSystemControlTabBar() {
|
||||
super(WindowGenesis.this, 8.0f, 28.0f, 23.0f, 100.0f, Position.LEFT);
|
||||
}
|
||||
private class BreedingSystemControlTabBar extends ControlTabBar<BreedingSystem> {
|
||||
public BreedingSystemControlTabBar() {
|
||||
super(WindowGenesis.this, 8.0f, 28.0f, 23.0f, 100.0f, Position.LEFT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ControlTab<BreedingSystem> createTab(float x, float y, float w, float h, BreedingSystem value) {
|
||||
return new ControlTabIcon<BreedingSystem>(this, x, y, w, h, value) {
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
int type = value.getDefaultType();
|
||||
IIndividual ind = value.getDefaultIndividual();
|
||||
return value.getSpeciesRoot().getMemberStack(ind, type);
|
||||
}
|
||||
@Override
|
||||
public ControlTab<BreedingSystem> createTab(float x, float y, float w, float h, BreedingSystem value) {
|
||||
return new ControlTabIcon<BreedingSystem>(this, x, y, w, h, value) {
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
int type = value.getDefaultType();
|
||||
IIndividual ind = value.getDefaultIndividual();
|
||||
return value.getSpeciesRoot().getMemberStack(ind, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return value.getName();
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return value.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOutlineColor() {
|
||||
return value.getColor();
|
||||
}
|
||||
@Override
|
||||
public int getOutlineColor() {
|
||||
return value.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOutline() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean hasOutline() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,53 +11,53 @@ import binnie.core.craftgui.geometry.TextJustification;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
|
||||
public class ControlButton extends Control {
|
||||
private ControlText textWidget;
|
||||
private String text;
|
||||
private ControlText textWidget;
|
||||
private String text;
|
||||
|
||||
public ControlButton(IWidget parent, float x, float y, float width, float height) {
|
||||
super(parent, x, y, width, height);
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
mouseHandler.setOrigin(EventHandler.Origin.Self, this);
|
||||
addEventHandler(mouseHandler);
|
||||
}
|
||||
public ControlButton(IWidget parent, float x, float y, float width, float height) {
|
||||
super(parent, x, y, width, height);
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
mouseHandler.setOrigin(EventHandler.Origin.Self, this);
|
||||
addEventHandler(mouseHandler);
|
||||
}
|
||||
|
||||
public ControlButton(IWidget parent, float x, float y, float width, float height, String text) {
|
||||
this(parent, x, y, width, height);
|
||||
this.text = text;
|
||||
textWidget = new ControlText(this, getArea(), text, TextJustification.MIDDLE_CENTER);
|
||||
}
|
||||
|
||||
private EventMouse.Down.Handler mouseHandler = new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
callEvent(new EventButtonClicked(getWidget()));
|
||||
onMouseClick(event);
|
||||
}
|
||||
};
|
||||
public ControlButton(IWidget parent, float x, float y, float width, float height, String text) {
|
||||
this(parent, x, y, width, height);
|
||||
this.text = text;
|
||||
textWidget = new ControlText(this, getArea(), text, TextJustification.MIDDLE_CENTER);
|
||||
}
|
||||
|
||||
protected void onMouseClick(EventMouse.Down event) {
|
||||
// ignored
|
||||
}
|
||||
private EventMouse.Down.Handler mouseHandler = new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
callEvent(new EventButtonClicked(getWidget()));
|
||||
onMouseClick(event);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
if (textWidget != null) {
|
||||
textWidget.setValue(getText());
|
||||
}
|
||||
}
|
||||
protected void onMouseClick(EventMouse.Down event) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
Object texture = CraftGUITexture.ButtonDisabled;
|
||||
if (isMouseOver()) {
|
||||
texture = CraftGUITexture.ButtonHighlighted;
|
||||
} else if (isEnabled()) {
|
||||
texture = CraftGUITexture.Button;
|
||||
}
|
||||
CraftGUI.render.texture(texture, getArea());
|
||||
}
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
if (textWidget != null) {
|
||||
textWidget.setValue(getText());
|
||||
}
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
Object texture = CraftGUITexture.ButtonDisabled;
|
||||
if (isMouseOver()) {
|
||||
texture = CraftGUITexture.ButtonHighlighted;
|
||||
} else if (isEnabled()) {
|
||||
texture = CraftGUITexture.Button;
|
||||
}
|
||||
CraftGUI.render.texture(texture, getArea());
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@@ -14,56 +14,58 @@ import binnie.core.craftgui.geometry.TextJustification;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
|
||||
public class ControlCheckbox extends Control implements IControlValue<Boolean> {
|
||||
boolean value;
|
||||
String text;
|
||||
boolean value;
|
||||
String text;
|
||||
|
||||
public ControlCheckbox(IWidget parent, float x, float y, boolean bool) {
|
||||
this(parent, x, y, 0.0f, "", bool);
|
||||
}
|
||||
public ControlCheckbox(IWidget parent, float x, float y, boolean bool) {
|
||||
this(parent, x, y, 0.0f, "", bool);
|
||||
}
|
||||
|
||||
public ControlCheckbox(IWidget parent, float x, float y, float w, String text, boolean bool) {
|
||||
super(parent, x, y, (w > 16.0f) ? w : 16.0f, 16.0f);
|
||||
this.text = text;
|
||||
value = bool;
|
||||
if (w > 16.0f) {
|
||||
new ControlText(this, new IArea(16.0f, 1.0f, w - 16.0f, 16.0f), text, TextJustification.MIDDLE_CENTER).setColor(4473924);
|
||||
}
|
||||
public ControlCheckbox(IWidget parent, float x, float y, float w, String text, boolean bool) {
|
||||
super(parent, x, y, (w > 16.0f) ? w : 16.0f, 16.0f);
|
||||
this.text = text;
|
||||
value = bool;
|
||||
if (w > 16.0f) {
|
||||
new ControlText(this, new IArea(16.0f, 1.0f, w - 16.0f, 16.0f), text, TextJustification.MIDDLE_CENTER)
|
||||
.setColor(4473924);
|
||||
}
|
||||
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
addEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
toggleValue();
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
}
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
addEventHandler(
|
||||
new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
toggleValue();
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
Object texture = getValue() ? CraftGUITexture.CheckboxChecked : CraftGUITexture.Checkbox;
|
||||
if (isMouseOver()) {
|
||||
texture = (getValue() ? CraftGUITexture.CheckboxCheckedHighlighted : CraftGUITexture.CheckboxHighlighted);
|
||||
}
|
||||
CraftGUI.render.texture(texture, IPoint.ZERO);
|
||||
}
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
Object texture = getValue() ? CraftGUITexture.CheckboxChecked : CraftGUITexture.Checkbox;
|
||||
if (isMouseOver()) {
|
||||
texture = (getValue() ? CraftGUITexture.CheckboxCheckedHighlighted : CraftGUITexture.CheckboxHighlighted);
|
||||
}
|
||||
CraftGUI.render.texture(texture, IPoint.ZERO);
|
||||
}
|
||||
|
||||
protected void onValueChanged(boolean value) {
|
||||
// ignored
|
||||
}
|
||||
protected void onValueChanged(boolean value) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
public void toggleValue() {
|
||||
setValue(!getValue());
|
||||
}
|
||||
public void toggleValue() {
|
||||
setValue(!getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getValue() {
|
||||
return value;
|
||||
}
|
||||
@Override
|
||||
public Boolean getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Boolean value) {
|
||||
this.value = value;
|
||||
onValueChanged(value);
|
||||
callEvent(new EventValueChanged<Object>(this, value));
|
||||
}
|
||||
@Override
|
||||
public void setValue(Boolean value) {
|
||||
this.value = value;
|
||||
onValueChanged(value);
|
||||
callEvent(new EventValueChanged<Object>(this, value));
|
||||
}
|
||||
}
|
||||
@@ -9,35 +9,40 @@ import binnie.core.craftgui.geometry.IPoint;
|
||||
import binnie.core.craftgui.geometry.TextJustification;
|
||||
|
||||
public class ControlText extends Control implements IControlValue<String> {
|
||||
private String text;
|
||||
private TextJustification align;
|
||||
private String text;
|
||||
private TextJustification align;
|
||||
|
||||
public ControlText(IWidget parent, IPoint pos, String text) {
|
||||
this(parent, new IArea(pos, new IPoint(500.0f, 0.0f)), text, TextJustification.TOP_LEFT);
|
||||
}
|
||||
public ControlText(IWidget parent, IPoint pos, String text) {
|
||||
this(parent, new IArea(pos, new IPoint(500.0f, 0.0f)), text, TextJustification.TOP_LEFT);
|
||||
}
|
||||
|
||||
public ControlText(IWidget parent, String text, TextJustification align) {
|
||||
this(parent, parent.getArea(), text, align);
|
||||
}
|
||||
public ControlText(IWidget parent, String text, TextJustification align) {
|
||||
this(parent, parent.getArea(), text, align);
|
||||
}
|
||||
|
||||
public ControlText(IWidget parent, IArea area, String text, TextJustification align) {
|
||||
super(parent, area.pos().x(), area.pos().y(), area.size().x(), area.size().y());
|
||||
setValue(text);
|
||||
this.align = align;
|
||||
}
|
||||
public ControlText(IWidget parent, IArea area, String text, TextJustification align) {
|
||||
super(
|
||||
parent,
|
||||
area.pos().x(),
|
||||
area.pos().y(),
|
||||
area.size().x(),
|
||||
area.size().y());
|
||||
setValue(text);
|
||||
this.align = align;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.render.text(getArea(), align, text, getColor());
|
||||
}
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.render.text(getArea(), align, text, getColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
@Override
|
||||
public void setValue(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return text;
|
||||
}
|
||||
@Override
|
||||
public String getValue() {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,11 @@ import binnie.core.craftgui.geometry.IPoint;
|
||||
import binnie.core.craftgui.geometry.TextJustification;
|
||||
|
||||
public class ControlTextCentered extends ControlText {
|
||||
public ControlTextCentered(IWidget parent, float y, String text) {
|
||||
super(parent, new IArea(new IPoint(0.0f, y), new IPoint(parent.size().x(), 0.0f)), text, TextJustification.TOP_CENTER);
|
||||
}
|
||||
public ControlTextCentered(IWidget parent, float y, String text) {
|
||||
super(
|
||||
parent,
|
||||
new IArea(new IPoint(0.0f, y), new IPoint(parent.size().x(), 0.0f)),
|
||||
text,
|
||||
TextJustification.TOP_CENTER);
|
||||
}
|
||||
}
|
||||
@@ -14,85 +14,92 @@ import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
||||
public class ControlTextEdit extends Control implements IControlValue<String> {
|
||||
GuiTextField field;
|
||||
private String cachedValue;
|
||||
GuiTextField field;
|
||||
private String cachedValue;
|
||||
|
||||
public ControlTextEdit(IWidget parent, float x, float y, float width, float height) {
|
||||
super(parent, x, y, width, height);
|
||||
cachedValue = "";
|
||||
field = new GuiTextField(getWindow().getGui().getFontRenderer(), 0, 0, 10, 10);
|
||||
addAttribute(WidgetAttribute.CAN_FOCUS);
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
field.setEnableBackgroundDrawing(false);
|
||||
public ControlTextEdit(IWidget parent, float x, float y, float width, float height) {
|
||||
super(parent, x, y, width, height);
|
||||
cachedValue = "";
|
||||
field = new GuiTextField(getWindow().getGui().getFontRenderer(), 0, 0, 10, 10);
|
||||
addAttribute(WidgetAttribute.CAN_FOCUS);
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
field.setEnableBackgroundDrawing(false);
|
||||
|
||||
addEventHandler(new EventKey.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventKey.Down event) {
|
||||
field.textboxKeyTyped(event.getCharacter(), event.getKey());
|
||||
String text = getValue();
|
||||
if (!text.equals(cachedValue)) {
|
||||
cachedValue = text;
|
||||
callEvent(new EventTextEdit(ControlTextEdit.this, cachedValue));
|
||||
onTextEdit(cachedValue);
|
||||
}
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
addEventHandler(
|
||||
new EventKey.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventKey.Down event) {
|
||||
field.textboxKeyTyped(event.getCharacter(), event.getKey());
|
||||
String text = getValue();
|
||||
if (!text.equals(cachedValue)) {
|
||||
cachedValue = text;
|
||||
callEvent(new EventTextEdit(ControlTextEdit.this, cachedValue));
|
||||
onTextEdit(cachedValue);
|
||||
}
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
|
||||
addEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
field.mouseClicked((int) getRelativeMousePosition().x(), (int) getRelativeMousePosition().y(), event.getButton());
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
addEventHandler(
|
||||
new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
field.mouseClicked(
|
||||
(int) getRelativeMousePosition().x(),
|
||||
(int) getRelativeMousePosition().y(),
|
||||
event.getButton());
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
|
||||
addEventHandler(new EventWidget.GainFocus.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventWidget.GainFocus event) {
|
||||
field.setFocused(true);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
addEventHandler(
|
||||
new EventWidget.GainFocus.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventWidget.GainFocus event) {
|
||||
field.setFocused(true);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
|
||||
addEventHandler(new EventWidget.LoseFocus.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventWidget.LoseFocus event) {
|
||||
field.setFocused(false);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
}
|
||||
addEventHandler(
|
||||
new EventWidget.LoseFocus.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventWidget.LoseFocus event) {
|
||||
field.setFocused(false);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
protected void onTextEdit(String value) {
|
||||
// ignored
|
||||
}
|
||||
protected void onTextEdit(String value) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.render.texture(CraftGUITexture.Slot, getArea());
|
||||
renderTextField();
|
||||
}
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.render.texture(CraftGUITexture.Slot, getArea());
|
||||
renderTextField();
|
||||
}
|
||||
|
||||
protected void renderTextField() {
|
||||
field.width = (int) w();
|
||||
field.height = (int) h();
|
||||
field.xPosition = (int) ((h() - 8.0f) / 2.0f);
|
||||
field.yPosition = (int) ((h() - 8.0f) / 2.0f);
|
||||
field.drawTextBox();
|
||||
}
|
||||
protected void renderTextField() {
|
||||
field.width = (int) w();
|
||||
field.height = (int) h();
|
||||
field.xPosition = (int) ((h() - 8.0f) / 2.0f);
|
||||
field.yPosition = (int) ((h() - 8.0f) / 2.0f);
|
||||
field.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return (field.getText() == null) ? "" : field.getText();
|
||||
}
|
||||
@Override
|
||||
public String getValue() {
|
||||
return (field.getText() == null) ? "" : field.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
if (!getValue().equals(value)) {
|
||||
field.setText(value);
|
||||
field.setCursorPosition(0);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
if (!getValue().equals(value)) {
|
||||
field.setText(value);
|
||||
field.setCursorPosition(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
package binnie.core.craftgui.controls;
|
||||
|
||||
public interface IControlSelectionOption<T> {
|
||||
T getValue();
|
||||
T getValue();
|
||||
}
|
||||
@@ -9,70 +9,69 @@ import binnie.core.craftgui.WidgetAttribute;
|
||||
import binnie.core.craftgui.geometry.IArea;
|
||||
import binnie.core.craftgui.geometry.IPoint;
|
||||
import binnie.core.craftgui.minecraft.Window;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Control extends Widget implements ITooltipHelp, ITooltip {
|
||||
public int extraLevel;
|
||||
public int extraLevel;
|
||||
|
||||
protected List<String> helpStrings;
|
||||
protected List<String> tooltipStrings;
|
||||
protected List<String> helpStrings;
|
||||
protected List<String> tooltipStrings;
|
||||
|
||||
public Control(IWidget parent, float x, float y, float w, float h) {
|
||||
super(parent);
|
||||
helpStrings = new ArrayList<>();
|
||||
tooltipStrings = new ArrayList<>();
|
||||
extraLevel = 0;
|
||||
setPosition(new IPoint(x, y));
|
||||
setSize(new IPoint(w, h));
|
||||
initialise();
|
||||
}
|
||||
public Control(IWidget parent, float x, float y, float w, float h) {
|
||||
super(parent);
|
||||
helpStrings = new ArrayList<>();
|
||||
tooltipStrings = new ArrayList<>();
|
||||
extraLevel = 0;
|
||||
setPosition(new IPoint(x, y));
|
||||
setSize(new IPoint(w, h));
|
||||
initialise();
|
||||
}
|
||||
|
||||
public Control(IWidget parent, IArea area) {
|
||||
this(parent, area.x(), area.y(), area.w(), area.h());
|
||||
}
|
||||
public Control(IWidget parent, IArea area) {
|
||||
this(parent, area.x(), area.y(), area.w(), area.h());
|
||||
}
|
||||
|
||||
protected void initialise() {
|
||||
// ignored
|
||||
}
|
||||
protected void initialise() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
public void addHelp(String string) {
|
||||
helpStrings.add(string);
|
||||
}
|
||||
public void addHelp(String string) {
|
||||
helpStrings.add(string);
|
||||
}
|
||||
|
||||
public void addHelp(String[] strings) {
|
||||
for (String string : strings) {
|
||||
addHelp(string);
|
||||
}
|
||||
}
|
||||
public void addHelp(String[] strings) {
|
||||
for (String string : strings) {
|
||||
addHelp(string);
|
||||
}
|
||||
}
|
||||
|
||||
public void addTooltip(String string) {
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
tooltipStrings.add(string);
|
||||
}
|
||||
public void addTooltip(String string) {
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
tooltipStrings.add(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return extraLevel + super.getLevel();
|
||||
}
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return extraLevel + super.getLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHelpTooltip(Tooltip tooltip) {
|
||||
tooltip.add(helpStrings);
|
||||
}
|
||||
@Override
|
||||
public void getHelpTooltip(Tooltip tooltip) {
|
||||
tooltip.add(helpStrings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
tooltip.add(tooltipStrings);
|
||||
}
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
tooltip.add(tooltipStrings);
|
||||
}
|
||||
|
||||
public Window getWindow() {
|
||||
return (Window) getSuperParent();
|
||||
}
|
||||
public Window getWindow() {
|
||||
return (Window) getSuperParent();
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package binnie.core.craftgui.controls.core;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
|
||||
public interface IControlValue<T> extends IWidget {
|
||||
T getValue();
|
||||
T getValue();
|
||||
|
||||
void setValue(T value);
|
||||
void setValue(T value);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package binnie.core.craftgui.controls.core;
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IControlValues<T> extends IControlValue<T> {
|
||||
Collection<T> getValues();
|
||||
Collection<T> getValues();
|
||||
|
||||
void setValues(Collection<T> values);
|
||||
void setValues(Collection<T> values);
|
||||
}
|
||||
@@ -6,115 +6,114 @@ import binnie.core.craftgui.controls.core.IControlValue;
|
||||
import binnie.core.craftgui.events.EventValueChanged;
|
||||
import binnie.core.craftgui.geometry.IPoint;
|
||||
import binnie.core.util.IValidator;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ControlList<T> extends Control implements IControlValue<T> {
|
||||
protected ControlListBox<T> parent;
|
||||
protected T value;
|
||||
protected Map<T, IWidget> allOptions = new LinkedHashMap<>();
|
||||
protected Map<T, IWidget> optionWidgets = new LinkedHashMap<>();
|
||||
protected boolean creating;
|
||||
protected IValidator<IWidget> validator;
|
||||
protected ControlListBox<T> parent;
|
||||
protected T value;
|
||||
protected Map<T, IWidget> allOptions = new LinkedHashMap<>();
|
||||
protected Map<T, IWidget> optionWidgets = new LinkedHashMap<>();
|
||||
protected boolean creating;
|
||||
protected IValidator<IWidget> validator;
|
||||
|
||||
protected ControlList(ControlListBox<T> parent, float x, float y, float w, float h) {
|
||||
super(parent, x, y, w, h);
|
||||
this.parent = parent;
|
||||
}
|
||||
protected ControlList(ControlListBox<T> parent, float x, float y, float w, float h) {
|
||||
super(parent, x, y, w, h);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
@Override
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
if (value == this.value) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
if (value == this.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.value = value;
|
||||
if (value != null && optionWidgets.containsKey(value)) {
|
||||
IWidget child = optionWidgets.get(value);
|
||||
parent.ensureVisible(child.y(), child.y() + child.h(), h());
|
||||
}
|
||||
getParent().callEvent(new EventValueChanged<Object>(getParent(), value));
|
||||
}
|
||||
this.value = value;
|
||||
if (value != null && optionWidgets.containsKey(value)) {
|
||||
IWidget child = optionWidgets.get(value);
|
||||
parent.ensureVisible(child.y(), child.y() + child.h(), h());
|
||||
}
|
||||
getParent().callEvent(new EventValueChanged<Object>(getParent(), value));
|
||||
}
|
||||
|
||||
public void setOptions(Collection<T> options) {
|
||||
deleteAllChildren();
|
||||
allOptions.clear();
|
||||
public void setOptions(Collection<T> options) {
|
||||
deleteAllChildren();
|
||||
allOptions.clear();
|
||||
|
||||
for (T option : options) {
|
||||
IWidget optionWidget = ((ControlListBox) getParent()).createOption(option, 0);
|
||||
if (optionWidget != null) {
|
||||
allOptions.put(option, optionWidget);
|
||||
}
|
||||
}
|
||||
filterOptions();
|
||||
}
|
||||
for (T option : options) {
|
||||
IWidget optionWidget = ((ControlListBox) getParent()).createOption(option, 0);
|
||||
if (optionWidget != null) {
|
||||
allOptions.put(option, optionWidget);
|
||||
}
|
||||
}
|
||||
filterOptions();
|
||||
}
|
||||
|
||||
public void filterOptions() {
|
||||
int height = 0;
|
||||
optionWidgets.clear();
|
||||
public void filterOptions() {
|
||||
int height = 0;
|
||||
optionWidgets.clear();
|
||||
|
||||
for (Map.Entry<T, IWidget> entry : allOptions.entrySet()) {
|
||||
if (isValidOption(entry.getValue())) {
|
||||
entry.getValue().show();
|
||||
optionWidgets.put(entry.getKey(), entry.getValue());
|
||||
entry.getValue().setPosition(new IPoint(0.0f, height));
|
||||
height += (int) entry.getValue().getSize().y();
|
||||
} else {
|
||||
entry.getValue().hide();
|
||||
}
|
||||
}
|
||||
for (Map.Entry<T, IWidget> entry : allOptions.entrySet()) {
|
||||
if (isValidOption(entry.getValue())) {
|
||||
entry.getValue().show();
|
||||
optionWidgets.put(entry.getKey(), entry.getValue());
|
||||
entry.getValue().setPosition(new IPoint(0.0f, height));
|
||||
height += (int) entry.getValue().getSize().y();
|
||||
} else {
|
||||
entry.getValue().hide();
|
||||
}
|
||||
}
|
||||
|
||||
creating = true;
|
||||
setValue(getValue());
|
||||
setSize(new IPoint(getSize().x(), height));
|
||||
}
|
||||
creating = true;
|
||||
setValue(getValue());
|
||||
setSize(new IPoint(getSize().x(), height));
|
||||
}
|
||||
|
||||
public Collection<T> getOptions() {
|
||||
return optionWidgets.keySet();
|
||||
}
|
||||
public Collection<T> getOptions() {
|
||||
return optionWidgets.keySet();
|
||||
}
|
||||
|
||||
public int getIndexOf(T value) {
|
||||
int index = 0;
|
||||
for (T option : getOptions()) {
|
||||
if (option.equals(value)) {
|
||||
return index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public int getIndexOf(T value) {
|
||||
int index = 0;
|
||||
for (T option : getOptions()) {
|
||||
if (option.equals(value)) {
|
||||
return index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getCurrentIndex() {
|
||||
return getIndexOf(getValue());
|
||||
}
|
||||
public int getCurrentIndex() {
|
||||
return getIndexOf(getValue());
|
||||
}
|
||||
|
||||
public void setIndex(int currentIndex) {
|
||||
int index = 0;
|
||||
for (T option : getOptions()) {
|
||||
if (index == currentIndex) {
|
||||
setValue(option);
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
setValue(null);
|
||||
}
|
||||
public void setIndex(int currentIndex) {
|
||||
int index = 0;
|
||||
for (T option : getOptions()) {
|
||||
if (index == currentIndex) {
|
||||
setValue(option);
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
setValue(null);
|
||||
}
|
||||
|
||||
private boolean isValidOption(IWidget widget) {
|
||||
return validator == null || validator.isValid(widget);
|
||||
}
|
||||
private boolean isValidOption(IWidget widget) {
|
||||
return validator == null || validator.isValid(widget);
|
||||
}
|
||||
|
||||
public void setValidator(IValidator<IWidget> validator) {
|
||||
if (this.validator != validator) {
|
||||
this.validator = validator;
|
||||
filterOptions();
|
||||
}
|
||||
}
|
||||
public void setValidator(IValidator<IWidget> validator) {
|
||||
if (this.validator != validator) {
|
||||
this.validator = validator;
|
||||
filterOptions();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,54 +5,53 @@ import binnie.core.craftgui.controls.core.IControlValue;
|
||||
import binnie.core.craftgui.controls.scroll.ControlScrollableContent;
|
||||
import binnie.core.craftgui.events.EventKey;
|
||||
import binnie.core.util.IValidator;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class ControlListBox<T> extends ControlScrollableContent<ControlList<T>> implements IControlValue<T> {
|
||||
public ControlListBox(IWidget parent, float x, float y, float w, float h, float scrollBarSize) {
|
||||
super(parent, x, y, w, h, scrollBarSize);
|
||||
}
|
||||
public ControlListBox(IWidget parent, float x, float y, float w, float h, float scrollBarSize) {
|
||||
super(parent, x, y, w, h, scrollBarSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialise() {
|
||||
setScrollableContent(new ControlList<>(this, 1.0f, 1.0f, w() - 2.0f - scrollBarSize, h() - 2.0f));
|
||||
addEventHandler(new EventKey.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventKey.Down event) {
|
||||
if (calculateIsMouseOver()) {
|
||||
int currentIndex = getContent().getCurrentIndex();
|
||||
if (event.getKey() == 208) {
|
||||
if (++currentIndex >= getContent().getOptions().size()) {
|
||||
currentIndex = 0;
|
||||
}
|
||||
} else if (event.getKey() == 200 && --currentIndex < 0) {
|
||||
currentIndex = getContent().getOptions().size() - 1;
|
||||
}
|
||||
getContent().setIndex(currentIndex);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void initialise() {
|
||||
setScrollableContent(new ControlList<>(this, 1.0f, 1.0f, w() - 2.0f - scrollBarSize, h() - 2.0f));
|
||||
addEventHandler(new EventKey.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventKey.Down event) {
|
||||
if (calculateIsMouseOver()) {
|
||||
int currentIndex = getContent().getCurrentIndex();
|
||||
if (event.getKey() == 208) {
|
||||
if (++currentIndex >= getContent().getOptions().size()) {
|
||||
currentIndex = 0;
|
||||
}
|
||||
} else if (event.getKey() == 200 && --currentIndex < 0) {
|
||||
currentIndex = getContent().getOptions().size() - 1;
|
||||
}
|
||||
getContent().setIndex(currentIndex);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public IWidget createOption(T value, int y) {
|
||||
return new ControlOption<>(getContent(), value, y);
|
||||
}
|
||||
public IWidget createOption(T value, int y) {
|
||||
return new ControlOption<>(getContent(), value, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return getContent().getValue();
|
||||
}
|
||||
@Override
|
||||
public T getValue() {
|
||||
return getContent().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
getContent().setValue(value);
|
||||
}
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
getContent().setValue(value);
|
||||
}
|
||||
|
||||
public void setOptions(Collection<T> options) {
|
||||
getContent().setOptions(options);
|
||||
}
|
||||
public void setOptions(Collection<T> options) {
|
||||
getContent().setOptions(options);
|
||||
}
|
||||
|
||||
public void setValidator(IValidator<IWidget> validator) {
|
||||
getContent().setValidator(validator);
|
||||
}
|
||||
public void setValidator(IValidator<IWidget> validator) {
|
||||
getContent().setValidator(validator);
|
||||
}
|
||||
}
|
||||
@@ -8,60 +8,59 @@ import binnie.core.craftgui.events.EventMouse;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
|
||||
public class ControlOption<T> extends Control implements IControlValue<T> {
|
||||
protected T value;
|
||||
protected T value;
|
||||
|
||||
public ControlOption(ControlList<T> controlList, T option) {
|
||||
this(controlList, option, 16);
|
||||
}
|
||||
public ControlOption(ControlList<T> controlList, T option) {
|
||||
this(controlList, option, 16);
|
||||
}
|
||||
|
||||
public ControlOption(ControlList<T> controlList, T option, int height) {
|
||||
super(controlList, 0.0f, height, controlList.getSize().x(), 20.0f);
|
||||
value = option;
|
||||
if (value != null) {
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
}
|
||||
addSelfEventHandler(mouseHandler);
|
||||
}
|
||||
public ControlOption(ControlList<T> controlList, T option, int height) {
|
||||
super(controlList, 0.0f, height, controlList.getSize().x(), 20.0f);
|
||||
value = option;
|
||||
if (value != null) {
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
}
|
||||
addSelfEventHandler(mouseHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
if (getValue() == null) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
if (getValue() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int color = 0xa0a0a0;
|
||||
if (isCurrentSelection()) {
|
||||
color = 0xffffff;
|
||||
}
|
||||
setColor(color);
|
||||
}
|
||||
int color = 0xa0a0a0;
|
||||
if (isCurrentSelection()) {
|
||||
color = 0xffffff;
|
||||
}
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
private EventMouse.Down.Handler mouseHandler = new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
((IControlValue) getParent()).setValue(getValue());
|
||||
}
|
||||
};
|
||||
private EventMouse.Down.Handler mouseHandler = new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
((IControlValue) getParent()).setValue(getValue());
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
if (isCurrentSelection()) {
|
||||
CraftGUI.render.texture(CraftGUITexture.Outline, getArea());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
if (isCurrentSelection()) {
|
||||
CraftGUI.render.texture(CraftGUITexture.Outline, getArea());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
@Override
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean isCurrentSelection() {
|
||||
return getValue() != null
|
||||
&& getValue().equals(((IControlValue) getParent()).getValue());
|
||||
}
|
||||
public boolean isCurrentSelection() {
|
||||
return getValue() != null && getValue().equals(((IControlValue) getParent()).getValue());
|
||||
}
|
||||
}
|
||||
@@ -6,29 +6,29 @@ import binnie.core.craftgui.events.EventWidget;
|
||||
import binnie.core.craftgui.geometry.TextJustification;
|
||||
|
||||
public class ControlTextOption<T> extends ControlOption<T> {
|
||||
protected ControlText textWidget;
|
||||
protected ControlText textWidget;
|
||||
|
||||
public ControlTextOption(ControlList<T> controlList, T option, String optionName, int y) {
|
||||
super(controlList, option, y);
|
||||
textWidget = null;
|
||||
textWidget = new ControlText(this, getArea(), optionName, TextJustification.MIDDLE_CENTER);
|
||||
public ControlTextOption(ControlList<T> controlList, T option, String optionName, int y) {
|
||||
super(controlList, option, y);
|
||||
textWidget = null;
|
||||
textWidget = new ControlText(this, getArea(), optionName, TextJustification.MIDDLE_CENTER);
|
||||
|
||||
mouseHandler.setOrigin(EventHandler.Origin.Self, this);
|
||||
addEventHandler(mouseHandler);
|
||||
}
|
||||
mouseHandler.setOrigin(EventHandler.Origin.Self, this);
|
||||
addEventHandler(mouseHandler);
|
||||
}
|
||||
|
||||
public ControlTextOption(ControlList<T> controlList, T option, int y) {
|
||||
this(controlList, option, option.toString(), y);
|
||||
}
|
||||
public ControlTextOption(ControlList<T> controlList, T option, int y) {
|
||||
this(controlList, option, option.toString(), y);
|
||||
}
|
||||
|
||||
private EventWidget.ChangeColour.Handler mouseHandler = new EventWidget.ChangeColour.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventWidget.ChangeColour event) {
|
||||
textWidget.setColor(getColor());
|
||||
}
|
||||
};
|
||||
private EventWidget.ChangeColour.Handler mouseHandler = new EventWidget.ChangeColour.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventWidget.ChangeColour event) {
|
||||
textWidget.setColor(getColor());
|
||||
}
|
||||
};
|
||||
|
||||
public String getText() {
|
||||
return textWidget.getValue();
|
||||
}
|
||||
public String getText() {
|
||||
return textWidget.getValue();
|
||||
}
|
||||
}
|
||||
@@ -5,27 +5,27 @@ import binnie.core.craftgui.controls.core.Control;
|
||||
import binnie.core.craftgui.controls.core.IControlValue;
|
||||
|
||||
public class ControlPage<T> extends Control implements IControlValue<T> {
|
||||
protected T value;
|
||||
protected T value;
|
||||
|
||||
public ControlPage(IWidget parent, T value) {
|
||||
this(parent, 0.0f, 0.0f, parent.w(), parent.h(), value);
|
||||
}
|
||||
public ControlPage(IWidget parent, T value) {
|
||||
this(parent, 0.0f, 0.0f, parent.w(), parent.h(), value);
|
||||
}
|
||||
|
||||
public ControlPage(IWidget parent, float x, float y, float w, float h, T value) {
|
||||
super(parent, x, y, w, h);
|
||||
setValue(value);
|
||||
if (parent instanceof IControlValue && ((IControlValue) parent).getValue() == null) {
|
||||
((IControlValue) parent).setValue(value);
|
||||
}
|
||||
}
|
||||
public ControlPage(IWidget parent, float x, float y, float w, float h, T value) {
|
||||
super(parent, x, y, w, h);
|
||||
setValue(value);
|
||||
if (parent instanceof IControlValue && ((IControlValue) parent).getValue() == null) {
|
||||
((IControlValue) parent).setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
@Override
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -5,53 +5,52 @@ import binnie.core.craftgui.controls.core.Control;
|
||||
import binnie.core.craftgui.controls.core.IControlValue;
|
||||
import binnie.core.craftgui.controls.core.IControlValues;
|
||||
import binnie.core.craftgui.events.EventValueChanged;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ControlPages<T> extends Control implements IControlValues<T>, IControlValue<T> {
|
||||
protected T value;
|
||||
protected T value;
|
||||
|
||||
public ControlPages(IWidget parent, float x, float y, float w, float h) {
|
||||
super(parent, x, y, w, h);
|
||||
value = null;
|
||||
}
|
||||
public ControlPages(IWidget parent, float x, float y, float w, float h) {
|
||||
super(parent, x, y, w, h);
|
||||
value = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddChild(IWidget widget) {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void onAddChild(IWidget widget) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
@Override
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
if (this.value != value) {
|
||||
this.value = value;
|
||||
callEvent(new EventValueChanged<Object>(this, value));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
if (this.value != value) {
|
||||
this.value = value;
|
||||
callEvent(new EventValueChanged<Object>(this, value));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<T> getValues() {
|
||||
List<T> list = new ArrayList<>();
|
||||
for (IWidget child : getWidgets()) {
|
||||
list.add((T) ((IControlValue) child).getValue());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@Override
|
||||
public Collection<T> getValues() {
|
||||
List<T> list = new ArrayList<>();
|
||||
for (IWidget child : getWidgets()) {
|
||||
list.add((T) ((IControlValue) child).getValue());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValues(Collection<T> values) {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void setValues(Collection<T> values) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildVisible(IWidget child) {
|
||||
return child != null && value == ((IControlValue) child).getValue();
|
||||
}
|
||||
@Override
|
||||
public boolean isChildVisible(IWidget child) {
|
||||
return child != null && value == ((IControlValue) child).getValue();
|
||||
}
|
||||
}
|
||||
@@ -4,15 +4,15 @@ import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlScroll extends Control {
|
||||
private IControlScrollable scrollWidget;
|
||||
private IControlScrollable scrollWidget;
|
||||
|
||||
public ControlScroll(IWidget parent, float x, float y, float width, float height, IControlScrollable scrollWidget) {
|
||||
super(parent, x, y, width, height);
|
||||
this.scrollWidget = scrollWidget;
|
||||
new ControlScrollBar(this);
|
||||
}
|
||||
public ControlScroll(IWidget parent, float x, float y, float width, float height, IControlScrollable scrollWidget) {
|
||||
super(parent, x, y, width, height);
|
||||
this.scrollWidget = scrollWidget;
|
||||
new ControlScrollBar(this);
|
||||
}
|
||||
|
||||
public IControlScrollable getScrollableWidget() {
|
||||
return scrollWidget;
|
||||
}
|
||||
public IControlScrollable getScrollableWidget() {
|
||||
return scrollWidget;
|
||||
}
|
||||
}
|
||||
@@ -9,77 +9,77 @@ import binnie.core.craftgui.geometry.IArea;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
|
||||
public class ControlScrollBar extends Control {
|
||||
protected IControlScrollable scrollable;
|
||||
protected IControlScrollable scrollable;
|
||||
|
||||
public ControlScrollBar(ControlScroll parent) {
|
||||
this(parent, 0.0f, 0.0f, parent.getSize().x(), parent.getSize().y(), parent.getScrollableWidget());
|
||||
}
|
||||
public ControlScrollBar(ControlScroll parent) {
|
||||
this(parent, 0.0f, 0.0f, parent.getSize().x(), parent.getSize().y(), parent.getScrollableWidget());
|
||||
}
|
||||
|
||||
public ControlScrollBar(IWidget parent, float x, float y, float w, float h, IControlScrollable scrollable2) {
|
||||
super(parent, x, y, w, h);
|
||||
scrollable = scrollable2;
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
addSelfEventHandler(new EventMouse.Drag.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Drag event) {
|
||||
scrollable.movePercentage(event.getDy() / (h() - getBarHeight()));
|
||||
}
|
||||
});
|
||||
addSelfEventHandler(mouseDownHandler);
|
||||
}
|
||||
public ControlScrollBar(IWidget parent, float x, float y, float w, float h, IControlScrollable scrollable2) {
|
||||
super(parent, x, y, w, h);
|
||||
scrollable = scrollable2;
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
addSelfEventHandler(new EventMouse.Drag.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Drag event) {
|
||||
scrollable.movePercentage(event.getDy() / (h() - getBarHeight()));
|
||||
}
|
||||
});
|
||||
addSelfEventHandler(mouseDownHandler);
|
||||
}
|
||||
|
||||
private EventMouse.Down.Handler mouseDownHandler = new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
float shownPercentage = scrollable.getPercentageShown();
|
||||
float percentageIndex = scrollable.getPercentageIndex();
|
||||
float minPercent = (1.0f - shownPercentage) * percentageIndex;
|
||||
float maxPercent = minPercent + shownPercentage;
|
||||
float clickedPercentage = getRelativeMousePosition().y() / (h() - 2.0f);
|
||||
clickedPercentage = Math.max(Math.min(clickedPercentage, 1.0f), 0.0f);
|
||||
private EventMouse.Down.Handler mouseDownHandler = new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
float shownPercentage = scrollable.getPercentageShown();
|
||||
float percentageIndex = scrollable.getPercentageIndex();
|
||||
float minPercent = (1.0f - shownPercentage) * percentageIndex;
|
||||
float maxPercent = minPercent + shownPercentage;
|
||||
float clickedPercentage = getRelativeMousePosition().y() / (h() - 2.0f);
|
||||
clickedPercentage = Math.max(Math.min(clickedPercentage, 1.0f), 0.0f);
|
||||
|
||||
if (clickedPercentage > maxPercent) {
|
||||
scrollable.setPercentageIndex((clickedPercentage - shownPercentage) / (1.0f - shownPercentage));
|
||||
}
|
||||
if (clickedPercentage < minPercent) {
|
||||
scrollable.setPercentageIndex(clickedPercentage / (1.0f - shownPercentage));
|
||||
}
|
||||
}
|
||||
};
|
||||
if (clickedPercentage > maxPercent) {
|
||||
scrollable.setPercentageIndex((clickedPercentage - shownPercentage) / (1.0f - shownPercentage));
|
||||
}
|
||||
if (clickedPercentage < minPercent) {
|
||||
scrollable.setPercentageIndex(clickedPercentage / (1.0f - shownPercentage));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
IArea renderArea = getRenderArea();
|
||||
Object texture = CraftGUITexture.ScrollDisabled;
|
||||
if (isMouseOver()) {
|
||||
texture = CraftGUITexture.ScrollHighlighted;
|
||||
} else if (isEnabled()) {
|
||||
texture = CraftGUITexture.Scroll;
|
||||
}
|
||||
CraftGUI.render.texture(texture, renderArea);
|
||||
}
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
IArea renderArea = getRenderArea();
|
||||
Object texture = CraftGUITexture.ScrollDisabled;
|
||||
if (isMouseOver()) {
|
||||
texture = CraftGUITexture.ScrollHighlighted;
|
||||
} else if (isEnabled()) {
|
||||
texture = CraftGUITexture.Scroll;
|
||||
}
|
||||
CraftGUI.render.texture(texture, renderArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return scrollable.getPercentageShown() < 0.99f;
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return scrollable.getPercentageShown() < 0.99f;
|
||||
}
|
||||
|
||||
public float getBarHeight() {
|
||||
return h() * scrollable.getPercentageShown();
|
||||
}
|
||||
public float getBarHeight() {
|
||||
return h() * scrollable.getPercentageShown();
|
||||
}
|
||||
|
||||
protected IArea getRenderArea() {
|
||||
float height = getBarHeight();
|
||||
if (height < 6.0f) {
|
||||
height = 6.0f;
|
||||
}
|
||||
protected IArea getRenderArea() {
|
||||
float height = getBarHeight();
|
||||
if (height < 6.0f) {
|
||||
height = 6.0f;
|
||||
}
|
||||
|
||||
float yOffset = ((int) h() - (int) getBarHeight()) * scrollable.getPercentageIndex();
|
||||
return new IArea(0.0f, yOffset, getSize().x(), height);
|
||||
}
|
||||
float yOffset = ((int) h() - (int) getBarHeight()) * scrollable.getPercentageIndex();
|
||||
return new IArea(0.0f, yOffset, getSize().x(), height);
|
||||
}
|
||||
}
|
||||
+117
-102
@@ -8,122 +8,137 @@ import binnie.core.craftgui.geometry.IArea;
|
||||
import binnie.core.craftgui.geometry.IPoint;
|
||||
|
||||
public class ControlScrollableContent<T extends IWidget> extends Control implements IControlScrollable {
|
||||
protected T controlChild;
|
||||
protected float scrollBarSize;
|
||||
protected float percentageIndex;
|
||||
protected T controlChild;
|
||||
protected float scrollBarSize;
|
||||
protected float percentageIndex;
|
||||
|
||||
public ControlScrollableContent(IWidget parent, float x, float y, float w, float h, float scrollBarSize) {
|
||||
super(parent, x, y, w, h);
|
||||
this.scrollBarSize = scrollBarSize;
|
||||
if (scrollBarSize != 0.0f) {
|
||||
new ControlScroll(this, getSize().x() - scrollBarSize, 0.0f, scrollBarSize, getSize().y(), this);
|
||||
}
|
||||
public ControlScrollableContent(IWidget parent, float x, float y, float w, float h, float scrollBarSize) {
|
||||
super(parent, x, y, w, h);
|
||||
this.scrollBarSize = scrollBarSize;
|
||||
if (scrollBarSize != 0.0f) {
|
||||
new ControlScroll(
|
||||
this,
|
||||
getSize().x() - scrollBarSize,
|
||||
0.0f,
|
||||
scrollBarSize,
|
||||
getSize().y(),
|
||||
this);
|
||||
}
|
||||
|
||||
percentageIndex = 0.0f;
|
||||
addEventHandler(mouseWheelHandler);
|
||||
}
|
||||
percentageIndex = 0.0f;
|
||||
addEventHandler(mouseWheelHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
setPercentageIndex(getPercentageIndex());
|
||||
}
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
setPercentageIndex(getPercentageIndex());
|
||||
}
|
||||
|
||||
private EventMouse.Wheel.Handler mouseWheelHandler = new EventMouse.Wheel.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Wheel event) {
|
||||
IPoint mousePos = getRelativeMousePosition();
|
||||
if (mousePos.x() > 0.0f && mousePos.y() > 0.0f && mousePos.x() < getSize().x() && mousePos.y() < getSize().y()) {
|
||||
if (getMovementRange() == 0.0f) {
|
||||
return;
|
||||
}
|
||||
float percentageMove = 0.8f / getMovementRange();
|
||||
movePercentage(percentageMove * -event.getDWheel());
|
||||
}
|
||||
}
|
||||
};
|
||||
private EventMouse.Wheel.Handler mouseWheelHandler = new EventMouse.Wheel.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Wheel event) {
|
||||
IPoint mousePos = getRelativeMousePosition();
|
||||
if (mousePos.x() > 0.0f
|
||||
&& mousePos.y() > 0.0f
|
||||
&& mousePos.x() < getSize().x()
|
||||
&& mousePos.y() < getSize().y()) {
|
||||
if (getMovementRange() == 0.0f) {
|
||||
return;
|
||||
}
|
||||
float percentageMove = 0.8f / getMovementRange();
|
||||
movePercentage(percentageMove * -event.getDWheel());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void setScrollableContent(T child) {
|
||||
controlChild = child;
|
||||
if (child == null) {
|
||||
return;
|
||||
}
|
||||
public void setScrollableContent(T child) {
|
||||
controlChild = child;
|
||||
if (child == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
child.setCroppedZone(this, new IArea(1.0F, 1.0F, getSize().x() - 2.0F - scrollBarSize, getSize().y() - 2.0F));
|
||||
child.addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventWidget.ChangeSize event) {
|
||||
controlChild.setOffset(new IPoint(0.0f, -percentageIndex * getMovementRange()));
|
||||
if (getMovementRange() == 0.0f) {
|
||||
percentageIndex = 0.0f;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
child.setCroppedZone(
|
||||
this,
|
||||
new IArea(
|
||||
1.0F,
|
||||
1.0F,
|
||||
getSize().x() - 2.0F - scrollBarSize,
|
||||
getSize().y() - 2.0F));
|
||||
child.addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventWidget.ChangeSize event) {
|
||||
controlChild.setOffset(new IPoint(0.0f, -percentageIndex * getMovementRange()));
|
||||
if (getMovementRange() == 0.0f) {
|
||||
percentageIndex = 0.0f;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public T getContent() {
|
||||
return controlChild;
|
||||
}
|
||||
public T getContent() {
|
||||
return controlChild;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPercentageShown() {
|
||||
if (controlChild == null || controlChild.getSize().y() == 0.0f) {
|
||||
return 1.0f;
|
||||
}
|
||||
float shown = getSize().y() / controlChild.getSize().y();
|
||||
return Math.min(shown, 1.0f);
|
||||
}
|
||||
@Override
|
||||
public float getPercentageShown() {
|
||||
if (controlChild == null || controlChild.getSize().y() == 0.0f) {
|
||||
return 1.0f;
|
||||
}
|
||||
float shown = getSize().y() / controlChild.getSize().y();
|
||||
return Math.min(shown, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPercentageIndex() {
|
||||
return percentageIndex;
|
||||
}
|
||||
@Override
|
||||
public float getPercentageIndex() {
|
||||
return percentageIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void movePercentage(float percentage) {
|
||||
if (controlChild == null) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void movePercentage(float percentage) {
|
||||
if (controlChild == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
percentageIndex += percentage;
|
||||
if (percentageIndex > 1.0f) {
|
||||
percentageIndex = 1.0f;
|
||||
} else if (percentageIndex < 0.0f) {
|
||||
percentageIndex = 0.0f;
|
||||
}
|
||||
percentageIndex += percentage;
|
||||
if (percentageIndex > 1.0f) {
|
||||
percentageIndex = 1.0f;
|
||||
} else if (percentageIndex < 0.0f) {
|
||||
percentageIndex = 0.0f;
|
||||
}
|
||||
|
||||
if (getMovementRange() == 0.0f) {
|
||||
percentageIndex = 0.0f;
|
||||
}
|
||||
controlChild.setOffset(new IPoint(0.0f, -percentageIndex * getMovementRange()));
|
||||
}
|
||||
if (getMovementRange() == 0.0f) {
|
||||
percentageIndex = 0.0f;
|
||||
}
|
||||
controlChild.setOffset(new IPoint(0.0f, -percentageIndex * getMovementRange()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPercentageIndex(float index) {
|
||||
movePercentage(index - percentageIndex);
|
||||
}
|
||||
@Override
|
||||
public void setPercentageIndex(float index) {
|
||||
movePercentage(index - percentageIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMovementRange() {
|
||||
if (controlChild == null) {
|
||||
return 0.0f;
|
||||
}
|
||||
float range = controlChild.getSize().y() - getSize().y();
|
||||
return Math.max(range, 0.0f);
|
||||
}
|
||||
@Override
|
||||
public float getMovementRange() {
|
||||
if (controlChild == null) {
|
||||
return 0.0f;
|
||||
}
|
||||
float range = controlChild.getSize().y() - getSize().y();
|
||||
return Math.max(range, 0.0f);
|
||||
}
|
||||
|
||||
public void ensureVisible(float minY, float maxY, float totalY) {
|
||||
minY /= totalY;
|
||||
maxY /= totalY;
|
||||
float shownPercentage = getPercentageShown();
|
||||
float percentageIndex = getPercentageIndex();
|
||||
float minPercent = (1.0f - shownPercentage) * percentageIndex;
|
||||
float maxPercent = minPercent + shownPercentage;
|
||||
public void ensureVisible(float minY, float maxY, float totalY) {
|
||||
minY /= totalY;
|
||||
maxY /= totalY;
|
||||
float shownPercentage = getPercentageShown();
|
||||
float percentageIndex = getPercentageIndex();
|
||||
float minPercent = (1.0f - shownPercentage) * percentageIndex;
|
||||
float maxPercent = minPercent + shownPercentage;
|
||||
|
||||
if (maxY > maxPercent) {
|
||||
setPercentageIndex((maxY - shownPercentage) / (1.0f - shownPercentage));
|
||||
}
|
||||
if (minY < minPercent) {
|
||||
setPercentageIndex(minY / (1.0f - shownPercentage));
|
||||
}
|
||||
}
|
||||
if (maxY > maxPercent) {
|
||||
setPercentageIndex((maxY - shownPercentage) / (1.0f - shownPercentage));
|
||||
}
|
||||
if (minY < minPercent) {
|
||||
setPercentageIndex(minY / (1.0f - shownPercentage));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,13 @@ package binnie.core.craftgui.controls.scroll;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
|
||||
public interface IControlScrollable extends IWidget {
|
||||
float getPercentageShown();
|
||||
float getPercentageShown();
|
||||
|
||||
float getPercentageIndex();
|
||||
float getPercentageIndex();
|
||||
|
||||
void movePercentage(float percentage);
|
||||
void movePercentage(float percentage);
|
||||
|
||||
void setPercentageIndex(float index);
|
||||
void setPercentageIndex(float index);
|
||||
|
||||
float getMovementRange();
|
||||
float getMovementRange();
|
||||
}
|
||||
@@ -17,94 +17,94 @@ import binnie.core.craftgui.resource.Texture;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
|
||||
public class ControlTab<T> extends Control implements ITooltip, IControlValue<T> {
|
||||
protected T value;
|
||||
protected T value;
|
||||
|
||||
private ControlTabBar<T> tabBar;
|
||||
private ControlTabBar<T> tabBar;
|
||||
|
||||
public ControlTab(ControlTabBar<T> parent, float x, float y, float w, float h, T value) {
|
||||
super(parent, x, y, w, h);
|
||||
setValue(value);
|
||||
tabBar = parent;
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
callEvent(new EventValueChanged<Object>(getWidget(), getValue()));
|
||||
}
|
||||
});
|
||||
}
|
||||
public ControlTab(ControlTabBar<T> parent, float x, float y, float w, float h, T value) {
|
||||
super(parent, x, y, w, h);
|
||||
setValue(value);
|
||||
tabBar = parent;
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
callEvent(new EventValueChanged<Object>(getWidget(), getValue()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
Object texture = CraftGUITexture.TabDisabled;
|
||||
if (isMouseOver()) {
|
||||
texture = CraftGUITexture.TabHighlighted;
|
||||
} else if (isCurrentSelection()) {
|
||||
texture = CraftGUITexture.Tab;
|
||||
}
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
Object texture = CraftGUITexture.TabDisabled;
|
||||
if (isMouseOver()) {
|
||||
texture = CraftGUITexture.TabHighlighted;
|
||||
} else if (isCurrentSelection()) {
|
||||
texture = CraftGUITexture.Tab;
|
||||
}
|
||||
|
||||
Texture lTexture = CraftGUI.render.getTexture(texture);
|
||||
Position position = getTabPosition();
|
||||
Texture iTexture = lTexture.crop(position, 8.0f);
|
||||
IArea area = getArea();
|
||||
if (texture == CraftGUITexture.TabDisabled) {
|
||||
if (position == Position.TOP || position == Position.LEFT) {
|
||||
area.setPosition(area.getPosition().sub(new IPoint(4 * position.x(), 4 * position.y())));
|
||||
area.setSize(area.getSize().add(new IPoint(4 * position.x(), 4 * position.y())));
|
||||
} else {
|
||||
area.setSize(area.getSize().sub(new IPoint(4 * position.x(), 4 * position.y())));
|
||||
}
|
||||
}
|
||||
Texture lTexture = CraftGUI.render.getTexture(texture);
|
||||
Position position = getTabPosition();
|
||||
Texture iTexture = lTexture.crop(position, 8.0f);
|
||||
IArea area = getArea();
|
||||
if (texture == CraftGUITexture.TabDisabled) {
|
||||
if (position == Position.TOP || position == Position.LEFT) {
|
||||
area.setPosition(area.getPosition().sub(new IPoint(4 * position.x(), 4 * position.y())));
|
||||
area.setSize(area.getSize().add(new IPoint(4 * position.x(), 4 * position.y())));
|
||||
} else {
|
||||
area.setSize(area.getSize().sub(new IPoint(4 * position.x(), 4 * position.y())));
|
||||
}
|
||||
}
|
||||
|
||||
CraftGUI.render.texture(iTexture, area);
|
||||
if (this instanceof ControlTabIcon) {
|
||||
ControlTabIcon icon = (ControlTabIcon) this;
|
||||
ControlItemDisplay item = (ControlItemDisplay) getWidgets().get(0);
|
||||
if (texture == CraftGUITexture.TabDisabled) {
|
||||
item.setColor(0xaaaaaaaa);
|
||||
} else {
|
||||
item.setColor(0xffffffff);
|
||||
}
|
||||
CraftGUI.render.texture(iTexture, area);
|
||||
if (this instanceof ControlTabIcon) {
|
||||
ControlTabIcon icon = (ControlTabIcon) this;
|
||||
ControlItemDisplay item = (ControlItemDisplay) getWidgets().get(0);
|
||||
if (texture == CraftGUITexture.TabDisabled) {
|
||||
item.setColor(0xaaaaaaaa);
|
||||
} else {
|
||||
item.setColor(0xffffffff);
|
||||
}
|
||||
|
||||
if (icon.hasOutline()) {
|
||||
iTexture = CraftGUI.render.getTexture(CraftGUITexture.TabOutline);
|
||||
iTexture = iTexture.crop(position, 8.0f);
|
||||
CraftGUI.render.color(icon.getOutlineColor());
|
||||
CraftGUI.render.texture(iTexture, area.inset(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (icon.hasOutline()) {
|
||||
iTexture = CraftGUI.render.getTexture(CraftGUITexture.TabOutline);
|
||||
iTexture = iTexture.crop(position, 8.0f);
|
||||
CraftGUI.render.color(icon.getOutlineColor());
|
||||
CraftGUI.render.texture(iTexture, area.inset(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
String name = getName();
|
||||
if (name != null && !name.isEmpty()) {
|
||||
tooltip.add(getName());
|
||||
}
|
||||
if (value instanceof ITooltip) {
|
||||
((ITooltip) value).getTooltip(tooltip);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
String name = getName();
|
||||
if (name != null && !name.isEmpty()) {
|
||||
tooltip.add(getName());
|
||||
}
|
||||
if (value instanceof ITooltip) {
|
||||
((ITooltip) value).getTooltip(tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
@Override
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Position getTabPosition() {
|
||||
return tabBar.position;
|
||||
}
|
||||
public Position getTabPosition() {
|
||||
return tabBar.position;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return value.toString();
|
||||
}
|
||||
public String getName() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public boolean isCurrentSelection() {
|
||||
return getValue() != null && getValue().equals(tabBar.getValue());
|
||||
}
|
||||
public boolean isCurrentSelection() {
|
||||
return getValue() != null && getValue().equals(tabBar.getValue());
|
||||
}
|
||||
}
|
||||
@@ -6,70 +6,70 @@ import binnie.core.craftgui.controls.core.IControlValue;
|
||||
import binnie.core.craftgui.events.EventHandler;
|
||||
import binnie.core.craftgui.events.EventValueChanged;
|
||||
import binnie.core.craftgui.geometry.Position;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class ControlTabBar<T> extends Control implements IControlValue<T> {
|
||||
protected T value;
|
||||
protected Position position;
|
||||
protected T value;
|
||||
protected Position position;
|
||||
|
||||
public ControlTabBar(IWidget parent, float x, float y, float width, float height, Position position) {
|
||||
super(parent, x, y, width, height);
|
||||
this.position = position;
|
||||
addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
setValue((T) event.getValue());
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.DirectChild, this));
|
||||
}
|
||||
public ControlTabBar(IWidget parent, float x, float y, float width, float height, Position position) {
|
||||
super(parent, x, y, width, height);
|
||||
this.position = position;
|
||||
addEventHandler(
|
||||
new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
setValue((T) event.getValue());
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.DirectChild, this));
|
||||
}
|
||||
|
||||
public ControlTab<T> createTab(float x, float y, float w, float h, T value) {
|
||||
return new ControlTab<>(this, x, y, w, h, value);
|
||||
}
|
||||
public ControlTab<T> createTab(float x, float y, float w, float h, T value) {
|
||||
return new ControlTab<>(this, x, y, w, h, value);
|
||||
}
|
||||
|
||||
public void setValues(Collection<T> values) {
|
||||
int i = 0;
|
||||
while (i < getWidgets().size()) {
|
||||
deleteChild(getWidgets().get(0));
|
||||
}
|
||||
public void setValues(Collection<T> values) {
|
||||
int i = 0;
|
||||
while (i < getWidgets().size()) {
|
||||
deleteChild(getWidgets().get(0));
|
||||
}
|
||||
|
||||
float length = values.size();
|
||||
int tabDimension = (int) (getSize().y() / length);
|
||||
if (position == Position.TOP || position == Position.BOTTOM) {
|
||||
tabDimension = (int) (getSize().x() / length);
|
||||
}
|
||||
float length = values.size();
|
||||
int tabDimension = (int) (getSize().y() / length);
|
||||
if (position == Position.TOP || position == Position.BOTTOM) {
|
||||
tabDimension = (int) (getSize().x() / length);
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
for (T value : values) {
|
||||
if (position == Position.TOP || position == Position.BOTTOM) {
|
||||
createTab(j * tabDimension, 0.0f, tabDimension, getSize().y(), value);
|
||||
} else {
|
||||
createTab(0.0f, j * tabDimension, getSize().x(), tabDimension, value);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
int j = 0;
|
||||
for (T value : values) {
|
||||
if (position == Position.TOP || position == Position.BOTTOM) {
|
||||
createTab(j * tabDimension, 0.0f, tabDimension, getSize().y(), value);
|
||||
} else {
|
||||
createTab(0.0f, j * tabDimension, getSize().x(), tabDimension, value);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
|
||||
if (value == null && !values.isEmpty()) {
|
||||
setValue(values.iterator().next());
|
||||
}
|
||||
}
|
||||
if (value == null && !values.isEmpty()) {
|
||||
setValue(values.iterator().next());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
@Override
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
boolean change = this.value != value;
|
||||
this.value = value;
|
||||
if (change) {
|
||||
callEvent(new EventValueChanged<Object>(this, value));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
boolean change = this.value != value;
|
||||
this.value = value;
|
||||
if (change) {
|
||||
callEvent(new EventValueChanged<Object>(this, value));
|
||||
}
|
||||
}
|
||||
|
||||
public Position getDirection() {
|
||||
return position;
|
||||
}
|
||||
public Position getDirection() {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,12 @@ import binnie.core.craftgui.controls.listbox.ControlListBox;
|
||||
import forestry.api.genetics.IClassification;
|
||||
|
||||
class ControlBranchBox extends ControlListBox<IClassification> {
|
||||
@Override
|
||||
public IWidget createOption(IClassification value, int y) {
|
||||
return new ControlBranchBoxOption(getContent(), value, y);
|
||||
}
|
||||
@Override
|
||||
public IWidget createOption(IClassification value, int y) {
|
||||
return new ControlBranchBoxOption(getContent(), value, y);
|
||||
}
|
||||
|
||||
public ControlBranchBox(IWidget parent, float x, float y, float width, float height) {
|
||||
super(parent, x, y, width, height, 12.0f);
|
||||
}
|
||||
public ControlBranchBox(IWidget parent, float x, float y, float width, float height) {
|
||||
super(parent, x, y, width, height, 12.0f);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,13 @@ import binnie.core.craftgui.controls.listbox.ControlTextOption;
|
||||
import forestry.api.genetics.IClassification;
|
||||
|
||||
class ControlBranchBoxOption extends ControlTextOption<IClassification> {
|
||||
public ControlBranchBoxOption(ControlList<IClassification> controlList, IClassification option, int y) {
|
||||
super(controlList, option, (option.getName() == null) ? option.getScientific() : (option.getName().contains(".") ? option.getScientific() : option.getName()), y);
|
||||
}
|
||||
public ControlBranchBoxOption(ControlList<IClassification> controlList, IClassification option, int y) {
|
||||
super(
|
||||
controlList,
|
||||
option,
|
||||
(option.getName() == null)
|
||||
? option.getScientific()
|
||||
: (option.getName().contains(".") ? option.getScientific() : option.getName()),
|
||||
y);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
package binnie.core.craftgui.database;
|
||||
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
@@ -13,22 +12,23 @@ import binnie.core.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
|
||||
class ControlBreedingProgress extends Control {
|
||||
private static Texture Progress = new StandardTexture(80, 22, 4, 4, CraftGUITextureSheet.Controls2);
|
||||
private float percentage;
|
||||
private int colour;
|
||||
private static Texture Progress = new StandardTexture(80, 22, 4, 4, CraftGUITextureSheet.Controls2);
|
||||
private float percentage;
|
||||
private int colour;
|
||||
|
||||
public ControlBreedingProgress(IWidget parent, int x, int y, int width, int height, BreedingSystem system, float percentage) {
|
||||
super(parent, x, y, width, height);
|
||||
this.percentage = percentage;
|
||||
colour = system.getColor();
|
||||
}
|
||||
public ControlBreedingProgress(
|
||||
IWidget parent, int x, int y, int width, int height, BreedingSystem system, float percentage) {
|
||||
super(parent, x, y, width, height);
|
||||
this.percentage = percentage;
|
||||
colour = system.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.render.texture(CraftGUITexture.PanelBlack, getArea());
|
||||
IArea area = getArea().inset(1);
|
||||
area.setSize(new IPoint(area.size().x() * percentage, area.size().y()));
|
||||
CraftGUI.render.color(colour);
|
||||
CraftGUI.render.texture(ControlBreedingProgress.Progress, area);
|
||||
}
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.render.texture(CraftGUITexture.PanelBlack, getArea());
|
||||
IArea area = getArea().inset(1);
|
||||
area.setSize(new IPoint(area.size().x() * percentage, area.size().y()));
|
||||
CraftGUI.render.color(colour);
|
||||
CraftGUI.render.texture(ControlBreedingProgress.Progress, area);
|
||||
}
|
||||
}
|
||||
@@ -19,96 +19,97 @@ import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class ControlDatabaseIndividualDisplay extends ControlItemDisplay implements ITooltip {
|
||||
protected EnumDiscoveryState discovered;
|
||||
protected EnumDiscoveryState discovered;
|
||||
|
||||
private IAlleleSpecies species;
|
||||
private IAlleleSpecies species;
|
||||
|
||||
public void setSpecies(IAlleleSpecies species) {
|
||||
setSpecies(species, EnumDiscoveryState.SHOW);
|
||||
}
|
||||
public void setSpecies(IAlleleSpecies species) {
|
||||
setSpecies(species, EnumDiscoveryState.SHOW);
|
||||
}
|
||||
|
||||
public void setSpecies(IAlleleSpecies species, EnumDiscoveryState state) {
|
||||
this.species = species;
|
||||
ISpeciesRoot speciesRoot = Binnie.Genetics.getSpeciesRoot(species);
|
||||
BreedingSystem system = Binnie.Genetics.getSystem(speciesRoot.getUID());
|
||||
IIndividual ind = system.getSpeciesRoot().templateAsIndividual(system.getSpeciesRoot().getTemplate(species.getUID()));
|
||||
super.setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType()));
|
||||
Window window = Window.get(this);
|
||||
GameProfile username = window.getUsername();
|
||||
public void setSpecies(IAlleleSpecies species, EnumDiscoveryState state) {
|
||||
this.species = species;
|
||||
ISpeciesRoot speciesRoot = Binnie.Genetics.getSpeciesRoot(species);
|
||||
BreedingSystem system = Binnie.Genetics.getSystem(speciesRoot.getUID());
|
||||
IIndividual ind = system.getSpeciesRoot()
|
||||
.templateAsIndividual(system.getSpeciesRoot().getTemplate(species.getUID()));
|
||||
super.setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType()));
|
||||
Window window = Window.get(this);
|
||||
GameProfile username = window.getUsername();
|
||||
|
||||
if (window instanceof WindowAbstractDatabase && ((WindowAbstractDatabase) window).isNEI) {
|
||||
state = EnumDiscoveryState.SHOW;
|
||||
} else if (state == EnumDiscoveryState.UNDETERMINED) {
|
||||
state = system.isSpeciesDiscovered(species, window.getWorld(), username)
|
||||
? EnumDiscoveryState.DISCOVERED
|
||||
: EnumDiscoveryState.UNDISCOVERED;
|
||||
}
|
||||
if (window instanceof WindowAbstractDatabase && ((WindowAbstractDatabase) window).isNEI) {
|
||||
state = EnumDiscoveryState.SHOW;
|
||||
} else if (state == EnumDiscoveryState.UNDETERMINED) {
|
||||
state = system.isSpeciesDiscovered(species, window.getWorld(), username)
|
||||
? EnumDiscoveryState.DISCOVERED
|
||||
: EnumDiscoveryState.UNDISCOVERED;
|
||||
}
|
||||
|
||||
discovered = state;
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
}
|
||||
discovered = state;
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
}
|
||||
|
||||
public ControlDatabaseIndividualDisplay(IWidget parent, float x, float y) {
|
||||
this(parent, x, y, 16.0f);
|
||||
}
|
||||
public ControlDatabaseIndividualDisplay(IWidget parent, float x, float y) {
|
||||
this(parent, x, y, 16.0f);
|
||||
}
|
||||
|
||||
public ControlDatabaseIndividualDisplay(IWidget parent, float x, float y, float size) {
|
||||
super(parent, x, y, size);
|
||||
species = null;
|
||||
discovered = EnumDiscoveryState.SHOW;
|
||||
addSelfEventHandler(new MouseDownHandler());
|
||||
}
|
||||
public ControlDatabaseIndividualDisplay(IWidget parent, float x, float y, float size) {
|
||||
super(parent, x, y, size);
|
||||
species = null;
|
||||
discovered = EnumDiscoveryState.SHOW;
|
||||
addSelfEventHandler(new MouseDownHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
IIcon icon = null;
|
||||
if (species == null) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
IIcon icon = null;
|
||||
if (species == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
BreedingSystem system = Binnie.Genetics.getSystem(species.getRoot());
|
||||
switch (discovered) {
|
||||
case SHOW:
|
||||
super.onRenderForeground();
|
||||
return;
|
||||
BreedingSystem system = Binnie.Genetics.getSystem(species.getRoot());
|
||||
switch (discovered) {
|
||||
case SHOW:
|
||||
super.onRenderForeground();
|
||||
return;
|
||||
|
||||
case DISCOVERED:
|
||||
icon = system.getDiscoveredIcon();
|
||||
break;
|
||||
case DISCOVERED:
|
||||
icon = system.getDiscoveredIcon();
|
||||
break;
|
||||
|
||||
case UNDISCOVERED:
|
||||
icon = system.getUndiscoveredIcon();
|
||||
break;
|
||||
}
|
||||
if (icon != null) {
|
||||
CraftGUI.render.iconItem(IPoint.ZERO, icon);
|
||||
}
|
||||
}
|
||||
case UNDISCOVERED:
|
||||
icon = system.getUndiscoveredIcon();
|
||||
break;
|
||||
}
|
||||
if (icon != null) {
|
||||
CraftGUI.render.iconItem(IPoint.ZERO, icon);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
if (species == null) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
if (species == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (discovered) {
|
||||
case SHOW:
|
||||
case DISCOVERED:
|
||||
tooltip.add(species.getName());
|
||||
break;
|
||||
switch (discovered) {
|
||||
case SHOW:
|
||||
case DISCOVERED:
|
||||
tooltip.add(species.getName());
|
||||
break;
|
||||
|
||||
case UNDISCOVERED:
|
||||
tooltip.add(I18N.localise("binniecore.gui.database.discovered.undiscovered"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
case UNDISCOVERED:
|
||||
tooltip.add(I18N.localise("binniecore.gui.database.discovered.undiscovered"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private class MouseDownHandler extends EventMouse.Down.Handler {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
if (event.getButton() == 0 && species != null && EnumDiscoveryState.SHOW == discovered) {
|
||||
((WindowAbstractDatabase) getSuperParent()).gotoSpeciesDelayed(species);
|
||||
}
|
||||
}
|
||||
}
|
||||
private class MouseDownHandler extends EventMouse.Down.Handler {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
if (event.getButton() == 0 && species != null && EnumDiscoveryState.SHOW == discovered) {
|
||||
((WindowAbstractDatabase) getSuperParent()).gotoSpeciesDelayed(species);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,22 +10,23 @@ import binnie.core.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ControlItemStackOption extends ControlTextOption<ItemStack> {
|
||||
private ControlItemDisplay controlBee;
|
||||
private ControlItemDisplay controlBee;
|
||||
|
||||
public ControlItemStackOption(ControlList<ItemStack> controlList, ItemStack option, int y) {
|
||||
super(controlList, option, option.getDisplayName(), y);
|
||||
setSize(new IPoint(getSize().x(), 20.0f));
|
||||
public ControlItemStackOption(ControlList<ItemStack> controlList, ItemStack option, int y) {
|
||||
super(controlList, option, option.getDisplayName(), y);
|
||||
setSize(new IPoint(getSize().x(), 20.0f));
|
||||
|
||||
controlBee = new ControlItemDisplay(this, 2.0f, 2.0f);
|
||||
controlBee.setItemStack(option);
|
||||
controlBee = new ControlItemDisplay(this, 2.0f, 2.0f);
|
||||
controlBee.setItemStack(option);
|
||||
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
CraftGUIUtil.moveWidget(textWidget, new IPoint(22.0f, 0.0f));
|
||||
textWidget.setSize(textWidget.getSize().sub(new IPoint(24.0f, 0.0f)));
|
||||
int th = (int) CraftGUI.render.textHeight(textWidget.getValue(), textWidget.getSize().x());
|
||||
int height = Math.max(20, th + 6);
|
||||
setSize(new IPoint(size().x(), height));
|
||||
textWidget.setSize(new IPoint(textWidget.getSize().x(), height));
|
||||
controlBee.setPosition(new IPoint(controlBee.pos().x(), (height - 18) / 2));
|
||||
}
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
CraftGUIUtil.moveWidget(textWidget, new IPoint(22.0f, 0.0f));
|
||||
textWidget.setSize(textWidget.getSize().sub(new IPoint(24.0f, 0.0f)));
|
||||
int th = (int) CraftGUI.render.textHeight(
|
||||
textWidget.getValue(), textWidget.getSize().x());
|
||||
int height = Math.max(20, th + 6);
|
||||
setSize(new IPoint(size().x(), height));
|
||||
textWidget.setSize(new IPoint(textWidget.getSize().x(), height));
|
||||
controlBee.setPosition(new IPoint(controlBee.pos().x(), (height - 18) / 2));
|
||||
}
|
||||
}
|
||||
@@ -6,58 +6,58 @@ import binnie.core.craftgui.minecraft.Window;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IMutation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class ControlMutationBox extends ControlListBox<IMutation> {
|
||||
private Type type;
|
||||
private IAlleleSpecies species;
|
||||
private Type type;
|
||||
private IAlleleSpecies species;
|
||||
|
||||
@Override
|
||||
public IWidget createOption(IMutation value, int y) {
|
||||
return new ControlMutationItem(getContent(), value, species, y);
|
||||
}
|
||||
@Override
|
||||
public IWidget createOption(IMutation value, int y) {
|
||||
return new ControlMutationItem(getContent(), value, species, y);
|
||||
}
|
||||
|
||||
public ControlMutationBox(IWidget parent, int x, int y, int width, int height, Type type) {
|
||||
super(parent, x, y, width, height, 12.0f);
|
||||
species = null;
|
||||
this.type = type;
|
||||
}
|
||||
public ControlMutationBox(IWidget parent, int x, int y, int width, int height, Type type) {
|
||||
super(parent, x, y, width, height, 12.0f);
|
||||
species = null;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setSpecies(IAlleleSpecies species) {
|
||||
if (species == this.species) {
|
||||
return;
|
||||
}
|
||||
public void setSpecies(IAlleleSpecies species) {
|
||||
if (species == this.species) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.species = species;
|
||||
movePercentage(-100.0f);
|
||||
BreedingSystem system = ((WindowAbstractDatabase) getSuperParent()).getBreedingSystem();
|
||||
List<IMutation> discovered = system.getDiscoveredMutations(Window.get(this).getWorld(), Window.get(this).getUsername());
|
||||
this.species = species;
|
||||
movePercentage(-100.0f);
|
||||
BreedingSystem system = ((WindowAbstractDatabase) getSuperParent()).getBreedingSystem();
|
||||
List<IMutation> discovered = system.getDiscoveredMutations(
|
||||
Window.get(this).getWorld(), Window.get(this).getUsername());
|
||||
|
||||
if (species == null) {
|
||||
return;
|
||||
}
|
||||
if (species == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == Type.RESULTANT) {
|
||||
setOptions(system.getResultantMutations(species));
|
||||
return;
|
||||
}
|
||||
if (type == Type.RESULTANT) {
|
||||
setOptions(system.getResultantMutations(species));
|
||||
return;
|
||||
}
|
||||
|
||||
List<IMutation> mutations = system.getFurtherMutations(species);
|
||||
int i = 0;
|
||||
while (i < mutations.size()) {
|
||||
IMutation mutation = mutations.get(i);
|
||||
if (!discovered.contains(mutations) && !((IAlleleSpecies) mutation.getTemplate()[0]).isCounted()) {
|
||||
mutations.remove(i);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
setOptions(mutations);
|
||||
}
|
||||
List<IMutation> mutations = system.getFurtherMutations(species);
|
||||
int i = 0;
|
||||
while (i < mutations.size()) {
|
||||
IMutation mutation = mutations.get(i);
|
||||
if (!discovered.contains(mutations) && !((IAlleleSpecies) mutation.getTemplate()[0]).isCounted()) {
|
||||
mutations.remove(i);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
setOptions(mutations);
|
||||
}
|
||||
|
||||
enum Type {
|
||||
RESULTANT,
|
||||
FURTHER
|
||||
}
|
||||
enum Type {
|
||||
RESULTANT,
|
||||
FURTHER
|
||||
}
|
||||
}
|
||||
@@ -8,43 +8,44 @@ import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IMutation;
|
||||
|
||||
class ControlMutationItem extends ControlOption<IMutation> {
|
||||
public ControlMutationItem(ControlList<IMutation> controlList, IMutation option, IAlleleSpecies species, int y) {
|
||||
super(controlList, option, y);
|
||||
ControlDatabaseIndividualDisplay itemWidget1 = new ControlDatabaseIndividualDisplay(this, 4.0f, 4.0f);
|
||||
ControlDatabaseIndividualDisplay itemWidget2 = new ControlDatabaseIndividualDisplay(this, 44.0f, 4.0f);
|
||||
ControlDatabaseIndividualDisplay itemWidget3 = new ControlDatabaseIndividualDisplay(this, 104.0f, 4.0f);
|
||||
ControlMutationSymbol addSymbol = new ControlMutationSymbol(this, 24, 4, 0);
|
||||
ControlMutationSymbol arrowSymbol = new ControlMutationSymbol(this, 64, 4, 1);
|
||||
boolean isNEI = ((WindowAbstractDatabase) getSuperParent()).isNEI();
|
||||
BreedingSystem system = ((WindowAbstractDatabase) getSuperParent()).getBreedingSystem();
|
||||
Window window = Window.get(this);
|
||||
public ControlMutationItem(ControlList<IMutation> controlList, IMutation option, IAlleleSpecies species, int y) {
|
||||
super(controlList, option, y);
|
||||
ControlDatabaseIndividualDisplay itemWidget1 = new ControlDatabaseIndividualDisplay(this, 4.0f, 4.0f);
|
||||
ControlDatabaseIndividualDisplay itemWidget2 = new ControlDatabaseIndividualDisplay(this, 44.0f, 4.0f);
|
||||
ControlDatabaseIndividualDisplay itemWidget3 = new ControlDatabaseIndividualDisplay(this, 104.0f, 4.0f);
|
||||
ControlMutationSymbol addSymbol = new ControlMutationSymbol(this, 24, 4, 0);
|
||||
ControlMutationSymbol arrowSymbol = new ControlMutationSymbol(this, 64, 4, 1);
|
||||
boolean isNEI = ((WindowAbstractDatabase) getSuperParent()).isNEI();
|
||||
BreedingSystem system = ((WindowAbstractDatabase) getSuperParent()).getBreedingSystem();
|
||||
Window window = Window.get(this);
|
||||
|
||||
if (getValue() == null) {
|
||||
return;
|
||||
}
|
||||
if (getValue() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isMutationDiscovered = system.isMutationDiscovered(getValue(), window.getWorld(), window.getUsername());
|
||||
IAlleleSpecies allele;
|
||||
EnumDiscoveryState state;
|
||||
allele = getValue().getAllele0();
|
||||
state = getState(isNEI, isMutationDiscovered, species, allele);
|
||||
itemWidget1.setSpecies(allele, state);
|
||||
boolean isMutationDiscovered = system.isMutationDiscovered(getValue(), window.getWorld(), window.getUsername());
|
||||
IAlleleSpecies allele;
|
||||
EnumDiscoveryState state;
|
||||
allele = getValue().getAllele0();
|
||||
state = getState(isNEI, isMutationDiscovered, species, allele);
|
||||
itemWidget1.setSpecies(allele, state);
|
||||
|
||||
allele = getValue().getAllele1();
|
||||
state = getState(isNEI, isMutationDiscovered, species, allele);
|
||||
itemWidget2.setSpecies(allele, state);
|
||||
allele = getValue().getAllele1();
|
||||
state = getState(isNEI, isMutationDiscovered, species, allele);
|
||||
itemWidget2.setSpecies(allele, state);
|
||||
|
||||
allele = (IAlleleSpecies) getValue().getTemplate()[0];
|
||||
state = getState(isNEI, isMutationDiscovered, species, allele);
|
||||
itemWidget3.setSpecies(allele, state);
|
||||
allele = (IAlleleSpecies) getValue().getTemplate()[0];
|
||||
state = getState(isNEI, isMutationDiscovered, species, allele);
|
||||
itemWidget3.setSpecies(allele, state);
|
||||
|
||||
addSymbol.setValue(getValue());
|
||||
arrowSymbol.setValue(getValue());
|
||||
}
|
||||
|
||||
private EnumDiscoveryState getState(boolean isNEI, boolean isMutationDiscovered, IAlleleSpecies species, IAlleleSpecies allele) {
|
||||
return (isNEI || isMutationDiscovered || species == allele)
|
||||
? EnumDiscoveryState.SHOW
|
||||
: EnumDiscoveryState.UNDETERMINED;
|
||||
}
|
||||
addSymbol.setValue(getValue());
|
||||
arrowSymbol.setValue(getValue());
|
||||
}
|
||||
|
||||
private EnumDiscoveryState getState(
|
||||
boolean isNEI, boolean isMutationDiscovered, IAlleleSpecies species, IAlleleSpecies allele) {
|
||||
return (isNEI || isMutationDiscovered || species == allele)
|
||||
? EnumDiscoveryState.SHOW
|
||||
: EnumDiscoveryState.UNDETERMINED;
|
||||
}
|
||||
}
|
||||
@@ -16,56 +16,58 @@ import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IMutation;
|
||||
|
||||
class ControlMutationSymbol extends Control implements ITooltip {
|
||||
private static Texture MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2);
|
||||
private static Texture MutationArrow = new StandardTexture(20, 94, 32, 16, CraftGUITextureSheet.Controls2);
|
||||
private IMutation value;
|
||||
private boolean discovered;
|
||||
private int type;
|
||||
private static Texture MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2);
|
||||
private static Texture MutationArrow = new StandardTexture(20, 94, 32, 16, CraftGUITextureSheet.Controls2);
|
||||
private IMutation value;
|
||||
private boolean discovered;
|
||||
private int type;
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
super.onRenderBackground();
|
||||
if (type == 0) {
|
||||
CraftGUI.render.texture(ControlMutationSymbol.MutationPlus, IPoint.ZERO);
|
||||
} else {
|
||||
CraftGUI.render.texture(ControlMutationSymbol.MutationArrow, IPoint.ZERO);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
super.onRenderBackground();
|
||||
if (type == 0) {
|
||||
CraftGUI.render.texture(ControlMutationSymbol.MutationPlus, IPoint.ZERO);
|
||||
} else {
|
||||
CraftGUI.render.texture(ControlMutationSymbol.MutationArrow, IPoint.ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
protected ControlMutationSymbol(IWidget parent, int x, int y, int type) {
|
||||
super(parent, x, y, 16 + type * 16, 16.0f);
|
||||
value = null;
|
||||
this.type = type;
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
}
|
||||
protected ControlMutationSymbol(IWidget parent, int x, int y, int type) {
|
||||
super(parent, x, y, 16 + type * 16, 16.0f);
|
||||
value = null;
|
||||
this.type = type;
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
}
|
||||
|
||||
public void setValue(IMutation value) {
|
||||
this.value = value;
|
||||
boolean isNEI = ((WindowAbstractDatabase) getSuperParent()).isNEI();
|
||||
BreedingSystem system = ((WindowAbstractDatabase) getSuperParent()).getBreedingSystem();
|
||||
discovered = (isNEI || system.isMutationDiscovered(value, Window.get(this).getWorld(), Window.get(this).getUsername()));
|
||||
if (discovered) {
|
||||
setColor(0xffffff);
|
||||
} else {
|
||||
setColor(0x777777);
|
||||
}
|
||||
}
|
||||
public void setValue(IMutation value) {
|
||||
this.value = value;
|
||||
boolean isNEI = ((WindowAbstractDatabase) getSuperParent()).isNEI();
|
||||
BreedingSystem system = ((WindowAbstractDatabase) getSuperParent()).getBreedingSystem();
|
||||
discovered = (isNEI
|
||||
|| system.isMutationDiscovered(
|
||||
value, Window.get(this).getWorld(), Window.get(this).getUsername()));
|
||||
if (discovered) {
|
||||
setColor(0xffffff);
|
||||
} else {
|
||||
setColor(0x777777);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
if (type != 1 || !discovered) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
if (type != 1 || !discovered) {
|
||||
return;
|
||||
}
|
||||
|
||||
IAllele species1 = value.getAllele0();
|
||||
IAllele species2 = value.getAllele1();
|
||||
BreedingSystem system = ((WindowAbstractDatabase) getSuperParent()).getBreedingSystem();
|
||||
float chance = system.getChance(value, Window.get(this).getPlayer(), species1, species2);
|
||||
tooltip.add("Current Chance - " + chance + "%");
|
||||
if (value.getSpecialConditions() != null) {
|
||||
for (String string : value.getSpecialConditions()) {
|
||||
tooltip.add(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
IAllele species1 = value.getAllele0();
|
||||
IAllele species2 = value.getAllele1();
|
||||
BreedingSystem system = ((WindowAbstractDatabase) getSuperParent()).getBreedingSystem();
|
||||
float chance = system.getChance(value, Window.get(this).getPlayer(), species1, species2);
|
||||
tooltip.add("Current Chance - " + chance + "%");
|
||||
if (value.getSpecialConditions() != null) {
|
||||
for (String string : value.getSpecialConditions()) {
|
||||
tooltip.add(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,46 +6,45 @@ import binnie.core.craftgui.minecraft.Window;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IClassification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ControlSpeciesBox extends ControlListBox<IAlleleSpecies> {
|
||||
private IClassification branch;
|
||||
private IClassification branch;
|
||||
|
||||
@Override
|
||||
public IWidget createOption(IAlleleSpecies value, int y) {
|
||||
return new ControlSpeciesBoxOption(getContent(), value, y);
|
||||
}
|
||||
@Override
|
||||
public IWidget createOption(IAlleleSpecies value, int y) {
|
||||
return new ControlSpeciesBoxOption(getContent(), value, y);
|
||||
}
|
||||
|
||||
public ControlSpeciesBox(IWidget parent, float x, float y, float width, float height) {
|
||||
super(parent, x, y, width, height, 12.0f);
|
||||
branch = null;
|
||||
}
|
||||
public ControlSpeciesBox(IWidget parent, float x, float y, float width, float height) {
|
||||
super(parent, x, y, width, height, 12.0f);
|
||||
branch = null;
|
||||
}
|
||||
|
||||
public void setBranch(IClassification branch) {
|
||||
if (branch == this.branch) {
|
||||
return;
|
||||
}
|
||||
public void setBranch(IClassification branch) {
|
||||
if (branch == this.branch) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.branch = branch;
|
||||
List<IAlleleSpecies> speciesList2 = new ArrayList<>();
|
||||
movePercentage(-100.0f);
|
||||
setOptions(speciesList2);
|
||||
this.branch = branch;
|
||||
List<IAlleleSpecies> speciesList2 = new ArrayList<>();
|
||||
movePercentage(-100.0f);
|
||||
setOptions(speciesList2);
|
||||
|
||||
GameProfile playerName = Window.get(this).getUsername();
|
||||
WindowAbstractDatabase db = Window.get(this);
|
||||
Collection<IAlleleSpecies> speciesList3 = db.isNEI
|
||||
? db.getBreedingSystem().getAllSpecies()
|
||||
: db.getBreedingSystem().getDiscoveredSpecies(db.getWorld(), playerName);
|
||||
if (branch != null) {
|
||||
for (IAlleleSpecies species : branch.getMemberSpecies()) {
|
||||
if (speciesList3.contains(species)) {
|
||||
speciesList2.add(species);
|
||||
}
|
||||
}
|
||||
}
|
||||
setOptions(speciesList2);
|
||||
}
|
||||
GameProfile playerName = Window.get(this).getUsername();
|
||||
WindowAbstractDatabase db = Window.get(this);
|
||||
Collection<IAlleleSpecies> speciesList3 = db.isNEI
|
||||
? db.getBreedingSystem().getAllSpecies()
|
||||
: db.getBreedingSystem().getDiscoveredSpecies(db.getWorld(), playerName);
|
||||
if (branch != null) {
|
||||
for (IAlleleSpecies species : branch.getMemberSpecies()) {
|
||||
if (speciesList3.contains(species)) {
|
||||
speciesList2.add(species);
|
||||
}
|
||||
}
|
||||
}
|
||||
setOptions(speciesList2);
|
||||
}
|
||||
}
|
||||
@@ -10,29 +10,31 @@ import binnie.core.util.I18N;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
class ControlSpeciesBoxOption extends ControlTextOption<IAlleleSpecies> {
|
||||
private ControlDatabaseIndividualDisplay controlBee;
|
||||
private ControlDatabaseIndividualDisplay controlBee;
|
||||
|
||||
public ControlSpeciesBoxOption(ControlList<IAlleleSpecies> controlList, IAlleleSpecies option, int y) {
|
||||
super(controlList, option, option.getName(), y);
|
||||
setSize(new IPoint(getSize().x(), 20.0f));
|
||||
(controlBee = new ControlDatabaseIndividualDisplay(this, 2.0f, 2.0f)).setSpecies(getValue(), EnumDiscoveryState.UNDETERMINED);
|
||||
if (controlBee.discovered == EnumDiscoveryState.DISCOVERED) {
|
||||
controlBee.discovered = EnumDiscoveryState.SHOW;
|
||||
}
|
||||
public ControlSpeciesBoxOption(ControlList<IAlleleSpecies> controlList, IAlleleSpecies option, int y) {
|
||||
super(controlList, option, option.getName(), y);
|
||||
setSize(new IPoint(getSize().x(), 20.0f));
|
||||
(controlBee = new ControlDatabaseIndividualDisplay(this, 2.0f, 2.0f))
|
||||
.setSpecies(getValue(), EnumDiscoveryState.UNDETERMINED);
|
||||
if (controlBee.discovered == EnumDiscoveryState.DISCOVERED) {
|
||||
controlBee.discovered = EnumDiscoveryState.SHOW;
|
||||
}
|
||||
|
||||
if (controlBee.discovered == EnumDiscoveryState.SHOW) {
|
||||
textWidget.setValue(option.getName());
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
} else {
|
||||
textWidget.setValue(I18N.localise("binniecore.gui.database.discovered.undiscovered"));
|
||||
}
|
||||
if (controlBee.discovered == EnumDiscoveryState.SHOW) {
|
||||
textWidget.setValue(option.getName());
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
} else {
|
||||
textWidget.setValue(I18N.localise("binniecore.gui.database.discovered.undiscovered"));
|
||||
}
|
||||
|
||||
CraftGUIUtil.moveWidget(textWidget, new IPoint(22.0f, 0.0f));
|
||||
textWidget.setSize(textWidget.getSize().sub(new IPoint(24.0f, 0.0f)));
|
||||
int th = (int) CraftGUI.render.textHeight(textWidget.getValue(), textWidget.getSize().x());
|
||||
int height = Math.max(20, th + 6);
|
||||
setSize(new IPoint(size().x(), height));
|
||||
textWidget.setSize(new IPoint(textWidget.getSize().x(), height));
|
||||
controlBee.setPosition(new IPoint(controlBee.pos().x(), (height - 18) / 2));
|
||||
}
|
||||
CraftGUIUtil.moveWidget(textWidget, new IPoint(22.0f, 0.0f));
|
||||
textWidget.setSize(textWidget.getSize().sub(new IPoint(24.0f, 0.0f)));
|
||||
int th = (int) CraftGUI.render.textHeight(
|
||||
textWidget.getValue(), textWidget.getSize().x());
|
||||
int height = Math.max(20, th + 6);
|
||||
setSize(new IPoint(size().x(), height));
|
||||
textWidget.setSize(new IPoint(textWidget.getSize().x(), height));
|
||||
controlBee.setPosition(new IPoint(controlBee.pos().x(), (height - 18) / 2));
|
||||
}
|
||||
}
|
||||
@@ -6,21 +6,21 @@ import binnie.core.craftgui.Tooltip;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class DatabaseTab implements ITooltipHelp {
|
||||
private String mod;
|
||||
private String unloc;
|
||||
private String mod;
|
||||
private String unloc;
|
||||
|
||||
public DatabaseTab(AbstractMod mod, String unloc) {
|
||||
this.mod = mod.getModID();
|
||||
this.unloc = unloc;
|
||||
}
|
||||
public DatabaseTab(AbstractMod mod, String unloc) {
|
||||
this.mod = mod.getModID();
|
||||
this.unloc = unloc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return I18N.localise(mod + ".gui.database.tab." + unloc);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return I18N.localise(mod + ".gui.database.tab." + unloc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHelpTooltip(Tooltip tooltip) {
|
||||
tooltip.add(I18N.localiseOrBlank(mod + ".gui.database.tab." + unloc + ".help"));
|
||||
}
|
||||
@Override
|
||||
public void getHelpTooltip(Tooltip tooltip) {
|
||||
tooltip.add(I18N.localiseOrBlank(mod + ".gui.database.tab." + unloc + ".help"));
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package binnie.core.craftgui.database;
|
||||
|
||||
public enum EnumDiscoveryState {
|
||||
SHOW,
|
||||
UNDETERMINED,
|
||||
DISCOVERED,
|
||||
UNDISCOVERED
|
||||
SHOW,
|
||||
UNDETERMINED,
|
||||
DISCOVERED,
|
||||
UNDISCOVERED
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
package binnie.core.craftgui.database;
|
||||
|
||||
public interface IDatabaseMode {
|
||||
String getName();
|
||||
String getName();
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.page.ControlPage;
|
||||
|
||||
public abstract class PageAbstract<T> extends ControlPage<DatabaseTab> {
|
||||
public PageAbstract(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, 0.0f, 0.0f, parent.getSize().x(), parent.getSize().y(), tab);
|
||||
}
|
||||
public PageAbstract(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, 0.0f, 0.0f, parent.getSize().x(), parent.getSize().y(), tab);
|
||||
}
|
||||
|
||||
public abstract void onValueChanged(T value);
|
||||
public abstract void onValueChanged(T value);
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import binnie.core.craftgui.IWidget;
|
||||
import forestry.api.genetics.IClassification;
|
||||
|
||||
abstract class PageBranch extends PageAbstract<IClassification> {
|
||||
public PageBranch(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
public PageBranch(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
}
|
||||
@@ -6,67 +6,62 @@ import binnie.core.craftgui.controls.ControlText;
|
||||
import binnie.core.craftgui.controls.ControlTextCentered;
|
||||
import binnie.core.util.I18N;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class PageBranchOverview extends PageBranch {
|
||||
private ControlText branchName;
|
||||
private ControlText branchScientific;
|
||||
private ControlText branchAuthority;
|
||||
private List<ControlText> branchDescription;
|
||||
private ControlText branchName;
|
||||
private ControlText branchScientific;
|
||||
private ControlText branchAuthority;
|
||||
private List<ControlText> branchDescription;
|
||||
|
||||
public PageBranchOverview(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
branchDescription = new ArrayList<>();
|
||||
branchName = new ControlTextCentered(this, 8.0f, "");
|
||||
branchScientific = new ControlTextCentered(this, 32.0f, "");
|
||||
branchAuthority = new ControlTextCentered(this, 44.0f, "");
|
||||
}
|
||||
public PageBranchOverview(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
branchDescription = new ArrayList<>();
|
||||
branchName = new ControlTextCentered(this, 8.0f, "");
|
||||
branchScientific = new ControlTextCentered(this, 32.0f, "");
|
||||
branchAuthority = new ControlTextCentered(this, 44.0f, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(IClassification branch) {
|
||||
String name = I18N.localise(branch.getName());
|
||||
branchName.setValue(
|
||||
EnumChatFormatting.BOLD
|
||||
+ I18N.localise("binniecore.gui.database.branch.name", name)
|
||||
+ EnumChatFormatting.RESET
|
||||
);
|
||||
branchScientific.setValue(
|
||||
EnumChatFormatting.ITALIC
|
||||
+ I18N.localise("binniecore.gui.database.branch.apidae", branch.getScientific())
|
||||
+ EnumChatFormatting.RESET
|
||||
);
|
||||
branchAuthority.setValue(
|
||||
EnumChatFormatting.BOLD
|
||||
+ I18N.localise("binniecore.gui.database.branch.discoveredBy", branch.getMemberSpecies()[0].getAuthority())
|
||||
+ EnumChatFormatting.RESET);
|
||||
@Override
|
||||
public void onValueChanged(IClassification branch) {
|
||||
String name = I18N.localise(branch.getName());
|
||||
branchName.setValue(EnumChatFormatting.BOLD
|
||||
+ I18N.localise("binniecore.gui.database.branch.name", name)
|
||||
+ EnumChatFormatting.RESET);
|
||||
branchScientific.setValue(EnumChatFormatting.ITALIC
|
||||
+ I18N.localise("binniecore.gui.database.branch.apidae", branch.getScientific())
|
||||
+ EnumChatFormatting.RESET);
|
||||
branchAuthority.setValue(EnumChatFormatting.BOLD
|
||||
+ I18N.localise(
|
||||
"binniecore.gui.database.branch.discoveredBy", branch.getMemberSpecies()[0].getAuthority())
|
||||
+ EnumChatFormatting.RESET);
|
||||
|
||||
for (IWidget widget : branchDescription) {
|
||||
deleteChild(widget);
|
||||
}
|
||||
for (IWidget widget : branchDescription) {
|
||||
deleteChild(widget);
|
||||
}
|
||||
|
||||
branchDescription.clear();
|
||||
String desc = branch.getDescription();
|
||||
if (desc == null || desc.isEmpty() || desc.matches("(\\w+\\.?)+")) { // unlocalized
|
||||
desc = I18N.localise("binniecore.gui.database.branch.noDesc");
|
||||
}
|
||||
branchDescription.clear();
|
||||
String desc = branch.getDescription();
|
||||
if (desc == null || desc.isEmpty() || desc.matches("(\\w+\\.?)+")) { // unlocalized
|
||||
desc = I18N.localise("binniecore.gui.database.branch.noDesc");
|
||||
}
|
||||
|
||||
StringBuilder line = new StringBuilder();
|
||||
List<String> descLines = new ArrayList<>();
|
||||
for (String str : desc.split(" ")) {
|
||||
if (CraftGUI.render.textWidth(line + " " + str) > 134) {
|
||||
descLines.add(EnumChatFormatting.ITALIC + line.toString() + EnumChatFormatting.RESET);
|
||||
line = new StringBuilder();
|
||||
}
|
||||
line.append(" ").append(str);
|
||||
}
|
||||
StringBuilder line = new StringBuilder();
|
||||
List<String> descLines = new ArrayList<>();
|
||||
for (String str : desc.split(" ")) {
|
||||
if (CraftGUI.render.textWidth(line + " " + str) > 134) {
|
||||
descLines.add(EnumChatFormatting.ITALIC + line.toString() + EnumChatFormatting.RESET);
|
||||
line = new StringBuilder();
|
||||
}
|
||||
line.append(" ").append(str);
|
||||
}
|
||||
|
||||
descLines.add(line.toString());
|
||||
int i = 0;
|
||||
for (String dLine : descLines) {
|
||||
branchDescription.add(new ControlTextCentered(this, 84 + 12 * i++, dLine));
|
||||
}
|
||||
}
|
||||
descLines.add(line.toString());
|
||||
int i = 0;
|
||||
for (String dLine : descLines) {
|
||||
branchDescription.add(new ControlTextCentered(this, 84 + 12 * i++, dLine));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,31 +9,31 @@ import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IClassification;
|
||||
|
||||
public class PageBranchSpecies extends PageBranch {
|
||||
private ControlSpeciesBox speciesList;
|
||||
private ControlSpeciesBox speciesList;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onHandleEvent(EventValueChanged<IAlleleSpecies> event) {
|
||||
// ignored
|
||||
}
|
||||
@Mod.EventHandler
|
||||
public void onHandleEvent(EventValueChanged<IAlleleSpecies> event) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
public PageBranchSpecies(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
new ControlTextCentered(this, 8.0f, I18N.localise("binniecore.gui.database.species"));
|
||||
addEventHandler(new ValueHandler());
|
||||
speciesList = new ControlSpeciesBox(this, 4.0f, 20.0f, 136.0f, 152.0f);
|
||||
}
|
||||
public PageBranchSpecies(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
new ControlTextCentered(this, 8.0f, I18N.localise("binniecore.gui.database.species"));
|
||||
addEventHandler(new ValueHandler());
|
||||
speciesList = new ControlSpeciesBox(this, 4.0f, 20.0f, 136.0f, 152.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(IClassification branch) {
|
||||
speciesList.setBranch(branch);
|
||||
}
|
||||
@Override
|
||||
public void onValueChanged(IClassification branch) {
|
||||
speciesList.setBranch(branch);
|
||||
}
|
||||
|
||||
private class ValueHandler extends EventValueChanged.Handler {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
if (event.isOrigin(speciesList)) {
|
||||
((WindowAbstractDatabase) getSuperParent()).gotoSpecies((IAlleleSpecies) event.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
private class ValueHandler extends EventValueChanged.Handler {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
if (event.isOrigin(speciesList)) {
|
||||
((WindowAbstractDatabase) getSuperParent()).gotoSpecies((IAlleleSpecies) event.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,35 +10,53 @@ import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class PageBreeder extends ControlPage<DatabaseTab> {
|
||||
private GameProfile player;
|
||||
private GameProfile player;
|
||||
|
||||
public PageBreeder(IWidget parent, GameProfile player, DatabaseTab tab) {
|
||||
super(parent, 0.0f, 0.0f, parent.getSize().x(), parent.getSize().y(), tab);
|
||||
this.player = player;
|
||||
onPageRefresh();
|
||||
}
|
||||
public PageBreeder(IWidget parent, GameProfile player, DatabaseTab tab) {
|
||||
super(parent, 0.0f, 0.0f, parent.getSize().x(), parent.getSize().y(), tab);
|
||||
this.player = player;
|
||||
onPageRefresh();
|
||||
}
|
||||
|
||||
public void onPageRefresh() {
|
||||
while (getWidgets().size() > 0) {
|
||||
deleteChild(getWidgets().get(0));
|
||||
}
|
||||
public void onPageRefresh() {
|
||||
while (getWidgets().size() > 0) {
|
||||
deleteChild(getWidgets().get(0));
|
||||
}
|
||||
|
||||
BreedingSystem system = ((WindowAbstractDatabase) Window.get(this)).getBreedingSystem();
|
||||
new ControlTextCentered(this, 8.0f,
|
||||
EnumChatFormatting.BOLD
|
||||
+ I18N.localise("binniecore.gui.database.descriptor", system.getDescriptor())
|
||||
+ EnumChatFormatting.RESET
|
||||
);
|
||||
new ControlTextCentered(this, 75.0f, I18N.localise("binniecore.gui.database.species.count", system.discoveredSpeciesCount, system.totalSpeciesCount));
|
||||
new ControlBreedingProgress(this, 20, 87, 102, 14, system, system.discoveredSpeciesPercentage);
|
||||
new ControlTextCentered(this, 115.0f, I18N.localise("binniecore.gui.database.branch.count", system.discoveredBranchCount, system.totalBranchCount));
|
||||
new ControlBreedingProgress(this, 20, 127, 102, 14, system, system.discoveredBranchPercentage);
|
||||
BreedingSystem system = ((WindowAbstractDatabase) Window.get(this)).getBreedingSystem();
|
||||
new ControlTextCentered(
|
||||
this,
|
||||
8.0f,
|
||||
EnumChatFormatting.BOLD
|
||||
+ I18N.localise("binniecore.gui.database.descriptor", system.getDescriptor())
|
||||
+ EnumChatFormatting.RESET);
|
||||
new ControlTextCentered(
|
||||
this,
|
||||
75.0f,
|
||||
I18N.localise(
|
||||
"binniecore.gui.database.species.count",
|
||||
system.discoveredSpeciesCount,
|
||||
system.totalSpeciesCount));
|
||||
new ControlBreedingProgress(this, 20, 87, 102, 14, system, system.discoveredSpeciesPercentage);
|
||||
new ControlTextCentered(
|
||||
this,
|
||||
115.0f,
|
||||
I18N.localise(
|
||||
"binniecore.gui.database.branch.count", system.discoveredBranchCount, system.totalBranchCount));
|
||||
new ControlBreedingProgress(this, 20, 127, 102, 14, system, system.discoveredBranchPercentage);
|
||||
|
||||
if (system.discoveredSecretCount > 0) {
|
||||
new ControlTextCentered(this, 155.0f, I18N.localise("binniecore.gui.database.species.secretCount", system.discoveredSecretCount, system.totalSecretCount));
|
||||
}
|
||||
if (system.discoveredSecretCount > 0) {
|
||||
new ControlTextCentered(
|
||||
this,
|
||||
155.0f,
|
||||
I18N.localise(
|
||||
"binniecore.gui.database.species.secretCount",
|
||||
system.discoveredSecretCount,
|
||||
system.totalSecretCount));
|
||||
}
|
||||
|
||||
new ControlTextCentered(this, 32.0f, player.getName());
|
||||
new ControlTextCentered(this, 44.0f, EnumChatFormatting.ITALIC + system.getEpitome() + EnumChatFormatting.RESET);
|
||||
}
|
||||
new ControlTextCentered(this, 32.0f, player.getName());
|
||||
new ControlTextCentered(
|
||||
this, 44.0f, EnumChatFormatting.ITALIC + system.getEpitome() + EnumChatFormatting.RESET);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import binnie.core.craftgui.IWidget;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
public abstract class PageSpecies extends PageAbstract<IAlleleSpecies> {
|
||||
public PageSpecies(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
public PageSpecies(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
}
|
||||
@@ -5,45 +5,46 @@ import binnie.core.craftgui.controls.ControlText;
|
||||
import binnie.core.craftgui.controls.ControlTextCentered;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IClassification;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PageSpeciesClassification extends PageSpecies {
|
||||
private Map<IClassification.EnumClassLevel, ControlText> levels;
|
||||
private ControlText genus;
|
||||
private Map<IClassification.EnumClassLevel, ControlText> levels;
|
||||
private ControlText genus;
|
||||
|
||||
public PageSpeciesClassification(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
levels = new LinkedHashMap<>();
|
||||
int y = 16;
|
||||
for (IClassification.EnumClassLevel level : IClassification.EnumClassLevel.values()) {
|
||||
ControlText text = new ControlTextCentered(this, y, "");
|
||||
text.setColor(level.getColour());
|
||||
levels.put(level, text);
|
||||
y += 12;
|
||||
}
|
||||
public PageSpeciesClassification(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
levels = new LinkedHashMap<>();
|
||||
int y = 16;
|
||||
for (IClassification.EnumClassLevel level : IClassification.EnumClassLevel.values()) {
|
||||
ControlText text = new ControlTextCentered(this, y, "");
|
||||
text.setColor(level.getColour());
|
||||
levels.put(level, text);
|
||||
y += 12;
|
||||
}
|
||||
|
||||
genus = new ControlTextCentered(this, y, "");
|
||||
genus.setColor(0xffba77);
|
||||
}
|
||||
genus = new ControlTextCentered(this, y, "");
|
||||
genus.setColor(0xffba77);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(IAlleleSpecies species) {
|
||||
if (species == null) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void onValueChanged(IAlleleSpecies species) {
|
||||
if (species == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ControlText text : levels.values()) {
|
||||
text.setValue("- - -");
|
||||
}
|
||||
for (ControlText text : levels.values()) {
|
||||
text.setValue("- - -");
|
||||
}
|
||||
|
||||
genus.setValue(species.getBinomial());
|
||||
for (IClassification classification = species.getBranch(); classification != null; classification = classification.getParent()) {
|
||||
IClassification.EnumClassLevel level = classification.getLevel();
|
||||
String text2 = "";
|
||||
text2 += classification.getScientific();
|
||||
levels.get(level).setValue(text2);
|
||||
}
|
||||
}
|
||||
genus.setValue(species.getBinomial());
|
||||
for (IClassification classification = species.getBranch();
|
||||
classification != null;
|
||||
classification = classification.getParent()) {
|
||||
IClassification.EnumClassLevel level = classification.getLevel();
|
||||
String text2 = "";
|
||||
text2 += classification.getScientific();
|
||||
levels.get(level).setValue(text2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,16 @@ import binnie.core.util.I18N;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
public class PageSpeciesMutations extends PageSpecies {
|
||||
private ControlMutationBox list;
|
||||
private ControlMutationBox list;
|
||||
|
||||
public PageSpeciesMutations(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
new ControlTextCentered(this, 8.0f, I18N.localise("binniecore.gui.database.furtherMutations"));
|
||||
list = new ControlMutationBox(this, 4, 20, 136, 152, ControlMutationBox.Type.FURTHER);
|
||||
}
|
||||
public PageSpeciesMutations(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
new ControlTextCentered(this, 8.0f, I18N.localise("binniecore.gui.database.furtherMutations"));
|
||||
list = new ControlMutationBox(this, 4, 20, 136, 152, ControlMutationBox.Type.FURTHER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(IAlleleSpecies species) {
|
||||
list.setSpecies(species);
|
||||
}
|
||||
@Override
|
||||
public void onValueChanged(IAlleleSpecies species) {
|
||||
list.setSpecies(species);
|
||||
}
|
||||
}
|
||||
@@ -12,59 +12,66 @@ import forestry.api.genetics.IAlleleSpecies;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class PageSpeciesOverview extends PageSpecies {
|
||||
private ControlText controlName;
|
||||
private ControlText controlScientific;
|
||||
private ControlText controlAuthority;
|
||||
private ControlText controlComplexity;
|
||||
private ControlText controlDescription;
|
||||
private ControlText controlSignature;
|
||||
private ControlDatabaseIndividualDisplay controlInd1;
|
||||
private ControlDatabaseIndividualDisplay controlInd2;
|
||||
private ControlText controlName;
|
||||
private ControlText controlScientific;
|
||||
private ControlText controlAuthority;
|
||||
private ControlText controlComplexity;
|
||||
private ControlText controlDescription;
|
||||
private ControlText controlSignature;
|
||||
private ControlDatabaseIndividualDisplay controlInd1;
|
||||
private ControlDatabaseIndividualDisplay controlInd2;
|
||||
|
||||
public PageSpeciesOverview(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
controlInd1 = new ControlDatabaseIndividualDisplay(this, 5.0f, 5.0f);
|
||||
controlInd2 = new ControlDatabaseIndividualDisplay(this, 123.0f, 5.0f);
|
||||
controlName = new ControlTextCentered(this, 8.0f, "");
|
||||
controlScientific = new ControlTextCentered(this, 32.0f, "");
|
||||
controlAuthority = new ControlTextCentered(this, 44.0f, "");
|
||||
controlComplexity = new ControlTextCentered(this, 56.0f, "");
|
||||
controlDescription = new ControlText(this, new IArea(8.0f, 84.0f, getSize().x() - 16.0f, 0.0f), "", TextJustification.MIDDLE_CENTER);
|
||||
controlSignature = new ControlText(this, new IArea(8.0f, 84.0f, getSize().x() - 16.0f, 0.0f), "", TextJustification.BOTTOM_RIGHT);
|
||||
}
|
||||
public PageSpeciesOverview(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
controlInd1 = new ControlDatabaseIndividualDisplay(this, 5.0f, 5.0f);
|
||||
controlInd2 = new ControlDatabaseIndividualDisplay(this, 123.0f, 5.0f);
|
||||
controlName = new ControlTextCentered(this, 8.0f, "");
|
||||
controlScientific = new ControlTextCentered(this, 32.0f, "");
|
||||
controlAuthority = new ControlTextCentered(this, 44.0f, "");
|
||||
controlComplexity = new ControlTextCentered(this, 56.0f, "");
|
||||
controlDescription = new ControlText(
|
||||
this, new IArea(8.0f, 84.0f, getSize().x() - 16.0f, 0.0f), "", TextJustification.MIDDLE_CENTER);
|
||||
controlSignature = new ControlText(
|
||||
this, new IArea(8.0f, 84.0f, getSize().x() - 16.0f, 0.0f), "", TextJustification.BOTTOM_RIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(IAlleleSpecies species) {
|
||||
controlInd1.setSpecies(species, EnumDiscoveryState.SHOW);
|
||||
controlInd2.setSpecies(species, EnumDiscoveryState.SHOW);
|
||||
String branchBinomial = (species.getBranch() != null)
|
||||
? species.getBranch().getScientific()
|
||||
: I18N.localise("extratrees.genetics.unknown");
|
||||
@Override
|
||||
public void onValueChanged(IAlleleSpecies species) {
|
||||
controlInd1.setSpecies(species, EnumDiscoveryState.SHOW);
|
||||
controlInd2.setSpecies(species, EnumDiscoveryState.SHOW);
|
||||
String branchBinomial = (species.getBranch() != null)
|
||||
? species.getBranch().getScientific()
|
||||
: I18N.localise("extratrees.genetics.unknown");
|
||||
|
||||
controlName.setValue(EnumChatFormatting.BOLD + species.getName() + EnumChatFormatting.RESET);
|
||||
controlScientific.setValue(EnumChatFormatting.ITALIC + branchBinomial + " " + species.getBinomial() + EnumChatFormatting.RESET);
|
||||
controlAuthority.setValue(EnumChatFormatting.BOLD + I18N.localise("extratrees.genetics.discoveredBy", species.getAuthority()) + EnumChatFormatting.RESET);
|
||||
controlComplexity.setValue(I18N.localise("extratrees.genetics.complexity", species.getComplexity()));
|
||||
String desc = species.getDescription();
|
||||
String descBody = EnumChatFormatting.ITALIC.toString();
|
||||
String descSig = "";
|
||||
controlName.setValue(EnumChatFormatting.BOLD + species.getName() + EnumChatFormatting.RESET);
|
||||
controlScientific.setValue(
|
||||
EnumChatFormatting.ITALIC + branchBinomial + " " + species.getBinomial() + EnumChatFormatting.RESET);
|
||||
controlAuthority.setValue(EnumChatFormatting.BOLD
|
||||
+ I18N.localise("extratrees.genetics.discoveredBy", species.getAuthority())
|
||||
+ EnumChatFormatting.RESET);
|
||||
controlComplexity.setValue(I18N.localise("extratrees.genetics.complexity", species.getComplexity()));
|
||||
String desc = species.getDescription();
|
||||
String descBody = EnumChatFormatting.ITALIC.toString();
|
||||
String descSig = "";
|
||||
|
||||
if (desc == null || desc.isEmpty() || desc.matches("(\\w+\\.?)+")) {
|
||||
descBody += I18N.localise("binniecore.gui.database.species.noDesc");
|
||||
} else {
|
||||
String[] descStrings = desc.split("\\|");
|
||||
descBody += descStrings[0];
|
||||
for (int i = 1; i < descStrings.length - 1; ++i) {
|
||||
descBody = descBody + " " + descStrings[i];
|
||||
}
|
||||
if (descStrings.length > 1) {
|
||||
descSig += descStrings[descStrings.length - 1];
|
||||
}
|
||||
}
|
||||
if (desc == null || desc.isEmpty() || desc.matches("(\\w+\\.?)+")) {
|
||||
descBody += I18N.localise("binniecore.gui.database.species.noDesc");
|
||||
} else {
|
||||
String[] descStrings = desc.split("\\|");
|
||||
descBody += descStrings[0];
|
||||
for (int i = 1; i < descStrings.length - 1; ++i) {
|
||||
descBody = descBody + " " + descStrings[i];
|
||||
}
|
||||
if (descStrings.length > 1) {
|
||||
descSig += descStrings[descStrings.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
controlDescription.setValue(descBody + EnumChatFormatting.RESET);
|
||||
controlSignature.setValue(descSig + EnumChatFormatting.RESET);
|
||||
float descHeight = CraftGUI.render.textHeight(controlDescription.getValue(), controlDescription.getSize().x());
|
||||
controlSignature.setPosition(new IPoint(controlSignature.pos().x(), controlDescription.getPosition().y() + descHeight + 10.0f));
|
||||
}
|
||||
controlDescription.setValue(descBody + EnumChatFormatting.RESET);
|
||||
controlSignature.setValue(descSig + EnumChatFormatting.RESET);
|
||||
float descHeight = CraftGUI.render.textHeight(
|
||||
controlDescription.getValue(), controlDescription.getSize().x());
|
||||
controlSignature.setPosition(new IPoint(
|
||||
controlSignature.pos().x(), controlDescription.getPosition().y() + descHeight + 10.0f));
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,16 @@ import binnie.core.util.I18N;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
public class PageSpeciesResultant extends PageSpecies {
|
||||
private ControlMutationBox list;
|
||||
private ControlMutationBox list;
|
||||
|
||||
public PageSpeciesResultant(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
new ControlTextCentered(this, 8.0f, I18N.localise("binniecore.gui.database.resultantMutations"));
|
||||
list = new ControlMutationBox(this, 4, 20, 136, 152, ControlMutationBox.Type.RESULTANT);
|
||||
}
|
||||
public PageSpeciesResultant(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
new ControlTextCentered(this, 8.0f, I18N.localise("binniecore.gui.database.resultantMutations"));
|
||||
list = new ControlMutationBox(this, 4, 20, 136, 152, ControlMutationBox.Type.RESULTANT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(IAlleleSpecies species) {
|
||||
list.setSpecies(species);
|
||||
}
|
||||
@Override
|
||||
public void onValueChanged(IAlleleSpecies species) {
|
||||
list.setSpecies(species);
|
||||
}
|
||||
}
|
||||
@@ -27,229 +27,250 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public abstract class WindowAbstractDatabase extends Window {
|
||||
protected boolean isNEI;
|
||||
protected boolean isNEI;
|
||||
|
||||
private float selectionBoxWidth;
|
||||
private Map<IDatabaseMode, ModeWidgets> modes;
|
||||
private BreedingSystem system;
|
||||
private Panel panelInformation;
|
||||
private Panel panelSearch;
|
||||
private ControlPages<IDatabaseMode> modePages;
|
||||
private IAlleleSpecies gotoSpecies;
|
||||
private float selectionBoxWidth;
|
||||
private Map<IDatabaseMode, ModeWidgets> modes;
|
||||
private BreedingSystem system;
|
||||
private Panel panelInformation;
|
||||
private Panel panelSearch;
|
||||
private ControlPages<IDatabaseMode> modePages;
|
||||
private IAlleleSpecies gotoSpecies;
|
||||
|
||||
public void changeMode(IDatabaseMode mode) {
|
||||
modePages.setValue(mode);
|
||||
}
|
||||
public void changeMode(IDatabaseMode mode) {
|
||||
modePages.setValue(mode);
|
||||
}
|
||||
|
||||
public WindowAbstractDatabase(EntityPlayer player, Side side, boolean nei, BreedingSystem system, float wid) {
|
||||
super(100.0f, 192.0f, player, null, side);
|
||||
selectionBoxWidth = 95.0f;
|
||||
modes = new HashMap<>();
|
||||
isNEI = nei;
|
||||
this.system = system;
|
||||
selectionBoxWidth = wid;
|
||||
}
|
||||
public WindowAbstractDatabase(EntityPlayer player, Side side, boolean nei, BreedingSystem system, float wid) {
|
||||
super(100.0f, 192.0f, player, null, side);
|
||||
selectionBoxWidth = 95.0f;
|
||||
modes = new HashMap<>();
|
||||
isNEI = nei;
|
||||
this.system = system;
|
||||
selectionBoxWidth = wid;
|
||||
}
|
||||
|
||||
public ControlPages<DatabaseTab> getInfoPages(IDatabaseMode mode) {
|
||||
return modes.get(mode).infoPages;
|
||||
}
|
||||
public ControlPages<DatabaseTab> getInfoPages(IDatabaseMode mode) {
|
||||
return modes.get(mode).infoPages;
|
||||
}
|
||||
|
||||
public boolean isNEI() {
|
||||
return isNEI;
|
||||
}
|
||||
public boolean isNEI() {
|
||||
return isNEI;
|
||||
}
|
||||
|
||||
public BreedingSystem getBreedingSystem() {
|
||||
return system;
|
||||
}
|
||||
public BreedingSystem getBreedingSystem() {
|
||||
return system;
|
||||
}
|
||||
|
||||
public WindowAbstractDatabase(EntityPlayer player, Side side, boolean nei, BreedingSystem system) {
|
||||
this(player, side, nei, system, 95.0f);
|
||||
}
|
||||
public WindowAbstractDatabase(EntityPlayer player, Side side, boolean nei, BreedingSystem system) {
|
||||
this(player, side, nei, system, 95.0f);
|
||||
}
|
||||
|
||||
protected ModeWidgets createMode(IDatabaseMode mode, ModeWidgets widgets) {
|
||||
modes.put(mode, widgets);
|
||||
return widgets;
|
||||
}
|
||||
protected ModeWidgets createMode(IDatabaseMode mode, ModeWidgets widgets) {
|
||||
modes.put(mode, widgets);
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
setSize(new IPoint(176.0f + selectionBoxWidth + 22.0f + 8.0f, 208.0f));
|
||||
addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
if (!(event.getOrigin().getParent() instanceof ControlPage)) {
|
||||
return;
|
||||
} else if ((event.getValue() instanceof DatabaseTab)) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
setSize(new IPoint(176.0f + selectionBoxWidth + 22.0f + 8.0f, 208.0f));
|
||||
addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
if (!(event.getOrigin().getParent() instanceof ControlPage)) {
|
||||
return;
|
||||
} else if ((event.getValue() instanceof DatabaseTab)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ControlPage parent = (ControlPage) event.getOrigin().getParent();
|
||||
if (!(parent.getValue() instanceof IDatabaseMode)) {
|
||||
return;
|
||||
}
|
||||
ControlPage parent = (ControlPage) event.getOrigin().getParent();
|
||||
if (!(parent.getValue() instanceof IDatabaseMode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (IWidget widget : parent.getWidgets()) {
|
||||
if (widget instanceof ControlPages) {
|
||||
if (event.getValue() == null) {
|
||||
widget.hide();
|
||||
} else {
|
||||
widget.show();
|
||||
for (IWidget widget2 : widget.getWidgets()) {
|
||||
if (widget2 instanceof PageAbstract) {
|
||||
((PageAbstract) widget2).onValueChanged(event.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
for (IWidget widget : parent.getWidgets()) {
|
||||
if (widget instanceof ControlPages) {
|
||||
if (event.getValue() == null) {
|
||||
widget.hide();
|
||||
} else {
|
||||
widget.show();
|
||||
for (IWidget widget2 : widget.getWidgets()) {
|
||||
if (widget2 instanceof PageAbstract) {
|
||||
((PageAbstract) widget2).onValueChanged(event.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
addEventHandler(new EventTextEdit.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventTextEdit event) {
|
||||
for (ModeWidgets widgets : modes.values()) {
|
||||
widgets.listBox.setValidator(new IValidator<IWidget>() {
|
||||
@Override
|
||||
public boolean isValid(IWidget object) {
|
||||
return event.getValue().isEmpty() || ((ControlTextOption) object).getText().toLowerCase().contains(event.getValue().toLowerCase());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.DirectChild, this));
|
||||
addEventHandler(
|
||||
new EventTextEdit.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventTextEdit event) {
|
||||
for (ModeWidgets widgets : modes.values()) {
|
||||
widgets.listBox.setValidator(new IValidator<IWidget>() {
|
||||
@Override
|
||||
public boolean isValid(IWidget object) {
|
||||
return event.getValue().isEmpty()
|
||||
|| ((ControlTextOption) object)
|
||||
.getText()
|
||||
.toLowerCase()
|
||||
.contains(event.getValue().toLowerCase());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.DirectChild, this));
|
||||
|
||||
new ControlHelp(this, 4.0f, 4.0f);
|
||||
(panelInformation = new Panel(this, 24.0f, 24.0f, 144.0f, 176.0f, MinecraftGUI.PanelType.Black)).setColor(860416);
|
||||
(panelSearch = new Panel(this, 176.0f, 24.0f, selectionBoxWidth, 160.0f, MinecraftGUI.PanelType.Black)).setColor(860416);
|
||||
modePages = new ControlPages<>(this, 0.0f, 0.0f, getSize().x(), getSize().y());
|
||||
new ControlTextEdit(this, 176.0f, 184.0f, selectionBoxWidth, 16.0f);
|
||||
new ControlHelp(this, 4.0f, 4.0f);
|
||||
(panelInformation = new Panel(this, 24.0f, 24.0f, 144.0f, 176.0f, MinecraftGUI.PanelType.Black))
|
||||
.setColor(860416);
|
||||
(panelSearch = new Panel(this, 176.0f, 24.0f, selectionBoxWidth, 160.0f, MinecraftGUI.PanelType.Black))
|
||||
.setColor(860416);
|
||||
modePages =
|
||||
new ControlPages<>(this, 0.0f, 0.0f, getSize().x(), getSize().y());
|
||||
new ControlTextEdit(this, 176.0f, 184.0f, selectionBoxWidth, 16.0f);
|
||||
|
||||
createMode(Mode.Species, new ModeWidgets(Mode.Species, this) {
|
||||
@Override
|
||||
public void createListBox(IArea area) {
|
||||
GameProfile playerName = getUsername();
|
||||
Collection<IAlleleSpecies> speciesList = database.isNEI ? database.system.getAllSpecies() : database.system.getDiscoveredSpecies(database.getWorld(), playerName);
|
||||
(listBox = new ControlSpeciesBox(modePage, area.x(), area.y(), area.w(), area.h())).setOptions(speciesList);
|
||||
}
|
||||
});
|
||||
createMode(Mode.Species, new ModeWidgets(Mode.Species, this) {
|
||||
@Override
|
||||
public void createListBox(IArea area) {
|
||||
GameProfile playerName = getUsername();
|
||||
Collection<IAlleleSpecies> speciesList = database.isNEI
|
||||
? database.system.getAllSpecies()
|
||||
: database.system.getDiscoveredSpecies(database.getWorld(), playerName);
|
||||
(listBox = new ControlSpeciesBox(modePage, area.x(), area.y(), area.w(), area.h()))
|
||||
.setOptions(speciesList);
|
||||
}
|
||||
});
|
||||
|
||||
createMode(Mode.Branches, new ModeWidgets(Mode.Branches, this) {
|
||||
@Override
|
||||
public void createListBox(IArea area) {
|
||||
GameProfile playerName = getUsername();
|
||||
Collection<IClassification> speciesList = database.isNEI
|
||||
? database.system.getAllBranches()
|
||||
: database.system.getDiscoveredBranches(database.getWorld(), playerName);
|
||||
createMode(Mode.Branches, new ModeWidgets(Mode.Branches, this) {
|
||||
@Override
|
||||
public void createListBox(IArea area) {
|
||||
GameProfile playerName = getUsername();
|
||||
Collection<IClassification> speciesList = database.isNEI
|
||||
? database.system.getAllBranches()
|
||||
: database.system.getDiscoveredBranches(database.getWorld(), playerName);
|
||||
|
||||
listBox = new ControlBranchBox(modePage, area.x(), area.y(), area.w(), area.h());
|
||||
listBox.setOptions(speciesList);
|
||||
}
|
||||
});
|
||||
listBox = new ControlBranchBox(modePage, area.x(), area.y(), area.w(), area.h());
|
||||
listBox.setOptions(speciesList);
|
||||
}
|
||||
});
|
||||
|
||||
createMode(Mode.Breeder, new ModeWidgets(Mode.Breeder, this) {
|
||||
@Override
|
||||
public void createListBox(IArea area) {
|
||||
listBox = new ControlListBox(modePage, area.x(), area.y(), area.w(), area.h(), 12.0f);
|
||||
}
|
||||
});
|
||||
createMode(Mode.Breeder, new ModeWidgets(Mode.Breeder, this) {
|
||||
@Override
|
||||
public void createListBox(IArea area) {
|
||||
listBox = new ControlListBox(modePage, area.x(), area.y(), area.w(), area.h(), 12.0f);
|
||||
}
|
||||
});
|
||||
|
||||
addTabs();
|
||||
ControlTabBar<IDatabaseMode> tab = new ControlTabBar<IDatabaseMode>(this, 176.0f + selectionBoxWidth, 24.0f, 22.0f, 176.0f, Position.RIGHT) {
|
||||
@Override
|
||||
public ControlTab<IDatabaseMode> createTab(float x, float y, float w, float h, IDatabaseMode value) {
|
||||
return new ControlTab<IDatabaseMode>(this, x, y, w, h, value) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return value.getName();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
addTabs();
|
||||
ControlTabBar<IDatabaseMode> tab =
|
||||
new ControlTabBar<IDatabaseMode>(
|
||||
this, 176.0f + selectionBoxWidth, 24.0f, 22.0f, 176.0f, Position.RIGHT) {
|
||||
@Override
|
||||
public ControlTab<IDatabaseMode> createTab(
|
||||
float x, float y, float w, float h, IDatabaseMode value) {
|
||||
return new ControlTab<IDatabaseMode>(this, x, y, w, h, value) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return value.getName();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
tab.setValues(modePages.getValues());
|
||||
CraftGUIUtil.linkWidgets(tab, modePages);
|
||||
changeMode(Mode.Species);
|
||||
for (IDatabaseMode mode : modes.keySet()) {
|
||||
modes.get(mode).infoTabs = new ControlTabBar(modes.get(mode).modePage, 8.0f, 24.0f, 16.0f, 176.0f, Position.LEFT);
|
||||
modes.get(mode).infoTabs.setValues(modes.get(mode).infoPages.getValues());
|
||||
CraftGUIUtil.linkWidgets(modes.get(mode).infoTabs, modes.get(mode).infoPages);
|
||||
}
|
||||
}
|
||||
tab.setValues(modePages.getValues());
|
||||
CraftGUIUtil.linkWidgets(tab, modePages);
|
||||
changeMode(Mode.Species);
|
||||
for (IDatabaseMode mode : modes.keySet()) {
|
||||
modes.get(mode).infoTabs =
|
||||
new ControlTabBar(modes.get(mode).modePage, 8.0f, 24.0f, 16.0f, 176.0f, Position.LEFT);
|
||||
modes.get(mode).infoTabs.setValues(modes.get(mode).infoPages.getValues());
|
||||
CraftGUIUtil.linkWidgets(modes.get(mode).infoTabs, modes.get(mode).infoPages);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseServer() {
|
||||
IBreedingTracker tracker = system.getSpeciesRoot().getBreedingTracker(getWorld(), getUsername());
|
||||
if (tracker != null) {
|
||||
tracker.synchToPlayer(getPlayer());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void initialiseServer() {
|
||||
IBreedingTracker tracker = system.getSpeciesRoot().getBreedingTracker(getWorld(), getUsername());
|
||||
if (tracker != null) {
|
||||
tracker.synchToPlayer(getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
protected void addTabs() {
|
||||
// ignored
|
||||
}
|
||||
protected void addTabs() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
public void gotoSpecies(IAlleleSpecies value) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
public void gotoSpecies(IAlleleSpecies value) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
modePages.setValue(Mode.Species);
|
||||
changeMode(Mode.Species);
|
||||
modes.get(modePages.getValue()).listBox.setValue(value);
|
||||
}
|
||||
modePages.setValue(Mode.Species);
|
||||
changeMode(Mode.Species);
|
||||
modes.get(modePages.getValue()).listBox.setValue(value);
|
||||
}
|
||||
|
||||
public void gotoSpeciesDelayed(IAlleleSpecies species) {
|
||||
gotoSpecies = species;
|
||||
}
|
||||
public void gotoSpeciesDelayed(IAlleleSpecies species) {
|
||||
gotoSpecies = species;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
if (gotoSpecies == null) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
if (gotoSpecies == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
((WindowAbstractDatabase) getSuperParent()).gotoSpecies(gotoSpecies);
|
||||
gotoSpecies = null;
|
||||
}
|
||||
((WindowAbstractDatabase) getSuperParent()).gotoSpecies(gotoSpecies);
|
||||
gotoSpecies = null;
|
||||
}
|
||||
|
||||
public enum Mode implements IDatabaseMode {
|
||||
Species,
|
||||
Branches,
|
||||
Breeder;
|
||||
public enum Mode implements IDatabaseMode {
|
||||
Species,
|
||||
Branches,
|
||||
Breeder;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return I18N.localise("binniecore.gui.database.mode." + name().toLowerCase());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return I18N.localise("binniecore.gui.database.mode." + name().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class ModeWidgets {
|
||||
public WindowAbstractDatabase database;
|
||||
public ControlPage<IDatabaseMode> modePage;
|
||||
public ControlListBox listBox;
|
||||
public abstract static class ModeWidgets {
|
||||
public WindowAbstractDatabase database;
|
||||
public ControlPage<IDatabaseMode> modePage;
|
||||
public ControlListBox listBox;
|
||||
|
||||
private ControlPages<DatabaseTab> infoPages;
|
||||
private ControlTabBar<DatabaseTab> infoTabs;
|
||||
private ControlPages<DatabaseTab> infoPages;
|
||||
private ControlTabBar<DatabaseTab> infoTabs;
|
||||
|
||||
public ModeWidgets(IDatabaseMode mode, WindowAbstractDatabase database) {
|
||||
this.database = database;
|
||||
modePage = new ControlPage<>(database.modePages, 0.0f, 0.0f, database.getSize().x(), database.getSize().y(), mode);
|
||||
IArea listBoxArea = database.panelSearch.area().inset(2);
|
||||
createListBox(listBoxArea);
|
||||
CraftGUIUtil.alignToWidget(listBox, database.panelSearch);
|
||||
CraftGUIUtil.moveWidget(listBox, new IPoint(2.0f, 2.0f));
|
||||
CraftGUIUtil.alignToWidget(infoPages = new ControlPages<>(modePage, 0.0f, 0.0f, 144.0f, 176.0f), database.panelInformation);
|
||||
}
|
||||
public ModeWidgets(IDatabaseMode mode, WindowAbstractDatabase database) {
|
||||
this.database = database;
|
||||
modePage = new ControlPage<>(
|
||||
database.modePages,
|
||||
0.0f,
|
||||
0.0f,
|
||||
database.getSize().x(),
|
||||
database.getSize().y(),
|
||||
mode);
|
||||
IArea listBoxArea = database.panelSearch.area().inset(2);
|
||||
createListBox(listBoxArea);
|
||||
CraftGUIUtil.alignToWidget(listBox, database.panelSearch);
|
||||
CraftGUIUtil.moveWidget(listBox, new IPoint(2.0f, 2.0f));
|
||||
CraftGUIUtil.alignToWidget(
|
||||
infoPages = new ControlPages<>(modePage, 0.0f, 0.0f, 144.0f, 176.0f), database.panelInformation);
|
||||
}
|
||||
|
||||
public abstract void createListBox(IArea area);
|
||||
}
|
||||
public abstract void createListBox(IArea area);
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,17 @@ package binnie.core.craftgui.events;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
|
||||
public class Event {
|
||||
IWidget origin;
|
||||
IWidget origin;
|
||||
|
||||
public Event(IWidget origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
public Event(IWidget origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
public IWidget getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
public IWidget getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
public boolean isOrigin(IWidget widget) {
|
||||
return origin == widget;
|
||||
}
|
||||
public boolean isOrigin(IWidget widget) {
|
||||
return origin == widget;
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,13 @@ package binnie.core.craftgui.events;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
|
||||
public class EventButtonClicked extends Event {
|
||||
public EventButtonClicked(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public EventButtonClicked(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<EventButtonClicked> {
|
||||
public Handler() {
|
||||
super(EventButtonClicked.class);
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<EventButtonClicked> {
|
||||
public Handler() {
|
||||
super(EventButtonClicked.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,14 @@ package binnie.core.craftgui.events;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
|
||||
public class EventCycleChanged extends Event {
|
||||
public int value;
|
||||
public int value;
|
||||
|
||||
public EventCycleChanged(IWidget origin, int value) {
|
||||
super(origin);
|
||||
this.value = value;
|
||||
}
|
||||
public EventCycleChanged(IWidget origin, int value) {
|
||||
super(origin);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -3,48 +3,48 @@ package binnie.core.craftgui.events;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
|
||||
public abstract class EventHandler<E extends Event> {
|
||||
Class<E> eventClass;
|
||||
Origin origin;
|
||||
IWidget relative;
|
||||
Class<E> eventClass;
|
||||
Origin origin;
|
||||
IWidget relative;
|
||||
|
||||
public EventHandler(Class<E> eventClass) {
|
||||
this.eventClass = eventClass;
|
||||
origin = Origin.Any;
|
||||
}
|
||||
public EventHandler(Class<E> eventClass) {
|
||||
this.eventClass = eventClass;
|
||||
origin = Origin.Any;
|
||||
}
|
||||
|
||||
public EventHandler setOrigin(Origin origin, IWidget relative) {
|
||||
this.origin = origin;
|
||||
this.relative = relative;
|
||||
return this;
|
||||
}
|
||||
public EventHandler setOrigin(Origin origin, IWidget relative) {
|
||||
this.origin = origin;
|
||||
this.relative = relative;
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract void onEvent(E event);
|
||||
public abstract void onEvent(E event);
|
||||
|
||||
public boolean handles(Event e) {
|
||||
return eventClass.isInstance(e) && origin.isOrigin(e.getOrigin(), relative);
|
||||
}
|
||||
public boolean handles(Event e) {
|
||||
return eventClass.isInstance(e) && origin.isOrigin(e.getOrigin(), relative);
|
||||
}
|
||||
|
||||
public enum Origin {
|
||||
Any,
|
||||
Self,
|
||||
Parent,
|
||||
DirectChild;
|
||||
public enum Origin {
|
||||
Any,
|
||||
Self,
|
||||
Parent,
|
||||
DirectChild;
|
||||
|
||||
public boolean isOrigin(IWidget origin, IWidget test) {
|
||||
switch (this) {
|
||||
case Any:
|
||||
return true;
|
||||
public boolean isOrigin(IWidget origin, IWidget test) {
|
||||
switch (this) {
|
||||
case Any:
|
||||
return true;
|
||||
|
||||
case DirectChild:
|
||||
return test.getWidgets().contains(origin);
|
||||
case DirectChild:
|
||||
return test.getWidgets().contains(origin);
|
||||
|
||||
case Parent:
|
||||
return test.getParent() == origin;
|
||||
case Parent:
|
||||
return test.getParent() == origin;
|
||||
|
||||
case Self:
|
||||
return test == origin;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case Self:
|
||||
return test == origin;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,32 +3,32 @@ package binnie.core.craftgui.events;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
|
||||
public abstract class EventKey extends Event {
|
||||
char character;
|
||||
int key;
|
||||
char character;
|
||||
int key;
|
||||
|
||||
public EventKey(IWidget origin, char character, int key) {
|
||||
super(origin);
|
||||
this.character = character;
|
||||
this.key = key;
|
||||
}
|
||||
public EventKey(IWidget origin, char character, int key) {
|
||||
super(origin);
|
||||
this.character = character;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public char getCharacter() {
|
||||
return character;
|
||||
}
|
||||
public char getCharacter() {
|
||||
return character;
|
||||
}
|
||||
|
||||
public int getKey() {
|
||||
return key;
|
||||
}
|
||||
public int getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public static class Down extends EventKey {
|
||||
public Down(IWidget origin, char character, int key) {
|
||||
super(origin, character, key);
|
||||
}
|
||||
public static class Down extends EventKey {
|
||||
public Down(IWidget origin, char character, int key) {
|
||||
super(origin, character, key);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Down> {
|
||||
public Handler() {
|
||||
super(Down.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<Down> {
|
||||
public Handler() {
|
||||
super(Down.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,113 +3,113 @@ package binnie.core.craftgui.events;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
|
||||
public abstract class EventMouse extends Event {
|
||||
public EventMouse(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public EventMouse(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public static class Button extends EventMouse {
|
||||
protected int x;
|
||||
protected int y;
|
||||
protected int button;
|
||||
public static class Button extends EventMouse {
|
||||
protected int x;
|
||||
protected int y;
|
||||
protected int button;
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getButton() {
|
||||
return button;
|
||||
}
|
||||
public int getButton() {
|
||||
return button;
|
||||
}
|
||||
|
||||
public Button(IWidget currentMousedOverWidget, int x, int y, int button) {
|
||||
super(currentMousedOverWidget);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.button = button;
|
||||
}
|
||||
}
|
||||
public Button(IWidget currentMousedOverWidget, int x, int y, int button) {
|
||||
super(currentMousedOverWidget);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.button = button;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Down extends Button {
|
||||
public Down(IWidget currentMousedOverWidget, int x, int y, int button) {
|
||||
super(currentMousedOverWidget, x, y, button);
|
||||
}
|
||||
public static class Down extends Button {
|
||||
public Down(IWidget currentMousedOverWidget, int x, int y, int button) {
|
||||
super(currentMousedOverWidget, x, y, button);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Down> {
|
||||
public Handler() {
|
||||
super(Down.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<Down> {
|
||||
public Handler() {
|
||||
super(Down.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Up extends Button {
|
||||
public Up(IWidget currentMousedOverWidget, int x, int y, int button) {
|
||||
super(currentMousedOverWidget, x, y, button);
|
||||
}
|
||||
public static class Up extends Button {
|
||||
public Up(IWidget currentMousedOverWidget, int x, int y, int button) {
|
||||
super(currentMousedOverWidget, x, y, button);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Up> {
|
||||
public Handler() {
|
||||
super(Up.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<Up> {
|
||||
public Handler() {
|
||||
super(Up.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Move extends EventMouse {
|
||||
protected float dx;
|
||||
protected float dy;
|
||||
public static class Move extends EventMouse {
|
||||
protected float dx;
|
||||
protected float dy;
|
||||
|
||||
public float getDx() {
|
||||
return dx;
|
||||
}
|
||||
public float getDx() {
|
||||
return dx;
|
||||
}
|
||||
|
||||
public float getDy() {
|
||||
return dy;
|
||||
}
|
||||
public float getDy() {
|
||||
return dy;
|
||||
}
|
||||
|
||||
public Move(IWidget origin, float dx, float dy) {
|
||||
super(origin);
|
||||
this.dx = dx;
|
||||
this.dy = dy;
|
||||
}
|
||||
public Move(IWidget origin, float dx, float dy) {
|
||||
super(origin);
|
||||
this.dx = dx;
|
||||
this.dy = dy;
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Move> {
|
||||
public Handler() {
|
||||
super(Move.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<Move> {
|
||||
public Handler() {
|
||||
super(Move.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Drag extends Move {
|
||||
public Drag(IWidget draggedWidget, float dx, float dy) {
|
||||
super(draggedWidget, dx, dy);
|
||||
}
|
||||
public static class Drag extends Move {
|
||||
public Drag(IWidget draggedWidget, float dx, float dy) {
|
||||
super(draggedWidget, dx, dy);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Drag> {
|
||||
public Handler() {
|
||||
super(Drag.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<Drag> {
|
||||
public Handler() {
|
||||
super(Drag.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Wheel extends EventMouse {
|
||||
protected int dWheel;
|
||||
public static class Wheel extends EventMouse {
|
||||
protected int dWheel;
|
||||
|
||||
public Wheel(IWidget origin, int dWheel) {
|
||||
super(origin);
|
||||
this.dWheel = 0;
|
||||
this.dWheel = dWheel / 28;
|
||||
}
|
||||
public Wheel(IWidget origin, int dWheel) {
|
||||
super(origin);
|
||||
this.dWheel = 0;
|
||||
this.dWheel = dWheel / 28;
|
||||
}
|
||||
|
||||
public int getDWheel() {
|
||||
return dWheel;
|
||||
}
|
||||
public int getDWheel() {
|
||||
return dWheel;
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Wheel> {
|
||||
public Handler() {
|
||||
super(Wheel.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<Wheel> {
|
||||
public Handler() {
|
||||
super(Wheel.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,13 @@ package binnie.core.craftgui.events;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
|
||||
public class EventTextEdit extends EventValueChanged<String> {
|
||||
public EventTextEdit(IWidget origin, String text) {
|
||||
super(origin, text);
|
||||
}
|
||||
public EventTextEdit(IWidget origin, String text) {
|
||||
super(origin, text);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<EventTextEdit> {
|
||||
public Handler() {
|
||||
super(EventTextEdit.class);
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<EventTextEdit> {
|
||||
public Handler() {
|
||||
super(EventTextEdit.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,14 @@ package binnie.core.craftgui.events;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
|
||||
public class EventToggleButtonClicked extends Event {
|
||||
protected boolean toggled;
|
||||
protected boolean toggled;
|
||||
|
||||
public EventToggleButtonClicked(IWidget origin, boolean toggled) {
|
||||
super(origin);
|
||||
this.toggled = toggled;
|
||||
}
|
||||
public EventToggleButtonClicked(IWidget origin, boolean toggled) {
|
||||
super(origin);
|
||||
this.toggled = toggled;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return toggled;
|
||||
}
|
||||
public boolean isActive() {
|
||||
return toggled;
|
||||
}
|
||||
}
|
||||
@@ -3,20 +3,20 @@ package binnie.core.craftgui.events;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
|
||||
public class EventValueChanged<T> extends Event {
|
||||
public T value;
|
||||
public T value;
|
||||
|
||||
public EventValueChanged(IWidget origin, T value) {
|
||||
super(origin);
|
||||
this.value = value;
|
||||
}
|
||||
public EventValueChanged(IWidget origin, T value) {
|
||||
super(origin);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<EventValueChanged> {
|
||||
public Handler() {
|
||||
super(EventValueChanged.class);
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<EventValueChanged> {
|
||||
public Handler() {
|
||||
super(EventValueChanged.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,14 @@ package binnie.core.craftgui.events;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
|
||||
public class EventValuesChanged<T> extends Event {
|
||||
public T[] values;
|
||||
public T[] values;
|
||||
|
||||
public EventValuesChanged(IWidget origin, T[] values) {
|
||||
super(origin);
|
||||
this.values = values;
|
||||
}
|
||||
public EventValuesChanged(IWidget origin, T[] values) {
|
||||
super(origin);
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public T[] getValues() {
|
||||
return values;
|
||||
}
|
||||
public T[] getValues() {
|
||||
return values;
|
||||
}
|
||||
}
|
||||
@@ -3,182 +3,182 @@ package binnie.core.craftgui.events;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
|
||||
public class EventWidget extends Event {
|
||||
public EventWidget(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public EventWidget(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public static class Enable extends EventWidget {
|
||||
public Enable(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public static class Enable extends EventWidget {
|
||||
public Enable(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Enable> {
|
||||
public Handler() {
|
||||
super(Enable.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<Enable> {
|
||||
public Handler() {
|
||||
super(Enable.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Disable extends EventWidget {
|
||||
public Disable(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public static class Disable extends EventWidget {
|
||||
public Disable(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Disable> {
|
||||
public Handler() {
|
||||
super(Disable.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<Disable> {
|
||||
public Handler() {
|
||||
super(Disable.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Show extends EventWidget {
|
||||
public Show(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public static class Show extends EventWidget {
|
||||
public Show(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Show> {
|
||||
public Handler() {
|
||||
super(Show.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<Show> {
|
||||
public Handler() {
|
||||
super(Show.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Hide extends EventWidget {
|
||||
public Hide(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public static class Hide extends EventWidget {
|
||||
public Hide(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Hide> {
|
||||
public Handler() {
|
||||
super(Hide.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<Hide> {
|
||||
public Handler() {
|
||||
super(Hide.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ChangePosition extends EventWidget {
|
||||
public ChangePosition(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public static class ChangePosition extends EventWidget {
|
||||
public ChangePosition(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<ChangePosition> {
|
||||
public Handler() {
|
||||
super(ChangePosition.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<ChangePosition> {
|
||||
public Handler() {
|
||||
super(ChangePosition.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ChangeSize extends EventWidget {
|
||||
public ChangeSize(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public static class ChangeSize extends EventWidget {
|
||||
public ChangeSize(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<ChangeSize> {
|
||||
public Handler() {
|
||||
super(ChangeSize.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<ChangeSize> {
|
||||
public Handler() {
|
||||
super(ChangeSize.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ChangeOffset extends EventWidget {
|
||||
public ChangeOffset(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public static class ChangeOffset extends EventWidget {
|
||||
public ChangeOffset(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<ChangeOffset> {
|
||||
public Handler() {
|
||||
super(ChangeOffset.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<ChangeOffset> {
|
||||
public Handler() {
|
||||
super(ChangeOffset.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ChangeColour extends EventWidget {
|
||||
public ChangeColour(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public static class ChangeColour extends EventWidget {
|
||||
public ChangeColour(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<ChangeColour> {
|
||||
public Handler() {
|
||||
super(ChangeColour.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<ChangeColour> {
|
||||
public Handler() {
|
||||
super(ChangeColour.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class StartMouseOver extends EventWidget {
|
||||
public StartMouseOver(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public static class StartMouseOver extends EventWidget {
|
||||
public StartMouseOver(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<StartMouseOver> {
|
||||
public Handler() {
|
||||
super(StartMouseOver.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<StartMouseOver> {
|
||||
public Handler() {
|
||||
super(StartMouseOver.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class EndMouseOver extends EventWidget {
|
||||
public EndMouseOver(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public static class EndMouseOver extends EventWidget {
|
||||
public EndMouseOver(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<EndMouseOver> {
|
||||
public Handler() {
|
||||
super(EndMouseOver.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<EndMouseOver> {
|
||||
public Handler() {
|
||||
super(EndMouseOver.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class StartDrag extends EventWidget {
|
||||
protected int button;
|
||||
public static class StartDrag extends EventWidget {
|
||||
protected int button;
|
||||
|
||||
public StartDrag(IWidget origin, int button) {
|
||||
super(origin);
|
||||
this.button = button;
|
||||
}
|
||||
public StartDrag(IWidget origin, int button) {
|
||||
super(origin);
|
||||
this.button = button;
|
||||
}
|
||||
|
||||
public int getButton() {
|
||||
return button;
|
||||
}
|
||||
public int getButton() {
|
||||
return button;
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<StartDrag> {
|
||||
public Handler() {
|
||||
super(StartDrag.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<StartDrag> {
|
||||
public Handler() {
|
||||
super(StartDrag.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class EndDrag extends EventWidget {
|
||||
public EndDrag(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public static class EndDrag extends EventWidget {
|
||||
public EndDrag(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<EndDrag> {
|
||||
public Handler() {
|
||||
super(EndDrag.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<EndDrag> {
|
||||
public Handler() {
|
||||
super(EndDrag.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class GainFocus extends EventWidget {
|
||||
public GainFocus(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public static class GainFocus extends EventWidget {
|
||||
public GainFocus(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<GainFocus> {
|
||||
public Handler() {
|
||||
super(GainFocus.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<GainFocus> {
|
||||
public Handler() {
|
||||
super(GainFocus.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class LoseFocus extends EventWidget {
|
||||
public LoseFocus(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
public static class LoseFocus extends EventWidget {
|
||||
public LoseFocus(IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<LoseFocus> {
|
||||
public Handler() {
|
||||
super(LoseFocus.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract static class Handler extends EventHandler<LoseFocus> {
|
||||
public Handler() {
|
||||
super(LoseFocus.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,61 +5,61 @@ import binnie.core.craftgui.controls.core.IControlValue;
|
||||
import binnie.core.craftgui.events.EventValueChanged;
|
||||
|
||||
public class CraftGUIUtil {
|
||||
public static void alignToWidget(IWidget target, IWidget relativeTo) {
|
||||
IPoint startPos = target.getAbsolutePosition();
|
||||
IPoint endPos = relativeTo.getAbsolutePosition();
|
||||
moveWidget(target, endPos.sub(startPos));
|
||||
}
|
||||
public static void alignToWidget(IWidget target, IWidget relativeTo) {
|
||||
IPoint startPos = target.getAbsolutePosition();
|
||||
IPoint endPos = relativeTo.getAbsolutePosition();
|
||||
moveWidget(target, endPos.sub(startPos));
|
||||
}
|
||||
|
||||
public static void moveWidget(IWidget target, IPoint movement) {
|
||||
target.setPosition(target.getPosition().add(movement));
|
||||
}
|
||||
public static void moveWidget(IWidget target, IPoint movement) {
|
||||
target.setPosition(target.getPosition().add(movement));
|
||||
}
|
||||
|
||||
public static void horizontalGrid(float px, float py, IWidget... widgets) {
|
||||
horizontalGrid(px, py, TextJustification.MIDDLE_CENTER, 0.0f, widgets);
|
||||
}
|
||||
public static void horizontalGrid(float px, float py, IWidget... widgets) {
|
||||
horizontalGrid(px, py, TextJustification.MIDDLE_CENTER, 0.0f, widgets);
|
||||
}
|
||||
|
||||
public static void horizontalGrid(float px, float py, TextJustification just, float spacing, IWidget... widgets) {
|
||||
float x = 0.0f;
|
||||
float h = 0.0f;
|
||||
for (IWidget widget : widgets) {
|
||||
h = Math.max(h, widget.getSize().y());
|
||||
}
|
||||
for (IWidget widget : widgets) {
|
||||
widget.setPosition(new IPoint(px + x, py + (h - widget.getSize().y()) * just.yOffset));
|
||||
x += widget.getSize().x() + spacing;
|
||||
}
|
||||
}
|
||||
public static void horizontalGrid(float px, float py, TextJustification just, float spacing, IWidget... widgets) {
|
||||
float x = 0.0f;
|
||||
float h = 0.0f;
|
||||
for (IWidget widget : widgets) {
|
||||
h = Math.max(h, widget.getSize().y());
|
||||
}
|
||||
for (IWidget widget : widgets) {
|
||||
widget.setPosition(new IPoint(px + x, py + (h - widget.getSize().y()) * just.yOffset));
|
||||
x += widget.getSize().x() + spacing;
|
||||
}
|
||||
}
|
||||
|
||||
public static void verticalGrid(float px, float py, IWidget... widgets) {
|
||||
horizontalGrid(px, py, TextJustification.MIDDLE_CENTER, 0.0f, widgets);
|
||||
}
|
||||
public static void verticalGrid(float px, float py, IWidget... widgets) {
|
||||
horizontalGrid(px, py, TextJustification.MIDDLE_CENTER, 0.0f, widgets);
|
||||
}
|
||||
|
||||
public static void verticalGrid(float px, float py, TextJustification just, float spacing, IWidget... widgets) {
|
||||
float y = 0.0f;
|
||||
float w = 0.0f;
|
||||
for (IWidget widget : widgets) {
|
||||
w = Math.max(w, widget.getSize().x());
|
||||
}
|
||||
for (IWidget widget : widgets) {
|
||||
widget.setPosition(new IPoint(px + (w - widget.getSize().x()) * just.xOffset, py + y));
|
||||
y += widget.getSize().y() + spacing;
|
||||
}
|
||||
}
|
||||
public static void verticalGrid(float px, float py, TextJustification just, float spacing, IWidget... widgets) {
|
||||
float y = 0.0f;
|
||||
float w = 0.0f;
|
||||
for (IWidget widget : widgets) {
|
||||
w = Math.max(w, widget.getSize().x());
|
||||
}
|
||||
for (IWidget widget : widgets) {
|
||||
widget.setPosition(new IPoint(px + (w - widget.getSize().x()) * just.xOffset, py + y));
|
||||
y += widget.getSize().y() + spacing;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void linkWidgets(IControlValue<T> tab, IControlValue<T> target) {
|
||||
tab.addSelfEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
target.setValue((T) event.getValue());
|
||||
}
|
||||
});
|
||||
public static <T> void linkWidgets(IControlValue<T> tab, IControlValue<T> target) {
|
||||
tab.addSelfEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
target.setValue((T) event.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
target.addSelfEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
tab.setValue((T) event.getValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
target.addSelfEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventValueChanged event) {
|
||||
tab.setValue((T) event.getValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,129 +1,121 @@
|
||||
package binnie.core.craftgui.geometry;
|
||||
|
||||
public class IArea {
|
||||
private IPoint pos;
|
||||
private IPoint size;
|
||||
private IPoint pos;
|
||||
private IPoint size;
|
||||
|
||||
public IArea(IArea area) {
|
||||
this(area.pos().x(), area.pos().y(), area.size().x(), area.size().y());
|
||||
}
|
||||
public IArea(IArea area) {
|
||||
this(area.pos().x(), area.pos().y(), area.size().x(), area.size().y());
|
||||
}
|
||||
|
||||
public IArea(IPoint pos, IPoint size) {
|
||||
this(pos.x(), pos.y(), size.x(), size.y());
|
||||
}
|
||||
public IArea(IPoint pos, IPoint size) {
|
||||
this(pos.x(), pos.y(), size.x(), size.y());
|
||||
}
|
||||
|
||||
public IArea(float xywh) {
|
||||
this(xywh, xywh, xywh, xywh);
|
||||
}
|
||||
public IArea(float xywh) {
|
||||
this(xywh, xywh, xywh, xywh);
|
||||
}
|
||||
|
||||
public IArea(float xy, float wh) {
|
||||
this(xy, xy, wh, wh);
|
||||
}
|
||||
public IArea(float xy, float wh) {
|
||||
this(xy, xy, wh, wh);
|
||||
}
|
||||
|
||||
public IArea(float x, float y, float wh) {
|
||||
this(x, y, wh, wh);
|
||||
}
|
||||
public IArea(float x, float y, float wh) {
|
||||
this(x, y, wh, wh);
|
||||
}
|
||||
|
||||
public IArea(float x, float y, float w, float h) {
|
||||
setPosition(new IPoint(x, y));
|
||||
setSize(new IPoint(w, h));
|
||||
}
|
||||
public IArea(float x, float y, float w, float h) {
|
||||
setPosition(new IPoint(x, y));
|
||||
setSize(new IPoint(w, h));
|
||||
}
|
||||
|
||||
public IPoint pos() {
|
||||
return pos;
|
||||
}
|
||||
public IPoint pos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public IPoint getPosition() {
|
||||
return pos;
|
||||
}
|
||||
public IPoint getPosition() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public void setPosition(IPoint position) {
|
||||
pos = position.copy();
|
||||
}
|
||||
public void setPosition(IPoint position) {
|
||||
pos = position.copy();
|
||||
}
|
||||
|
||||
public IPoint size() {
|
||||
return size;
|
||||
}
|
||||
public IPoint size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public IPoint getSize() {
|
||||
return size;
|
||||
}
|
||||
public IPoint getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(IPoint size) {
|
||||
this.size = size.copy();
|
||||
}
|
||||
public void setSize(IPoint size) {
|
||||
this.size = size.copy();
|
||||
}
|
||||
|
||||
public boolean contains(IPoint position) {
|
||||
return position.x() >= pos().x()
|
||||
&& position.y() >= pos.y()
|
||||
&& position.x() <= pos().x() + size().x()
|
||||
&& position.y() <= pos().y() + size().y();
|
||||
}
|
||||
public boolean contains(IPoint position) {
|
||||
return position.x() >= pos().x()
|
||||
&& position.y() >= pos.y()
|
||||
&& position.x() <= pos().x() + size().x()
|
||||
&& position.y() <= pos().y() + size().y();
|
||||
}
|
||||
|
||||
public float x() {
|
||||
return pos().x();
|
||||
}
|
||||
public float x() {
|
||||
return pos().x();
|
||||
}
|
||||
|
||||
public float y() {
|
||||
return pos().y();
|
||||
}
|
||||
public float y() {
|
||||
return pos().y();
|
||||
}
|
||||
|
||||
public float w() {
|
||||
return size().x();
|
||||
}
|
||||
public float w() {
|
||||
return size().x();
|
||||
}
|
||||
|
||||
public float h() {
|
||||
return size().y();
|
||||
}
|
||||
public float h() {
|
||||
return size().y();
|
||||
}
|
||||
|
||||
public float x(float n) {
|
||||
return pos.x(n);
|
||||
}
|
||||
public float x(float n) {
|
||||
return pos.x(n);
|
||||
}
|
||||
|
||||
public float y(float n) {
|
||||
return pos.y(n);
|
||||
}
|
||||
public float y(float n) {
|
||||
return pos.y(n);
|
||||
}
|
||||
|
||||
public float w(float n) {
|
||||
return size.x(n);
|
||||
}
|
||||
public float w(float n) {
|
||||
return size.x(n);
|
||||
}
|
||||
|
||||
public float h(float n) {
|
||||
return size.y(n);
|
||||
}
|
||||
public float h(float n) {
|
||||
return size.y(n);
|
||||
}
|
||||
|
||||
public IArea inset(IBorder border) {
|
||||
return new IArea(
|
||||
x() + border.l(),
|
||||
y() + border.t(),
|
||||
w() - border.l() - border.r(),
|
||||
h() - border.t() - border.b()
|
||||
);
|
||||
}
|
||||
public IArea inset(IBorder border) {
|
||||
return new IArea(
|
||||
x() + border.l(), y() + border.t(), w() - border.l() - border.r(), h() - border.t() - border.b());
|
||||
}
|
||||
|
||||
public IArea outset(int outset) {
|
||||
return outset(new IBorder(outset));
|
||||
}
|
||||
public IArea outset(int outset) {
|
||||
return outset(new IBorder(outset));
|
||||
}
|
||||
|
||||
public IArea outset(IBorder border) {
|
||||
return new IArea(
|
||||
x() - border.l(),
|
||||
y() - border.t(),
|
||||
w() + border.l() + border.r(),
|
||||
h() + border.t() + border.b()
|
||||
);
|
||||
}
|
||||
public IArea outset(IBorder border) {
|
||||
return new IArea(
|
||||
x() - border.l(), y() - border.t(), w() + border.l() + border.r(), h() + border.t() + border.b());
|
||||
}
|
||||
|
||||
public IArea inset(int inset) {
|
||||
return inset(new IBorder(inset));
|
||||
}
|
||||
public IArea inset(int inset) {
|
||||
return inset(new IBorder(inset));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return w() + "x" + h() + "@" + x() + "," + y();
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return w() + "x" + h() + "@" + x() + "," + y();
|
||||
}
|
||||
|
||||
public IArea shift(float dx, float f) {
|
||||
return new IArea(x() + dx, y() + f, w(), h());
|
||||
}
|
||||
public IArea shift(float dx, float f) {
|
||||
return new IArea(x() + dx, y() + f, w(), h());
|
||||
}
|
||||
}
|
||||
@@ -1,102 +1,106 @@
|
||||
package binnie.core.craftgui.geometry;
|
||||
|
||||
public class IBorder {
|
||||
public static IBorder ZERO = new IBorder(0.0f);
|
||||
|
||||
protected float t;
|
||||
protected float b;
|
||||
protected float l;
|
||||
protected float r;
|
||||
public static IBorder ZERO = new IBorder(0.0f);
|
||||
|
||||
public IBorder(float pad) {
|
||||
this(pad, pad, pad, pad);
|
||||
}
|
||||
protected float t;
|
||||
protected float b;
|
||||
protected float l;
|
||||
protected float r;
|
||||
|
||||
public IBorder(float tb, float rl) {
|
||||
this(tb, rl, tb, rl);
|
||||
}
|
||||
public IBorder(float pad) {
|
||||
this(pad, pad, pad, pad);
|
||||
}
|
||||
|
||||
public IBorder(float t, float rl, float b) {
|
||||
this(t, rl, b, rl);
|
||||
}
|
||||
public IBorder(float tb, float rl) {
|
||||
this(tb, rl, tb, rl);
|
||||
}
|
||||
|
||||
public IBorder(float t, float r, float b, float l) {
|
||||
this.t = t;
|
||||
this.b = b;
|
||||
this.l = l;
|
||||
this.r = r;
|
||||
}
|
||||
public IBorder(float t, float rl, float b) {
|
||||
this(t, rl, b, rl);
|
||||
}
|
||||
|
||||
public IBorder(Position edge, float n) {
|
||||
this((edge == Position.TOP) ? n : 0.0f, (edge == Position.RIGHT) ? n : 0.0f, (edge == Position.BOTTOM) ? n : 0.0f, (edge == Position.LEFT) ? n : 0.0f);
|
||||
}
|
||||
public IBorder(float t, float r, float b, float l) {
|
||||
this.t = t;
|
||||
this.b = b;
|
||||
this.l = l;
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public IBorder(IBorder padding) {
|
||||
this(padding.t(), padding.r(), padding.b(), padding.l());
|
||||
}
|
||||
public IBorder(Position edge, float n) {
|
||||
this(
|
||||
(edge == Position.TOP) ? n : 0.0f,
|
||||
(edge == Position.RIGHT) ? n : 0.0f,
|
||||
(edge == Position.BOTTOM) ? n : 0.0f,
|
||||
(edge == Position.LEFT) ? n : 0.0f);
|
||||
}
|
||||
|
||||
public float t() {
|
||||
return t;
|
||||
}
|
||||
public IBorder(IBorder padding) {
|
||||
this(padding.t(), padding.r(), padding.b(), padding.l());
|
||||
}
|
||||
|
||||
public float b() {
|
||||
return b;
|
||||
}
|
||||
public float t() {
|
||||
return t;
|
||||
}
|
||||
|
||||
public float l() {
|
||||
return l;
|
||||
}
|
||||
public float b() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public float r() {
|
||||
return r;
|
||||
}
|
||||
public float l() {
|
||||
return l;
|
||||
}
|
||||
|
||||
public float t(float n) {
|
||||
return t = n;
|
||||
}
|
||||
public float r() {
|
||||
return r;
|
||||
}
|
||||
|
||||
public float b(float n) {
|
||||
return b = n;
|
||||
}
|
||||
public float t(float n) {
|
||||
return t = n;
|
||||
}
|
||||
|
||||
public float l(float n) {
|
||||
return l = n;
|
||||
}
|
||||
public float b(float n) {
|
||||
return b = n;
|
||||
}
|
||||
|
||||
public float r(float n) {
|
||||
return r = n;
|
||||
}
|
||||
public float l(float n) {
|
||||
return l = n;
|
||||
}
|
||||
|
||||
public boolean isNonZero() {
|
||||
return t != 0.0f || r != 0.0f || l != 0.0f || b != 0.0f;
|
||||
}
|
||||
public float r(float n) {
|
||||
return r = n;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IPoint tl() {
|
||||
return new IPoint(l(), t());
|
||||
}
|
||||
public boolean isNonZero() {
|
||||
return t != 0.0f || r != 0.0f || l != 0.0f || b != 0.0f;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IPoint tr() {
|
||||
return new IPoint(r(), t());
|
||||
}
|
||||
@Deprecated
|
||||
public IPoint tl() {
|
||||
return new IPoint(l(), t());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IPoint bl() {
|
||||
return new IPoint(l(), b());
|
||||
}
|
||||
@Deprecated
|
||||
public IPoint tr() {
|
||||
return new IPoint(r(), t());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IPoint br() {
|
||||
return new IPoint(r(), b());
|
||||
}
|
||||
@Deprecated
|
||||
public IPoint bl() {
|
||||
return new IPoint(l(), b());
|
||||
}
|
||||
|
||||
public IBorder add(IBorder o) {
|
||||
return new IBorder(t() + o.t(), r() + o.r(), b() + o.b(), l() + o.l());
|
||||
}
|
||||
@Deprecated
|
||||
public IPoint br() {
|
||||
return new IPoint(r(), b());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return t() + "-" + r() + "-" + b() + "-" + l();
|
||||
}
|
||||
public IBorder add(IBorder o) {
|
||||
return new IBorder(t() + o.t(), r() + o.r(), b() + o.b(), l() + o.l());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return t() + "-" + r() + "-" + b() + "-" + l();
|
||||
}
|
||||
}
|
||||
@@ -1,67 +1,67 @@
|
||||
package binnie.core.craftgui.geometry;
|
||||
|
||||
public class IPoint {
|
||||
public static IPoint ZERO = new IPoint(0.0f, 0.0f);
|
||||
public static IPoint ZERO = new IPoint(0.0f, 0.0f);
|
||||
|
||||
protected float x;
|
||||
protected float y;
|
||||
protected float x;
|
||||
protected float y;
|
||||
|
||||
public IPoint(float x, float y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
public IPoint(float x, float y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public IPoint(IPoint o) {
|
||||
x = o.x();
|
||||
y = o.y();
|
||||
}
|
||||
public IPoint(IPoint o) {
|
||||
x = o.x();
|
||||
y = o.y();
|
||||
}
|
||||
|
||||
public static IPoint add(IPoint a, IPoint b) {
|
||||
return new IPoint(a.x() + b.x(), a.y() + b.y());
|
||||
}
|
||||
public static IPoint add(IPoint a, IPoint b) {
|
||||
return new IPoint(a.x() + b.x(), a.y() + b.y());
|
||||
}
|
||||
|
||||
public static IPoint sub(IPoint a, IPoint b) {
|
||||
return new IPoint(a.x() - b.x(), a.y() - b.y());
|
||||
}
|
||||
public static IPoint sub(IPoint a, IPoint b) {
|
||||
return new IPoint(a.x() - b.x(), a.y() - b.y());
|
||||
}
|
||||
|
||||
public IPoint sub(IPoint a) {
|
||||
return sub(this, a);
|
||||
}
|
||||
public IPoint sub(IPoint a) {
|
||||
return sub(this, a);
|
||||
}
|
||||
|
||||
public IPoint add(IPoint other) {
|
||||
return add(this, other);
|
||||
}
|
||||
public IPoint add(IPoint other) {
|
||||
return add(this, other);
|
||||
}
|
||||
|
||||
public IPoint add(float dx, float dy) {
|
||||
return add(this, new IPoint(dx, dy));
|
||||
}
|
||||
public IPoint add(float dx, float dy) {
|
||||
return add(this, new IPoint(dx, dy));
|
||||
}
|
||||
|
||||
public IPoint copy() {
|
||||
return new IPoint(this);
|
||||
}
|
||||
public IPoint copy() {
|
||||
return new IPoint(this);
|
||||
}
|
||||
|
||||
public float x() {
|
||||
return x;
|
||||
}
|
||||
public float x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public float y() {
|
||||
return y;
|
||||
}
|
||||
public float y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void xy(float x, float y) {
|
||||
x(x);
|
||||
y(y);
|
||||
}
|
||||
public void xy(float x, float y) {
|
||||
x(x);
|
||||
y(y);
|
||||
}
|
||||
|
||||
public float x(float x) {
|
||||
return this.x = x;
|
||||
}
|
||||
public float x(float x) {
|
||||
return this.x = x;
|
||||
}
|
||||
|
||||
public float y(float y) {
|
||||
return this.y = y;
|
||||
}
|
||||
public float y(float y) {
|
||||
return this.y = y;
|
||||
}
|
||||
|
||||
public boolean equals(IPoint other) {
|
||||
return x() == other.x() && y() == other.y();
|
||||
}
|
||||
public boolean equals(IPoint other) {
|
||||
return x() == other.x() && y() == other.y();
|
||||
}
|
||||
}
|
||||
@@ -1,41 +1,41 @@
|
||||
package binnie.core.craftgui.geometry;
|
||||
|
||||
public enum Position {
|
||||
TOP(0, -1),
|
||||
BOTTOM(0, 1),
|
||||
LEFT(-1, 0),
|
||||
RIGHT(1, 0);
|
||||
TOP(0, -1),
|
||||
BOTTOM(0, 1),
|
||||
LEFT(-1, 0),
|
||||
RIGHT(1, 0);
|
||||
|
||||
protected int x;
|
||||
protected int y;
|
||||
protected int x;
|
||||
protected int y;
|
||||
|
||||
Position(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
Position(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int x() {
|
||||
return x;
|
||||
}
|
||||
public int x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int y() {
|
||||
return y;
|
||||
}
|
||||
public int y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public Position opposite() {
|
||||
switch (this) {
|
||||
case BOTTOM:
|
||||
return Position.TOP;
|
||||
public Position opposite() {
|
||||
switch (this) {
|
||||
case BOTTOM:
|
||||
return Position.TOP;
|
||||
|
||||
case LEFT:
|
||||
return Position.RIGHT;
|
||||
case LEFT:
|
||||
return Position.RIGHT;
|
||||
|
||||
case RIGHT:
|
||||
return Position.LEFT;
|
||||
case RIGHT:
|
||||
return Position.LEFT;
|
||||
|
||||
case TOP:
|
||||
return Position.BOTTOM;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
case TOP:
|
||||
return Position.BOTTOM;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,29 @@
|
||||
package binnie.core.craftgui.geometry;
|
||||
|
||||
public enum TextJustification {
|
||||
TOP_LEFT(0.0f, 0.0f),
|
||||
TOP_CENTER(0.5f, 0.0f),
|
||||
TOP_RIGHT(1.0f, 0.0f),
|
||||
MIDDLE_LEFT(0.0f, 0.5f),
|
||||
MIDDLE_CENTER(0.5f, 0.5f),
|
||||
MIDDLE_RIGHT(1.0f, 0.5f),
|
||||
BOTTOM_LEFT(0.0f, 1.0f),
|
||||
BOTTOM_CENTER(0.5f, 1.0f),
|
||||
BOTTOM_RIGHT(1.0f, 1.0f);
|
||||
TOP_LEFT(0.0f, 0.0f),
|
||||
TOP_CENTER(0.5f, 0.0f),
|
||||
TOP_RIGHT(1.0f, 0.0f),
|
||||
MIDDLE_LEFT(0.0f, 0.5f),
|
||||
MIDDLE_CENTER(0.5f, 0.5f),
|
||||
MIDDLE_RIGHT(1.0f, 0.5f),
|
||||
BOTTOM_LEFT(0.0f, 1.0f),
|
||||
BOTTOM_CENTER(0.5f, 1.0f),
|
||||
BOTTOM_RIGHT(1.0f, 1.0f);
|
||||
|
||||
protected float xOffset;
|
||||
protected float yOffset;
|
||||
protected float xOffset;
|
||||
protected float yOffset;
|
||||
|
||||
TextJustification(float xOffset, float yOffset) {
|
||||
this.xOffset = xOffset;
|
||||
this.yOffset = yOffset;
|
||||
}
|
||||
TextJustification(float xOffset, float yOffset) {
|
||||
this.xOffset = xOffset;
|
||||
this.yOffset = yOffset;
|
||||
}
|
||||
|
||||
public float getXOffset() {
|
||||
return xOffset;
|
||||
}
|
||||
public float getXOffset() {
|
||||
return xOffset;
|
||||
}
|
||||
|
||||
public float getYOffset() {
|
||||
return yOffset;
|
||||
}
|
||||
public float getYOffset() {
|
||||
return yOffset;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,10 @@ import binnie.core.machines.transfer.TransferRequest;
|
||||
import binnie.core.network.packet.MessageContainerUpdate;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -27,492 +31,487 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ContainerCraftGUI extends Container {
|
||||
private Window window;
|
||||
private Map<String, NBTTagCompound> syncedNBT;
|
||||
private Map<String, NBTTagCompound> sentNBT;
|
||||
private Map<Integer, TankInfo> syncedTanks;
|
||||
private PowerInfo syncedPower;
|
||||
private ProcessInfo syncedProcess;
|
||||
private int errorType;
|
||||
private ErrorState error;
|
||||
private int mousedOverSlotNumber;
|
||||
private Window window;
|
||||
private Map<String, NBTTagCompound> syncedNBT;
|
||||
private Map<String, NBTTagCompound> sentNBT;
|
||||
private Map<Integer, TankInfo> syncedTanks;
|
||||
private PowerInfo syncedPower;
|
||||
private ProcessInfo syncedProcess;
|
||||
private int errorType;
|
||||
private ErrorState error;
|
||||
private int mousedOverSlotNumber;
|
||||
|
||||
public ContainerCraftGUI(Window window) {
|
||||
this.window = window;
|
||||
syncedNBT = new HashMap<>();
|
||||
sentNBT = new HashMap<>();
|
||||
syncedTanks = new HashMap<>();
|
||||
syncedPower = new PowerInfo();
|
||||
syncedProcess = new ProcessInfo();
|
||||
errorType = 0;
|
||||
error = null;
|
||||
mousedOverSlotNumber = -1;
|
||||
IMachine machine = Machine.getMachine(window.getInventory());
|
||||
if (getSide() != Side.SERVER) {
|
||||
return;
|
||||
}
|
||||
public ContainerCraftGUI(Window window) {
|
||||
this.window = window;
|
||||
syncedNBT = new HashMap<>();
|
||||
sentNBT = new HashMap<>();
|
||||
syncedTanks = new HashMap<>();
|
||||
syncedPower = new PowerInfo();
|
||||
syncedProcess = new ProcessInfo();
|
||||
errorType = 0;
|
||||
error = null;
|
||||
mousedOverSlotNumber = -1;
|
||||
IMachine machine = Machine.getMachine(window.getInventory());
|
||||
if (getSide() != Side.SERVER) {
|
||||
return;
|
||||
}
|
||||
|
||||
inventoryItemStacks = new ListMap();
|
||||
inventorySlots = new ListMap();
|
||||
if (machine == null) {
|
||||
return;
|
||||
}
|
||||
inventoryItemStacks = new ListMap();
|
||||
inventorySlots = new ListMap();
|
||||
if (machine == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GameProfile user = machine.getOwner();
|
||||
if (user != null) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setString("username", user.getName());
|
||||
sendNBTToClient("username", nbt);
|
||||
}
|
||||
}
|
||||
GameProfile user = machine.getOwner();
|
||||
if (user != null) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setString("username", user.getName());
|
||||
sendNBTToClient("username", nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Slot addSlotToContainer(Slot slot) {
|
||||
return super.addSlotToContainer(slot);
|
||||
}
|
||||
@Override
|
||||
protected Slot addSlotToContainer(Slot slot) {
|
||||
return super.addSlotToContainer(slot);
|
||||
}
|
||||
|
||||
private Side getSide() {
|
||||
return window.isServer() ? Side.SERVER : Side.CLIENT;
|
||||
}
|
||||
private Side getSide() {
|
||||
return window.isServer() ? Side.SERVER : Side.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slot getSlot(int index) {
|
||||
if (index < 0 || index >= inventorySlots.size()) {
|
||||
return null;
|
||||
}
|
||||
return (Slot) inventorySlots.get(index);
|
||||
}
|
||||
@Override
|
||||
public Slot getSlot(int index) {
|
||||
if (index < 0 || index >= inventorySlots.size()) {
|
||||
return null;
|
||||
}
|
||||
return (Slot) inventorySlots.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStackInSlot(int index, ItemStack stack) {
|
||||
if (getSlot(index) != null) {
|
||||
getSlot(index).putStack(stack);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void putStackInSlot(int index, ItemStack stack) {
|
||||
if (getSlot(index) != null) {
|
||||
getSlot(index).putStack(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStacksInSlots(ItemStack[] par1ArrayOfItemStack) {
|
||||
for (int i = 0; i < par1ArrayOfItemStack.length; ++i) {
|
||||
if (getSlot(i) != null) {
|
||||
getSlot(i).putStack(par1ArrayOfItemStack[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void putStacksInSlots(ItemStack[] par1ArrayOfItemStack) {
|
||||
for (int i = 0; i < par1ArrayOfItemStack.length; ++i) {
|
||||
if (getSlot(i) != null) {
|
||||
getSlot(i).putStack(par1ArrayOfItemStack[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
WindowInventory inventory = window.getWindowInventory();
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
if (!inventory.dispenseOnClose(i)) {
|
||||
continue;
|
||||
}
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
WindowInventory inventory = window.getWindowInventory();
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
if (!inventory.dispenseOnClose(i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack == null) {
|
||||
continue;
|
||||
}
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
stack = new TransferRequest(stack, player.inventory).transfer(true);
|
||||
if (stack != null) {
|
||||
player.dropPlayerItemWithRandomChoice(stack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
stack = new TransferRequest(stack, player.inventory).transfer(true);
|
||||
if (stack != null) {
|
||||
player.dropPlayerItemWithRandomChoice(stack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player) {
|
||||
Slot slot = getSlot(slotNum);
|
||||
if (slot instanceof CustomSlot && ((CustomSlot) slot).handleClick()) {
|
||||
((CustomSlot) slot).onSlotClick(this, mouseButton, modifier, player);
|
||||
return player.inventory.getItemStack();
|
||||
}
|
||||
return super.slotClick(slotNum, mouseButton, modifier, player);
|
||||
}
|
||||
@Override
|
||||
public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player) {
|
||||
Slot slot = getSlot(slotNum);
|
||||
if (slot instanceof CustomSlot && ((CustomSlot) slot).handleClick()) {
|
||||
((CustomSlot) slot).onSlotClick(this, mouseButton, modifier, player);
|
||||
return player.inventory.getItemStack();
|
||||
}
|
||||
return super.slotClick(slotNum, mouseButton, modifier, player);
|
||||
}
|
||||
|
||||
public void sendNBTToClient(String key, NBTTagCompound nbt) {
|
||||
syncedNBT.put(key, nbt);
|
||||
}
|
||||
public void sendNBTToClient(String key, NBTTagCompound nbt) {
|
||||
syncedNBT.put(key, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
if (!crafters.contains(player)) {
|
||||
crafters.add(player);
|
||||
}
|
||||
sentNBT.clear();
|
||||
}
|
||||
IInventory inventory = window.getInventory();
|
||||
return inventory == null || inventory.isUseableByPlayer(player);
|
||||
}
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
if (!crafters.contains(player)) {
|
||||
crafters.add(player);
|
||||
}
|
||||
sentNBT.clear();
|
||||
}
|
||||
IInventory inventory = window.getInventory();
|
||||
return inventory == null || inventory.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
|
||||
return shiftClick(player, slotID);
|
||||
}
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
|
||||
return shiftClick(player, slotID);
|
||||
}
|
||||
|
||||
private ItemStack shiftClick(EntityPlayer player, int index) {
|
||||
TransferRequest request = getShiftClickRequest(player, index);
|
||||
if (request == null) {
|
||||
return null;
|
||||
}
|
||||
private ItemStack shiftClick(EntityPlayer player, int index) {
|
||||
TransferRequest request = getShiftClickRequest(player, index);
|
||||
if (request == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack stack = request.transfer(true);
|
||||
Slot shiftClickedSlot = (Slot) inventorySlots.get(index);
|
||||
shiftClickedSlot.putStack(stack);
|
||||
shiftClickedSlot.onSlotChanged();
|
||||
return null;
|
||||
}
|
||||
ItemStack stack = request.transfer(true);
|
||||
Slot shiftClickedSlot = (Slot) inventorySlots.get(index);
|
||||
shiftClickedSlot.putStack(stack);
|
||||
shiftClickedSlot.onSlotChanged();
|
||||
return null;
|
||||
}
|
||||
|
||||
private TransferRequest getShiftClickRequest(EntityPlayer player, int index) {
|
||||
if (index < 0) {
|
||||
return null;
|
||||
}
|
||||
private TransferRequest getShiftClickRequest(EntityPlayer player, int index) {
|
||||
if (index < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Slot shiftClickedSlot = (Slot) inventorySlots.get(index);
|
||||
ItemStack itemstack = null;
|
||||
if (shiftClickedSlot.getHasStack()) {
|
||||
itemstack = shiftClickedSlot.getStack().copy();
|
||||
}
|
||||
Slot shiftClickedSlot = (Slot) inventorySlots.get(index);
|
||||
ItemStack itemstack = null;
|
||||
if (shiftClickedSlot.getHasStack()) {
|
||||
itemstack = shiftClickedSlot.getStack().copy();
|
||||
}
|
||||
|
||||
IInventory playerInventory = player.inventory;
|
||||
IInventory containerInventory = window.getInventory();
|
||||
IInventory windowInventory = window.getWindowInventory();
|
||||
IInventory fromPlayer = (containerInventory == null) ? windowInventory : containerInventory;
|
||||
int[] target = new int[36];
|
||||
for (int i = 0; i < 36; ++i) {
|
||||
target[i] = i;
|
||||
}
|
||||
IInventory playerInventory = player.inventory;
|
||||
IInventory containerInventory = window.getInventory();
|
||||
IInventory windowInventory = window.getWindowInventory();
|
||||
IInventory fromPlayer = (containerInventory == null) ? windowInventory : containerInventory;
|
||||
int[] target = new int[36];
|
||||
for (int i = 0; i < 36; ++i) {
|
||||
target[i] = i;
|
||||
}
|
||||
|
||||
TransferRequest request;
|
||||
if (shiftClickedSlot.inventory == playerInventory) {
|
||||
request = new TransferRequest(itemstack, fromPlayer).setOrigin(shiftClickedSlot.inventory);
|
||||
} else {
|
||||
request = new TransferRequest(itemstack, playerInventory).setOrigin(shiftClickedSlot.inventory).setTargetSlots(target);
|
||||
}
|
||||
TransferRequest request;
|
||||
if (shiftClickedSlot.inventory == playerInventory) {
|
||||
request = new TransferRequest(itemstack, fromPlayer).setOrigin(shiftClickedSlot.inventory);
|
||||
} else {
|
||||
request = new TransferRequest(itemstack, playerInventory)
|
||||
.setOrigin(shiftClickedSlot.inventory)
|
||||
.setTargetSlots(target);
|
||||
}
|
||||
|
||||
if (window instanceof IWindowAffectsShiftClick) {
|
||||
((IWindowAffectsShiftClick) window).alterRequest(request);
|
||||
}
|
||||
return request;
|
||||
}
|
||||
if (window instanceof IWindowAffectsShiftClick) {
|
||||
((IWindowAffectsShiftClick) window).alterRequest(request);
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
||||
public ItemStack tankClick(EntityPlayer player, int slotID) {
|
||||
if (player.inventory.getItemStack() == null) {
|
||||
return null;
|
||||
}
|
||||
public ItemStack tankClick(EntityPlayer player, int slotID) {
|
||||
if (player.inventory.getItemStack() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack heldItem = player.inventory.getItemStack().copy();
|
||||
heldItem = new TransferRequest(heldItem, window.getInventory())
|
||||
.setOrigin(player.inventory)
|
||||
.setTargetSlots(new int[0])
|
||||
.setTargetTanks(new int[]{slotID})
|
||||
.transfer(true);
|
||||
player.inventory.setItemStack(heldItem);
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) player).updateHeldItem();
|
||||
}
|
||||
return heldItem;
|
||||
}
|
||||
ItemStack heldItem = player.inventory.getItemStack().copy();
|
||||
heldItem = new TransferRequest(heldItem, window.getInventory())
|
||||
.setOrigin(player.inventory)
|
||||
.setTargetSlots(new int[0])
|
||||
.setTargetTanks(new int[] {slotID})
|
||||
.transfer(true);
|
||||
player.inventory.setItemStack(heldItem);
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) player).updateHeldItem();
|
||||
}
|
||||
return heldItem;
|
||||
}
|
||||
|
||||
public boolean handleNBT(Side side, EntityPlayer player, String name, NBTTagCompound action) {
|
||||
if (side == Side.SERVER) {
|
||||
if (name.equals("tank-click")) {
|
||||
tankClick(player, action.getByte("id"));
|
||||
}
|
||||
if (name.equals("slot-reg")) {
|
||||
int type = action.getByte("t");
|
||||
int index = action.getShort("i");
|
||||
int slotNumber = action.getShort("n");
|
||||
getOrCreateSlot(InventoryType.values()[type % 4], index, slotNumber);
|
||||
public boolean handleNBT(Side side, EntityPlayer player, String name, NBTTagCompound action) {
|
||||
if (side == Side.SERVER) {
|
||||
if (name.equals("tank-click")) {
|
||||
tankClick(player, action.getByte("id"));
|
||||
}
|
||||
if (name.equals("slot-reg")) {
|
||||
int type = action.getByte("t");
|
||||
int index = action.getShort("i");
|
||||
int slotNumber = action.getShort("n");
|
||||
getOrCreateSlot(InventoryType.values()[type % 4], index, slotNumber);
|
||||
|
||||
for (Object crafterObject : crafters) {
|
||||
ICrafting crafter = (ICrafting) crafterObject;
|
||||
crafter.sendContainerAndContentsToPlayer(this, getInventory());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Object crafterObject : crafters) {
|
||||
ICrafting crafter = (ICrafting) crafterObject;
|
||||
crafter.sendContainerAndContentsToPlayer(this, getInventory());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (name.contains("tank-update")) {
|
||||
onTankUpdate(action);
|
||||
} else if (name.equals("power-update")) {
|
||||
onPowerUpdate(action);
|
||||
} else if (name.equals("process-update")) {
|
||||
onProcessUpdate(action);
|
||||
} else if (name.equals("error-update")) {
|
||||
onErrorUpdate(action);
|
||||
} else if (name.equals("mouse-over-slot")) {
|
||||
onMouseOverSlot(player, action);
|
||||
} else if (name.equals("shift-click-info")) {
|
||||
onRecieveShiftClickHighlights(player, action);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (name.contains("tank-update")) {
|
||||
onTankUpdate(action);
|
||||
} else if (name.equals("power-update")) {
|
||||
onPowerUpdate(action);
|
||||
} else if (name.equals("process-update")) {
|
||||
onProcessUpdate(action);
|
||||
} else if (name.equals("error-update")) {
|
||||
onErrorUpdate(action);
|
||||
} else if (name.equals("mouse-over-slot")) {
|
||||
onMouseOverSlot(player, action);
|
||||
} else if (name.equals("shift-click-info")) {
|
||||
onRecieveShiftClickHighlights(player, action);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
ITankMachine tanks = Machine.getInterface(ITankMachine.class, window.getInventory());
|
||||
IPoweredMachine powered = Machine.getInterface(IPoweredMachine.class, window.getInventory());
|
||||
IErrorStateSource error = Machine.getInterface(IErrorStateSource.class, window.getInventory());
|
||||
IProcess process = Machine.getInterface(IProcess.class, window.getInventory());
|
||||
if (tanks != null && window.isServer()) {
|
||||
for (int i = 0; i < tanks.getTankInfos().length; ++i) {
|
||||
TankInfo tank = tanks.getTankInfos()[i];
|
||||
if (!getTankInfo(i).equals(tank)) {
|
||||
syncedNBT.put("tank-update-" + i, createTankNBT(i, tank));
|
||||
syncedTanks.put(i, tank);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
ITankMachine tanks = Machine.getInterface(ITankMachine.class, window.getInventory());
|
||||
IPoweredMachine powered = Machine.getInterface(IPoweredMachine.class, window.getInventory());
|
||||
IErrorStateSource error = Machine.getInterface(IErrorStateSource.class, window.getInventory());
|
||||
IProcess process = Machine.getInterface(IProcess.class, window.getInventory());
|
||||
if (tanks != null && window.isServer()) {
|
||||
for (int i = 0; i < tanks.getTankInfos().length; ++i) {
|
||||
TankInfo tank = tanks.getTankInfos()[i];
|
||||
if (!getTankInfo(i).equals(tank)) {
|
||||
syncedNBT.put("tank-update-" + i, createTankNBT(i, tank));
|
||||
syncedTanks.put(i, tank);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (powered != null && window.isServer()) {
|
||||
syncedNBT.put("power-update", createPowerNBT(powered.getPowerInfo()));
|
||||
}
|
||||
if (process != null && window.isServer()) {
|
||||
syncedNBT.put("process-update", createProcessNBT(process.getInfo()));
|
||||
}
|
||||
if (error != null && window.isServer()) {
|
||||
syncedNBT.put("error-update", createErrorNBT(error));
|
||||
}
|
||||
if (powered != null && window.isServer()) {
|
||||
syncedNBT.put("power-update", createPowerNBT(powered.getPowerInfo()));
|
||||
}
|
||||
if (process != null && window.isServer()) {
|
||||
syncedNBT.put("process-update", createProcessNBT(process.getInfo()));
|
||||
}
|
||||
if (error != null && window.isServer()) {
|
||||
syncedNBT.put("error-update", createErrorNBT(error));
|
||||
}
|
||||
|
||||
INetwork.SendGuiNBT machineSync = Machine.getInterface(INetwork.SendGuiNBT.class, window.getInventory());
|
||||
if (machineSync != null) {
|
||||
machineSync.sendGuiNBT(syncedNBT);
|
||||
}
|
||||
INetwork.SendGuiNBT machineSync = Machine.getInterface(INetwork.SendGuiNBT.class, window.getInventory());
|
||||
if (machineSync != null) {
|
||||
machineSync.sendGuiNBT(syncedNBT);
|
||||
}
|
||||
|
||||
Map<String, NBTTagCompound> sentThisTime = new HashMap<>();
|
||||
for (Map.Entry<String, NBTTagCompound> nbt : syncedNBT.entrySet()) {
|
||||
nbt.getValue().setString("type", nbt.getKey());
|
||||
boolean shouldSend = true;
|
||||
NBTTagCompound lastSent = sentNBT.get(nbt.getKey());
|
||||
if (lastSent != null) {
|
||||
shouldSend = !lastSent.equals(nbt.getValue());
|
||||
}
|
||||
Map<String, NBTTagCompound> sentThisTime = new HashMap<>();
|
||||
for (Map.Entry<String, NBTTagCompound> nbt : syncedNBT.entrySet()) {
|
||||
nbt.getValue().setString("type", nbt.getKey());
|
||||
boolean shouldSend = true;
|
||||
NBTTagCompound lastSent = sentNBT.get(nbt.getKey());
|
||||
if (lastSent != null) {
|
||||
shouldSend = !lastSent.equals(nbt.getValue());
|
||||
}
|
||||
|
||||
if (shouldSend) {
|
||||
for (Object crafter : crafters) {
|
||||
if (crafter instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) crafter;
|
||||
BinnieCore.proxy.sendToPlayer(new MessageContainerUpdate(nbt.getValue()), player);
|
||||
}
|
||||
}
|
||||
sentThisTime.put(nbt.getKey(), nbt.getValue());
|
||||
}
|
||||
}
|
||||
if (shouldSend) {
|
||||
for (Object crafter : crafters) {
|
||||
if (crafter instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) crafter;
|
||||
BinnieCore.proxy.sendToPlayer(new MessageContainerUpdate(nbt.getValue()), player);
|
||||
}
|
||||
}
|
||||
sentThisTime.put(nbt.getKey(), nbt.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
sentNBT.putAll(sentThisTime);
|
||||
syncedNBT.clear();
|
||||
}
|
||||
sentNBT.putAll(sentThisTime);
|
||||
syncedNBT.clear();
|
||||
}
|
||||
|
||||
private NBTTagCompound createErrorNBT(IErrorStateSource error) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
ErrorState state = null;
|
||||
if (error.canWork() != null) {
|
||||
nbt.setByte("type", (byte) 0);
|
||||
state = error.canWork();
|
||||
} else if (error.canProgress() != null) {
|
||||
nbt.setByte("type", (byte) 1);
|
||||
state = error.canProgress();
|
||||
}
|
||||
private NBTTagCompound createErrorNBT(IErrorStateSource error) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
ErrorState state = null;
|
||||
if (error.canWork() != null) {
|
||||
nbt.setByte("type", (byte) 0);
|
||||
state = error.canWork();
|
||||
} else if (error.canProgress() != null) {
|
||||
nbt.setByte("type", (byte) 1);
|
||||
state = error.canProgress();
|
||||
}
|
||||
|
||||
if (state != null) {
|
||||
state.writeToNBT(nbt);
|
||||
}
|
||||
return nbt;
|
||||
}
|
||||
if (state != null) {
|
||||
state.writeToNBT(nbt);
|
||||
}
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public NBTTagCompound createPowerNBT(PowerInfo powerInfo) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
powerInfo.writeToNBT(nbt);
|
||||
return nbt;
|
||||
}
|
||||
public NBTTagCompound createPowerNBT(PowerInfo powerInfo) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
powerInfo.writeToNBT(nbt);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public NBTTagCompound createProcessNBT(ProcessInfo powerInfo) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
powerInfo.writeToNBT(nbt);
|
||||
return nbt;
|
||||
}
|
||||
public NBTTagCompound createProcessNBT(ProcessInfo powerInfo) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
powerInfo.writeToNBT(nbt);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public NBTTagCompound createTankNBT(int tank, TankInfo tankInfo) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
tankInfo.writeToNBT(nbt);
|
||||
nbt.setByte("tank", (byte) tank);
|
||||
return nbt;
|
||||
}
|
||||
public NBTTagCompound createTankNBT(int tank, TankInfo tankInfo) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
tankInfo.writeToNBT(nbt);
|
||||
nbt.setByte("tank", (byte) tank);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public void onTankUpdate(NBTTagCompound nbt) {
|
||||
int tankID = nbt.getByte("tank");
|
||||
TankInfo tank = new TankInfo();
|
||||
tank.readFromNBT(nbt);
|
||||
syncedTanks.put(tankID, tank);
|
||||
}
|
||||
public void onTankUpdate(NBTTagCompound nbt) {
|
||||
int tankID = nbt.getByte("tank");
|
||||
TankInfo tank = new TankInfo();
|
||||
tank.readFromNBT(nbt);
|
||||
syncedTanks.put(tankID, tank);
|
||||
}
|
||||
|
||||
public void onProcessUpdate(NBTTagCompound nbt) {
|
||||
(syncedProcess = new ProcessInfo()).readFromNBT(nbt);
|
||||
}
|
||||
public void onProcessUpdate(NBTTagCompound nbt) {
|
||||
(syncedProcess = new ProcessInfo()).readFromNBT(nbt);
|
||||
}
|
||||
|
||||
public void onPowerUpdate(NBTTagCompound nbt) {
|
||||
syncedPower = new PowerInfo();
|
||||
syncedPower.readFromNBT(nbt);
|
||||
}
|
||||
public void onPowerUpdate(NBTTagCompound nbt) {
|
||||
syncedPower = new PowerInfo();
|
||||
syncedPower.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
public PowerInfo getPowerInfo() {
|
||||
return syncedPower;
|
||||
}
|
||||
public PowerInfo getPowerInfo() {
|
||||
return syncedPower;
|
||||
}
|
||||
|
||||
public ProcessInfo getProcessInfo() {
|
||||
return syncedProcess;
|
||||
}
|
||||
public ProcessInfo getProcessInfo() {
|
||||
return syncedProcess;
|
||||
}
|
||||
|
||||
public TankInfo getTankInfo(int tank) {
|
||||
return syncedTanks.containsKey(tank)
|
||||
? syncedTanks.get(tank)
|
||||
: new TankInfo();
|
||||
}
|
||||
public TankInfo getTankInfo(int tank) {
|
||||
return syncedTanks.containsKey(tank) ? syncedTanks.get(tank) : new TankInfo();
|
||||
}
|
||||
|
||||
public void onErrorUpdate(NBTTagCompound nbt) {
|
||||
errorType = nbt.getByte("type");
|
||||
if (nbt.hasKey("name")) {
|
||||
error = new ErrorState("", "");
|
||||
error.readFromNBT(nbt);
|
||||
} else {
|
||||
error = null;
|
||||
}
|
||||
}
|
||||
public void onErrorUpdate(NBTTagCompound nbt) {
|
||||
errorType = nbt.getByte("type");
|
||||
if (nbt.hasKey("name")) {
|
||||
error = new ErrorState("", "");
|
||||
error.readFromNBT(nbt);
|
||||
} else {
|
||||
error = null;
|
||||
}
|
||||
}
|
||||
|
||||
public ErrorState getErrorState() {
|
||||
return error;
|
||||
}
|
||||
public ErrorState getErrorState() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public int getErrorType() {
|
||||
return errorType;
|
||||
}
|
||||
public int getErrorType() {
|
||||
return errorType;
|
||||
}
|
||||
|
||||
public CustomSlot[] getCustomSlots() {
|
||||
List<CustomSlot> slots = new ArrayList<>();
|
||||
for (Object object : inventorySlots) {
|
||||
if (object instanceof CustomSlot) {
|
||||
slots.add((CustomSlot) object);
|
||||
}
|
||||
}
|
||||
return slots.toArray(new CustomSlot[0]);
|
||||
}
|
||||
public CustomSlot[] getCustomSlots() {
|
||||
List<CustomSlot> slots = new ArrayList<>();
|
||||
for (Object object : inventorySlots) {
|
||||
if (object instanceof CustomSlot) {
|
||||
slots.add((CustomSlot) object);
|
||||
}
|
||||
}
|
||||
return slots.toArray(new CustomSlot[0]);
|
||||
}
|
||||
|
||||
public void setMouseOverSlot(Slot slot) {
|
||||
if (slot.slotNumber == mousedOverSlotNumber) {
|
||||
return;
|
||||
}
|
||||
public void setMouseOverSlot(Slot slot) {
|
||||
if (slot.slotNumber == mousedOverSlotNumber) {
|
||||
return;
|
||||
}
|
||||
|
||||
mousedOverSlotNumber = slot.slotNumber;
|
||||
ControlSlot.highlighting.get(EnumHighlighting.SHIFT_CLICK).clear();
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setShort("slot", (short) slot.slotNumber);
|
||||
window.sendClientAction("mouse-over-slot", nbt);
|
||||
}
|
||||
mousedOverSlotNumber = slot.slotNumber;
|
||||
ControlSlot.highlighting.get(EnumHighlighting.SHIFT_CLICK).clear();
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setShort("slot", (short) slot.slotNumber);
|
||||
window.sendClientAction("mouse-over-slot", nbt);
|
||||
}
|
||||
|
||||
private void onMouseOverSlot(EntityPlayer player, NBTTagCompound data) {
|
||||
int slotnumber = data.getShort("slot");
|
||||
TransferRequest request = getShiftClickRequest(player, slotnumber);
|
||||
if (request == null) {
|
||||
return;
|
||||
}
|
||||
private void onMouseOverSlot(EntityPlayer player, NBTTagCompound data) {
|
||||
int slotnumber = data.getShort("slot");
|
||||
TransferRequest request = getShiftClickRequest(player, slotnumber);
|
||||
if (request == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
request.transfer(false);
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
List<Integer> slots = new ArrayList<>();
|
||||
for (TransferRequest.TransferSlot tslot : request.getInsertedSlots()) {
|
||||
Slot slot = getSlot(tslot.inventory, tslot.id);
|
||||
if (slot != null) {
|
||||
slots.add(slot.slotNumber);
|
||||
}
|
||||
}
|
||||
request.transfer(false);
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
List<Integer> slots = new ArrayList<>();
|
||||
for (TransferRequest.TransferSlot tslot : request.getInsertedSlots()) {
|
||||
Slot slot = getSlot(tslot.inventory, tslot.id);
|
||||
if (slot != null) {
|
||||
slots.add(slot.slotNumber);
|
||||
}
|
||||
}
|
||||
|
||||
int[] array = new int[slots.size()];
|
||||
for (int i = 0; i < slots.size(); ++i) {
|
||||
array[i] = slots.get(i);
|
||||
}
|
||||
int[] array = new int[slots.size()];
|
||||
for (int i = 0; i < slots.size(); ++i) {
|
||||
array[i] = slots.get(i);
|
||||
}
|
||||
|
||||
nbt.setIntArray("slots", array);
|
||||
nbt.setShort("origin", (short) slotnumber);
|
||||
syncedNBT.put("shift-click-info", nbt);
|
||||
}
|
||||
nbt.setIntArray("slots", array);
|
||||
nbt.setShort("origin", (short) slotnumber);
|
||||
syncedNBT.put("shift-click-info", nbt);
|
||||
}
|
||||
|
||||
private void onRecieveShiftClickHighlights(EntityPlayer player, NBTTagCompound data) {
|
||||
ControlSlot.highlighting.get(EnumHighlighting.SHIFT_CLICK).clear();
|
||||
for (int slotnumber : data.getIntArray("slots")) {
|
||||
ControlSlot.highlighting.get(EnumHighlighting.SHIFT_CLICK).add(slotnumber);
|
||||
}
|
||||
}
|
||||
private void onRecieveShiftClickHighlights(EntityPlayer player, NBTTagCompound data) {
|
||||
ControlSlot.highlighting.get(EnumHighlighting.SHIFT_CLICK).clear();
|
||||
for (int slotnumber : data.getIntArray("slots")) {
|
||||
ControlSlot.highlighting.get(EnumHighlighting.SHIFT_CLICK).add(slotnumber);
|
||||
}
|
||||
}
|
||||
|
||||
private CustomSlot getSlot(IInventory inventory, int id) {
|
||||
for (Object o : inventorySlots) {
|
||||
CustomSlot slot = (CustomSlot) o;
|
||||
if (slot.inventory == inventory && slot.getSlotIndex() == id) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private CustomSlot getSlot(IInventory inventory, int id) {
|
||||
for (Object o : inventorySlots) {
|
||||
CustomSlot slot = (CustomSlot) o;
|
||||
if (slot.inventory == inventory && slot.getSlotIndex() == id) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void recieveNBT(Side side, EntityPlayer player, NBTTagCompound action) {
|
||||
String name = action.getString("type");
|
||||
if (handleNBT(side, player, name, action)) {
|
||||
return;
|
||||
}
|
||||
public void recieveNBT(Side side, EntityPlayer player, NBTTagCompound action) {
|
||||
String name = action.getString("type");
|
||||
if (handleNBT(side, player, name, action)) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.recieveGuiNBT(getSide(), player, name, action);
|
||||
INetwork.RecieveGuiNBT machine = Machine.getInterface(INetwork.RecieveGuiNBT.class, window.getInventory());
|
||||
if (machine != null) {
|
||||
machine.recieveGuiNBT(getSide(), player, name, action);
|
||||
}
|
||||
}
|
||||
window.recieveGuiNBT(getSide(), player, name, action);
|
||||
INetwork.RecieveGuiNBT machine = Machine.getInterface(INetwork.RecieveGuiNBT.class, window.getInventory());
|
||||
if (machine != null) {
|
||||
machine.recieveGuiNBT(getSide(), player, name, action);
|
||||
}
|
||||
}
|
||||
|
||||
public Slot getOrCreateSlot(InventoryType type, int index) {
|
||||
IInventory inventory = getInventory(type);
|
||||
Slot slot = getSlot(inventory, index);
|
||||
if (slot == null) {
|
||||
slot = new CustomSlot(inventory, index);
|
||||
addSlotToContainer(slot);
|
||||
}
|
||||
public Slot getOrCreateSlot(InventoryType type, int index) {
|
||||
IInventory inventory = getInventory(type);
|
||||
Slot slot = getSlot(inventory, index);
|
||||
if (slot == null) {
|
||||
slot = new CustomSlot(inventory, index);
|
||||
addSlotToContainer(slot);
|
||||
}
|
||||
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setByte("t", (byte) type.ordinal());
|
||||
nbt.setShort("i", (short) index);
|
||||
nbt.setShort("n", (short) slot.slotNumber);
|
||||
window.sendClientAction("slot-reg", nbt);
|
||||
return slot;
|
||||
}
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setByte("t", (byte) type.ordinal());
|
||||
nbt.setShort("i", (short) index);
|
||||
nbt.setShort("n", (short) slot.slotNumber);
|
||||
window.sendClientAction("slot-reg", nbt);
|
||||
return slot;
|
||||
}
|
||||
|
||||
protected IInventory getInventory(InventoryType type) {
|
||||
if (type == InventoryType.Machine) {
|
||||
return window.getInventory();
|
||||
}
|
||||
if (type == InventoryType.Player) {
|
||||
return window.getPlayer().inventory;
|
||||
}
|
||||
if (type == InventoryType.Window) {
|
||||
return window.getWindowInventory();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
protected IInventory getInventory(InventoryType type) {
|
||||
if (type == InventoryType.Machine) {
|
||||
return window.getInventory();
|
||||
}
|
||||
if (type == InventoryType.Player) {
|
||||
return window.getPlayer().inventory;
|
||||
}
|
||||
if (type == InventoryType.Window) {
|
||||
return window.getWindowInventory();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Slot getOrCreateSlot(InventoryType type, int index, int slotNumber) {
|
||||
IInventory inventory = getInventory(type);
|
||||
if (inventorySlots.get(slotNumber) != null) {
|
||||
return null;
|
||||
}
|
||||
private Slot getOrCreateSlot(InventoryType type, int index, int slotNumber) {
|
||||
IInventory inventory = getInventory(type);
|
||||
if (inventorySlots.get(slotNumber) != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Slot slot = new CustomSlot(inventory, index);
|
||||
slot.slotNumber = slotNumber;
|
||||
inventorySlots.add(slotNumber, slot);
|
||||
inventoryItemStacks.add(slotNumber, null);
|
||||
return slot;
|
||||
}
|
||||
Slot slot = new CustomSlot(inventory, index);
|
||||
slot.slotNumber = slotNumber;
|
||||
inventorySlots.add(slotNumber, slot);
|
||||
inventoryItemStacks.add(slotNumber, null);
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
@@ -9,36 +9,36 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class CustomSlot extends Slot {
|
||||
public CustomSlot(IInventory inventory, int index) {
|
||||
super(inventory, index, 0, 0);
|
||||
}
|
||||
public CustomSlot(IInventory inventory, int index) {
|
||||
super(inventory, index, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack) {
|
||||
return inventory.isItemValidForSlot(getSlotIndex(), par1ItemStack);
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack) {
|
||||
return inventory.isItemValidForSlot(getSlotIndex(), par1ItemStack);
|
||||
}
|
||||
|
||||
public InventorySlot getInventorySlot() {
|
||||
IInventorySlots slots = Machine.getInterface(IInventorySlots.class, inventory);
|
||||
if (slots != null) {
|
||||
return slots.getSlot(getSlotIndex());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public InventorySlot getInventorySlot() {
|
||||
IInventorySlots slots = Machine.getInterface(IInventorySlots.class, inventory);
|
||||
if (slots != null) {
|
||||
return slots.getSlot(getSlotIndex());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean handleClick() {
|
||||
InventorySlot slot = getInventorySlot();
|
||||
return slot != null && slot.isRecipe();
|
||||
}
|
||||
public boolean handleClick() {
|
||||
InventorySlot slot = getInventorySlot();
|
||||
return slot != null && slot.isRecipe();
|
||||
}
|
||||
|
||||
public void onSlotClick(ContainerCraftGUI container, int mouseButton, int modifier, EntityPlayer player) {
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
if (stack == null || mouseButton == 2) {
|
||||
putStack(null);
|
||||
} else {
|
||||
stack = stack.copy();
|
||||
stack.stackSize = 1;
|
||||
putStack(stack);
|
||||
}
|
||||
}
|
||||
public void onSlotClick(ContainerCraftGUI container, int mouseButton, int modifier, EntityPlayer player) {
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
if (stack == null || mouseButton == 2) {
|
||||
putStack(null);
|
||||
} else {
|
||||
stack = stack.copy();
|
||||
stack.stackSize = 1;
|
||||
putStack(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,39 +10,39 @@ import binnie.core.craftgui.geometry.IPoint;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
|
||||
public abstract class Dialog extends Control {
|
||||
public Dialog(IWidget parent, float w, float h) {
|
||||
super(parent, (parent.w() - w) / 2.0f, (parent.h() - h) / 2.0f, w, h);
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
addAttribute(WidgetAttribute.ALWAYS_ON_TOP);
|
||||
addAttribute(WidgetAttribute.BLOCK_TOOLTIP);
|
||||
initialise();
|
||||
addEventHandler(new MouseDownHandler().setOrigin(EventHandler.Origin.Any, this));
|
||||
}
|
||||
public Dialog(IWidget parent, float w, float h) {
|
||||
super(parent, (parent.w() - w) / 2.0f, (parent.h() - h) / 2.0f, w, h);
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
addAttribute(WidgetAttribute.ALWAYS_ON_TOP);
|
||||
addAttribute(WidgetAttribute.BLOCK_TOOLTIP);
|
||||
initialise();
|
||||
addEventHandler(new MouseDownHandler().setOrigin(EventHandler.Origin.Any, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void initialise();
|
||||
@Override
|
||||
public abstract void initialise();
|
||||
|
||||
public abstract void onClose();
|
||||
public abstract void onClose();
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.render.gradientRect(getArea().outset(400), -1442840576, -1442840576);
|
||||
CraftGUI.render.texture(CraftGUITexture.Window, getArea());
|
||||
CraftGUI.render.texture(CraftGUITexture.TabOutline, getArea().inset(4));
|
||||
}
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.render.gradientRect(getArea().outset(400), -1442840576, -1442840576);
|
||||
CraftGUI.render.texture(CraftGUITexture.Window, getArea());
|
||||
CraftGUI.render.texture(CraftGUITexture.TabOutline, getArea().inset(4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMouseOverWidget(IPoint relativeMouse) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isMouseOverWidget(IPoint relativeMouse) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private class MouseDownHandler extends EventMouse.Down.Handler {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
if (!getArea().contains(getRelativeMousePosition())) {
|
||||
onClose();
|
||||
getParent().deleteChild(Dialog.this);
|
||||
}
|
||||
}
|
||||
}
|
||||
private class MouseDownHandler extends EventMouse.Down.Handler {
|
||||
@Override
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
if (!getArea().contains(getRelativeMousePosition())) {
|
||||
onClose();
|
||||
getParent().deleteChild(Dialog.this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,43 +2,43 @@ package binnie.core.craftgui.minecraft;
|
||||
|
||||
// TODO replace to EnumChatFormatting?
|
||||
public enum EnumColor {
|
||||
Black("Black", 0, '0'),
|
||||
DarkBlue("Dark Blue", 170, '1'),
|
||||
DarkGreen("Dark Green", 43520, '2'),
|
||||
DarkAqua("Dark Aqua", 43690, '3'),
|
||||
DarkRed("Dark Red", 11141120, '4'),
|
||||
Purple("Purple", 11141290, '5'),
|
||||
Gold("Gold", 16755200, '6'),
|
||||
Grey("Grey", 11184810, '7'),
|
||||
DarkGrey("Dark Grey", 5592405, '8'),
|
||||
Blue("Blue", 5592575, '9'),
|
||||
Green("Green", 5635925, 'a'),
|
||||
Aqua("Aqua", 5636095, 'b'),
|
||||
Red("Red", 16733525, 'c'),
|
||||
Pink("Pink", 16733695, 'd'),
|
||||
Yellow("Yellow", 16777045, 'e'),
|
||||
White("White", 16777215, 'f');
|
||||
Black("Black", 0, '0'),
|
||||
DarkBlue("Dark Blue", 170, '1'),
|
||||
DarkGreen("Dark Green", 43520, '2'),
|
||||
DarkAqua("Dark Aqua", 43690, '3'),
|
||||
DarkRed("Dark Red", 11141120, '4'),
|
||||
Purple("Purple", 11141290, '5'),
|
||||
Gold("Gold", 16755200, '6'),
|
||||
Grey("Grey", 11184810, '7'),
|
||||
DarkGrey("Dark Grey", 5592405, '8'),
|
||||
Blue("Blue", 5592575, '9'),
|
||||
Green("Green", 5635925, 'a'),
|
||||
Aqua("Aqua", 5636095, 'b'),
|
||||
Red("Red", 16733525, 'c'),
|
||||
Pink("Pink", 16733695, 'd'),
|
||||
Yellow("Yellow", 16777045, 'e'),
|
||||
White("White", 16777215, 'f');
|
||||
|
||||
protected int colour;
|
||||
protected String name;
|
||||
protected char code;
|
||||
protected int colour;
|
||||
protected String name;
|
||||
protected char code;
|
||||
|
||||
EnumColor(String name, int colour, char code) {
|
||||
this.name = name;
|
||||
this.colour = colour;
|
||||
this.code = code;
|
||||
}
|
||||
EnumColor(String name, int colour, char code) {
|
||||
this.name = name;
|
||||
this.colour = colour;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return colour;
|
||||
}
|
||||
public int getColor() {
|
||||
return colour;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return "\u00a7" + code;
|
||||
}
|
||||
public String getCode() {
|
||||
return "\u00a7" + code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -6,31 +6,31 @@ import binnie.core.resource.BinnieIcon;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public enum GUIIcon {
|
||||
ArrowUp("arrow-up"),
|
||||
ArrowDown("arrow-down"),
|
||||
ArrowLeft("arrow-left"),
|
||||
ArrowRight("arrow-right"),
|
||||
ArrowUpLeft("arrow-upleft"),
|
||||
ArrowUpRight("arrow-upright"),
|
||||
ArrowRightUp("arrow-rightup"),
|
||||
ArrowRightDown("arrow-rightdown"),
|
||||
ArrowDownRight("arrow-downright"),
|
||||
ArrowDownLeft("arrow-downleft"),
|
||||
ArrowLeftDown("arrow-leftdown"),
|
||||
ArrowLeftUp("arrow-leftup");
|
||||
ArrowUp("arrow-up"),
|
||||
ArrowDown("arrow-down"),
|
||||
ArrowLeft("arrow-left"),
|
||||
ArrowRight("arrow-right"),
|
||||
ArrowUpLeft("arrow-upleft"),
|
||||
ArrowUpRight("arrow-upright"),
|
||||
ArrowRightUp("arrow-rightup"),
|
||||
ArrowRightDown("arrow-rightdown"),
|
||||
ArrowDownRight("arrow-downright"),
|
||||
ArrowDownLeft("arrow-downleft"),
|
||||
ArrowLeftDown("arrow-leftdown"),
|
||||
ArrowLeftUp("arrow-leftup");
|
||||
|
||||
String path;
|
||||
BinnieIcon icon;
|
||||
String path;
|
||||
BinnieIcon icon;
|
||||
|
||||
GUIIcon(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
GUIIcon(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public void register() {
|
||||
icon = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/" + path);
|
||||
}
|
||||
public void register() {
|
||||
icon = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/" + path);
|
||||
}
|
||||
|
||||
public IIcon getIcon() {
|
||||
return icon.getIcon();
|
||||
}
|
||||
public IIcon getIcon() {
|
||||
return icon.getIcon();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import binnie.core.craftgui.geometry.IBorder;
|
||||
import binnie.core.craftgui.geometry.IPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -28,450 +30,473 @@ import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiCraftGUI extends GuiContainer {
|
||||
private Window window;
|
||||
private ItemStack draggedItem;
|
||||
private Window window;
|
||||
private ItemStack draggedItem;
|
||||
|
||||
public GuiCraftGUI(Window window) {
|
||||
super(window.getContainer());
|
||||
this.window = window;
|
||||
resize(window.getSize());
|
||||
}
|
||||
public GuiCraftGUI(Window window) {
|
||||
super(window.getContainer());
|
||||
this.window = window;
|
||||
resize(window.getSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
window.updateClient();
|
||||
}
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
window.updateClient();
|
||||
}
|
||||
|
||||
public Minecraft getMinecraft() {
|
||||
return mc;
|
||||
}
|
||||
public Minecraft getMinecraft() {
|
||||
return mc;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
mc.thePlayer.openContainer = inventorySlots;
|
||||
guiLeft = (width - xSize) / 2;
|
||||
guiTop = (height - ySize) / 2;
|
||||
window.setSize(new IPoint(xSize, ySize));
|
||||
window.setPosition(new IPoint(guiLeft, guiTop));
|
||||
window.initGui();
|
||||
}
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
mc.thePlayer.openContainer = inventorySlots;
|
||||
guiLeft = (width - xSize) / 2;
|
||||
guiTop = (height - ySize) / 2;
|
||||
window.setSize(new IPoint(xSize, ySize));
|
||||
window.setPosition(new IPoint(guiLeft, guiTop));
|
||||
window.initGui();
|
||||
}
|
||||
|
||||
public ItemStack getDraggedItem() {
|
||||
return draggedItem;
|
||||
}
|
||||
public ItemStack getDraggedItem() {
|
||||
return draggedItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float par3) {
|
||||
window.setMousePosition(mouseX - (int) window.getPosition().x(), mouseY - (int) window.getPosition().y());
|
||||
drawDefaultBackground();
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float par3) {
|
||||
window.setMousePosition(
|
||||
mouseX - (int) window.getPosition().x(),
|
||||
mouseY - (int) window.getPosition().y());
|
||||
drawDefaultBackground();
|
||||
|
||||
GL11.glDisable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
zLevel = 10.0f;
|
||||
GuiScreen.itemRender.zLevel = zLevel;
|
||||
GL11.glDisable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
zLevel = 10.0f;
|
||||
GuiScreen.itemRender.zLevel = zLevel;
|
||||
|
||||
window.render();
|
||||
window.render();
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
|
||||
InventoryPlayer playerInventory = mc.thePlayer.inventory;
|
||||
draggedItem = playerInventory.getItemStack();
|
||||
if (draggedItem != null) {
|
||||
renderItem(new IPoint(mouseX - 8, mouseY - 8), draggedItem, false);
|
||||
renderItem(new IPoint(mouseX - 8, mouseY - 8), draggedItem, false);
|
||||
}
|
||||
GL11.glDisable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
GL11.glPopMatrix();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
MinecraftTooltip tooltip = new MinecraftTooltip();
|
||||
if (isHelpMode()) {
|
||||
tooltip.setType(Tooltip.Type.HELP);
|
||||
window.getHelpTooltip(tooltip);
|
||||
} else {
|
||||
tooltip.setType(Tooltip.Type.STANDARD);
|
||||
window.getTooltip(tooltip);
|
||||
}
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
|
||||
InventoryPlayer playerInventory = mc.thePlayer.inventory;
|
||||
draggedItem = playerInventory.getItemStack();
|
||||
if (draggedItem != null) {
|
||||
renderItem(new IPoint(mouseX - 8, mouseY - 8), draggedItem, false);
|
||||
renderItem(new IPoint(mouseX - 8, mouseY - 8), draggedItem, false);
|
||||
}
|
||||
GL11.glDisable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
GL11.glPopMatrix();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
MinecraftTooltip tooltip = new MinecraftTooltip();
|
||||
if (isHelpMode()) {
|
||||
tooltip.setType(Tooltip.Type.HELP);
|
||||
window.getHelpTooltip(tooltip);
|
||||
} else {
|
||||
tooltip.setType(Tooltip.Type.STANDARD);
|
||||
window.getTooltip(tooltip);
|
||||
}
|
||||
|
||||
if (tooltip.exists()) {
|
||||
renderTooltip(new IPoint(mouseX, mouseY), tooltip);
|
||||
}
|
||||
zLevel = 0.0f;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
if (tooltip.exists()) {
|
||||
renderTooltip(new IPoint(mouseX, mouseY), tooltip);
|
||||
}
|
||||
zLevel = 0.0f;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
public void renderTooltip(IPoint mousePosition, MinecraftTooltip tooltip) {
|
||||
int mouseX = (int) mousePosition.x();
|
||||
int mouseY = (int) mousePosition.y();
|
||||
FontRenderer font = getFontRenderer();
|
||||
GL11.glDisable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
public void renderTooltip(IPoint mousePosition, MinecraftTooltip tooltip) {
|
||||
int mouseX = (int) mousePosition.x();
|
||||
int mouseY = (int) mousePosition.y();
|
||||
FontRenderer font = getFontRenderer();
|
||||
GL11.glDisable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
int k = 0;
|
||||
List<String> strings = new ArrayList<>();
|
||||
for (String string : tooltip.getList()) {
|
||||
if (string != null) {
|
||||
if (!string.contains("~~~")) {
|
||||
strings.addAll(font.listFormattedStringToWidth(string, tooltip.maxWidth));
|
||||
} else {
|
||||
strings.add(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
int k = 0;
|
||||
List<String> strings = new ArrayList<>();
|
||||
for (String string : tooltip.getList()) {
|
||||
if (string != null) {
|
||||
if (!string.contains("~~~")) {
|
||||
strings.addAll(font.listFormattedStringToWidth(string, tooltip.maxWidth));
|
||||
} else {
|
||||
strings.add(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String s : strings) {
|
||||
int l = font.getStringWidth(s);
|
||||
if (s.contains("~~~")) {
|
||||
l = 12 + font.getStringWidth(s.replaceAll("~~~(.*?)~~~", ""));
|
||||
}
|
||||
if (l > k) {
|
||||
k = l;
|
||||
}
|
||||
}
|
||||
for (String s : strings) {
|
||||
int l = font.getStringWidth(s);
|
||||
if (s.contains("~~~")) {
|
||||
l = 12 + font.getStringWidth(s.replaceAll("~~~(.*?)~~~", ""));
|
||||
}
|
||||
if (l > k) {
|
||||
k = l;
|
||||
}
|
||||
}
|
||||
|
||||
int i1 = mouseX + 12;
|
||||
int j1 = mouseY - 12;
|
||||
int k2 = 8;
|
||||
if (strings.size() > 1) {
|
||||
k2 += 2 + (strings.size() - 1) * 10;
|
||||
}
|
||||
if (i1 + k > width) {
|
||||
i1 -= 28 + k;
|
||||
}
|
||||
if (j1 + k2 + 6 > height) {
|
||||
j1 = height - k2 - 6;
|
||||
}
|
||||
zLevel = 300.0f;
|
||||
GuiScreen.itemRender.zLevel = 300.0f;
|
||||
int l2 = 0xf0100010;
|
||||
int j2;
|
||||
int i2 = j2 = 0x50000000 + MinecraftTooltip.getOutline(tooltip.getType());
|
||||
int i1 = mouseX + 12;
|
||||
int j1 = mouseY - 12;
|
||||
int k2 = 8;
|
||||
if (strings.size() > 1) {
|
||||
k2 += 2 + (strings.size() - 1) * 10;
|
||||
}
|
||||
if (i1 + k > width) {
|
||||
i1 -= 28 + k;
|
||||
}
|
||||
if (j1 + k2 + 6 > height) {
|
||||
j1 = height - k2 - 6;
|
||||
}
|
||||
zLevel = 300.0f;
|
||||
GuiScreen.itemRender.zLevel = 300.0f;
|
||||
int l2 = 0xf0100010;
|
||||
int j2;
|
||||
int i2 = j2 = 0x50000000 + MinecraftTooltip.getOutline(tooltip.getType());
|
||||
|
||||
drawGradientRect(i1 - 3, j1 - 4, i1 + k + 3, j1 - 3, l2, l2);
|
||||
drawGradientRect(i1 - 3, j1 + k2 + 3, i1 + k + 3, j1 + k2 + 4, l2, l2);
|
||||
drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 + k2 + 3, l2, l2);
|
||||
drawGradientRect(i1 - 4, j1 - 3, i1 - 3, j1 + k2 + 3, l2, l2);
|
||||
drawGradientRect(i1 + k + 3, j1 - 3, i1 + k + 4, j1 + k2 + 3, l2, l2);
|
||||
drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k2 + 3 - 1, i2, j2);
|
||||
drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k2 + 3 - 1, i2, j2);
|
||||
drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2);
|
||||
drawGradientRect(i1 - 3, j1 + k2 + 2, i1 + k + 3, j1 + k2 + 3, j2, j2);
|
||||
drawGradientRect(i1 - 3, j1 - 4, i1 + k + 3, j1 - 3, l2, l2);
|
||||
drawGradientRect(i1 - 3, j1 + k2 + 3, i1 + k + 3, j1 + k2 + 4, l2, l2);
|
||||
drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 + k2 + 3, l2, l2);
|
||||
drawGradientRect(i1 - 4, j1 - 3, i1 - 3, j1 + k2 + 3, l2, l2);
|
||||
drawGradientRect(i1 + k + 3, j1 - 3, i1 + k + 4, j1 + k2 + 3, l2, l2);
|
||||
drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k2 + 3 - 1, i2, j2);
|
||||
drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k2 + 3 - 1, i2, j2);
|
||||
drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2);
|
||||
drawGradientRect(i1 - 3, j1 + k2 + 2, i1 + k + 3, j1 + k2 + 3, j2, j2);
|
||||
|
||||
for (int k3 = 0; k3 < strings.size(); ++k3) {
|
||||
String s2 = strings.get(k3);
|
||||
if (k3 == 0) {
|
||||
s2 = MinecraftTooltip.getTitle(tooltip.getType()) + s2;
|
||||
} else {
|
||||
s2 = MinecraftTooltip.getBody(tooltip.getType()) + s2;
|
||||
}
|
||||
for (int k3 = 0; k3 < strings.size(); ++k3) {
|
||||
String s2 = strings.get(k3);
|
||||
if (k3 == 0) {
|
||||
s2 = MinecraftTooltip.getTitle(tooltip.getType()) + s2;
|
||||
} else {
|
||||
s2 = MinecraftTooltip.getBody(tooltip.getType()) + s2;
|
||||
}
|
||||
|
||||
if (s2.contains("~~~")) {
|
||||
String split = s2.split("~~~")[1];
|
||||
try {
|
||||
NBTTagCompound nbt = (NBTTagCompound) JsonToNBT.func_150315_a(split);
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(i1, j1 - 1.5f, 0.0f);
|
||||
GL11.glScalef(0.6f, 0.6f, 1.0f);
|
||||
renderItem(new IPoint(0.0f, 0.0f), stack, false);
|
||||
GL11.glPopMatrix();
|
||||
} catch (NBTException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
s2 = " " + s2.replaceAll("~~~(.*?)~~~", "");
|
||||
}
|
||||
if (s2.contains("~~~")) {
|
||||
String split = s2.split("~~~")[1];
|
||||
try {
|
||||
NBTTagCompound nbt = (NBTTagCompound) JsonToNBT.func_150315_a(split);
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(i1, j1 - 1.5f, 0.0f);
|
||||
GL11.glScalef(0.6f, 0.6f, 1.0f);
|
||||
renderItem(new IPoint(0.0f, 0.0f), stack, false);
|
||||
GL11.glPopMatrix();
|
||||
} catch (NBTException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
s2 = " " + s2.replaceAll("~~~(.*?)~~~", "");
|
||||
}
|
||||
|
||||
font.drawStringWithShadow(s2, i1, j1, -1);
|
||||
if (k3 == 0) {
|
||||
j1 += 2;
|
||||
}
|
||||
j1 += 10;
|
||||
}
|
||||
font.drawStringWithShadow(s2, i1, j1, -1);
|
||||
if (k3 == 0) {
|
||||
j1 += 2;
|
||||
}
|
||||
j1 += 10;
|
||||
}
|
||||
|
||||
zLevel = 0.0f;
|
||||
GuiScreen.itemRender.zLevel = 0.0f;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
}
|
||||
zLevel = 0.0f;
|
||||
GuiScreen.itemRender.zLevel = 0.0f;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int button) {
|
||||
IWidget origin = window;
|
||||
if (window.getMousedOverWidget() != null) {
|
||||
origin = window.getMousedOverWidget();
|
||||
}
|
||||
window.callEvent(new EventMouse.Down(origin, x, y, button));
|
||||
}
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int button) {
|
||||
IWidget origin = window;
|
||||
if (window.getMousedOverWidget() != null) {
|
||||
origin = window.getMousedOverWidget();
|
||||
}
|
||||
window.callEvent(new EventMouse.Down(origin, x, y, button));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char c, int key) {
|
||||
if (key == 1 || (key == mc.gameSettings.keyBindInventory.getKeyCode() && window.getFocusedWidget() == null)) {
|
||||
mc.thePlayer.closeScreen();
|
||||
}
|
||||
IWidget origin = (window.getFocusedWidget() == null) ? window : window.getFocusedWidget();
|
||||
window.callEvent(new EventKey.Down(origin, c, key));
|
||||
}
|
||||
@Override
|
||||
protected void keyTyped(char c, int key) {
|
||||
if (key == 1 || (key == mc.gameSettings.keyBindInventory.getKeyCode() && window.getFocusedWidget() == null)) {
|
||||
mc.thePlayer.closeScreen();
|
||||
}
|
||||
IWidget origin = (window.getFocusedWidget() == null) ? window : window.getFocusedWidget();
|
||||
window.callEvent(new EventKey.Down(origin, c, key));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseMovedOrUp(int x, int y, int button) {
|
||||
IWidget origin = (window.getMousedOverWidget() == null) ? window : window.getMousedOverWidget();
|
||||
if (button != -1) {
|
||||
window.callEvent(new EventMouse.Up(origin, x, y, button));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void mouseMovedOrUp(int x, int y, int button) {
|
||||
IWidget origin = (window.getMousedOverWidget() == null) ? window : window.getMousedOverWidget();
|
||||
if (button != -1) {
|
||||
window.callEvent(new EventMouse.Up(origin, x, y, button));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput() {
|
||||
super.handleMouseInput();
|
||||
int dWheel = Mouse.getDWheel();
|
||||
if (dWheel != 0) {
|
||||
window.callEvent(new EventMouse.Wheel(window, dWheel));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void handleMouseInput() {
|
||||
super.handleMouseInput();
|
||||
int dWheel = Mouse.getDWheel();
|
||||
if (dWheel != 0) {
|
||||
window.callEvent(new EventMouse.Wheel(window, dWheel));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
window.onClose();
|
||||
}
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
window.onClose();
|
||||
}
|
||||
|
||||
public void renderTexture(IPoint position, IArea textureArea) {
|
||||
drawTexturedModalRect(
|
||||
(int) position.x(),
|
||||
(int) position.y(),
|
||||
(int) textureArea.pos().x(),
|
||||
(int) textureArea.pos().y(),
|
||||
(int) textureArea.size().x(),
|
||||
(int) textureArea.size().y()
|
||||
);
|
||||
}
|
||||
public void renderTexture(IPoint position, IArea textureArea) {
|
||||
drawTexturedModalRect(
|
||||
(int) position.x(),
|
||||
(int) position.y(),
|
||||
(int) textureArea.pos().x(),
|
||||
(int) textureArea.pos().y(),
|
||||
(int) textureArea.size().x(),
|
||||
(int) textureArea.size().y());
|
||||
}
|
||||
|
||||
public void renderTexturePadded(IArea area, IArea texture, IBorder padding) {
|
||||
int borderLeft = (int) padding.l();
|
||||
int borderRight = (int) padding.r();
|
||||
int borderTop = (int) padding.t();
|
||||
int borderBottom = (int) padding.b();
|
||||
int posX = (int) area.pos().x();
|
||||
int posY = (int) area.pos().y();
|
||||
int width = (int) area.size().x();
|
||||
int height = (int) area.size().y();
|
||||
int textWidth = (int) texture.w();
|
||||
int textHeight = (int) texture.h();
|
||||
int u = (int) texture.x();
|
||||
int v = (int) texture.y();
|
||||
public void renderTexturePadded(IArea area, IArea texture, IBorder padding) {
|
||||
int borderLeft = (int) padding.l();
|
||||
int borderRight = (int) padding.r();
|
||||
int borderTop = (int) padding.t();
|
||||
int borderBottom = (int) padding.b();
|
||||
int posX = (int) area.pos().x();
|
||||
int posY = (int) area.pos().y();
|
||||
int width = (int) area.size().x();
|
||||
int height = (int) area.size().y();
|
||||
int textWidth = (int) texture.w();
|
||||
int textHeight = (int) texture.h();
|
||||
int u = (int) texture.x();
|
||||
int v = (int) texture.y();
|
||||
|
||||
if (borderTop + borderBottom > height) {
|
||||
borderTop = height / 2;
|
||||
borderBottom = height / 2;
|
||||
}
|
||||
if (borderTop + borderBottom > height) {
|
||||
borderTop = height / 2;
|
||||
borderBottom = height / 2;
|
||||
}
|
||||
|
||||
if (borderLeft + borderRight > width) {
|
||||
borderLeft = width / 2;
|
||||
borderRight = width / 2;
|
||||
}
|
||||
if (borderLeft + borderRight > width) {
|
||||
borderLeft = width / 2;
|
||||
borderRight = width / 2;
|
||||
}
|
||||
|
||||
drawTexturedModalRect(posX, posY, u, v, borderLeft, borderTop);
|
||||
drawTexturedModalRect(posX + width - borderRight, posY, u + textWidth - borderRight, v, borderRight, borderTop);
|
||||
drawTexturedModalRect(posX, posY + height - borderBottom, u, v + textHeight - borderBottom, borderLeft, borderBottom);
|
||||
drawTexturedModalRect(posX + width - borderRight, posY + height - borderBottom, u + textWidth - borderRight, v + textHeight - borderBottom, borderRight, borderBottom);
|
||||
drawTexturedModalRect(posX, posY, u, v, borderLeft, borderTop);
|
||||
drawTexturedModalRect(posX + width - borderRight, posY, u + textWidth - borderRight, v, borderRight, borderTop);
|
||||
drawTexturedModalRect(
|
||||
posX, posY + height - borderBottom, u, v + textHeight - borderBottom, borderLeft, borderBottom);
|
||||
drawTexturedModalRect(
|
||||
posX + width - borderRight,
|
||||
posY + height - borderBottom,
|
||||
u + textWidth - borderRight,
|
||||
v + textHeight - borderBottom,
|
||||
borderRight,
|
||||
borderBottom);
|
||||
|
||||
int texturingWidth;
|
||||
for (int currentXPos = borderLeft; currentXPos < width - borderRight; currentXPos += texturingWidth) {
|
||||
int distanceXRemaining = width - borderRight - currentXPos;
|
||||
texturingWidth = textWidth - borderLeft - borderRight;
|
||||
if (texturingWidth > distanceXRemaining) {
|
||||
texturingWidth = distanceXRemaining;
|
||||
}
|
||||
int texturingWidth;
|
||||
for (int currentXPos = borderLeft; currentXPos < width - borderRight; currentXPos += texturingWidth) {
|
||||
int distanceXRemaining = width - borderRight - currentXPos;
|
||||
texturingWidth = textWidth - borderLeft - borderRight;
|
||||
if (texturingWidth > distanceXRemaining) {
|
||||
texturingWidth = distanceXRemaining;
|
||||
}
|
||||
|
||||
if (texturingWidth <= 0) {
|
||||
break;
|
||||
}
|
||||
if (texturingWidth <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
drawTexturedModalRect(posX + currentXPos, posY, u + borderLeft, v, texturingWidth, borderTop);
|
||||
drawTexturedModalRect(posX + currentXPos, posY + height - borderBottom, u + borderLeft, v + textHeight - borderBottom, texturingWidth, borderBottom);
|
||||
int texturingHeight;
|
||||
for (int currentYPos = borderTop; currentYPos < height - borderBottom; currentYPos += texturingHeight) {
|
||||
int distanceYRemaining = height - borderBottom - currentYPos;
|
||||
texturingHeight = textHeight - borderTop - borderBottom;
|
||||
if (texturingHeight > distanceYRemaining) {
|
||||
texturingHeight = distanceYRemaining;
|
||||
}
|
||||
if (texturingHeight <= 0) {
|
||||
break;
|
||||
}
|
||||
drawTexturedModalRect(posX + currentXPos, posY + currentYPos, u + borderLeft, v + borderTop, texturingWidth, texturingHeight);
|
||||
}
|
||||
}
|
||||
drawTexturedModalRect(posX + currentXPos, posY, u + borderLeft, v, texturingWidth, borderTop);
|
||||
drawTexturedModalRect(
|
||||
posX + currentXPos,
|
||||
posY + height - borderBottom,
|
||||
u + borderLeft,
|
||||
v + textHeight - borderBottom,
|
||||
texturingWidth,
|
||||
borderBottom);
|
||||
int texturingHeight;
|
||||
for (int currentYPos = borderTop; currentYPos < height - borderBottom; currentYPos += texturingHeight) {
|
||||
int distanceYRemaining = height - borderBottom - currentYPos;
|
||||
texturingHeight = textHeight - borderTop - borderBottom;
|
||||
if (texturingHeight > distanceYRemaining) {
|
||||
texturingHeight = distanceYRemaining;
|
||||
}
|
||||
if (texturingHeight <= 0) {
|
||||
break;
|
||||
}
|
||||
drawTexturedModalRect(
|
||||
posX + currentXPos,
|
||||
posY + currentYPos,
|
||||
u + borderLeft,
|
||||
v + borderTop,
|
||||
texturingWidth,
|
||||
texturingHeight);
|
||||
}
|
||||
}
|
||||
|
||||
int texturingHeight2;
|
||||
for (int currentYPos2 = borderTop; currentYPos2 < height - borderBottom; currentYPos2 += texturingHeight2) {
|
||||
int distanceYRemaining2 = height - borderBottom - currentYPos2;
|
||||
texturingHeight2 = textHeight - borderTop - borderBottom;
|
||||
if (texturingHeight2 > distanceYRemaining2) {
|
||||
texturingHeight2 = distanceYRemaining2;
|
||||
}
|
||||
int texturingHeight2;
|
||||
for (int currentYPos2 = borderTop; currentYPos2 < height - borderBottom; currentYPos2 += texturingHeight2) {
|
||||
int distanceYRemaining2 = height - borderBottom - currentYPos2;
|
||||
texturingHeight2 = textHeight - borderTop - borderBottom;
|
||||
if (texturingHeight2 > distanceYRemaining2) {
|
||||
texturingHeight2 = distanceYRemaining2;
|
||||
}
|
||||
|
||||
if (texturingHeight2 <= 0) {
|
||||
break;
|
||||
}
|
||||
drawTexturedModalRect(posX, posY + currentYPos2, u, v + borderTop, borderLeft, texturingHeight2);
|
||||
drawTexturedModalRect(posX + width - borderRight, posY + currentYPos2, u + textWidth - borderRight, v + borderTop, borderRight, texturingHeight2);
|
||||
}
|
||||
}
|
||||
if (texturingHeight2 <= 0) {
|
||||
break;
|
||||
}
|
||||
drawTexturedModalRect(posX, posY + currentYPos2, u, v + borderTop, borderLeft, texturingHeight2);
|
||||
drawTexturedModalRect(
|
||||
posX + width - borderRight,
|
||||
posY + currentYPos2,
|
||||
u + textWidth - borderRight,
|
||||
v + borderTop,
|
||||
borderRight,
|
||||
texturingHeight2);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawGradientArea(float x, float y, float width, float height, int color1, int color2) {
|
||||
float alpha1 = (color1 >> 24 & 0xFF) / 255.0f;
|
||||
float r1 = (color1 >> 16 & 0xFF) / 255.0f;
|
||||
float b1 = (color1 >> 8 & 0xFF) / 255.0f;
|
||||
float g1 = (color1 & 0xFF) / 255.0f;
|
||||
public void drawGradientArea(float x, float y, float width, float height, int color1, int color2) {
|
||||
float alpha1 = (color1 >> 24 & 0xFF) / 255.0f;
|
||||
float r1 = (color1 >> 16 & 0xFF) / 255.0f;
|
||||
float b1 = (color1 >> 8 & 0xFF) / 255.0f;
|
||||
float g1 = (color1 & 0xFF) / 255.0f;
|
||||
|
||||
float alpha2 = (color2 >> 24 & 0xFF) / 255.0f;
|
||||
float r2 = (color2 >> 16 & 0xFF) / 255.0f;
|
||||
float g2 = (color2 >> 8 & 0xFF) / 255.0f;
|
||||
float b2 = (color2 & 0xFF) / 255.0f;
|
||||
float alpha2 = (color2 >> 24 & 0xFF) / 255.0f;
|
||||
float r2 = (color2 >> 16 & 0xFF) / 255.0f;
|
||||
float g2 = (color2 >> 8 & 0xFF) / 255.0f;
|
||||
float b2 = (color2 & 0xFF) / 255.0f;
|
||||
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(r1, b1, g1, alpha1);
|
||||
tessellator.addVertex(width, y, zLevel);
|
||||
tessellator.addVertex(x, y, zLevel);
|
||||
tessellator.setColorRGBA_F(r2, g2, b2, alpha2);
|
||||
tessellator.addVertex(x, height, zLevel);
|
||||
tessellator.addVertex(width, height, 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);
|
||||
}
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(r1, b1, g1, alpha1);
|
||||
tessellator.addVertex(width, y, zLevel);
|
||||
tessellator.addVertex(x, y, zLevel);
|
||||
tessellator.setColorRGBA_F(r2, g2, b2, alpha2);
|
||||
tessellator.addVertex(x, height, zLevel);
|
||||
tessellator.addVertex(width, height, 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);
|
||||
}
|
||||
|
||||
public void renderItem(IPoint pos, ItemStack item, boolean rotating) {
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
|
||||
GL11.glPushAttrib(8256);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
FontRenderer font = item.getItem().getFontRenderer(item);
|
||||
if (font == null) {
|
||||
font = getFontRenderer();
|
||||
}
|
||||
public void renderItem(IPoint pos, ItemStack item, boolean rotating) {
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
|
||||
GL11.glPushAttrib(8256);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
FontRenderer font = item.getItem().getFontRenderer(item);
|
||||
if (font == null) {
|
||||
font = getFontRenderer();
|
||||
}
|
||||
|
||||
BinnieCore.proxy.getMinecraftInstance();
|
||||
float phase = Minecraft.getSystemTime() / 20.0f;
|
||||
|
||||
if (rotating) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(8.0f, 8.0f, 0.0f);
|
||||
GL11.glRotatef(phase, 0.0f, -0.866f, 0.5f);
|
||||
GL11.glTranslatef(-8.0f, -8.0f, -67.1f);
|
||||
}
|
||||
BinnieCore.proxy.getMinecraftInstance();
|
||||
float phase = Minecraft.getSystemTime() / 20.0f;
|
||||
|
||||
GuiScreen.itemRender.renderItemAndEffectIntoGUI(font, mc.renderEngine, item, (int) pos.x(), (int) pos.y());
|
||||
if (rotating) {
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
if (rotating) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(8.0f, 8.0f, 0.0f);
|
||||
GL11.glRotatef(phase, 0.0f, -0.866f, 0.5f);
|
||||
GL11.glTranslatef(-8.0f, -8.0f, -67.1f);
|
||||
}
|
||||
|
||||
GuiScreen.itemRender.renderItemOverlayIntoGUI(font, mc.renderEngine, item, (int) pos.x(), (int) pos.y(), null);
|
||||
GL11.glClear(256);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
GuiScreen.itemRender.renderItemAndEffectIntoGUI(font, mc.renderEngine, item, (int) pos.x(), (int) pos.y());
|
||||
if (rotating) {
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void renderIcon(IPoint pos, IIcon icon, ResourceLocation map) {
|
||||
if (icon == null) {
|
||||
return;
|
||||
}
|
||||
GuiScreen.itemRender.renderItemOverlayIntoGUI(font, mc.renderEngine, item, (int) pos.x(), (int) pos.y(), null);
|
||||
GL11.glClear(256);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
BinnieCore.proxy.bindTexture(map);
|
||||
GuiScreen.itemRender.zLevel = zLevel;
|
||||
GuiScreen.itemRender.renderIcon((int) pos.x(), (int) pos.y(), icon, 16, 16);
|
||||
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
public void renderIcon(IPoint pos, IIcon icon, ResourceLocation map) {
|
||||
if (icon == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
public boolean isHelpMode() {
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_TAB);
|
||||
}
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
BinnieCore.proxy.bindTexture(map);
|
||||
GuiScreen.itemRender.zLevel = zLevel;
|
||||
GuiScreen.itemRender.renderIcon((int) pos.x(), (int) pos.y(), icon, 16, 16);
|
||||
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public FontRenderer getFontRenderer() {
|
||||
return fontRendererObj;
|
||||
}
|
||||
public boolean isHelpMode() {
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_TAB);
|
||||
}
|
||||
|
||||
public void resize(IPoint size) {
|
||||
xSize = (int) size.x();
|
||||
ySize = (int) size.y();
|
||||
guiLeft = (width - xSize) / 2;
|
||||
guiTop = (height - ySize) / 2;
|
||||
window.setPosition(new IPoint(guiLeft, guiTop));
|
||||
}
|
||||
public FontRenderer getFontRenderer() {
|
||||
return fontRendererObj;
|
||||
}
|
||||
|
||||
public void limitArea(IArea area) {
|
||||
float x = area.pos().x();
|
||||
float y = area.pos().y();
|
||||
float w = area.size().x();
|
||||
float h = area.size().y();
|
||||
y = height - (y + h);
|
||||
float scaleX = width / (float) mc.displayWidth;
|
||||
float scaleY = height / (float) mc.displayHeight;
|
||||
GL11.glScissor((int) (x / scaleX), (int) (y / scaleY), (int) (w / scaleX), (int) (h / scaleY));
|
||||
}
|
||||
public void resize(IPoint size) {
|
||||
xSize = (int) size.x();
|
||||
ySize = (int) size.y();
|
||||
guiLeft = (width - xSize) / 2;
|
||||
guiTop = (height - ySize) / 2;
|
||||
window.setPosition(new IPoint(guiLeft, guiTop));
|
||||
}
|
||||
|
||||
public void drawRect(float x, float y, float width, float height, int color) {
|
||||
if (x < width) {
|
||||
float temp = x;
|
||||
x = width;
|
||||
width = temp;
|
||||
}
|
||||
public void limitArea(IArea area) {
|
||||
float x = area.pos().x();
|
||||
float y = area.pos().y();
|
||||
float w = area.size().x();
|
||||
float h = area.size().y();
|
||||
y = height - (y + h);
|
||||
float scaleX = width / (float) mc.displayWidth;
|
||||
float scaleY = height / (float) mc.displayHeight;
|
||||
GL11.glScissor((int) (x / scaleX), (int) (y / scaleY), (int) (w / scaleX), (int) (h / scaleY));
|
||||
}
|
||||
|
||||
if (y < height) {
|
||||
float temp = y;
|
||||
y = height;
|
||||
height = temp;
|
||||
}
|
||||
public void drawRect(float x, float y, float width, float height, int color) {
|
||||
if (x < width) {
|
||||
float temp = x;
|
||||
x = width;
|
||||
width = temp;
|
||||
}
|
||||
|
||||
float alpha = (color >> 24 & 0xFF) / 255.0f;
|
||||
float r = (color >> 16 & 0xFF) / 255.0f;
|
||||
float g = (color >> 8 & 0xFF) / 255.0f;
|
||||
float b = (color & 0xFF) / 255.0f;
|
||||
if (y < height) {
|
||||
float temp = y;
|
||||
y = height;
|
||||
height = temp;
|
||||
}
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
GL11.glColor4f(r, g, b, alpha);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertex(x, height, 0.0);
|
||||
tessellator.addVertex(width, height, 0.0);
|
||||
tessellator.addVertex(width, y, 0.0);
|
||||
tessellator.addVertex(x, y, 0.0);
|
||||
tessellator.draw();
|
||||
GL11.glColor4f(1, 1, 1, 255);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
float alpha = (color >> 24 & 0xFF) / 255.0f;
|
||||
float r = (color >> 16 & 0xFF) / 255.0f;
|
||||
float g = (color >> 8 & 0xFF) / 255.0f;
|
||||
float b = (color & 0xFF) / 255.0f;
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
GL11.glColor4f(r, g, b, alpha);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertex(x, height, 0.0);
|
||||
tessellator.addVertex(width, height, 0.0);
|
||||
tessellator.addVertex(width, y, 0.0);
|
||||
tessellator.addVertex(x, y, 0.0);
|
||||
tessellator.draw();
|
||||
GL11.glColor4f(1, 1, 1, 255);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
package binnie.core.craftgui.minecraft;
|
||||
|
||||
public interface IMachineInformation {
|
||||
String getInformation();
|
||||
String getInformation();
|
||||
}
|
||||
@@ -3,5 +3,5 @@ package binnie.core.craftgui.minecraft;
|
||||
import binnie.core.craftgui.ITooltip;
|
||||
|
||||
public interface IMinecraftTooltip extends ITooltip {
|
||||
void getTooltip(MinecraftTooltip p0);
|
||||
void getTooltip(MinecraftTooltip p0);
|
||||
}
|
||||
@@ -3,5 +3,5 @@ package binnie.core.craftgui.minecraft;
|
||||
import binnie.core.machines.transfer.TransferRequest;
|
||||
|
||||
public interface IWindowAffectsShiftClick {
|
||||
void alterRequest(TransferRequest p0);
|
||||
void alterRequest(TransferRequest p0);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package binnie.core.craftgui.minecraft;
|
||||
|
||||
public enum InventoryType {
|
||||
Player,
|
||||
Machine,
|
||||
Window,
|
||||
Custom
|
||||
Player,
|
||||
Machine,
|
||||
Window,
|
||||
Custom
|
||||
}
|
||||
@@ -8,140 +8,140 @@ import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
class ListMap<T> implements List<T> {
|
||||
private LinkedHashMap<Integer, T> map;
|
||||
private LinkedHashMap<Integer, T> map;
|
||||
|
||||
ListMap() {
|
||||
map = new LinkedHashMap<>();
|
||||
}
|
||||
ListMap() {
|
||||
map = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
int i = -1;
|
||||
for (int k : map.keySet()) {
|
||||
if (k > i) {
|
||||
i = k;
|
||||
}
|
||||
}
|
||||
return i + 1;
|
||||
}
|
||||
@Override
|
||||
public int size() {
|
||||
int i = -1;
|
||||
for (int k : map.keySet()) {
|
||||
if (k > i) {
|
||||
i = k;
|
||||
}
|
||||
}
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return map.isEmpty();
|
||||
}
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return map.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return map.containsValue(o);
|
||||
}
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return map.containsValue(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return map.values().iterator();
|
||||
}
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return map.values().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return map.values().toArray();
|
||||
}
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return map.values().toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <P> P[] toArray(P[] a) {
|
||||
return map.values().toArray(a);
|
||||
}
|
||||
@Override
|
||||
public <P> P[] toArray(P[] a) {
|
||||
return map.values().toArray(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(T e) {
|
||||
if (get(size()) == null) {
|
||||
add(size(), e);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean add(T e) {
|
||||
if (get(size()) == null) {
|
||||
add(size(), e);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
return map.values().containsAll(c);
|
||||
}
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
return map.values().containsAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends T> c) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends T> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends T> c) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends T> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
map.clear();
|
||||
}
|
||||
@Override
|
||||
public void clear() {
|
||||
map.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(int index) {
|
||||
return map.get(index);
|
||||
}
|
||||
@Override
|
||||
public T get(int index) {
|
||||
return map.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T set(int index, T element) {
|
||||
map.put(index, element);
|
||||
return element;
|
||||
}
|
||||
@Override
|
||||
public T set(int index, T element) {
|
||||
map.put(index, element);
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, T element) {
|
||||
map.put(index, element);
|
||||
}
|
||||
@Override
|
||||
public void add(int index, T element) {
|
||||
map.put(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T remove(int index) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public T remove(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
for (Map.Entry<Integer, T> entry : map.entrySet()) {
|
||||
if (entry.getValue() == o) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
for (Map.Entry<Integer, T> entry : map.entrySet()) {
|
||||
if (entry.getValue() == o) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
return indexOf(o);
|
||||
}
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
return indexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<T> listIterator() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ListIterator<T> listIterator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<T> listIterator(int index) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ListIterator<T> listIterator(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> subList(int fromIndex, int toIndex) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public List<T> subList(int fromIndex, int toIndex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 818 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user