public GuiDiskPopup(NormalMk2GuiOrderer mainGui) {
   super(150, 200, 0, 0);
   this.mainGui = mainGui;
   name2 = "";
   if (mainGui.getDisk().hasTagCompound()) {
     name1 = mainGui.getDisk().getTagCompound().getString("name");
   } else {
     name1 = "Disk";
   }
 }
 private void writeDiskName() {
   editname = false;
   MainProxy.sendPacketToServer(
       new PacketPipeString(
               NetworkConstants.DISK_SET_NAME,
               mainGui.pipe.xCoord,
               mainGui.pipe.yCoord,
               mainGui.pipe.zCoord,
               name1 + name2)
           .getPacket());
   NBTTagCompound nbt = new NBTTagCompound();
   if (mainGui.getDisk().hasTagCompound()) {
     nbt = mainGui.getDisk().getTagCompound();
   }
   nbt.setString("name", name1 + name2);
   mainGui.getDisk().setTagCompound(nbt);
 }
  @Override
  protected void actionPerformed(GuiButton guibutton) {
    if (guibutton.id == 0) {
      handleRequest();
    } else if (guibutton.id == 1) {
      this.exitGui();
    } else if (guibutton.id == 2) {
      this.setSubGui(new GuiAddMacro(mainGui));
    } else if (guibutton.id == 3) {
      NBTTagCompound nbt = mainGui.getDisk().getTagCompound();
      if (nbt == null) {
        mainGui.getDisk().setTagCompound(new NBTTagCompound());
        nbt = mainGui.getDisk().getTagCompound();
      }

      if (!nbt.hasKey("macroList")) {
        NBTTagList list = new NBTTagList();
        nbt.setTag("macroList", list);
      }

      NBTTagList list = nbt.getTagList("macroList");
      NBTTagList listnew = new NBTTagList();

      for (int i = 0; i < list.tagCount(); i++) {
        if (i != selected) {
          listnew.appendTag(list.tagAt(i));
        }
      }
      selected = -1;
      nbt.setTag("macroList", listnew);
    } else if (guibutton.id == 4) {
      if (scroll > 0) {
        scroll--;
      }
    } else if (guibutton.id == 5) {
      scroll++;
    } else {
      super.actionPerformed(guibutton);
    }
  }
  @Override
  public void drawScreen(int par1, int par2, float par3) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    BasicGuiHelper.drawGuiBackGround(mc, guiLeft, guiTop, right, bottom, zLevel, true);

    fontRenderer.drawStringWithShadow(
        "Disk", xCenter - (fontRenderer.getStringWidth("Disk") / 2), guiTop + 10, 0xFFFFFF);

    // NameInput
    if (editname) {
      drawRect(
          guiLeft + 10,
          guiTop + 28,
          right - 10,
          guiTop + 45,
          BasicGuiHelper.ConvertEnumToColor(Colors.Black));
      drawRect(
          guiLeft + 11,
          guiTop + 29,
          right - 11,
          guiTop + 44,
          BasicGuiHelper.ConvertEnumToColor(Colors.White));
    } else {
      drawRect(
          guiLeft + 11,
          guiTop + 29,
          right - 11,
          guiTop + 44,
          BasicGuiHelper.ConvertEnumToColor(Colors.Black));
    }
    drawRect(
        guiLeft + 12,
        guiTop + 30,
        right - 12,
        guiTop + 43,
        BasicGuiHelper.ConvertEnumToColor(Colors.DarkGrey));

    fontRenderer.drawString(name1 + name2, guiLeft + 15, guiTop + 33, 0xFFFFFF);

    drawRect(
        guiLeft + 6,
        guiTop + 46,
        right - 6,
        bottom - 30,
        BasicGuiHelper.ConvertEnumToColor(Colors.MiddleGrey));

    NBTTagCompound nbt = mainGui.getDisk().getTagCompound();
    if (nbt == null) {
      mainGui.getDisk().setTagCompound(new NBTTagCompound());
      nbt = mainGui.getDisk().getTagCompound();
    }

    if (!nbt.hasKey("macroList")) {
      NBTTagList list = new NBTTagList();
      nbt.setTag("macroList", list);
    }

    NBTTagList list = nbt.getTagList("macroList");

    if (scroll + 12 > list.tagCount()) {
      scroll = list.tagCount() - 12;
    }
    if (scroll < 0) {
      scroll = 0;
    }

    boolean flag = false;

    for (int i = scroll; i < list.tagCount() && (i - scroll) < 12; i++) {
      if (guiLeft + 8 < mouseX
          && mouseX < right - 8
          && guiTop + 48 + ((i - scroll) * 10) < mouseY
          && mouseY < guiTop + 59 + ((i - scroll) * 10)) {
        selected = i;
        mouseX = 0;
        mouseY = 0;
      }
      if (i == selected) {
        drawRect(
            guiLeft + 8,
            guiTop + 48 + ((i - scroll) * 10),
            right - 8,
            guiTop + 59 + ((i - scroll) * 10),
            BasicGuiHelper.ConvertEnumToColor(Colors.DarkGrey));
        flag = true;
      }
      NBTTagCompound entry = (NBTTagCompound) list.tagAt(i);
      String name = entry.getString("name");
      fontRenderer.drawString(name, guiLeft + 10, guiTop + 50 + ((i - scroll) * 10), 0xFFFFFF);
    }

    if (!flag) {
      selected = -1;
    }

    if (editname) {
      int linex = guiLeft + 15 + fontRenderer.getStringWidth(name1);
      if (System.currentTimeMillis() - oldSystemTime > 500) {
        displaycursor = !displaycursor;
        oldSystemTime = System.currentTimeMillis();
      }
      if (displaycursor) {
        drawRect(
            linex,
            guiTop + 31,
            linex + 1,
            guiTop + 42,
            BasicGuiHelper.ConvertEnumToColor(Colors.White));
      }
    }
    super.drawScreen(par1, par2, par3);
  }