| 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.ResourceLocation;
|
| 9 |
|
| 10 | public class GuiStreamIndicator
|
| 11 | {
|
| 12 | private static final ResourceLocation locationStreamIndicator = new ResourceLocation("textures/gui/stream_indicator.png");
|
| 13 | private final Minecraft mc;
|
| 14 | private float streamAlpha = 1.0F;
|
| 15 | private int streamAlphaDelta = 1;
|
| 16 |
|
| 17 | public GuiStreamIndicator(Minecraft mcIn)
|
| 18 | {
|
| 19 | this.mc = mcIn;
|
| 20 | }
|
| 21 |
|
| 22 | public void render(int p_152437_1_, int p_152437_2_)
|
| 23 | {
|
| 24 | if (this.mc.getTwitchStream().isBroadcasting())
|
| 25 | {
|
| 26 | GlStateManager.enableBlend();
|
| 27 | int i = this.mc.getTwitchStream().func_152920_A();
|
| 28 |
|
| 29 | if (i > 0)
|
| 30 | {
|
| 31 | String s = "" + i;
|
| 32 | int j = this.mc.fontRendererObj.getStringWidth(s);
|
| 33 | int k = 20;
|
| 34 | int l = p_152437_1_ - j - 1;
|
| 35 | int i1 = p_152437_2_ + 20 - 1;
|
| 36 | int j1 = p_152437_2_ + 20 + this.mc.fontRendererObj.FONT_HEIGHT - 1;
|
| 37 | GlStateManager.disableTexture2D();
|
| 38 | Tessellator tessellator = Tessellator.getInstance();
|
| 39 | WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
| 40 | GlStateManager.color(0.0F, 0.0F, 0.0F, (0.65F + 0.35000002F * this.streamAlpha) / 2.0F);
|
| 41 | worldrenderer.begin(7, DefaultVertexFormats.POSITION);
|
| 42 | worldrenderer.pos((double)l, (double)j1, 0.0D).endVertex();
|
| 43 | worldrenderer.pos((double)p_152437_1_, (double)j1, 0.0D).endVertex();
|
| 44 | worldrenderer.pos((double)p_152437_1_, (double)i1, 0.0D).endVertex();
|
| 45 | worldrenderer.pos((double)l, (double)i1, 0.0D).endVertex();
|
| 46 | tessellator.draw();
|
| 47 | GlStateManager.enableTexture2D();
|
| 48 | this.mc.fontRendererObj.drawString(s, p_152437_1_ - j, p_152437_2_ + 20, 16777215);
|
| 49 | }
|
| 50 |
|
| 51 | this.render(p_152437_1_, p_152437_2_, this.func_152440_b(), 0);
|
| 52 | this.render(p_152437_1_, p_152437_2_, this.func_152438_c(), 17);
|
| 53 | }
|
| 54 | }
|
| 55 |
|
| 56 | private void render(int p_152436_1_, int p_152436_2_, int p_152436_3_, int p_152436_4_)
|
| 57 | {
|
| 58 | GlStateManager.color(1.0F, 1.0F, 1.0F, 0.65F + 0.35000002F * this.streamAlpha);
|
| 59 | this.mc.getTextureManager().bindTexture(locationStreamIndicator);
|
| 60 | float f = 150.0F;
|
| 61 | float f1 = 0.0F;
|
| 62 | float f2 = (float)p_152436_3_ * 0.015625F;
|
| 63 | float f3 = 1.0F;
|
| 64 | float f4 = (float)(p_152436_3_ + 16) * 0.015625F;
|
| 65 | Tessellator tessellator = Tessellator.getInstance();
|
| 66 | WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
| 67 | worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
|
| 68 | worldrenderer.pos((double)(p_152436_1_ - 16 - p_152436_4_), (double)(p_152436_2_ + 16), (double)f).tex((double)f1, (double)f4).endVertex();
|
| 69 | worldrenderer.pos((double)(p_152436_1_ - p_152436_4_), (double)(p_152436_2_ + 16), (double)f).tex((double)f3, (double)f4).endVertex();
|
| 70 | worldrenderer.pos((double)(p_152436_1_ - p_152436_4_), (double)(p_152436_2_ + 0), (double)f).tex((double)f3, (double)f2).endVertex();
|
| 71 | worldrenderer.pos((double)(p_152436_1_ - 16 - p_152436_4_), (double)(p_152436_2_ + 0), (double)f).tex((double)f1, (double)f2).endVertex();
|
| 72 | tessellator.draw();
|
| 73 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
| 74 | }
|
| 75 |
|
| 76 | private int func_152440_b()
|
| 77 | {
|
| 78 | return this.mc.getTwitchStream().isPaused() ? 16 : 0;
|
| 79 | }
|
| 80 |
|
| 81 | private int func_152438_c()
|
| 82 | {
|
| 83 | return this.mc.getTwitchStream().func_152929_G() ? 48 : 32;
|
| 84 | }
|
| 85 |
|
| 86 | public void updateStreamAlpha()
|
| 87 | {
|
| 88 | if (this.mc.getTwitchStream().isBroadcasting())
|
| 89 | {
|
| 90 | this.streamAlpha += 0.025F * (float)this.streamAlphaDelta;
|
| 91 |
|
| 92 | if (this.streamAlpha < 0.0F)
|
| 93 | {
|
| 94 | this.streamAlphaDelta *= -1;
|
| 95 | this.streamAlpha = 0.0F;
|
| 96 | }
|
| 97 | else if (this.streamAlpha > 1.0F)
|
| 98 | {
|
| 99 | this.streamAlphaDelta *= -1;
|
| 100 | this.streamAlpha = 1.0F;
|
| 101 | }
|
| 102 | }
|
| 103 | else
|
| 104 | {
|
| 105 | this.streamAlpha = 1.0F;
|
| 106 | this.streamAlphaDelta = 1;
|
| 107 | }
|
| 108 | }
|
| 109 | }
|
| 110 |
|