forked from xsun2001/Applied-Energistics-2-Unofficial
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from repo-alt/feature/OredictFilter
Oredictionary filter card
- Loading branch information
Showing
31 changed files
with
528 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/main/java/appeng/client/gui/implementations/GuiOreFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package appeng.client.gui.implementations; | ||
|
||
import appeng.client.gui.AEBaseGui; | ||
import appeng.container.AEBaseContainer; | ||
import appeng.container.implementations.ContainerOreFilter; | ||
import appeng.core.AELog; | ||
import appeng.core.localization.GuiText; | ||
import appeng.core.sync.GuiBridge; | ||
import appeng.core.sync.network.NetworkHandler; | ||
import appeng.core.sync.packets.PacketSwitchGuis; | ||
import appeng.core.sync.packets.PacketValueConfig; | ||
import appeng.helpers.IOreFilterable; | ||
import appeng.parts.automation.PartSharedItemBus; | ||
import appeng.parts.misc.PartStorageBus; | ||
import net.minecraft.client.gui.GuiTextField; | ||
import net.minecraft.entity.player.InventoryPlayer; | ||
|
||
import java.io.IOException; | ||
|
||
public class GuiOreFilter extends AEBaseGui { | ||
private GuiTextField filter; | ||
public GuiOreFilter(InventoryPlayer ip, IOreFilterable obj) { | ||
super(new ContainerOreFilter(ip, obj)); | ||
} | ||
|
||
@Override | ||
public void initGui() { | ||
super.initGui(); | ||
this.filter = new GuiTextField(this.fontRendererObj, this.guiLeft + 13, this.guiTop + 36, 150, this.fontRendererObj.FONT_HEIGHT); | ||
this.filter.setEnableBackgroundDrawing(false); | ||
this.filter.setMaxStringLength(32); | ||
this.filter.setTextColor(0xFFFFFF); | ||
this.filter.setVisible(true); | ||
this.filter.setFocused(true); | ||
((ContainerOreFilter) this.inventorySlots).setTextField(this.filter); | ||
} | ||
|
||
@Override | ||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) { | ||
this.fontRendererObj.drawString( GuiText.OreFilterLabel.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.filter.drawTextBox(); | ||
} | ||
|
||
@Override | ||
protected void keyTyped(final char character, final int key) { | ||
if (key == 28) // Enter | ||
{ | ||
try | ||
{ | ||
NetworkHandler.instance.sendToServer(new PacketValueConfig("OreFilter", this.filter.getText())); | ||
} | ||
catch (IOException e) | ||
{ | ||
AELog.debug(e); | ||
} | ||
final Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget(); | ||
GuiBridge OriginalGui = null; | ||
if (target instanceof PartStorageBus) | ||
OriginalGui = GuiBridge.GUI_STORAGEBUS; | ||
else if (target instanceof PartSharedItemBus) | ||
OriginalGui = GuiBridge.GUI_BUS; | ||
|
||
if (OriginalGui != null) | ||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) ); | ||
else | ||
this.mc.thePlayer.closeScreen(); | ||
} | ||
else if (this.filter.textboxKeyTyped(character, key)) | ||
{ | ||
((ContainerOreFilter) this.inventorySlots).setFilter(filter.getText()); | ||
} | ||
else | ||
super.keyTyped(character, key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/appeng/container/implementations/ContainerOreFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package appeng.container.implementations; | ||
|
||
import appeng.api.config.SecurityPermissions; | ||
import appeng.api.parts.IPart; | ||
import appeng.container.AEBaseContainer; | ||
import appeng.container.guisync.GuiSync; | ||
import appeng.helpers.IOreFilterable; | ||
import appeng.util.Platform; | ||
import cpw.mods.fml.relauncher.Side; | ||
import cpw.mods.fml.relauncher.SideOnly; | ||
import net.minecraft.client.gui.GuiTextField; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.entity.player.InventoryPlayer; | ||
import net.minecraft.tileentity.TileEntity; | ||
|
||
public class ContainerOreFilter extends AEBaseContainer | ||
{ | ||
private final IOreFilterable filterHost; | ||
@SideOnly( Side.CLIENT ) | ||
private GuiTextField textField; | ||
@GuiSync( 2 ) | ||
public String filter = ""; | ||
|
||
public ContainerOreFilter( final InventoryPlayer ip, final IOreFilterable te) | ||
{ | ||
super( ip, (TileEntity) ( te instanceof TileEntity ? te : null ), (IPart) ( te instanceof IPart ? te : null ) ); | ||
this.filterHost = te; | ||
} | ||
|
||
@SideOnly( Side.CLIENT ) | ||
public void setTextField( final GuiTextField f ) | ||
{ | ||
this.textField = f; | ||
this.textField.setText(filter); | ||
} | ||
|
||
public void setFilter( final String newValue) | ||
{ | ||
this.filterHost.setFilter(newValue); | ||
this.filter = newValue; | ||
} | ||
|
||
@Override | ||
public void detectAndSendChanges() | ||
{ | ||
this.verifyPermissions( SecurityPermissions.BUILD, false ); | ||
if (Platform.isServer()) | ||
this.filter = this.filterHost.getFilter(); | ||
super.detectAndSendChanges(); | ||
} | ||
@Override | ||
public void onUpdate( final String field, final Object oldValue, final Object newValue ) | ||
{ | ||
if (field.equals("filter") && this.textField != null) | ||
this.textField.setText(filter); | ||
|
||
super.onUpdate( field, oldValue, newValue ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.