mirror of
https://github.com/Shiewk/Widgets.git
synced 2026-04-28 11:34:17 +02:00
1.21.6-1.21.8 backport
This commit is contained in:
+4
-4
@@ -2,8 +2,8 @@
|
|||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx1G
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://modmuss50.me/fabric.html
|
# check these on https://modmuss50.me/fabric.html
|
||||||
minecraft_version=1.21.9
|
minecraft_version=1.21.6
|
||||||
yarn_mappings=1.21.9+build.1
|
yarn_mappings=1.21.6+build.1
|
||||||
loader_version=0.17.2
|
loader_version=0.17.2
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=2.0.0
|
mod_version=2.0.0
|
||||||
@@ -11,5 +11,5 @@ maven_group=de.shiewk
|
|||||||
archives_base_name=Widgets
|
archives_base_name=Widgets
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# check this on https://modmuss50.me/fabric.html
|
# check this on https://modmuss50.me/fabric.html
|
||||||
fabric_version=0.134.0+1.21.9
|
fabric_version=0.127.0+1.21.6
|
||||||
modmenu_version=16.0.0-rc.1
|
modmenu_version=15.0.0
|
||||||
|
|||||||
@@ -2,12 +2,9 @@ package de.shiewk.widgets;
|
|||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import de.shiewk.widgets.utils.WidgetUtils;
|
import de.shiewk.widgets.utils.WidgetUtils;
|
||||||
import net.minecraft.client.gui.Click;
|
|
||||||
import net.minecraft.client.gui.Drawable;
|
import net.minecraft.client.gui.Drawable;
|
||||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||||
import net.minecraft.client.gui.widget.Widget;
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
import net.minecraft.client.input.CharInput;
|
|
||||||
import net.minecraft.client.input.KeyInput;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
@@ -46,23 +43,23 @@ public abstract class WidgetSettingOption implements Drawable, Widget {
|
|||||||
public abstract JsonElement saveState();
|
public abstract JsonElement saveState();
|
||||||
public abstract void loadState(JsonElement state);
|
public abstract void loadState(JsonElement state);
|
||||||
|
|
||||||
public boolean mouseClicked(Click click, boolean doubled) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean mouseReleased(Click click){
|
public boolean mouseReleased(double mouseX, double mouseY){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean charTyped(CharInput input) {
|
public boolean charTyped(char chr, int modifiers) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean keyPressed(KeyInput input) {
|
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean keyReleased(KeyInput input) {
|
public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class WidgetsModClient implements ClientModInitializer {
|
|||||||
"widgets.key.config",
|
"widgets.key.config",
|
||||||
InputUtil.Type.KEYSYM,
|
InputUtil.Type.KEYSYM,
|
||||||
GLFW.GLFW_KEY_RIGHT_SHIFT,
|
GLFW.GLFW_KEY_RIGHT_SHIFT,
|
||||||
KeyBinding.Category.create(Identifier.of(WidgetsMod.MOD_ID, "main"))
|
"widgets.key.category"
|
||||||
));
|
));
|
||||||
|
|
||||||
// in-game /widgetsmod command
|
// in-game /widgetsmod command
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package de.shiewk.widgets.client.screen;
|
package de.shiewk.widgets.client.screen;
|
||||||
|
|
||||||
import de.shiewk.widgets.utils.WidgetUtils;
|
import de.shiewk.widgets.utils.WidgetUtils;
|
||||||
import net.minecraft.client.gui.Click;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.cursor.StandardCursors;
|
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
@@ -75,12 +73,12 @@ public class ContextMenuScreen extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(Click click, boolean doubled) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
if (!isInBounds(click.x(), click.y())){
|
if (!isInBounds(mouseX, mouseY)){
|
||||||
close();
|
close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int opt = (int) (click.y() - menuY - 1) / 15;
|
int opt = (int) (mouseY - menuY - 1) / 15;
|
||||||
if (opt < options.size()){
|
if (opt < options.size()){
|
||||||
Option option = options.get(opt);
|
Option option = options.get(opt);
|
||||||
close();
|
close();
|
||||||
@@ -98,7 +96,7 @@ public class ContextMenuScreen extends Screen {
|
|||||||
public void render(DrawContext context, int mouseX, int mouseY, float deltaTicks) {
|
public void render(DrawContext context, int mouseX, int mouseY, float deltaTicks) {
|
||||||
super.render(context, mouseX, mouseY, deltaTicks);
|
super.render(context, mouseX, mouseY, deltaTicks);
|
||||||
parent.render(context, -67, -67, deltaTicks);
|
parent.render(context, -67, -67, deltaTicks);
|
||||||
context.drawStrokedRectangle(
|
context.drawBorder(
|
||||||
menuX,
|
menuX,
|
||||||
menuY,
|
menuY,
|
||||||
menuWidth,
|
menuWidth,
|
||||||
@@ -127,7 +125,6 @@ public class ContextMenuScreen extends Screen {
|
|||||||
y + 15,
|
y + 15,
|
||||||
0x30_ff_ff_ff
|
0x30_ff_ff_ff
|
||||||
);
|
);
|
||||||
context.setCursor(StandardCursors.POINTING_HAND);
|
|
||||||
}
|
}
|
||||||
context.drawText(textRenderer, option.title, menuX + 5, y + 3, option.highlighted ? 0xff_00_ff_ff : 0xff_ff_ff_ff, false);
|
context.drawText(textRenderer, option.title, menuX + 5, y + 3, option.highlighted ? 0xff_00_ff_ff : 0xff_ff_ff_ff, false);
|
||||||
y += 15;
|
y += 15;
|
||||||
|
|||||||
@@ -6,9 +6,7 @@ import de.shiewk.widgets.WidgetSettings;
|
|||||||
import de.shiewk.widgets.client.WidgetManager;
|
import de.shiewk.widgets.client.WidgetManager;
|
||||||
import de.shiewk.widgets.utils.WidgetUtils;
|
import de.shiewk.widgets.utils.WidgetUtils;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
import net.minecraft.client.gui.Click;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.cursor.StandardCursors;
|
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.tooltip.Tooltip;
|
import net.minecraft.client.gui.tooltip.Tooltip;
|
||||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
@@ -93,15 +91,11 @@ public class EditWidgetPositionsScreen extends AnimatedScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selectedWidget == null ? hoveredWidget == widget : selectedWidget == widget){
|
if (selectedWidget == null ? hoveredWidget == widget : selectedWidget == widget){
|
||||||
context.drawStrokedRectangle(wx-1,wy-1, ww+2, wh+2, SELECT_COLOR);
|
context.drawBorder(wx-1,wy-1, ww+2, wh+2, SELECT_COLOR);
|
||||||
context.drawStrokedRectangle(wx, wy, ww, wh, SELECT_COLOR);
|
context.drawBorder(wx, wy, ww, wh, SELECT_COLOR);
|
||||||
}
|
}
|
||||||
widget.render(context, mt, textRenderer, wx, wy);
|
widget.render(context, mt, textRenderer, wx, wy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hoveredWidget != null){
|
|
||||||
context.setCursor(StandardCursors.RESIZE_ALL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canAlign(int val1, int val2){
|
private boolean canAlign(int val1, int val2){
|
||||||
@@ -220,8 +214,8 @@ public class EditWidgetPositionsScreen extends AnimatedScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseReleased(Click click) {
|
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||||
if (click.button() == 0 && selectedWidget != null){
|
if (button == 0 && selectedWidget != null){
|
||||||
if (align){
|
if (align){
|
||||||
AlignResult alignedX = alignX(selectedWidget);
|
AlignResult alignedX = alignX(selectedWidget);
|
||||||
if (alignedX != null){
|
if (alignedX != null){
|
||||||
@@ -243,18 +237,18 @@ public class EditWidgetPositionsScreen extends AnimatedScreen {
|
|||||||
onEdit.accept(selectedWidget);
|
onEdit.accept(selectedWidget);
|
||||||
selectedWidget = null;
|
selectedWidget = null;
|
||||||
}
|
}
|
||||||
return super.mouseReleased(click);
|
return super.mouseReleased(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(Click click, boolean doubled) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
if (click.button() == 0 && hoveredWidget != null){
|
if (button == 0 && hoveredWidget != null){
|
||||||
selectedWidget = hoveredWidget;
|
selectedWidget = hoveredWidget;
|
||||||
focusedExtraX = (int) (click.x() - hoveredWidget.getX(scaledWindowWidth));
|
focusedExtraX = (int) (mouseX - hoveredWidget.getX(scaledWindowWidth));
|
||||||
focusedExtraY = (int) (click.y() - hoveredWidget.getY(scaledWindowHeight));
|
focusedExtraY = (int) (mouseY - hoveredWidget.getY(scaledWindowHeight));
|
||||||
} else if (click.button() == 1){
|
} else if (button == 1){
|
||||||
int x = (int) click.x();
|
int x = (int) mouseX;
|
||||||
int y = (int) click.y();
|
int y = (int) mouseY;
|
||||||
ModWidget hovered = hoveredWidget;
|
ModWidget hovered = hoveredWidget;
|
||||||
WidgetUtils.playSound(SoundEvents.BLOCK_COPPER_BULB_TURN_ON);
|
WidgetUtils.playSound(SoundEvents.BLOCK_COPPER_BULB_TURN_ON);
|
||||||
assert client != null;
|
assert client != null;
|
||||||
@@ -347,12 +341,12 @@ public class EditWidgetPositionsScreen extends AnimatedScreen {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.mouseClicked(click, doubled);
|
return super.mouseClicked(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseDragged(Click click, double deltaX, double deltaY) {
|
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
|
||||||
if (click.button() == 0){
|
if (button == 0){
|
||||||
assert client != null;
|
assert client != null;
|
||||||
final ModWidget widget = selectedWidget;
|
final ModWidget widget = selectedWidget;
|
||||||
if (widget != null){
|
if (widget != null){
|
||||||
@@ -361,14 +355,14 @@ public class EditWidgetPositionsScreen extends AnimatedScreen {
|
|||||||
int wx = MathHelper.clamp(widget.getX(scaledWindowWidth), 0, this.width - ww);
|
int wx = MathHelper.clamp(widget.getX(scaledWindowWidth), 0, this.width - ww);
|
||||||
final int wh = (int) (widget.height() * widget.getScaleFactor());
|
final int wh = (int) (widget.height() * widget.getScaleFactor());
|
||||||
int wy = MathHelper.clamp(widget.getY(scaledWindowHeight), 0, this.height - wh);
|
int wy = MathHelper.clamp(widget.getY(scaledWindowHeight), 0, this.height - wh);
|
||||||
if (click.x() <= wx + ww + deltaX && click.x() >= wx + deltaX){
|
if (mouseX <= wx + ww + deltaX && mouseX >= wx + deltaX){
|
||||||
if (click.y() <= wy + wh + deltaY && click.y() >= wy + deltaY){
|
if (mouseY <= wy + wh + deltaY && mouseY >= wy + deltaY){
|
||||||
Anchor anchor = Anchor.getAnchor(scaledWindowWidth, scaledWindowHeight, (int) click.x(), (int) click.y());
|
Anchor anchor = Anchor.getAnchor(scaledWindowWidth, scaledWindowHeight, (int) mouseX, (int) mouseY);
|
||||||
if (anchor == null) {
|
if (anchor == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int newOffX = (int) (click.x() - anchor.getAlignStartPosX(scaledWindowWidth)) - focusedExtraX;
|
int newOffX = (int) (mouseX - anchor.getAlignStartPosX(scaledWindowWidth)) - focusedExtraX;
|
||||||
int newOffY = (int) (click.y() - anchor.getAlignStartPosY(scaledWindowHeight)) - focusedExtraY;
|
int newOffY = (int) (mouseY - anchor.getAlignStartPosY(scaledWindowHeight)) - focusedExtraY;
|
||||||
|
|
||||||
settings.setPos(anchor, newOffX, newOffY);
|
settings.setPos(anchor, newOffX, newOffY);
|
||||||
|
|
||||||
@@ -395,7 +389,7 @@ public class EditWidgetPositionsScreen extends AnimatedScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.mouseDragged(click, deltaX, deltaY);
|
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package de.shiewk.widgets.client.screen;
|
|||||||
|
|
||||||
import de.shiewk.widgets.ModWidget;
|
import de.shiewk.widgets.ModWidget;
|
||||||
import de.shiewk.widgets.client.screen.components.WidgetSettingsEditWidget;
|
import de.shiewk.widgets.client.screen.components.WidgetSettingsEditWidget;
|
||||||
import net.minecraft.client.gui.Click;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.Element;
|
import net.minecraft.client.gui.Element;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
@@ -38,13 +37,13 @@ public class WidgetSettingsScreen extends AnimatedScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseReleased(Click click) {
|
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||||
for (Element child : children()) {
|
for (Element child : children()) {
|
||||||
if (child instanceof ClickableWidget s){
|
if (child instanceof ClickableWidget s){
|
||||||
s.mouseReleased(click);
|
s.mouseReleased(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.mouseReleased(click);
|
return super.mouseReleased(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package de.shiewk.widgets.client.screen.components;
|
package de.shiewk.widgets.client.screen.components;
|
||||||
|
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.Click;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
||||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||||
@@ -36,7 +35,7 @@ public class ScaledTextWidget extends ClickableWidget {
|
|||||||
protected void appendClickableNarrations(NarrationMessageBuilder builder) {}
|
protected void appendClickableNarrations(NarrationMessageBuilder builder) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(Click click, boolean doubled) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import de.shiewk.widgets.ModWidget;
|
|||||||
import de.shiewk.widgets.client.WidgetManager;
|
import de.shiewk.widgets.client.WidgetManager;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.Click;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.Element;
|
import net.minecraft.client.gui.Element;
|
||||||
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
||||||
@@ -101,18 +100,15 @@ public class WidgetListWidget extends ScrollableWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(Click click, boolean doubled) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
double mouseY = click.y();
|
|
||||||
double mouseX = click.x();
|
|
||||||
mouseY += getScrollY();
|
mouseY += getScrollY();
|
||||||
Click newClick = new Click(mouseX, mouseY, click.buttonInfo());
|
|
||||||
for (Element element : elements) {
|
for (Element element : elements) {
|
||||||
if (element.mouseClicked(newClick, doubled)){
|
if (element.mouseClicked(mouseX, mouseY, button)){
|
||||||
client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.checkScrollbarDragged(newClick);
|
return super.checkScrollbarDragged(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+15
-20
@@ -3,12 +3,9 @@ package de.shiewk.widgets.client.screen.components;
|
|||||||
import de.shiewk.widgets.ModWidget;
|
import de.shiewk.widgets.ModWidget;
|
||||||
import de.shiewk.widgets.WidgetSettingOption;
|
import de.shiewk.widgets.WidgetSettingOption;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.Click;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
||||||
import net.minecraft.client.gui.widget.ScrollableWidget;
|
import net.minecraft.client.gui.widget.ScrollableWidget;
|
||||||
import net.minecraft.client.input.CharInput;
|
|
||||||
import net.minecraft.client.input.KeyInput;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.joml.Matrix3x2fStack;
|
import org.joml.Matrix3x2fStack;
|
||||||
|
|
||||||
@@ -84,16 +81,14 @@ public class WidgetSettingsEditWidget extends ScrollableWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(Click click, boolean doubled) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
double mouseY = click.y();
|
|
||||||
double mouseX = click.x();
|
|
||||||
mouseY += getScrollY();
|
mouseY += getScrollY();
|
||||||
for (WidgetSettingOption customSetting : widget.getSettings().getCustomSettings()) {
|
for (WidgetSettingOption customSetting : widget.getSettings().getCustomSettings()) {
|
||||||
if (!customSetting.shouldShow()) continue;
|
if (!customSetting.shouldShow()) continue;
|
||||||
if (customSetting.isHovered(mouseX, mouseY)){
|
if (customSetting.isHovered(mouseX, mouseY)){
|
||||||
focus = customSetting;
|
focus = customSetting;
|
||||||
customSetting.setFocused(true);
|
customSetting.setFocused(true);
|
||||||
if (customSetting.mouseClicked(new Click(mouseX, mouseY + getScrollY(), click.buttonInfo()), doubled)){
|
if (customSetting.mouseClicked(mouseX, mouseY + getScrollY(), button)){
|
||||||
onChange.run();
|
onChange.run();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -101,52 +96,52 @@ public class WidgetSettingsEditWidget extends ScrollableWidget {
|
|||||||
customSetting.setFocused(false);
|
customSetting.setFocused(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return checkScrollbarDragged(click);
|
return checkScrollbarDragged(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseReleased(Click click) {
|
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||||
for (WidgetSettingOption customSetting : widget.getSettings().getCustomSettings()) {
|
for (WidgetSettingOption customSetting : widget.getSettings().getCustomSettings()) {
|
||||||
if (!customSetting.shouldShow()) continue;
|
if (!customSetting.shouldShow()) continue;
|
||||||
if (customSetting.mouseReleased(new Click(click.x(), click.y() + getScrollY(), click.buttonInfo()))){
|
if (customSetting.mouseReleased(mouseX, mouseY + getScrollY())){
|
||||||
onChange.run();
|
onChange.run();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.mouseReleased(click);
|
return super.mouseReleased(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean charTyped(CharInput input) {
|
public boolean charTyped(char chr, int modifiers) {
|
||||||
if (this.focus != null){
|
if (this.focus != null){
|
||||||
if (this.focus.charTyped(input)){
|
if (this.focus.charTyped(chr, modifiers)){
|
||||||
onChange.run();
|
onChange.run();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.charTyped(input);
|
return super.charTyped(chr, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(KeyInput input) {
|
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||||
if (this.focus != null){
|
if (this.focus != null){
|
||||||
if (this.focus.keyPressed(input)){
|
if (this.focus.keyPressed(keyCode, scanCode, modifiers)){
|
||||||
onChange.run();
|
onChange.run();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.keyPressed(input);
|
return super.keyPressed(keyCode, scanCode, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyReleased(KeyInput input) {
|
public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
|
||||||
if (this.focus != null){
|
if (this.focus != null){
|
||||||
if (this.focus.keyReleased(input)){
|
if (this.focus.keyReleased(keyCode, scanCode, modifiers)){
|
||||||
onChange.run();
|
onChange.run();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.keyReleased(input);
|
return super.keyReleased(keyCode, scanCode, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import de.shiewk.widgets.client.screen.WidgetSettingsScreen;
|
|||||||
import de.shiewk.widgets.utils.WidgetUtils;
|
import de.shiewk.widgets.utils.WidgetUtils;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.Click;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.cursor.StandardCursors;
|
|
||||||
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
||||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||||
import net.minecraft.text.OrderedText;
|
import net.minecraft.text.OrderedText;
|
||||||
@@ -69,10 +67,6 @@ public class WidgetWidget extends ClickableWidget {
|
|||||||
}
|
}
|
||||||
this.renderToggleButton(context, mouseX, mouseY, widgetEnabled);
|
this.renderToggleButton(context, mouseX, mouseY, widgetEnabled);
|
||||||
|
|
||||||
if (hover || isMouseOverToggle(mouseX, mouseY)){
|
|
||||||
context.setCursor(StandardCursors.POINTING_HAND);
|
|
||||||
}
|
|
||||||
|
|
||||||
context.drawHorizontalLine(getX(), getX() + getWidth() - 1, getY(), COLOR_BORDER);
|
context.drawHorizontalLine(getX(), getX() + getWidth() - 1, getY(), COLOR_BORDER);
|
||||||
context.drawHorizontalLine(getX() + 1, getX() + getWidth() - 1, getY() + getHeight() - 1, COLOR_BORDER);
|
context.drawHorizontalLine(getX() + 1, getX() + getWidth() - 1, getY() + getHeight() - 1, COLOR_BORDER);
|
||||||
context.drawVerticalLine(getX(), getY(), getY() + getHeight(), COLOR_BORDER);
|
context.drawVerticalLine(getX(), getY(), getY() + getHeight(), COLOR_BORDER);
|
||||||
@@ -80,11 +74,11 @@ public class WidgetWidget extends ClickableWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(Click click, boolean doubled) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
if (isMouseOver(click.x(), click.y())){
|
if (isMouseOver(mouseX, mouseY)){
|
||||||
client.setScreen(new WidgetSettingsScreen(client.currentScreen, widget, onEdit));
|
client.setScreen(new WidgetSettingsScreen(client.currentScreen, widget, onEdit));
|
||||||
return true;
|
return true;
|
||||||
} else if (isMouseOverToggle(click.x(), click.y())){
|
} else if (isMouseOverToggle(mouseX, mouseY)){
|
||||||
this.toggleWidget();
|
this.toggleWidget();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package de.shiewk.widgets.mixin;
|
|||||||
|
|
||||||
import de.shiewk.widgets.widgets.CPSWidget;
|
import de.shiewk.widgets.widgets.CPSWidget;
|
||||||
import net.minecraft.client.Mouse;
|
import net.minecraft.client.Mouse;
|
||||||
import net.minecraft.client.input.MouseInput;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -11,18 +11,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
@Mixin(Mouse.class)
|
@Mixin(Mouse.class)
|
||||||
public class MixinMouse {
|
public class MixinMouse {
|
||||||
|
|
||||||
@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/Mouse;leftButtonClicked:Z"), method = "onMouseButton")
|
@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/Mouse;leftButtonClicked:Z", opcode = Opcodes.PUTFIELD), method = "onMouseButton")
|
||||||
public void onLeftClick(long window, MouseInput input, int action, CallbackInfo ci){
|
public void onLeftClick(long window, int button, int action, int mods, CallbackInfo ci){
|
||||||
if (action == 1) CPSWidget.clickLeft();
|
if (action == 1) CPSWidget.clickLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/Mouse;middleButtonClicked:Z"), method = "onMouseButton")
|
@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/Mouse;middleButtonClicked:Z", opcode = Opcodes.PUTFIELD), method = "onMouseButton")
|
||||||
public void onMiddleClick(long window, MouseInput input, int action, CallbackInfo ci){
|
public void onMiddleClick(long window, int button, int action, int mods, CallbackInfo ci){
|
||||||
if (action == 1) CPSWidget.clickMiddle();
|
if (action == 1) CPSWidget.clickMiddle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/Mouse;rightButtonClicked:Z"), method = "onMouseButton")
|
@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/Mouse;rightButtonClicked:Z", opcode = Opcodes.PUTFIELD), method = "onMouseButton")
|
||||||
public void onRightClick(long window, MouseInput input, int action, CallbackInfo ci){
|
public void onRightClick(long window, int button, int action, int mods, CallbackInfo ci){
|
||||||
if (action == 1) CPSWidget.clickRight();
|
if (action == 1) CPSWidget.clickRight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class SpeedWidget extends BasicTextWidget {
|
|||||||
ClientPlayerEntity player = MinecraftClient.getInstance().player;
|
ClientPlayerEntity player = MinecraftClient.getInstance().player;
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
Vec3d lastPos = this.lastPos;
|
Vec3d lastPos = this.lastPos;
|
||||||
Vec3d newPos = this.lastPos = player.getEntityPos();
|
Vec3d newPos = this.lastPos = player.getPos();
|
||||||
Vec3d velocity = lastPos.subtract(newPos);
|
Vec3d velocity = lastPos.subtract(newPos);
|
||||||
double rt = 0;
|
double rt = 0;
|
||||||
if (withXVelocity) rt += velocity.getX() * velocity.getX();
|
if (withXVelocity) rt += velocity.getX() * velocity.getX();
|
||||||
|
|||||||
@@ -6,9 +6,7 @@ import de.shiewk.widgets.WidgetSettingOption;
|
|||||||
import de.shiewk.widgets.utils.WidgetUtils;
|
import de.shiewk.widgets.utils.WidgetUtils;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.Click;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.cursor.StandardCursors;
|
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
@@ -78,9 +76,6 @@ public class EnumWidgetSetting<T extends Enum<T>> extends WidgetSettingOption {
|
|||||||
this.changed = true;
|
this.changed = true;
|
||||||
WidgetUtils.playSound(SoundEvents.BLOCK_COPPER_BULB_TURN_ON);
|
WidgetUtils.playSound(SoundEvents.BLOCK_COPPER_BULB_TURN_ON);
|
||||||
}
|
}
|
||||||
if (hover){
|
|
||||||
context.setCursor(StandardCursors.POINTING_HAND);
|
|
||||||
}
|
|
||||||
nx += textRendererWidth + 20;
|
nx += textRendererWidth + 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,13 +84,13 @@ public class EnumWidgetSetting<T extends Enum<T>> extends WidgetSettingOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(Click click, boolean doubled) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
mouseClick = true;
|
mouseClick = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseReleased(Click click) {
|
public boolean mouseReleased(double mouseX, double mouseY) {
|
||||||
mouseClick = false;
|
mouseClick = false;
|
||||||
boolean changed = this.changed;
|
boolean changed = this.changed;
|
||||||
this.changed = false;
|
this.changed = false;
|
||||||
|
|||||||
@@ -5,12 +5,10 @@ import com.google.gson.JsonPrimitive;
|
|||||||
import de.shiewk.widgets.WidgetSettingOption;
|
import de.shiewk.widgets.WidgetSettingOption;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.Click;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.cursor.StandardCursors;
|
|
||||||
import net.minecraft.client.input.KeyInput;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
public class IntSliderWidgetSetting extends WidgetSettingOption {
|
public class IntSliderWidgetSetting extends WidgetSettingOption {
|
||||||
|
|
||||||
@@ -28,11 +26,11 @@ public class IntSliderWidgetSetting extends WidgetSettingOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(KeyInput input) {
|
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||||
if (maxValue > value && input.isRight()) {
|
if (maxValue > value && keyCode == GLFW.GLFW_KEY_RIGHT) {
|
||||||
value++;
|
value++;
|
||||||
return true;
|
return true;
|
||||||
} else if (minValue < value && input.isLeft()){
|
} else if (minValue < value && keyCode == GLFW.GLFW_KEY_LEFT){
|
||||||
value--;
|
value--;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -72,9 +70,6 @@ public class IntSliderWidgetSetting extends WidgetSettingOption {
|
|||||||
this.changed = true;
|
this.changed = true;
|
||||||
this.value = MathHelper.clamp(xPosToValue(mouseX), minValue, maxValue);
|
this.value = MathHelper.clamp(xPosToValue(mouseX), minValue, maxValue);
|
||||||
}
|
}
|
||||||
if (isHovering(mouseX, mouseY)){
|
|
||||||
context.setCursor(StandardCursors.RESIZE_EW);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isHovering(int mouseX, int mouseY) {
|
private boolean isHovering(int mouseX, int mouseY) {
|
||||||
@@ -85,13 +80,13 @@ public class IntSliderWidgetSetting extends WidgetSettingOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(Click click, boolean doubled) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
this.clicked = true;
|
this.clicked = true;
|
||||||
return super.mouseClicked(click, doubled);
|
return super.mouseClicked(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseReleased(Click click) {
|
public boolean mouseReleased(double mouseX, double mouseY) {
|
||||||
this.clicked = false;
|
this.clicked = false;
|
||||||
boolean t = this.changed;
|
boolean t = this.changed;
|
||||||
this.changed = false;
|
this.changed = false;
|
||||||
|
|||||||
@@ -6,16 +6,14 @@ import de.shiewk.widgets.WidgetSettingOption;
|
|||||||
import de.shiewk.widgets.utils.WidgetUtils;
|
import de.shiewk.widgets.utils.WidgetUtils;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.Click;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.cursor.StandardCursors;
|
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
||||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||||
import net.minecraft.client.input.KeyInput;
|
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
@@ -88,10 +86,6 @@ public class RGBAColorWidgetSetting extends WidgetSettingOption {
|
|||||||
0xff_ff_ff_ff,
|
0xff_ff_ff_ff,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.isHovered(mouseX, mouseY)){
|
|
||||||
context.setCursor(StandardCursors.POINTING_HAND);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toHexSingle(int comp){
|
private String toHexSingle(int comp){
|
||||||
@@ -104,7 +98,7 @@ public class RGBAColorWidgetSetting extends WidgetSettingOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(Click click, boolean doubled) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
MinecraftClient client = MinecraftClient.getInstance();
|
MinecraftClient client = MinecraftClient.getInstance();
|
||||||
WidgetUtils.playSound(SoundEvents.BLOCK_COPPER_BULB_TURN_ON);
|
WidgetUtils.playSound(SoundEvents.BLOCK_COPPER_BULB_TURN_ON);
|
||||||
client.setScreen(
|
client.setScreen(
|
||||||
@@ -181,7 +175,7 @@ public class RGBAColorWidgetSetting extends WidgetSettingOption {
|
|||||||
public void render(DrawContext context, int mouseX, int mouseY, float deltaTicks) {
|
public void render(DrawContext context, int mouseX, int mouseY, float deltaTicks) {
|
||||||
parent.render(context, 0, 0, deltaTicks);
|
parent.render(context, 0, 0, deltaTicks);
|
||||||
context.fill(x, y, x+ RECT_WIDTH, y+ RECT_HEIGHT,0xc0_00_00_00);
|
context.fill(x, y, x+ RECT_WIDTH, y+ RECT_HEIGHT,0xc0_00_00_00);
|
||||||
context.drawStrokedRectangle(x, y, RECT_WIDTH, RECT_HEIGHT, 0x67_ff_ff_ff);
|
context.drawBorder(x, y, RECT_WIDTH, RECT_HEIGHT, 0x67_ff_ff_ff);
|
||||||
super.render(context, mouseX, mouseY, deltaTicks);
|
super.render(context, mouseX, mouseY, deltaTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,13 +185,13 @@ public class RGBAColorWidgetSetting extends WidgetSettingOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(Click click, boolean doubled) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
if (click.x() < x || click.y() < y || click.x() > x + RECT_WIDTH || click.y() > y + RECT_HEIGHT){
|
if (mouseX < x || mouseY < y || mouseX > x + RECT_WIDTH || mouseY > y + RECT_HEIGHT){
|
||||||
close();
|
close();
|
||||||
WidgetUtils.playSound(SoundEvents.BLOCK_COPPER_BULB_TURN_OFF);
|
WidgetUtils.playSound(SoundEvents.BLOCK_COPPER_BULB_TURN_OFF);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return super.mouseClicked(click, doubled);
|
return super.mouseClicked(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ColorBar extends ClickableWidget {
|
public class ColorBar extends ClickableWidget {
|
||||||
@@ -265,9 +259,6 @@ public class RGBAColorWidgetSetting extends WidgetSettingOption {
|
|||||||
int textWidth = textRenderer.getWidth(text);
|
int textWidth = textRenderer.getWidth(text);
|
||||||
context.drawText(textRenderer, text, getX() + (getWidth() / 2 - textWidth / 2), getY() + 142, 0xffffffff, true);
|
context.drawText(textRenderer, text, getX() + (getWidth() / 2 - textWidth / 2), getY() + 142, 0xffffffff, true);
|
||||||
}
|
}
|
||||||
if (isHovered()){
|
|
||||||
context.setCursor(StandardCursors.RESIZE_NS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String componentLabel() {
|
private String componentLabel() {
|
||||||
@@ -281,14 +272,14 @@ public class RGBAColorWidgetSetting extends WidgetSettingOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(Click click, boolean doubled) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
return this.mouseDragged(click, 0, 0);
|
return this.mouseDragged(mouseX, mouseY, button, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseDragged(Click click, double offsetX, double offsetY) {
|
public boolean mouseDragged(double mouseX, double mouseY, int button, double offsetX, double offsetY) {
|
||||||
if (isHovered()){
|
if (isHovered()){
|
||||||
double pos = click.y() - this.getY() - 10;
|
double pos = mouseY - this.getY() - 10;
|
||||||
int val = (int) (255 - pos * 2);
|
int val = (int) (255 - pos * 2);
|
||||||
setValue(val);
|
setValue(val);
|
||||||
return true;
|
return true;
|
||||||
@@ -307,15 +298,15 @@ public class RGBAColorWidgetSetting extends WidgetSettingOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(KeyInput input) {
|
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||||
if (input.isUp()) {
|
if (keyCode == GLFW.GLFW_KEY_UP) {
|
||||||
setValue(getValue() + 1);
|
setValue(getValue() + 1);
|
||||||
return true;
|
return true;
|
||||||
} else if (input.isDown()) {
|
} else if (keyCode == GLFW.GLFW_KEY_DOWN) {
|
||||||
setValue(getValue() - 1);
|
setValue(getValue() - 1);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return super.keyPressed(input);
|
return super.keyPressed(keyCode, scanCode, modifiers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-13
@@ -6,11 +6,8 @@ import de.shiewk.widgets.WidgetSettingOption;
|
|||||||
import de.shiewk.widgets.WidgetsMod;
|
import de.shiewk.widgets.WidgetsMod;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.Click;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||||
import net.minecraft.client.input.CharInput;
|
|
||||||
import net.minecraft.client.input.KeyInput;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
public class TextFieldWidgetSettingOption extends WidgetSettingOption {
|
public class TextFieldWidgetSettingOption extends WidgetSettingOption {
|
||||||
@@ -95,28 +92,28 @@ public class TextFieldWidgetSettingOption extends WidgetSettingOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(Click click, boolean doubled) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
return isFocused() && textField.mouseClicked(click, doubled);
|
return isFocused() && textField.mouseClicked(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseReleased(Click click) {
|
public boolean mouseReleased(double mouseX, double mouseY) {
|
||||||
return isFocused() && textField.mouseReleased(click);
|
return isFocused() && textField.mouseReleased(mouseX, mouseY, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean charTyped(CharInput input) {
|
public boolean charTyped(char chr, int modifiers) {
|
||||||
return isFocused() && textField.charTyped(input);
|
return isFocused() && textField.charTyped(chr, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(KeyInput input) {
|
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||||
return isFocused() && textField.keyPressed(input);
|
return isFocused() && textField.keyPressed(keyCode, scanCode, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyReleased(KeyInput input) {
|
public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
|
||||||
return isFocused() && textField.keyReleased(input);
|
return isFocused() && textField.keyReleased(keyCode, scanCode, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import com.google.gson.JsonElement;
|
|||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
import de.shiewk.widgets.WidgetSettingOption;
|
import de.shiewk.widgets.WidgetSettingOption;
|
||||||
import de.shiewk.widgets.utils.WidgetUtils;
|
import de.shiewk.widgets.utils.WidgetUtils;
|
||||||
import net.minecraft.client.gui.Click;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.cursor.StandardCursors;
|
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Util;
|
import net.minecraft.util.Util;
|
||||||
@@ -56,14 +54,9 @@ public class ToggleWidgetSetting extends WidgetSettingOption {
|
|||||||
: value ? getX() + getWidth() - 4 - 12 : getX() + 4;
|
: value ? getX() + getWidth() - 4 - 12 : getX() + 4;
|
||||||
context.fill(getX() + 2, getY() + 2, getX() + getWidth() - 2, getY() + getHeight() - 2, col);
|
context.fill(getX() + 2, getY() + 2, getX() + getWidth() - 2, getY() + getHeight() - 2, col);
|
||||||
context.fill(thumbLoc, getY() + 4, thumbLoc + 12, getY() + getHeight() - 4, thumb);
|
context.fill(thumbLoc, getY() + 4, thumbLoc + 12, getY() + getHeight() - 4, thumb);
|
||||||
|
|
||||||
if (this.isHovered(mouseX, mouseY)){
|
|
||||||
context.setCursor(StandardCursors.POINTING_HAND);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
public boolean mouseClicked(Click click, boolean doubled) {
|
|
||||||
toggle();
|
toggle();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user