aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java9
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java28
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/TextInputField.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java28
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/BlurHandler.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/font/FontManager.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/Lwjgl2FunctionProvider.java (renamed from src/main/java/cc/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider.java)2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/Scissor.java (renamed from src/main/java/cc/polyfrost/oneconfig/lwjgl/Scissor.java)2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java (renamed from src/main/java/cc/polyfrost/oneconfig/lwjgl/ScissorManager.java)3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java (renamed from src/main/java/cc/polyfrost/oneconfig/lwjgl/IOUtil.java)14
14 files changed, 82 insertions, 31 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
index 72cd8c0..2c0816c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -7,8 +7,8 @@ import cc.polyfrost.oneconfig.gui.elements.TextInputField;
import cc.polyfrost.oneconfig.gui.pages.HomePage;
import cc.polyfrost.oneconfig.gui.pages.Page;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
-import cc.polyfrost.oneconfig.lwjgl.Scissor;
-import cc.polyfrost.oneconfig.lwjgl.ScissorManager;
+import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor;
+import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
import cc.polyfrost.oneconfig.utils.InputUtils;
@@ -125,7 +125,10 @@ public class OneConfigGui extends GuiScreen {
pageProgress = -224f;
}
} else {
- currentPage.draw(vg, (int) (x - pageProgress), y + 72);
+ if(currentPage.getMaxScrollHeight() == 728) {
+ currentPage.draw(vg, (int) (x - pageProgress), y + 72);
+ } else currentPage.scrollWithDraw(vg, (int) (x - pageProgress), y + 72);
+
}
ScissorManager.resetScissor(vg, scissor);
if (currentColorSelector != null) {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java
index 83d0f7c..fcd96b2 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java
@@ -9,6 +9,22 @@ import java.awt.*;
import java.util.ArrayList;
public class ColorSelector {
+
+ public ColorSelector(Color color, int mouseX, int mouseY) {
+
+ }
+
+ public void draw(long vg) {
+
+ }
+
+ public Color getColor() {
+
+ return null;
+ }
+}
+
+/*public class ColorSelector {
private Color color;
private final int x, y;
private final int width = 416;
@@ -147,7 +163,7 @@ public class ColorSelector {
public abstract void drawBox(long vg, int x, int y);
/** draw the color selector contents, including the box, and the input fields. If it is clicked, getColorAtPos is called. updateElements is also called to update all the input fields. */
- public void draw(long vg, int x, int y) {
+ /*public void draw(long vg, int x, int y) {
drawBox(vg, x + 16, y + 120);
if(InputUtils.isAreaHovered(x + 16, y + 120, 384, 288) && Mouse.isButtonDown(0)) {
selectedX = InputUtils.mouseX() - x - 16;
@@ -170,18 +186,18 @@ public class ColorSelector {
RenderManager.drawRoundedRect(vg, x + 16, y + 488, 384, 40, color1.getRGB(), 12f);
}
- /** called to set the color of the color selector box based on the values of the input fields. */
+ /** called to set the color of the color selector box based on the values of the input fields. */ /*
public abstract void setColor(Color color);
- /** return an array of two ints of the start color of the gradient and the end color of the gradient. */
+ /** return an array of two ints of the start color of the gradient and the end color of the gradient. */ /*
public abstract int[] drawTopSlider();
- /** return an array of two ints of the start color of the gradient and the end color of the gradient. */
+ /** return an array of two ints of the start color of the gradient and the end color of the gradient. */ /*
public abstract int[] drawBottomSlider();
/**
* This method is called when the color selector is clicked. It needs to return color at the clicked position.
* @return color at the clicked position as a <code>float[] rgba.</code>
- */
+ */ /*
public abstract float[] getColorAtPos(int clickX, int clickY);
public float getRed() {
@@ -246,5 +262,5 @@ public class ColorSelector {
}
}
}
-
+*/
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/TextInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/TextInputField.java
index 3058643..196c447 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/TextInputField.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/TextInputField.java
@@ -2,8 +2,8 @@ package cc.polyfrost.oneconfig.gui.elements;
import cc.polyfrost.oneconfig.config.OneConfigConfig;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
-import cc.polyfrost.oneconfig.lwjgl.Scissor;
-import cc.polyfrost.oneconfig.lwjgl.ScissorManager;
+import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor;
+import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.utils.InputUtils;
import net.minecraft.client.gui.GuiScreen;
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java
index 0623f1e..5fad0a4 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java
@@ -3,8 +3,8 @@ package cc.polyfrost.oneconfig.gui.elements.config;
import cc.polyfrost.oneconfig.config.OneConfigConfig;
import cc.polyfrost.oneconfig.config.interfaces.BasicOption;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
-import cc.polyfrost.oneconfig.lwjgl.Scissor;
-import cc.polyfrost.oneconfig.lwjgl.ScissorManager;
+import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor;
+import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
import cc.polyfrost.oneconfig.utils.InputUtils;
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
index f335e4d..d0e809e 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
@@ -149,4 +149,9 @@ public class ModConfigPage extends Page {
button.setToggled(false);
}
}
+
+ @Override
+ public int getMaxScrollHeight() {
+ return 1600;
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
index ba31fa8..2f2fa36 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
@@ -1,9 +1,17 @@
package cc.polyfrost.oneconfig.gui.pages;
+import cc.polyfrost.oneconfig.config.OneConfigConfig;
+import cc.polyfrost.oneconfig.lwjgl.RenderManager;
+import cc.polyfrost.oneconfig.utils.MathUtils;
+import org.lwjgl.input.Mouse;
+
/**
* A page is a 1056x728 rectangle of the GUI. It is the main content of the gui, and can be switched back and forwards easily. All the content of OneConfig is in a page.
*/
public abstract class Page {
+ private float scrollPercent = 0f;
+ private float yDiff, scrollAmount;
+
protected final String title;
Page(String title) {
@@ -15,6 +23,21 @@ public abstract class Page {
public void finishUpAndClose() {
}
+ public void scrollWithDraw(long vg, int x, int y) {
+ int dWheel = Mouse.getDWheel();
+ scrollAmount += dWheel / 120f;
+ scrollPercent = MathUtils.easeOut(scrollPercent, scrollAmount, 20f);
+
+
+ int currentScroll = (int) yDiff + (int) (scrollPercent * 100);
+ if(currentScroll > 0) {
+ currentScroll = 0;
+ scrollPercent = 0;
+ scrollAmount = 0;
+ }
+ draw(vg, x, y + currentScroll);
+ }
+
public String getTitle() {
return title;
}
@@ -28,4 +51,9 @@ public abstract class Page {
public boolean isBase() {
return false;
}
+
+ /** Use this method to set the maximum scroll height of the page. */
+ public int getMaxScrollHeight() {
+ return 728;
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/BlurHandler.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/BlurHandler.java
index 914c483..285875a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/BlurHandler.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/BlurHandler.java
@@ -109,7 +109,7 @@ public class BlurHandler {
su.set(progress);
}
} catch (IllegalArgumentException ex) {
- this.logger.error("An error occurred while updating ToggleChat's blur. Please report this!", ex);
+ this.logger.error("An error occurred while updating OneConfig's blur. Please report this!", ex);
}
this.mc.mcProfiler.endSection();
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/FontManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/FontManager.java
index 0974019..534795b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/FontManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/FontManager.java
@@ -1,6 +1,6 @@
package cc.polyfrost.oneconfig.lwjgl.font;
-import cc.polyfrost.oneconfig.lwjgl.IOUtil;
+import cc.polyfrost.oneconfig.utils.IOUtils;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -15,7 +15,7 @@ public class FontManager {
Font font = fonts.font;
int loaded = -1;
try {
- ByteBuffer buffer = IOUtil.resourceToByteBuffer(font.getFileName());
+ ByteBuffer buffer = IOUtils.resourceToByteBuffer(font.getFileName());
loaded = nvgCreateFontMem(vg, font.getName(), buffer, 0);
font.setBuffer(buffer);
} catch (IOException e) {
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
index 8e72828..479104c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
@@ -1,6 +1,6 @@
package cc.polyfrost.oneconfig.lwjgl.image;
-import cc.polyfrost.oneconfig.lwjgl.IOUtil;
+import cc.polyfrost.oneconfig.utils.IOUtils;
import org.lwjgl.nanovg.NanoVG;
import org.lwjgl.stb.STBImage;
@@ -17,7 +17,7 @@ public class ImageLoader {
int[] height = {0};
int[] channels = {0};
- ByteBuffer image = IOUtil.resourceToByteBufferNullable(fileName);
+ ByteBuffer image = IOUtils.resourceToByteBufferNullable(fileName);
if (image == null) {
return false;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java
index c34f3b8..858d615 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java
@@ -23,11 +23,11 @@ public class ClassTransformer implements IClassTransformer {
InsnList list = new InsnList();
list.add(new VarInsnNode(Opcodes.LLOAD, 0));
- list.add(new TypeInsnNode(Opcodes.NEW, "cc/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider"));
+ list.add(new TypeInsnNode(Opcodes.NEW, "cc/polyfrost/oneconfig/lwjgl/plugin/Lwjgl2FunctionProvider"));
list.add(new InsnNode(Opcodes.DUP));
list.add(new MethodInsnNode(
Opcodes.INVOKESPECIAL,
- "cc/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider",
+ "cc/polyfrost/oneconfig/lwjgl/plugin/Lwjgl2FunctionProvider",
"<init>",
"()V",
false
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/Lwjgl2FunctionProvider.java
index e00570e..4cef17c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/Lwjgl2FunctionProvider.java
@@ -1,4 +1,4 @@
-package cc.polyfrost.oneconfig.lwjgl;
+package cc.polyfrost.oneconfig.lwjgl.plugin;
import org.lwjgl.opengl.GLContext;
import org.lwjgl.system.FunctionProvider;
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/Scissor.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/Scissor.java
index 5709823..9523865 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/Scissor.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/Scissor.java
@@ -1,4 +1,4 @@
-package cc.polyfrost.oneconfig.lwjgl;
+package cc.polyfrost.oneconfig.lwjgl.scissor;
public class Scissor {
public float x;
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/ScissorManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java
index db85e86..a3f3780 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/ScissorManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java
@@ -1,5 +1,6 @@
-package cc.polyfrost.oneconfig.lwjgl;
+package cc.polyfrost.oneconfig.lwjgl.scissor;
+import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor;
import org.lwjgl.nanovg.NanoVG;
import java.util.ArrayList;
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/IOUtil.java b/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java
index 1394239..6264451 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/IOUtil.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java
@@ -1,6 +1,4 @@
-package cc.polyfrost.oneconfig.lwjgl;
-
-import org.apache.commons.io.IOUtils;
+package cc.polyfrost.oneconfig.utils;
import java.io.File;
import java.io.FileNotFoundException;
@@ -12,9 +10,9 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.file.Files;
-public final class IOUtil {
+public final class IOUtils {
- private IOUtil() {
+ private IOUtils() {
}
/**
@@ -25,19 +23,19 @@ public final class IOUtil {
byte[] bytes;
path = path.trim();
if (path.startsWith("http")) {
- bytes = IOUtils.toByteArray(new URL(path));
+ bytes = org.apache.commons.io.IOUtils.toByteArray(new URL(path));
} else {
InputStream stream;
File file = new File(path);
if (file.exists() && file.isFile()) {
stream = Files.newInputStream(file.toPath());
} else {
- stream = IOUtil.class.getResourceAsStream(path);
+ stream = IOUtils.class.getResourceAsStream(path);
}
if (stream == null) {
throw new FileNotFoundException(path);
}
- bytes = IOUtils.toByteArray(stream);
+ bytes = org.apache.commons.io.IOUtils.toByteArray(stream);
}
ByteBuffer data = ByteBuffer.allocateDirect(bytes.length).order(ByteOrder.nativeOrder())
.put(bytes);