WIP Continued modifier settings gui overhaul
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package nl.requios.effortlessbuilding;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.UIRenderHelper;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
|
||||
public enum AllGuiTextures implements ScreenElement {
|
||||
ARRAY_ENTRY("modifiers", 256, 60),
|
||||
MIRROR_ENTRY("modifiers", 0, 60, 256, 60),
|
||||
RADIAL_MIRROR_ENTRY("modifiers", 0, 120, 256, 60),
|
||||
;
|
||||
public final ResourceLocation location;
|
||||
public int width, height;
|
||||
public int startX, startY;
|
||||
private AllGuiTextures(String location, int width, int height) {
|
||||
this(location, 0, 0, width, height);
|
||||
}
|
||||
|
||||
private AllGuiTextures(int startX, int startY) {
|
||||
this("icons", startX * 16, startY * 16, 16, 16);
|
||||
}
|
||||
|
||||
private AllGuiTextures(String location, int startX, int startY, int width, int height) {
|
||||
this(EffortlessBuilding.MODID, location, startX, startY, width, height);
|
||||
}
|
||||
|
||||
private AllGuiTextures(String namespace, String location, int startX, int startY, int width, int height) {
|
||||
this.location = new ResourceLocation(namespace, "textures/gui/" + location + ".png");
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.startX = startX;
|
||||
this.startY = startY;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void bind() {
|
||||
RenderSystem.setShaderTexture(0, location);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void render(PoseStack ms, int x, int y) {
|
||||
bind();
|
||||
GuiComponent.blit(ms, x, y, 0, startX, startY, width, height, 256, 256);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(PoseStack ms, int x, int y, GuiComponent component) {
|
||||
bind();
|
||||
component.blit(ms, x, y, startX, startY, width, height);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(PoseStack ms, int x, int y, Color c) {
|
||||
bind();
|
||||
UIRenderHelper.drawColoredTexture(ms, c, x, y, startX, startY, width, height);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.world.entity.player.Player;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||
|
||||
public abstract class BaseModifier {
|
||||
public boolean enabled = false;
|
||||
public boolean enabled = true;
|
||||
|
||||
public abstract void findCoordinates(BlockSet blocks, Player player);
|
||||
|
||||
|
||||
@@ -106,6 +106,8 @@ public class ScrollInput extends AbstractSimiWidget {
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
|
||||
if (!this.visible || !this.isHovered) return false; //Added
|
||||
|
||||
if (inverted)
|
||||
delta *= -1;
|
||||
|
||||
|
||||
@@ -9,9 +9,11 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.AllGuiTextures;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.Array;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.AbstractSimiScreen;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.Label;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.ScrollInput;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
@@ -31,10 +33,11 @@ public class ArrayEntry extends BaseModifierEntry<Array> {
|
||||
protected Vector<ScrollInput> offsetInputs = new Vector<>(3);
|
||||
protected Vector<Label> offsetLabels = new Vector<>(3);
|
||||
protected ScrollInput countInput;
|
||||
protected Label countLabel;
|
||||
protected Label reachLabel;
|
||||
|
||||
public ArrayEntry(BaseModifier array) {
|
||||
super((Array) array);
|
||||
public ArrayEntry(ModifiersScreen screen, BaseModifier array) {
|
||||
super(screen, (Array) array, Component.literal("Array"), AllGuiTextures.ARRAY_ENTRY);
|
||||
|
||||
offsetInputs.clear();
|
||||
offsetLabels.clear();
|
||||
@@ -43,7 +46,7 @@ public class ArrayEntry extends BaseModifierEntry<Array> {
|
||||
var label = new Label(0, 0, Components.immutableEmpty()).withShadow();
|
||||
|
||||
final int index = i;
|
||||
var scrollInput = new ScrollInput(0, 0, 20, 20)
|
||||
var scrollInput = new ScrollInput(0, 0, 18, 18)
|
||||
.withRange(0, 100)
|
||||
.writingTo(label)
|
||||
.titled(Component.literal("Offset"))
|
||||
@@ -53,7 +56,6 @@ public class ArrayEntry extends BaseModifierEntry<Array> {
|
||||
onValueChanged();
|
||||
});
|
||||
scrollInput.setState(MathHelper.get(modifier.offset, index));
|
||||
scrollInput.onChanged();
|
||||
|
||||
offsetInputs.add(scrollInput);
|
||||
offsetLabels.add(label);
|
||||
@@ -62,22 +64,26 @@ public class ArrayEntry extends BaseModifierEntry<Array> {
|
||||
listeners.addAll(offsetInputs);
|
||||
listeners.addAll(offsetLabels);
|
||||
|
||||
countInput = new ScrollInput(0, 0, 20, 20)
|
||||
countLabel = new Label(0, 0, Components.immutableEmpty()).withShadow();
|
||||
countInput = new ScrollInput(0, 0, 18, 18)
|
||||
.withRange(1, 100)
|
||||
.writingTo(countLabel)
|
||||
.titled(Component.literal("Count"))
|
||||
.calling(value -> {
|
||||
modifier.count = value;
|
||||
onValueChanged();
|
||||
});
|
||||
|
||||
countInput.setState(modifier.count);
|
||||
countInput.onChanged();
|
||||
|
||||
listeners.add(countInput);
|
||||
listeners.add(countLabel);
|
||||
|
||||
reachLabel = new Label(100, 100, Components.immutableEmpty()).withShadow();
|
||||
reachLabel = new Label(0, 0, Components.immutableEmpty()).withShadow();
|
||||
listeners.add(reachLabel);
|
||||
|
||||
onValueChanged();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
offsetInputs.get(i).onChanged();
|
||||
}
|
||||
countInput.onChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,24 +92,51 @@ public class ArrayEntry extends BaseModifierEntry<Array> {
|
||||
offsetInputs.forEach(ScrollInput::tick);
|
||||
offsetLabels.forEach(Label::tick);
|
||||
countInput.tick();
|
||||
|
||||
int currentReach = Math.max(-1, getArrayReach());
|
||||
int maxReach = ReachHelper.getMaxReach(Minecraft.getInstance().player);
|
||||
ChatFormatting reachColor = isCurrentReachValid(currentReach, maxReach) ? ChatFormatting.GRAY : ChatFormatting.RED;
|
||||
var reachText = "Reach: " + reachColor + currentReach + ChatFormatting.GRAY + "/" + ChatFormatting.GRAY + maxReach;
|
||||
reachLabel.text = Component.literal(reachText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
||||
super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks);
|
||||
|
||||
//draw offset labels
|
||||
for (int i = 0; i < 3; i++) {
|
||||
offsetLabels.get(i).x = x + 75 + 20 * i;
|
||||
offsetLabels.get(i).y = y + 24;
|
||||
offsetLabels.get(i).render(ms, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
//draw offset inputs
|
||||
for (int i = 0; i < 3; i++) {
|
||||
offsetInputs.get(i).x = x + 75 + 20 * i;
|
||||
offsetInputs.get(i).y = y + 24;
|
||||
offsetInputs.get(i).render(ms, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
//draw count label
|
||||
countLabel.x = x + 140;
|
||||
countLabel.y = y + 24;
|
||||
countLabel.render(ms, mouseX, mouseY, partialTicks);
|
||||
|
||||
//draw count input
|
||||
countInput.x = x + 140;
|
||||
countInput.y = y + 24;
|
||||
countInput.render(ms, mouseX, mouseY, partialTicks);
|
||||
|
||||
//draw reach label
|
||||
reachLabel.x = x + width - 125;
|
||||
reachLabel.y = y + 40;
|
||||
reachLabel.render(ms, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged() {
|
||||
super.onValueChanged();
|
||||
|
||||
|
||||
int currentReach = Math.max(-1, getArrayReach());
|
||||
int maxReach = ReachHelper.getMaxReach(Minecraft.getInstance().player);
|
||||
ChatFormatting reachColor = isCurrentReachValid(currentReach, maxReach) ? ChatFormatting.GRAY : ChatFormatting.RED;
|
||||
var reachText = "Reach: " + reachColor + currentReach + ChatFormatting.GRAY + "/" + ChatFormatting.GRAY + maxReach;
|
||||
reachLabel.text = Component.literal(reachText);
|
||||
}
|
||||
|
||||
private int getArrayReach() {
|
||||
|
||||
@@ -1,48 +1,75 @@
|
||||
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import nl.requios.effortlessbuilding.AllGuiTextures;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.AbstractSimiScreen;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.AllIcons;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.BoxWidget;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.IconButton;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.Label;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiCollapsibleScrollEntry;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiScrollPane;
|
||||
|
||||
public abstract class BaseModifierEntry<T extends BaseModifier> extends ModifiersScreenList.Entry {
|
||||
|
||||
public T modifier;
|
||||
BoxWidget enableButton;
|
||||
protected AllGuiTextures background;
|
||||
protected IconButton enableButton;
|
||||
protected Label nameLabel;
|
||||
protected IconButton removeButton;
|
||||
|
||||
public BaseModifierEntry(T modifier) {
|
||||
super();
|
||||
public BaseModifierEntry(ModifiersScreen screen, T modifier, Component name, AllGuiTextures background) {
|
||||
super(screen);
|
||||
|
||||
this.modifier = modifier;
|
||||
this.background = background;
|
||||
|
||||
enableButton = new BoxWidget()
|
||||
.showingElement(AllIcons.I_CONFIRM.asStencil())
|
||||
enableButton = new IconButton(35, 8, AllIcons.I_PLACE)
|
||||
.withCallback(() -> {
|
||||
modifier.enabled = !modifier.enabled;
|
||||
onValueChanged();
|
||||
});
|
||||
listeners.add(enableButton);
|
||||
|
||||
nameLabel = new Label(65, 8, name);
|
||||
nameLabel.text = name;
|
||||
|
||||
removeButton = new IconButton(0, 0, AllIcons.I_TRASH)
|
||||
.withCallback(() -> {
|
||||
screen.removeModifier(this);
|
||||
});
|
||||
listeners.add(removeButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
enableButton.tick();
|
||||
// enableButton.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
||||
super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks);
|
||||
|
||||
enableButton.x = x + width - 80;
|
||||
enableButton.y = y + 10;
|
||||
enableButton.setWidth(35);
|
||||
enableButton.setHeight(height - 20);
|
||||
background.render(ms, x + 22, y, screen);
|
||||
|
||||
enableButton.x = x + width - 60;
|
||||
enableButton.y = y + 18;
|
||||
enableButton.render(ms, mouseX, mouseY, partialTicks);
|
||||
|
||||
nameLabel.x = x + 65;
|
||||
nameLabel.y = y + 4;
|
||||
nameLabel.render(ms, mouseX, mouseY, partialTicks);
|
||||
|
||||
removeButton.x = x + width - 60;
|
||||
removeButton.y = y + 38;
|
||||
removeButton.render(ms, mouseX, mouseY, partialTicks);
|
||||
|
||||
super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks);
|
||||
}
|
||||
|
||||
public void onValueChanged() {
|
||||
enableButton.showingElement(modifier.enabled ? AllIcons.I_CONFIRM.asStencil() : AllIcons.I_DISABLE.asStencil());
|
||||
enableButton.setIcon(modifier.enabled ? AllIcons.I_PLACE : AllIcons.I_CLEAR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,11 @@ import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.AllGuiTextures;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.Mirror;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.AbstractSimiScreen;
|
||||
import nl.requios.effortlessbuilding.gui.elements.*;
|
||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||
|
||||
@@ -24,8 +26,8 @@ import java.util.List;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class MirrorEntry extends BaseModifierEntry<Mirror> {
|
||||
|
||||
public MirrorEntry(BaseModifier modifier) {
|
||||
super((Mirror) modifier);
|
||||
public MirrorEntry(ModifiersScreen screen, BaseModifier modifier) {
|
||||
super(screen, (Mirror) modifier, Component.literal("Mirror"), AllGuiTextures.MIRROR_ENTRY);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.Mirror;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.AbstractSimiScreen;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.AllIcons;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.BoxWidget;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiScrollPane;
|
||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||
|
||||
@@ -25,7 +28,10 @@ import java.util.Map;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ModifiersScreen extends AbstractSimiScreen {
|
||||
protected ModifiersScreenList list;
|
||||
private Button buttonClose;
|
||||
protected BoxWidget addArrayButton;
|
||||
protected BoxWidget addMirrorButton;
|
||||
protected BoxWidget addRadialMirrorButton;
|
||||
protected BoxWidget closeButton;
|
||||
|
||||
public ModifiersScreen() {
|
||||
super(Component.translatable("effortlessbuilding.screen.modifier_settings"));
|
||||
@@ -41,23 +47,46 @@ public class ModifiersScreen extends AbstractSimiScreen {
|
||||
int listL = this.width / 2 - listWidth / 2;
|
||||
int listR = this.width / 2 + listWidth / 2;
|
||||
|
||||
list = new ModifiersScreenList(minecraft, listWidth, height - 80, 35, height - 45, 40);
|
||||
list = new ModifiersScreenList(minecraft, listWidth, height - 80, 45, height - 45, 60);
|
||||
list.setLeftPos(this.width / 2 - list.getWidth() / 2);
|
||||
|
||||
addRenderableWidget(list);
|
||||
|
||||
initScrollEntries();
|
||||
|
||||
//Close button
|
||||
int y = height - 26;
|
||||
buttonClose = new Button(width / 2 - 100, y, 200, 20, Component.literal("Close"), (button) -> {
|
||||
Minecraft.getInstance().player.closeContainer();
|
||||
});
|
||||
addRenderableOnly(buttonClose);
|
||||
addArrayButton = new BoxWidget(listR - 90, 10, 20, 20)
|
||||
.withPadding(2, 2)
|
||||
.withCallback(() -> addModifier(new Array()));
|
||||
addArrayButton.showingElement(AllIcons.I_ADD.asStencil().withElementRenderer(BoxWidget.gradientFactory.apply(addArrayButton)));
|
||||
addArrayButton.getToolTip().add(Components.literal("Add Array"));
|
||||
|
||||
addMirrorButton = new BoxWidget(listR - 60, 10, 20, 20)
|
||||
.withPadding(2, 2)
|
||||
.withCallback(() -> addModifier(new Mirror()));
|
||||
addMirrorButton.showingElement(AllIcons.I_ADD.asStencil().withElementRenderer(BoxWidget.gradientFactory.apply(addMirrorButton)));
|
||||
addMirrorButton.getToolTip().add(Components.literal("Add Mirror"));
|
||||
|
||||
addRadialMirrorButton = new BoxWidget(listR - 30, 10, 20, 20)
|
||||
.withPadding(2, 2)
|
||||
.withCallback(() -> addModifier(new RadialMirror()));
|
||||
addRadialMirrorButton.showingElement(AllIcons.I_ADD.asStencil().withElementRenderer(BoxWidget.gradientFactory.apply(addRadialMirrorButton)));
|
||||
addRadialMirrorButton.getToolTip().add(Components.literal("Add Radial Mirror"));
|
||||
|
||||
closeButton = new BoxWidget(listL - 30, yCenter - 10, 20, 20)
|
||||
.withPadding(2, 2)
|
||||
.withCallback(this::onClose);
|
||||
closeButton.showingElement(AllIcons.I_CONFIG_BACK.asStencil().withElementRenderer(BoxWidget.gradientFactory.apply(closeButton)));
|
||||
closeButton.getToolTip().add(Components.literal("Close"));
|
||||
|
||||
addRenderableWidget(addArrayButton);
|
||||
addRenderableWidget(addMirrorButton);
|
||||
addRenderableWidget(addRadialMirrorButton);
|
||||
addRenderableWidget(closeButton);
|
||||
}
|
||||
|
||||
private void initScrollEntries() {
|
||||
|
||||
list.children().clear();
|
||||
var modifierSettingsList = EffortlessBuildingClient.BUILD_MODIFIERS.getModifierSettingsList();
|
||||
for (BaseModifier modifier : modifierSettingsList) {
|
||||
var entry = createModifierPanel(modifier);
|
||||
@@ -67,11 +96,11 @@ public class ModifiersScreen extends AbstractSimiScreen {
|
||||
|
||||
private BaseModifierEntry createModifierPanel(BaseModifier modifier) {
|
||||
if (modifier instanceof Mirror) {
|
||||
return new MirrorEntry(modifier);
|
||||
return new MirrorEntry(this, modifier);
|
||||
} else if (modifier instanceof Array) {
|
||||
return new ArrayEntry(modifier);
|
||||
return new ArrayEntry(this, modifier);
|
||||
} else if (modifier instanceof RadialMirror) {
|
||||
return new RadialMirrorEntry(modifier);
|
||||
return new RadialMirrorEntry(this, modifier);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -83,7 +112,7 @@ public class ModifiersScreen extends AbstractSimiScreen {
|
||||
EffortlessBuildingClient.BUILD_MODIFIERS.addModifierSettings(modifier);
|
||||
}
|
||||
|
||||
private void removeModifier(BaseModifierEntry entry) {
|
||||
public void removeModifier(BaseModifierEntry entry) {
|
||||
list.children().remove(entry);
|
||||
EffortlessBuildingClient.BUILD_MODIFIERS.removeModifierSettings(entry.modifier);
|
||||
}
|
||||
@@ -97,7 +126,7 @@ public class ModifiersScreen extends AbstractSimiScreen {
|
||||
|
||||
@Override
|
||||
protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,7 +138,7 @@ public class ModifiersScreen extends AbstractSimiScreen {
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int p_96553_, int p_96554_) {
|
||||
if (keyCode == ClientEvents.keyBindings[1].getKey().getValue()) {
|
||||
minecraft.player.closeContainer();
|
||||
onClose();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,21 +7,21 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.AbstractSimiScreen;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.TickableGuiEventListener;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.UIRenderHelper;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.AbstractSimiWidget;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
//Based on Create's ConfigScreenList
|
||||
public class ModifiersScreenList extends ObjectSelectionList<ModifiersScreenList.Entry> implements TickableGuiEventListener {
|
||||
|
||||
public ModifiersScreenList(Minecraft pMinecraft, int pWidth, int pHeight, int pY0, int pY1, int pItemHeight) {
|
||||
super(pMinecraft, pWidth, pHeight, pY0, pY1, pItemHeight);
|
||||
public ModifiersScreenList(Minecraft mc, int width, int height, int y0, int y1, int itemHeight) {
|
||||
super(mc, width, height, y0, y1, itemHeight);
|
||||
setRenderBackground(false);
|
||||
setRenderTopAndBottom(false);
|
||||
setRenderSelection(false);
|
||||
@@ -50,11 +50,32 @@ public class ModifiersScreenList extends ObjectSelectionList<ModifiersScreenList
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double x, double y, int button) {
|
||||
children().stream().forEach(e -> e.mouseClicked(x, y, button));
|
||||
|
||||
if (children().stream().anyMatch(e -> e.mouseClicked(x, y, button)))
|
||||
return true;
|
||||
return super.mouseClicked(x, y, button);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) {
|
||||
if (children().stream().anyMatch(e -> e.keyPressed(pKeyCode, pScanCode, pModifiers)))
|
||||
return true;
|
||||
return super.keyPressed(pKeyCode, pScanCode, pModifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char pCodePoint, int pModifiers) {
|
||||
if (children().stream().anyMatch(e -> e.charTyped(pCodePoint, pModifiers)))
|
||||
return true;
|
||||
return super.charTyped(pCodePoint, pModifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(double pMouseX, double pMouseY, double pDelta) {
|
||||
if (children().stream().anyMatch(e -> e.mouseScrolled(pMouseX, pMouseY, pDelta)))
|
||||
return true;
|
||||
return super.mouseScrolled(pMouseX, pMouseY, pDelta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowWidth() {
|
||||
return width - 16;
|
||||
@@ -71,9 +92,11 @@ public class ModifiersScreenList extends ObjectSelectionList<ModifiersScreenList
|
||||
}
|
||||
|
||||
public static abstract class Entry extends ObjectSelectionList.Entry<Entry> implements TickableGuiEventListener {
|
||||
protected final ModifiersScreen screen;
|
||||
protected List<GuiEventListener> listeners;
|
||||
|
||||
protected Entry() {
|
||||
protected Entry(ModifiersScreen screen) {
|
||||
this.screen = screen;
|
||||
listeners = new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -91,9 +114,30 @@ public class ModifiersScreenList extends ObjectSelectionList<ModifiersScreenList
|
||||
public boolean charTyped(char ch, int modifiers) {
|
||||
return getGuiListeners().stream().anyMatch(l -> l.charTyped(ch, modifiers));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {}
|
||||
public boolean mouseScrolled(double x, double y, double delta) {
|
||||
return getGuiListeners().stream().anyMatch(l -> l.mouseScrolled(x, y, delta));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
||||
|
||||
// UIRenderHelper.streak(ms, 0, x - 10, y + height / 2, height - 6, width, 0xdd_000000);
|
||||
// UIRenderHelper.streak(ms, 180, x + (int) (width * 1.35f) + 10, y + height / 2, height - 6, width / 8 * 7, 0xdd_000000);
|
||||
|
||||
for (var listener : listeners) {
|
||||
if (listener instanceof AbstractSimiWidget simiWidget && simiWidget.isHoveredOrFocused()
|
||||
&& simiWidget.visible) {
|
||||
List<Component> tooltip = simiWidget.getToolTip();
|
||||
if (tooltip.isEmpty())
|
||||
continue;
|
||||
int ttx = simiWidget.lockedTooltipX == -1 ? mouseX : simiWidget.lockedTooltipX + simiWidget.x;
|
||||
int tty = simiWidget.lockedTooltipY == -1 ? mouseY : simiWidget.lockedTooltipY + simiWidget.y;
|
||||
screen.renderComponentTooltip(ms, tooltip, ttx, tty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {}
|
||||
|
||||
@@ -10,9 +10,11 @@ import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.AllGuiTextures;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.AbstractSimiScreen;
|
||||
import nl.requios.effortlessbuilding.gui.elements.*;
|
||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||
|
||||
@@ -24,8 +26,8 @@ import java.util.List;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class RadialMirrorEntry extends BaseModifierEntry<RadialMirror> {
|
||||
|
||||
public RadialMirrorEntry(BaseModifier modifier) {
|
||||
super((RadialMirror) modifier);
|
||||
public RadialMirrorEntry(ModifiersScreen screen, BaseModifier modifier) {
|
||||
super(screen, (RadialMirror) modifier, Component.literal("Radial Mirror"), AllGuiTextures.RADIAL_MIRROR_ENTRY);
|
||||
}
|
||||
|
||||
// protected static final ResourceLocation BUILDING_ICONS = new ResourceLocation(EffortlessBuilding.MODID, "textures/gui/building_icons.png");
|
||||
|
||||
@@ -83,5 +83,11 @@
|
||||
"effortlessbuilding.action.thickness_3": "3 Blocks Thick",
|
||||
"effortlessbuilding.action.thickness_5": "5 Blocks Thick",
|
||||
"effortlessbuilding.action.start_center": "Middle",
|
||||
"effortlessbuilding.action.start_corner": "Corner"
|
||||
}
|
||||
"effortlessbuilding.action.start_corner": "Corner",
|
||||
|
||||
"effortlessbuilding.gui.scrollInput.defaultTitle": "Choose an Option:",
|
||||
"effortlessbuilding.gui.scrollInput.scrollToModify": "Scroll to Modify",
|
||||
"effortlessbuilding.gui.scrollInput.scrollToAdjustAmount": "Scroll to Adjust Amount",
|
||||
"effortlessbuilding.gui.scrollInput.scrollToSelect": "Scroll to Select",
|
||||
"effortlessbuilding.gui.scrollInput.shiftScrollsFaster": "Shift to Scroll Faster"
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
Reference in New Issue
Block a user