Social Icons

Friday 25 May 2012

[TUTORIAL] ArrayList GUI

Please try to research more about ArrayList and it's built-in methods. I want to have some learning value to this tutorial, not just everyone copying and pasting to their client. But if you do, it's fine. --- http://download.oracle.com/javase/1.5.0/...yList.html

This is my first tutorial. Feedback appreciated (assuming it's constructive[/b]).

Recently I decided to switch over from just a basic GUI where all the hacks are listed, to an ArrayList. And I have to say it's now one of my new favorite types of GUI. So, I decided to share it with those who want to make it but don't know how.

REQUIREMENTS
  • Already have a toggle system
  • Basic knowledge of Java

In GuiIngame Java, you'll need create your ArrayList object. I've just decided to name mine guiArray; you can name yours something else.

Code:
private ArrayList guiArray = new ArrayList();

Now once you have your object, you need to go up to the code that toggles your hacks. Inside of your toggle code, add:

(Replace "yourhackvariable" with the variable of the hack your using, in this case I'm using a no item render hack)

Code:
if(yourhackvariable)
              {
                  mc.renderGlobal.loadRenderers();
                  guiArray.add("No-Items");
              }
              else
                {
                        if(guiArray.contains("No-Items"))
                    guiArray.remove(guiArray.indexOf("No-Items"));   
                }

For example, mine is:

Code:
    if(checkKey(23))
          {
              HideItemHack = !HideItemHack;
              if(HideItemHack)
              {
                  mc.renderGlobal.loadRenderers();
                  guiArray.add("No-Items");
              }
              else
                {
                        if(guiArray.contains("No-Items"))
  guiArray.remove(guiArray.indexOf("No-Items"));   
                }
          }

As you can see, if the hack is toggled ON: It adds an item to the ArrayList "No-Items", but if it's toggled OFF: It checks if the ArrayList contains "No-Items", if it does - then it removes it by checking the indexOf "No-Items" in the ArrayList guiArray, which returns the index (position/number) of "No-Items" in guiArray/your array list name.

Now to add all hacks that are on to the screen:
Code:
int lcd = 14;
        for(int guiInt = 0; guiInt < guiArray.size(); guiInt++)
      {
            fontrenderer.drawStringWithShadow("" + guiArray.get(guiInt), 2, lcd, 0xFBB917);
            lcd += 12;
        }
 
 
Credit To:-

No comments:

Post a Comment