diff options
author | Lorenz <ESs95s3P5z8Pheb> | 2022-07-07 00:31:50 +0200 |
---|---|---|
committer | Lorenz <ESs95s3P5z8Pheb> | 2022-07-07 00:31:50 +0200 |
commit | 99773d6a593c444151503de315f127bea6f74d49 (patch) | |
tree | 9ee1ae505e5f82aba62f10c882af85a3acd6e483 /src/main/java/com/thatgravyboat/skyblockhud/config | |
download | skyhanni-99773d6a593c444151503de315f127bea6f74d49.tar.gz skyhanni-99773d6a593c444151503de315f127bea6f74d49.tar.bz2 skyhanni-99773d6a593c444151503de315f127bea6f74d49.zip |
init lorenz mod
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/config')
3 files changed, 1046 insertions, 0 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/KeyBindings.java b/src/main/java/com/thatgravyboat/skyblockhud/config/KeyBindings.java new file mode 100644 index 000000000..9ffd3523b --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/KeyBindings.java @@ -0,0 +1,8 @@ +package com.thatgravyboat.skyblockhud.config; + +import net.minecraft.client.settings.KeyBinding; + +public class KeyBindings { + + public static KeyBinding map = new KeyBinding("Opens the big map.", 50, "SkyblockHud"); +} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java new file mode 100644 index 000000000..8793fb8ec --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java @@ -0,0 +1,436 @@ +package com.thatgravyboat.skyblockhud.config; + +import com.google.gson.annotations.Expose; +import com.thatgravyboat.skyblockhud.SkyblockHud; +import com.thatgravyboat.skyblockhud.core.GuiScreenElementWrapper; +import com.thatgravyboat.skyblockhud.core.config.Config; +import com.thatgravyboat.skyblockhud.core.config.Position; +import com.thatgravyboat.skyblockhud.core.config.annotations.*; +import com.thatgravyboat.skyblockhud.core.config.gui.GuiPositionEditor; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import net.minecraft.client.Minecraft; + +public class SBHConfig extends Config { + + private void editOverlay(String activeConfig, int width, int height, Position position) { + Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(position, width, height, () -> {}, () -> {}, () -> SkyblockHud.screenToOpen = new GuiScreenElementWrapper(new SBHConfigEditor(SkyblockHud.config, activeConfig)))); + } + + @Override + public void executeRunnable(String runnableId) { + String activeConfigCategory = null; + if (Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper) { + GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft().currentScreen; + if (wrapper.element instanceof SBHConfigEditor) { + activeConfigCategory = ((SBHConfigEditor) wrapper.element).getSelectedCategoryName(); + } + } + + switch (runnableId) { + case "rpg": + editOverlay(activeConfigCategory, 120, 47, rpg.rpgHudPosition); + return; + case "d1": + editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer1); + return; + case "d2": + editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer2); + return; + case "d3": + editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer3); + return; + case "d4": + editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer4); + return; + case "main": + editOverlay(activeConfigCategory, 1000, 34, main.mainHudPos); + return; + case "ultimate": + editOverlay(activeConfigCategory, 182, 5, dungeon.barPosition); + return; + case "map": + editOverlay(activeConfigCategory, 72, 72, map.miniMapPosition); + return; + case "tracker": + editOverlay(activeConfigCategory, 130, 70, trackers.trackerPosition); + return; + case "drill": + editOverlay(activeConfigCategory, 136, 7, mining.drillBar); + return; + case "heat": + editOverlay(activeConfigCategory, 45, 7, mining.heatBar); + return; + case "dialogue": + editOverlay(activeConfigCategory, 182, 68, misc.dialoguePos); + return; + } + } + + @Expose + @Category(name = "Misc Options", desc = "Just a bunch of random options.") + public Misc misc = new Misc(); + + @Expose + @Category(name = "Main Hud", desc = "All Options for the main hud.") + public MainHud main = new MainHud(); + + @Expose + @Category(name = "RPG Hud", desc = "All Options for the RPG hud.") + public RPGHud rpg = new RPGHud(); + + @Expose + @Category(name = "Dungeon Hud", desc = "All Options for the Dungeon hud.") + public DungeonHud dungeon = new DungeonHud(); + + @Expose + @Category(name = "Renderer", desc = "All Options for rendering.") + public Renderer renderer = new Renderer(); + + @Expose + @Category(name = "Map", desc = "All Options for the Map.") + public Map map = new Map(); + + @Expose + @Category(name = "Mining", desc = "All Options for the Mining Stuff.") + public Mining mining = new Mining(); + + @Expose + @Category(name = "Tracker", desc = "All Options for the Trackers.") + public Trackers trackers = new Trackers(); + + public static class Misc { + + @Expose + @ConfigOption(name = "Hide Scoreboard", desc = "Hides the scoreboard when in Skyblock.") + @ConfigEditorBoolean + public boolean hideScoreboard = false; + + @Expose + @ConfigOption(name = "Texture Styles", desc = "If this list only contains 1 thing that means your texture pack doesnt support styles") + @ConfigEditorStyle + public int style = 0; + + @Expose + @ConfigOption(name = "Hide Dialogue Box", desc = "Hides the Dialogue Box.") + @ConfigEditorBoolean + public boolean hideDialogueBox = true; + + @Expose + @ConfigOption(name = "Dialogue Box", desc = "") + @ConfigEditorButton(runnableId = "dialogue", buttonText = "Edit") + public Position dialoguePos = new Position(0, -50, true, false); + + @Expose + @ConfigOption(name = "Hide Item Cooldowns", desc = "Hides item cooldowns") + @ConfigEditorBoolean + public boolean hideItemCooldowns = false; + } + + public static class MainHud { + + @Expose + @ConfigOption(name = "Disable Main Hud", desc = "IDK Why you would do this as its like half the mod but ok.") + @ConfigEditorBoolean + public boolean disaleMainHud = false; + + @Expose + @ConfigOption(name = "Main Hud Position", desc = "") + @ConfigEditorButton(runnableId = "main", buttonText = "Edit") + public Position mainHudPos = new Position(0, 1, true, false); + + @Expose + @ConfigOption(name = "Twelve Hour Clock", desc = "Allows you to change the clock to be 12 hour instead of 24 hour.") + @ConfigEditorBoolean + public boolean twelveHourClock = false; + + @Expose + @ConfigOption(name = "Shift hud with boss", desc = "Shifts the hud when bossbar is visible.") + @ConfigEditorBoolean + public boolean bossShiftHud = true; + + @Expose + @ConfigOption(name = "Require Redstone", desc = "Allows to make it so that the redstone percentage requires you to hold a redstone item to show.") + @ConfigEditorBoolean + public boolean requireRedstone = true; + } + + public static class RPGHud { + + @Expose + @ConfigOption(name = "Show RPG Hud", desc = "Allows you to show or hide the RPG Hud.") + @ConfigEditorBoolean + public boolean showRpgHud = true; + + @Expose + @ConfigOption(name = "Flip Hud", desc = "Flips the hud when half way across the screen.") + @ConfigEditorBoolean + public boolean flipHud = true; + + @Expose + @ConfigOption(name = "RPG Hud Position", desc = "Allows you to change the position of the RPG Hud.") + @ConfigEditorButton(runnableId = "rpg", buttonText = "Edit") + public Position rpgHudPosition = new Position(1, 1); + } + + public static class DungeonHud { + + @Expose + @ConfigOption(name = "Dungeon Ultimate Bar", desc = "") + @ConfigEditorAccordion(id = 2) + public boolean ultimateBar = false; + + @Expose + @ConfigOption(name = "Hide Ultimate Bar", desc = "Hides the custom ultimate bar.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean hideUltimateBar = false; + + @Expose + @ConfigOption(name = "Bar Position", desc = "Change the position of the bar.") + @ConfigEditorButton(runnableId = "ultimate", buttonText = "Edit") + @ConfigAccordionId(id = 2) + public Position barPosition = new Position(0, 50, true, false); + + @Expose + @ConfigOption(name = "Bar Loading Color", desc = "The color of the bar when its loading.") + @ConfigEditorColour + @ConfigAccordionId(id = 2) + public String barLoadColor = "159:0:0:0:255"; + + @Expose + @ConfigOption(name = "Bar Full Color", desc = "The color of the bar when its full.") + @ConfigEditorColour + @ConfigAccordionId(id = 2) + public String barFullColor = "255:0:0:0:255"; + + @Expose + @ConfigOption(name = "Bar Style", desc = "Change the style of the bar") + @ConfigEditorDropdown(values = { "No Notch", "6 Notch", "10 Notch", "12 Notch", "20 Notch" }) + @ConfigAccordionId(id = 2) + public int barStyle = 2; + + @Expose + @ConfigOption(name = "Dungeon Players", desc = "") + @ConfigEditorAccordion(id = 1) + public boolean dungeonPlayerAccordion = false; + + @Expose + @ConfigOption(name = "Hide Dungeon Players", desc = "Allows you to hide the dungeon player hud") + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean hideDungeonPlayers = false; + + @Expose + @ConfigOption(name = "Dungeon Player Opacity", desc = "Allows you to change the opacity of the dungeon players.") + @ConfigEditorSlider(minValue = 0, maxValue = 100, minStep = 1) + @ConfigAccordionId(id = 1) + public int dungeonPlayerOpacity = 0; + + @Expose + @ConfigOption(name = "Hide Dead Players", desc = "Allows you to hide players that are dead or have left.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean hideDeadDungeonPlayers = false; + + @Expose + @ConfigOption(name = "Player Position 1", desc = "Change the position of this dungeon player.") + @ConfigEditorButton(runnableId = "d1", buttonText = "Edit") + @ConfigAccordionId(id = 1) + public Position dungeonPlayer1 = new Position(5, 5); + + @Expose + @ConfigOption(name = "Player Position 2", desc = "Change the position of this dungeon player.") + @ConfigEditorButton(runnableId = "d2", buttonText = "Edit") + @ConfigAccordionId(id = 1) + public Position dungeonPlayer2 = new Position(5, 42); + + @Expose + @ConfigOption(name = "Player Position 3", desc = "Change the position of this dungeon player.") + @ConfigEditorButton(runnableId = "d3", buttonText = "Edit") + @ConfigAccordionId(id = 1) + public Position dungeonPlayer3 = new Position(5, 79); + + @Expose + @ConfigOption(name = "Player Position 4", desc = "Change the position of this dungeon player.") + @ConfigEditorButton(runnableId = "d4", buttonText = "Edit") + @ConfigAccordionId(id = 1) + public Position dungeonPlayer4 = new Position(5, 116); + } + + public static class Renderer { + + @Expose + @ConfigOption(name = "Add Overflow Mana Back", desc = "Adds overflow mana back to the actionbar") + @ConfigEditorBoolean + public boolean addOverflowMana = false; + + @Expose + @ConfigOption(name = "Hide Boss Bar", desc = "Hides Boss Bar when certain conditions are met such as the name is just wither or it starts with objective:") + @ConfigEditorBoolean + public boolean hideBossBar = true; + + @Expose + @ConfigOption(name = "Hide XP Bar", desc = "Hides xp bar.") + @ConfigEditorBoolean + public boolean hideXpBar = true; + + @Expose + @ConfigOption(name = "Hide Food", desc = "Hides food.") + @ConfigEditorBoolean + public boolean hideFood = true; + + @Expose + @ConfigOption(name = "Hide air", desc = "Hides air.") + @ConfigEditorBoolean + public boolean hideAir = true; + + @Expose + @ConfigOption(name = "Hide hearts", desc = "Hides hearts.") + @ConfigEditorBoolean + public boolean hideHearts = true; + + @Expose + @ConfigOption(name = "Hide armor", desc = "Hides armor.") + @ConfigEditorBoolean + public boolean hideArmor = true; + + @Expose + @ConfigOption(name = "Hide Animal Hearts", desc = "Hides Animal Hearts.") + @ConfigEditorBoolean + public boolean hideAnimalHearts = true; + } + + public static class Map { + + @Expose + @ConfigOption(name = "Show Player Location", desc = "This feature is off by default as Hypixel's rules are so vague that this would fall under their disallowed modifications.") + @ConfigEditorBoolean + public boolean showPlayerLocation = false; + + @Expose + @ConfigOption(name = "Show Mini-Map", desc = "Shows the Mini-Map on your overlay if turned off you can still use /sbhmap to see the map in fullscreen.") + @ConfigEditorBoolean + public boolean showMiniMap = false; + + @Expose + @ConfigOption(name = "Map Locations", desc = "Remove a location from this list if you would like the map to not show up in that location. This is so you can use other mods maps.") + @ConfigEditorDraggableList(exampleText = { "HUB", "BARN", "MUSHROOMDESERT", "GOLDMINE (No Map Yet)", "DEEPCAVERNS (No Map Yet)", "SPIDERSDEN", "PARK", "FORTRESS", "DUNGEONHUB (No Map Yet)", "JERRY (No Map Yet)", "THEEND (No Map Yet)", "DWARVENMINES", "CRYSTALHOLLOWS" }) + public List<Integer> mapLocations = new ArrayList<>(Arrays.asList(0, 1, 2, 5, 6, 7, 11)); + + @Expose + @ConfigOption(name = "Mini-Map Position", desc = "Allows you to change the position of the Mini-Map.") + @ConfigEditorButton(runnableId = "map", buttonText = "Edit") + public Position miniMapPosition = new Position(0, 100, false, false); + + @Expose + @ConfigOption(name = "Icons", desc = "") + @ConfigEditorAccordion(id = 3) + public boolean icons = false; + + @Expose + @ConfigOption(name = "NPC", desc = "Show NPC Icons") + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean showNpcIcons = true; + + @Expose + @ConfigOption(name = "Info", desc = "Show Info Icons") + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean showInfoIcons = true; + + @Expose + @ConfigOption(name = "Misc", desc = "Show Misc Icons") + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean showMiscIcons = true; + + @Expose + @ConfigOption(name = "Shops", desc = "Show Shop Icons") + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean showShopIcons = true; + + @Expose + @ConfigOption(name = "Quests", desc = "Show Quest Icons") + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean showQuestIcons = false; + } + + public static class Mining { + + @Expose + @ConfigOption(name = "Mining Bars", desc = "") + @ConfigEditorAccordion(id = 4) + public boolean miningBars = false; + + @Expose + @ConfigOption(name = "Bar Mode", desc = "Change the mode of bar. Static mode will allow it to auto replace the xp when drill is held or you are heating up.") + @ConfigEditorDropdown(values = { "Moveable", "Static" }) + @ConfigAccordionId(id = 4) + public int barMode = 1; + + @Expose + @ConfigOption(name = "Show Drill Bar", desc = "Allows you to show or hide the Drill Bar.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 4) + public boolean showDrillBar = true; + + @Expose + @ConfigOption(name = "Show Heat Bar", desc = "Allows you to show or hide the Heat Bar.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 4) + public boolean showHeatBar = true; + + @Expose + @ConfigOption(name = "Bar Positions (Requires mode to be Moveable)", desc = "") + @ConfigAccordionId(id = 4) + @ConfigEditorAccordion(id = 5) + public boolean barPositions = false; + + @Expose + @ConfigOption(name = "Drill Bar Position", desc = "Allows you to change the position of the Drill Bar.") + @ConfigEditorButton(runnableId = "drill", buttonText = "Edit") + @ConfigAccordionId(id = 5) + public Position drillBar = new Position(-1, -1); + + @Expose + @ConfigOption(name = "Heat Bar Position", desc = "Allows you to change the position of the Heat Bar.") + @ConfigEditorButton(runnableId = "heat", buttonText = "Edit") + @ConfigAccordionId(id = 5) + public Position heatBar = new Position(-1, -9); + + @Expose + @ConfigOption(name = "Crystal Hollow Waypoints", desc = "") + @ConfigEditorAccordion(id = 6) + public boolean waypoints = false; + + @Expose + @ConfigOption(name = "Auto Waypoint", desc = "Turns on auto waypoints for the main areas of crystal hollows.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 6) + public boolean autoWaypoint = true; + + @Expose + @ConfigOption(name = "Chat Waypoint Mode", desc = "Change the mode of the chat waypoint In Chat Bar will allow you to edit it before adding it to your waypoints.") + @ConfigEditorDropdown(values = { "Instant Add", "In chat bar" }) + @ConfigAccordionId(id = 6) + public int chatWaypointMode = 1; + } + + public static class Trackers { + + @Expose + @ConfigOption(name = "Tracker Position", desc = "Allows you to change the position of the Trackers.") + @ConfigEditorButton(runnableId = "tracker", buttonText = "Edit") + public Position trackerPosition = new Position(-1, 200); + + @Expose + @ConfigOption(name = "Hide Tracker", desc = "It will still track the data just in case.") + @ConfigEditorBoolean + public boolean hideTracker = true; + } +} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java new file mode 100644 index 000000000..113037066 --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java @@ -0,0 +1,602 @@ +package com.thatgravyboat.skyblockhud.config; + +import static com.thatgravyboat.skyblockhud.GuiTextures.DISCORD; +import static com.thatgravyboat.skyblockhud.GuiTextures.TWITTER; + +import com.google.common.collect.Lists; +import com.thatgravyboat.skyblockhud.core.GlScissorStack; +import com.thatgravyboat.skyblockhud.core.GuiElement; +import com.thatgravyboat.skyblockhud.core.config.Config; +import com.thatgravyboat.skyblockhud.core.config.gui.GuiOptionEditor; +import com.thatgravyboat.skyblockhud.core.config.gui.GuiOptionEditorAccordion; +import com.thatgravyboat.skyblockhud.core.config.struct.ConfigProcessor; +import com.thatgravyboat.skyblockhud.core.util.lerp.LerpUtils; +import com.thatgravyboat.skyblockhud.core.util.lerp.LerpingInteger; +import com.thatgravyboat.skyblockhud.core.util.render.RenderUtils; +import com.thatgravyboat.skyblockhud.core.util.render.TextRenderUtils; +import java.awt.*; +import java.net.URI; +import java.util.*; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +public class SBHConfigEditor extends GuiElement { + + private static final ResourceLocation[] socialsIco = new ResourceLocation[] { DISCORD, TWITTER }; + private static final String[] socialsLink = new String[] { "https://discord.gg/moulberry", "https://twitter.com/thatgravyboat/" }; + + private final long openedMillis; + + private String selectedCategory = null; + + private final LerpingInteger optionsScroll = new LerpingInteger(0, 150); + private final LerpingInteger categoryScroll = new LerpingInteger(0, 150); + + private LinkedHashMap<String, ConfigProcessor.ProcessedCategory> processedConfig; + private TreeMap<String, Set<ConfigProcessor.ProcessedOption>> searchOptionMap = new TreeMap<>(); + private HashMap<ConfigProcessor.ProcessedOption, ConfigProcessor.ProcessedCategory> categoryForOption = new HashMap<>(); + + public SBHConfigEditor(Config config) { + this(config, null); + } + + public SBHConfigEditor(Config config, String categoryOpen) { + this.openedMillis = System.currentTimeMillis(); + this.processedConfig = ConfigProcessor.create(config); + + for (ConfigProcessor.ProcessedCategory category : processedConfig.values()) { + for (ConfigProcessor.ProcessedOption option : category.options.values()) { + categoryForOption.put(option, category); + } + } + + if (categoryOpen != null) { + for (Map.Entry<String, ConfigProcessor.ProcessedCategory> category : processedConfig.entrySet()) { + if (category.getValue().name.equalsIgnoreCase(categoryOpen)) { + selectedCategory = category.getKey(); + break; + } + } + if (selectedCategory == null) { + for (Map.Entry<String, ConfigProcessor.ProcessedCategory> category : processedConfig.entrySet()) { + if (category.getValue().name.toLowerCase().startsWith(categoryOpen.toLowerCase())) { + selectedCategory = category.getKey(); + break; + } + } + } + if (selectedCategory == null) { + for (Map.Entry<String, ConfigProcessor.ProcessedCategory> category : processedConfig.entrySet()) { + if (category.getValue().name.toLowerCase().contains(categoryOpen.toLowerCase())) { + selectedCategory = category.getKey(); + break; + } + } + } + } + } + + private LinkedHashMap<String, ConfigProcessor.ProcessedCategory> getCurrentConfigEditing() { + return new LinkedHashMap<>(processedConfig); + } + + private LinkedHashMap<String, ConfigProcessor.ProcessedOption> getOptionsInCategory(ConfigProcessor.ProcessedCategory cat) { + return new LinkedHashMap<>(cat.options); + } + + public String getSelectedCategory() { + return selectedCategory; + } + + public String getSelectedCategoryName() { + return processedConfig.get(selectedCategory).name; + } + + private void setSelectedCategory(String category) { + selectedCategory = category; + optionsScroll.setValue(0); + } + + public void render() { + optionsScroll.tick(); + categoryScroll.tick(); + + List<String> tooltipToDisplay = null; + + long currentTime = System.currentTimeMillis(); + long delta = currentTime - openedMillis; + + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + float opacityFactor = LerpUtils.sigmoidZeroOne(delta / 500f); + RenderUtils.drawGradientRect(0, 0, 0, width, height, (int) (0x80 * opacityFactor) << 24 | 0x101010, (int) (0x90 * opacityFactor) << 24 | 0x101010); + + int xSize = Math.min(scaledResolution.getScaledWidth() - 100 / scaledResolution.getScaleFactor(), 500); + int ySize = Math.min(scaledResolution.getScaledHeight() - 100 / scaledResolution.getScaleFactor(), 400); + + int x = (scaledResolution.getScaledWidth() - xSize) / 2; + int y = (scaledResolution.getScaledHeight() - ySize) / 2; + + int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); + + int openingXSize = xSize; + int openingYSize = ySize; + if (delta < 150) { + openingXSize = (int) (delta * xSize / 150); + openingYSize = 5; + } else if (delta < 300) { + openingYSize = 5 + (int) (delta - 150) * (ySize - 5) / 150; + } + RenderUtils.drawFloatingRectDark((scaledResolution.getScaledWidth() - openingXSize) / 2, (scaledResolution.getScaledHeight() - openingYSize) / 2, openingXSize, openingYSize); + GlScissorStack.clear(); + GlScissorStack.push((scaledResolution.getScaledWidth() - openingXSize) / 2, (scaledResolution.getScaledHeight() - openingYSize) / 2, (scaledResolution.getScaledWidth() + openingXSize) / 2, (scaledResolution.getScaledHeight() + openingYSize) / 2, scaledResolution); + + RenderUtils.drawFloatingRectDark(x + 5, y + 5, xSize - 10, 20, false); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + TextRenderUtils.drawStringCenteredScaledMaxWidth("SkyBlockHud by " + EnumChatFormatting.RED + "ThatGravyBoat" + EnumChatFormatting.RESET + ", config by " + EnumChatFormatting.DARK_PURPLE + "Moulberry", fr, x + xSize / 2f, y + 15, false, 200, 0xa0a0a0); + + RenderUtils.drawFloatingRectDark(x + 4, y + 49 - 20, 140, ySize - 54 + 20, false); + + int innerPadding = 20 / adjScaleFactor; + int innerLeft = x + 4 + innerPadding; + int innerRight = x + 144 - innerPadding; + int innerTop = y + 49 + innerPadding; + int innerBottom = y + ySize - 5 - innerPadding; + Gui.drawRect(innerLeft, innerTop, innerLeft + 1, innerBottom, 0xff08080E); //Left + Gui.drawRect(innerLeft + 1, innerTop, innerRight, innerTop + 1, 0xff08080E); //Top + Gui.drawRect(innerRight - 1, innerTop + 1, innerRight, innerBottom, 0xff28282E); //Right + Gui.drawRect(innerLeft + 1, innerBottom - 1, innerRight - 1, innerBottom, 0xff28282E); //Bottom + Gui.drawRect(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, 0x6008080E); //Middle + + GlScissorStack.push(0, innerTop + 1, scaledResolution.getScaledWidth(), innerBottom - 1, scaledResolution); + + float catBarSize = 1; + int catY = -categoryScroll.getValue(); + + LinkedHashMap<String, ConfigProcessor.ProcessedCategory> currentConfigEditing = getCurrentConfigEditing(); + for (Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : currentConfigEditing.entrySet()) { + String selectedCategory = getSelectedCategory(); + if (selectedCategory == null || !currentConfigEditing.containsKey(selectedCategory)) { + setSelectedCategory(entry.getKey()); + } + String catName = entry.getValue().name; + if (entry.getKey().equals(getSelectedCategory())) { + catName = EnumChatFormatting.DARK_AQUA.toString() + EnumChatFormatting.UNDERLINE + catName; + } else { + catName = EnumChatFormatting.GRAY + catName; + } + TextRenderUtils.drawStringCenteredScaledMaxWidth(catName, fr, x + 75, y + 70 + catY, false, 100, -1); + catY += 15; + if (catY > 0) { + catBarSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (catY + 5 + categoryScroll.getValue())); + } + } + + float catBarStart = categoryScroll.getValue() / (float) (catY + categoryScroll.getValue()); + float catBarEnd = catBarStart + catBarSize; + if (catBarEnd > 1) { + catBarEnd = 1; + if (categoryScroll.getTarget() / (float) (catY + categoryScroll.getValue()) + catBarSize < 1) { + int target = optionsScroll.getTarget(); + categoryScroll.setValue((int) Math.ceil((catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue()))); + categoryScroll.setTarget(target); + } else { + categoryScroll.setValue((int) Math.ceil((catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue()))); + } + } + int catDist = innerBottom - innerTop - 12; + Gui.drawRect(innerLeft + 2, innerTop + 5, innerLeft + 7, innerBottom - 5, 0xff101010); + Gui.drawRect(innerLeft + 3, innerTop + 6 + (int) (catDist * catBarStart), innerLeft + 6, innerTop + 6 + (int) (catDist * catBarEnd), 0xff303030); + + GlScissorStack.pop(scaledResolution); + + TextRenderUtils.drawStringCenteredScaledMaxWidth("Categories", fr, x + 75, y + 44, false, 120, 0xa368ef); + + RenderUtils.drawFloatingRectDark(x + 149, y + 29, xSize - 154, ySize - 34, false); + + innerLeft = x + 149 + innerPadding; + innerRight = x + xSize - 5 - innerPadding; + innerBottom = y + ySize - 5 - innerPadding; + + GlStateManager.color(1, 1, 1, 1); + int rightStuffLen = 20; + + if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { + ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); + + TextRenderUtils.drawStringScaledMaxWidth(cat.desc, fr, innerLeft + 5, y + 40, true, innerRight - innerLeft - rightStuffLen - 10, 0xb0b0b0); + } + + Gui.drawRect(innerLeft, innerTop, innerLeft + 1, innerBottom, 0xff08080E); //Left + Gui.drawRect(innerLeft + 1, innerTop, innerRight, innerTop + 1, 0xff08080E); //Top + Gui.drawRect(innerRight - 1, innerTop + 1, innerRight, innerBottom, 0xff303036); //Right + Gui.drawRect(innerLeft + 1, innerBottom - 1, innerRight - 1, innerBottom, 0xff303036); //Bottom + Gui.drawRect(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, 0x6008080E); //Middle + + GlScissorStack.push(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, scaledResolution); + float barSize = 1; + int optionY = -optionsScroll.getValue(); + if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { + ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); + int optionWidthDefault = innerRight - innerLeft - 20; + GlStateManager.enableDepth(); + HashMap<Integer, Integer> activeAccordions = new HashMap<>(); + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + int optionWidth = optionWidthDefault; + if (option.accordionId >= 0) { + if (!activeAccordions.containsKey(option.accordionId)) { + continue; + } + int accordionDepth = activeAccordions.get(option.accordionId); + optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1); + } + + GuiOptionEditor editor = option.editor; + if (editor == null) { + continue; + } + if (editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if (accordion.getToggled()) { + int accordionDepth = 0; + if (option.accordionId >= 0) { + accordionDepth = activeAccordions.get(option.accordionId) + 1; + } + activeAccordions.put(accordion.getAccordionId(), accordionDepth); + } + } + int optionHeight = editor.getHeight(); + if (innerTop + 5 + optionY + optionHeight > innerTop + 1 && innerTop + 5 + optionY < innerBottom - 1) { + editor.render((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionY, optionWidth); + } + optionY += optionHeight + 5; + } + GlStateManager.disableDepth(); + if (optionY > 0) { + barSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (optionY + 5 + optionsScroll.getValue())); + } + } + + GlScissorStack.pop(scaledResolution); + + GL11.glDisable(GL11.GL_SCISSOR_TEST); + if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { + int optionYOverlay = -optionsScroll.getValue(); + ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); + int optionWidthDefault = innerRight - innerLeft - 20; + + GlStateManager.translate(0, 0, 10); + GlStateManager.enableDepth(); + HashMap<Integer, Integer> activeAccordions = new HashMap<>(); + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + int optionWidth = optionWidthDefault; + if (option.accordionId >= 0) { + if (!activeAccordions.containsKey(option.accordionId)) { + continue; + } + int accordionDepth = activeAccordions.get(option.accordionId); + optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1); + } + + GuiOptionEditor editor = option.editor; + if (editor == null) { + continue; + } + if (editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if (accordion.getToggled()) { + int accordionDepth = 0; + if (option.accordionId >= 0) { + accordionDepth = activeAccordions.get(option.accordionId) + 1; + } + activeAccordions.put(accordion.getAccordionId(), accordionDepth); + } + } + int optionHeight = editor.getHeight(); + if (innerTop + 5 + optionYOverlay + optionHeight > innerTop + 1 && innerTop + 5 + optionYOverlay < innerBottom - 1) { + editor.renderOverlay((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionYOverlay, optionWidth); + } + optionYOverlay += optionHeight + 5; + } + GlStateManager.disableDepth(); + GlStateManager.translate(0, 0, -10); + } + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + float barStart = optionsScroll.getValue() / (float) (optionY + optionsScroll.getValue()); + float barEnd = barStart + barSize; + if (barEnd > 1) { + barEnd = 1; + if (optionsScroll.getTarget() / (float) (optionY + optionsScroll.getValue()) + barSize < 1) { + int target = optionsScroll.getTarget(); + optionsScroll.setValue((int) Math.ceil((optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue()))); + optionsScroll.setTarget(target); + } else { + optionsScroll.setValue((int) Math.ceil((optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue()))); + } + } + int dist = innerBottom - innerTop - 12; + Gui.drawRect(innerRight - 10, innerTop + 5, innerRight - 5, innerBottom - 5, 0xff101010); + Gui.drawRect(innerRight - 9, innerTop + 6 + (int) (dist * barStart), innerRight - 6, innerTop + 6 + (int) (dist * barEnd), 0xff303030); + + for (int socialIndex = 0; socialIndex < socialsIco.length; socialIndex++) { + Minecraft.getMinecraft().getTextureManager().bindTexture(socialsIco[socialIndex]); + GlStateManager.color(1, 1, 1, 1); + int socialLeft = x + xSize - 23 - 18 * socialIndex; + RenderUtils.drawTexturedRect(socialLeft, y + 7, 16, 16, GL11.GL_LINEAR); + + if (mouseX >= socialLeft && mouseX <= socialLeft + 16 && mouseY >= y + 6 && mouseY <= y + 23) { + tooltipToDisplay = Lists.newArrayList(EnumChatFormatting.YELLOW + "Go to: " + EnumChatFormatting.RESET + socialsLink[socialIndex]); + } + } + + GlScissorStack.clear(); + + if (tooltipToDisplay != null) { + TextRenderUtils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr); + } + + GlStateManager.translate(0, 0, -2); + } + + public boolean mouseInput(int mouseX, int mouseY) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + + int xSize = Math.min(width - 100 / scaledResolution.getScaleFactor(), 500); + int ySize = Math.min(height - 100 / scaledResolution.getScaleFactor(), 400); + + int x = (scaledResolution.getScaledWidth() - xSize) / 2; + int y = (scaledResolution.getScaledHeight() - ySize) / 2; + + int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); + + int innerPadding = 20 / adjScaleFactor; + int innerTop = y + 49 + innerPadding; + int innerBottom = y + ySize - 5 - innerPadding; + int innerLeft = x + 149 + innerPadding; + int innerRight = x + xSize - 5 - innerPadding; + + int dWheel = Mouse.getEventDWheel(); + if (mouseY > innerTop && mouseY < innerBottom && dWheel != 0) { + if (dWheel < 0) { + dWheel = -1; + } + if (dWheel > 0) { + dWheel = 1; + } + if (mouseX < innerLeft) { + int newTarget = categoryScroll.getTarget() - dWheel * 30; + if (newTarget < 0) { + newTarget = 0; + } + + float catBarSize = 1; + int catY = -newTarget; + for (Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : getCurrentConfigEditing().entrySet()) { + if (getSelectedCategory() == null) { + setSelectedCategory(entry.getKey()); + } + + catY += 15; + if (catY > 0) { + catBarSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (catY + 5 + newTarget)); + } + } + + int barMax = (int) Math.floor((catY + 5 + newTarget) - catBarSize * (catY + 5 + newTarget)); + if (newTarget > barMax) { + newTarget = barMax; + } + categoryScroll.resetTimer(); + categoryScroll.setTarget(newTarget); + } else { + int newTarget = optionsScroll.getTarget() - dWheel * 30; + if (newTarget < 0) { + newTarget = 0; + } + + float barSize = 1; + int optionY = -newTarget; + if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); + HashMap<Integer, Integer> activeAccordions = new HashMap<>(); + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + if (option.accordionId >= 0) { + if (!activeAccordions.containsKey(option.accordionId)) { + continue; + } + } + + GuiOptionEditor editor = option.editor; + if (editor == null) { + continue; + } + if (editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if (accordion.getToggled()) { + int accordionDepth = 0; + if (option.accordionId >= 0) { + accordionDepth = activeAccordions.get(option.accordionId) + 1; + } + activeAccordions.put(accordion.getAccordionId(), accordionDepth); + } + } + optionY += editor.getHeight() + 5; + + if (optionY > 0) { + barSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (optionY + 5 + newTarget)); + } + } + } + + int barMax = (int) Math.floor((optionY + 5 + newTarget) - barSize * (optionY + 5 + newTarget)); + if (newTarget > barMax) { + newTarget = barMax; + } + optionsScroll.setTimeToReachTarget(Math.min(150, Math.max(10, 5 * Math.abs(newTarget - optionsScroll.getValue())))); + optionsScroll.resetTimer(); + optionsScroll.setTarget(newTarget); + } + } else if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { + if (getCurrentConfigEditing() != null) { + int catY = -categoryScroll.getValue(); + for (Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : getCurrentConfigEditing().entrySet()) { + if (getSelectedCategory() == null) { + setSelectedCategory(entry.getKey()); + } + if (mouseX >= x + 5 && mouseX <= x + 145 && mouseY >= y + 70 + catY - 7 && mouseY <= y + 70 + catY + 7) { + setSelectedCategory(entry.getKey()); + return true; + } + catY += 15; + } + } + + for (int socialIndex = 0; socialIndex < socialsLink.length; socialIndex++) { + int socialLeft = x + xSize - 23 - 18 * socialIndex; + + if (mouseX >= socialLeft && mouseX <= socialLeft + 16 && mouseY >= y + 6 && mouseY <= y + 23) { + try { + Desktop.getDesktop().browse(new URI(socialsLink[socialIndex])); + } catch (Exception ignored) {} + return true; + } + } + } + + int optionY = -optionsScroll.getValue(); + if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { + int optionWidthDefault = innerRight - innerLeft - 20; + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); + HashMap<Integer, Integer> activeAccordions = new HashMap<>(); + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + int optionWidth = optionWidthDefault; + if (option.accordionId >= 0) { + if (!activeAccordions.containsKey(option.accordionId)) { + continue; + } + int accordionDepth = activeAccordions.get(option.accordionId); + optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1); + } + + GuiOptionEditor editor = option.editor; + if (editor == null) { + continue; + } + if (editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if (accordion.getToggled()) { + int accordionDepth = 0; + if (option.accordionId >= 0) { + accordionDepth = activeAccordions.get(option.accordionId) + 1; + } + activeAccordions.put(accordion.getAccordionId(), accordionDepth); + } + } + if (editor.mouseInputOverlay((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionY, optionWidth, mouseX, mouseY)) { + return true; + } + optionY += editor.getHeight() + 5; + } + } + + if (mouseX > innerLeft && mouseX < innerRight && mouseY > innerTop && mouseY < innerBottom) { + optionY = -optionsScroll.getValue(); + if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { + int optionWidthDefault = innerRight - innerLeft - 20; + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); + HashMap<Integer, Integer> activeAccordions = new HashMap<>(); + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + int optionWidth = optionWidthDefault; + if (option.accordionId >= 0) { + if (!activeAccordions.containsKey(option.accordionId)) { + continue; + } + int accordionDepth = activeAccordions.get(option.accordionId); + optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1); + } + + GuiOptionEditor editor = option.editor; + if (editor == null) { + continue; + } + if (editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if (accordion.getToggled()) { + int accordionDepth = 0; + if (option.accordionId >= 0) { + accordionDepth = activeAccordions.get(option.accordionId) + 1; + } + activeAccordions.put(accordion.getAccordionId(), accordionDepth); + } + } + if (editor.mouseInput((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionY, optionWidth, mouseX, mouseY)) { + return true; + } + optionY += editor.getHeight() + 5; + } + } + } + + return true; + } + + public boolean keyboardInput() { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + int width = scaledResolution.getScaledWidth(); + + int xSize = Math.min(width - 100 / scaledResolution.getScaleFactor(), 500); + + int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); + + int innerPadding = 20 / adjScaleFactor; + int innerWidth = xSize - 154 - innerPadding * 2; + + if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); + HashMap<Integer, Integer> activeAccordions = new HashMap<>(); + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + if (option.accordionId >= 0) { + if (!activeAccordions.containsKey(option.accordionId)) { + continue; + } + } + + GuiOptionEditor editor = option.editor; + if (editor == null) { + continue; + } + if (editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if (accordion.getToggled()) { + int accordionDepth = 0; + if (option.accordionId >= 0) { + accordionDepth = activeAccordions.get(option.accordionId) + 1; + } + activeAccordions.put(accordion.getAccordionId(), accordionDepth); + } + } + if (editor.keyboardInput()) { + return true; + } + } + } + + return true; + } +} |