Hey guys, today I'm going to present a simpler and more efficient way to go about displaying a text gui (for all of you out there that still use them).
Normally, you'd see that lots of people like to use something like this:
Now this is fine, but it can get quite tedious (plus it looks tacky) to add that for every one of your hacks. So instead you'd would want to find a way to draw them with only a short amount of code -- loops! In this case, the 'for' loop is your friend. So let's make a couple of arrays.
You're going to need two arrays; one for the booleans and one for the strings. So go ahead and set up the arrays in this fashion:
Remember, that you're also going to have to initialize those lists in the class before you actually start using them.
Okay; so now you probably see where I'm going at (hopefully) with these two lists. The first one holds the booleans and the second one holds the text that is to be drawed on the screen if that said boolean be true. Let's take a look at the loop code:
Code:
for (int p=0;p<guiHacksBool[showHackGUICurrentPage].length;p++) {
if (guiHacksBoolean[guiPage][p]) {
fontrenderer.drawStringWithShadow(guiHacksStr[guiPage][p], 2, 12+p*10, 0x00ff00);
} else {
fontrenderer.drawStringWithShadow(guiHacksStr[guiPage][p], 2, 12+p*10, 0xff0000);
}
}
If you study the code above, you'll soon realize that it's pretty simple. You set it up so that it cycles through the boolean list and then draws the matching string. In this case, 'guiPage' is a declared int that lets you know what "page" you're on in the arrays. I suggest adding a key toggle to add/subtract this value.
Well, that's pretty much the main idea. A tip: again, make sure to initialize the list (preferably by a different name as a final) so that you can access it by a key toggle (like that guiPage incrementer/decrementer). But you still have to leave the previous declaration so that your booleans don't always return their initial value.
I commend all who took their time to read through this tutorial because I enjoyed writing this. Good luck!
05-24-2012
InCapacitated
We would like to see a result screen shot, please put one.
Thanks.