Created
July 29, 2019 00:51
-
-
Save xtrm-en/72bfc68f9c71c3d1d07aaccd9011d89b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.xtrm.E_xTrM.ui.tabgui; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.Comparator; | |
import org.lwjgl.input.Keyboard; | |
import me.xtrm.E_xTrM.E_xTrM; | |
import me.xtrm.E_xTrM.module.Module; | |
import me.xtrm.E_xTrM.module.Module.Category; | |
import me.xtrm.E_xTrM.utils.ColorUtil; | |
import me.xtrm.E_xTrM.utils.Wrapper; | |
import net.minecraft.client.gui.Gui; | |
public class TabGuiNew extends Gui { | |
public static int selectedCat = 0; | |
public static int selectedMod = 0; | |
public static int catTargetY = 0; | |
public static int modTargetY = 0; | |
public static int modSelectorX = 0, modSelectorY = -666; | |
public static int x, y, width, height; | |
public static int catSelectorX = 0, catSelectorY = -666; | |
public static Category selectedCategory; | |
public static boolean collapsed = false; | |
public static TabGuiNew theTabGui = new TabGuiNew(); | |
public static ArrayList<Module> modules = new ArrayList<Module>(); | |
public void drawTabGui(){ | |
x = 3; | |
y = Wrapper.gsu(E_xTrM.modManager.getModule("HUD"), "Watermark").bool() ? 25 : 3; | |
width = 72; | |
height = 12; | |
catSelectorX = x + 1; | |
int modX = x + width + 2; | |
int catCount = 0; | |
for(Category c : Category.values()){ | |
if(!c.name().equalsIgnoreCase("GENERAL") && !c.name().equalsIgnoreCase("GUI") && !c.name().equalsIgnoreCase("DEV")){ | |
catCount++; | |
} | |
} | |
if(selectedCat > catCount - 1){ | |
selectedCat = 0; | |
} | |
if(selectedCat < 0){ | |
selectedCat = catCount - 1; | |
} | |
selectedCategory = Category.values()[selectedCat]; | |
catTargetY = y + (selectedCat * height); | |
if(catSelectorY == -666) | |
catSelectorY = catTargetY; | |
// ChatUtils.sendMessage(""); | |
// ChatUtils.sendMessage(""); | |
// ChatUtils.sendMessage(""); | |
// ChatUtils.sendMessage(""); | |
// ChatUtils.sendMessage("catTargetY = " + catTargetY); | |
// ChatUtils.sendMessage("y = " + y); | |
// ChatUtils.sendMessage("selectedCat = " + selectedCat); | |
// ChatUtils.sendMessage("height = " + height); | |
if(catSelectorY < catTargetY){ | |
catSelectorY++; | |
} | |
if(catSelectorY > catTargetY){ | |
catSelectorY--; | |
} | |
if(catSelectorY < catTargetY){ | |
catSelectorY++; | |
} | |
if(catSelectorY > catTargetY){ | |
catSelectorY--; | |
} | |
if(catSelectorY < catTargetY){ | |
catSelectorY++; | |
} | |
if(catSelectorY > catTargetY){ | |
catSelectorY--; | |
} | |
if(catSelectorY < catTargetY){ | |
catSelectorY++; | |
} | |
if(catSelectorY > catTargetY){ | |
catSelectorY--; | |
} | |
int count1 = 0; | |
for(Category c : Category.values()){ | |
if(!c.name().equalsIgnoreCase("GENERAL") && !c.name().equalsIgnoreCase("GUI") && !c.name().equalsIgnoreCase("DEV")){ | |
drawRect(x, y + (count1 * height), x + width, y + (count1 + 1) * height, 0x55000000); | |
count1++; | |
} | |
} | |
// CategorySelector | |
drawRect(catSelectorX, catSelectorY + 1, width + 2, catSelectorY + (height - 1), ColorUtil.getClickGUIColor().getRGB()); | |
int count2 = 0; | |
for(Category c : Category.values()){ | |
if(!c.name().equalsIgnoreCase("GENERAL") && !c.name().equalsIgnoreCase("GUI") && !c.name().equalsIgnoreCase("DEV")){ | |
String name = c.name().substring(0, 1).toUpperCase() + c.name().substring(1).toLowerCase(); | |
Wrapper.fr.drawStringWithShadow(name, x + (Category.values()[selectedCat].name().equalsIgnoreCase(c.name()) ? 6 : 3), y + (count2 * height) + 2, 0xFFFFFF); | |
count2++; | |
} | |
} | |
if(collapsed){ | |
int modCount = 0; | |
int maxWidth = 0; | |
Collections.sort(E_xTrM.modManager.getMods(), new Comparator<Module>() | |
{ | |
public int compare(Module m1, Module m2) | |
{ | |
if (Wrapper.fr.getStringWidth(m1.getName()) > Wrapper.fr.getStringWidth(m2.getName())) { | |
return -1; | |
} | |
if (Wrapper.fr.getStringWidth(m1.getName()) < Wrapper.fr.getStringWidth(m2.getName())) { | |
return 1; | |
} | |
return 0; | |
} | |
}); | |
modules.clear(); | |
for(Module m : E_xTrM.INSTANCE.modManager.getMods()){ | |
if(m.getCategory() == selectedCategory){ | |
modules.add(m); | |
} | |
} | |
for(Module m : modules){ | |
if(m.isCategory(selectedCategory)){ | |
if(Wrapper.fr.getStringWidth(m.getName()) > maxWidth){ | |
maxWidth = Wrapper.fr.getStringWidth(m.getName()); | |
} | |
modCount++; | |
} | |
} | |
maxWidth += 10; | |
if(selectedMod > modCount - 1){ | |
selectedMod = 0; | |
} | |
if(selectedMod < 0){ | |
selectedMod = modCount - 1; | |
} | |
int selectedCatY = selectedCat * height; | |
modTargetY = y + selectedCatY + (selectedMod * height); | |
if(modSelectorY < modTargetY){ | |
modSelectorY++; | |
} | |
if(modSelectorY > modTargetY){ | |
modSelectorY--; | |
} | |
if(modSelectorY < modTargetY){ | |
modSelectorY++; | |
} | |
if(modSelectorY > modTargetY){ | |
modSelectorY--; | |
} | |
if(modSelectorY < modTargetY){ | |
modSelectorY++; | |
} | |
if(modSelectorY > modTargetY){ | |
modSelectorY--; | |
} | |
if(modSelectorY < modTargetY){ | |
modSelectorY++; | |
} | |
if(modSelectorY > modTargetY){ | |
modSelectorY--; | |
} | |
int count3 = 0; | |
for(Module m : modules){ | |
if(m.isCategory(selectedCategory)){ | |
drawRect(modX, y + selectedCatY + (count3 * height), modX + maxWidth + 1, y + selectedCatY + (count3 + 1) * height, 0x55000000); | |
count3++; | |
} | |
} | |
// ModSelector | |
drawRect(modX + 1 + modSelectorX, modSelectorY + 1, modX + maxWidth, modSelectorY + (height - 1), ColorUtil.getClickGUIColor().getRGB()); | |
int count4 = 0; | |
for(Module m : modules){ | |
if(m.isCategory(selectedCategory)){ | |
Wrapper.fr.drawStringWithShadow((m.isEnabled() ? "§f" : "§7") + m.getName(), modX + (modules.get(selectedMod).getName().equalsIgnoreCase(m.getName()) ? 6 : 3), y + selectedCatY + (count4 * height) + 2, 0xFFFFFF); | |
count4++; | |
} | |
} | |
if(tog){ | |
tog = false; | |
modules.get(selectedMod).toggle(); | |
} | |
} | |
} | |
static boolean tog = false; | |
static boolean c = false; | |
static boolean c2 = false; | |
public static void key(int key){ | |
if(!collapsed){ | |
if(key == Keyboard.KEY_UP){ | |
selectedCat--; | |
} | |
if(key == Keyboard.KEY_DOWN){ | |
selectedCat++; | |
} | |
if(key == Keyboard.KEY_RETURN || key == Keyboard.KEY_RIGHT){ | |
collapsed = true; | |
modSelectorY = y + (selectedCat * height) + (selectedMod * height); | |
} | |
}else{ | |
if(key == Keyboard.KEY_UP){ | |
selectedMod--; | |
} | |
if(key == Keyboard.KEY_DOWN){ | |
selectedMod++; | |
} | |
if(key == Keyboard.KEY_RETURN || key == Keyboard.KEY_RIGHT){ | |
tog = true; | |
} | |
if(key == Keyboard.KEY_LEFT){ | |
collapsed = false; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment