diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-04-16 14:51:58 +0900 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-04-16 14:51:58 +0900 |
commit | cf164be0c8f43c3d1387c9c9f7ae73c2cf1b3a02 (patch) | |
tree | c3f2cbfe39919941b9bb04f6de2e3cec103509fd /src/main/java/io/polyfrost/oneconfig/gui | |
parent | f10f1165a7c2ea88ce7bb265d51b52eeaa64d8f8 (diff) | |
download | OneConfig-cf164be0c8f43c3d1387c9c9f7ae73c2cf1b3a02.tar.gz OneConfig-cf164be0c8f43c3d1387c9c9f7ae73c2cf1b3a02.tar.bz2 OneConfig-cf164be0c8f43c3d1387c9c9f7ae73c2cf1b3a02.zip |
merge rendering files + remove themes
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/gui')
12 files changed, 0 insertions, 553 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/Window.java b/src/main/java/io/polyfrost/oneconfig/gui/Window.java deleted file mode 100644 index fa672d5..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/Window.java +++ /dev/null @@ -1,111 +0,0 @@ -package io.polyfrost.oneconfig.gui; - -import io.polyfrost.oneconfig.gui.elements.OCBlock; -import io.polyfrost.oneconfig.gui.elements.OCStoreBlock; -import io.polyfrost.oneconfig.themes.Theme; -import io.polyfrost.oneconfig.themes.Themes; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.util.ResourceLocation; - -import java.awt.*; - -import static io.polyfrost.oneconfig.renderer.Renderer.clamp; -import static io.polyfrost.oneconfig.renderer.Renderer.easeOut; - -public class Window extends GuiScreen { - private float currentProgress = 0f; - public static Window currentWindow; - private final Theme t = Themes.getActiveTheme(); - private final int guiScaleToRestore; - long secondCounter = System.currentTimeMillis(); - long prevTime = System.currentTimeMillis(); - int frames = 0; - OCBlock block = new OCBlock(() -> { - t.getFont().drawString("hi", 10, 10, 1f, 1f, -1); - },750, 144); - ResourceLocation example = new ResourceLocation("oneconfig", "textures/hudsettings.png"); - OCStoreBlock storeBlock = new OCStoreBlock("OneConfig Theme", "OneConfig default theme with the default look you love.", example, new Color(27,27,27,255).getRGB()); - public static ScaledResolution resolution = new ScaledResolution(Minecraft.getMinecraft()); - - public Window() { - super.initGui(); - currentWindow = this; - guiScaleToRestore = Minecraft.getMinecraft().gameSettings.guiScale; - Minecraft.getMinecraft().gameSettings.guiScale = 1; - } - - public boolean doesGuiPauseGame() { - return false; - } - - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - resolution = new ScaledResolution(Minecraft.getMinecraft()); - super.drawScreen(mouseX, mouseY, partialTicks); - currentProgress = clamp(easeOut(currentProgress, 1f)); - int alphaVal = (int) (50 * currentProgress); - drawGradientRect(0, 0, super.width, super.height, new Color(80, 80, 80, alphaVal).getRGB(), new Color(80, 80, 80, alphaVal + 10).getRGB()); - long secondDelta = System.currentTimeMillis() - secondCounter; - long deltaTime = System.currentTimeMillis() - prevTime; - //if(deltaTime >= 15) { - // prevTime = System.currentTimeMillis(); - // frames++; - // drawWindow(); - //} - if(secondDelta >= 1000) { - secondCounter = System.currentTimeMillis(); - //System.out.println(frames + "FPS"); - //Minecraft.getMinecraft().thePlayer.sendChatMessage(frames + "FPS"); - frames = 0; - } - drawWindow(); - } - - public void drawWindow() { - Color testingColor = new Color(127, 144, 155, 255); - //System.out.println(testingColor.getRGB()); - int middleX = this.width / 2; - int middleY = this.height / 2; - int left = middleX - 800; - int right = (int) (1600 * currentProgress); - int top = middleY - 512; - int bottom = (int) (1024 * currentProgress); - //Gui.drawRect(left - 1, top - 1, right + 1, bottom + 1, testingColor.getRGB()); - //new Color(16, 17, 19, 255).getRGB() - //t.getTextureManager().draw(ThemeElement.BACKGROUND, left, top, right, bottom); - //t.getTextureManager().draw(ThemeElement.BUTTON_OFF, left + 480, top + 40, 640, 48); - //t.getTextureManager().draw(ThemeElement.SEARCH, left + 504, top + 48, 32, 32); - //t.getFont().drawString("Search all of OneConfig", left + 548, top + 48, 1.1f, 1f, new Color(242,242,242,255).getRGB()); - - //t.getTextureManager().draw(ThemeElement.BUTTON_OFF, left + 1504, top + 32, 64, 64); - //t.getTextureManager().draw(ThemeElement.BUTTON_OFF, left + 1424, top + 32, 64, 64); - //t.getTextureManager().draw(ThemeElement.BUTTON_OFF, left + 1344, top + 32, 64, 64); - //block.draw(200, 300); - block.draw(100,200); - //t.getTextureManager().draw(ThemeElement.CLOSE, left + 1504, top + 32, 64, 64); - //t.getTextureManager().draw(ThemeElement.BUTTON_OFF, left + 100, top + 100, 296, 64); - //t.getTextureManager().draw(ThemeElement.CLOSE); - - //Renderer.drawRoundRect(left,top,right,bottom,30, testingColor.getRGB()); - //Renderer.drawRoundRect(left + 1,top + 1,right - 2,bottom - 2,30, t.getBaseColor().getRGB()); - //t.getTextureManager().draw(ThemeElement.LOGO, left + 24, top + 24, 64, 64); // 0.875 - //t.getBoldFont().drawString("OneConfig", left + 93f, top + 25, 1f,1f); - //Gui.drawRect(left, top, right, bottom, t.getBaseColor().getRGB()); - - //Gui.drawRect(left, top, right, top + 100, t.getTitleBarColor().getRGB()); - //Gui.drawRect(left, top + 100, right, top + 101, testingColor.getRGB()); - - - //font.drawString("OneConfig is pog!\nWow, this font renderer actually works :D", 50, 50, 1f, 1f); - } - - public static Window getWindow() { - return currentWindow; - } - - @Override - public void onGuiClosed() { - Minecraft.getMinecraft().gameSettings.guiScale = guiScaleToRestore; - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCBlock.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/OCBlock.java deleted file mode 100644 index abcd5ca..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCBlock.java +++ /dev/null @@ -1,270 +0,0 @@ -package io.polyfrost.oneconfig.gui.elements; - -import io.polyfrost.oneconfig.renderer.Renderer; -import io.polyfrost.oneconfig.themes.Theme; -import io.polyfrost.oneconfig.themes.Themes; -import io.polyfrost.oneconfig.themes.textures.ThemeElement; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import org.jetbrains.annotations.NotNull; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -import java.awt.*; - -import static io.polyfrost.oneconfig.gui.Window.resolution; - -/** - * Default simple block for all the GUI elements. If you are making custom ones, your class should extend this one. - */ -@SuppressWarnings("unused") -public class OCBlock { - public static final Theme theme = Themes.getActiveTheme(); - private static final Minecraft mc = Minecraft.getMinecraft(); - private final boolean bold; - private final Color elementColor = theme.getElementColor(); - private final Color hoverColor = theme.getHoverColor(); - private final Runnable draw; - /** - * Width of the element in pixels. - */ - public int width; - /** - * Height of the element in pixels. - */ - public int height; - private Color color; - private String text; - private ThemeElement element; - private boolean clicked = false; - private boolean rightClicked = false; - private int mouseX, mouseY; - private boolean hovered; - private float percentHoveredRed = 0f; - private float percentHoveredGreen = 0f; - private float percentHoveredBlue = 0f; - private float percentHoveredAlpha = 0f; - - /** - * Create a basic element. - */ - public OCBlock(int width, int height) { - this(null, false, theme.getElementColor().getRGB(), width, height); - } - - /** - * Create a new basic element. - * - * @param color color of the element - * @param width width of the element - * @param height height of the element - * @deprecated This method DOES NOT respect the theme colors for the element. Use of {@link #OCBlock(int, int)} is recommended instead. - */ - @Deprecated() - public OCBlock(int color, int width, int height) { - this(null, false, color, width, height); - } - - /** - * Create a new element with the specified text, and automatic width/height + padding. - * - * @param text text to use - * @param bold weather or not to use bold text - * @param color color for the text - */ - public OCBlock(@NotNull String text, boolean bold, int color) { - this(text, bold, color, theme.getFont().getWidth(text) + 6, theme.getFont().getHeight() + 4); - } - - /** - * Create a new element with the specified text, and custom width/height. - * - * @param text text to use - * @param bold weather or not to use bold text - * @param color color for the text (use {@link Theme#getTextColor()} or {@link Theme#getAccentTextColor()} for default colors) - */ - public OCBlock(String text, boolean bold, int color, int width, int height) { - this.draw = null; - this.text = text; - this.bold = bold; - this.color = Renderer.getColorFromInt(color); - this.width = width; - this.height = height; - } - - /** - * Create a new Element with the specified image. - * - * @param element element to use - * @param colorMask color mast to use (-1 for default) - */ - public OCBlock(ThemeElement element, int colorMask, int width, int height) { - this.draw = null; - this.element = element; - this.color = Renderer.getColorFromInt(colorMask); - this.width = width; - this.height = height; - this.bold = false; - } - - /** - * Create a new Element with a custom render script. The {@link Runnable} should ONLY contain #draw() calls or equivalent. - * - * @param whatToDraw a {@link Runnable}, containing draw scripts for elements. You will need to instantiate the objects first, if they are sub-elements. - */ - public OCBlock(Runnable whatToDraw, int width, int height) { - this.draw = whatToDraw; - this.bold = false; - this.width = width; - this.height = height; - } - - /** - * Draw the element at the specified coordinates. - */ - public void draw(int x, int y) { - GlStateManager.enableBlend(); - percentHoveredRed = smooth(percentHoveredRed, elementColor.getRed() / 255f, hoverColor.getRed() / 255f); - percentHoveredGreen = smooth(percentHoveredGreen, elementColor.getGreen() / 255f, hoverColor.getGreen() / 255f); - percentHoveredBlue = smooth(percentHoveredBlue, elementColor.getBlue() / 255f, hoverColor.getBlue() / 255f); - percentHoveredAlpha = smooth(percentHoveredAlpha, elementColor.getAlpha() / 255f, hoverColor.getAlpha() / 255f); - GlStateManager.color(percentHoveredRed, percentHoveredGreen, percentHoveredBlue, percentHoveredAlpha); - update(x, y); - if (draw != null) { - draw.run(); - } - if (element != null) { - theme.getTextureManager().draw(ThemeElement.BUTTON, x, y, width, height); - GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f); - theme.getTextureManager().draw(element, x, y, width, height); - } - if (text == null) { - theme.getTextureManager().draw(ThemeElement.BUTTON, x, y, width, height); - } else { - theme.getTextureManager().draw(ThemeElement.BUTTON, x, y, width, height); - if (bold) { - theme.getBoldFont().drawString(text, x + 3, y + 2, 1f, 1f, color.getRGB()); - } else { - theme.getFont().drawString(text, x + 3, y + 2, 1.1f, 1f, color.getRGB()); - } - } - GlStateManager.disableBlend(); - - - } - - /** - * Update this elements click, key and hover status. Call this method at the end of your 'draw' function, if overridden. - */ - public void update(int x, int y) { - int mouseX = Mouse.getX() / resolution.getScaleFactor(); - int mouseY = Math.abs((Mouse.getY() / resolution.getScaleFactor()) - resolution.getScaledHeight()); - hovered = mouseX > x && mouseY > y && mouseX < x + width && mouseY < y + height; - if (hovered) { - onHover(); - if (Mouse.isButtonDown(0) && !clicked) { - onClick(0); - } - clicked = Mouse.isButtonDown(0); - - if (Mouse.isButtonDown(1) && !rightClicked) { - onClick(1); - } - rightClicked = Mouse.isButtonDown(1); - onKeyPress(Keyboard.getEventKey()); - } - if (clicked) { - Renderer.color(theme.getClickColor()); - } - if (!hovered && clicked) clicked = false; - } - - /** - * Draw the element with the specified coordinates, width and height. - */ - public void draw(int x, int y, int width, int height) { - this.width = width; - this.height = height; - draw(x, y); - } - - - /** - * Override this method to set a function when a key is pressed while this element is hovered. - * - * @param keyCode key code that was pressed (check org.lwjgl.Keyboard for keymap) - */ - public void onKeyPress(int keyCode) { - - } - - /** - * Override this method to set a function when the element is hovered. - * - * @param button the button that was pressed (0 is left, 1 is right) - */ - public void onClick(int button) { - - } - - - /** - * Override this method to set a function when the element is hovered. - */ - public void onHover() { - - } - - - private float smooth(float current, float min, float max) { - current = Renderer.easeOut(current, isHovered() ? 1f : 0f); - if (current <= min) { - current = min; - } - - if (current >= max) { - current = max; - } - return current; - } - - public int getHeight() { - return height; - } - - public void setHeight(int height) { - this.height = height; - } - - public Color getColor() { - return color; - } - - public void setColor(Color color) { - this.color = color; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public boolean isHovered() { - return hovered; - } - - public boolean isClicked() { - return clicked; - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCButton.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/OCButton.java deleted file mode 100644 index 5f78baa..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCButton.java +++ /dev/null @@ -1,105 +0,0 @@ -package io.polyfrost.oneconfig.gui.elements; - -import io.polyfrost.oneconfig.renderer.Renderer; -import io.polyfrost.oneconfig.themes.textures.ThemeElement; -import net.minecraft.client.renderer.GlStateManager; -import org.jetbrains.annotations.NotNull; - -import java.awt.*; - -public class OCButton extends OCBlock { - private final Color elementColor = theme.getElementColor(); - private final Color hoverColor = theme.getHoverColor(); - private float percentHoveredRed = 0f; - private float percentHoveredGreen = 0f; - private float percentHoveredBlue = 0f; - private float percentHoveredAlpha = 0f; - private float percentDescription = 0f; - private ThemeElement element; - private boolean alwaysShowDesc = true; - private String title, description; - - /** - * Create an empty button. - */ - public OCButton(int width, int height) { - super(width, height); - } - - /** - * Create a new button with the specified texture. - */ - public OCButton(ThemeElement element) { - super(element.size + 2, element.size + 2); - this.element = element; - } - - public OCButton(@NotNull String title, @NotNull String description, ThemeElement icon, boolean alwaysShowDesc) { - super(icon.size + theme.getBoldFont().getWidth(title) + 20, icon.size + 10); - this.element = icon; - this.title = title; - this.description = description; - this.alwaysShowDesc = alwaysShowDesc; - } - - - public OCButton(@NotNull String title, @NotNull String description, ThemeElement icon, boolean alwaysShowDesc, int width, int height) { - super(width, height); - this.element = icon; - this.title = title; - this.description = description; - this.alwaysShowDesc = alwaysShowDesc; - } - - public void draw(int x, int y) { - super.update(x, y); - - percentHoveredRed = smooth(percentHoveredRed, elementColor.getRed() / 255f, hoverColor.getRed() / 255f); - percentHoveredGreen = smooth(percentHoveredGreen, elementColor.getGreen() / 255f, hoverColor.getGreen() / 255f); - percentHoveredBlue = smooth(percentHoveredBlue, elementColor.getBlue() / 255f, hoverColor.getBlue() / 255f); - percentHoveredAlpha = smooth(percentHoveredAlpha, elementColor.getAlpha() / 255f, hoverColor.getAlpha() / 255f); - if (!alwaysShowDesc) { - percentDescription = Renderer.clamp(Renderer.easeOut(percentDescription, isHovered() ? 1f : 0f)); - } - GlStateManager.color(percentHoveredRed, percentHoveredGreen, percentHoveredBlue, percentHoveredAlpha); - if (isClicked()) { - //Renderer.setGlColor(theme.getClickColor()); - } - - theme.getTextureManager().draw(ThemeElement.BUTTON, x, y, width, height); - if (element != null) { - GlStateManager.color(1f, 1f, 1f, isClicked() ? 0.6f : 1f); - theme.getTextureManager().draw(element, x + 19, y + 8, element.size, element.size); - if (title != null) { - if (alwaysShowDesc) { - theme.getBoldFont().drawString(title, x + element.size + 25, y + 30, 1.2f, 1.2f, isClicked() ? theme.getTextColor().darker().getRGB() : theme.getTextColor().getRGB()); - theme.getFont().drawString(description, x + element.size + 25, y + theme.getBoldFont().getHeight() + 37, 1.2f, 1.2f, isClicked() ? theme.getAccentTextColor().darker().getRGB() : theme.getAccentTextColor().getRGB()); - } else { - int titleY = y + 48; - titleY -= (int) (percentDescription * 18); - Color targetColor = theme.getAccentTextColor(); - Color currentColor = isClicked() ? targetColor.darker() : new Color(targetColor.getRed(), targetColor.getGreen(), targetColor.getBlue(), (int) (targetColor.getAlpha() * percentDescription)); - theme.getFont().drawString(description, x + element.size + 25, y + theme.getBoldFont().getHeight() + 37, 1.2f, 1.2f, currentColor.getRGB()); - theme.getBoldFont().drawString(title, x + element.size + 25, titleY, 1.2f, 1.2f, isClicked() ? theme.getTextColor().darker().getRGB() : theme.getTextColor().getRGB()); - } - } - } - } - - - private float smooth(float current, float min, float max) { - current = Renderer.easeOut(current, isHovered() ? 1f : 0f); - if (current <= min) { - current = min; - } - - if (current >= max) { - current = max; - } - return current; - } - - public void onHover() { - - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCColorPicker.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/OCColorPicker.java deleted file mode 100644 index e055d25..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCColorPicker.java +++ /dev/null @@ -1,4 +0,0 @@ -package io.polyfrost.oneconfig.gui.elements; - -public class OCColorPicker { -} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCSelector.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/OCSelector.java deleted file mode 100644 index 83805fa..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCSelector.java +++ /dev/null @@ -1,4 +0,0 @@ -package io.polyfrost.oneconfig.gui.elements; - -public class OCSelector { -} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCStoreBlock.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/OCStoreBlock.java deleted file mode 100644 index d7fa7e9..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCStoreBlock.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.polyfrost.oneconfig.gui.elements; - -import io.polyfrost.oneconfig.renderer.Renderer; -import net.minecraft.util.ResourceLocation; - -import java.awt.*; - -public class OCStoreBlock extends OCBlock { - private final ResourceLocation image; - private final String description; - private final String title; - private final Color color; - - public OCStoreBlock(String title, String description, ResourceLocation image, int color) { - super(color, 300, 400); - this.color = Renderer.getColorFromInt(color); - this.description = description; - this.title = title; - this.image = image; - } - - public void draw(int x, int y) { - //super.draw(x, y); - Renderer.drawScaledImage(image, x, y, 300, 150); - //Gui.drawRect(x,y,x + 300, y + 150, -1); - theme.getBoldFont().drawSplitString(title, x + 2, y + 152, 200, -1); - - - //super.update(); - } - - public void draw(int x, int y, int width, int height) { - draw(x, y); - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCTextField.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/OCTextField.java deleted file mode 100644 index da0df96..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCTextField.java +++ /dev/null @@ -1,4 +0,0 @@ -package io.polyfrost.oneconfig.gui.elements; - -public class OCTextField { -} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/BasicWindowPage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/BasicWindowPage.java deleted file mode 100644 index 0d09526..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/pages/BasicWindowPage.java +++ /dev/null @@ -1,4 +0,0 @@ -package io.polyfrost.oneconfig.gui.pages; - -public class BasicWindowPage { -} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java deleted file mode 100644 index 65ad1e9..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java +++ /dev/null @@ -1,4 +0,0 @@ -package io.polyfrost.oneconfig.gui.pages; - -public class HomePage { -} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java deleted file mode 100644 index 4cbda94..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java +++ /dev/null @@ -1,4 +0,0 @@ -package io.polyfrost.oneconfig.gui.pages; - -public class ModsPage { -} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/SettingsPage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/SettingsPage.java deleted file mode 100644 index 9fecc75..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/pages/SettingsPage.java +++ /dev/null @@ -1,4 +0,0 @@ -package io.polyfrost.oneconfig.gui.pages; - -public class SettingsPage { -} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/StorePage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/StorePage.java deleted file mode 100644 index 4aa1616..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/pages/StorePage.java +++ /dev/null @@ -1,4 +0,0 @@ -package io.polyfrost.oneconfig.gui.pages; - -public class StorePage { -} |