pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -12,12 +12,13 @@ public final class CommonButtons {
|
||||
}
|
||||
|
||||
public static GuiSettingToggleButton<PowerUnits> togglePowerUnit(int x, int y) {
|
||||
return new GuiSettingToggleButton<>( x, y, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit(), CommonButtons::togglePowerUnit );
|
||||
return new GuiSettingToggleButton<>(x, y, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit(),
|
||||
CommonButtons::togglePowerUnit);
|
||||
}
|
||||
|
||||
private static void togglePowerUnit(GuiSettingToggleButton<PowerUnits> button, boolean backwards) {
|
||||
AEConfig.instance().nextPowerUnit( backwards );
|
||||
button.set( AEConfig.instance().selectedPowerUnit() );
|
||||
AEConfig.instance().nextPowerUnit(backwards);
|
||||
button.set(AEConfig.instance().selectedPowerUnit());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,10 +18,14 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
@@ -29,87 +33,77 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
|
||||
public class GuiActionButton extends GuiIconButton implements ITooltip {
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
|
||||
private final int iconIndex;
|
||||
|
||||
public class GuiActionButton extends GuiIconButton implements ITooltip
|
||||
{
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL );
|
||||
private final int iconIndex;
|
||||
public GuiActionButton(final int x, final int y, final ActionItems action, Consumer<ActionItems> onPress) {
|
||||
super(x, y, btn -> onPress.accept(action));
|
||||
|
||||
public GuiActionButton(final int x, final int y, final ActionItems action, Consumer<ActionItems> onPress )
|
||||
{
|
||||
super( x, y, btn -> onPress.accept(action) );
|
||||
ButtonToolTips displayName;
|
||||
ButtonToolTips displayValue;
|
||||
switch (action) {
|
||||
case WRENCH:
|
||||
iconIndex = 66;
|
||||
displayName = ButtonToolTips.PartitionStorage;
|
||||
displayValue = ButtonToolTips.PartitionStorageHint;
|
||||
break;
|
||||
case CLOSE:
|
||||
iconIndex = 6;
|
||||
displayName = ButtonToolTips.Clear;
|
||||
displayValue = ButtonToolTips.ClearSettings;
|
||||
break;
|
||||
case STASH:
|
||||
iconIndex = 6;
|
||||
displayName = ButtonToolTips.Stash;
|
||||
displayValue = ButtonToolTips.StashDesc;
|
||||
break;
|
||||
case ENCODE:
|
||||
iconIndex = 8;
|
||||
displayName = ButtonToolTips.Encode;
|
||||
displayValue = ButtonToolTips.EncodeDescription;
|
||||
break;
|
||||
case ENABLE_SUBSTITUTION:
|
||||
iconIndex = 4 + 3 * 16;
|
||||
displayName = ButtonToolTips.Substitutions;
|
||||
displayValue = ButtonToolTips.SubstitutionsDescEnabled;
|
||||
break;
|
||||
case DISABLE_SUBSTITUTION:
|
||||
iconIndex = 7 + 3 * 16;
|
||||
displayName = ButtonToolTips.Substitutions;
|
||||
displayValue = ButtonToolTips.SubstitutionsDescDisabled;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown ActionItem: " + action);
|
||||
}
|
||||
|
||||
ButtonToolTips displayName;
|
||||
ButtonToolTips displayValue;
|
||||
switch (action) {
|
||||
case WRENCH:
|
||||
iconIndex = 66;
|
||||
displayName = ButtonToolTips.PartitionStorage;
|
||||
displayValue = ButtonToolTips.PartitionStorageHint;
|
||||
break;
|
||||
case CLOSE:
|
||||
iconIndex = 6;
|
||||
displayName = ButtonToolTips.Clear;
|
||||
displayValue = ButtonToolTips.ClearSettings;
|
||||
break;
|
||||
case STASH:
|
||||
iconIndex = 6;
|
||||
displayName = ButtonToolTips.Stash;
|
||||
displayValue = ButtonToolTips.StashDesc;
|
||||
break;
|
||||
case ENCODE:
|
||||
iconIndex = 8;
|
||||
displayName = ButtonToolTips.Encode;
|
||||
displayValue = ButtonToolTips.EncodeDescription;
|
||||
break;
|
||||
case ENABLE_SUBSTITUTION:
|
||||
iconIndex = 4 + 3 * 16;
|
||||
displayName = ButtonToolTips.Substitutions;
|
||||
displayValue = ButtonToolTips.SubstitutionsDescEnabled;
|
||||
break;
|
||||
case DISABLE_SUBSTITUTION:
|
||||
iconIndex = 7 + 3 * 16;
|
||||
displayName = ButtonToolTips.Substitutions;
|
||||
displayValue = ButtonToolTips.SubstitutionsDescDisabled;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown ActionItem: " + action);
|
||||
}
|
||||
setMessage(buildMessage(displayName, displayValue));
|
||||
}
|
||||
|
||||
setMessage(buildMessage(displayName, displayValue));
|
||||
}
|
||||
@Override
|
||||
protected int getIconIndex() {
|
||||
return iconIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIconIndex()
|
||||
{
|
||||
return iconIndex;
|
||||
}
|
||||
private String buildMessage(ButtonToolTips displayName, ButtonToolTips displayValue) {
|
||||
String name = displayName.getTranslationKey().getString();
|
||||
String value = displayValue.getTranslationKey().getString();
|
||||
|
||||
private String buildMessage(ButtonToolTips displayName, ButtonToolTips displayValue)
|
||||
{
|
||||
String name = displayName.getTranslationKey().getString();
|
||||
String value = displayValue.getTranslationKey().getString();
|
||||
value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n");
|
||||
final StringBuilder sb = new StringBuilder(value);
|
||||
|
||||
value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" );
|
||||
final StringBuilder sb = new StringBuilder( value );
|
||||
int i = sb.lastIndexOf("\n");
|
||||
if (i <= 0) {
|
||||
i = 0;
|
||||
}
|
||||
while (i + 30 < sb.length() && (i = sb.lastIndexOf(" ", i + 30)) != -1) {
|
||||
sb.replace(i, i + 1, "\n");
|
||||
}
|
||||
|
||||
int i = sb.lastIndexOf( "\n" );
|
||||
if( i <= 0 )
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
|
||||
{
|
||||
sb.replace( i, i + 1, "\n" );
|
||||
}
|
||||
|
||||
return name + '\n' + sb;
|
||||
}
|
||||
return name + '\n' + sb;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,85 +1,70 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class GuiCustomSlot extends AbstractGui implements ITooltip {
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int id;
|
||||
|
||||
public abstract class GuiCustomSlot extends AbstractGui implements ITooltip
|
||||
{
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int id;
|
||||
public GuiCustomSlot(final int id, final int x, final int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public GuiCustomSlot( final int id, final int x, final int y )
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.id = id;
|
||||
}
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
public boolean canClick(final PlayerEntity player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canClick( final PlayerEntity player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public void slotClicked(final ItemStack clickStack, final int mouseButton) {
|
||||
}
|
||||
|
||||
public void slotClicked( final ItemStack clickStack, final int mouseButton )
|
||||
{
|
||||
}
|
||||
public abstract void drawContent(final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks);
|
||||
|
||||
public abstract void drawContent( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks );
|
||||
public void drawBackground(int guileft, int guitop, int currentZIndex) {
|
||||
}
|
||||
|
||||
public void drawBackground( int guileft, int guitop, int currentZIndex )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public boolean isSlotEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
@@ -29,128 +31,108 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
|
||||
public abstract class GuiIconButton extends Button implements ITooltip {
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2",
|
||||
"textures/guis/states.png");
|
||||
|
||||
public abstract class GuiIconButton extends Button implements ITooltip
|
||||
{
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png");
|
||||
private boolean halfSize = false;
|
||||
|
||||
private boolean halfSize = false;
|
||||
public GuiIconButton(final int x, final int y, IPressable onPress) {
|
||||
super(x, y, 16, 16, "", onPress);
|
||||
}
|
||||
|
||||
public GuiIconButton(final int x, final int y, IPressable onPress )
|
||||
{
|
||||
super( x, y, 16, 16, "", onPress );
|
||||
}
|
||||
public void setVisibility(final boolean vis) {
|
||||
this.visible = vis;
|
||||
this.active = vis;
|
||||
}
|
||||
|
||||
public void setVisibility( final boolean vis )
|
||||
{
|
||||
this.visible = vis;
|
||||
this.active = vis;
|
||||
}
|
||||
@Override
|
||||
public void renderButton(final int mouseX, final int mouseY, float partial) {
|
||||
|
||||
@Override
|
||||
public void renderButton(final int mouseX, final int mouseY, float partial) {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
if (this.visible) {
|
||||
final int iconIndex = this.getIconIndex();
|
||||
|
||||
if( this.visible )
|
||||
{
|
||||
final int iconIndex = this.getIconIndex();
|
||||
TextureManager textureManager = minecraft.getTextureManager();
|
||||
textureManager.bindTexture(TEXTURE_STATES);
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.enableBlend(); // FIXME: This should be the _default_ state, but some vanilla widget disables
|
||||
// it :|
|
||||
if (this.halfSize) {
|
||||
this.width = 8;
|
||||
this.height = 8;
|
||||
|
||||
TextureManager textureManager = minecraft.getTextureManager();
|
||||
textureManager.bindTexture(TEXTURE_STATES);
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.enableBlend(); // FIXME: This should be the _default_ state, but some vanilla widget disables it :|
|
||||
if( this.halfSize )
|
||||
{
|
||||
this.width = 8;
|
||||
this.height = 8;
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translatef(this.x, this.y, 0.0F);
|
||||
RenderSystem.scalef(0.5f, 0.5f, 0.5f);
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translatef( this.x, this.y, 0.0F );
|
||||
RenderSystem.scalef( 0.5f, 0.5f, 0.5f );
|
||||
if (this.active) {
|
||||
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
} else {
|
||||
RenderSystem.color4f(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
if( this.active )
|
||||
{
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSystem.color4f( 0.5f, 0.5f, 0.5f, 1.0f );
|
||||
}
|
||||
final int uv_y = iconIndex / 16;
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
final int uv_y = iconIndex / 16;
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
GuiUtils.drawTexturedModalRect(0, 0, 256 - 16, 256 - 16, 16, 16, 0);
|
||||
GuiUtils.drawTexturedModalRect(0, 0, uv_x * 16, uv_y * 16, 16, 16, 0);
|
||||
RenderSystem.popMatrix();
|
||||
} else {
|
||||
if (this.active) {
|
||||
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
} else {
|
||||
RenderSystem.color4f(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
GuiUtils.drawTexturedModalRect( 0, 0, 256 - 16, 256 - 16, 16, 16, 0 );
|
||||
GuiUtils.drawTexturedModalRect( 0, 0, uv_x * 16, uv_y * 16, 16, 16, 0 );
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( this.active )
|
||||
{
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSystem.color4f( 0.5f, 0.5f, 0.5f, 1.0f );
|
||||
}
|
||||
final int uv_y = iconIndex / 16;
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
final int uv_y = iconIndex / 16;
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
GuiUtils.drawTexturedModalRect(this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0);
|
||||
GuiUtils.drawTexturedModalRect(this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0);
|
||||
}
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0 );
|
||||
}
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
protected abstract int getIconIndex();
|
||||
|
||||
protected abstract int getIconIndex();
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.halfSize ? 8 : 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return this.halfSize ? 8 : 16;
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.halfSize ? 8 : 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return this.halfSize ? 8 : 16;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return this.visible;
|
||||
}
|
||||
public boolean isHalfSize() {
|
||||
return this.halfSize;
|
||||
}
|
||||
|
||||
public boolean isHalfSize()
|
||||
{
|
||||
return this.halfSize;
|
||||
}
|
||||
|
||||
public void setHalfSize( final boolean halfSize )
|
||||
{
|
||||
this.halfSize = halfSize;
|
||||
}
|
||||
public void setHalfSize(final boolean halfSize) {
|
||||
this.halfSize = halfSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,46 +18,35 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
|
||||
// FIXME: Fix this piece of crap (i.e. onChange listener)
|
||||
public class GuiNumberBox extends TextFieldWidget
|
||||
{
|
||||
public class GuiNumberBox extends TextFieldWidget {
|
||||
|
||||
private final Class type;
|
||||
private final Class type;
|
||||
|
||||
public GuiNumberBox( final FontRenderer fontRenderer, final int x, final int y, final int width, final int height, final Class type )
|
||||
{
|
||||
super( fontRenderer, x, y, width, height, "0" );
|
||||
this.type = type;
|
||||
}
|
||||
public GuiNumberBox(final FontRenderer fontRenderer, final int x, final int y, final int width, final int height,
|
||||
final Class type) {
|
||||
super(fontRenderer, x, y, width, height, "0");
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeText( final String selectedText )
|
||||
{
|
||||
final String original = this.getText();
|
||||
super.writeText( selectedText );
|
||||
@Override
|
||||
public void writeText(final String selectedText) {
|
||||
final String original = this.getText();
|
||||
super.writeText(selectedText);
|
||||
|
||||
try
|
||||
{
|
||||
if( this.type == int.class || this.type == Integer.class )
|
||||
{
|
||||
Integer.parseInt( this.getText() );
|
||||
}
|
||||
else if( this.type == long.class || this.type == Long.class )
|
||||
{
|
||||
Long.parseLong( this.getText() );
|
||||
}
|
||||
else if( this.type == double.class || this.type == Double.class )
|
||||
{
|
||||
Double.parseDouble( this.getText() );
|
||||
}
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
this.setText( original );
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (this.type == int.class || this.type == Integer.class) {
|
||||
Integer.parseInt(this.getText());
|
||||
} else if (this.type == long.class || this.type == Long.class) {
|
||||
Long.parseLong(this.getText());
|
||||
} else if (this.type == double.class || this.type == Double.class) {
|
||||
Double.parseDouble(this.getText());
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
this.setText(original);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,115 +18,100 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.container.interfaces.IProgressProvider;
|
||||
import appeng.core.localization.GuiText;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiProgressBar extends Widget implements ITooltip {
|
||||
|
||||
public class GuiProgressBar extends Widget implements ITooltip
|
||||
{
|
||||
private final IProgressProvider source;
|
||||
private final ResourceLocation texture;
|
||||
private final int fill_u;
|
||||
private final int fill_v;
|
||||
private final Direction layout;
|
||||
private final String titleName;
|
||||
private String fullMsg;
|
||||
|
||||
private final IProgressProvider source;
|
||||
private final ResourceLocation texture;
|
||||
private final int fill_u;
|
||||
private final int fill_v;
|
||||
private final Direction layout;
|
||||
private final String titleName;
|
||||
private String fullMsg;
|
||||
public GuiProgressBar(final IProgressProvider source, final String texture, final int posX, final int posY,
|
||||
final int u, final int y, final int width, final int height, final Direction dir) {
|
||||
this(source, texture, posX, posY, u, y, width, height, dir, null);
|
||||
}
|
||||
|
||||
public GuiProgressBar( final IProgressProvider source, final String texture, final int posX, final int posY, final int u, final int y, final int width, final int height, final Direction dir )
|
||||
{
|
||||
this( source, texture, posX, posY, u, y, width, height, dir, null );
|
||||
}
|
||||
public GuiProgressBar(final IProgressProvider source, final String texture, final int posX, final int posY,
|
||||
final int u, final int y, final int width, final int height, final Direction dir, final String title) {
|
||||
super(posX, posY, width, height, "");
|
||||
this.source = source;
|
||||
this.texture = new ResourceLocation("appliedenergistics2", "textures/" + texture);
|
||||
this.fill_u = u;
|
||||
this.fill_v = y;
|
||||
this.layout = dir;
|
||||
this.titleName = title;
|
||||
}
|
||||
|
||||
public GuiProgressBar( final IProgressProvider source, final String texture, final int posX, final int posY, final int u, final int y, final int width, final int height, final Direction dir, final String title )
|
||||
{
|
||||
super( posX, posY, width, height, "" );
|
||||
this.source = source;
|
||||
this.texture = new ResourceLocation( "appliedenergistics2", "textures/" + texture );
|
||||
this.fill_u = u;
|
||||
this.fill_v = y;
|
||||
this.layout = dir;
|
||||
this.titleName = title;
|
||||
}
|
||||
@Override
|
||||
public void renderButton(final int par2, final int par3, final float partial) {
|
||||
if (this.visible) {
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(this.texture);
|
||||
final int max = this.source.getMaxProgress();
|
||||
final int current = this.source.getCurrentProgress();
|
||||
|
||||
@Override
|
||||
public void renderButton( final int par2, final int par3, final float partial )
|
||||
{
|
||||
if( this.visible )
|
||||
{
|
||||
Minecraft.getInstance().getTextureManager().bindTexture( this.texture );
|
||||
final int max = this.source.getMaxProgress();
|
||||
final int current = this.source.getCurrentProgress();
|
||||
if (this.layout == Direction.VERTICAL) {
|
||||
final int diff = this.height - (max > 0 ? (this.height * current) / max : 0);
|
||||
GuiUtils.drawTexturedModalRect(this.x, this.y + diff, this.fill_u, this.fill_v + diff, this.width,
|
||||
this.height - diff, 0);
|
||||
} else {
|
||||
final int diff = this.width - (max > 0 ? (this.width * current) / max : 0);
|
||||
GuiUtils.drawTexturedModalRect(this.x, this.y, this.fill_u + diff, this.fill_v, this.width - diff,
|
||||
this.height, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( this.layout == Direction.VERTICAL )
|
||||
{
|
||||
final int diff = this.height - ( max > 0 ? ( this.height * current ) / max : 0 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y + diff, this.fill_u, this.fill_v + diff, this.width, this.height - diff, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
final int diff = this.width - ( max > 0 ? ( this.width * current ) / max : 0 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, this.fill_u + diff, this.fill_v, this.width - diff, this.height, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setFullMsg(final String msg) {
|
||||
this.fullMsg = msg;
|
||||
}
|
||||
|
||||
public void setFullMsg( final String msg )
|
||||
{
|
||||
this.fullMsg = msg;
|
||||
}
|
||||
@Override
|
||||
public String getMessage() {
|
||||
if (this.fullMsg != null) {
|
||||
return this.fullMsg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
if( this.fullMsg != null )
|
||||
{
|
||||
return this.fullMsg;
|
||||
}
|
||||
return (this.titleName != null ? this.titleName : "") + '\n' + this.source.getCurrentProgress() + ' '
|
||||
+ GuiText.Of.getLocal() + ' ' + this.source.getMaxProgress();
|
||||
}
|
||||
|
||||
return ( this.titleName != null ? this.titleName : "" ) + '\n' + this.source.getCurrentProgress() + ' ' + GuiText.Of.getLocal() + ' ' + this.source
|
||||
.getMaxProgress();
|
||||
}
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.x - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return this.x - 2;
|
||||
}
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.y - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return this.y - 2;
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.width + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return this.width + 4;
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return this.height + 4;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public enum Direction
|
||||
{
|
||||
HORIZONTAL, VERTICAL
|
||||
}
|
||||
public enum Direction {
|
||||
HORIZONTAL, VERTICAL
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,139 +18,117 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
|
||||
public class GuiScrollbar implements IScrollSource
|
||||
{
|
||||
public class GuiScrollbar implements IScrollSource {
|
||||
|
||||
private int displayX = 0;
|
||||
private int displayY = 0;
|
||||
private int width = 12;
|
||||
private int height = 16;
|
||||
private int pageSize = 1;
|
||||
private int displayX = 0;
|
||||
private int displayY = 0;
|
||||
private int width = 12;
|
||||
private int height = 16;
|
||||
private int pageSize = 1;
|
||||
|
||||
private int maxScroll = 0;
|
||||
private int minScroll = 0;
|
||||
private int currentScroll = 0;
|
||||
private int maxScroll = 0;
|
||||
private int minScroll = 0;
|
||||
private int currentScroll = 0;
|
||||
|
||||
public void draw( final AEBaseGui g )
|
||||
{
|
||||
g.bindTexture( "minecraft", "gui/container/creative_inventory/tabs.png" );
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
public void draw(final AEBaseGui g) {
|
||||
g.bindTexture("minecraft", "gui/container/creative_inventory/tabs.png");
|
||||
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
if( this.getRange() == 0 )
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( this.displayX, this.displayY, 232 + this.width, 0, this.width, 15, 0 /* FIXME: this used the GUI's zIndex before */ );
|
||||
}
|
||||
else
|
||||
{
|
||||
final int offset = ( this.currentScroll - this.minScroll ) * ( this.height - 15 ) / this.getRange();
|
||||
GuiUtils.drawTexturedModalRect( this.displayX, offset + this.displayY, 232, 0, this.width, 15, 0 /* FIXME: this used the GUI's zIndex before */ );
|
||||
}
|
||||
}
|
||||
if (this.getRange() == 0) {
|
||||
GuiUtils.drawTexturedModalRect(this.displayX, this.displayY, 232 + this.width, 0, this.width, 15,
|
||||
0 /* FIXME: this used the GUI's zIndex before */ );
|
||||
} else {
|
||||
final int offset = (this.currentScroll - this.minScroll) * (this.height - 15) / this.getRange();
|
||||
GuiUtils.drawTexturedModalRect(this.displayX, offset + this.displayY, 232, 0, this.width, 15,
|
||||
0 /* FIXME: this used the GUI's zIndex before */ );
|
||||
}
|
||||
}
|
||||
|
||||
private int getRange()
|
||||
{
|
||||
return this.maxScroll - this.minScroll;
|
||||
}
|
||||
private int getRange() {
|
||||
return this.maxScroll - this.minScroll;
|
||||
}
|
||||
|
||||
public int getLeft()
|
||||
{
|
||||
return this.displayX;
|
||||
}
|
||||
public int getLeft() {
|
||||
return this.displayX;
|
||||
}
|
||||
|
||||
public GuiScrollbar setLeft( final int v )
|
||||
{
|
||||
this.displayX = v;
|
||||
return this;
|
||||
}
|
||||
public GuiScrollbar setLeft(final int v) {
|
||||
this.displayX = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getTop()
|
||||
{
|
||||
return this.displayY;
|
||||
}
|
||||
public int getTop() {
|
||||
return this.displayY;
|
||||
}
|
||||
|
||||
public GuiScrollbar setTop( final int v )
|
||||
{
|
||||
this.displayY = v;
|
||||
return this;
|
||||
}
|
||||
public GuiScrollbar setTop(final int v) {
|
||||
this.displayY = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return this.width;
|
||||
}
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public GuiScrollbar setWidth( final int v )
|
||||
{
|
||||
this.width = v;
|
||||
return this;
|
||||
}
|
||||
public GuiScrollbar setWidth(final int v) {
|
||||
this.width = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
return this.height;
|
||||
}
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public GuiScrollbar setHeight( final int v )
|
||||
{
|
||||
this.height = v;
|
||||
return this;
|
||||
}
|
||||
public GuiScrollbar setHeight(final int v) {
|
||||
this.height = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setRange( final int min, final int max, final int pageSize )
|
||||
{
|
||||
this.minScroll = min;
|
||||
this.maxScroll = max;
|
||||
this.pageSize = pageSize;
|
||||
public void setRange(final int min, final int max, final int pageSize) {
|
||||
this.minScroll = min;
|
||||
this.maxScroll = max;
|
||||
this.pageSize = pageSize;
|
||||
|
||||
if( this.minScroll > this.maxScroll )
|
||||
{
|
||||
this.maxScroll = this.minScroll;
|
||||
}
|
||||
if (this.minScroll > this.maxScroll) {
|
||||
this.maxScroll = this.minScroll;
|
||||
}
|
||||
|
||||
this.applyRange();
|
||||
}
|
||||
this.applyRange();
|
||||
}
|
||||
|
||||
private void applyRange()
|
||||
{
|
||||
this.currentScroll = Math.max( Math.min( this.currentScroll, this.maxScroll ), this.minScroll );
|
||||
}
|
||||
private void applyRange() {
|
||||
this.currentScroll = Math.max(Math.min(this.currentScroll, this.maxScroll), this.minScroll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentScroll()
|
||||
{
|
||||
return this.currentScroll;
|
||||
}
|
||||
@Override
|
||||
public int getCurrentScroll() {
|
||||
return this.currentScroll;
|
||||
}
|
||||
|
||||
public void click(final double x, final double y)
|
||||
{
|
||||
if( this.getRange() == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
public void click(final double x, final double y) {
|
||||
if (this.getRange() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( x > this.displayX && x <= this.displayX + this.width )
|
||||
{
|
||||
if( y > this.displayY && y <= this.displayY + this.height )
|
||||
{
|
||||
this.currentScroll = (int) ( y - this.displayY );
|
||||
this.currentScroll = this.minScroll + ( ( this.currentScroll * 2 * this.getRange() / this.height ) );
|
||||
this.currentScroll = ( this.currentScroll + 1 ) >> 1;
|
||||
this.applyRange();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (x > this.displayX && x <= this.displayX + this.width) {
|
||||
if (y > this.displayY && y <= this.displayY + this.height) {
|
||||
this.currentScroll = (int) (y - this.displayY);
|
||||
this.currentScroll = this.minScroll + ((this.currentScroll * 2 * this.getRange() / this.height));
|
||||
this.currentScroll = (this.currentScroll + 1) >> 1;
|
||||
this.applyRange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void wheel( double delta )
|
||||
{
|
||||
delta = Math.max( Math.min( -delta, 1 ), -1 );
|
||||
this.currentScroll += delta * this.pageSize;
|
||||
this.applyRange();
|
||||
}
|
||||
public void wheel(double delta) {
|
||||
delta = Math.max(Math.min(-delta, 1), -1);
|
||||
this.currentScroll += delta * this.pageSize;
|
||||
this.applyRange();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,32 +18,30 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Convenience button that automatically sends settings changes to the server.
|
||||
*/
|
||||
public class GuiServerSettingToggleButton<T extends Enum<T>> extends GuiSettingToggleButton<T>
|
||||
{
|
||||
public class GuiServerSettingToggleButton<T extends Enum<T>> extends GuiSettingToggleButton<T> {
|
||||
|
||||
public GuiServerSettingToggleButton(final int x, final int y, final Settings setting, final T val )
|
||||
{
|
||||
super( x, y, setting, val, GuiServerSettingToggleButton::sendToServer );
|
||||
}
|
||||
public GuiServerSettingToggleButton(final int x, final int y, final Settings setting, final T val) {
|
||||
super(x, y, setting, val, GuiServerSettingToggleButton::sendToServer);
|
||||
}
|
||||
|
||||
private static <T extends Enum<T>> void sendToServer(GuiSettingToggleButton<T> button, boolean backwards) {
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( button.getSetting(), backwards ) );
|
||||
}
|
||||
private static <T extends Enum<T>> void sendToServer(GuiSettingToggleButton<T> button, boolean backwards) {
|
||||
NetworkHandler.instance().sendToServer(new PacketConfigButton(button.getSetting(), backwards));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,308 +18,328 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.util.EnumCycler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class GuiSettingToggleButton<T extends Enum<T>> extends GuiIconButton
|
||||
{
|
||||
private static final Pattern COMPILE = Pattern.compile( "%s" );
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL );
|
||||
private static Map<EnumPair, ButtonAppearance> appearances;
|
||||
private final Settings buttonSetting;
|
||||
private final IHandler<GuiSettingToggleButton<T>> onPress;
|
||||
private final EnumSet<T> validValues;
|
||||
private String fillVar;
|
||||
private T currentValue;
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.util.EnumCycler;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IHandler<T extends GuiSettingToggleButton<?>> {
|
||||
void handle(T button, boolean backwards);
|
||||
}
|
||||
public class GuiSettingToggleButton<T extends Enum<T>> extends GuiIconButton {
|
||||
private static final Pattern COMPILE = Pattern.compile("%s");
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
|
||||
private static Map<EnumPair, ButtonAppearance> appearances;
|
||||
private final Settings buttonSetting;
|
||||
private final IHandler<GuiSettingToggleButton<T>> onPress;
|
||||
private final EnumSet<T> validValues;
|
||||
private String fillVar;
|
||||
private T currentValue;
|
||||
|
||||
public GuiSettingToggleButton(final int x, final int y, final Settings setting, final T val, IHandler<GuiSettingToggleButton<T>> onPress )
|
||||
{
|
||||
this(x, y, setting, val, t -> true, onPress);
|
||||
}
|
||||
@FunctionalInterface
|
||||
public interface IHandler<T extends GuiSettingToggleButton<?>> {
|
||||
void handle(T button, boolean backwards);
|
||||
}
|
||||
|
||||
public GuiSettingToggleButton(final int x, final int y, final Settings setting, final T val, Predicate<T> isValidValue, IHandler<GuiSettingToggleButton<T>> onPress )
|
||||
{
|
||||
super( x, y, GuiSettingToggleButton::onPress );
|
||||
this.onPress = onPress;
|
||||
public GuiSettingToggleButton(final int x, final int y, final Settings setting, final T val,
|
||||
IHandler<GuiSettingToggleButton<T>> onPress) {
|
||||
this(x, y, setting, val, t -> true, onPress);
|
||||
}
|
||||
|
||||
// Build a list of values (in order) that are valid w.r.t. the given predicate
|
||||
EnumSet<T> validValues = EnumSet.allOf(val.getDeclaringClass());
|
||||
validValues.removeIf(isValidValue.negate());
|
||||
validValues.removeIf(s -> !setting.getPossibleValues().contains(s));
|
||||
this.validValues = validValues;
|
||||
public GuiSettingToggleButton(final int x, final int y, final Settings setting, final T val,
|
||||
Predicate<T> isValidValue, IHandler<GuiSettingToggleButton<T>> onPress) {
|
||||
super(x, y, GuiSettingToggleButton::onPress);
|
||||
this.onPress = onPress;
|
||||
|
||||
this.buttonSetting = setting;
|
||||
this.currentValue = val;
|
||||
// Build a list of values (in order) that are valid w.r.t. the given predicate
|
||||
EnumSet<T> validValues = EnumSet.allOf(val.getDeclaringClass());
|
||||
validValues.removeIf(isValidValue.negate());
|
||||
validValues.removeIf(s -> !setting.getPossibleValues().contains(s));
|
||||
this.validValues = validValues;
|
||||
|
||||
if( appearances == null )
|
||||
{
|
||||
appearances = new HashMap<>();
|
||||
registerApp( 16 * 7, Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH, ButtonToolTips.CondenserOutput, ButtonToolTips.Trash );
|
||||
registerApp( 16 * 7 + 1, Settings.CONDENSER_OUTPUT, CondenserOutput.MATTER_BALLS, ButtonToolTips.CondenserOutput, ButtonToolTips.MatterBalls );
|
||||
registerApp( 16 * 7 + 2, Settings.CONDENSER_OUTPUT, CondenserOutput.SINGULARITY, ButtonToolTips.CondenserOutput, ButtonToolTips.Singularity );
|
||||
this.buttonSetting = setting;
|
||||
this.currentValue = val;
|
||||
|
||||
registerApp( 16 * 9 + 1, Settings.ACCESS, AccessRestriction.READ, ButtonToolTips.IOMode, ButtonToolTips.Read );
|
||||
registerApp( 16 * 9, Settings.ACCESS, AccessRestriction.WRITE, ButtonToolTips.IOMode, ButtonToolTips.Write );
|
||||
registerApp( 16 * 9 + 2, Settings.ACCESS, AccessRestriction.READ_WRITE, ButtonToolTips.IOMode, ButtonToolTips.ReadWrite );
|
||||
if (appearances == null) {
|
||||
appearances = new HashMap<>();
|
||||
registerApp(16 * 7, Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH, ButtonToolTips.CondenserOutput,
|
||||
ButtonToolTips.Trash);
|
||||
registerApp(16 * 7 + 1, Settings.CONDENSER_OUTPUT, CondenserOutput.MATTER_BALLS,
|
||||
ButtonToolTips.CondenserOutput, ButtonToolTips.MatterBalls);
|
||||
registerApp(16 * 7 + 2, Settings.CONDENSER_OUTPUT, CondenserOutput.SINGULARITY,
|
||||
ButtonToolTips.CondenserOutput, ButtonToolTips.Singularity);
|
||||
|
||||
registerApp( 16 * 10, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.textComponent() );
|
||||
registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.textComponent() );
|
||||
registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.textComponent() );
|
||||
registerApp(16 * 9 + 1, Settings.ACCESS, AccessRestriction.READ, ButtonToolTips.IOMode,
|
||||
ButtonToolTips.Read);
|
||||
registerApp(16 * 9, Settings.ACCESS, AccessRestriction.WRITE, ButtonToolTips.IOMode, ButtonToolTips.Write);
|
||||
registerApp(16 * 9 + 2, Settings.ACCESS, AccessRestriction.READ_WRITE, ButtonToolTips.IOMode,
|
||||
ButtonToolTips.ReadWrite);
|
||||
|
||||
registerApp( 3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode, ButtonToolTips.AlwaysActive );
|
||||
registerApp( 0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithoutSignal );
|
||||
registerApp( 1, Settings.REDSTONE_CONTROLLED, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithSignal );
|
||||
registerApp( 2, Settings.REDSTONE_CONTROLLED, RedstoneMode.SIGNAL_PULSE, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveOnPulse );
|
||||
registerApp(16 * 10, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits,
|
||||
PowerUnits.AE.textComponent());
|
||||
registerApp(16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits,
|
||||
PowerUnits.EU.textComponent());
|
||||
registerApp(16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits,
|
||||
PowerUnits.RF.textComponent());
|
||||
|
||||
registerApp( 0, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelsBelow );
|
||||
registerApp( 1, Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelAbove );
|
||||
registerApp(3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode,
|
||||
ButtonToolTips.AlwaysActive);
|
||||
registerApp(0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode,
|
||||
ButtonToolTips.ActiveWithoutSignal);
|
||||
registerApp(1, Settings.REDSTONE_CONTROLLED, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode,
|
||||
ButtonToolTips.ActiveWithSignal);
|
||||
registerApp(2, Settings.REDSTONE_CONTROLLED, RedstoneMode.SIGNAL_PULSE, ButtonToolTips.RedstoneMode,
|
||||
ButtonToolTips.ActiveOnPulse);
|
||||
|
||||
registerApp( 51, Settings.OPERATION_MODE, OperationMode.FILL, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell );
|
||||
registerApp( 50, Settings.OPERATION_MODE, OperationMode.EMPTY, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork );
|
||||
registerApp(0, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode,
|
||||
ButtonToolTips.EmitLevelsBelow);
|
||||
registerApp(1, Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode,
|
||||
ButtonToolTips.EmitLevelAbove);
|
||||
|
||||
registerApp( 51, Settings.IO_DIRECTION, RelativeDirection.LEFT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell );
|
||||
registerApp( 50, Settings.IO_DIRECTION, RelativeDirection.RIGHT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork );
|
||||
registerApp(51, Settings.OPERATION_MODE, OperationMode.FILL, ButtonToolTips.TransferDirection,
|
||||
ButtonToolTips.TransferToStorageCell);
|
||||
registerApp(50, Settings.OPERATION_MODE, OperationMode.EMPTY, ButtonToolTips.TransferDirection,
|
||||
ButtonToolTips.TransferToNetwork);
|
||||
|
||||
registerApp( 48, Settings.SORT_DIRECTION, SortDir.ASCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection );
|
||||
registerApp( 49, Settings.SORT_DIRECTION, SortDir.DESCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection );
|
||||
registerApp(51, Settings.IO_DIRECTION, RelativeDirection.LEFT, ButtonToolTips.TransferDirection,
|
||||
ButtonToolTips.TransferToStorageCell);
|
||||
registerApp(50, Settings.IO_DIRECTION, RelativeDirection.RIGHT, ButtonToolTips.TransferDirection,
|
||||
ButtonToolTips.TransferToNetwork);
|
||||
|
||||
registerApp( 16 * 2 + 3, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Auto );
|
||||
registerApp( 16 * 2 + 4, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Standard );
|
||||
registerApp( 16 * 2 + 5, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIAuto );
|
||||
registerApp( 16 * 2 + 6, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_JEIStandard );
|
||||
registerApp( 16 * 2 + 7, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH_KEEP, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_AutoKeep );
|
||||
registerApp( 16 * 2 + 8, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_StandardKeep );
|
||||
registerApp( 16 * 2 + 9, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH_KEEP, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_JEIAutoKeep );
|
||||
registerApp( 16 * 2 + 10, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_JEIStandardKeep );
|
||||
registerApp(48, Settings.SORT_DIRECTION, SortDir.ASCENDING, ButtonToolTips.SortOrder,
|
||||
ButtonToolTips.ToggleSortDirection);
|
||||
registerApp(49, Settings.SORT_DIRECTION, SortDir.DESCENDING, ButtonToolTips.SortOrder,
|
||||
ButtonToolTips.ToggleSortDirection);
|
||||
|
||||
registerApp( 16 * 5 + 3, Settings.LEVEL_TYPE, LevelType.ENERGY_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Energy );
|
||||
registerApp( 16 * 4 + 3, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Item );
|
||||
registerApp(16 * 2 + 3, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_Auto);
|
||||
registerApp(16 * 2 + 4, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_Standard);
|
||||
registerApp(16 * 2 + 5, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_JEIAuto);
|
||||
registerApp(16 * 2 + 6, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_JEIStandard);
|
||||
registerApp(16 * 2 + 7, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH_KEEP, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_AutoKeep);
|
||||
registerApp(16 * 2 + 8, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_StandardKeep);
|
||||
registerApp(16 * 2 + 9, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH_KEEP, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_JEIAutoKeep);
|
||||
registerApp(16 * 2 + 10, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH_KEEP,
|
||||
ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIStandardKeep);
|
||||
|
||||
registerApp( 16 * 13, Settings.TERMINAL_STYLE, TerminalStyle.TALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Tall );
|
||||
registerApp( 16 * 13 + 1, Settings.TERMINAL_STYLE, TerminalStyle.SMALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Small );
|
||||
registerApp( 16 * 13 + 2, Settings.TERMINAL_STYLE, TerminalStyle.FULL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Full );
|
||||
registerApp(16 * 5 + 3, Settings.LEVEL_TYPE, LevelType.ENERGY_LEVEL, ButtonToolTips.LevelType,
|
||||
ButtonToolTips.LevelType_Energy);
|
||||
registerApp(16 * 4 + 3, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, ButtonToolTips.LevelType,
|
||||
ButtonToolTips.LevelType_Item);
|
||||
|
||||
registerApp( 64, Settings.SORT_BY, SortOrder.NAME, ButtonToolTips.SortBy, ButtonToolTips.ItemName );
|
||||
registerApp( 65, Settings.SORT_BY, SortOrder.AMOUNT, ButtonToolTips.SortBy, ButtonToolTips.NumberOfItems );
|
||||
registerApp( 68, Settings.SORT_BY, SortOrder.INVTWEAKS, ButtonToolTips.SortBy, ButtonToolTips.InventoryTweaks );
|
||||
registerApp( 69, Settings.SORT_BY, SortOrder.MOD, ButtonToolTips.SortBy, ButtonToolTips.Mod );
|
||||
registerApp(16 * 13, Settings.TERMINAL_STYLE, TerminalStyle.TALL, ButtonToolTips.TerminalStyle,
|
||||
ButtonToolTips.TerminalStyle_Tall);
|
||||
registerApp(16 * 13 + 1, Settings.TERMINAL_STYLE, TerminalStyle.SMALL, ButtonToolTips.TerminalStyle,
|
||||
ButtonToolTips.TerminalStyle_Small);
|
||||
registerApp(16 * 13 + 2, Settings.TERMINAL_STYLE, TerminalStyle.FULL, ButtonToolTips.TerminalStyle,
|
||||
ButtonToolTips.TerminalStyle_Full);
|
||||
|
||||
registerApp( 16, Settings.VIEW_MODE, ViewItems.STORED, ButtonToolTips.View, ButtonToolTips.StoredItems );
|
||||
registerApp( 18, Settings.VIEW_MODE, ViewItems.ALL, ButtonToolTips.View, ButtonToolTips.StoredCraftable );
|
||||
registerApp( 19, Settings.VIEW_MODE, ViewItems.CRAFTABLE, ButtonToolTips.View, ButtonToolTips.Craftable );
|
||||
registerApp(64, Settings.SORT_BY, SortOrder.NAME, ButtonToolTips.SortBy, ButtonToolTips.ItemName);
|
||||
registerApp(65, Settings.SORT_BY, SortOrder.AMOUNT, ButtonToolTips.SortBy, ButtonToolTips.NumberOfItems);
|
||||
registerApp(68, Settings.SORT_BY, SortOrder.INVTWEAKS, ButtonToolTips.SortBy,
|
||||
ButtonToolTips.InventoryTweaks);
|
||||
registerApp(69, Settings.SORT_BY, SortOrder.MOD, ButtonToolTips.SortBy, ButtonToolTips.Mod);
|
||||
|
||||
registerApp( 16 * 6, Settings.FUZZY_MODE, FuzzyMode.PERCENT_25, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_25 );
|
||||
registerApp( 16 * 6 + 1, Settings.FUZZY_MODE, FuzzyMode.PERCENT_50, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_50 );
|
||||
registerApp( 16 * 6 + 2, Settings.FUZZY_MODE, FuzzyMode.PERCENT_75, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_75 );
|
||||
registerApp( 16 * 6 + 3, Settings.FUZZY_MODE, FuzzyMode.PERCENT_99, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_99 );
|
||||
registerApp( 16 * 6 + 4, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, ButtonToolTips.FuzzyMode, ButtonToolTips.FZIgnoreAll );
|
||||
registerApp(16, Settings.VIEW_MODE, ViewItems.STORED, ButtonToolTips.View, ButtonToolTips.StoredItems);
|
||||
registerApp(18, Settings.VIEW_MODE, ViewItems.ALL, ButtonToolTips.View, ButtonToolTips.StoredCraftable);
|
||||
registerApp(19, Settings.VIEW_MODE, ViewItems.CRAFTABLE, ButtonToolTips.View, ButtonToolTips.Craftable);
|
||||
|
||||
registerApp( 80, Settings.FULLNESS_MODE, FullnessMode.EMPTY, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenEmpty );
|
||||
registerApp( 81, Settings.FULLNESS_MODE, FullnessMode.HALF, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenWorkIsDone );
|
||||
registerApp( 82, Settings.FULLNESS_MODE, FullnessMode.FULL, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenFull );
|
||||
registerApp(16 * 6, Settings.FUZZY_MODE, FuzzyMode.PERCENT_25, ButtonToolTips.FuzzyMode,
|
||||
ButtonToolTips.FZPercent_25);
|
||||
registerApp(16 * 6 + 1, Settings.FUZZY_MODE, FuzzyMode.PERCENT_50, ButtonToolTips.FuzzyMode,
|
||||
ButtonToolTips.FZPercent_50);
|
||||
registerApp(16 * 6 + 2, Settings.FUZZY_MODE, FuzzyMode.PERCENT_75, ButtonToolTips.FuzzyMode,
|
||||
ButtonToolTips.FZPercent_75);
|
||||
registerApp(16 * 6 + 3, Settings.FUZZY_MODE, FuzzyMode.PERCENT_99, ButtonToolTips.FuzzyMode,
|
||||
ButtonToolTips.FZPercent_99);
|
||||
registerApp(16 * 6 + 4, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, ButtonToolTips.FuzzyMode,
|
||||
ButtonToolTips.FZIgnoreAll);
|
||||
|
||||
registerApp( 16 + 5, Settings.BLOCK, YesNo.YES, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.Blocking );
|
||||
registerApp( 16 + 4, Settings.BLOCK, YesNo.NO, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.NonBlocking );
|
||||
registerApp(80, Settings.FULLNESS_MODE, FullnessMode.EMPTY, ButtonToolTips.OperationMode,
|
||||
ButtonToolTips.MoveWhenEmpty);
|
||||
registerApp(81, Settings.FULLNESS_MODE, FullnessMode.HALF, ButtonToolTips.OperationMode,
|
||||
ButtonToolTips.MoveWhenWorkIsDone);
|
||||
registerApp(82, Settings.FULLNESS_MODE, FullnessMode.FULL, ButtonToolTips.OperationMode,
|
||||
ButtonToolTips.MoveWhenFull);
|
||||
|
||||
registerApp( 16 + 3, Settings.CRAFT_ONLY, YesNo.YES, ButtonToolTips.Craft, ButtonToolTips.CraftOnly );
|
||||
registerApp( 16 + 2, Settings.CRAFT_ONLY, YesNo.NO, ButtonToolTips.Craft, ButtonToolTips.CraftEither );
|
||||
registerApp(16 + 5, Settings.BLOCK, YesNo.YES, ButtonToolTips.InterfaceBlockingMode,
|
||||
ButtonToolTips.Blocking);
|
||||
registerApp(16 + 4, Settings.BLOCK, YesNo.NO, ButtonToolTips.InterfaceBlockingMode,
|
||||
ButtonToolTips.NonBlocking);
|
||||
|
||||
registerApp( 16 * 11 + 2, Settings.CRAFT_VIA_REDSTONE, YesNo.YES, ButtonToolTips.EmitterMode, ButtonToolTips.CraftViaRedstone );
|
||||
registerApp( 16 * 11 + 1, Settings.CRAFT_VIA_REDSTONE, YesNo.NO, ButtonToolTips.EmitterMode, ButtonToolTips.EmitWhenCrafting );
|
||||
registerApp(16 + 3, Settings.CRAFT_ONLY, YesNo.YES, ButtonToolTips.Craft, ButtonToolTips.CraftOnly);
|
||||
registerApp(16 + 2, Settings.CRAFT_ONLY, YesNo.NO, ButtonToolTips.Craft, ButtonToolTips.CraftEither);
|
||||
|
||||
registerApp( 16 * 3 + 5, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY, ButtonToolTips.ReportInaccessibleItems,
|
||||
ButtonToolTips.ReportInaccessibleItemsNo );
|
||||
registerApp( 16 * 3 + 6, Settings.STORAGE_FILTER, StorageFilter.NONE, ButtonToolTips.ReportInaccessibleItems,
|
||||
ButtonToolTips.ReportInaccessibleItemsYes );
|
||||
registerApp(16 * 11 + 2, Settings.CRAFT_VIA_REDSTONE, YesNo.YES, ButtonToolTips.EmitterMode,
|
||||
ButtonToolTips.CraftViaRedstone);
|
||||
registerApp(16 * 11 + 1, Settings.CRAFT_VIA_REDSTONE, YesNo.NO, ButtonToolTips.EmitterMode,
|
||||
ButtonToolTips.EmitWhenCrafting);
|
||||
|
||||
registerApp( 16 * 14, Settings.PLACE_BLOCK, YesNo.YES, ButtonToolTips.BlockPlacement, ButtonToolTips.BlockPlacementYes );
|
||||
registerApp( 16 * 14 + 1, Settings.PLACE_BLOCK, YesNo.NO, ButtonToolTips.BlockPlacement, ButtonToolTips.BlockPlacementNo );
|
||||
registerApp(16 * 3 + 5, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY,
|
||||
ButtonToolTips.ReportInaccessibleItems, ButtonToolTips.ReportInaccessibleItemsNo);
|
||||
registerApp(16 * 3 + 6, Settings.STORAGE_FILTER, StorageFilter.NONE, ButtonToolTips.ReportInaccessibleItems,
|
||||
ButtonToolTips.ReportInaccessibleItemsYes);
|
||||
|
||||
registerApp( 16 * 15, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeDefault );
|
||||
registerApp( 16 * 15 + 1, Settings.SCHEDULING_MODE, SchedulingMode.ROUNDROBIN, ButtonToolTips.SchedulingMode,
|
||||
ButtonToolTips.SchedulingModeRoundRobin );
|
||||
registerApp( 16 * 15 + 2, Settings.SCHEDULING_MODE, SchedulingMode.RANDOM, ButtonToolTips.SchedulingMode,
|
||||
ButtonToolTips.SchedulingModeRandom );
|
||||
}
|
||||
}
|
||||
registerApp(16 * 14, Settings.PLACE_BLOCK, YesNo.YES, ButtonToolTips.BlockPlacement,
|
||||
ButtonToolTips.BlockPlacementYes);
|
||||
registerApp(16 * 14 + 1, Settings.PLACE_BLOCK, YesNo.NO, ButtonToolTips.BlockPlacement,
|
||||
ButtonToolTips.BlockPlacementNo);
|
||||
|
||||
private static void onPress(Button btn) {
|
||||
if (btn instanceof GuiSettingToggleButton) {
|
||||
((GuiSettingToggleButton<?>) btn).triggerPress();
|
||||
}
|
||||
}
|
||||
registerApp(16 * 15, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT, ButtonToolTips.SchedulingMode,
|
||||
ButtonToolTips.SchedulingModeDefault);
|
||||
registerApp(16 * 15 + 1, Settings.SCHEDULING_MODE, SchedulingMode.ROUNDROBIN, ButtonToolTips.SchedulingMode,
|
||||
ButtonToolTips.SchedulingModeRoundRobin);
|
||||
registerApp(16 * 15 + 2, Settings.SCHEDULING_MODE, SchedulingMode.RANDOM, ButtonToolTips.SchedulingMode,
|
||||
ButtonToolTips.SchedulingModeRandom);
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerPress() {
|
||||
boolean backwards = Minecraft.getInstance().mouseHelper.isRightDown();
|
||||
onPress.handle(this, backwards);
|
||||
}
|
||||
private static void onPress(Button btn) {
|
||||
if (btn instanceof GuiSettingToggleButton) {
|
||||
((GuiSettingToggleButton<?>) btn).triggerPress();
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerApp( final int iconIndex, final Settings setting, final Enum<?> val, final ButtonToolTips title, final ITextComponent hint )
|
||||
{
|
||||
final ButtonAppearance a = new ButtonAppearance();
|
||||
a.displayName = title.getTranslationKey();
|
||||
a.displayValue = hint;
|
||||
a.index = iconIndex;
|
||||
appearances.put( new EnumPair( setting, val ), a );
|
||||
}
|
||||
private void triggerPress() {
|
||||
boolean backwards = Minecraft.getInstance().mouseHelper.isRightDown();
|
||||
onPress.handle(this, backwards);
|
||||
}
|
||||
|
||||
private static void registerApp( final int iconIndex, final Settings setting, final Enum<?> val, final ButtonToolTips title, final ButtonToolTips hint )
|
||||
{
|
||||
registerApp(iconIndex, setting, val, title, hint.getTranslationKey());
|
||||
}
|
||||
private static void registerApp(final int iconIndex, final Settings setting, final Enum<?> val,
|
||||
final ButtonToolTips title, final ITextComponent hint) {
|
||||
final ButtonAppearance a = new ButtonAppearance();
|
||||
a.displayName = title.getTranslationKey();
|
||||
a.displayValue = hint;
|
||||
a.index = iconIndex;
|
||||
appearances.put(new EnumPair(setting, val), a);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIconIndex()
|
||||
{
|
||||
if( this.buttonSetting != null && this.currentValue != null )
|
||||
{
|
||||
final ButtonAppearance app = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) );
|
||||
if( app == null )
|
||||
{
|
||||
return 256 - 1;
|
||||
}
|
||||
return app.index;
|
||||
}
|
||||
return 256 - 1;
|
||||
}
|
||||
private static void registerApp(final int iconIndex, final Settings setting, final Enum<?> val,
|
||||
final ButtonToolTips title, final ButtonToolTips hint) {
|
||||
registerApp(iconIndex, setting, val, title, hint.getTranslationKey());
|
||||
}
|
||||
|
||||
public Settings getSetting()
|
||||
{
|
||||
return this.buttonSetting;
|
||||
}
|
||||
@Override
|
||||
protected int getIconIndex() {
|
||||
if (this.buttonSetting != null && this.currentValue != null) {
|
||||
final ButtonAppearance app = appearances.get(new EnumPair(this.buttonSetting, this.currentValue));
|
||||
if (app == null) {
|
||||
return 256 - 1;
|
||||
}
|
||||
return app.index;
|
||||
}
|
||||
return 256 - 1;
|
||||
}
|
||||
|
||||
public T getCurrentValue()
|
||||
{
|
||||
return this.currentValue;
|
||||
}
|
||||
public Settings getSetting() {
|
||||
return this.buttonSetting;
|
||||
}
|
||||
|
||||
public void set( final T e )
|
||||
{
|
||||
if( this.currentValue != e )
|
||||
{
|
||||
this.currentValue = e;
|
||||
}
|
||||
}
|
||||
public T getCurrentValue() {
|
||||
return this.currentValue;
|
||||
}
|
||||
|
||||
public T getNextValue(boolean backwards) {
|
||||
return EnumCycler.rotateEnum(currentValue, backwards, validValues);
|
||||
}
|
||||
public void set(final T e) {
|
||||
if (this.currentValue != e) {
|
||||
this.currentValue = e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
ITextComponent displayName = null;
|
||||
ITextComponent displayValue = null;
|
||||
public T getNextValue(boolean backwards) {
|
||||
return EnumCycler.rotateEnum(currentValue, backwards, validValues);
|
||||
}
|
||||
|
||||
if( this.buttonSetting != null && this.currentValue != null )
|
||||
{
|
||||
final ButtonAppearance buttonAppearance = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) );
|
||||
if( buttonAppearance == null )
|
||||
{
|
||||
return "No Such Message";
|
||||
}
|
||||
@Override
|
||||
public String getMessage() {
|
||||
ITextComponent displayName = null;
|
||||
ITextComponent displayValue = null;
|
||||
|
||||
displayName = buttonAppearance.displayName;
|
||||
displayValue = buttonAppearance.displayValue;
|
||||
}
|
||||
if (this.buttonSetting != null && this.currentValue != null) {
|
||||
final ButtonAppearance buttonAppearance = appearances
|
||||
.get(new EnumPair(this.buttonSetting, this.currentValue));
|
||||
if (buttonAppearance == null) {
|
||||
return "No Such Message";
|
||||
}
|
||||
|
||||
if( displayName != null )
|
||||
{
|
||||
String name = displayName.getString();
|
||||
String value = displayValue.getString();
|
||||
displayName = buttonAppearance.displayName;
|
||||
displayValue = buttonAppearance.displayValue;
|
||||
}
|
||||
|
||||
if( this.fillVar != null )
|
||||
{
|
||||
value = COMPILE.matcher( value ).replaceFirst( this.fillVar );
|
||||
}
|
||||
if (displayName != null) {
|
||||
String name = displayName.getString();
|
||||
String value = displayValue.getString();
|
||||
|
||||
value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" );
|
||||
final StringBuilder sb = new StringBuilder( value );
|
||||
if (this.fillVar != null) {
|
||||
value = COMPILE.matcher(value).replaceFirst(this.fillVar);
|
||||
}
|
||||
|
||||
int i = sb.lastIndexOf( "\n" );
|
||||
if( i <= 0 )
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
|
||||
{
|
||||
sb.replace( i, i + 1, "\n" );
|
||||
}
|
||||
value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n");
|
||||
final StringBuilder sb = new StringBuilder(value);
|
||||
|
||||
return name + '\n' + sb;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
int i = sb.lastIndexOf("\n");
|
||||
if (i <= 0) {
|
||||
i = 0;
|
||||
}
|
||||
while (i + 30 < sb.length() && (i = sb.lastIndexOf(" ", i + 30)) != -1) {
|
||||
sb.replace(i, i + 1, "\n");
|
||||
}
|
||||
|
||||
public String getFillVar()
|
||||
{
|
||||
return this.fillVar;
|
||||
}
|
||||
return name + '\n' + sb;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setFillVar( final String fillVar )
|
||||
{
|
||||
this.fillVar = fillVar;
|
||||
}
|
||||
public String getFillVar() {
|
||||
return this.fillVar;
|
||||
}
|
||||
|
||||
private static final class EnumPair
|
||||
{
|
||||
public void setFillVar(final String fillVar) {
|
||||
this.fillVar = fillVar;
|
||||
}
|
||||
|
||||
final Settings setting;
|
||||
final Enum<?> value;
|
||||
private static final class EnumPair {
|
||||
|
||||
EnumPair( final Settings a, final Enum<?> b )
|
||||
{
|
||||
this.setting = a;
|
||||
this.value = b;
|
||||
}
|
||||
final Settings setting;
|
||||
final Enum<?> value;
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return this.setting.hashCode() ^ this.value.hashCode();
|
||||
}
|
||||
EnumPair(final Settings a, final Enum<?> b) {
|
||||
this.setting = a;
|
||||
this.value = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( final Object obj )
|
||||
{
|
||||
if( obj == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( this.getClass() != obj.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final EnumPair other = (EnumPair) obj;
|
||||
return other.setting == this.setting && other.value == this.value;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.setting.hashCode() ^ this.value.hashCode();
|
||||
}
|
||||
|
||||
private static class ButtonAppearance
|
||||
{
|
||||
public int index;
|
||||
public ITextComponent displayName;
|
||||
public ITextComponent displayValue;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final EnumPair other = (EnumPair) obj;
|
||||
return other.setting == this.setting && other.value == this.value;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ButtonAppearance {
|
||||
public int index;
|
||||
public ITextComponent displayName;
|
||||
public ITextComponent displayValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
@@ -30,117 +30,105 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiTabButton extends Button implements ITooltip {
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2",
|
||||
"textures/guis/states.png");
|
||||
private final ItemRenderer itemRenderer;
|
||||
private int hideEdge = 0;
|
||||
private int myIcon = -1;
|
||||
private ItemStack myItem;
|
||||
|
||||
public class GuiTabButton extends Button implements ITooltip
|
||||
{
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png");
|
||||
private final ItemRenderer itemRenderer;
|
||||
private int hideEdge = 0;
|
||||
private int myIcon = -1;
|
||||
private ItemStack myItem;
|
||||
public GuiTabButton(final int x, final int y, final int ico, final String message, final ItemRenderer ir,
|
||||
IPressable onPress) {
|
||||
super(x, y, 22, 22, message, onPress);
|
||||
|
||||
public GuiTabButton( final int x, final int y, final int ico, final String message, final ItemRenderer ir, IPressable onPress )
|
||||
{
|
||||
super( x, y, 22, 22, message, onPress );
|
||||
this.myIcon = ico;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
this.myIcon = ico;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
/**
|
||||
* Using itemstack as an icon
|
||||
*
|
||||
* @param x x pos of button
|
||||
* @param y y pos of button
|
||||
* @param ico used icon
|
||||
* @param message mouse over message
|
||||
* @param ir renderer
|
||||
*/
|
||||
public GuiTabButton(final int x, final int y, final ItemStack ico, final String message, final ItemRenderer ir,
|
||||
IPressable onPress) {
|
||||
super(x, y, 22, 22, message, onPress);
|
||||
this.myItem = ico;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Using itemstack as an icon
|
||||
*
|
||||
* @param x x pos of button
|
||||
* @param y y pos of button
|
||||
* @param ico used icon
|
||||
* @param message mouse over message
|
||||
* @param ir renderer
|
||||
*/
|
||||
public GuiTabButton( final int x, final int y, final ItemStack ico, final String message, final ItemRenderer ir, IPressable onPress )
|
||||
{
|
||||
super( x, y, 22, 22, message, onPress );
|
||||
this.myItem = ico;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
@Override
|
||||
public void renderButton(final int x, final int y, float partial) {
|
||||
final Minecraft minecraft = Minecraft.getInstance();
|
||||
|
||||
@Override
|
||||
public void renderButton( final int x, final int y, float partial )
|
||||
{
|
||||
final Minecraft minecraft = Minecraft.getInstance();
|
||||
if (this.visible) {
|
||||
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
minecraft.textureManager.bindTexture(TEXTURE_STATES);
|
||||
|
||||
if( this.visible )
|
||||
{
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
minecraft.textureManager.bindTexture(TEXTURE_STATES);
|
||||
RenderSystem.enableAlphaTest();
|
||||
|
||||
RenderSystem.enableAlphaTest();
|
||||
int uv_x = (this.hideEdge > 0 ? 11 : 13);
|
||||
|
||||
int uv_x = ( this.hideEdge > 0 ? 11 : 13 );
|
||||
final int offsetX = this.hideEdge > 0 ? 1 : 0;
|
||||
|
||||
final int offsetX = this.hideEdge > 0 ? 1 : 0;
|
||||
blit(this.x, this.y, uv_x * 16, 0, 25, 22);
|
||||
|
||||
blit( this.x, this.y, uv_x * 16, 0, 25, 22 );
|
||||
if (this.myIcon >= 0) {
|
||||
final int uv_y = this.myIcon / 16;
|
||||
uv_x = this.myIcon - uv_y * 16;
|
||||
|
||||
if( this.myIcon >= 0 )
|
||||
{
|
||||
final int uv_y = this.myIcon / 16;
|
||||
uv_x = this.myIcon - uv_y * 16;
|
||||
blit(offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16);
|
||||
}
|
||||
|
||||
blit( offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
}
|
||||
RenderSystem.disableAlphaTest();
|
||||
|
||||
RenderSystem.disableAlphaTest();
|
||||
if (this.myItem != null) {
|
||||
this.itemRenderer.zLevel = 100.0F;
|
||||
|
||||
if( this.myItem != null )
|
||||
{
|
||||
this.itemRenderer.zLevel = 100.0F;
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
this.itemRenderer.renderItemAndEffectIntoGUI(this.myItem, offsetX + this.x + 3, this.y + 3);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
this.itemRenderer.renderItemAndEffectIntoGUI( this.myItem, offsetX + this.x + 3, this.y + 3 );
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
this.itemRenderer.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.itemRenderer.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return this.visible;
|
||||
}
|
||||
public int getHideEdge() {
|
||||
return this.hideEdge;
|
||||
}
|
||||
|
||||
public int getHideEdge()
|
||||
{
|
||||
return this.hideEdge;
|
||||
}
|
||||
|
||||
public void setHideEdge( final int hideEdge )
|
||||
{
|
||||
this.hideEdge = hideEdge;
|
||||
}
|
||||
public void setHideEdge(final int hideEdge) {
|
||||
this.hideEdge = hideEdge;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,128 +18,112 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiToggleButton extends Button implements ITooltip {
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2",
|
||||
"textures/guis/states.png");
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
|
||||
private final int iconIdxOn;
|
||||
private final int iconIdxOff;
|
||||
|
||||
public class GuiToggleButton extends Button implements ITooltip
|
||||
{
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png");
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL );
|
||||
private final int iconIdxOn;
|
||||
private final int iconIdxOff;
|
||||
private final String displayName;
|
||||
private final String displayHint;
|
||||
|
||||
private final String displayName;
|
||||
private final String displayHint;
|
||||
private boolean isActive;
|
||||
|
||||
private boolean isActive;
|
||||
public GuiToggleButton(final int x, final int y, final int on, final int off, final String displayName,
|
||||
final String displayHint, IPressable onPress) {
|
||||
super(x, y, 16, 16, "", onPress);
|
||||
this.iconIdxOn = on;
|
||||
this.iconIdxOff = off;
|
||||
this.displayName = displayName;
|
||||
this.displayHint = displayHint;
|
||||
}
|
||||
|
||||
public GuiToggleButton( final int x, final int y, final int on, final int off, final String displayName, final String displayHint, IPressable onPress )
|
||||
{
|
||||
super( x, y, 16, 16, "", onPress );
|
||||
this.iconIdxOn = on;
|
||||
this.iconIdxOff = off;
|
||||
this.displayName = displayName;
|
||||
this.displayHint = displayHint;
|
||||
}
|
||||
public void setState(final boolean isOn) {
|
||||
this.isActive = isOn;
|
||||
}
|
||||
|
||||
public void setState( final boolean isOn )
|
||||
{
|
||||
this.isActive = isOn;
|
||||
}
|
||||
@Override
|
||||
public void renderButton(final int mouseX, final int mouseY, final float partial) {
|
||||
if (this.visible) {
|
||||
final int iconIndex = this.getIconIndex();
|
||||
|
||||
@Override
|
||||
public void renderButton( final int mouseX, final int mouseY, final float partial )
|
||||
{
|
||||
if( this.visible )
|
||||
{
|
||||
final int iconIndex = this.getIconIndex();
|
||||
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
Minecraft.getInstance().textureManager.bindTexture(TEXTURE_STATES);
|
||||
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
Minecraft.getInstance().textureManager.bindTexture( TEXTURE_STATES );
|
||||
final int uv_y = iconIndex / 16;
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
final int uv_y = iconIndex / 16;
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
GuiUtils.drawTexturedModalRect(this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0);
|
||||
GuiUtils.drawTexturedModalRect(this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0);
|
||||
}
|
||||
}
|
||||
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0 );
|
||||
}
|
||||
}
|
||||
private int getIconIndex() {
|
||||
return this.isActive ? this.iconIdxOn : this.iconIdxOff;
|
||||
}
|
||||
|
||||
private int getIconIndex()
|
||||
{
|
||||
return this.isActive ? this.iconIdxOn : this.iconIdxOff;
|
||||
}
|
||||
@Override
|
||||
public String getMessage() {
|
||||
if (this.displayName != null) {
|
||||
String name = I18n.format(this.displayName);
|
||||
String value = I18n.format(this.displayHint);
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
if( this.displayName != null )
|
||||
{
|
||||
String name = I18n.format( this.displayName );
|
||||
String value = I18n.format( this.displayHint );
|
||||
if (name == null || name.isEmpty()) {
|
||||
name = this.displayName;
|
||||
}
|
||||
if (value == null || value.isEmpty()) {
|
||||
value = this.displayHint;
|
||||
}
|
||||
|
||||
if( name == null || name.isEmpty() )
|
||||
{
|
||||
name = this.displayName;
|
||||
}
|
||||
if( value == null || value.isEmpty() )
|
||||
{
|
||||
value = this.displayHint;
|
||||
}
|
||||
value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n");
|
||||
final StringBuilder sb = new StringBuilder(value);
|
||||
|
||||
value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" );
|
||||
final StringBuilder sb = new StringBuilder( value );
|
||||
int i = sb.lastIndexOf("\n");
|
||||
if (i <= 0) {
|
||||
i = 0;
|
||||
}
|
||||
while (i + 30 < sb.length() && (i = sb.lastIndexOf(" ", i + 30)) != -1) {
|
||||
sb.replace(i, i + 1, "\n");
|
||||
}
|
||||
|
||||
int i = sb.lastIndexOf( "\n" );
|
||||
if( i <= 0 )
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
|
||||
{
|
||||
sb.replace( i, i + 1, "\n" );
|
||||
}
|
||||
return name + '\n' + sb;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return name + '\n' + sb;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return this.visible;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
public interface IScrollSource {
|
||||
|
||||
public interface IScrollSource
|
||||
{
|
||||
|
||||
int getCurrentScroll();
|
||||
int getCurrentScroll();
|
||||
}
|
||||
|
||||
@@ -18,15 +18,14 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
|
||||
public interface ISortSource {
|
||||
SortOrder getSortBy();
|
||||
|
||||
public interface ISortSource
|
||||
{
|
||||
SortOrder getSortBy();
|
||||
SortDir getSortDir();
|
||||
ViewItems getSortDisplay();
|
||||
SortDir getSortDir();
|
||||
|
||||
ViewItems getSortDisplay();
|
||||
}
|
||||
|
||||
@@ -18,50 +18,48 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
/**
|
||||
* AEBaseGui controlled Tooltip Interface.
|
||||
*/
|
||||
public interface ITooltip
|
||||
{
|
||||
public interface ITooltip {
|
||||
|
||||
/**
|
||||
* returns the tooltip message.
|
||||
*
|
||||
* @return tooltip message
|
||||
*/
|
||||
String getMessage();
|
||||
/**
|
||||
* returns the tooltip message.
|
||||
*
|
||||
* @return tooltip message
|
||||
*/
|
||||
String getMessage();
|
||||
|
||||
/**
|
||||
* x Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return xPosition
|
||||
*/
|
||||
int xPos();
|
||||
/**
|
||||
* x Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return xPosition
|
||||
*/
|
||||
int xPos();
|
||||
|
||||
/**
|
||||
* y Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return yPosition
|
||||
*/
|
||||
int yPos();
|
||||
/**
|
||||
* y Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return yPosition
|
||||
*/
|
||||
int yPos();
|
||||
|
||||
/**
|
||||
* Width of the object that triggers the tooltip.
|
||||
*
|
||||
* @return width
|
||||
*/
|
||||
int getWidth();
|
||||
/**
|
||||
* Width of the object that triggers the tooltip.
|
||||
*
|
||||
* @return width
|
||||
*/
|
||||
int getWidth();
|
||||
|
||||
/**
|
||||
* Height for the object that triggers the tooltip.
|
||||
*
|
||||
* @return height
|
||||
*/
|
||||
int getHeight();
|
||||
/**
|
||||
* Height for the object that triggers the tooltip.
|
||||
*
|
||||
* @return height
|
||||
*/
|
||||
int getHeight();
|
||||
|
||||
/**
|
||||
* @return true if button being drawn
|
||||
*/
|
||||
boolean isVisible();
|
||||
/**
|
||||
* @return true if button being drawn
|
||||
*/
|
||||
boolean isVisible();
|
||||
}
|
||||
|
||||
@@ -18,152 +18,135 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
|
||||
|
||||
/**
|
||||
* A modified version of the Minecraft text field.
|
||||
* You can initialize it over the full element span.
|
||||
* The mouse click area is increased to the full element
|
||||
* A modified version of the Minecraft text field. You can initialize it over
|
||||
* the full element span. The mouse click area is increased to the full element
|
||||
* subtracted with the defined padding.
|
||||
*
|
||||
* The rendering does pay attention to the size of the '_' caret.
|
||||
*/
|
||||
public class MEGuiTextField extends TextFieldWidget
|
||||
{
|
||||
private static final int PADDING = 2;
|
||||
public class MEGuiTextField extends TextFieldWidget {
|
||||
private static final int PADDING = 2;
|
||||
|
||||
private final int _fontPad;
|
||||
private int selectionColor = 0xFF00FF00;
|
||||
private final int _fontPad;
|
||||
private int selectionColor = 0xFF00FF00;
|
||||
|
||||
/**
|
||||
* Uses the values to instantiate a padded version of a text field.
|
||||
* Pays attention to the '_' caret.
|
||||
*
|
||||
* @param fontRenderer renderer for the strings
|
||||
* @param xPos absolute left position
|
||||
* @param yPos absolute top position
|
||||
* @param width absolute width
|
||||
* @param height absolute height
|
||||
*/
|
||||
public MEGuiTextField( final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height )
|
||||
{
|
||||
super( fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - (int) fontRenderer.getCharWidth( '_' ), height - 2 * PADDING, "" );
|
||||
/**
|
||||
* Uses the values to instantiate a padded version of a text field. Pays
|
||||
* attention to the '_' caret.
|
||||
*
|
||||
* @param fontRenderer renderer for the strings
|
||||
* @param xPos absolute left position
|
||||
* @param yPos absolute top position
|
||||
* @param width absolute width
|
||||
* @param height absolute height
|
||||
*/
|
||||
public MEGuiTextField(final FontRenderer fontRenderer, final int xPos, final int yPos, final int width,
|
||||
final int height) {
|
||||
super(fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - (int) fontRenderer.getCharWidth('_'),
|
||||
height - 2 * PADDING, "");
|
||||
|
||||
this._fontPad = (int) fontRenderer.getCharWidth( '_' );
|
||||
}
|
||||
this._fontPad = (int) fontRenderer.getCharWidth('_');
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked( final double xPos, final double yPos, final int button )
|
||||
{
|
||||
if (!super.mouseClicked( xPos, yPos, button )) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean mouseClicked(final double xPos, final double yPos, final int button) {
|
||||
if (!super.mouseClicked(xPos, yPos, button)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final boolean requiresFocus = this.isMouseOver( xPos, yPos );
|
||||
if( !this.isFocused() )
|
||||
{
|
||||
this.setFocused2( requiresFocus );
|
||||
}
|
||||
final boolean requiresFocus = this.isMouseOver(xPos, yPos);
|
||||
if (!this.isFocused()) {
|
||||
this.setFocused2(requiresFocus);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void selectAll()
|
||||
{
|
||||
this.setCursorPosition( 0 );
|
||||
this.setSelectionPos( this.getMaxStringLength() );
|
||||
}
|
||||
public void selectAll() {
|
||||
this.setCursorPosition(0);
|
||||
this.setSelectionPos(this.getMaxStringLength());
|
||||
}
|
||||
|
||||
public void setSelectionColor( int color )
|
||||
{
|
||||
this.selectionColor = color;
|
||||
}
|
||||
public void setSelectionColor(int color) {
|
||||
this.selectionColor = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(int mouseX, int mouseY, float partial)
|
||||
{
|
||||
if( this.getVisible() )
|
||||
{
|
||||
if( this.isFocused() )
|
||||
{
|
||||
fill( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
|
||||
0xFF606060 );
|
||||
}
|
||||
else
|
||||
{
|
||||
fill( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
|
||||
0xFFA8A8A8 );
|
||||
}
|
||||
super.renderButton(mouseX, mouseY, partial);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void renderButton(int mouseX, int mouseY, float partial) {
|
||||
if (this.getVisible()) {
|
||||
if (this.isFocused()) {
|
||||
fill(this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1,
|
||||
this.y + this.height + PADDING - 1, 0xFF606060);
|
||||
} else {
|
||||
fill(this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1,
|
||||
this.y + this.height + PADDING - 1, 0xFFA8A8A8);
|
||||
}
|
||||
super.renderButton(mouseX, mouseY, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelectionBox( int startX, int startY, int endX, int endY )
|
||||
{
|
||||
if( !this.isFocused() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void drawSelectionBox(int startX, int startY, int endX, int endY) {
|
||||
if (!this.isFocused()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( startX < endX )
|
||||
{
|
||||
int i = startX;
|
||||
startX = endX;
|
||||
endX = i;
|
||||
}
|
||||
if (startX < endX) {
|
||||
int i = startX;
|
||||
startX = endX;
|
||||
endX = i;
|
||||
}
|
||||
|
||||
startX += 1;
|
||||
endX -= 1;
|
||||
startX += 1;
|
||||
endX -= 1;
|
||||
|
||||
if( startY < endY )
|
||||
{
|
||||
int j = startY;
|
||||
startY = endY;
|
||||
endY = j;
|
||||
}
|
||||
if (startY < endY) {
|
||||
int j = startY;
|
||||
startY = endY;
|
||||
endY = j;
|
||||
}
|
||||
|
||||
startY -= PADDING;
|
||||
startY -= PADDING;
|
||||
|
||||
if( endX > this.x + this.width )
|
||||
{
|
||||
endX = this.x + this.width;
|
||||
}
|
||||
if (endX > this.x + this.width) {
|
||||
endX = this.x + this.width;
|
||||
}
|
||||
|
||||
if( startX > this.x + this.width )
|
||||
{
|
||||
startX = this.x + this.width;
|
||||
}
|
||||
if (startX > this.x + this.width) {
|
||||
startX = this.x + this.width;
|
||||
}
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
||||
|
||||
float red = ( this.selectionColor >> 16 & 255 ) / 255.0F;
|
||||
float blue = ( this.selectionColor >> 8 & 255 ) / 255.0F;
|
||||
float green = ( this.selectionColor & 255 ) / 255.0F;
|
||||
float alpha = ( this.selectionColor >> 24 & 255 ) / 255.0F;
|
||||
float red = (this.selectionColor >> 16 & 255) / 255.0F;
|
||||
float blue = (this.selectionColor >> 8 & 255) / 255.0F;
|
||||
float green = (this.selectionColor & 255) / 255.0F;
|
||||
float alpha = (this.selectionColor >> 24 & 255) / 255.0F;
|
||||
|
||||
RenderSystem.color4f( red, green, blue, alpha );
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.enableColorLogicOp();
|
||||
RenderSystem.logicOp( GlStateManager.LogicOp.OR_REVERSE );
|
||||
bufferbuilder.begin( 7, DefaultVertexFormats.POSITION );
|
||||
bufferbuilder.pos( startX, endY, 0.0D ).endVertex();
|
||||
bufferbuilder.pos( endX, endY, 0.0D ).endVertex();
|
||||
bufferbuilder.pos( endX, startY, 0.0D ).endVertex();
|
||||
bufferbuilder.pos( startX, startY, 0.0D ).endVertex();
|
||||
tessellator.draw();
|
||||
RenderSystem.disableColorLogicOp();
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.color4f( 1, 1, 1, 1 );
|
||||
}
|
||||
RenderSystem.color4f(red, green, blue, alpha);
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.enableColorLogicOp();
|
||||
RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE);
|
||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
||||
bufferbuilder.pos(startX, endY, 0.0D).endVertex();
|
||||
bufferbuilder.pos(endX, endY, 0.0D).endVertex();
|
||||
bufferbuilder.pos(endX, startY, 0.0D).endVertex();
|
||||
bufferbuilder.pos(startX, startY, 0.0D).endVertex();
|
||||
tessellator.draw();
|
||||
RenderSystem.disableColorLogicOp();
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.color4f(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user