From 6108ddcf353390cc0d2ddd40e3802d025fc5f4a4 Mon Sep 17 00:00:00 2001 From: Lorenz Date: Thu, 14 Jul 2022 11:28:50 +0200 Subject: changed packages --- .../java/com/thatgravyboat/amod/GuiTextures.java | 32 -- .../com/thatgravyboat/amod/commands/Commands.java | 31 -- .../thatgravyboat/amod/commands/SimpleCommand.java | 60 -- .../thatgravyboat/amod/config/ConfigEditor.java | 602 --------------------- .../thatgravyboat/amod/core/BackgroundBlur.java | 249 --------- .../com/thatgravyboat/amod/core/ChromaColour.java | 93 ---- .../thatgravyboat/amod/core/GlScissorStack.java | 86 --- .../com/thatgravyboat/amod/core/GuiElement.java | 12 - .../thatgravyboat/amod/core/GuiElementBoolean.java | 118 ---- .../thatgravyboat/amod/core/GuiElementColour.java | 370 ------------- .../amod/core/GuiElementTextField.java | 549 ------------------- .../amod/core/GuiScreenElementWrapper.java | 34 -- .../com/thatgravyboat/amod/core/config/Config.java | 5 - .../amod/core/config/KeybindHelper.java | 49 -- .../thatgravyboat/amod/core/config/Position.java | 197 ------- .../amod/core/config/annotations/Category.java | 14 - .../core/config/annotations/ConfigAccordionId.java | 12 - .../config/annotations/ConfigEditorAccordion.java | 12 - .../config/annotations/ConfigEditorBoolean.java | 11 - .../config/annotations/ConfigEditorButton.java | 14 - .../config/annotations/ConfigEditorColour.java | 11 - .../annotations/ConfigEditorDraggableList.java | 12 - .../config/annotations/ConfigEditorDropdown.java | 14 - .../config/annotations/ConfigEditorKeybind.java | 12 - .../config/annotations/ConfigEditorSlider.java | 16 - .../core/config/annotations/ConfigEditorStyle.java | 11 - .../core/config/annotations/ConfigEditorText.java | 11 - .../amod/core/config/annotations/ConfigOption.java | 16 - .../amod/core/config/gui/GuiOptionEditor.java | 62 --- .../core/config/gui/GuiOptionEditorAccordion.java | 80 --- .../core/config/gui/GuiOptionEditorBoolean.java | 37 -- .../core/config/gui/GuiOptionEditorButton.java | 60 -- .../core/config/gui/GuiOptionEditorColour.java | 74 --- .../config/gui/GuiOptionEditorDraggableList.java | 268 --------- .../core/config/gui/GuiOptionEditorDropdown.java | 145 ----- .../core/config/gui/GuiOptionEditorKeybind.java | 88 --- .../core/config/gui/GuiOptionEditorSlider.java | 136 ----- .../amod/core/config/gui/GuiOptionEditorStyle.java | 42 -- .../amod/core/config/gui/GuiOptionEditorText.java | 78 --- .../amod/core/config/gui/GuiPositionEditor.java | 171 ------ .../amod/core/config/struct/ConfigProcessor.java | 166 ------ .../amod/core/util/GuiElementSlider.java | 120 ---- .../thatgravyboat/amod/core/util/StringUtils.java | 8 - .../amod/core/util/lerp/LerpUtils.java | 25 - .../amod/core/util/lerp/LerpingFloat.java | 68 --- .../amod/core/util/lerp/LerpingInteger.java | 76 --- .../amod/core/util/render/RenderUtils.java | 155 ------ .../amod/core/util/render/TextRenderUtils.java | 155 ------ .../thatgravyboat/amod/textures/TextureObject.java | 37 -- .../com/thatgravyboat/amod/textures/Textures.java | 56 -- .../java/com/thatgravyboat/amod/utils/Utils.java | 374 ------------- 51 files changed, 5134 deletions(-) delete mode 100644 src/main/java/com/thatgravyboat/amod/GuiTextures.java delete mode 100644 src/main/java/com/thatgravyboat/amod/commands/Commands.java delete mode 100644 src/main/java/com/thatgravyboat/amod/commands/SimpleCommand.java delete mode 100644 src/main/java/com/thatgravyboat/amod/config/ConfigEditor.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/BackgroundBlur.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/ChromaColour.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/GlScissorStack.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/GuiElement.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/GuiElementBoolean.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/GuiElementColour.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/GuiElementTextField.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/GuiScreenElementWrapper.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/Config.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/KeybindHelper.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/Position.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/annotations/Category.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/annotations/ConfigAccordionId.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/annotations/ConfigEditorAccordion.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/annotations/ConfigEditorBoolean.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/annotations/ConfigEditorButton.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/annotations/ConfigEditorColour.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/annotations/ConfigEditorDraggableList.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/annotations/ConfigEditorDropdown.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/annotations/ConfigEditorKeybind.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/annotations/ConfigEditorSlider.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/annotations/ConfigEditorStyle.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/annotations/ConfigEditorText.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/annotations/ConfigOption.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/gui/GuiOptionEditor.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/gui/GuiOptionEditorAccordion.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/gui/GuiOptionEditorBoolean.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/gui/GuiOptionEditorButton.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/gui/GuiOptionEditorColour.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/gui/GuiOptionEditorDraggableList.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/gui/GuiOptionEditorDropdown.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/gui/GuiOptionEditorKeybind.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/gui/GuiOptionEditorSlider.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/gui/GuiOptionEditorStyle.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/gui/GuiOptionEditorText.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/gui/GuiPositionEditor.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/config/struct/ConfigProcessor.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/util/GuiElementSlider.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/util/StringUtils.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/util/lerp/LerpUtils.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/util/lerp/LerpingFloat.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/util/lerp/LerpingInteger.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/util/render/RenderUtils.java delete mode 100644 src/main/java/com/thatgravyboat/amod/core/util/render/TextRenderUtils.java delete mode 100644 src/main/java/com/thatgravyboat/amod/textures/TextureObject.java delete mode 100644 src/main/java/com/thatgravyboat/amod/textures/Textures.java delete mode 100644 src/main/java/com/thatgravyboat/amod/utils/Utils.java (limited to 'src/main/java/com') diff --git a/src/main/java/com/thatgravyboat/amod/GuiTextures.java b/src/main/java/com/thatgravyboat/amod/GuiTextures.java deleted file mode 100644 index 605fc5c00..000000000 --- a/src/main/java/com/thatgravyboat/amod/GuiTextures.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.thatgravyboat.amod; - -import net.minecraft.util.ResourceLocation; - -public class GuiTextures { - - private GuiTextures() {} - - public static final ResourceLocation DISCORD = new ResourceLocation("lorenzmod:discord.png"); - - public static final ResourceLocation button_tex = new ResourceLocation("lorenzmod:button.png"); - - public static final ResourceLocation button_white = new ResourceLocation("lorenzmod:button_white.png"); - - public static final ResourceLocation BAR = new ResourceLocation("lorenzmod:core/bar.png"); - public static final ResourceLocation OFF = new ResourceLocation("lorenzmod:core/toggle_off.png"); - public static final ResourceLocation ONE = new ResourceLocation("lorenzmod:core/toggle_1.png"); - public static final ResourceLocation TWO = new ResourceLocation("lorenzmod:core/toggle_2.png"); - public static final ResourceLocation THREE = new ResourceLocation("lorenzmod:core/toggle_3.png"); - public static final ResourceLocation ON = new ResourceLocation("lorenzmod:core/toggle_on.png"); - public static final ResourceLocation DELETE = new ResourceLocation("lorenzmod:core/delete.png"); - - public static final ResourceLocation slider_off_cap = new ResourceLocation("lorenzmod:core/slider/slider_off_cap.png"); - public static final ResourceLocation slider_off_notch = new ResourceLocation("lorenzmod:core/slider/slider_off_notch.png"); - public static final ResourceLocation slider_off_segment = new ResourceLocation("lorenzmod:core/slider/slider_off_segment.png"); - public static final ResourceLocation slider_on_cap = new ResourceLocation("lorenzmod:core/slider/slider_on_cap.png"); - public static final ResourceLocation slider_on_notch = new ResourceLocation("lorenzmod:core/slider/slider_on_notch.png"); - public static final ResourceLocation slider_on_segment = new ResourceLocation("lorenzmod:core/slider/slider_on_segment.png"); - public static final ResourceLocation slider_button_new = new ResourceLocation("lorenzmod:core/slider/slider_button.png"); - - public static final ResourceLocation mapOverlay = new ResourceLocation("lorenzmod", "maps/map_overlay.png"); -} diff --git a/src/main/java/com/thatgravyboat/amod/commands/Commands.java b/src/main/java/com/thatgravyboat/amod/commands/Commands.java deleted file mode 100644 index 97188933a..000000000 --- a/src/main/java/com/thatgravyboat/amod/commands/Commands.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.thatgravyboat.amod.commands; - -import at.lorenz.mod.LorenzMod; -import com.thatgravyboat.amod.config.ConfigEditor; -import com.thatgravyboat.amod.core.GuiScreenElementWrapper; -import net.minecraft.command.ICommandSender; -import net.minecraftforge.client.ClientCommandHandler; -import org.apache.commons.lang3.StringUtils; - -public class Commands { - - private static final boolean devMode = false; - - private static final SimpleCommand.ProcessCommandRunnable settingsRunnable = new SimpleCommand.ProcessCommandRunnable() { - public void processCommand(ICommandSender sender, String[] args) { - if (args.length > 0) { - LorenzMod.screenToOpen = new GuiScreenElementWrapper(new ConfigEditor(LorenzMod.feature, StringUtils.join(args, " "))); - } else { - LorenzMod.screenToOpen = new GuiScreenElementWrapper(new ConfigEditor(LorenzMod.feature)); - } - } - }; - - private static final SimpleCommand settingsCommand = new SimpleCommand("lm", settingsRunnable); - private static final SimpleCommand settingsCommand2 = new SimpleCommand("lorenzmod", settingsRunnable); - - public static void init() { - ClientCommandHandler.instance.registerCommand(settingsCommand); - ClientCommandHandler.instance.registerCommand(settingsCommand2); - } -} diff --git a/src/main/java/com/thatgravyboat/amod/commands/SimpleCommand.java b/src/main/java/com/thatgravyboat/amod/commands/SimpleCommand.java deleted file mode 100644 index dc1657976..000000000 --- a/src/main/java/com/thatgravyboat/amod/commands/SimpleCommand.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.thatgravyboat.amod.commands; - -import java.util.List; -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.BlockPos; - -/** - @author Moulberry - **/ -public class SimpleCommand extends CommandBase { - - private final String commandName; - private final ProcessCommandRunnable runnable; - private TabCompleteRunnable tabRunnable; - - public SimpleCommand(String commandName, ProcessCommandRunnable runnable) { - this.commandName = commandName; - this.runnable = runnable; - } - - public SimpleCommand(String commandName, ProcessCommandRunnable runnable, TabCompleteRunnable tabRunnable) { - this.commandName = commandName; - this.runnable = runnable; - this.tabRunnable = tabRunnable; - } - - public abstract static class ProcessCommandRunnable { - - public abstract void processCommand(ICommandSender sender, String[] args); - } - - public abstract static class TabCompleteRunnable { - - public abstract List tabComplete(ICommandSender sender, String[] args, BlockPos pos); - } - - public boolean canCommandSenderUseCommand(ICommandSender sender) { - return true; - } - - public String getCommandName() { - return commandName; - } - - public String getCommandUsage(ICommandSender sender) { - return "/" + commandName; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - runnable.processCommand(sender, args); - } - - @Override - public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { - if (tabRunnable != null) return tabRunnable.tabComplete(sender, args, pos); - return null; - } -} diff --git a/src/main/java/com/thatgravyboat/amod/config/ConfigEditor.java b/src/main/java/com/thatgravyboat/amod/config/ConfigEditor.java deleted file mode 100644 index 1c22fbbe8..000000000 --- a/src/main/java/com/thatgravyboat/amod/config/ConfigEditor.java +++ /dev/null @@ -1,602 +0,0 @@ -package com.thatgravyboat.amod.config; - -import static com.thatgravyboat.amod.GuiTextures.DISCORD; - -import at.lorenz.mod.LorenzMod; -import at.lorenz.mod.config.Features; -import com.google.common.collect.Lists; -import com.thatgravyboat.amod.core.GlScissorStack; -import com.thatgravyboat.amod.core.GuiElement; -import com.thatgravyboat.amod.core.config.gui.GuiOptionEditor; -import com.thatgravyboat.amod.core.config.gui.GuiOptionEditorAccordion; -import com.thatgravyboat.amod.core.config.struct.ConfigProcessor; -import com.thatgravyboat.amod.core.util.lerp.LerpUtils; -import com.thatgravyboat.amod.core.util.lerp.LerpingInteger; -import com.thatgravyboat.amod.core.util.render.RenderUtils; -import com.thatgravyboat.amod.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 ConfigEditor extends GuiElement { - - private static final ResourceLocation[] socialsIco = new ResourceLocation[] { DISCORD }; - private static final String[] socialsLink = new String[] { "https://discord.gg/NcvkPDBA6Y" }; - - 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 final LinkedHashMap processedConfig; - private final TreeMap> searchOptionMap = new TreeMap<>(); - private final HashMap categoryForOption = new HashMap<>(); - - public ConfigEditor(Features config) { - this(config, null); - } - - public ConfigEditor(Features 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 category : processedConfig.entrySet()) { - if (category.getValue().name.equalsIgnoreCase(categoryOpen)) { - selectedCategory = category.getKey(); - break; - } - } - if (selectedCategory == null) { - for (Map.Entry category : processedConfig.entrySet()) { - if (category.getValue().name.toLowerCase().startsWith(categoryOpen.toLowerCase())) { - selectedCategory = category.getKey(); - break; - } - } - } - if (selectedCategory == null) { - for (Map.Entry category : processedConfig.entrySet()) { - if (category.getValue().name.toLowerCase().contains(categoryOpen.toLowerCase())) { - selectedCategory = category.getKey(); - break; - } - } - } - } - } - - private LinkedHashMap getCurrentConfigEditing() { - return new LinkedHashMap<>(processedConfig); - } - - private LinkedHashMap 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 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("LorenzMod " + LorenzMod.VERSION + " by " + EnumChatFormatting.RED + "hannibal2" + 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 currentConfigEditing = getCurrentConfigEditing(); - for (Map.Entry 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 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 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 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 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 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 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 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 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; - } -} diff --git a/src/main/java/com/thatgravyboat/amod/core/BackgroundBlur.java b/src/main/java/com/thatgravyboat/amod/core/BackgroundBlur.java deleted file mode 100644 index 93dafb9b3..000000000 --- a/src/main/java/com/thatgravyboat/amod/core/BackgroundBlur.java +++ /dev/null @@ -1,249 +0,0 @@ -package com.thatgravyboat.amod.core; - -import com.thatgravyboat.amod.core.util.render.RenderUtils; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.shader.Framebuffer; -import net.minecraft.client.shader.Shader; -import net.minecraft.util.Matrix4f; -import net.minecraftforge.client.event.EntityViewRenderEvent; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL30; - -public class BackgroundBlur { - - private static class OutputStuff { - - public Framebuffer framebuffer; - public Shader blurShaderHorz = null; - public Shader blurShaderVert = null; - - public OutputStuff(Framebuffer framebuffer, Shader blurShaderHorz, Shader blurShaderVert) { - this.framebuffer = framebuffer; - this.blurShaderHorz = blurShaderHorz; - this.blurShaderVert = blurShaderVert; - } - } - - private static final HashMap blurOutput = new HashMap<>(); - private static final HashMap lastBlurUse = new HashMap<>(); - private static long lastBlur = 0; - private static final HashSet requestedBlurs = new HashSet<>(); - - private static int fogColour = 0; - private static boolean registered = false; - - public static void registerListener() { - if (!registered) { - registered = true; - MinecraftForge.EVENT_BUS.register(new BackgroundBlur()); - } - } - - private static boolean shouldBlur = true; - - public static void markDirty() { - if (Minecraft.getMinecraft().theWorld != null) { - shouldBlur = true; - } - } - - public static void processBlurs() { - if (shouldBlur) { - shouldBlur = false; - - long currentTime = System.currentTimeMillis(); - - for (float blur : requestedBlurs) { - lastBlur = currentTime; - lastBlurUse.put(blur, currentTime); - - int width = Minecraft.getMinecraft().displayWidth; - int height = Minecraft.getMinecraft().displayHeight; - - OutputStuff output = blurOutput.computeIfAbsent( - blur, - k -> { - Framebuffer fb = new Framebuffer(width, height, false); - fb.setFramebufferFilter(GL11.GL_NEAREST); - return new OutputStuff(fb, null, null); - } - ); - - if (output.framebuffer.framebufferWidth != width || output.framebuffer.framebufferHeight != height) { - output.framebuffer.createBindFramebuffer(width, height); - if (output.blurShaderHorz != null) { - output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); - } - if (output.blurShaderVert != null) { - output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); - } - } - - blurBackground(output, blur); - } - - Set remove = new HashSet<>(); - for (Map.Entry entry : lastBlurUse.entrySet()) { - if (currentTime - entry.getValue() > 30 * 1000) { - remove.add(entry.getKey()); - } - } - remove.remove(5f); - - lastBlurUse.keySet().removeAll(remove); - blurOutput.keySet().removeAll(remove); - - requestedBlurs.clear(); - } - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onScreenRender(RenderGameOverlayEvent.Pre event) { - if (event.type == RenderGameOverlayEvent.ElementType.ALL) { - processBlurs(); - } - } - - @SubscribeEvent - public void onFogColour(EntityViewRenderEvent.FogColors event) { - fogColour = 0xff000000; - fogColour |= ((int) (event.red * 255) & 0xFF) << 16; - fogColour |= ((int) (event.green * 255) & 0xFF) << 8; - fogColour |= (int) (event.blue * 255) & 0xFF; - } - - private static Framebuffer blurOutputHorz = null; - - /** - * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate - * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis). - * - * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to - * apply scales and translations manually. - */ - private static Matrix4f createProjectionMatrix(int width, int height) { - Matrix4f projMatrix = new Matrix4f(); - projMatrix.setIdentity(); - projMatrix.m00 = 2.0F / (float) width; - projMatrix.m11 = 2.0F / (float) (-height); - projMatrix.m22 = -0.0020001999F; - projMatrix.m33 = 1.0F; - projMatrix.m03 = -1.0F; - projMatrix.m13 = 1.0F; - projMatrix.m23 = -1.0001999F; - return projMatrix; - } - - private static void blurBackground(OutputStuff output, float blurFactor) { - if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return; - - int width = Minecraft.getMinecraft().displayWidth; - int height = Minecraft.getMinecraft().displayHeight; - - GlStateManager.matrixMode(GL11.GL_PROJECTION); - GlStateManager.loadIdentity(); - GlStateManager.ortho(0.0D, width, height, 0.0D, 1000.0D, 3000.0D); - GlStateManager.matrixMode(GL11.GL_MODELVIEW); - GlStateManager.loadIdentity(); - GlStateManager.translate(0.0F, 0.0F, -2000.0F); - - if (blurOutputHorz == null) { - blurOutputHorz = new Framebuffer(width, height, false); - blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST); - } - if (blurOutputHorz == null || output == null) { - return; - } - if (blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) { - blurOutputHorz.createBindFramebuffer(width, height); - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); - } - - if (output.blurShaderHorz == null) { - try { - output.blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", output.framebuffer, blurOutputHorz); - output.blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0); - output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); - } catch (Exception ignored) {} - } - if (output.blurShaderVert == null) { - try { - output.blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", blurOutputHorz, output.framebuffer); - output.blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1); - output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); - } catch (Exception ignored) {} - } - if (output.blurShaderHorz != null && output.blurShaderVert != null) { - if (output.blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) { - //Corrupted shader? - return; - } - - output.blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(blurFactor); - output.blurShaderVert.getShaderManager().getShaderUniform("Radius").set(blurFactor); - - GL11.glPushMatrix(); - GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject); - GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, output.framebuffer.framebufferObject); - GL30.glBlitFramebuffer(0, 0, width, height, 0, 0, output.framebuffer.framebufferWidth, output.framebuffer.framebufferHeight, GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST); - - output.blurShaderHorz.loadShader(0); - output.blurShaderVert.loadShader(0); - GlStateManager.enableDepth(); - GL11.glPopMatrix(); - - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); - } - } - - public static void renderBlurredBackground(float blurStrength, int screenWidth, int screenHeight, int x, int y, int blurWidth, int blurHeight) { - renderBlurredBackground(blurStrength, screenWidth, screenHeight, x, y, blurWidth, blurHeight, false); - } - - /** - * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen. - * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight] - */ - public static void renderBlurredBackground(float blurStrength, int screenWidth, int screenHeight, int x, int y, int blurWidth, int blurHeight, boolean forcedUpdate) { - if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return; - if (blurStrength < 0.5) return; - requestedBlurs.add(blurStrength); - - long currentTime = System.currentTimeMillis(); - if (currentTime - lastBlur > 300) { - shouldBlur = true; - if (currentTime - lastBlur > 400 && forcedUpdate) return; - } - - if (blurOutput.isEmpty()) return; - - OutputStuff out = blurOutput.get(blurStrength); - if (out == null) { - out = blurOutput.values().iterator().next(); - } - - float uMin = x / (float) screenWidth; - float uMax = (x + blurWidth) / (float) screenWidth; - float vMin = (screenHeight - y) / (float) screenHeight; - float vMax = (screenHeight - y - blurHeight) / (float) screenHeight; - - GlStateManager.depthMask(false); - Gui.drawRect(x, y, x + blurWidth, y + blurHeight, fogColour); - out.framebuffer.bindFramebufferTexture(); - GlStateManager.color(1f, 1f, 1f, 1f); - RenderUtils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax); - out.framebuffer.unbindFramebufferTexture(); - GlStateManager.depthMask(true); - } -} diff --git a/src/main/java/com/thatgravyboat/amod/core/ChromaColour.java b/src/main/java/com/thatgravyboat/amod/core/ChromaColour.java deleted file mode 100644 index 2e4e2a20a..000000000 --- a/src/main/java/com/thatgravyboat/amod/core/ChromaColour.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.thatgravyboat.amod.core; - -import java.awt.*; - -public class ChromaColour { - - public static String special(int chromaSpeed, int alpha, int rgb) { - return special(chromaSpeed, alpha, (rgb & 0xFF0000) >> 16, (rgb & 0x00FF00) >> 8, (rgb & 0x0000FF)); - } - - private static final int RADIX = 10; - - public static String special(int chromaSpeed, int alpha, int r, int g, int b) { - StringBuilder sb = new StringBuilder(); - sb.append(Integer.toString(chromaSpeed, RADIX)).append(":"); - sb.append(Integer.toString(alpha, RADIX)).append(":"); - sb.append(Integer.toString(r, RADIX)).append(":"); - sb.append(Integer.toString(g, RADIX)).append(":"); - sb.append(Integer.toString(b, RADIX)); - return sb.toString(); - } - - private static int[] decompose(String csv) { - String[] split = csv.split(":"); - - int[] arr = new int[split.length]; - - for (int i = 0; i < split.length; i++) { - arr[i] = Integer.parseInt(split[split.length - 1 - i], RADIX); - } - return arr; - } - - public static int specialToSimpleRGB(String special) { - int[] d = decompose(special); - int r = d[2]; - int g = d[1]; - int b = d[0]; - int a = d[3]; - int chr = d[4]; - - return (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF); - } - - public static int getSpeed(String special) { - return decompose(special)[4]; - } - - public static float getSecondsForSpeed(int speed) { - return (255 - speed) / 254f * (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + MIN_CHROMA_SECS; - } - - private static final int MIN_CHROMA_SECS = 1; - private static final int MAX_CHROMA_SECS = 60; - - public static long startTime = -1; - - public static int specialToChromaRGB(String special) { - if (startTime < 0) startTime = System.currentTimeMillis(); - - int[] d = decompose(special); - int chr = d[4]; - int a = d[3]; - int r = d[2]; - int g = d[1]; - int b = d[0]; - - float[] hsv = Color.RGBtoHSB(r, g, b, null); - - if (chr > 0) { - float seconds = getSecondsForSpeed(chr); - hsv[0] += (System.currentTimeMillis() - startTime) / 1000f / seconds; - hsv[0] %= 1; - if (hsv[0] < 0) hsv[0] += 1; - } - - return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF); - } - - public static int rotateHue(int argb, int degrees) { - int a = (argb >> 24) & 0xFF; - int r = (argb >> 16) & 0xFF; - int g = (argb >> 8) & 0xFF; - int b = (argb) & 0xFF; - - float[] hsv = Color.RGBtoHSB(r, g, b, null); - - hsv[0] += degrees / 360f; - hsv[0] %= 1; - - return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF); - } -} diff --git a/src/main/java/com/thatgravyboat/amod/core/GlScissorStack.java b/src/main/java/com/thatgravyboat/amod/core/GlScissorStack.java deleted file mode 100644 index ae9162f77..000000000 --- a/src/main/java/com/thatgravyboat/amod/core/GlScissorStack.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.thatgravyboat.amod.core; - -import java.util.LinkedList; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import org.lwjgl.opengl.GL11; - -public class GlScissorStack { - - private static class Bounds { - - int left; - int top; - int right; - int bottom; - - public Bounds(int left, int top, int right, int bottom) { - this.left = left; - this.top = top; - this.right = right; - this.bottom = bottom; - } - - public Bounds createSubBound(int left, int top, int right, int bottom) { - left = Math.max(left, this.left); - top = Math.max(top, this.top); - right = Math.min(right, this.right); - bottom = Math.min(bottom, this.bottom); - - if (top > bottom) { - top = bottom; - } - if (left > right) { - left = right; - } - - return new Bounds(left, top, right, bottom); - } - - public void set(ScaledResolution scaledResolution) { - int height = Minecraft.getMinecraft().displayHeight; - int scale = scaledResolution.getScaleFactor(); - GL11.glScissor(left * scale, height - bottom * scale, (right - left) * scale, (bottom - top) * scale); - } - } - - private static final LinkedList boundsStack = new LinkedList<>(); - - public static void push(int left, int top, int right, int bottom, ScaledResolution scaledResolution) { - if (right < left) { - int temp = right; - right = left; - left = temp; - } - if (bottom < top) { - int temp = bottom; - bottom = top; - top = temp; - } - if (boundsStack.isEmpty()) { - boundsStack.push(new Bounds(left, top, right, bottom)); - } else { - boundsStack.push(boundsStack.peek().createSubBound(left, top, right, bottom)); - } - if (!boundsStack.isEmpty()) { - boundsStack.peek().set(scaledResolution); - } - GL11.glEnable(GL11.GL_SCISSOR_TEST); - } - - public static void pop(ScaledResolution scaledResolution) { - if (!boundsStack.isEmpty()) { - boundsStack.pop(); - } - if (boundsStack.isEmpty()) { - GL11.glDisable(GL11.GL_SCISSOR_TEST); - } else { - boundsStack.peek().set(scaledResolution); - } - } - - public static void clear() { - boundsStack.clear(); - GL11.glDisable(GL11.GL_SCISSOR_TEST); - } -} diff --git a/src/main/java/com/thatgravyboat/amod/core/GuiElement.java b/src/main/java/com/thatgravyboat/amod/core/GuiElement.java deleted file mode 100644 index 2310702bb..000000000 --- a/src/main/java/com/thatgravyboat/amod/core/GuiElement.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.thatgravyboat.amod.core; - -import net.minecraft.client.gui.Gui; - -public abstract class GuiElement extends Gui { - - public abstract void render(); - - public abstract boolean mouseInput(int mouseX, int mouseY); - - public abstract boolean keyboardInput(); -} diff --git a/src/main/java/com/thatgravyboat/amod/core/GuiElementBoolean.java b/src/main/java/com/thatgravyboat/amod/core/GuiElementBoolean.java deleted file mode 100644 index 06e2c8c0e..000000000 --- a/src/main/java/com/thatgravyboat/amod/core/GuiElementBoolean.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.thatgravyboat.amod.core; - -import com.thatgravyboat.amod.GuiTextures; -import com.thatgravyboat.amod.core.util.lerp.LerpUtils; -import com.thatgravyboat.amod.core.util.render.RenderUtils; -import java.util.function.Consumer; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.input.Mouse; - -public class GuiElementBoolean extends GuiElement { - - public int x; - public int y; - private boolean value; - private final int clickRadius; - private final Consumer toggleCallback; - - private boolean previewValue; - private int animation = 0; - private long lastMillis = 0; - - private static final int xSize = 48; - private static final int ySize = 14; - - public GuiElementBoolean(int x, int y, boolean value, Consumer toggleCallback) { - this(x, y, value, 0, toggleCallback); - } - - public GuiElementBoolean(int x, int y, boolean value, int clickRadius, Consumer toggleCallback) { - this.x = x; - this.y = y; - this.value = value; - this.previewValue = value; - this.clickRadius = clickRadius; - this.toggleCallback = toggleCallback; - this.lastMillis = System.currentTimeMillis(); - - if (value) animation = 36; - } - - @Override - public void render() { - GlStateManager.color(1, 1, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(GuiTextures.BAR); - RenderUtils.dra