Skip to content

Commit 43fe832

Browse files
authored
Merge pull request #3 from GlodBlock/upstream
upstream
2 parents c5a75cf + 932bb9e commit 43fe832

39 files changed

+2263
-179
lines changed

dependencies.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ dependencies {
77
compile('com.github.GTNewHorizons:ExtraCells2:2.5.9:dev') {transitive = false}
88
compile("com.github.GTNewHorizons:ForestryMC:4.4.7:dev")
99

10+
compileOnly("com.github.GTNewHorizons:ForestryMC:4.4.4:dev")
1011
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.27:dev")
1112
compileOnly("com.github.GTNewHorizons:EnderCore:0.2.6:dev")
1213
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.40.41:dev')
@@ -15,5 +16,7 @@ dependencies {
1516
compileOnly('com.github.GTNewHorizons:AppleCore:3.1.9:dev') {transitive = false}
1617
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:dev') {transitive = false}
1718
compileOnly("com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev") {transitive = false}
19+
compileOnly('com.github.GTNewHorizons:OpenComputers:1.7.5.23-GTNH:dev') {transitive = false}
1820
compileOnly("com.github.GTNewHorizons:GTplusplus:1.7.49:dev") {transitive = false}
21+
1922
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
package com.glodblock.github.client.gui;
2+
3+
import appeng.api.config.Settings;
4+
import appeng.api.config.YesNo;
5+
import appeng.client.gui.implementations.GuiUpgradeable;
6+
import appeng.client.gui.widgets.GuiImgButton;
7+
import appeng.client.gui.widgets.GuiTabButton;
8+
import appeng.client.gui.widgets.GuiToggleButton;
9+
import appeng.container.implementations.ContainerInterface;
10+
import appeng.core.localization.GuiText;
11+
import appeng.core.sync.network.NetworkHandler;
12+
import appeng.core.sync.packets.PacketConfigButton;
13+
import appeng.helpers.IInterfaceHost;
14+
import com.glodblock.github.FluidCraft;
15+
import com.glodblock.github.common.parts.PartFluidInterface;
16+
import com.glodblock.github.common.tile.TileFluidInterface;
17+
import com.glodblock.github.inventory.gui.GuiType;
18+
import com.glodblock.github.loader.ItemAndBlockHolder;
19+
import com.glodblock.github.network.CPacketSwitchGuis;
20+
import com.glodblock.github.util.ModAndClassUtil;
21+
import com.glodblock.github.util.NameConst;
22+
import net.minecraft.client.gui.GuiButton;
23+
import net.minecraft.entity.player.InventoryPlayer;
24+
import net.minecraft.util.StatCollector;
25+
import org.lwjgl.input.Mouse;
26+
27+
public class GuiDualInterface extends GuiUpgradeable {
28+
29+
private GuiTabButton priority;
30+
private GuiTabButton switcher;
31+
private GuiImgButton BlockMode;
32+
private GuiToggleButton interfaceMode;
33+
private final IInterfaceHost host;
34+
35+
public GuiDualInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
36+
super(new ContainerInterface(inventoryPlayer, te));
37+
this.host = te;
38+
this.ySize = 211;
39+
}
40+
41+
@Override
42+
@SuppressWarnings("unchecked")
43+
protected void addButtons()
44+
{
45+
this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender );
46+
this.buttonList.add( this.priority );
47+
48+
this.switcher = new GuiTabButton( this.guiLeft + 132, this.guiTop, host instanceof PartFluidInterface ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(), StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), itemRender );
49+
this.buttonList.add( this.switcher );
50+
51+
this.BlockMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO );
52+
this.buttonList.add( this.BlockMode );
53+
54+
this.interfaceMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 26, 84, 85, GuiText.InterfaceTerminal.getLocal(), GuiText.InterfaceTerminalHint.getLocal() );
55+
this.buttonList.add( this.interfaceMode );
56+
}
57+
58+
@Override
59+
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
60+
{
61+
if( this.BlockMode != null )
62+
{
63+
this.BlockMode.set( ( (ContainerInterface) this.cvb ).getBlockingMode() );
64+
}
65+
66+
if( this.interfaceMode != null )
67+
{
68+
this.interfaceMode.setState( ( (ContainerInterface) this.cvb ).getInterfaceTerminalMode() == YesNo.YES );
69+
}
70+
71+
this.fontRendererObj.drawString( StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE), 8, 6, 4210752 );
72+
}
73+
74+
@Override
75+
protected String getBackground()
76+
{
77+
if (!ModAndClassUtil.isBigInterface)
78+
return "guis/interface.png";
79+
switch (((ContainerInterface) this.cvb).getPatternCapacityCardsInstalled())
80+
{
81+
case 1:
82+
return "guis/interface2.png";
83+
case 2:
84+
return "guis/interface3.png";
85+
case 3:
86+
return "guis/interface4.png";
87+
}
88+
return "guis/interface.png";
89+
}
90+
91+
@Override
92+
protected void actionPerformed( final GuiButton btn )
93+
{
94+
super.actionPerformed( btn );
95+
96+
final boolean backwards = Mouse.isButtonDown( 1 );
97+
98+
if( btn == this.priority )
99+
{
100+
if (host instanceof TileFluidInterface) {
101+
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY));
102+
}
103+
else if(host instanceof PartFluidInterface) {
104+
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY_PART));
105+
}
106+
}
107+
108+
if( btn == this.switcher )
109+
{
110+
if (host instanceof TileFluidInterface) {
111+
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
112+
}
113+
else if (host instanceof PartFluidInterface) {
114+
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID_PART));
115+
}
116+
}
117+
118+
if( btn == this.interfaceMode )
119+
{
120+
NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) );
121+
}
122+
123+
if( btn == this.BlockMode )
124+
{
125+
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.BlockMode.getSetting(), backwards ) );
126+
}
127+
}
128+
}
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
package com.glodblock.github.client.gui;
2+
3+
import appeng.client.gui.AEBaseGui;
4+
import appeng.client.gui.widgets.GuiNumberBox;
5+
import appeng.client.gui.widgets.GuiTabButton;
6+
import appeng.container.AEBaseContainer;
7+
import appeng.container.implementations.ContainerPriority;
8+
import appeng.core.AEConfig;
9+
import appeng.core.AELog;
10+
import appeng.core.localization.GuiText;
11+
import appeng.core.sync.network.NetworkHandler;
12+
import appeng.core.sync.packets.PacketValueConfig;
13+
import appeng.helpers.IPriorityHost;
14+
import com.glodblock.github.FluidCraft;
15+
import com.glodblock.github.common.parts.PartFluidInterface;
16+
import com.glodblock.github.common.tile.TileFluidInterface;
17+
import com.glodblock.github.inventory.gui.GuiType;
18+
import com.glodblock.github.loader.ItemAndBlockHolder;
19+
import com.glodblock.github.network.CPacketSwitchGuis;
20+
import net.minecraft.client.gui.Gui;
21+
import net.minecraft.client.gui.GuiButton;
22+
import net.minecraft.entity.player.InventoryPlayer;
23+
import net.minecraft.item.ItemStack;
24+
25+
import java.io.IOException;
26+
27+
public class GuiFCPriority extends AEBaseGui
28+
{
29+
30+
private GuiNumberBox priority;
31+
private GuiTabButton originalGuiBtn;
32+
33+
private GuiButton plus1;
34+
private GuiButton plus10;
35+
private GuiButton plus100;
36+
private GuiButton plus1000;
37+
private GuiButton minus1;
38+
private GuiButton minus10;
39+
private GuiButton minus100;
40+
private GuiButton minus1000;
41+
42+
private GuiType OriginalGui;
43+
44+
public GuiFCPriority( final InventoryPlayer inventoryPlayer, final IPriorityHost te )
45+
{
46+
super( new ContainerPriority( inventoryPlayer, te ) );
47+
}
48+
49+
@Override
50+
@SuppressWarnings("unchecked")
51+
public void initGui()
52+
{
53+
super.initGui();
54+
55+
final int a = AEConfig.instance.priorityByStacksAmounts( 0 );
56+
final int b = AEConfig.instance.priorityByStacksAmounts( 1 );
57+
final int c = AEConfig.instance.priorityByStacksAmounts( 2 );
58+
final int d = AEConfig.instance.priorityByStacksAmounts( 3 );
59+
60+
this.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a ) );
61+
this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b ) );
62+
this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c ) );
63+
this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d ) );
64+
65+
this.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a ) );
66+
this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b ) );
67+
this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c ) );
68+
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d ) );
69+
70+
ItemStack myIcon = null;
71+
final Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget();
72+
73+
if( target instanceof TileFluidInterface)
74+
{
75+
myIcon = ItemAndBlockHolder.INTERFACE.stack();
76+
this.OriginalGui = GuiType.DUAL_INTERFACE;
77+
}
78+
else if (target instanceof PartFluidInterface)
79+
{
80+
myIcon = ItemAndBlockHolder.FLUID_INTERFACE.stack();
81+
this.OriginalGui = GuiType.DUAL_INTERFACE_FLUID_PART;
82+
}
83+
84+
if( this.OriginalGui != null && myIcon != null )
85+
{
86+
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
87+
}
88+
89+
this.priority = new GuiNumberBox( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Long.class );
90+
this.priority.setEnableBackgroundDrawing( false );
91+
this.priority.setMaxStringLength( 16 );
92+
this.priority.setTextColor( 0xFFFFFF );
93+
this.priority.setVisible( true );
94+
this.priority.setFocused( true );
95+
( (ContainerPriority) this.inventorySlots ).setTextField( this.priority );
96+
}
97+
98+
@Override
99+
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
100+
{
101+
this.fontRendererObj.drawString( GuiText.Priority.getLocal(), 8, 6, 4210752 );
102+
}
103+
104+
@Override
105+
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
106+
{
107+
this.bindTexture( getBackground() );
108+
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
109+
110+
this.priority.drawTextBox();
111+
}
112+
113+
@Override
114+
protected void actionPerformed( final GuiButton btn )
115+
{
116+
super.actionPerformed( btn );
117+
118+
if( btn == this.originalGuiBtn )
119+
{
120+
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui));
121+
}
122+
123+
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
124+
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
125+
126+
if( isPlus || isMinus )
127+
{
128+
this.addQty( this.getQty( btn ) );
129+
}
130+
}
131+
132+
private void addQty( final int i )
133+
{
134+
try
135+
{
136+
String out = this.priority.getText();
137+
138+
boolean fixed = false;
139+
while( out.startsWith( "0" ) && out.length() > 1 )
140+
{
141+
out = out.substring( 1 );
142+
fixed = true;
143+
}
144+
145+
if( fixed )
146+
{
147+
this.priority.setText( out );
148+
}
149+
150+
if( out.isEmpty() )
151+
{
152+
out = "0";
153+
}
154+
155+
long result = Long.parseLong( out );
156+
result += i;
157+
158+
this.priority.setText( out = Long.toString( result ) );
159+
160+
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
161+
}
162+
catch( final NumberFormatException e )
163+
{
164+
// nope..
165+
this.priority.setText( "0" );
166+
}
167+
catch( final IOException e )
168+
{
169+
AELog.debug( e );
170+
}
171+
}
172+
173+
@Override
174+
protected void keyTyped( final char character, final int key )
175+
{
176+
if( !this.checkHotbarKeys( key ) )
177+
{
178+
if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.priority.textboxKeyTyped( character, key ) )
179+
{
180+
try
181+
{
182+
String out = this.priority.getText();
183+
184+
boolean fixed = false;
185+
while( out.startsWith( "0" ) && out.length() > 1 )
186+
{
187+
out = out.substring( 1 );
188+
fixed = true;
189+
}
190+
191+
if( fixed )
192+
{
193+
this.priority.setText( out );
194+
}
195+
196+
if( out.isEmpty() )
197+
{
198+
out = "0";
199+
}
200+
201+
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
202+
}
203+
catch( final IOException e )
204+
{
205+
AELog.debug( e );
206+
}
207+
}
208+
else
209+
{
210+
super.keyTyped( character, key );
211+
}
212+
}
213+
}
214+
215+
protected String getBackground()
216+
{
217+
return "guis/priority.png";
218+
}
219+
}

0 commit comments

Comments
 (0)