add options to active modules and close #28

This commit is contained in:
Bella 2020-03-20 23:04:25 -04:00
parent ff8323be4d
commit ebc99af46c
No known key found for this signature in database
GPG Key ID: 815562EA23BFE344
6 changed files with 155 additions and 30 deletions

View File

@ -197,6 +197,7 @@ public class KamiMod {
try { // load modules that are on by default // autoenable
ModuleManager.getModuleByName("InfoOverlay").setEnabled(true);
ModuleManager.getModuleByName("InventoryViewer").setEnabled(true);
ModuleManager.getModuleByName("ActiveModules").setEnabled(true);
if (((Capes) ModuleManager.getModuleByName("Capes")).startupGlobal.getValue()) {
ModuleManager.getModuleByName("Capes").setEnabled(true);

View File

@ -1,12 +1,12 @@
package me.zeroeightsix.kami.gui.kami.theme.kami;
import me.zeroeightsix.kami.KamiMod;
import me.zeroeightsix.kami.gui.kami.component.ActiveModules;
import me.zeroeightsix.kami.gui.rgui.component.AlignedComponent;
import me.zeroeightsix.kami.command.Command;
import me.zeroeightsix.kami.gui.rgui.render.AbstractComponentUI;
import me.zeroeightsix.kami.gui.rgui.render.font.FontRenderer;
import me.zeroeightsix.kami.module.Module;
import me.zeroeightsix.kami.module.ModuleManager;
import me.zeroeightsix.kami.module.modules.gui.ActiveModules;
import me.zeroeightsix.kami.util.Wrapper;
import org.lwjgl.opengl.GL11;
@ -16,16 +16,18 @@ import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import static me.zeroeightsix.kami.util.ColourConverter.toF;
import static org.lwjgl.opengl.GL11.GL_BLEND;
import static org.lwjgl.opengl.GL11.glDisable;
/**
* Created by 086 on 4/08/2017.
* Updated by S-B99 on 13/12/19
* Updated by S-B99 on 20/03/19
*/
public class KamiActiveModulesUI extends AbstractComponentUI<ActiveModules> {
public class KamiActiveModulesUI extends AbstractComponentUI<me.zeroeightsix.kami.gui.kami.component.ActiveModules> {
ActiveModules activeMods;
@Override
public void renderComponent(ActiveModules component, FontRenderer f) {
public void renderComponent(me.zeroeightsix.kami.gui.kami.component.ActiveModules component, FontRenderer f) {
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_TEXTURE_2D);
@ -33,17 +35,18 @@ public class KamiActiveModulesUI extends AbstractComponentUI<ActiveModules> {
FontRenderer renderer = Wrapper.getFontRenderer();
List<Module> mods = ModuleManager.getModules().stream()
.filter(Module::isEnabled)
.filter(Module::isOnArray)
.sorted(Comparator.comparing(module -> renderer.getStringWidth(module.getName() + (module.getHudInfo() == null ? "" : module.getHudInfo() + " ")) * (component.sort_up ? -1 : 1)))
.collect(Collectors.toList());
final int[] y = {2};
activeMods = (ActiveModules) ModuleManager.getModuleByName("ActiveModules");
if (component.getParent().getY() < 26 && Wrapper.getPlayer().getActivePotionEffects().size() > 0 && component.getParent().getOpacity() == 0)
y[0] = Math.max(component.getParent().getY(), 26 - component.getParent().getY());
final float[] hue = {(System.currentTimeMillis() % (360 * 32)) / (360f * 32)};
final float[] hue = {(System.currentTimeMillis() % (360 * activeMods.getRainbowSpeed())) / (360f * activeMods.getRainbowSpeed())};
boolean lAlign = component.getAlignment() == AlignedComponent.Alignment.LEFT;
Function<Integer, Integer> xFunc;
switch (component.getAlignment()) {
case RIGHT:
@ -58,22 +61,32 @@ public class KamiActiveModulesUI extends AbstractComponentUI<ActiveModules> {
break;
}
mods.forEach(module -> {
if (module.getShowOnArray().equals(Module.ShowOnArray.ON)) {
int rgb = Color.HSBtoRGB(hue[0], 1, 1);
String s = module.getHudInfo();
String text = module.getName() + (s == null ? "" : " " + KamiMod.colour + "7" + s);
int textWidth = renderer.getStringWidth(text);
int textHeight = renderer.getFontHeight() + 1;
int red = (rgb >> 16) & 0xFF;
int green = (rgb >> 8) & 0xFF;
int blue = rgb & 0xFF;
for (int i = 0 ; i < mods.size() ; i++) {
Module module = mods.get(i);
int rgb;
renderer.drawStringWithShadow(xFunc.apply(textWidth), y[0], red, green, blue, text);
hue[0] += .02f;
y[0] += textHeight;
if (activeMods.mode.getValue().equals(ActiveModules.Mode.RAINBOW)) {
rgb = Color.HSBtoRGB(hue[0], toF(activeMods.saturationR.getValue()), toF(activeMods.brightnessR.getValue()));
} else if (activeMods.mode.getValue().equals(ActiveModules.Mode.CATEGORY)) {
rgb = ActiveModules.getCategoryColour(module);
} else if (activeMods.mode.getValue().equals(ActiveModules.Mode.CUSTOM)){
rgb = Color.HSBtoRGB(toF(activeMods.hueC.getValue()), toF(activeMods.saturationC.getValue()), toF(activeMods.brightnessC.getValue()));
} else {
rgb = activeMods.getInfoColour(i);
}
});
String s = module.getHudInfo();
String text = module.getName() + (s == null ? "" : " " + KamiMod.colour + "7" + s);
int textWidth = renderer.getStringWidth(text);
int textHeight = renderer.getFontHeight() + 1;
int red = (rgb >> 16) & 0xFF;
int green = (rgb >> 8) & 0xFF;
int blue = rgb & 0xFF;
renderer.drawStringWithShadow(xFunc.apply(textWidth), y[0], red, green, blue, text);
hue[0] += .02f;
y[0] += textHeight;
}
component.setHeight(y[0]);
@ -82,7 +95,7 @@ public class KamiActiveModulesUI extends AbstractComponentUI<ActiveModules> {
}
@Override
public void handleSizeComponent(ActiveModules component) {
public void handleSizeComponent(me.zeroeightsix.kami.gui.kami.component.ActiveModules component) {
component.setWidth(100);
component.setHeight(100);
}

View File

@ -134,6 +134,8 @@ public class Module {
public boolean isEnabled() { return enabled.getValue(); }
public boolean isOnArray() { return showOnArray.getValue().equals(ShowOnArray.ON); }
protected void onEnable() {}
protected void onDisable() {}

View File

@ -0,0 +1,109 @@
package me.zeroeightsix.kami.module.modules.gui;
import me.zeroeightsix.kami.module.Module;
import me.zeroeightsix.kami.module.ModuleManager;
import me.zeroeightsix.kami.setting.Setting;
import me.zeroeightsix.kami.setting.Settings;
import static me.zeroeightsix.kami.command.Command.sendDisableMessage;
import static me.zeroeightsix.kami.util.ColourConverter.rgbToInt;
import static me.zeroeightsix.kami.util.InfoCalculator.isNumberEven;
import static me.zeroeightsix.kami.util.InfoCalculator.reverseNumber;
/**
* @author S-B99
* Created by S-B99 on 20/03/20
*/
@Module.Info(name = "ActiveModules", category = Module.Category.GUI, description = "Configures ActiveModules Colour", showOnArray = Module.ShowOnArray.OFF)
public class ActiveModules extends Module {
public Setting<Mode> mode = register(Settings.e("Mode", Mode.RAINBOW));
private Setting<Integer> rainbowSpeed = register(Settings.integerBuilder().withName("Speed F").withValue(30).withMinimum(0).withMaximum(100).withVisibility(v -> mode.getValue().equals(Mode.RAINBOW)).build());
public Setting<Integer> saturationR = register(Settings.integerBuilder().withName("Saturation R").withValue(117).withMinimum(0).withMaximum(255).withVisibility(v -> mode.getValue().equals(Mode.RAINBOW)).build());
public Setting<Integer> brightnessR = register(Settings.integerBuilder().withName("Brightness R").withValue(255).withMinimum(0).withMaximum(255).withVisibility(v -> mode.getValue().equals(Mode.RAINBOW)).build());
public Setting<Integer> hueC = register(Settings.integerBuilder().withName("Hue C").withValue(178).withMinimum(0).withMaximum(255).withVisibility(v -> mode.getValue().equals(Mode.CUSTOM)).build());
public Setting<Integer> saturationC = register(Settings.integerBuilder().withName("Saturation C").withValue(156).withMinimum(0).withMaximum(255).withVisibility(v -> mode.getValue().equals(Mode.CUSTOM)).build());
public Setting<Integer> brightnessC = register(Settings.integerBuilder().withName("Brightness C").withValue(255).withMinimum(0).withMaximum(255).withVisibility(v -> mode.getValue().equals(Mode.CUSTOM)).build());
private Setting<Boolean> alternate = register(Settings.booleanBuilder().withName("Alternate").withValue(true).withVisibility(v -> mode.getValue().equals(Mode.INFO_OVERLAY)).build());
public static int getCategoryColour(Module module) {
switch (module.getCategory()) {
case CHAT: return rgbToInt(245, 66, 66);
case COMBAT: return rgbToInt(245, 135, 66);
case EXPERIMENTAL: return rgbToInt(245, 66, 129);
case GUI: return rgbToInt(245, 203, 66);
case RENDER: return rgbToInt(194, 245, 66);
case PLAYER: return rgbToInt(66, 245, 126);
case MOVEMENT: return rgbToInt(66, 182, 245);
case MISC: return rgbToInt(170, 66, 245);
default: return rgbToInt(139, 100, 255);
}
}
public int getInfoColour(int position) {
if (!alternate.getValue()) return getSecondInfoColourFromSettings();
else {
if (isNumberEven(position)) {
return getFirstInfoColourFromSettings();
} else {
return getSecondInfoColourFromSettings();
}
}
}
//TODO: fix this dogshit code with the ColourTextFormatting class
private int getFirstInfoColourFromSettings() {
InfoOverlay infoOverlay = (InfoOverlay) ModuleManager.getModuleByName("InfoOverlay");
switch (infoOverlay.firstColour.getValue()) {
case BLACK: return rgbToInt(0,0, 0);
case DARK_BLUE: return rgbToInt(0, 0, 170);
case DARK_GREEN: return rgbToInt(0, 170, 0);
case DARK_AQUA: return rgbToInt(0, 170, 170);
case DARK_RED: return rgbToInt(170, 0, 0);
case DARK_PURPLE: return rgbToInt(170, 0, 170);
case GOLD: return rgbToInt(255, 170, 0);
case GRAY: return rgbToInt(170, 170, 0);
case DARK_GRAY: return rgbToInt(85, 85, 85);
case BLUE: return rgbToInt(85, 85, 255);
case GREEN: return rgbToInt(85, 255, 85);
case AQUA: return rgbToInt(85, 225, 225);
case RED: return rgbToInt(255, 85, 85);
case LIGHT_PURPLE: return rgbToInt(255, 85, 255);
case YELLOW: return rgbToInt(255, 255, 85);
case WHITE: return rgbToInt(255, 255, 255);
}
return rgbToInt(155, 144, 255);
}
private int getSecondInfoColourFromSettings() {
InfoOverlay infoOverlay = (InfoOverlay) ModuleManager.getModuleByName("InfoOverlay");
switch (infoOverlay.secondColour.getValue()) {
case BLACK: return rgbToInt(0,0, 0);
case DARK_BLUE: return rgbToInt(0, 0, 170);
case DARK_GREEN: return rgbToInt(0, 170, 0);
case DARK_AQUA: return rgbToInt(0, 170, 170);
case DARK_RED: return rgbToInt(170, 0, 0);
case DARK_PURPLE: return rgbToInt(170, 0, 170);
case GOLD: return rgbToInt(255, 170, 0);
case GRAY: return rgbToInt(170, 170, 0);
case DARK_GRAY: return rgbToInt(85, 85, 85);
case BLUE: return rgbToInt(85, 85, 255);
case GREEN: return rgbToInt(85, 255, 85);
case AQUA: return rgbToInt(85, 225, 225);
case RED: return rgbToInt(255, 85, 85);
case LIGHT_PURPLE: return rgbToInt(255, 85, 255);
case YELLOW: return rgbToInt(255, 255, 85);
case WHITE: return rgbToInt(255, 255, 255);
}
return rgbToInt(155, 144, 255);
}
public int getRainbowSpeed() {
if (rainbowSpeed.getValue() == 0) return 10000000; // if 0 basically just never change the color
int rSpeed = reverseNumber(rainbowSpeed.getValue(), 1, 100);
if (rSpeed == 0) return 1; // can't divide by 0
else return rSpeed;
}
public enum Mode { RAINBOW, CATEGORY, CUSTOM, INFO_OVERLAY }
public void onDisable() { sendDisableMessage(getName()); }
}

View File

@ -50,16 +50,12 @@ public class InfoOverlay extends Module {
private Setting<TimeUtil.TimeType> timeTypeSetting = register(Settings.enumBuilder(TimeUtil.TimeType.class).withName("Time Format").withValue(TimeUtil.TimeType.HHMMSS).withVisibility(v -> page.getValue().equals(Page.THREE) && time.getValue()).build());
private Setting<TimeUtil.TimeUnit> timeUnitSetting = register(Settings.enumBuilder(TimeUtil.TimeUnit.class).withName("Time Unit").withValue(TimeUtil.TimeUnit.H12).withVisibility(v -> page.getValue().equals(Page.THREE) && time.getValue()).build());
private Setting<Boolean> doLocale = register(Settings.booleanBuilder("Time Show AMPM").withValue(true).withVisibility(v -> page.getValue().equals(Page.THREE) && time.getValue()).build());
private Setting<ColourUtils.ColourCode> firstColour = register(Settings.enumBuilder(ColourUtils.ColourCode.class).withName("First Colour").withValue(ColourUtils.ColourCode.WHITE).withVisibility(v -> page.getValue().equals(Page.THREE)).build());
private Setting<ColourUtils.ColourCode> secondColour = register(Settings.enumBuilder(ColourUtils.ColourCode.class).withName("Second Colour").withValue(ColourUtils.ColourCode.BLUE).withVisibility(v -> page.getValue().equals(Page.THREE)).build());
public Setting<ColourUtils.ColourCode> firstColour = register(Settings.enumBuilder(ColourUtils.ColourCode.class).withName("First Colour").withValue(ColourUtils.ColourCode.WHITE).withVisibility(v -> page.getValue().equals(Page.THREE)).build());
public Setting<ColourUtils.ColourCode> secondColour = register(Settings.enumBuilder(ColourUtils.ColourCode.class).withName("Second Colour").withValue(ColourUtils.ColourCode.BLUE).withVisibility(v -> page.getValue().equals(Page.THREE)).build());
private enum SpeedUnit {
MPS, KMH;
}
private enum SpeedUnit { MPS, KMH }
private enum Page {
ONE, TWO, THREE
}
private enum Page { ONE, TWO, THREE }
public boolean useUnitKmH() {
return speedUnit.getValue().equals(SpeedUnit.KMH);

View File

@ -89,4 +89,8 @@ public class InfoCalculator extends Module {
/* Is Even */
public static boolean isNumberEven(int i) { return (i & 1) == 0; }
/* End of Is Even */
/* Reverse Number */
public static int reverseNumber(int num, int min, int max) { return (max + min) - num; }
/* End of Reverse Number */
}