mirror of
https://github.com/Shiewk/Widgets.git
synced 2026-04-28 11:34:17 +02:00
1.21.5 support
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.8.11'
|
||||
id 'fabric-loom' version '1.10.1'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ dependencies {
|
||||
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
modImplementation "maven.modrinth:modmenu:12.0.0"
|
||||
modImplementation "maven.modrinth:modmenu:14.0.0-rc.2"
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
||||
+5
-5
@@ -2,13 +2,13 @@
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.21.3
|
||||
yarn_mappings=1.21.3+build.2
|
||||
loader_version=0.16.8
|
||||
minecraft_version=1.21.5
|
||||
yarn_mappings=1.21.5+build.1
|
||||
loader_version=0.16.12
|
||||
# Mod Properties
|
||||
mod_version=1.5.0
|
||||
mod_version=1.5.1
|
||||
maven_group=de.shiewk
|
||||
archives_base_name=Widgets
|
||||
# Dependencies
|
||||
# check this on https://modmuss50.me/fabric.html
|
||||
fabric_version=0.106.1+1.21.3
|
||||
fabric_version=0.119.5+1.21.5
|
||||
|
||||
@@ -10,6 +10,9 @@ import net.minecraft.client.gui.screen.narration.NarrationPart;
|
||||
import net.minecraft.client.gui.widget.GridWidget;
|
||||
import net.minecraft.client.gui.widget.ScrollableWidget;
|
||||
import net.minecraft.client.gui.widget.SimplePositioningWidget;
|
||||
import net.minecraft.client.sound.PositionedSoundInstance;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -42,7 +45,7 @@ public class WidgetListWidget extends ScrollableWidget {
|
||||
adder.add(new WidgetWidget(0, 0, 200, 100, client, widget, textRenderer, onEdit));
|
||||
}
|
||||
gw.refreshPositions();
|
||||
SimplePositioningWidget.setPos(gw, 0, 0, this.width, this.getContentsHeight(), 0.5F, 0.5F);
|
||||
SimplePositioningWidget.setPos(gw, 0, 0, this.width, this.getContentsHeightWithPadding(), 0.5F, 0.5F);
|
||||
gw.forEachChild(w -> this.addWidget((WidgetWidget) w));
|
||||
}
|
||||
|
||||
@@ -51,7 +54,7 @@ public class WidgetListWidget extends ScrollableWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentsHeight() {
|
||||
protected int getContentsHeightWithPadding() {
|
||||
final int rowSize = this.width / 208;
|
||||
final int rows = widgets.size() % rowSize == 0 ? widgets.size() / rowSize : widgets.size() / rowSize + 1;
|
||||
return 10 + (rows * 108);
|
||||
@@ -63,10 +66,14 @@ public class WidgetListWidget extends ScrollableWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderContents(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
MatrixStack matrices = context.getMatrices();
|
||||
matrices.push();
|
||||
matrices.translate(0, -getScrollY(), 0);
|
||||
for (WidgetWidget element : elements) {
|
||||
element.render(context, mouseX, (int) (mouseY + getScrollY()), delta);
|
||||
}
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,10 +81,12 @@ public class WidgetListWidget extends ScrollableWidget {
|
||||
mouseY += getScrollY();
|
||||
for (Element element : elements) {
|
||||
if (element.mouseClicked(mouseX, mouseY, 0)){
|
||||
client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if (super.checkScrollbarDragged(mouseX, mouseY - getScrollY(), button)) return true;
|
||||
return super.mouseClicked(mouseX, mouseY - getScrollY(), button);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,7 +95,4 @@ public class WidgetListWidget extends ScrollableWidget {
|
||||
builder.put(NarrationPart.HINT, widget.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBox(DrawContext context, int x, int y, int width, int height) {}
|
||||
}
|
||||
|
||||
+13
-10
@@ -6,6 +6,7 @@ import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
||||
import net.minecraft.client.gui.widget.ScrollableWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -37,7 +38,7 @@ public class WidgetSettingsEditWidget extends ScrollableWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentsHeight() {
|
||||
protected int getContentsHeightWithPadding() {
|
||||
return this.contentsHeight;
|
||||
}
|
||||
|
||||
@@ -47,11 +48,16 @@ public class WidgetSettingsEditWidget extends ScrollableWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderContents(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
context.getMatrices().push();
|
||||
context.getMatrices().scale(2, 2, 2);
|
||||
protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
context.fill(getX(), getY(), getX()+width, getY()+height, COLOR_BG);
|
||||
MatrixStack matrices = context.getMatrices();
|
||||
matrices.push();
|
||||
matrices.translate(0, -getScrollY(), 0);
|
||||
matrices.push();
|
||||
matrices.scale(2, 2, 2);
|
||||
matrices.translate(0, -getScrollY(), 0);
|
||||
context.drawText(textRenderer, widget.getName(), this.width / 4 - textRenderer.getWidth(widget.getName()) / 2, this.height / 100, COLOR_FG, true);
|
||||
context.getMatrices().pop();
|
||||
matrices.pop();
|
||||
int y = textRenderer.fontHeight * 2 + this.height / 50 + 5;
|
||||
for (WidgetSettingOption setting : widget.getSettings().getCustomSettings()) {
|
||||
if (!setting.shouldShow()) continue;
|
||||
@@ -70,6 +76,7 @@ public class WidgetSettingsEditWidget extends ScrollableWidget {
|
||||
y += 5;
|
||||
}
|
||||
this.contentsHeight = y;
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,6 +95,7 @@ public class WidgetSettingsEditWidget extends ScrollableWidget {
|
||||
customSetting.setFocused(false);
|
||||
}
|
||||
}
|
||||
if (checkScrollbarDragged(mouseX, mouseY - getScrollY(), button)) return true;
|
||||
return super.mouseClicked(mouseX, mouseY - getScrollY(), button);
|
||||
}
|
||||
|
||||
@@ -139,9 +147,4 @@ public class WidgetSettingsEditWidget extends ScrollableWidget {
|
||||
protected void appendClickableNarrations(NarrationMessageBuilder builder) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBox(DrawContext context, int x, int y, int width, int height) {
|
||||
context.fill(x, y, x+width, y+height, COLOR_BG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,20 +63,19 @@ public class WidgetWidget extends ClickableWidget {
|
||||
OrderedText t = it.next();
|
||||
context.drawText(textRenderer, t, getX() + 5 + ((getWidth() - 5) / 2) - (textRenderer.getWidth(t) / 2), y, COLOR_FG, false);
|
||||
}
|
||||
this.renderToggleButton(context, mouseX, mouseY, delta, widgetEnabled);
|
||||
this.renderToggleButton(context, mouseX, mouseY, widgetEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean clicked(double mouseX, double mouseY) {
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (isMouseOver(mouseX, mouseY)){
|
||||
client.setScreen(new WidgetSettingsScreen(client.currentScreen, widget));
|
||||
return true;
|
||||
} else if (isMouseOverToggle(mouseX, mouseY)){
|
||||
this.toggleWidget();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void toggleWidget() {
|
||||
@@ -85,7 +84,7 @@ public class WidgetWidget extends ClickableWidget {
|
||||
onEdit.accept(widget);
|
||||
}
|
||||
|
||||
private void renderToggleButton(DrawContext context, int mouseX, int mouseY, float delta, boolean widgetEnabled){
|
||||
private void renderToggleButton(DrawContext context, int mouseX, int mouseY, boolean widgetEnabled){
|
||||
boolean hoverToggle = this.isMouseOverToggle(mouseX, mouseY);
|
||||
final int toggleColor;
|
||||
final int toggleColorInvert;
|
||||
|
||||
Reference in New Issue
Block a user