aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/renderer
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-06 18:20:23 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-06 18:20:23 +0200
commit21d31344a151dfe94c79a20b503af55120c63b63 (patch)
tree6bae89e3532b2ed976a493ff8d6b5b7bfed94221 /src/main/java/cc/polyfrost/oneconfig/renderer
parent462d5976f3654f40229ff61391e7e55d0819d82d (diff)
downloadOneConfig-21d31344a151dfe94c79a20b503af55120c63b63.tar.gz
OneConfig-21d31344a151dfe94c79a20b503af55120c63b63.tar.bz2
OneConfig-21d31344a151dfe94c79a20b503af55120c63b63.zip
rewrite config system
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/renderer')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/renderer/AssetLoader.java (renamed from src/main/java/cc/polyfrost/oneconfig/renderer/image/ImageLoader.java)34
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java27
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/renderer/image/Images.java19
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/renderer/image/SVGs.java52
4 files changed, 31 insertions, 101 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/image/ImageLoader.java b/src/main/java/cc/polyfrost/oneconfig/renderer/AssetLoader.java
index e8861eb..ee6c326 100644
--- a/src/main/java/cc/polyfrost/oneconfig/renderer/image/ImageLoader.java
+++ b/src/main/java/cc/polyfrost/oneconfig/renderer/AssetLoader.java
@@ -1,5 +1,7 @@
-package cc.polyfrost.oneconfig.renderer.image;
+package cc.polyfrost.oneconfig.renderer;
+import cc.polyfrost.oneconfig.internal.assets.Images;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.utils.IOUtils;
import org.lwjgl.nanovg.NSVGImage;
import org.lwjgl.nanovg.NanoSVG;
@@ -20,21 +22,21 @@ import java.util.HashMap;
* @see Images
* @see SVGs
*/
-public final class ImageLoader {
- private ImageLoader() {
+public final class AssetLoader {
+ private AssetLoader() {
}
private final HashMap<String, Integer> imageHashMap = new HashMap<>();
private final HashMap<String, Integer> svgHashMap = new HashMap<>();
- public static ImageLoader INSTANCE = new ImageLoader();
+ public static AssetLoader INSTANCE = new AssetLoader();
/**
- * Loads an image from resources.
+ * Loads an assets from resources.
*
* @param vg The NanoVG context.
* @param fileName The name of the file to load.
- * @return Whether the image was loaded successfully.
+ * @return Whether the assets was loaded successfully.
*/
public boolean loadImage(long vg, String fileName) {
if (!imageHashMap.containsKey(fileName)) {
@@ -109,24 +111,24 @@ public final class ImageLoader {
}
/**
- * Get a loaded image from the cache.
- * <p><b>Requires the image to have been loaded first.</b></p>
+ * Get a loaded assets from the cache.
+ * <p><b>Requires the assets to have been loaded first.</b></p>
*
* @param fileName The name of the file to load.
- * @return The image
- * @see ImageLoader#loadImage(long, String)
+ * @return The assets
+ * @see AssetLoader#loadImage(long, String)
*/
public int getImage(String fileName) {
return imageHashMap.get(fileName);
}
/**
- * Remove an image from the cache, allowing the image to be garbage collected.
- * Should be used when the GUI rendering the image is closed.
+ * Remove an assets from the cache, allowing the assets to be garbage collected.
+ * Should be used when the GUI rendering the assets is closed.
*
* @param vg The NanoVG context.
* @param fileName The name of the file to remove.
- * @see ImageLoader#loadImage(long, String)
+ * @see AssetLoader#loadImage(long, String)
*/
public void removeImage(long vg, String fileName) {
NanoVG.nvgDeleteImage(vg, imageHashMap.get(fileName));
@@ -153,7 +155,7 @@ public final class ImageLoader {
*
* @param fileName The name of the file to load.
* @return The SVG
- * @see ImageLoader#loadSVG(long, String, float, float)
+ * @see AssetLoader#loadSVG(long, String, float, float)
*/
public int getSVG(String fileName, float width, float height) {
String name = fileName + "-" + width + "-" + height;
@@ -161,12 +163,12 @@ public final class ImageLoader {
}
/**
- * Remove a SVG from the cache, allowing the SVG to be garbage collected.
+ * Remove an SVG from the cache, allowing the SVG to be garbage collected.
* Should be used when the GUI rendering the SVG is closed.
*
* @param vg The NanoVG context.
* @param fileName The name of the file to remove.
- * @see ImageLoader#loadSVG(long, String, float, float)
+ * @see AssetLoader#loadSVG(long, String, float, float)
*/
public void removeSVG(long vg, String fileName, float width, float height) {
String name = fileName + "-" + width + "-" + height;
diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java
index 20fc8f6..7ab39e0 100644
--- a/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java
@@ -1,14 +1,13 @@
package cc.polyfrost.oneconfig.renderer;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.data.InfoType;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.renderer.font.Font;
import cc.polyfrost.oneconfig.renderer.font.FontManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.ImageLoader;
-import cc.polyfrost.oneconfig.renderer.image.Images;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.Images;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.utils.InputUtils;
import cc.polyfrost.oneconfig.utils.NetworkUtils;
import gg.essential.universal.UGraphics;
@@ -405,9 +404,9 @@ public final class RenderManager {
* @see RenderManager#drawImage(long, String, float, float, float, float, int)
*/
public static void drawImage(long vg, String filePath, float x, float y, float width, float height) {
- if (ImageLoader.INSTANCE.loadImage(vg, filePath)) {
+ if (AssetLoader.INSTANCE.loadImage(vg, filePath)) {
NVGPaint imagePaint = NVGPaint.calloc();
- int image = ImageLoader.INSTANCE.getImage(filePath);
+ int image = AssetLoader.INSTANCE.getImage(filePath);
nvgBeginPath(vg);
nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint);
nvgRect(vg, x, y, width, height);
@@ -429,9 +428,9 @@ public final class RenderManager {
* @param color The color.
*/
public static void drawImage(long vg, String filePath, float x, float y, float width, float height, int color) {
- if (ImageLoader.INSTANCE.loadImage(vg, filePath)) {
+ if (AssetLoader.INSTANCE.loadImage(vg, filePath)) {
NVGPaint imagePaint = NVGPaint.calloc();
- int image = ImageLoader.INSTANCE.getImage(filePath);
+ int image = AssetLoader.INSTANCE.getImage(filePath);
nvgBeginPath(vg);
nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint);
nvgRGBA((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF), (byte) (color >> 24 & 0xFF), imagePaint.innerColor());
@@ -472,9 +471,9 @@ public final class RenderManager {
* @param radius The radius.
*/
public static void drawRoundImage(long vg, String filePath, float x, float y, float width, float height, float radius) {
- if (ImageLoader.INSTANCE.loadImage(vg, filePath)) {
+ if (AssetLoader.INSTANCE.loadImage(vg, filePath)) {
NVGPaint imagePaint = NVGPaint.calloc();
- int image = ImageLoader.INSTANCE.getImage(filePath);
+ int image = AssetLoader.INSTANCE.getImage(filePath);
nvgBeginPath(vg);
nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint);
nvgRoundedRect(vg, x, y, width, height, radius);
@@ -636,9 +635,9 @@ public final class RenderManager {
w *= OneConfigGui.INSTANCE.getScaleFactor();
h *= OneConfigGui.INSTANCE.getScaleFactor();
}
- if (ImageLoader.INSTANCE.loadSVG(vg, filePath, w, h)) {
+ if (AssetLoader.INSTANCE.loadSVG(vg, filePath, w, h)) {
NVGPaint imagePaint = NVGPaint.calloc();
- int image = ImageLoader.INSTANCE.getSVG(filePath, w, h);
+ int image = AssetLoader.INSTANCE.getSVG(filePath, w, h);
nvgBeginPath(vg);
nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint);
nvgRect(vg, x, y, width, height);
@@ -666,9 +665,9 @@ public final class RenderManager {
w *= OneConfigGui.INSTANCE.getScaleFactor();
h *= OneConfigGui.INSTANCE.getScaleFactor();
}
- if (ImageLoader.INSTANCE.loadSVG(vg, filePath, w, h)) {
+ if (AssetLoader.INSTANCE.loadSVG(vg, filePath, w, h)) {
NVGPaint imagePaint = NVGPaint.calloc();
- int image = ImageLoader.INSTANCE.getSVG(filePath, w, h);
+ int image = AssetLoader.INSTANCE.getSVG(filePath, w, h);
nvgBeginPath(vg);
nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint);
nvgRGBA((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF), (byte) (color >> 24 & 0xFF), imagePaint.innerColor());
diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/image/Images.java b/src/main/java/cc/polyfrost/oneconfig/renderer/image/Images.java
deleted file mode 100644
index ad1941e..0000000
--- a/src/main/java/cc/polyfrost/oneconfig/renderer/image/Images.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package cc.polyfrost.oneconfig.renderer.image;
-
-/**
- * An enum of images used in OneConfig.
- *
- * @see cc.polyfrost.oneconfig.renderer.RenderManager#drawImage(long, String, float, float, float, float, int)
- * @see ImageLoader
- */
-public enum Images {
- HUE_GRADIENT("/assets/oneconfig/options/HueGradient.png"),
- COLOR_WHEEL("/assets/oneconfig/options/ColorWheel.png"),
- ALPHA_GRID("/assets/oneconfig/options/AlphaGrid.png");
-
- public final String filePath;
-
- Images(String filePath) {
- this.filePath = filePath;
- }
-} \ No newline at end of file
diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/image/SVGs.java b/src/main/java/cc/polyfrost/oneconfig/renderer/image/SVGs.java
deleted file mode 100644
index 5ba3fcd..0000000
--- a/src/main/java/cc/polyfrost/oneconfig/renderer/image/SVGs.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package cc.polyfrost.oneconfig.renderer.image;
-
-/**
- * An enum of SVGs used in OneConfig.
- *
- * @see cc.polyfrost.oneconfig.renderer.RenderManager#drawSvg(long, String, float, float, float, float, int)
- * @see ImageLoader
- */
-public enum SVGs {
- ONECONFIG("/assets/oneconfig/icons/OneConfig.svg"),
- ONECONFIG_OFF("/assets/oneconfig/icons/OneConfigOff.svg"),
- COPYRIGHT_FILL("/assets/oneconfig/icons/CopyrightFill.svg"),
- APERTURE_FILL("/assets/oneconfig/icons/ApertureFill.svg"),
- ARROWS_CLOCKWISE_BOLD("/assets/oneconfig/icons/ArrowsClockwiseBold.svg"),
- FADERS_HORIZONTAL_BOLD("/assets/oneconfig/icons/FadersHorizontalBold.svg"),
- GAUGE_FILL("/assets/oneconfig/icons/GaugeFill.svg"),
- GEAR_SIX_FILL("/assets/oneconfig/icons/GearSixFill.svg"),
- MAGNIFYING_GLASS_BOLD("/assets/oneconfig/icons/MagnifyingGlassBold.svg"),
- NOTE_PENCIL_BOLD("/assets/oneconfig/icons/NotePencilBold.svg"),
- PAINT_BRUSH_BROAD_FILL("/assets/oneconfig/icons/PaintBrushBroadFill.svg"),
- USER_SWITCH_FILL("/assets/oneconfig/icons/UserSwitchFill.svg"),
- X_CIRCLE_BOLD("/assets/oneconfig/icons/XCircleBold.svg"),
- CARET_LEFT("/assets/oneconfig/icons/CaretLeftBold.svg"),
- CARET_RIGHT("/assets/oneconfig/icons/CaretRightBold.svg"),
-
- // OLD ICONS
- BOX("/assets/oneconfig/old-icons/Box.svg"),
- CHECKBOX_TICK("/assets/oneconfig/old-icons/CheckboxTick.svg"),
- CHECK_CIRCLE("/assets/oneconfig/old-icons/CheckCircle.svg"),
- CHEVRON_DOWN("/assets/oneconfig/old-icons/ChevronDown.svg"),
- CHEVRON_UP("/assets/oneconfig/old-icons/ChevronUp.svg"),
- COPY("/assets/oneconfig/old-icons/Copy.svg"),
- DROPDOWN_LIST("/assets/oneconfig/old-icons/DropdownList.svg"),
- ERROR("/assets/oneconfig/old-icons/Error.svg"),
- EYE("/assets/oneconfig/old-icons/Eye.svg"),
- EYE_OFF("/assets/oneconfig/old-icons/EyeOff.svg"),
- HEART_FILL("/assets/oneconfig/old-icons/HeartFill.svg"),
- HEART_OUTLINE("/assets/oneconfig/old-icons/HeartOutline.svg"),
- HELP_CIRCLE("/assets/oneconfig/old-icons/HelpCircle.svg"),
- HISTORY("/assets/oneconfig/old-icons/History.svg"),
- INFO_CIRCLE("/assets/oneconfig/old-icons/InfoCircle.svg"),
- KEYSTROKE("/assets/oneconfig/old-icons/Keystroke.svg"),
- PASTE("/assets/oneconfig/old-icons/Paste.svg"),
- POP_OUT("/assets/oneconfig/old-icons/PopOut.svg"),
- WARNING("/assets/oneconfig/old-icons/Warning.svg");
-
- public final String filePath;
-
- SVGs(String filePath) {
- this.filePath = filePath;
- }
-}