-
Notifications
You must be signed in to change notification settings - Fork 497
/
GuiFiller.java
96 lines (72 loc) · 2.67 KB
/
GuiFiller.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
/**
* Copyright (c) SpaceToad, 2011
* 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.builders.gui;
import net.minecraft.inventory.IInventory;
import org.lwjgl.opengl.GL11;
import buildcraft.builders.TileFiller;
import buildcraft.core.DefaultProps;
import buildcraft.core.gui.GuiBuildCraft;
import buildcraft.core.utils.StringUtil;
public class GuiFiller extends GuiBuildCraft {
IInventory playerInventory;
TileFiller filler;
public GuiFiller(IInventory playerInventory, TileFiller filler) {
super(new ContainerFiller(playerInventory, filler), filler);
this.playerInventory = playerInventory;
this.filler = filler;
xSize = 175;
ySize = 240;
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
String title = StringUtil.localize("tile.fillerBlock");
fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.filling.resources"), 8, 74, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, 142, 0x404040);
if (filler.currentPattern != null) {
drawForegroundSelection(filler.currentPattern.getName());
}
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(DefaultProps.TEXTURE_PATH_GUI + "/filler.png");
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if (filler.currentPattern != null) {
mc.renderEngine.bindTexture("/terrain.png");
drawTexturedModelRectFromIcon(guiLeft + patternSymbolX, guiTop + patternSymbolY, filler.currentPattern.getTexture(), 16, 16);
}
}
public boolean intersectsWith(int i, int j) {
if (i >= patternSymbolX && i <= patternSymbolX + 16 && j >= patternSymbolY && j <= patternSymbolY + 16)
return true;
return false;
}
protected void drawForegroundSelection(String tag) {
if (!intersectsWith(lastX - guiLeft, lastY - guiTop))
return;
if (tag.length() > 0) {
int i2 = (lastX - guiLeft) + 12;
int k2 = lastY - guiTop - 12;
int l2 = fontRenderer.getStringWidth(tag);
drawGradientRect(i2 - 3, k2 - 3, i2 + l2 + 3, k2 + 8 + 3, 0xc0000000, 0xc0000000);
fontRenderer.drawStringWithShadow(tag, i2, k2, -1);
}
}
@Override
protected void mouseMovedOrUp(int i, int j, int k) {
super.mouseMovedOrUp(i, j, k);
lastX = i;
lastY = j;
}
private int lastX = 0;
private int lastY = 0;
public final int patternSymbolX = 125;
public final int patternSymbolY = 34;
}