Better formatting & save
This commit is contained in:
parent
78e73dc007
commit
e8947c3cff
|
@ -29,102 +29,80 @@ public class TabGui extends RenderMod {
|
|||
return Category.values().length * 16 + 4;
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
public void draw() {
|
||||
FontRenderer fr = mc.fontRendererObj;
|
||||
|
||||
int primaryColor = 0xffff69b4, secondaryColor = 0xffff46b4;
|
||||
|
||||
//original tab gui
|
||||
Gui.drawRect(5.5, 5.5f, 70, 5 + Mod.Category.values().length * 16 + 1.5, 0x90000000);
|
||||
Gui.drawRect(5.5, 5.5f + current * 16, 70, 13 + current * 16 + 7 + 2.5f, primaryColor);
|
||||
|
||||
|
||||
int count = 0;
|
||||
for (Category c : Mod.Category.values())
|
||||
{
|
||||
fr.drawStringWithShadow(c.name, 11, 10 + count*16, -1);
|
||||
for (Category c : Mod.Category.values()) {
|
||||
fr.drawStringWithShadow(c.name, 11, 10 + count * 16, -1);
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
//expansion
|
||||
if (expanded)
|
||||
{
|
||||
if (expanded) {
|
||||
Category category = Mod.Category.values()[current];
|
||||
List<Mod> modules = Resent.INSTANCE.modManager.modsInCategory(category);
|
||||
|
||||
if(modules.size() == 0)
|
||||
{
|
||||
if (modules.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Gui.drawRect(70, 5.5, 138, 5 + modules.size() * 16 + 1.5, 0x90000000);
|
||||
Gui.drawRect(70, 5.5 + category.i * 16, 138, 8 + category.i * 16 + 12 + 2.5F, primaryColor);
|
||||
|
||||
count = 0;
|
||||
for (Mod m : modules)
|
||||
{
|
||||
fr.drawStringWithShadow(m.getName(), 73, 10 + count*16, -1);
|
||||
for (Mod m : modules) {
|
||||
fr.drawStringWithShadow(m.getName(), 73, 10 + count * 16, -1);
|
||||
|
||||
if(count == category.i && m.expanded)
|
||||
{
|
||||
if (count == category.i && m.expanded) {
|
||||
|
||||
int index = 0, maxLength = 0;
|
||||
for (Setting setting : m.settings)
|
||||
{
|
||||
if(setting instanceof BooleanSetting)
|
||||
{
|
||||
for (Setting setting : m.settings) {
|
||||
if (setting instanceof BooleanSetting) {
|
||||
BooleanSetting bool = (BooleanSetting) setting;
|
||||
if(maxLength < fr.getStringWidth(setting.name + ": " + (bool.getValue() ? "Enabled" : "Disabled")))
|
||||
{
|
||||
maxLength = fr.getStringWidth(setting.name + ": " + (bool.getValue() ? "Enabled" : "Disabled"));
|
||||
if (maxLength < fr
|
||||
.getStringWidth(setting.name + ": " + (bool.getValue() ? "Enabled" : "Disabled"))) {
|
||||
maxLength = fr.getStringWidth(
|
||||
setting.name + ": " + (bool.getValue() ? "Enabled" : "Disabled"));
|
||||
}
|
||||
}
|
||||
|
||||
if(setting instanceof NumberSetting)
|
||||
{
|
||||
NumberSetting number = (NumberSetting) setting;
|
||||
if(maxLength < fr.getStringWidth(setting.name + ": " + number.getValue()))
|
||||
{
|
||||
maxLength = fr.getStringWidth(setting.name + ": " + number.getValue());
|
||||
}
|
||||
//fr.drawStringWithShadow(setting.name + ": " + number.getValue(), 73 + 68, 35 + index*16, -1);
|
||||
}
|
||||
|
||||
if(setting instanceof ModeSetting)
|
||||
{
|
||||
if (setting instanceof ModeSetting) {
|
||||
ModeSetting mode = (ModeSetting) setting;
|
||||
if(maxLength < fr.getStringWidth(setting.name + ": " + mode.getValue()))
|
||||
{
|
||||
if (maxLength < fr.getStringWidth(setting.name + ": " + mode.getValue())) {
|
||||
maxLength = fr.getStringWidth(setting.name + ": " + mode.getValue());
|
||||
}
|
||||
//fr.drawStringWithShadow(setting.name + ": " + mode.getValue(), 73 + 68, 35 + index*16, -1);
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
if (!m.settings.isEmpty()) {
|
||||
|
||||
if(!m.settings.isEmpty())
|
||||
{
|
||||
|
||||
Gui.drawRect(70 + 68, 5.5, 70 + 68 + maxLength + 9, 5 + m.settings.size() * 16 + 1.5, 0x90000000);
|
||||
Gui.drawRect(70 + 68, 5.5f + m.index * 16, 7 + 61 + maxLength + 70 + 9, 8 + m.index * 16 + 12 + 2.5f,m.settings.get(m.index).focused ? secondaryColor : primaryColor); //0xffff69b4);
|
||||
Gui.drawRect(70 + 68, 5.5, 70 + 68 + maxLength + 9, 5 + m.settings.size() * 16 + 1.5,
|
||||
0x90000000);
|
||||
Gui.drawRect(70 + 68, 5.5f + m.index * 16, 7 + 61 + maxLength + 70 + 9,
|
||||
8 + m.index * 16 + 12 + 2.5f,
|
||||
m.settings.get(m.index).focused ? secondaryColor : primaryColor); // 0xffff69b4);
|
||||
|
||||
index = 0;
|
||||
for (Setting setting : m.settings)
|
||||
{
|
||||
if(setting instanceof BooleanSetting)
|
||||
{
|
||||
for (Setting setting : m.settings) {
|
||||
if (setting instanceof BooleanSetting) {
|
||||
BooleanSetting bool = (BooleanSetting) setting;
|
||||
fr.drawStringWithShadow(setting.name + ": " + (bool.getValue() ? "Enabled" : "Disabled"), 73 + 68, 10 + index*16, -1);
|
||||
fr.drawStringWithShadow(
|
||||
setting.name + ": " + (bool.getValue() ? "Enabled" : "Disabled"), 73 + 68,
|
||||
10 + index * 16, -1);
|
||||
}
|
||||
|
||||
if(setting instanceof ModeSetting)
|
||||
{
|
||||
if (setting instanceof ModeSetting) {
|
||||
ModeSetting mode = (ModeSetting) setting;
|
||||
fr.drawStringWithShadow(setting.name + ": " + mode.getValue(), 73 + 68, 10 + index*16, -1);
|
||||
fr.drawStringWithShadow(setting.name + ": " + mode.getValue(), 73 + 68, 10 + index * 16,
|
||||
-1);
|
||||
}
|
||||
|
||||
index++;
|
||||
|
@ -138,175 +116,108 @@ public class TabGui extends RenderMod {
|
|||
}
|
||||
}
|
||||
|
||||
public void onKey(int code){
|
||||
public void onKey(int code) {
|
||||
|
||||
Category category = Mod.Category.values()[current];
|
||||
List<Mod> modules = Resent.INSTANCE.modManager.modsInCategory(category);
|
||||
|
||||
if(expanded && !modules.isEmpty() && modules.get(category.i).expanded)
|
||||
{
|
||||
if (code == KeyboardConstants.KEY_UP) {
|
||||
if (expanded) {
|
||||
if (expanded && !modules.isEmpty() && modules.get(category.i).expanded) {
|
||||
Mod module = modules.get(category.i);
|
||||
|
||||
}
|
||||
|
||||
if(code == KeyboardConstants.KEY_UP)
|
||||
{
|
||||
if(expanded)
|
||||
{
|
||||
if(expanded && !modules.isEmpty() && modules.get(category.i).expanded)
|
||||
{
|
||||
Mod module = modules.get(category.i);
|
||||
|
||||
if(!module.settings.isEmpty())
|
||||
{
|
||||
if (module.settings.get(module.index).focused)
|
||||
{
|
||||
Setting setting = module.settings.get(module.index);
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(module.index <= 0)
|
||||
{
|
||||
if (!module.settings.isEmpty()) {
|
||||
if (module.index <= 0) {
|
||||
module.index = module.settings.size() - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
module.index--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(category.i <= 0)
|
||||
{
|
||||
} else {
|
||||
if (category.i <= 0) {
|
||||
category.i = modules.size() - 1;
|
||||
}else
|
||||
} else
|
||||
category.i--;
|
||||
}
|
||||
}else
|
||||
if(current <= 0)
|
||||
{
|
||||
} else if (current <= 0) {
|
||||
current = Mod.Category.values().length - 1;
|
||||
}else
|
||||
} else
|
||||
current--;
|
||||
}
|
||||
if(code == KeyboardConstants.KEY_DOWN)
|
||||
{
|
||||
if(expanded)
|
||||
{
|
||||
if(expanded && !modules.isEmpty() && modules.get(category.i).expanded)
|
||||
{
|
||||
if (code == KeyboardConstants.KEY_DOWN) {
|
||||
if (expanded) {
|
||||
if (expanded && !modules.isEmpty() && modules.get(category.i).expanded) {
|
||||
Mod module = modules.get(category.i);
|
||||
|
||||
if(!module.settings.isEmpty())
|
||||
{
|
||||
if (module.settings.get(module.index).focused)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (module.index >= module.settings.size() - 1)
|
||||
{
|
||||
if (!module.settings.isEmpty()) {
|
||||
if (module.index >= module.settings.size() - 1) {
|
||||
module.index = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
module.index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (category.i >= modules.size() - 1)
|
||||
{
|
||||
} else {
|
||||
if (category.i >= modules.size() - 1) {
|
||||
category.i = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
category.i++;
|
||||
}
|
||||
}
|
||||
}else
|
||||
if (current >= Mod.Category.values().length - 1)
|
||||
{
|
||||
} else if (current >= Mod.Category.values().length - 1) {
|
||||
current = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
current++;
|
||||
}
|
||||
}
|
||||
|
||||
if(code == KeyboardConstants.KEY_RETURN)
|
||||
{
|
||||
if(expanded && modules.size() != 0)
|
||||
{
|
||||
if (code == KeyboardConstants.KEY_RETURN) {
|
||||
if (expanded && modules.size() != 0) {
|
||||
Mod module = modules.get(category.i);
|
||||
if(!module.expanded && !module.settings.isEmpty())
|
||||
if (!module.expanded && !module.settings.isEmpty())
|
||||
module.expanded = true;
|
||||
else if(module.expanded && !module.settings.isEmpty())
|
||||
{
|
||||
else if (module.expanded && !module.settings.isEmpty()) {
|
||||
module.settings.get(module.index).focused = !module.settings.get(module.index).focused;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(code == KeyboardConstants.KEY_RIGHT)
|
||||
{
|
||||
if(expanded && modules.size() != 0)
|
||||
{
|
||||
if (code == KeyboardConstants.KEY_RIGHT) {
|
||||
if (expanded && modules.size() != 0) {
|
||||
Mod module = modules.get(category.i);
|
||||
|
||||
|
||||
if(expanded && !modules.isEmpty() && module.expanded)
|
||||
{
|
||||
if(!module.settings.isEmpty())
|
||||
{
|
||||
if (expanded && !modules.isEmpty() && module.expanded) {
|
||||
if (!module.settings.isEmpty()) {
|
||||
Setting setting = module.settings.get(module.index);
|
||||
|
||||
if (setting instanceof BooleanSetting)
|
||||
{
|
||||
((BooleanSetting)setting).toggle();
|
||||
if (setting instanceof BooleanSetting) {
|
||||
((BooleanSetting) setting).toggle();
|
||||
}
|
||||
if (setting instanceof ModeSetting)
|
||||
{
|
||||
((ModeSetting)setting).next();
|
||||
if (setting instanceof ModeSetting) {
|
||||
((ModeSetting) setting).next();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!module.getName().equals("TabGUI"))
|
||||
} else {
|
||||
if (!module.getName().equals("TabGUI"))
|
||||
module.toggle();
|
||||
}
|
||||
}else
|
||||
} else
|
||||
expanded = true;
|
||||
}
|
||||
if(code == KeyboardConstants.KEY_LEFT)
|
||||
{
|
||||
if(expanded && !modules.isEmpty() && modules.get(category.i).expanded)
|
||||
{
|
||||
Mod module = modules.get(category.i);
|
||||
|
||||
if(!module.settings.isEmpty())
|
||||
{
|
||||
if (module.settings.get(module.index).focused)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
modules.get(category.i).expanded = false;
|
||||
}
|
||||
}else
|
||||
expanded = false;
|
||||
}
|
||||
mc.gameSettings.saveOptions();
|
||||
}
|
||||
if (code == KeyboardConstants.KEY_LEFT) {
|
||||
if (expanded && !modules.isEmpty() && modules.get(category.i).expanded) {
|
||||
Mod module = modules.get(category.i);
|
||||
|
||||
if (!module.settings.isEmpty()) {
|
||||
if (module.settings.get(module.index).focused) {
|
||||
|
||||
} else
|
||||
modules.get(category.i).expanded = false;
|
||||
}
|
||||
} else
|
||||
expanded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user