aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorJuuxel <6596629+Juuxel@users.noreply.github.com>2020-11-26 22:52:34 +0200
committerJuuxel <6596629+Juuxel@users.noreply.github.com>2020-11-26 22:52:34 +0200
commit68e38117e60197e45963746c9b0fa44f696f420f (patch)
treeb236fd63ae938ed9707d01cc05b7d0a46ccd85bd /src/main/java
parenta43a1123fdcd88eb49276cc523713d1204215891 (diff)
downloadLibGui-68e38117e60197e45963746c9b0fa44f696f420f.tar.gz
LibGui-68e38117e60197e45963746c9b0fa44f696f420f.tar.bz2
LibGui-68e38117e60197e45963746c9b0fa44f696f420f.zip
Move modmenu support, nine-patch internals and init code into impl package
Also introduced a new LibGui class that provides API access to the dark mode setting now that the config is unavailable publically.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java2
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/LibGui.java18
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/LightweightGuiDescription.java2
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/NinePatch.java104
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java2
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/package-info.java4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/access/package-info.java3
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/client/LibGuiClient.java (renamed from src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiClient.java)5
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/client/LibGuiConfig.java (renamed from src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiConfig.java)2
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/client/NinePatchInternals.java103
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/client/modmenu/ConfigGui.java (renamed from src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ConfigGui.java)4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/client/modmenu/ModMenuSupport.java (renamed from src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ModMenuSupport.java)2
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/client/modmenu/WKirbSprite.java (renamed from src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/WKirbSprite.java)8
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/client/modmenu/package-info.java7
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/client/package-info.java9
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/package-info.java3
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WDynamicLabel.java4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java6
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java10
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java4
24 files changed, 187 insertions, 131 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java b/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java
index 293852d..83ae894 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java
@@ -21,7 +21,7 @@ import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.world.World;
import io.github.cottonmc.cotton.gui.client.BackgroundPainter;
-import io.github.cottonmc.cotton.gui.client.LibGuiClient;
+import io.github.cottonmc.cotton.gui.client.LibGui;
import io.github.cottonmc.cotton.gui.widget.WGridPanel;
import io.github.cottonmc.cotton.gui.widget.WLabel;
import io.github.cottonmc.cotton.gui.widget.WPanel;
@@ -74,7 +74,7 @@ public class SyncedGuiDescription extends ScreenHandler implements GuiDescriptio
}
public int getTitleColor() {
- return (world.isClient && LibGuiClient.config.darkMode) ? darkTitleColor : titleColor;
+ return (world.isClient && LibGui.isDarkMode()) ? darkTitleColor : titleColor;
}
public SyncedGuiDescription setRootPanel(WPanel panel) {
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java b/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java
index 4789271..c856761 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java
@@ -147,7 +147,7 @@ public interface BackgroundPainter {
*/
public static BackgroundPainter createLightDarkVariants(BackgroundPainter light, BackgroundPainter dark) {
return (left, top, panel) -> {
- if (LibGuiClient.config.darkMode) dark.paintBackground(left, top, panel);
+ if (LibGui.isDarkMode()) dark.paintBackground(left, top, panel);
else light.paintBackground(left, top, panel);
};
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/LibGui.java b/src/main/java/io/github/cottonmc/cotton/gui/client/LibGui.java
new file mode 100644
index 0000000..8b1973a
--- /dev/null
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/LibGui.java
@@ -0,0 +1,18 @@
+package io.github.cottonmc.cotton.gui.client;
+
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+
+import io.github.cottonmc.cotton.gui.impl.client.LibGuiClient;
+
+/**
+ * Provides access to global LibGui data such as the dark mode state.
+ *
+ * @since 4.0.0
+ */
+@Environment(EnvType.CLIENT)
+public final class LibGui {
+ public static boolean isDarkMode() {
+ return LibGuiClient.config.darkMode;
+ }
+}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/LightweightGuiDescription.java b/src/main/java/io/github/cottonmc/cotton/gui/client/LightweightGuiDescription.java
index 41b8d49..54ae02f 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/LightweightGuiDescription.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/LightweightGuiDescription.java
@@ -32,7 +32,7 @@ public class LightweightGuiDescription implements GuiDescription {
@Override
public int getTitleColor() {
- return (LibGuiClient.config.darkMode) ? darkmodeTitleColor : titleColor;
+ return (LibGui.isDarkMode()) ? darkmodeTitleColor : titleColor;
}
@Override
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/NinePatch.java b/src/main/java/io/github/cottonmc/cotton/gui/client/NinePatch.java
index 9057739..033f7cf 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/NinePatch.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/NinePatch.java
@@ -2,24 +2,13 @@ package io.github.cottonmc.cotton.gui.client;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
-import net.minecraft.resource.Resource;
-import net.minecraft.resource.ResourceManager;
-import net.minecraft.resource.SinglePreparationResourceReloadListener;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
-import net.minecraft.util.profiler.Profiler;
+import io.github.cottonmc.cotton.gui.impl.client.NinePatchInternals;
import io.github.cottonmc.cotton.gui.widget.WWidget;
import org.jetbrains.annotations.Nullable;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
/**
* The nine-patch background painter paints rectangles using a nine-patch texture.
*
@@ -178,7 +167,7 @@ public class NinePatch implements BackgroundPainter {
int y2 = top + height - cornerSize;
float uv1 = cornerUv;
float uv2 = 1.0f - cornerUv;
- Mode mode = this.mode != null ? this.mode : MetadataLoader.INSTANCE.getProperties(texture).getMode();
+ Mode mode = this.mode != null ? this.mode : NinePatchInternals.MetadataLoader.INSTANCE.getProperties(texture).getMode();
ScreenDrawing.texturedRect(left, top, cornerSize, cornerSize, texture, 0, 0, uv1, uv1, 0xFF_FFFFFF);
ScreenDrawing.texturedRect(x2, top, cornerSize, cornerSize, texture, uv2, 0, 1, uv1, 0xFF_FFFFFF);
@@ -239,8 +228,15 @@ public class NinePatch implements BackgroundPainter {
*/
TILING;
+ /**
+ * Deserializes a nine-patch mode from a string.
+ *
+ * @param str the mode string
+ * @return the mode, or null if the string is invalid
+ * @since 4.0.0
+ */
@Nullable
- static Mode fromString(String str) {
+ public static Mode fromString(String str) {
if (str == null) return null;
if (str.equalsIgnoreCase("stretching")) return STRETCHING;
@@ -249,84 +245,4 @@ public class NinePatch implements BackgroundPainter {
return null;
}
}
-
- public static class TextureProperties {
- public static final TextureProperties DEFAULT = new TextureProperties(Mode.STRETCHING);
-
- private final Mode mode;
-
- public TextureProperties(Mode mode) {
- this.mode = mode;
- }
-
- public Mode getMode() {
- return mode;
- }
- }
-
- public static class MetadataLoader extends SinglePreparationResourceReloadListener<Map<Identifier, Properties>> implements IdentifiableResourceReloadListener {
- public static final MetadataLoader INSTANCE = new MetadataLoader();
-
- private static final Identifier ID = new Identifier("libgui", "9patch_metadata");
- private static final String SUFFIX = ".9patch";
-
- private Map<Identifier, TextureProperties> properties = Collections.emptyMap();
-
- public TextureProperties getProperties(Identifier texture) {
- return properties.getOrDefault(texture, TextureProperties.DEFAULT);
- }
-
- @Override
- public Identifier getFabricId() {
- return ID;
- }
-
- @Override
- protected Map<Identifier, Properties> prepare(ResourceManager manager, Profiler profiler) {
- Collection<Identifier> ids = manager.findResources("textures", s -> s.endsWith(SUFFIX));
- Map<Identifier, Properties> result = new HashMap<>();
-
- for (Identifier input : ids) {
- try (Resource resource = manager.getResource(input);
- InputStream stream = resource.getInputStream()) {
- Properties props = new Properties();
- props.load(stream);
- Identifier textureId = new Identifier(input.getNamespace(), input.getPath().substring(0, input.getPath().length() - SUFFIX.length()));
- result.put(textureId, props);
- } catch (Exception e) {
- LibGuiClient.logger.error("Error while loading metadata file {}, skipping...", input, e);
- }
- }
-
- return result;
- }
-
- @Override
- protected void apply(Map<Identifier, Properties> meta, ResourceManager manager, Profiler profiler) {
- properties = new HashMap<>();
- for (Map.Entry<Identifier, Properties> entry : meta.entrySet()) {
- Identifier id = entry.getKey();
- Properties props = entry.getValue();
-
- Mode mode = TextureProperties.DEFAULT.getMode();
-// float cornerUv = TextureProperties.DEFAULT.getCornerUv();
-
- if (props.containsKey("mode")) {
- String modeStr = props.getProperty("mode");
- mode = Mode.fromString(modeStr);
- if (mode == null) {
- LibGuiClient.logger.error("Invalid mode '{}' in nine-patch metadata file for texture {}", modeStr, id);
- continue;
- }
- }
-
-// if (props.containsKey("cornerUv")) {
-// cornerUv = Float.parseFloat(props.getProperty("cornerUv"));
-// }
-
- TextureProperties texProperties = new TextureProperties(mode);
- properties.put(id, texProperties);
- }
- }
- }
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
index daaaf2f..0781769 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
@@ -263,7 +263,7 @@ public class ScreenDrawing {
* @param height the height of the panel
*/
public static void drawGuiPanel(int x, int y, int width, int height) {
- if (LibGuiClient.config.darkMode) drawGuiPanel(x, y, width, height, 0xFF0B0B0B, 0xFF2F2F2F, 0xFF414141, 0xFF000000);
+ if (LibGui.isDarkMode()) drawGuiPanel(x, y, width, height, 0xFF0B0B0B, 0xFF2F2F2F, 0xFF414141, 0xFF000000);
else drawGuiPanel(x, y, width, height, 0xFF555555, 0xFFC6C6C6, 0xFFFFFFFF, 0xFF000000);
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/package-info.java b/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/package-info.java
deleted file mode 100644
index ad040bf..0000000
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Mod Menu support for LibGui.
- */
-package io.github.cottonmc.cotton.gui.client.modmenu;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/access/package-info.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/access/package-info.java
index 8f391fd..b98a6b8 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/impl/access/package-info.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/access/package-info.java
@@ -1,4 +1,7 @@
/**
* Internal implementation classes.
*/
+@ApiStatus.Internal
package io.github.cottonmc.cotton.gui.impl.access;
+
+import org.jetbrains.annotations.ApiStatus;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiClient.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/LibGuiClient.java
index a5fbb2d..5ebc2bb 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiClient.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/LibGuiClient.java
@@ -1,4 +1,4 @@
-package io.github.cottonmc.cotton.gui.client;
+package io.github.cottonmc.cotton.gui.impl.client;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
@@ -11,6 +11,7 @@ import blue.endless.jankson.JsonObject;
import io.github.cottonmc.jankson.JanksonFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.jetbrains.annotations.ApiStatus;
import java.io.File;
import java.io.FileOutputStream;
@@ -27,7 +28,7 @@ public class LibGuiClient implements ClientModInitializer {
public void onInitializeClient() {
config = loadConfig();
- ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(NinePatch.MetadataLoader.INSTANCE);
+ ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(NinePatchInternals.MetadataLoader.INSTANCE);
}
public static LibGuiConfig loadConfig() {
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiConfig.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/LibGuiConfig.java
index b971e31..b1985af 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiConfig.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/LibGuiConfig.java
@@ -1,4 +1,4 @@
-package io.github.cottonmc.cotton.gui.client;
+package io.github.cottonmc.cotton.gui.impl.client;
import blue.endless.jankson.Comment;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NinePatchInternals.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NinePatchInternals.java
new file mode 100644
index 0000000..4113825
--- /dev/null
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NinePatchInternals.java
@@ -0,0 +1,103 @@
+package io.github.cottonmc.cotton.gui.impl.client;
+
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
+import net.minecraft.resource.Resource;
+import net.minecraft.resource.ResourceManager;
+import net.minecraft.resource.SinglePreparationResourceReloadListener;
+import net.minecraft.util.Identifier;
+import net.minecraft.util.profiler.Profiler;
+
+import io.github.cottonmc.cotton.gui.client.NinePatch;
+
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+@Environment(EnvType.CLIENT)
+public final class NinePatchInternals {
+ @Environment(EnvType.CLIENT)
+ public static final class MetadataLoader extends SinglePreparationResourceReloadListener<Map<Identifier, Properties>> implements IdentifiableResourceReloadListener {
+ public static final MetadataLoader INSTANCE = new MetadataLoader();
+
+ private static final Identifier ID = new Identifier("libgui", "9patch_metadata");
+ private static final String SUFFIX = ".9patch";
+
+ private Map<Identifier, TextureProperties> properties = Collections.emptyMap();
+
+ public TextureProperties getProperties(Identifier texture) {
+ return properties.getOrDefault(texture, TextureProperties.DEFAULT);
+ }
+
+ @Override
+ public Identifier getFabricId() {
+ return ID;
+ }
+
+ @Override
+ protected Map<Identifier, Properties> prepare(ResourceManager manager, Profiler profiler) {
+ Collection<Identifier> ids = manager.findResources("textures", s -> s.endsWith(SUFFIX));
+ Map<Identifier, Properties> result = new HashMap<>();
+
+ for (Identifier input : ids) {
+ try (Resource resource = manager.getResource(input);
+ InputStream stream = resource.getInputStream()) {
+ Properties props = new Properties();
+ props.load(stream);
+ Identifier textureId = new Identifier(input.getNamespace(), input.getPath().substring(0, input.getPath().length() - SUFFIX.length()));
+ result.put(textureId, props);
+ } catch (Exception e) {
+ LibGuiClient.logger.error("Error while loading metadata file {}, skipping...", input, e);
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ protected void apply(Map<Identifier, Properties> meta, ResourceManager manager, Profiler profiler) {
+ properties = new HashMap<>();
+ for (Map.Entry<Identifier, Properties> entry : meta.entrySet()) {
+ Identifier id = entry.getKey();
+ Properties props = entry.getValue();
+
+ NinePatch.Mode mode = TextureProperties.DEFAULT.getMode();
+ // float cornerUv = TextureProperties.DEFAULT.getCornerUv();
+
+ if (props.containsKey("mode")) {
+ String modeStr = props.getProperty("mode");
+ mode = NinePatch.Mode.fromString(modeStr);
+ if (mode == null) {
+ LibGuiClient.logger.error("Invalid mode '{}' in nine-patch metadata file for texture {}", modeStr, id);
+ continue;
+ }
+ }
+
+ // if (props.containsKey("cornerUv")) {
+ // cornerUv = Float.parseFloat(props.getProperty("cornerUv"));
+ // }
+
+ TextureProperties texProperties = new TextureProperties(mode);
+ properties.put(id, texProperties);
+ }
+ }
+ }
+
+ public static class TextureProperties {
+ public static final TextureProperties DEFAULT = new TextureProperties(NinePatch.Mode.STRETCHING);
+
+ private final NinePatch.Mode mode;
+
+ public TextureProperties(NinePatch.Mode mode) {
+ this.mode = mode;
+ }
+
+ public NinePatch.Mode getMode() {
+ return mode;
+ }
+ }
+}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ConfigGui.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/modmenu/ConfigGui.java
index cd3fe0a..5f3d4fa 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ConfigGui.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/modmenu/ConfigGui.java
@@ -1,12 +1,12 @@
-package io.github.cottonmc.cotton.gui.client.modmenu;
+package io.github.cottonmc.cotton.gui.impl.client.modmenu;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.TranslatableText;
import io.github.cottonmc.cotton.gui.client.BackgroundPainter;
-import io.github.cottonmc.cotton.gui.client.LibGuiClient;
import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
+import io.github.cottonmc.cotton.gui.impl.client.LibGuiClient;
import io.github.cottonmc.cotton.gui.widget.WButton;
import io.github.cottonmc.cotton.gui.widget.WGridPanel;
import io.github.cottonmc.cotton.gui.widget.WTextField;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ModMenuSupport.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/modmenu/ModMenuSupport.java
index ccdff93..82fead4 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ModMenuSupport.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/modmenu/ModMenuSupport.java
@@ -1,4 +1,4 @@
-package io.github.cottonmc.cotton.gui.client.modmenu;
+package io.github.cottonmc.cotton.gui.impl.client.modmenu;
import net.minecraft.text.TranslatableText;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/WKirbSprite.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/modmenu/WKirbSprite.java
index 74d5357..140819a 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/WKirbSprite.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/modmenu/WKirbSprite.java
@@ -1,11 +1,11 @@
-package io.github.cottonmc.cotton.gui.client.modmenu;
+package io.github.cottonmc.cotton.gui.impl.client.modmenu;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
-import io.github.cottonmc.cotton.gui.client.LibGuiClient;
+import io.github.cottonmc.cotton.gui.client.LibGui;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.widget.WWidget;
@@ -30,7 +30,7 @@ public class WKirbSprite extends WWidget {
private long lastFrame;
public WKirbSprite() {
- state = (LibGuiClient.config.darkMode) ? State.ASLEEP : State.AWAKE;
+ state = (LibGui.isDarkMode()) ? State.ASLEEP : State.AWAKE;
}
public void schedule(int[] frames) {
@@ -60,7 +60,7 @@ public class WKirbSprite extends WWidget {
if (pendingFrames.isEmpty()) {
- if (LibGuiClient.config.darkMode) {
+ if (LibGui.isDarkMode()) {
switch(state) {
case AWAKE:
state = State.FALLING_ASLEEP;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/modmenu/package-info.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/modmenu/package-info.java
new file mode 100644
index 0000000..283aa50
--- /dev/null
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/modmenu/package-info.java
@@ -0,0 +1,7 @@
+/**
+ * Mod Menu support for LibGui.
+ */
+@ApiStatus.Internal
+package io.github.cottonmc.cotton.gui.impl.client.modmenu;
+
+import org.jetbrains.annotations.ApiStatus;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/package-info.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/package-info.java
new file mode 100644
index 0000000..c27d30e
--- /dev/null
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/package-info.java
@@ -0,0 +1,9 @@
+/**
+ * Internal implementation classes.
+ *
+ * @since 4.0.0
+ */
+@ApiStatus.Internal // I hope this scares people off
+package io.github.cottonmc.cotton.gui.impl.client;
+
+import org.jetbrains.annotations.ApiStatus;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/package-info.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/package-info.java
index 678ba6f..298c2fc 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/impl/package-info.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/package-info.java
@@ -3,4 +3,7 @@
*
* @since 2.0.0
*/
+@ApiStatus.Internal
package io.github.cottonmc.cotton.gui.impl;
+
+import org.jetbrains.annotations.ApiStatus;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WDynamicLabel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WDynamicLabel.java
index 0412b83..6099022 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WDynamicLabel.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WDynamicLabel.java
@@ -4,7 +4,7 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.util.math.MatrixStack;
-import io.github.cottonmc.cotton.gui.client.LibGuiClient;
+import io.github.cottonmc.cotton.gui.client.LibGui;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment;
@@ -40,7 +40,7 @@ public class WDynamicLabel extends WWidget {
@Override
public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
String tr = text.get();
- ScreenDrawing.drawString(matrices, tr, alignment, x, y, this.getWidth(), LibGuiClient.config.darkMode ? darkmodeColor : color);
+ ScreenDrawing.drawString(matrices, tr, alignment, x, y, this.getWidth(), LibGui.isDarkMode() ? darkmodeColor : color);
}
@Override
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java
index 0bdf81a..2583448 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java
@@ -10,7 +10,7 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
-import io.github.cottonmc.cotton.gui.client.LibGuiClient;
+import io.github.cottonmc.cotton.gui.client.LibGui;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.client.TextHoverRendererScreen;
import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment;
@@ -33,7 +33,7 @@ public class WLabel extends WWidget {
public static final int DEFAULT_TEXT_COLOR = 0x404040;
/**
- * The default text color for {@linkplain io.github.cottonmc.cotton.gui.client.LibGuiConfig#darkMode dark mode} labels.
+ * The default text color for {@linkplain LibGui#isDarkMode() dark mode} labels.
*/
public static final int DEFAULT_DARKMODE_TEXT_COLOR = 0xbcbcbc;
@@ -98,7 +98,7 @@ public class WLabel extends WWidget {
break;
}
- ScreenDrawing.drawString(matrices, text.asOrderedText(), horizontalAlignment, x, y + yOffset, this.getWidth(), LibGuiClient.config.darkMode ? darkmodeColor : color);
+ ScreenDrawing.drawString(matrices, text.asOrderedText(), horizontalAlignment, x, y + yOffset, this.getWidth(), LibGui.isDarkMode() ? darkmodeColor : color);
Style hoveredTextStyle = getTextStyleAt(mouseX, mouseY);
if (hoveredTextStyle != null) {
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java
index 500f312..812b5fe 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java
@@ -4,7 +4,7 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.util.math.MatrixStack;
-import io.github.cottonmc.cotton.gui.client.LibGuiClient;
+import io.github.cottonmc.cotton.gui.client.LibGui;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.widget.data.Axis;
@@ -36,7 +36,7 @@ public class WScrollBar extends WWidget {
@Environment(EnvType.CLIENT)
@Override
public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
- if (LibGuiClient.config.darkMode) {
+ if (LibGui.isDarkMode()) {
ScreenDrawing.drawBeveledPanel(x, y, width, height, 0xFF_212121, 0xFF_2F2F2F, 0xFF_5D5D5D);
} else {
ScreenDrawing.drawBeveledPanel(x, y, width, height, 0xFF_373737, 0xFF_8B8B8B, 0xFF_FFFFFF);
@@ -47,7 +47,7 @@ public class WScrollBar extends WWidget {
int top, middle, bottom;
if (sliding) {
- if (LibGuiClient.config.darkMode) {
+ if (LibGui.isDarkMode()) {
top = 0xFF_6C6C6C;
middle = 0xFF_2F2F2F;
bottom = 0xFF_212121;
@@ -57,7 +57,7 @@ public class WScrollBar extends WWidget {
bottom = 0xFF_555555;
}
} else if (isWithinBounds(mouseX, mouseY)) {
- if (LibGuiClient.config.darkMode) {
+ if (LibGui.isDarkMode()) {
top = 0xFF_5F6A9D;
middle = 0xFF_323F6E;
bottom = 0xFF_0B204A;
@@ -67,7 +67,7 @@ public class WScrollBar extends WWidget {
bottom = 0xFF_343E75;
}
} else {
- if (LibGuiClient.config.darkMode) {
+ if (LibGui.isDarkMode()) {
top = 0xFF_6C6C6C;
middle = 0xFF_414141;
bottom = 0xFF_212121;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java
index 0e78333..6638fb7 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java
@@ -6,7 +6,7 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import io.github.cottonmc.cotton.gui.client.BackgroundPainter;
-import io.github.cottonmc.cotton.gui.client.LibGuiClient;
+import io.github.cottonmc.cotton.gui.client.LibGui;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.widget.data.Axis;
import org.jetbrains.annotations.Nullable;
@@ -57,7 +57,7 @@ public class WSlider extends WAbstractSlider {
int thumbX, thumbY;
// thumbXOffset: thumb texture x offset in pixels
int thumbXOffset;
- Identifier texture = LibGuiClient.config.darkMode ? DARK_TEXTURE : LIGHT_TEXTURE;
+ Identifier texture = LibGui.isDarkMode() ? DARK_TEXTURE : LIGHT_TEXTURE;
if (axis == Axis.VERTICAL) {
int trackX = x + width / 2 - TRACK_WIDTH / 2;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java
index 9e17d37..576588a 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java
@@ -11,7 +11,7 @@ import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import io.github.cottonmc.cotton.gui.client.BackgroundPainter;
-import io.github.cottonmc.cotton.gui.client.LibGuiClient;
+import io.github.cottonmc.cotton.gui.client.LibGui;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.widget.data.Axis;
import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment;
@@ -336,7 +336,7 @@ public class WTabPanel extends WPanel {
HorizontalAlignment align = (icon != null) ? HorizontalAlignment.LEFT : HorizontalAlignment.CENTER;
int color;
- if (LibGuiClient.config.darkMode) {
+ if (LibGui.isDarkMode()) {
color = WLabel.DEFAULT_DARKMODE_TEXT_COLOR;
} else {
color = selected ? WLabel.DEFAULT_TEXT_COLOR : 0xEEEEEE;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java
index 953f995..4ce4440 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java
@@ -10,7 +10,7 @@ import net.minecraft.text.OrderedText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
-import io.github.cottonmc.cotton.gui.client.LibGuiClient;
+import io.github.cottonmc.cotton.gui.client.LibGui;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.client.TextHoverRendererScreen;
import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment;
@@ -109,7 +109,7 @@ public class WText extends WWidget {
for (int i = 0; i < wrappedLines.size(); i++) {
OrderedText line = wrappedLines.get(i);
- int c = LibGuiClient.config.darkMode ? darkmodeColor : color;
+ int c = LibGui.isDarkMode() ? darkmodeColor : color;
ScreenDrawing.drawString(matrices, line, horizontalAlignment, x, y + yOffset + i * font.fontHeight, width, c);
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java
index 1142928..1a88ece 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java
@@ -9,7 +9,7 @@ import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
-import io.github.cottonmc.cotton.gui.client.LibGuiClient;
+import io.github.cottonmc.cotton.gui.client.LibGui;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.widget.data.Texture;
import org.jetbrains.annotations.Nullable;
@@ -107,7 +107,7 @@ public class WToggleButton extends WWidget {
}
if (label!=null) {
- ScreenDrawing.drawString(matrices, label.asOrderedText(), x + 22, y+6, LibGuiClient.config.darkMode ? darkmodeColor : color);
+ ScreenDrawing.drawString(matrices, label.asOrderedText(), x + 22, y+6, LibGui.isDarkMode() ? darkmodeColor : color);
}
}