Bug fixes for EnabledModsComponent

This commit is contained in:
noil 2020-12-19 21:22:02 -05:00
parent 57920ad4b6
commit 57c23e6258
1 changed files with 89 additions and 88 deletions

View File

@ -53,103 +53,104 @@ public final class EnabledModsComponent extends DraggableHudComponent {
final ScaledResolution res = new ScaledResolution(mc);
boolean isInHudEditor = mc.currentScreen instanceof GuiHudEditor;
float xOffset = 0;
float yOffset = 0;
float maxWidth = 0;
int hueDifference = 0;
for (Module mod : Seppuku.INSTANCE.getModuleManager().getModuleList()) {
if (mod != null && mod.getType() != Module.ModuleType.HIDDEN && mod.isEnabled() && !mod.isHidden()) {
mods.add(mod);
}
}
if (SORTING_MODE.equals(LENGTH)) {
final Comparator<Module> lengthComparator = (first, second) -> {
String firstName = first.getDisplayName() + (SHOW_METADATA ? (first.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + first.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "") : "");
String secondName = second.getDisplayName() + (SHOW_METADATA ? (second.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + second.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "") : "");
if (LOWERCASE) {
firstName = firstName.toLowerCase();
secondName = secondName.toLowerCase();
}
final float dif = mc.fontRenderer.getStringWidth(secondName) - mc.fontRenderer.getStringWidth(firstName);
return dif != 0 ? (int) dif : secondName.compareTo(firstName);
};
mods.sort(lengthComparator);
} else if (SORTING_MODE.equals(ALPHABET)) {
final Comparator<Module> alphabeticalComparator = (first, second) -> {
String firstName = first.getDisplayName() + (SHOW_METADATA ? (first.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + first.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "") : "");
String secondName = second.getDisplayName() + (SHOW_METADATA ? (second.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + second.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "") : "");
if (LOWERCASE) {
firstName = firstName.toLowerCase();
secondName = secondName.toLowerCase();
}
return firstName.compareToIgnoreCase(secondName);
};
mods.sort(alphabeticalComparator);
} else if (SORTING_MODE.equals(UNSORTED)) {
}
float xOffset = 0;
float yOffset = 0;
float maxWidth = 0;
int hueDifference = 0;
for (Module mod : mods) {
if (mod != null && mod.getType() != Module.ModuleType.HIDDEN && mod.isEnabled() && !mod.isHidden()) {
String name = mod.getDisplayName() + (SHOW_METADATA ? (mod.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + mod.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "") : "");
if (LOWERCASE)
name = name.toLowerCase();
final float width = mc.fontRenderer.getStringWidth(name);
int color;
if (RAINBOW && mc.player != null) {
Color rainbow = new Color(Color.HSBtoRGB((float) (mc.player.ticksExisted / (100.0D - RAINBOW_HUE_SPEED) + Math.sin(hueDifference / (100.0D - RAINBOW_HUE_SPEED * Math.PI / 2.0D))) % 1.0F, RAINBOW_SATURATION, RAINBOW_BRIGHTNESS));
color = ColorUtil.changeAlpha((new Color(rainbow.getRed(), rainbow.getGreen(), rainbow.getBlue())).getRGB(), 0xFF);
} else {
color = ColorUtil.changeAlpha(mod.getColor(), 0xFF);
}
if (width >= maxWidth) {
maxWidth = width;
}
if (this.getAnchorPoint() != null) {
switch (this.getAnchorPoint().getPoint()) {
case TOP_CENTER:
case BOTTOM_CENTER:
xOffset = (this.getW() - mc.fontRenderer.getStringWidth(name)) / 2;
break;
case TOP_LEFT:
case BOTTOM_LEFT:
xOffset = 0;
break;
case TOP_RIGHT:
case BOTTOM_RIGHT:
xOffset = this.getW() - mc.fontRenderer.getStringWidth(name);
break;
if (mods.size() > 0) {
if (SORTING_MODE.equals(LENGTH)) {
final Comparator<Module> lengthComparator = (first, second) -> {
String firstName = first.getDisplayName() + (SHOW_METADATA ? (first.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + first.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "") : "");
String secondName = second.getDisplayName() + (SHOW_METADATA ? (second.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + second.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "") : "");
if (LOWERCASE) {
firstName = firstName.toLowerCase();
secondName = secondName.toLowerCase();
}
}
if (this.getAnchorPoint() != null) {
switch (this.getAnchorPoint().getPoint()) {
case TOP_CENTER:
case TOP_LEFT:
case TOP_RIGHT:
mc.fontRenderer.drawStringWithShadow(name, this.getX() + xOffset, this.getY() + yOffset, color);
yOffset += (mc.fontRenderer.FONT_HEIGHT + 1);
break;
case BOTTOM_CENTER:
case BOTTOM_LEFT:
case BOTTOM_RIGHT:
mc.fontRenderer.drawStringWithShadow(name, this.getX() + xOffset, this.getY() + (this.getH() - mc.fontRenderer.FONT_HEIGHT) + yOffset, color);
yOffset -= (mc.fontRenderer.FONT_HEIGHT + 1);
break;
final float dif = mc.fontRenderer.getStringWidth(secondName) - mc.fontRenderer.getStringWidth(firstName);
return dif != 0 ? (int) dif : secondName.compareTo(firstName);
};
mods.sort(lengthComparator);
} else if (SORTING_MODE.equals(ALPHABET)) {
final Comparator<Module> alphabeticalComparator = (first, second) -> {
String firstName = first.getDisplayName() + (SHOW_METADATA ? (first.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + first.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "") : "");
String secondName = second.getDisplayName() + (SHOW_METADATA ? (second.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + second.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "") : "");
if (LOWERCASE) {
firstName = firstName.toLowerCase();
secondName = secondName.toLowerCase();
}
} else {
mc.fontRenderer.drawStringWithShadow(name, this.getX() + xOffset, this.getY() + yOffset, color);
yOffset += (mc.fontRenderer.FONT_HEIGHT + 1);
}
return firstName.compareToIgnoreCase(secondName);
};
mods.sort(alphabeticalComparator);
} else if (SORTING_MODE.equals(UNSORTED)) {
hueDifference = (int) (hueDifference + RAINBOW_HUE_DIFFERENCE);
}
for (Module mod : mods) {
if (mod != null && mod.getType() != Module.ModuleType.HIDDEN && mod.isEnabled() && !mod.isHidden()) {
String name = mod.getDisplayName() + (SHOW_METADATA ? (mod.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + mod.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "") : "");
if (LOWERCASE)
name = name.toLowerCase();
final float width = mc.fontRenderer.getStringWidth(name);
int color;
if (RAINBOW && mc.player != null) {
Color rainbow = new Color(Color.HSBtoRGB((float) (mc.player.ticksExisted / (100.0D - RAINBOW_HUE_SPEED) + Math.sin(hueDifference / (100.0D - RAINBOW_HUE_SPEED * Math.PI / 2.0D))) % 1.0F, RAINBOW_SATURATION, RAINBOW_BRIGHTNESS));
color = ColorUtil.changeAlpha((new Color(rainbow.getRed(), rainbow.getGreen(), rainbow.getBlue())).getRGB(), 0xFF);
} else {
color = ColorUtil.changeAlpha(mod.getColor(), 0xFF);
}
if (width >= maxWidth) {
maxWidth = width;
}
if (this.getAnchorPoint() != null) {
switch (this.getAnchorPoint().getPoint()) {
case TOP_CENTER:
case BOTTOM_CENTER:
xOffset = (this.getW() - mc.fontRenderer.getStringWidth(name)) / 2;
break;
case TOP_LEFT:
case BOTTOM_LEFT:
xOffset = 0;
break;
case TOP_RIGHT:
case BOTTOM_RIGHT:
xOffset = this.getW() - mc.fontRenderer.getStringWidth(name);
break;
}
}
if (this.getAnchorPoint() != null) {
switch (this.getAnchorPoint().getPoint()) {
case TOP_CENTER:
case TOP_LEFT:
case TOP_RIGHT:
mc.fontRenderer.drawStringWithShadow(name, this.getX() + xOffset, this.getY() + yOffset, color);
yOffset += (mc.fontRenderer.FONT_HEIGHT + 1);
break;
case BOTTOM_CENTER:
case BOTTOM_LEFT:
case BOTTOM_RIGHT:
mc.fontRenderer.drawStringWithShadow(name, this.getX() + xOffset, this.getY() + (this.getH() - mc.fontRenderer.FONT_HEIGHT) + yOffset, color);
yOffset -= (mc.fontRenderer.FONT_HEIGHT + 1);
break;
}
} else {
mc.fontRenderer.drawStringWithShadow(name, this.getX() + xOffset, this.getY() + yOffset, color);
yOffset += (mc.fontRenderer.FONT_HEIGHT + 1);
}
hueDifference = (int) (hueDifference + RAINBOW_HUE_DIFFERENCE);
}
}
}