-
Notifications
You must be signed in to change notification settings - Fork 497
/
GuiEmeraldPipe.java
130 lines (104 loc) · 4.13 KB
/
GuiEmeraldPipe.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.transport.gui;
import org.lwjgl.opengl.GL11;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import buildcraft.core.lib.gui.GuiBuildCraft;
import buildcraft.core.lib.gui.buttons.GuiImageButton;
import buildcraft.core.lib.gui.buttons.IButtonClickEventListener;
import buildcraft.core.lib.gui.buttons.IButtonClickEventTrigger;
import buildcraft.core.lib.network.PacketGuiReturn;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.transport.pipes.PipeItemsEmerald;
import buildcraft.transport.pipes.PipeItemsEmerald.FilterMode;
public class GuiEmeraldPipe extends GuiBuildCraft implements IButtonClickEventListener {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcrafttransport:textures/gui/pipe_emerald.png");
private static final int WHITE_LIST_BUTTON_ID = 1;
private static final int BLACK_LIST_BUTTON_ID = 2;
private static final int ROUND_ROBIN_BUTTON_ID = 3;
private GuiImageButton whiteListButton;
private GuiImageButton blackListButton;
private GuiImageButton roundRobinButton;
private PipeItemsEmerald pipe;
public GuiEmeraldPipe(IInventory playerInventory, PipeItemsEmerald pipe) {
super(new ContainerEmeraldPipe(playerInventory, pipe), pipe.getFilters(), TEXTURE);
this.pipe = pipe;
xSize = 175;
ySize = 161;
}
@Override
public void initGui() {
super.initGui();
this.buttonList.clear();
this.whiteListButton = new GuiImageButton(WHITE_LIST_BUTTON_ID, this.guiLeft + 7, this.guiTop + 41, GuiImageButton.ButtonImage.WHITE_LIST);
this.whiteListButton.registerListener(this);
this.buttonList.add(this.whiteListButton);
this.blackListButton = new GuiImageButton(BLACK_LIST_BUTTON_ID, this.guiLeft + 7 + 18, this.guiTop + 41, GuiImageButton.ButtonImage.BLACK_LIST);
this.blackListButton.registerListener(this);
this.buttonList.add(this.blackListButton);
this.roundRobinButton = new GuiImageButton(ROUND_ROBIN_BUTTON_ID, this.guiLeft + 7 + 36, this.guiTop + 41, GuiImageButton.ButtonImage.ROUND_ROBIN);
this.roundRobinButton.registerListener(this);
this.buttonList.add(this.roundRobinButton);
switch (pipe.getSettings().getFilterMode()) {
case WHITE_LIST:
this.whiteListButton.activate();
break;
case BLACK_LIST:
this.blackListButton.activate();
break;
case ROUND_ROBIN:
this.roundRobinButton.activate();
break;
}
}
@Override
public void onGuiClosed() {
if (pipe.getWorld().isRemote) {
PacketGuiReturn pkt = new PacketGuiReturn(pipe.getContainer());
pkt.sendPacket();
}
super.onGuiClosed();
}
@Override
public void handleButtonClick(IButtonClickEventTrigger sender, int buttonId) {
switch (buttonId) {
case WHITE_LIST_BUTTON_ID:
whiteListButton.activate();
blackListButton.deActivate();
roundRobinButton.deActivate();
pipe.getSettings().setFilterMode(FilterMode.WHITE_LIST);
break;
case BLACK_LIST_BUTTON_ID:
whiteListButton.deActivate();
blackListButton.activate();
roundRobinButton.deActivate();
pipe.getSettings().setFilterMode(FilterMode.BLACK_LIST);
break;
case ROUND_ROBIN_BUTTON_ID:
whiteListButton.deActivate();
blackListButton.deActivate();
roundRobinButton.activate();
pipe.getSettings().setFilterMode(FilterMode.ROUND_ROBIN);
break;
}
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
String title = StringUtils.localize("gui.pipes.emerald.title");
fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title)) / 2, 6, 0x404040);
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 93, 0x404040);
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(TEXTURE);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}
}