Doubled filter max string length from 12 characters to 24 characters, allows hyphens and spaces in filters, developed and integrated new fancy auto-scaling text renderer to prevent text overlap
This commit is contained in:
parent
7d17192173
commit
09f1a04764
10 changed files with 60 additions and 34 deletions
|
@ -33,10 +33,10 @@ public class GuiDynamicTank extends GuiMekanism
|
|||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040);
|
||||
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.volume") + ": " + tileEntity.clientCapacity/TankUpdateProtocol.FLUID_PER_TANK, 53, 26, 0x00CD00);
|
||||
fontRendererObj.drawString(tileEntity.structure.fluidStored != null ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ":" : MekanismUtils.localize("gui.noFluid"), 53, 44, 0x00CD00);
|
||||
renderScaledText(tileEntity.structure.fluidStored != null ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ":" : MekanismUtils.localize("gui.noFluid"), 53, 44, 0x00CD00, 74);
|
||||
|
||||
if(tileEntity.structure.fluidStored != null)
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ public class GuiGasTank extends GuiMekanism
|
|||
|
||||
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize / 2) - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), 6, 0x404040);
|
||||
fontRendererObj.drawString(capacityInfo, 45, 40, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.gas") + ": " + (tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() : MekanismUtils.localize("gui.none")), 45, 49, 0x404040);
|
||||
renderScaledText(MekanismUtils.localize("gui.gas") + ": " + (tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() : MekanismUtils.localize("gui.none")), 45, 49, 0x404040, 112);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040);
|
||||
|
||||
String name = chooseByMode(tileEntity.dumping, MekanismUtils.localize("gui.idle"), MekanismUtils.localize("gui.dumping"), MekanismUtils.localize("gui.dumping_excess"));
|
||||
|
|
|
@ -8,6 +8,7 @@ import mekanism.client.sound.SoundHandler;
|
|||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.OreDictCache;
|
||||
import mekanism.common.content.miner.MModIDFilter;
|
||||
import mekanism.common.content.transporter.TransporterFilter;
|
||||
import mekanism.common.inventory.container.ContainerFilter;
|
||||
import mekanism.common.network.PacketDigitalMinerGui.DigitalMinerGuiMessage;
|
||||
import mekanism.common.network.PacketDigitalMinerGui.MinerGuiPacket;
|
||||
|
@ -17,7 +18,6 @@ import mekanism.common.tile.TileEntityDigitalMiner;
|
|||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
@ -25,12 +25,13 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiMModIDFilter extends GuiMekanism
|
||||
{
|
||||
|
@ -93,7 +94,7 @@ public class GuiMModIDFilter extends GuiMekanism
|
|||
}
|
||||
|
||||
modIDText = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 47, 95, 12);
|
||||
modIDText.setMaxStringLength(12);
|
||||
modIDText.setMaxStringLength(TransporterFilter.MAX_LENGTH);
|
||||
modIDText.setFocused(true);
|
||||
}
|
||||
|
||||
|
@ -111,7 +112,7 @@ public class GuiMModIDFilter extends GuiMekanism
|
|||
return;
|
||||
}
|
||||
|
||||
if(Character.isLetter(c) || Character.isDigit(c) || c == '*' || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT)
|
||||
if(Character.isLetter(c) || Character.isDigit(c) || TransporterFilter.SPECIAL_CHARS.contains(c) || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT)
|
||||
{
|
||||
modIDText.textboxKeyTyped(c, i);
|
||||
}
|
||||
|
@ -161,7 +162,7 @@ public class GuiMModIDFilter extends GuiMekanism
|
|||
|
||||
fontRendererObj.drawString((isNew ? MekanismUtils.localize("gui.new") : MekanismUtils.localize("gui.edit")) + " " + MekanismUtils.localize("gui.modIDFilter"), 43, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.id") + ": " + filter.modID, 35, 32, 0x00CD00);
|
||||
renderScaledText(MekanismUtils.localize("gui.id") + ": " + filter.modID, 35, 32, 0x00CD00, 107);
|
||||
|
||||
if(renderStack != null)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ import mekanism.client.sound.SoundHandler;
|
|||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.OreDictCache;
|
||||
import mekanism.common.content.miner.MOreDictFilter;
|
||||
import mekanism.common.content.transporter.TransporterFilter;
|
||||
import mekanism.common.inventory.container.ContainerFilter;
|
||||
import mekanism.common.network.PacketDigitalMinerGui.DigitalMinerGuiMessage;
|
||||
import mekanism.common.network.PacketDigitalMinerGui.MinerGuiPacket;
|
||||
|
@ -17,7 +18,6 @@ import mekanism.common.tile.TileEntityDigitalMiner;
|
|||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
@ -25,12 +25,13 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiMOreDictFilter extends GuiMekanism
|
||||
{
|
||||
|
@ -93,7 +94,7 @@ public class GuiMOreDictFilter extends GuiMekanism
|
|||
}
|
||||
|
||||
oreDictText = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 47, 95, 12);
|
||||
oreDictText.setMaxStringLength(12);
|
||||
oreDictText.setMaxStringLength(TransporterFilter.MAX_LENGTH);
|
||||
oreDictText.setFocused(true);
|
||||
}
|
||||
|
||||
|
@ -111,7 +112,7 @@ public class GuiMOreDictFilter extends GuiMekanism
|
|||
return;
|
||||
}
|
||||
|
||||
if(Character.isLetter(c) || Character.isDigit(c) || c == '*' || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT)
|
||||
if(Character.isLetter(c) || Character.isDigit(c) || TransporterFilter.SPECIAL_CHARS.contains(c) || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT)
|
||||
{
|
||||
oreDictText.textboxKeyTyped(c, i);
|
||||
}
|
||||
|
@ -161,7 +162,7 @@ public class GuiMOreDictFilter extends GuiMekanism
|
|||
|
||||
fontRendererObj.drawString((isNew ? MekanismUtils.localize("gui.new") : MekanismUtils.localize("gui.edit")) + " " + MekanismUtils.localize("gui.oredictFilter"), 43, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.key") + ": " + filter.oreDictName, 35, 32, 0x00CD00);
|
||||
renderScaledText(MekanismUtils.localize("gui.key") + ": " + filter.oreDictName, 35, 32, 0x00CD00, 107);
|
||||
|
||||
if(renderStack != null)
|
||||
{
|
||||
|
|
|
@ -9,7 +9,6 @@ import mekanism.common.SideData;
|
|||
import mekanism.common.base.IInvConfiguration;
|
||||
import mekanism.common.item.ItemConfigurator;
|
||||
import mekanism.common.tile.TileEntityContainerBlock;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
@ -36,6 +35,28 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper
|
|||
tileEntity = tile;
|
||||
}
|
||||
|
||||
public void renderScaledText(String text, int x, int y, int color, int maxX)
|
||||
{
|
||||
int length = fontRendererObj.getStringWidth(text);
|
||||
|
||||
if(length <= maxX)
|
||||
{
|
||||
fontRendererObj.drawString(text, x, y, color);
|
||||
}
|
||||
else {
|
||||
float scale = (float)maxX/length;
|
||||
float reverse = 1/scale;
|
||||
float yAdd = 4-(scale*8)/2F;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
fontRendererObj.drawString(text, (int)(x*reverse), (int)((y*reverse)+yAdd), color);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@ import mekanism.client.sound.SoundHandler;
|
|||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.OreDictCache;
|
||||
import mekanism.common.content.transporter.TModIDFilter;
|
||||
import mekanism.common.content.transporter.TransporterFilter;
|
||||
import mekanism.common.inventory.container.ContainerFilter;
|
||||
import mekanism.common.network.PacketEditFilter.EditFilterMessage;
|
||||
import mekanism.common.network.PacketLogisticalSorterGui.LogisticalSorterGuiMessage;
|
||||
|
@ -18,18 +19,18 @@ import mekanism.common.tile.TileEntityLogisticalSorter;
|
|||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import mekanism.common.util.TransporterUtils;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiTModIDFilter extends GuiMekanism
|
||||
{
|
||||
|
@ -92,7 +93,7 @@ public class GuiTModIDFilter extends GuiMekanism
|
|||
}
|
||||
|
||||
modIDText = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 47, 95, 12);
|
||||
modIDText.setMaxStringLength(12);
|
||||
modIDText.setMaxStringLength(TransporterFilter.MAX_LENGTH);
|
||||
modIDText.setFocused(true);
|
||||
}
|
||||
|
||||
|
@ -110,7 +111,7 @@ public class GuiTModIDFilter extends GuiMekanism
|
|||
return;
|
||||
}
|
||||
|
||||
if(Character.isLetter(c) || Character.isDigit(c) || c == '*' || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT)
|
||||
if(Character.isLetter(c) || Character.isDigit(c) || TransporterFilter.SPECIAL_CHARS.contains(c) || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT)
|
||||
{
|
||||
modIDText.textboxKeyTyped(c, i);
|
||||
}
|
||||
|
@ -160,7 +161,7 @@ public class GuiTModIDFilter extends GuiMekanism
|
|||
|
||||
fontRendererObj.drawString((isNew ? MekanismUtils.localize("gui.new") : MekanismUtils.localize("gui.edit")) + " " + MekanismUtils.localize("gui.modIDFilter"), 43, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.id") + ": " + filter.modID, 35, 32, 0x00CD00);
|
||||
renderScaledText(MekanismUtils.localize("gui.id") + ": " + filter.modID, 35, 32, 0x00CD00, 107);
|
||||
|
||||
if(renderStack != null)
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@ import mekanism.client.sound.SoundHandler;
|
|||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.OreDictCache;
|
||||
import mekanism.common.content.transporter.TOreDictFilter;
|
||||
import mekanism.common.content.transporter.TransporterFilter;
|
||||
import mekanism.common.inventory.container.ContainerFilter;
|
||||
import mekanism.common.network.PacketEditFilter.EditFilterMessage;
|
||||
import mekanism.common.network.PacketLogisticalSorterGui.LogisticalSorterGuiMessage;
|
||||
|
@ -18,7 +19,6 @@ import mekanism.common.tile.TileEntityLogisticalSorter;
|
|||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import mekanism.common.util.TransporterUtils;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -92,7 +92,7 @@ public class GuiTOreDictFilter extends GuiMekanism
|
|||
}
|
||||
|
||||
oreDictText = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 47, 95, 12);
|
||||
oreDictText.setMaxStringLength(12);
|
||||
oreDictText.setMaxStringLength(TransporterFilter.MAX_LENGTH);
|
||||
oreDictText.setFocused(true);
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ public class GuiTOreDictFilter extends GuiMekanism
|
|||
return;
|
||||
}
|
||||
|
||||
if(Character.isLetter(c) || Character.isDigit(c) || c == '*' || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT)
|
||||
if(Character.isLetter(c) || Character.isDigit(c) || TransporterFilter.SPECIAL_CHARS.contains(c) || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT)
|
||||
{
|
||||
oreDictText.textboxKeyTyped(c, i);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public class GuiTOreDictFilter extends GuiMekanism
|
|||
|
||||
fontRendererObj.drawString((isNew ? MekanismUtils.localize("gui.new") : MekanismUtils.localize("gui.edit")) + " " + MekanismUtils.localize("gui.oredictFilter"), 43, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.key") + ": " + filter.oreDictName, 35, 32, 0x00CD00);
|
||||
renderScaledText(MekanismUtils.localize("gui.key") + ": " + filter.oreDictName, 35, 32, 0x00CD00, 107);
|
||||
|
||||
if(renderStack != null)
|
||||
{
|
||||
|
|
|
@ -173,13 +173,11 @@ public class RenderBin extends TileEntitySpecialRenderer
|
|||
GL11.glScalef(scale, -scale, scale);
|
||||
GL11.glDepthMask(false);
|
||||
|
||||
int offsetX;
|
||||
int offsetY;
|
||||
int realHeight = (int)Math.floor(displayHeight / scale);
|
||||
int realWidth = (int)Math.floor(displayWidth / scale);
|
||||
|
||||
offsetX = (realWidth - requiredWidth) / 2;
|
||||
offsetY = (realHeight - requiredHeight) / 2;
|
||||
int offsetX = (realWidth - requiredWidth) / 2;
|
||||
int offsetY = (realHeight - requiredHeight) / 2;
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
fontRenderer.drawString("\u00a7f" + text, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1);
|
||||
|
|
|
@ -1,19 +1,24 @@
|
|||
package mekanism.common.content.transporter;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.common.util.TransporterUtils;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public abstract class TransporterFilter
|
||||
{
|
||||
public static final int MAX_LENGTH = 24;
|
||||
|
||||
public static final List<Character> SPECIAL_CHARS = Arrays.asList('*', '-', ' ');
|
||||
|
||||
public EnumColor color;
|
||||
|
||||
public abstract boolean canFilter(ItemStack itemStack);
|
||||
|
|
|
@ -49,7 +49,6 @@ import mekanism.common.network.PacketElectricChest.ElectricChestPacketType;
|
|||
import mekanism.common.tile.TileEntityAdvancedBoundingBlock;
|
||||
import mekanism.common.tile.TileEntityBoundingBlock;
|
||||
import mekanism.common.tile.TileEntityElectricChest;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
|
Loading…
Reference in a new issue