From 4c7158c99f0186a8ed7dd2fd37db4b6df4164f4c Mon Sep 17 00:00:00 2001 From: Juuxel Date: Thu, 29 Aug 2019 12:11:03 +0300 Subject: Sliders are done! --- .../cotton/gui/client/modmenu/ConfigGui.java | 19 ++++-- .../cotton/gui/widget/WAbstractSlider.java | 65 ++++++++++++++------- .../cottonmc/cotton/gui/widget/WLabeledSlider.java | 64 +++++++++++++++----- .../github/cottonmc/cotton/gui/widget/WSlider.java | 16 +---- .../assets/libgui/textures/widget/slider.png | Bin 2597 -> 2978 bytes 5 files changed, 112 insertions(+), 52 deletions(-) diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ConfigGui.java b/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ConfigGui.java index 97b3cfc..b8abd22 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ConfigGui.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ConfigGui.java @@ -3,11 +3,8 @@ package io.github.cottonmc.cotton.gui.client.modmenu; 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.widget.Axis; import io.github.cottonmc.cotton.gui.widget.WButton; import io.github.cottonmc.cotton.gui.widget.WGridPanel; -import io.github.cottonmc.cotton.gui.widget.WLabeledSlider; -import io.github.cottonmc.cotton.gui.widget.WSlider; import io.github.cottonmc.cotton.gui.widget.WTextField; import io.github.cottonmc.cotton.gui.widget.WToggleButton; import net.minecraft.client.MinecraftClient; @@ -33,8 +30,20 @@ public class ConfigGui extends LightweightGuiDescription { WTextField testField = new WTextField(); testField.setSuggestion("test"); root.add(testField, 0, 3, 4, 1); - root.add(new WSlider(-100, 100, Axis.VERTICAL).setValueChangeListener(System.out::println), 6, 0, 1, 3); - root.add(new WLabeledSlider(1, 100).setValueChangeListener(System.out::println), 1, 4, 4, 1); + + /* + WSlider verticalSlider = new WSlider(-100, 100, Axis.VERTICAL); + verticalSlider.setDraggingFinishedListener(() -> System.out.println("Mouse released")); + verticalSlider.setValueChangeListener(System.out::println); + + WLabeledSlider horizontalSlider = new WLabeledSlider(0, 500); + horizontalSlider.setLabelUpdater(value -> new LiteralText(value + "!")); + horizontalSlider.setDraggingFinishedListener(() -> System.out.println("Mouse released")); + horizontalSlider.setValue(250); + + root.add(verticalSlider, 6, 0, 1, 3); + root.add(horizontalSlider, 1, 4, 4, 1); + */ root.add(new WKirbSprite(), 5, 4); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java index bfa455e..074371f 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java @@ -12,10 +12,11 @@ import java.util.function.IntConsumer; *

You can set two listeners on a slider: *