| 1 | package net.minecraft.client.gui;
|
| 2 |
|
| 3 | import net.minecraft.client.Minecraft;
|
| 4 | import net.minecraft.client.renderer.GlStateManager;
|
| 5 | import net.minecraft.client.renderer.Tessellator;
|
| 6 | import net.minecraft.client.renderer.WorldRenderer;
|
| 7 | import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
| 8 | import net.minecraft.util.MathHelper;
|
| 9 | import org.lwjgl.input.Mouse;
|
| 10 |
|
| 11 | public abstract class GuiSlot
|
| 12 | {
|
| 13 | protected final Minecraft mc;
|
| 14 | protected int width;
|
| 15 | protected int height;
|
| 16 |
|
| 17 | /** The top of the slot container. Affects the overlays and scrolling. */
|
| 18 | protected int top;
|
| 19 |
|
| 20 | /** The bottom of the slot container. Affects the overlays and scrolling. */
|
| 21 | protected int bottom;
|
| 22 | protected int right;
|
| 23 | protected int left;
|
| 24 |
|
| 25 | /** The height of a slot. */
|
| 26 | protected final int slotHeight;
|
| 27 |
|
| 28 | /** The buttonID of the button used to scroll up */
|
| 29 | private int scrollUpButtonID;
|
| 30 |
|
| 31 | /** The buttonID of the button used to scroll down */
|
| 32 | private int scrollDownButtonID;
|
| 33 | protected int mouseX;
|
| 34 | protected int mouseY;
|
| 35 | protected boolean field_148163_i = true;
|
| 36 |
|
| 37 | /** Where the mouse was in the window when you first clicked to scroll */
|
| 38 | protected int initialClickY = -2;
|
| 39 |
|
| 40 | /**
|
| 41 | * What to multiply the amount you moved your mouse by (used for slowing down scrolling when over the items and not
|
| 42 | * on the scroll bar)
|
| 43 | */
|
| 44 | protected float scrollMultiplier;
|
| 45 |
|
| 46 | /** How far down this slot has been scrolled */
|
| 47 | protected float amountScrolled;
|
| 48 |
|
| 49 | /** The element in the list that was selected */
|
| 50 | protected int selectedElement = -1;
|
| 51 |
|
| 52 | /** The time when this button was last clicked. */
|
| 53 | protected long lastClicked;
|
| 54 | protected boolean field_178041_q = true;
|
| 55 |
|
| 56 | /**
|
| 57 | * Set to true if a selected element in this gui will show an outline box
|
| 58 | */
|
| 59 | protected boolean showSelectionBox = true;
|
| 60 | protected boolean hasListHeader;
|
| 61 | protected int headerPadding;
|
| 62 | private boolean enabled = true;
|
| 63 |
|
| 64 | public GuiSlot(Minecraft mcIn, int width, int height, int topIn, int bottomIn, int slotHeightIn)
|
| 65 | {
|
| 66 | this.mc = mcIn;
|
| 67 | this.width = width;
|
| 68 | this.height = height;
|
| 69 | this.top = topIn;
|
| 70 | this.bottom = bottomIn;
|
| 71 | this.slotHeight = slotHeightIn;
|
| 72 | this.left = 0;
|
| 73 | this.right = width;
|
| 74 | }
|
| 75 |
|
| 76 | public void setDimensions(int widthIn, int heightIn, int topIn, int bottomIn)
|
| 77 | {
|
| 78 | this.width = widthIn;
|
| 79 | this.height = heightIn;
|
| 80 | this.top = topIn;
|
| 81 | this.bottom = bottomIn;
|
| 82 | this.left = 0;
|
| 83 | this.right = widthIn;
|
| 84 | }
|
| 85 |
|
| 86 | public void setShowSelectionBox(boolean showSelectionBoxIn)
|
| 87 | {
|
| 88 | this.showSelectionBox = showSelectionBoxIn;
|
| 89 | }
|
| 90 |
|
| 91 | /**
|
| 92 | * Sets hasListHeader and headerHeight. Params: hasListHeader, headerHeight. If hasListHeader is false headerHeight
|
| 93 | * is set to 0.
|
| 94 | */
|
| 95 | protected void setHasListHeader(boolean hasListHeaderIn, int headerPaddingIn)
|
| 96 | {
|
| 97 | this.hasListHeader = hasListHeaderIn;
|
| 98 | this.headerPadding = headerPaddingIn;
|
| 99 |
|
| 100 | if (!hasListHeaderIn)
|
| 101 | {
|
| 102 | this.headerPadding = 0;
|
| 103 | }
|
| 104 | }
|
| 105 |
|
| 106 | protected abstract int getSize();
|
| 107 |
|
| 108 | /**
|
| 109 | * The element in the slot that was clicked, boolean for whether it was double clicked or not
|
| 110 | */
|
| 111 | protected abstract void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY);
|
| 112 |
|
| 113 | /**
|
| 114 | * Returns true if the element passed in is currently selected
|
| 115 | */
|
| 116 | protected abstract boolean isSelected(int slotIndex);
|
| 117 |
|
| 118 | /**
|
| 119 | * Return the height of the content being scrolled
|
| 120 | */
|
| 121 | protected int getContentHeight()
|
| 122 | {
|
| 123 | return this.getSize() * this.slotHeight + this.headerPadding;
|
| 124 | }
|
| 125 |
|
| 126 | protected abstract void drawBackground();
|
| 127 |
|
| 128 | protected void func_178040_a(int p_178040_1_, int p_178040_2_, int p_178040_3_)
|
| 129 | {
|
| 130 | }
|
| 131 |
|
| 132 | protected abstract void drawSlot(int entryID, int p_180791_2_, int p_180791_3_, int p_180791_4_, int mouseXIn, int mouseYIn);
|
| 133 |
|
| 134 | /**
|
| 135 | * Handles drawing a list's header row.
|
| 136 | */
|
| 137 | protected void drawListHeader(int p_148129_1_, int p_148129_2_, Tessellator p_148129_3_)
|
| 138 | {
|
| 139 | }
|
| 140 |
|
| 141 | protected void func_148132_a(int p_148132_1_, int p_148132_2_)
|
| 142 | {
|
| 143 | }
|
| 144 |
|
| 145 | protected void func_148142_b(int p_148142_1_, int p_148142_2_)
|
| 146 | {
|
| 147 | }
|
| 148 |
|
| 149 | public int getSlotIndexFromScreenCoords(int p_148124_1_, int p_148124_2_)
|
| 150 | {
|
| 151 | int i = this.left + this.width / 2 - this.getListWidth() / 2;
|
| 152 | int j = this.left + this.width / 2 + this.getListWidth() / 2;
|
| 153 | int k = p_148124_2_ - this.top - this.headerPadding + (int)this.amountScrolled - 4;
|
| 154 | int l = k / this.slotHeight;
|
| 155 | return p_148124_1_ < this.getScrollBarX() && p_148124_1_ >= i && p_148124_1_ <= j && l >= 0 && k >= 0 && l < this.getSize() ? l : -1;
|
| 156 | }
|
| 157 |
|
| 158 | /**
|
| 159 | * Registers the IDs that can be used for the scrollbar's up/down buttons.
|
| 160 | */
|
| 161 | public void registerScrollButtons(int scrollUpButtonIDIn, int scrollDownButtonIDIn)
|
| 162 | {
|
| 163 | this.scrollUpButtonID = scrollUpButtonIDIn;
|
| 164 | this.scrollDownButtonID = scrollDownButtonIDIn;
|
| 165 | }
|
| 166 |
|
| 167 | /**
|
| 168 | * Stop the thing from scrolling out of bounds
|
| 169 | */
|
| 170 | protected void bindAmountScrolled()
|
| 171 | {
|
| 172 | this.amountScrolled = MathHelper.clamp_float(this.amountScrolled, 0.0F, (float)this.func_148135_f());
|
| 173 | }
|
| 174 |
|
| 175 | public int func_148135_f()
|
| 176 | {
|
| 177 | return Math.max(0, this.getContentHeight() - (this.bottom - this.top - 4));
|
| 178 | }
|
| 179 |
|
| 180 | /**
|
| 181 | * Returns the amountScrolled field as an integer.
|
| 182 | */
|
| 183 | public int getAmountScrolled()
|
| 184 | {
|
| 185 | return (int)this.amountScrolled;
|
| 186 | }
|
| 187 |
|
| 188 | public boolean isMouseYWithinSlotBounds(int p_148141_1_)
|
| 189 | {
|
| 190 | return p_148141_1_ >= this.top && p_148141_1_ <= this.bottom && this.mouseX >= this.left && this.mouseX <= this.right;
|
| 191 | }
|
| 192 |
|
| 193 | /**
|
| 194 | * Scrolls the slot by the given amount. A positive value scrolls down, and a negative value scrolls up.
|
| 195 | */
|
| 196 | public void scrollBy(int amount)
|
| 197 | {
|
| 198 | this.amountScrolled += (float)amount;
|
| 199 | this.bindAmountScrolled();
|
| 200 | this.initialClickY = -2;
|
| 201 | }
|
| 202 |
|
| 203 | public void actionPerformed(GuiButton button)
|
| 204 | {
|
| 205 | if (button.enabled)
|
| 206 | {
|
| 207 | if (button.id == this.scrollUpButtonID)
|
| 208 | {
|
| 209 | this.amountScrolled -= (float)(this.slotHeight * 2 / 3);
|
| 210 | this.initialClickY = -2;
|
| 211 | this.bindAmountScrolled();
|
| 212 | }
|
| 213 | else if (button.id == this.scrollDownButtonID)
|
| 214 | {
|
| 215 | this.amountScrolled += (float)(this.slotHeight * 2 / 3);
|
| 216 | this.initialClickY = -2;
|
| 217 | this.bindAmountScrolled();
|
| 218 | }
|
| 219 | }
|
| 220 | }
|
| 221 |
|
| 222 | public void drawScreen(int mouseXIn, int mouseYIn, float p_148128_3_)
|
| 223 | {
|
| 224 | if (this.field_178041_q)
|
| 225 | {
|
| 226 | this.mouseX = mouseXIn;
|
| 227 | this.mouseY = mouseYIn;
|
| 228 | this.drawBackground();
|
| 229 | int i = this.getScrollBarX();
|
| 230 | int j = i + 6;
|
| 231 | this.bindAmountScrolled();
|
| 232 | GlStateManager.disableLighting();
|
| 233 | GlStateManager.disableFog();
|
| 234 | Tessellator tessellator = Tessellator.getInstance();
|
| 235 | WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
| 236 | this.mc.getTextureManager().bindTexture(Gui.optionsBackground);
|
| 237 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
| 238 | float f = 32.0F;
|
| 239 | worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
| 240 | worldrenderer.pos((double)this.left, (double)this.bottom, 0.0D).tex((double)((float)this.left / f), (double)((float)(this.bottom + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex();
|
| 241 | worldrenderer.pos((double)this.right, (double)this.bottom, 0.0D).tex((double)((float)this.right / f), (double)((float)(this.bottom + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex();
|
| 242 | worldrenderer.pos((double)this.right, (double)this.top, 0.0D).tex((double)((float)this.right / f), (double)((float)(this.top + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex();
|
| 243 | worldrenderer.pos((double)this.left, (double)this.top, 0.0D).tex((double)((float)this.left / f), (double)((float)(this.top + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex();
|
| 244 | tessellator.draw();
|
| 245 | int k = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
|
| 246 | int l = this.top + 4 - (int)this.amountScrolled;
|
| 247 |
|
| 248 | if (this.hasListHeader)
|
| 249 | {
|
| 250 | this.drawListHeader(k, l, tessellator);
|
| 251 | }
|
| 252 |
|
| 253 | this.drawSelectionBox(k, l, mouseXIn, mouseYIn);
|
| 254 | GlStateManager.disableDepth();
|
| 255 | int i1 = 4;
|
| 256 | this.overlayBackground(0, this.top, 255, 255);
|
| 257 | this.overlayBackground(this.bottom, this.height, 255, 255);
|
| 258 | GlStateManager.enableBlend();
|
| 259 | GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1);
|
| 260 | GlStateManager.disableAlpha();
|
| 261 | GlStateManager.shadeModel(7425);
|
| 262 | GlStateManager.disableTexture2D();
|
| 263 | worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
| 264 | worldrenderer.pos((double)this.left, (double)(this.top + i1), 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 0).endVertex();
|
| 265 | worldrenderer.pos((double)this.right, (double)(this.top + i1), 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 0).endVertex();
|
| 266 | worldrenderer.pos((double)this.right, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
| 267 | worldrenderer.pos((double)this.left, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
| 268 | tessellator.draw();
|
| 269 | worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
| 270 | worldrenderer.pos((double)this.left, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
| 271 | worldrenderer.pos((double)this.right, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
| 272 | worldrenderer.pos((double)this.right, (double)(this.bottom - i1), 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 0).endVertex();
|
| 273 | worldrenderer.pos((double)this.left, (double)(this.bottom - i1), 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 0).endVertex();
|
| 274 | tessellator.draw();
|
| 275 | int j1 = this.func_148135_f();
|
| 276 |
|
| 277 | if (j1 > 0)
|
| 278 | {
|
| 279 | int k1 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
|
| 280 | k1 = MathHelper.clamp_int(k1, 32, this.bottom - this.top - 8);
|
| 281 | int l1 = (int)this.amountScrolled * (this.bottom - this.top - k1) / j1 + this.top;
|
| 282 |
|
| 283 | if (l1 < this.top)
|
| 284 | {
|
| 285 | l1 = this.top;
|
| 286 | }
|
| 287 |
|
| 288 | worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
| 289 | worldrenderer.pos((double)i, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
| 290 | worldrenderer.pos((double)j, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
| 291 | worldrenderer.pos((double)j, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
| 292 | worldrenderer.pos((double)i, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
| 293 | tessellator.draw();
|
| 294 | worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
| 295 | worldrenderer.pos((double)i, (double)(l1 + k1), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
| 296 | worldrenderer.pos((double)j, (double)(l1 + k1), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
| 297 | worldrenderer.pos((double)j, (double)l1, 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
| 298 | worldrenderer.pos((double)i, (double)l1, 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
| 299 | tessellator.draw();
|
| 300 | worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
| 301 | worldrenderer.pos((double)i, (double)(l1 + k1 - 1), 0.0D).tex(0.0D, 1.0D).color(192, 192, 192, 255).endVertex();
|
| 302 | worldrenderer.pos((double)(j - 1), (double)(l1 + k1 - 1), 0.0D).tex(1.0D, 1.0D).color(192, 192, 192, 255).endVertex();
|
| 303 | worldrenderer.pos((double)(j - 1), (double)l1, 0.0D).tex(1.0D, 0.0D).color(192, 192, 192, 255).endVertex();
|
| 304 | worldrenderer.pos((double)i, (double)l1, 0.0D).tex(0.0D, 0.0D).color(192, 192, 192, 255).endVertex();
|
| 305 | tessellator.draw();
|
| 306 | }
|
| 307 |
|
| 308 | this.func_148142_b(mouseXIn, mouseYIn);
|
| 309 | GlStateManager.enableTexture2D();
|
| 310 | GlStateManager.shadeModel(7424);
|
| 311 | GlStateManager.enableAlpha();
|
| 312 | GlStateManager.disableBlend();
|
| 313 | }
|
| 314 | }
|
| 315 |
|
| 316 | public void handleMouseInput()
|
| 317 | {
|
| 318 | if (this.isMouseYWithinSlotBounds(this.mouseY))
|
| 319 | {
|
| 320 | if (Mouse.getEventButton() == 0 && Mouse.getEventButtonState() && this.mouseY >= this.top && this.mouseY <= this.bottom)
|
| 321 | {
|
| 322 | int i = (this.width - this.getListWidth()) / 2;
|
| 323 | int j = (this.width + this.getListWidth()) / 2;
|
| 324 | int k = this.mouseY - this.top - this.headerPadding + (int)this.amountScrolled - 4;
|
| 325 | int l = k / this.slotHeight;
|
| 326 |
|
| 327 | if (l < this.getSize() && this.mouseX >= i && this.mouseX <= j && l >= 0 && k >= 0)
|
| 328 | {
|
| 329 | this.elementClicked(l, false, this.mouseX, this.mouseY);
|
| 330 | this.selectedElement = l;
|
| 331 | }
|
| 332 | else if (this.mouseX >= i && this.mouseX <= j && k < 0)
|
| 333 | {
|
| 334 | this.func_148132_a(this.mouseX - i, this.mouseY - this.top + (int)this.amountScrolled - 4);
|
| 335 | }
|
| 336 | }
|
| 337 |
|
| 338 | if (Mouse.isButtonDown(0) && this.getEnabled())
|
| 339 | {
|
| 340 | if (this.initialClickY == -1)
|
| 341 | {
|
| 342 | boolean flag1 = true;
|
| 343 |
|
| 344 | if (this.mouseY >= this.top && this.mouseY <= this.bottom)
|
| 345 | {
|
| 346 | int j2 = (this.width - this.getListWidth()) / 2;
|
| 347 | int k2 = (this.width + this.getListWidth()) / 2;
|
| 348 | int l2 = this.mouseY - this.top - this.headerPadding + (int)this.amountScrolled - 4;
|
| 349 | int i1 = l2 / this.slotHeight;
|
| 350 |
|
| 351 | if (i1 < this.getSize() && this.mouseX >= j2 && this.mouseX <= k2 && i1 >= 0 && l2 >= 0)
|
| 352 | {
|
| 353 | boolean flag = i1 == this.selectedElement && Minecraft.getSystemTime() - this.lastClicked < 250L;
|
| 354 | this.elementClicked(i1, flag, this.mouseX, this.mouseY);
|
| 355 | this.selectedElement = i1;
|
| 356 | this.lastClicked = Minecraft.getSystemTime();
|
| 357 | }
|
| 358 | else if (this.mouseX >= j2 && this.mouseX <= k2 && l2 < 0)
|
| 359 | {
|
| 360 | this.func_148132_a(this.mouseX - j2, this.mouseY - this.top + (int)this.amountScrolled - 4);
|
| 361 | flag1 = false;
|
| 362 | }
|
| 363 |
|
| 364 | int i3 = this.getScrollBarX();
|
| 365 | int j1 = i3 + 6;
|
| 366 |
|
| 367 | if (this.mouseX >= i3 && this.mouseX <= j1)
|
| 368 | {
|
| 369 | this.scrollMultiplier = -1.0F;
|
| 370 | int k1 = this.func_148135_f();
|
| 371 |
|
| 372 | if (k1 < 1)
|
| 373 | {
|
| 374 | k1 = 1;
|
| 375 | }
|
| 376 |
|
| 377 | int l1 = (int)((float)((this.bottom - this.top) * (this.bottom - this.top)) / (float)this.getContentHeight());
|
| 378 | l1 = MathHelper.clamp_int(l1, 32, this.bottom - this.top - 8);
|
| 379 | this.scrollMultiplier /= (float)(this.bottom - this.top - l1) / (float)k1;
|
| 380 | }
|
| 381 | else
|
| 382 | {
|
| 383 | this.scrollMultiplier = 1.0F;
|
| 384 | }
|
| 385 |
|
| 386 | if (flag1)
|
| 387 | {
|
| 388 | this.initialClickY = this.mouseY;
|
| 389 | }
|
| 390 | else
|
| 391 | {
|
| 392 | this.initialClickY = -2;
|
| 393 | }
|
| 394 | }
|
| 395 | else
|
| 396 | {
|
| 397 | this.initialClickY = -2;
|
| 398 | }
|
| 399 | }
|
| 400 | else if (this.initialClickY >= 0)
|
| 401 | {
|
| 402 | this.amountScrolled -= (float)(this.mouseY - this.initialClickY) * this.scrollMultiplier;
|
| 403 | this.initialClickY = this.mouseY;
|
| 404 | }
|
| 405 | }
|
| 406 | else
|
| 407 | {
|
| 408 | this.initialClickY = -1;
|
| 409 | }
|
| 410 |
|
| 411 | int i2 = Mouse.getEventDWheel();
|
| 412 |
|
| 413 | if (i2 != 0)
|
| 414 | {
|
| 415 | if (i2 > 0)
|
| 416 | {
|
| 417 | i2 = -1;
|
| 418 | }
|
| 419 | else if (i2 < 0)
|
| 420 | {
|
| 421 | i2 = 1;
|
| 422 | }
|
| 423 |
|
| 424 | this.amountScrolled += (float)(i2 * this.slotHeight / 2);
|
| 425 | }
|
| 426 | }
|
| 427 | }
|
| 428 |
|
| 429 | public void setEnabled(boolean enabledIn)
|
| 430 | {
|
| 431 | this.enabled = enabledIn;
|
| 432 | }
|
| 433 |
|
| 434 | public boolean getEnabled()
|
| 435 | {
|
| 436 | return this.enabled;
|
| 437 | }
|
| 438 |
|
| 439 | /**
|
| 440 | * Gets the width of the list
|
| 441 | */
|
| 442 | public int getListWidth()
|
| 443 | {
|
| 444 | return 220;
|
| 445 | }
|
| 446 |
|
| 447 | /**
|
| 448 | * Draws the selection box around the selected slot element.
|
| 449 | */
|
| 450 | protected void drawSelectionBox(int p_148120_1_, int p_148120_2_, int mouseXIn, int mouseYIn)
|
| 451 | {
|
| 452 | int i = this.getSize();
|
| 453 | Tessellator tessellator = Tessellator.getInstance();
|
| 454 | WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
| 455 |
|
| 456 | for (int j = 0; j < i; ++j)
|
| 457 | {
|
| 458 | int k = p_148120_2_ + j * this.slotHeight + this.headerPadding;
|
| 459 | int l = this.slotHeight - 4;
|
| 460 |
|
| 461 | if (k > this.bottom || k + l < this.top)
|
| 462 | {
|
| 463 | this.func_178040_a(j, p_148120_1_, k);
|
| 464 | }
|
| 465 |
|
| 466 | if (this.showSelectionBox && this.isSelected(j))
|
| 467 | {
|
| 468 | int i1 = this.left + (this.width / 2 - this.getListWidth() / 2);
|
| 469 | int j1 = this.left + this.width / 2 + this.getListWidth() / 2;
|
| 470 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
| 471 | GlStateManager.disableTexture2D();
|
| 472 | worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
| 473 | worldrenderer.pos((double)i1, (double)(k + l + 2), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
| 474 | worldrenderer.pos((double)j1, (double)(k + l + 2), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
| 475 | worldrenderer.pos((double)j1, (double)(k - 2), 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
| 476 | worldrenderer.pos((double)i1, (double)(k - 2), 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
| 477 | worldrenderer.pos((double)(i1 + 1), (double)(k + l + 1), 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
| 478 | worldrenderer.pos((double)(j1 - 1), (double)(k + l + 1), 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
| 479 | worldrenderer.pos((double)(j1 - 1), (double)(k - 1), 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
| 480 | worldrenderer.pos((double)(i1 + 1), (double)(k - 1), 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
| 481 | tessellator.draw();
|
| 482 | GlStateManager.enableTexture2D();
|
| 483 | }
|
| 484 |
|
| 485 | this.drawSlot(j, p_148120_1_, k, l, mouseXIn, mouseYIn);
|
| 486 | }
|
| 487 | }
|
| 488 |
|
| 489 | protected int getScrollBarX()
|
| 490 | {
|
| 491 | return this.width / 2 + 124;
|
| 492 | }
|
| 493 |
|
| 494 | /**
|
| 495 | * Overlays the background to hide scrolled items
|
| 496 | */
|
| 497 | protected void overlayBackground(int startY, int endY, int startAlpha, int endAlpha)
|
| 498 | {
|
| 499 | Tessellator tessellator = Tessellator.getInstance();
|
| 500 | WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
| 501 | this.mc.getTextureManager().bindTexture(Gui.optionsBackground);
|
| 502 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
| 503 | float f = 32.0F;
|
| 504 | worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
| 505 | worldrenderer.pos((double)this.left, (double)endY, 0.0D).tex(0.0D, (double)((float)endY / 32.0F)).color(64, 64, 64, endAlpha).endVertex();
|
| 506 | worldrenderer.pos((double)(this.left + this.width), (double)endY, 0.0D).tex((double)((float)this.width / 32.0F), (double)((float)endY / 32.0F)).color(64, 64, 64, endAlpha).endVertex();
|
| 507 | worldrenderer.pos((double)(this.left + this.width), (double)startY, 0.0D).tex((double)((float)this.width / 32.0F), (double)((float)startY / 32.0F)).color(64, 64, 64, startAlpha).endVertex();
|
| 508 | worldrenderer.pos((double)this.left, (double)startY, 0.0D).tex(0.0D, (double)((float)startY / 32.0F)).color(64, 64, 64, startAlpha).endVertex();
|
| 509 | tessellator.draw();
|
| 510 | }
|
| 511 |
|
| 512 | /**
|
| 513 | * Sets the left and right bounds of the slot. Param is the left bound, right is calculated as left + width.
|
| 514 | */
|
| 515 | public void setSlotXBoundsFromLeft(int leftIn)
|
| 516 | {
|
| 517 | this.left = leftIn;
|
| 518 | this.right = leftIn + this.width;
|
| 519 | }
|
| 520 |
|
| 521 | public int getSlotHeight()
|
| 522 | {
|
| 523 | return this.slotHeight;
|
| 524 | }
|
| 525 | }
|
| 526 |
|