Compare commits
2 Commits
d2ef12f718
...
8e30d8c2ee
Author | SHA1 | Date | |
---|---|---|---|
8e30d8c2ee | |||
8369034f10 |
@ -2,13 +2,13 @@
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.19.3
|
||||
yarn_mappings=1.19.3+build.5
|
||||
loader_version=0.14.13
|
||||
minecraft_version=1.19.4
|
||||
yarn_mappings=1.19.4+build.1
|
||||
loader_version=0.14.17
|
||||
# Mod Properties
|
||||
mod_version=1.0.1
|
||||
mod_version=1.1.0
|
||||
maven_group=cmods
|
||||
archives_base_name=cmods
|
||||
# Dependencies
|
||||
# check this on https://modmuss50.me/fabric.html
|
||||
fabric_version=0.73.0+1.19.3
|
||||
fabric_version=0.75.3+1.19.4
|
||||
|
@ -49,9 +49,9 @@ public class CmodsOptionsScreen extends Screen {
|
||||
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> client.setScreen(parent))
|
||||
.width(doneButtonWidth).build(), 2, adder.copyPositioner().marginTop(doneButtonRowIncrement));
|
||||
|
||||
grid.recalculateDimensions();
|
||||
grid.refreshPositions();
|
||||
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
|
||||
addDrawableChild(grid);
|
||||
grid.forEachChild(this::addDrawableChild);
|
||||
}
|
||||
|
||||
public static void addExtraButtons(ArrayList<ButtonBuilder> buttons, int precedence) {
|
||||
@ -72,7 +72,7 @@ public class CmodsOptionsScreen extends Screen {
|
||||
Text versionText = Text.literal("v" + CmodsClient.version);
|
||||
|
||||
|
||||
drawCenteredText(matrices, textRenderer, title, this.width / 2, 15, 0xffffff);
|
||||
drawCenteredTextWithShadow(matrices, textRenderer, title, this.width / 2, 15, 0xffffff);
|
||||
drawTextWithShadow(matrices, textRenderer, versionText, this.width - textRenderer.getWidth(versionText) - 2,
|
||||
this.height - textRenderer.fontHeight - 2, 0xffffff);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
|
@ -2,16 +2,17 @@ package cmods.cmods.client.ui;
|
||||
|
||||
import cmods.cmods.client.options.IntegerOption;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.WrapperWidget;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class IntegerAdjustWidget extends WrapperWidget {
|
||||
private final ArrayList<ButtonWidget> children;
|
||||
private final ArrayList<ButtonWidget> elements;
|
||||
private final IntegerOption option;
|
||||
private final Text text;
|
||||
private final int delta;
|
||||
|
||||
public IntegerAdjustWidget(Text text, IntegerOption option) {
|
||||
@ -19,25 +20,15 @@ public class IntegerAdjustWidget extends WrapperWidget {
|
||||
}
|
||||
|
||||
public IntegerAdjustWidget(Text text, IntegerOption option, int delta) {
|
||||
super(0, 0, 150, 20, text);
|
||||
super(0, 0, 150, 20);
|
||||
this.text = text;
|
||||
this.option = option;
|
||||
this.delta = delta;
|
||||
children = new ArrayList<>(3);
|
||||
elements = new ArrayList<>(3);
|
||||
|
||||
refreshDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends ClickableWidget> wrappedWidgets() {
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWidth(int width) {
|
||||
super.setWidth(width);
|
||||
refreshDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setX(int x) {
|
||||
super.setX(x);
|
||||
@ -50,17 +41,11 @@ public class IntegerAdjustWidget extends WrapperWidget {
|
||||
refreshDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPos(int x, int y) {
|
||||
super.setPos(x, y);
|
||||
refreshDimensions();
|
||||
}
|
||||
|
||||
private void refreshDimensions() {
|
||||
final int button_width = 25;
|
||||
final String labelStr = getMessage().getString() + ": ";
|
||||
final String labelStr = text.getString() + ": ";
|
||||
|
||||
children.clear();
|
||||
elements.clear();
|
||||
|
||||
ButtonWidget middle = ButtonWidget.builder(Text.literal(labelStr + option.get()), button -> {})
|
||||
.dimensions(getX() + button_width - 1, getY(),width - (button_width * 2) + 2, height).build();
|
||||
@ -73,8 +58,15 @@ public class IntegerAdjustWidget extends WrapperWidget {
|
||||
button -> middle.setMessage(Text.literal(labelStr + option.inc(delta))))
|
||||
.dimensions(getX() + width - button_width + 1, getY(), button_width, height).build();
|
||||
|
||||
children.add(sub);
|
||||
children.add(middle);
|
||||
children.add(add);
|
||||
elements.add(sub);
|
||||
elements.add(middle);
|
||||
elements.add(add);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachElement(Consumer<Widget> consumer) {
|
||||
for (Widget element: elements) {
|
||||
consumer.accept(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,9 +51,9 @@ public class UIOptionsScreen extends Screen {
|
||||
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> client.setScreen(parent))
|
||||
.width(doneButtonWidth).build(), 2, adder.copyPositioner().marginTop(doneButtonRowIncrement));
|
||||
|
||||
grid.recalculateDimensions();
|
||||
grid.refreshPositions();
|
||||
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
|
||||
addDrawableChild(grid);
|
||||
grid.forEachChild(this::addDrawableChild);
|
||||
}
|
||||
|
||||
public static void addButtons(ArrayList<ButtonBuilder> buttons, int precedence) {
|
||||
@ -71,7 +71,7 @@ public class UIOptionsScreen extends Screen {
|
||||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
this.renderBackground(matrices);
|
||||
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 0xffffff);
|
||||
drawCenteredTextWithShadow(matrices, this.textRenderer, this.title, this.width / 2, 15, 0xffffff);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@
|
||||
"cmods.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.11",
|
||||
"fabricloader": ">=0.14.10",
|
||||
"fabric": "*",
|
||||
"minecraft": "1.19.3"
|
||||
"minecraft": "1.19.4"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user