@Override
  protected void actionPerformed(GuiButton button) {
    if (button.enabled) {
      switch (button.id) {
        case 0:
          if (rankList.selected != null) {
            MinerRank rank = rankList.selected;

            if (rankField != null) {
              rankField.setText(Integer.toString(rank.getRank()));
            }
          }

          mc.displayGuiScreen(parent);

          rankList.selected = null;
          rankList.scrollToTop();
          break;
        case 1:
          CaveConfigGui.detailInfo = detailInfo.isChecked();
          break;
        case 2:
          CaveConfigGui.instantFilter = instantFilter.isChecked();
          break;
      }
    }
  }
 /**
  * Prepare a text field for entry.
  *
  * @param field the field
  * @param length the maximum length of the string
  * @param text the initial text
  */
 private void initTextField(GuiTextField field, int length, String text) {
   field.setVisible(true);
   field.setMaxStringLength(length);
   field.setEnableBackgroundDrawing(true);
   field.setCanLoseFocus(true);
   field.setFocused(false);
   field.setText(text);
 }
  @Override
  protected void keyTyped(char c, int i) {
    searchBar.textboxKeyTyped(c, i);
    if (searchBar.isFocused()) {
      onSearch();
    }
    if (i == 1) {
      if (searchBar.isFocused()) {
        searchBar.setText("");
        searchBar.setFocused(false);
        onSearchBarInteract();
      } else {
        exitWithoutUpdate();

        this.mc.setIngameFocus();
      }
    }
    if (!searchBar.isFocused()) {
      GameSettings gameSettings = Minecraft.getMinecraft().gameSettings;
      if (i == Keyboard.KEY_R) {
        mc.getSoundHandler()
            .playSound(
                PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
        randomize();
      } else if (i == Keyboard.KEY_TAB || i == gameSettings.keyBindChat.getKeyCode()) {
        searchBar.setFocused(true);
        onSearchBarInteract();
      } else if (i == Keyboard.KEY_H
          && !(stand.hatName.equalsIgnoreCase("") && view == VIEW_HATS)) {
        mc.getSoundHandler()
            .playSound(
                PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
        toggleHatsColourizer();
      } else if (i == Keyboard.KEY_N && !stand.hatName.equalsIgnoreCase("")) {
        mc.getSoundHandler()
            .playSound(
                PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
        removeHat();
      }
      if (view == VIEW_HATS) {
        if ((i == gameSettings.keyBindLeft.getKeyCode() || i == Keyboard.KEY_LEFT)
            && pageNumber > 0) {
          mc.getSoundHandler()
              .playSound(
                  PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
          switchPage(true);
        } else if ((i == gameSettings.keyBindRight.getKeyCode() || i == Keyboard.KEY_RIGHT)
            && !((pageNumber + 1) * 6 >= hatsToShow.size())) {
          mc.getSoundHandler()
              .playSound(
                  PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
          switchPage(false);
        }
      }
    }
  }
  @Override
  public void initGui() {
    initGuiComponents();

    nameBox =
        new GuiTextField(mc.fontRenderer, spacing, 80 + spacing, width - spacing * 2, buttonHeight);
    nameBox.setText(clone.getFullEditedName());
    lastTickName = clone.getFullEditedName();
    Keyboard.enableRepeatEvents(true);
  }
 public void onSearchBarInteract() {
   if (searchBar.isFocused()) {
     searchBar.setTextColor(14737632);
     if (!hasClicked
         && searchBar
             .getText()
             .equalsIgnoreCase(StatCollector.translateToLocal("hats.gui.search"))) {
       hasClicked = true;
       searchBar.setText("");
       onSearch();
     }
   } else {
     searchBar.setTextColor(0xAAAAAA);
     if (searchBar.getText().equalsIgnoreCase("")) {
       hasClicked = false;
       searchBar.setText(StatCollector.translateToLocal("hats.gui.search"));
     }
   }
 }
 @Override
 public void updateScreen() {
   if (!lastTickName.equals(nameBox.getText())) {
     lastTickName = nameBox.getText();
     clone.setName(lastTickName);
     clone.getSyncer().sendValueToServer(Syncer.ID_NAME);
   } else if (!nameBox.isFocused() && !nameBox.getText().equals(clone.nameUnedited)) {
     nameBox.setText(clone.nameUnedited);
   }
   nameBox.updateCursorCounter();
 }
  public void toggleHatsColourizer() {
    view = view > VIEW_HATS ? VIEW_HATS : VIEW_COLOURIZER;

    hatsToShow = new ArrayList<String>(availableHats);
    Collections.sort(hatsToShow);

    searchBar.setText("");
    onSearchBarInteract();

    updateButtonList();
  }
  @Override
  public void actionPerformed(GuiButton button) {
    if (button.id == applyButton.id) {
      tile.getOptions().sendUpdate(uri, projectorWidth, projectorHeight, triggerRange, fadeRange);

      this.mc.displayGuiScreen((GuiScreen) null);
      this.mc.setIngameFocus();
    } else if (button.id == clearUriButton.id) {
      uriField.setText("");
      uriField.setFocused(true);
      uri = uriField.getText();
    }
  }
  @Override
  public void initGui() {
    super.initGui();

    if (stand == null) {
      mc.displayGuiScreen(null);
    } else {
      Keyboard.enableRepeatEvents(true);

      buttonList.clear();

      this.guiLeft = (this.width - this.xSize) / 2;
      this.guiTop = (this.height - this.ySize) / 2;

      buttonList.add(new GuiButton(ID_PAGE_LEFT, width / 2 - 6, height / 2 + 54, 20, 20, "<"));
      buttonList.add(new GuiButton(ID_PAGE_RIGHT, width / 2 + 62, height / 2 + 54, 20, 20, ">"));
      buttonList.add(
          new GuiButton(
              ID_DONE_SELECT, width / 2 + 16, height / 2 + 54, 44, 20, I18n.format("gui.done")));

      // 4, 5, 6, 7, 8 = taken.

      addToolButton(ID_NONE, 0);
      addToolButton(ID_HAT_COLOUR_SWAP, 1);
      addToolButton(ID_RANDOM, 2);

      buttonList.add(new GuiButton(ID_CLOSE, width - 22, 2, 20, 20, "X"));

      pageNumber = 0;

      if (!stand.hatName.equalsIgnoreCase("")) {
        for (int i = 0; i < hatsToShow.size(); i++) {
          String hatName = (String) hatsToShow.get(i);
          if (hatName.equalsIgnoreCase(stand.hatName)) {
            i -= i % 6;
            pageNumber = i / 6;
            break;
          }
        }
      }

      updateButtonList();

      searchBar =
          new GuiTextField(0, this.fontRendererObj, this.width / 2 - 65, height - 24, 150, 20);
      searchBar.setMaxStringLength(255);
      searchBar.setText(StatCollector.translateToLocal("hats.gui.search"));
      searchBar.setTextColor(0xAAAAAA);
      searchBar.setVisible(enabledSearchBar);
    }
  }
Exemple #10
0
 @Override // Opened and resized
 public void initGui() {
   super.initGui(); // I see this done a ton and I don't understand why
   // buttonNext = new GuiButton(1,);
   buttons.add(new GuiButton(0, 172, 410, 124, 20, "Previous"));
   buttons.add(new GuiButton(1, 296, 410, 124, 20, "Next"));
   buttons.add(new GuiButton(2, 504, 410, 248, 20, "Go"));
   int x = 3;
   for (int i = 98; i < 393; i += 20) {
     buttons.add(new GuiButton(x, 172, i, 248, 20, "Stuff " + x));
     x++;
   }
   x = 0;
   status.setCanLoseFocus(true);
   status.setText("Status Message");
   status.setFocused(false);
 }
Exemple #11
0
  @Override
  protected void mouseClicked(int par1, int par2, int par3) throws IOException {
    super.mouseClicked(par1, par2, par3);
    boolean flag =
        par1 >= (this.width / 2 - 65)
            && par1 < (this.width / 2 - 65) + this.width
            && par2 >= (height - 24)
            && par2 < (height - 24) + this.height;
    if (enabledSearchBar) {
      searchBar.mouseClicked(par1, par2, par3);

      if (par3 == 1 && flag) {
        searchBar.setText("");
        onSearch();
      }
      onSearchBarInteract();
    }
  }
 private void updateHeat(int delta) {
   if (textboxHeat != null) {
     int heat = 0;
     try {
       String value = textboxHeat.getText();
       if (!"".equals(value)) heat = Integer.parseInt(value);
     } catch (NumberFormatException e) {
       // do nothing
     }
     heat += delta;
     if (heat < 0) heat = 0;
     if (heat >= 1000000) heat = 1000000;
     if (thermo.getHeatLevel().intValue() != heat) {
       thermo.setHeatLevel(heat);
       ((NetworkManager) IC2.network.get()).initiateClientTileEntityEvent(thermo, heat);
     }
     textboxHeat.setText(new Integer(heat).toString());
   }
 }
Exemple #13
0
  @Override
  public void initGui() {

    // used to offset buttons
    int offSetX = 150;
    int offSetY = 250;

    int posX = (this.width) / 2;
    int posY = (this.height) / 2;
    this.buttonList.clear();

    System.out.println("The channel for this telepad is : " + te.TELEPORTCHANNEL);

    channelField = new GuiTextField(fontRendererObj, posX - 50, posY - 130, 150, 20);

    if (channelField != null) {
      channelField.setText(channelName);
      channelField.setMaxStringLength(50);
    }

    ArrayList<int[]> allCoords =
        TelepadWorldData.get(thePlayer.worldObj).getCoordsForChannel(te.TELEPORTCHANNEL);
    int c = allCoords.size();

    if (c < 1) {
      return;
    }

    for (int i = 0; i < c; i++) {
      String name = TelepadWorldData.get(thePlayer.worldObj).getPadName(allCoords.get(i));
      this.buttonList.add(
          new GuiButton(
              i, /*x*/
              posX - 200 + (i / 10 > 0 && i % 10 >= 0 ? 120 * (i / 10) : 0), /*y*/
              posY + ((i * 25)) - (i / 10 > 0 && i % 10 >= 0 ? (250 * (i / 10)) + 100 : 100),
              /*size*/ 100,
              20, /**/
              name));
    }

    this.buttonList.add(new GuiButton(EXIT_BUTTON, posX - 200, posY - 120, 20, 20, "X"));
  }
  @SuppressWarnings("unchecked")
  @Override
  public void initGui() {
    super.initGui();
    buttonList.clear();
    buttonList.add(new CompactButton(0, guiLeft + 47, guiTop + 20, 22, 12, "-1"));
    buttonList.add(new CompactButton(1, guiLeft + 47, guiTop + 31, 22, 12, "-10"));
    buttonList.add(new CompactButton(2, guiLeft + 12, guiTop + 20, 36, 12, "-100"));
    buttonList.add(new CompactButton(3, guiLeft + 12, guiTop + 31, 36, 12, "-1000"));
    buttonList.add(new CompactButton(4, guiLeft + 12, guiTop + 42, 57, 12, "-10000"));

    buttonList.add(new CompactButton(5, guiLeft + 122, guiTop + 20, 22, 12, "+1"));
    buttonList.add(new CompactButton(6, guiLeft + 122, guiTop + 31, 22, 12, "+10"));
    buttonList.add(new CompactButton(7, guiLeft + 143, guiTop + 20, 36, 12, "+100"));
    buttonList.add(new CompactButton(8, guiLeft + 143, guiTop + 31, 36, 12, "+1000"));
    buttonList.add(new CompactButton(9, guiLeft + 122, guiTop + 42, 57, 12, "+10000"));

    buttonList.add(new GuiThermoInvertRedstone(10, guiLeft + 70, guiTop + 38, thermo));

    textboxHeat = new GuiTextField(fontRendererObj, 70, 21, 51, 12);
    textboxHeat.setFocused(true);
    textboxHeat.setText(thermo.getHeatLevel().toString());
  }
  @Override
  protected void actionPerformed(GuiButton guibutton) {
    if (guibutton.enabled == false) {
      return;
    } else if (guibutton == doneButton) {
      WorldPropertiesManager manager =
          MCA.getInstance().playerWorldManagerMap.get(player.getCommandSenderName());

      // Assign babyName the string that is in the text field, trimmed of whitespace.
      manager.worldProperties.babyName = babyNameTextField.getText().trim();
      manager.saveWorldProperties();

      // Check if the player is married to another player.
      if (manager.worldProperties.playerSpouseID < 0) {
        MCA.packetPipeline.sendPacketToServer(new Packet(EnumPacketType.BabyInfo, manager));
      }

      // Close the GUI
      mc.displayGuiScreen(null);
    } else if (guibutton == randomButton) {
      babyNameTextField.setText(Utility.getRandomName(isMale));
      babyNameTextField.mouseClicked(5, 5, 5);
    }
  }
  @Override
  protected void actionPerformed(GuiButton guibutton) {
    if (guibutton.id == 1) { // change Attack Mobs
      if (player.getUniqueID().toString().equals(base.getOwner())) {
        sendChangeToServerMobs(!base.isAttacksMobs());
        guibutton.displayString =
            "Attack Mobs: " + (!base.isAttacksMobs() ? "\u00A72Yes" : "\u00A7cNo");
      } else if (base.getTrustedPlayer(player.getUniqueID()).canChangeTargeting) {
        sendChangeToServerMobs(!base.isAttacksMobs());
        guibutton.displayString =
            "Attack Mobs: " + (!base.isAttacksMobs() ? "\u00A72Yes" : "\u00A7cNo");
      } else {
        player.addChatMessage(
            new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
      }
    }

    if (guibutton.id == 2) { // change Attack Neutrals
      if (player.getUniqueID().toString().equals(base.getOwner())) {
        sendChangeToServerNeutrals(!base.isAttacksNeutrals());
        guibutton.displayString =
            "Attack Neutrals: " + (!base.isAttacksNeutrals() ? "\u00A72Yes" : "\u00A7cNo");
      } else if (base.getTrustedPlayer(player.getUniqueID()).canChangeTargeting) {
        sendChangeToServerNeutrals(!base.isAttacksNeutrals());
        guibutton.displayString =
            "Attack Neutrals: " + (!base.isAttacksNeutrals() ? "\u00A72Yes" : "\u00A7cNo");
      } else {
        player.addChatMessage(
            new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
      }
    }

    if (guibutton.id == 3) { // change Attack Players
      if (player.getUniqueID().toString().equals(base.getOwner())) {
        sendChangeToServerPlayers(!base.isAttacksPlayers());
        guibutton.displayString =
            "Attack Players: " + (!base.isAttacksPlayers() ? "\u00A72Yes" : "\u00A7cNo");
      } else if (base.getTrustedPlayer(player.getUniqueID()).canChangeTargeting) {
        sendChangeToServerPlayers(!base.isAttacksPlayers());
        guibutton.displayString =
            "Attack Players: " + (!base.isAttacksPlayers() ? "\u00A72Yes" : "\u00A7cNo");
      } else {
        player.addChatMessage(
            new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
      }
    }

    if (guibutton.id == 4) { // add trusted player
      if (player.getUniqueID().toString().equals(base.getOwner())) {
        if (!textFieldAddTrustedPlayer.getText().equals("")
            || !textFieldAddTrustedPlayer.getText().isEmpty()) {
          base.addTrustedPlayer(textFieldAddTrustedPlayer.getText());
          sendChangeToServerAddTrusted();
          textFieldAddTrustedPlayer.setText("");
          this.base.trustedPlayerIndex = 0;
          player.openGui(
              ModularTurrets.instance, 6, player.worldObj, base.xCoord, base.yCoord, base.zCoord);
        }
      } else if (base.getTrustedPlayer(player.getUniqueID()).admin) {
        if (!textFieldAddTrustedPlayer.getText().equals("")
            || !textFieldAddTrustedPlayer.getText().isEmpty()) {
          base.addTrustedPlayer(textFieldAddTrustedPlayer.getText());
          sendChangeToServerAddTrusted();
          textFieldAddTrustedPlayer.setText("");
          this.base.trustedPlayerIndex = 0;
          player.openGui(
              ModularTurrets.instance, 6, player.worldObj, base.xCoord, base.yCoord, base.zCoord);
        }
      } else {
        player.addChatMessage(
            new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
      }
    }

    if (guibutton.id == 5) { // remove trusted player
      if (base.getTrustedPlayers().size() > 0) {
        if (this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null
            && player.getUniqueID().toString().equals(base.getOwner())) {
          sendChangeToServerRemoveTrusted();
          base.removeTrustedPlayer(base.getTrustedPlayers().get(base.trustedPlayerIndex).getName());
          textFieldAddTrustedPlayer.setText("");
          this.base.trustedPlayerIndex = 0;
          player.openGui(
              ModularTurrets.instance, 6, player.worldObj, base.xCoord, base.yCoord, base.zCoord);
        } else if (base.getTrustedPlayer(player.getUniqueID()).admin) {
          if (this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null
              && this.base.getTrustedPlayers().size() > 0) {
            sendChangeToServerRemoveTrusted();
            base.removeTrustedPlayer(
                base.getTrustedPlayers().get(base.trustedPlayerIndex).getName());
            textFieldAddTrustedPlayer.setText("");
            this.base.trustedPlayerIndex = 0;
            if (this.base
                    .getTrustedPlayers()
                    .get(base.trustedPlayerIndex)
                    .uuid
                    .equals(player.getUniqueID())
                && !player.getUniqueID().toString().equals(base.getOwner())) {
              mc.displayGuiScreen(null);
              return;
            }
            player.openGui(
                ModularTurrets.instance, 6, player.worldObj, base.xCoord, base.yCoord, base.zCoord);
          }
        } else {
          player.addChatMessage(
              new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
        }
      }
    }

    if (guibutton.id == 6) { // decrease index of trusted player list
      if ((this.base.trustedPlayerIndex - 1 >= 0)) {
        this.base.trustedPlayerIndex--;
        player.openGui(
            ModularTurrets.instance, 6, player.worldObj, base.xCoord, base.yCoord, base.zCoord);
      }
    }

    if (guibutton.id == 7) { // increase index of trusted player list
      if (!((this.base.trustedPlayerIndex + 1) > (base.getTrustedPlayers().size() - 1))) {
        this.base.trustedPlayerIndex++;
        player.openGui(
            ModularTurrets.instance, 6, player.worldObj, base.xCoord, base.yCoord, base.zCoord);
      }
    }

    if (guibutton.id == 8) { // change trusted player permission for GUI opening
      if (player.getUniqueID().toString().equals(base.getOwner())
          && this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null) {
        sendChangeToServerModifyPermissions(
            this.base.getTrustedPlayers().get(base.trustedPlayerIndex).getName(),
            "gui",
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canOpenGUI);
        guibutton.displayString =
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canOpenGUI
                ? "\u00A72Y"
                : "\u00A7cN";
      } else if (this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null
          && base.getTrustedPlayer(player.getUniqueID()).admin) {
        sendChangeToServerModifyPermissions(
            this.base.getTrustedPlayers().get(base.trustedPlayerIndex).getName(),
            "gui",
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canOpenGUI);
        guibutton.displayString =
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canOpenGUI
                ? "\u00A72Y"
                : "\u00A7cN";
      } else {
        player.addChatMessage(
            new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
      }
    }

    if (guibutton.id == 9) { // change trusted player permission for targeting
      if (player.getUniqueID().toString().equals(base.getOwner())
          && this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null) {
        sendChangeToServerModifyPermissions(
            this.base.getTrustedPlayers().get(base.trustedPlayerIndex).getName(),
            "targeting",
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canChangeTargeting);
        guibutton.displayString =
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canChangeTargeting
                ? "\u00A72Y"
                : "\u00A7cN";
      } else if (this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null
          && base.getTrustedPlayer(player.getUniqueID()).admin) {
        sendChangeToServerModifyPermissions(
            this.base.getTrustedPlayers().get(base.trustedPlayerIndex).getName(),
            "targeting",
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canChangeTargeting);
        guibutton.displayString =
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).canChangeTargeting
                ? "\u00A72Y"
                : "\u00A7cN";
      } else {
        player.addChatMessage(
            new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
      }
    }

    if (guibutton.id == 10) { // change trusted player permission for administering
      if (player.getUniqueID().toString().equals(base.getOwner())
          && this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null) {
        sendChangeToServerModifyPermissions(
            this.base.getTrustedPlayers().get(base.trustedPlayerIndex).getName(),
            "isAdmin",
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).admin);
        guibutton.displayString =
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).admin ? "\u00A72Y" : "\u00A7cN";
      } else if (this.base.getTrustedPlayers().get(base.trustedPlayerIndex) != null
          && base.getTrustedPlayer(player.getUniqueID()).admin) {
        sendChangeToServerModifyPermissions(
            this.base.getTrustedPlayers().get(base.trustedPlayerIndex).getName(),
            "isAdmin",
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).admin);
        guibutton.displayString =
            !base.getTrustedPlayers().get(base.trustedPlayerIndex).admin ? "\u00A72Y" : "\u00A7cN";
      } else {
        player.addChatMessage(
            new ChatComponentText(StatCollector.translateToLocal("status.ownership")));
      }
    }
  }