minor cleanup

This commit is contained in:
PrototypeTrousers
2022-09-05 15:08:04 -03:00
parent a9c891f69a
commit efb9ab512a
6 changed files with 105 additions and 98 deletions
@@ -28,6 +28,7 @@ import java.util.List;
import appeng.parts.reporting.PartExpandedProcessingPatternTerminal;
import com.google.common.base.Joiner;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
@@ -127,7 +128,7 @@ public class GuiCraftConfirm extends AEBaseGui
this.buttonList.add( this.start );
this.selectCPU = new GuiButton( 0, this.guiLeft + ( 219 - 180 ) / 2, this.guiTop + this.ySize - 68, 180, 20, GuiText.CraftingCPU
.getLocal() + ": " + GuiText.Automatic );
.getLocal() + ": " + GuiText.Automatic );
this.selectCPU.enabled = false;
this.buttonList.add( this.selectCPU );
@@ -227,7 +228,7 @@ public class GuiCraftConfirm extends AEBaseGui
else
{
dsp = this.ccc.getCpuAvailableBytes() > 0 ? ( GuiText.Bytes.getLocal() + ": " + this.ccc.getCpuAvailableBytes() + " : " + GuiText.CoProcessors
.getLocal() + ": " + this.ccc.getCpuCoProcessors() ) : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
.getLocal() + ": " + this.ccc.getCpuCoProcessors() ) : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
}
final int offset = ( 219 - this.fontRenderer.getStringWidth( dsp ) ) / 2;
@@ -294,7 +295,7 @@ public class GuiCraftConfirm extends AEBaseGui
str = GuiText.FromStorage.getLocal() + ": " + str;
final int w = 4 + this.fontRenderer.getStringWidth( str );
this.fontRenderer.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ),
( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if( this.tooltip == z - viewStart )
{
@@ -320,7 +321,7 @@ public class GuiCraftConfirm extends AEBaseGui
str = GuiText.Missing.getLocal() + ": " + str;
final int w = 4 + this.fontRenderer.getStringWidth( str );
this.fontRenderer.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ),
( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if( this.tooltip == z - viewStart )
{
@@ -346,7 +347,7 @@ public class GuiCraftConfirm extends AEBaseGui
str = GuiText.ToCraft.getLocal() + ": " + str;
final int w = 4 + this.fontRenderer.getStringWidth( str );
this.fontRenderer.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ),
( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if( this.tooltip == z - viewStart )
{
@@ -416,7 +417,7 @@ public class GuiCraftConfirm extends AEBaseGui
public void postUpdate( final List<IAEItemStack> list, final byte ref )
{
switch( ref )
switch ( ref )
{
case 0:
for( final IAEItemStack l : list )
@@ -513,7 +514,7 @@ public class GuiCraftConfirm extends AEBaseGui
private void deleteVisualStack( final IAEItemStack l )
{
final Iterator<IAEItemStack> i = this.visual.iterator();
while( i.hasNext() )
while ( i.hasNext() )
{
final IAEItemStack o = i.next();
if( o.equals( l ) )
@@ -544,7 +545,7 @@ public class GuiCraftConfirm extends AEBaseGui
{
if( !this.checkHotbarKeys( key ) )
{
if( key == 28 )
if( key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER )
{
this.actionPerformed( this.start );
}
@@ -21,6 +21,7 @@ package appeng.client.gui.implementations;
import java.io.IOException;
import appeng.items.contents.QuartzKnifeObj;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.InventoryPlayer;
@@ -30,7 +31,6 @@ import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.bootstrap.contents.QuartzKnifeObj;
public class GuiQuartzKnife extends AEBaseGui
@@ -8,101 +8,107 @@ import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.ICustomNameObject;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
import java.io.IOException;
public class GuiRenamer extends AEBaseGui {
private MEGuiTextField textField;
private GuiButton confirmButton;
public class GuiRenamer extends AEBaseGui
{
private MEGuiTextField textField;
private GuiButton confirmButton;
public GuiRenamer(InventoryPlayer ip, ICustomNameObject obj) {
super(new ContainerRenamer(ip, obj));
this.xSize = 256;
public GuiRenamer( InventoryPlayer ip, ICustomNameObject obj )
{
super( new ContainerRenamer( ip, obj ) );
this.xSize = 256;
}
this.textField = new MEGuiTextField(Minecraft.getMinecraft().fontRenderer, 0, 0, 230, 12) {
@Override
public void onTextChange(final String oldText) {
final String text = getText();
@Override
public void initGui()
{
super.initGui();
if (!text.equals(oldText)) {
((ContainerRenamer) inventorySlots).setCustomName(text);
}
}
};
this.textField.setEnableBackgroundDrawing(false);
this.textField.setMaxStringLength(32);
}
this.textField = new MEGuiTextField( this.fontRenderer, this.guiLeft + 9, this.guiTop + 33, 229, 12 );
@Override
public void initGui() {
super.initGui();
this.textField.setEnableBackgroundDrawing( false );
this.textField.setMaxStringLength( 32 );
this.textField.x = this.guiLeft + 12;
this.textField.y = this.guiTop + 35;
this.textField.setFocused(true);
this.textField.setFocused( true );
this.buttonList.add(this.confirmButton = new GuiButton(0, this.guiLeft + 238, this.guiTop + 33, 12, 12, ""));
this.buttonList.add( this.confirmButton = new GuiButton( 0, this.guiLeft + 238, this.guiTop + 33, 12, 12, "" ) );
((ContainerRenamer) this.inventorySlots).setTextField(this.textField);
}
( (ContainerRenamer) this.inventorySlots ).setTextField( this.textField );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.Renamer.getLocal()), 12, 8, 4210752);
}
@Override
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.Renamer.getLocal() ), 12, 8, 4210752 );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture("guis/renamer.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
this.textField.drawTextBox();
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/renamer.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
this.textField.drawTextBox();
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) throws IOException{
this.textField.mouseClicked(xCoord, yCoord, btn);
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) throws IOException
{
if( this.textField.isMouseIn( xCoord, yCoord ) )
{
if( btn == 1 )
{
this.textField.setText( "" );
}
this.textField.mouseClicked( xCoord, yCoord, btn );
}
super.mouseClicked( xCoord, yCoord, btn );
}
@Override
protected void keyTyped(final char character, final int key) throws IOException {
if (key == 28) { // Enter
try {
NetworkHandler.instance().sendToServer(
new PacketValueConfig("QuartzKnife.ReName", this.textField.getText()));
} catch (IOException e) {
AELog.debug(e);
}
this.mc.player.closeScreen();
} else if (!this.textField.textboxKeyTyped(character, key)) {
super.keyTyped(character, key);
}
}
@Override
protected void keyTyped( final char character, final int key ) throws IOException
{
if( key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER )
{ // Enter
try
{
NetworkHandler.instance().sendToServer(
new PacketValueConfig( "QuartzKnife.ReName", this.textField.getText() ) );
}
catch( IOException e )
{
AELog.debug( e );
}
this.mc.player.closeScreen();
}
else if( !this.textField.textboxKeyTyped( character, key ) )
{
super.keyTyped( character, key );
}
}
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
if(btn == this.confirmButton) {
try {
NetworkHandler.instance().sendToServer(
new PacketValueConfig("QuartzKnife.ReName", this.textField.getText()));
this.mc.player.closeScreen();
} catch (IOException e) {
AELog.debug(e);
}
}
}
public boolean isOverTextField(final int mousex, final int mousey) {
return textField.isMouseIn(mousex, mousey);
}
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
textField.setText(displayName);
}
if( btn == this.confirmButton )
{
try
{
NetworkHandler.instance().sendToServer(
new PacketValueConfig( "QuartzKnife.ReName", this.textField.getText() ) );
this.mc.player.closeScreen();
}
catch( IOException e )
{
AELog.debug( e );
}
}
}
}