Skip to content

Commit

Permalink
Work on adjusting various GUIs so that they don't have to make use of…
Browse files Browse the repository at this point in the history
… scrolling text for default configs when set to english
  • Loading branch information
pupnewfster committed Sep 24, 2024
1 parent 284c313 commit cb1a182
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ public class GuiFissionReactorLogicAdapter extends GuiMekanismTile<TileEntityFis

public GuiFissionReactorLogicAdapter(EmptyTileContainer<TileEntityFissionReactorLogicAdapter> container, Inventory inv, Component title) {
super(container, inv, title);
imageWidth += 20;
}

@Override
protected void addGuiElements() {
super.addGuiElements();
addRenderableWidget(new GuiElementHolder(this, 16, 31, 130, 90));
scrollBar = addRenderableWidget(new GuiScrollBar(this, 146, 31, 90, () -> tile.getModes().length, () -> DISPLAY_COUNT));
addRenderableWidget(new GuiElementHolder(this, 26, 31, 130, 90));
scrollBar = addRenderableWidget(new GuiScrollBar(this, 156, 31, 90, () -> tile.getModes().length, () -> DISPLAY_COUNT));
for (int i = 0; i < DISPLAY_COUNT; i++) {
int typeShift = 22 * i;
addRenderableWidget(new ReactorLogicButton<>(this, 17, 32 + typeShift, i, tile, FissionReactorLogic.class, scrollBar::getCurrentSelection, tile::getModes, this::changeLogic));
addRenderableWidget(new ReactorLogicButton<>(this, 27, 32 + typeShift, i, tile, FissionReactorLogic.class, scrollBar::getCurrentSelection, tile::getModes, this::changeLogic));
}
}

Expand All @@ -48,8 +49,8 @@ private void changeLogic(FissionReactorLogic type) {
@Override
protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) {
renderTitleText(guiGraphics);
drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_LOGIC_REDSTONE_MODE.translate(tile.logicType.getColor(), tile.logicType), 0, 123, TextAlignment.CENTER, titleTextColor(), 16, false);
drawScrollingString(guiGraphics, MekanismLang.STATUS.translate(EnumColor.RED, tile.getStatus()), 0, 136, TextAlignment.CENTER, titleTextColor(), 16, false);
drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_LOGIC_REDSTONE_MODE.translate(tile.logicType.getColor(), tile.logicType), 0, 123, TextAlignment.CENTER, titleTextColor(), 4, false);
drawScrollingString(guiGraphics, MekanismLang.STATUS.translate(EnumColor.RED, tile.getStatus()), 0, 136, TextAlignment.CENTER, titleTextColor(), 4, false);
super.drawForegroundText(guiGraphics, mouseX, mouseY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,20 @@ public class GuiFusionReactorLogicAdapter extends GuiMekanismTile<TileEntityFusi

public GuiFusionReactorLogicAdapter(EmptyTileContainer<TileEntityFusionReactorLogicAdapter> container, Inventory inv, Component title) {
super(container, inv, title);
imageWidth += 20;
}

@Override
protected void addGuiElements() {
super.addGuiElements();
addRenderableWidget(new GuiElementHolder(this, 16, 31, 130, 90));
addRenderableWidget(new ToggleButton(this, 16, 19, 11, tile::isActiveCooled,
addRenderableWidget(new GuiElementHolder(this, 26, 31, 130, 90));
addRenderableWidget(new ToggleButton(this, 26, 19, 11, tile::isActiveCooled,
(element, mouseX, mouseY) -> PacketUtils.sendToServer(new PacketGuiInteract(GuiInteraction.NEXT_MODE, ((GuiFusionReactorLogicAdapter) element.gui()).tile))))
.setTooltip(GeneratorsLang.REACTOR_LOGIC_TOGGLE_COOLING);
scrollBar = addRenderableWidget(new GuiScrollBar(this, 146, 31, 90, () -> tile.getModes().length, () -> DISPLAY_COUNT));
scrollBar = addRenderableWidget(new GuiScrollBar(this, 156, 31, 90, () -> tile.getModes().length, () -> DISPLAY_COUNT));
for (int i = 0; i < DISPLAY_COUNT; i++) {
int typeShift = 22 * i;
addRenderableWidget(new ReactorLogicButton<>(this, 17, 32 + typeShift, i, tile, FusionReactorLogic.class, scrollBar::getCurrentSelection, tile::getModes, this::changeLogic));
addRenderableWidget(new ReactorLogicButton<>(this, 27, 32 + typeShift, i, tile, FusionReactorLogic.class, scrollBar::getCurrentSelection, tile::getModes, this::changeLogic));
}
}

Expand All @@ -55,11 +56,11 @@ private void changeLogic(FusionReactorLogic type) {
@Override
protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) {
renderTitleText(guiGraphics);
drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_LOGIC_ACTIVE_COOLING.translate(EnumColor.RED, OnOff.of(tile.isActiveCooled())), 13, 20, TextAlignment.LEFT,
titleTextColor(), getXSize() - 13, 16, false);
drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_LOGIC_REDSTONE_MODE.translate(EnumColor.RED, tile.logicType), 0, 123, TextAlignment.CENTER, titleTextColor(), 16, false);
drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_LOGIC_ACTIVE_COOLING.translate(EnumColor.RED, OnOff.of(tile.isActiveCooled())), 23, 20, TextAlignment.LEFT,
titleTextColor(), getXSize() - 23, 16, false);
drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_LOGIC_REDSTONE_MODE.translate(EnumColor.RED, tile.logicType), 0, 123, TextAlignment.CENTER, titleTextColor(), 4, false);
drawScrollingString(guiGraphics, MekanismLang.STATUS.translate(EnumColor.RED, tile.checkMode() ? GeneratorsLang.REACTOR_LOGIC_OUTPUTTING : MekanismLang.IDLE),
0, 136, TextAlignment.CENTER, titleTextColor(), 16, false);
0, 136, TextAlignment.CENTER, titleTextColor(), 4, false);
super.drawForegroundText(guiGraphics, mouseX, mouseY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected void addGuiElements() {
//Add the side holder before the slots, as it holds a couple of the slots
addRenderableWidget(GuiSideHolder.create(this, -26, 6, 98, true, true, SpecialColors.TAB_ARMOR_SLOTS));
super.addGuiElements();
addRenderableWidget(new GuiInnerScreen(this, 48, 23, 80, 40, () -> List.of(
addRenderableWidget(new GuiInnerScreen(this, 40, 23, 96, 40, () -> List.of(
EnergyDisplay.of(tile.getEnergyContainer()).getTextComponent(),
GeneratorsLang.PRODUCING_AMOUNT.translate(EnergyDisplay.of(tile.getProductionRate())),
GeneratorsLang.OUTPUT_RATE_SHORT.translate(EnergyDisplay.of(tile.getMaxOutput()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public GuiScreenSwitch(IGuiWrapper gui, int x, int y, int width, Component butto
this.active = true;
this.clickSound = () -> this.stateSupplier.getAsBoolean() ? MekanismSounds.BEEP_OFF.get() : MekanismSounds.BEEP_ON.get();
this.clickVolume = 1.0F;
padding(4);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public GuiQIOCrystallizerScreen(IGuiWrapper gui, int x, int y, int width, int he
super(gui, x, y, width, height);
this.oreInfo = oreInfo;
int slotX = relativeX + this.width - SlotType.ORE.getWidth();
this.slot = addChild(new GuiSlot(SlotType.ORE, gui, slotX, 13));
this.slot = addChild(new GuiSlot(SlotType.ORE, gui, slotX, relativeY));
if (this.oreInfo.usesSequencedDisplay()) {
this.iterStacks = new ArrayList<>();
this.slotDisplay = addChild(new GuiSequencedSlotDisplay(gui, slotX + 1, 14, () -> this.iterStacks));
this.slotDisplay = addChild(new GuiSequencedSlotDisplay(gui, slotX + 1, relativeY + 1, () -> this.iterStacks));
updateSlotContents();
} else {
this.iterStacks = Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public GuiSideConfiguration(IGuiWrapper gui, int x, int y, TILE tile, SelectedWi
setCurrentType(transmissions.getFirst());
//TODO: Try to make the GUI look a bit better as it still seems a bit off with the scales and such
// Maybe we want to eventually add some sort of "in world preview" type thing
addChild(new GuiInnerScreen(gui, relativeX + 41, relativeY + 25, 74, 12, () -> {
addChild(new GuiInnerScreen(gui, relativeX + 38, relativeY + 25, 80, 12, () -> {
ConfigInfo config = getCurrentConfig();
if (config == null || !config.canEject()) {
return Collections.singletonList(MekanismLang.NO_EJECT.translate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public GuiTransporterConfig(IGuiWrapper gui, int x, int y, TILE tile, SelectedWi
}
this.tile = tile;
interactionStrategy = InteractionStrategy.ALL;
addChild(new GuiInnerScreen(gui, relativeX + 41, relativeY + 15, 74, 12,
addChild(new GuiInnerScreen(gui, relativeX + 38, relativeY + 15, 80, 12,
() -> Collections.singletonList(MekanismLang.STRICT_INPUT_ENABLED.translate(OnOff.of(tile.getEjector().hasStrictInput())))));
addChild(new GuiSlot(SlotType.NORMAL, gui, relativeX + 111, relativeY + 48));
addChild(new MekanismImageButton(gui, relativeX + 136, relativeY + 6, 14, 16, getButtonLocation("exclamation"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,37 @@

public class GuiOredictionificatorFilter extends GuiTextFilter<OredictionificatorItemFilter, TileEntityOredictionificator> {

private static final int WIDTH = 162;

public static GuiOredictionificatorFilter create(IGuiWrapper gui, TileEntityOredictionificator tile) {
return new GuiOredictionificatorFilter(gui, (gui.getXSize() - 152) / 2, 15, tile, null);
return new GuiOredictionificatorFilter(gui, (gui.getXSize() - WIDTH) / 2, 15, tile, null);
}

public static GuiOredictionificatorFilter edit(IGuiWrapper gui, TileEntityOredictionificator tile, OredictionificatorItemFilter filter) {
return new GuiOredictionificatorFilter(gui, (gui.getXSize() - 152) / 2, 15, tile, filter);
return new GuiOredictionificatorFilter(gui, (gui.getXSize() - WIDTH) / 2, 15, tile, filter);
}

private GuiOredictionificatorFilter(IGuiWrapper gui, int x, int y, TileEntityOredictionificator tile, @Nullable OredictionificatorItemFilter origFilter) {
super(gui, x, y, 152, 100, MekanismLang.OREDICTIONIFICATOR_FILTER.translate(), tile, origFilter);
super(gui, x, y, WIDTH, 100, MekanismLang.OREDICTIONIFICATOR_FILTER.translate(), tile, origFilter);
}

@Override
protected int getScreenHeight() {
return 52;
}

@Override
protected int getSlotOffset() {
return 32;
}

@Override
protected void init() {
super.init();
addChild(new MekanismImageButton(gui(), relativeX + 10, relativeY + 18, 12, getButtonLocation("left"), (element, mouseX, mouseY) -> {
addChild(new MekanismImageButton(gui(), relativeX + 3, relativeY + 38, 12, getButtonLocation("left"), (element, mouseX, mouseY) -> {
if (filter.hasFilter()) {
filter.previous();
slotDisplay.updateStackList();
return true;
}
return false;
})).setTooltip(MekanismLang.LAST_ITEM);
addChild(new MekanismImageButton(gui(), relativeX + 10, relativeY + 52, 12, getButtonLocation("right"), (element, mouseX, mouseY) -> {
addChild(new MekanismImageButton(gui(), relativeX + 16, relativeY + 38, 12, getButtonLocation("right"), (element, mouseX, mouseY) -> {
if (filter.hasFilter()) {
filter.next();
slotDisplay.updateStackList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

public interface GuiMinerFilterHelper extends GuiFilterHelper<TileEntityDigitalMiner> {

int MINER_FILTER_WIDTH = 173;

@Override
MinerFilter<?> getFilter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
public class GuiMinerItemStackFilter extends GuiItemStackFilter<MinerItemStackFilter, TileEntityDigitalMiner> implements GuiMinerFilterHelper {

public static GuiMinerItemStackFilter create(IGuiWrapper gui, TileEntityDigitalMiner tile) {
return new GuiMinerItemStackFilter(gui, (gui.getXSize() - 173) / 2, 30, tile, null);
return new GuiMinerItemStackFilter(gui, (gui.getXSize() - MINER_FILTER_WIDTH) / 2, 30, tile, null);
}

public static GuiMinerItemStackFilter edit(IGuiWrapper gui, TileEntityDigitalMiner tile, MinerItemStackFilter filter) {
return new GuiMinerItemStackFilter(gui, (gui.getXSize() - 173) / 2, 30, tile, filter);
return new GuiMinerItemStackFilter(gui, (gui.getXSize() - MINER_FILTER_WIDTH) / 2, 30, tile, filter);
}

private GuiMinerItemStackFilter(IGuiWrapper gui, int x, int y, TileEntityDigitalMiner tile, @Nullable MinerItemStackFilter origFilter) {
super(gui, x, y, 173, 90, tile, origFilter);
super(gui, x, y, MINER_FILTER_WIDTH, 90, tile, origFilter);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
public class GuiMinerModIDFilter extends GuiModIDFilter<MinerModIDFilter, TileEntityDigitalMiner> implements GuiMinerFilterHelper {

public static GuiMinerModIDFilter create(IGuiWrapper gui, TileEntityDigitalMiner tile) {
return new GuiMinerModIDFilter(gui, (gui.getXSize() - 173) / 2, 30, tile, null);
return new GuiMinerModIDFilter(gui, (gui.getXSize() - MINER_FILTER_WIDTH) / 2, 30, tile, null);
}

public static GuiMinerModIDFilter edit(IGuiWrapper gui, TileEntityDigitalMiner tile, MinerModIDFilter filter) {
return new GuiMinerModIDFilter(gui, (gui.getXSize() - 173) / 2, 30, tile, filter);
return new GuiMinerModIDFilter(gui, (gui.getXSize() - MINER_FILTER_WIDTH) / 2, 30, tile, filter);
}

private GuiMinerModIDFilter(IGuiWrapper gui, int x, int y, TileEntityDigitalMiner tile, @Nullable MinerModIDFilter origFilter) {
super(gui, x, y, 173, 90, tile, origFilter);
super(gui, x, y, MINER_FILTER_WIDTH, 90, tile, origFilter);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
public class GuiMinerTagFilter extends GuiTagFilter<MinerTagFilter, TileEntityDigitalMiner> implements GuiMinerFilterHelper {

public static GuiMinerTagFilter create(IGuiWrapper gui, TileEntityDigitalMiner tile) {
return new GuiMinerTagFilter(gui, (gui.getXSize() - 173) / 2, 30, tile, null);
return new GuiMinerTagFilter(gui, (gui.getXSize() - MINER_FILTER_WIDTH) / 2, 30, tile, null);
}

public static GuiMinerTagFilter edit(IGuiWrapper gui, TileEntityDigitalMiner tile, MinerTagFilter filter) {
return new GuiMinerTagFilter(gui, (gui.getXSize() - 173) / 2, 30, tile, filter);
return new GuiMinerTagFilter(gui, (gui.getXSize() - MINER_FILTER_WIDTH) / 2, 30, tile, filter);
}

private GuiMinerTagFilter(IGuiWrapper gui, int x, int y, TileEntityDigitalMiner tile, @Nullable MinerTagFilter origFilter) {
super(gui, x, y, 173, 90, tile, origFilter);
super(gui, x, y, MINER_FILTER_WIDTH, 90, tile, origFilter);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

public interface GuiSorterFilterHelper extends GuiFilterHelper<TileEntityLogisticalSorter>, IFancyFontRenderer, ContainerEventHandler {

int SORTER_FILTER_WIDTH = 200;

@Override
SorterFilter<?> getFilter();

Expand All @@ -54,12 +56,12 @@ default void addSorterDefaults(IGuiWrapper gui, int slotOffset, UnaryOperator<Gu
return true;
})).setTooltip(MekanismLang.FILTER_ALLOW_DEFAULT);
int maxStackSizeDigits = Integer.toString(Item.ABSOLUTE_MAX_STACK_SIZE).length();
GuiTextField minField = new GuiTextField(gui, this, relativeX + 169, relativeY + 31, 20, 11);
GuiTextField minField = new GuiTextField(gui, this, relativeX + 174, relativeY + 31, 20, 11);
minField.setMaxLength(maxStackSizeDigits);
minField.setInputValidator(InputValidator.DIGIT);
minField.setText(Integer.toString(getFilter().min));
childAdder.apply(minField);
GuiTextField maxField = new GuiTextField(gui, this, relativeX + 169, relativeY + 43, 20, 11);
GuiTextField maxField = new GuiTextField(gui, this, relativeX + 174, relativeY + 43, 20, 11);
maxField.setMaxLength(maxStackSizeDigits);
maxField.setInputValidator(InputValidator.DIGIT);
maxField.setText(Integer.toString(getFilter().max));
Expand All @@ -80,13 +82,12 @@ default GuiSorterFilerSelect getFilterSelect(IGuiWrapper gui, TileEntityLogistic

default void renderSorterForeground(GuiGraphics guiGraphics) {
SorterFilter<?> filter = getFilter();
int screenEnd = 29 + getScreenWidth();
int screenEnd = 30 + getScreenWidth();
drawScrollingString(guiGraphics, OnOff.of(filter.allowDefault).getTextComponent(), 159, 20, TextAlignment.LEFT, titleTextColor(), getXSize() - 161, 2, false);
//Note: We add two to the length, as min and max have two spaces at the end given we aren't actually providing a parameter
//TODO: Do we want to adjust this, and just have separate lang keys for them?
drawScrollingString(guiGraphics, MekanismLang.MIN.translate(""), screenEnd, 32, TextAlignment.LEFT, titleTextColor(), 168 - screenEnd, 1, false);
//TODO - 1.21: Make the gui slightly wider so that we can have it so max isn't scrolling ever so slightly be default?
drawScrollingString(guiGraphics, MekanismLang.MAX.translate(""), screenEnd, 44, TextAlignment.LEFT, titleTextColor(), 168 - screenEnd, 1, false);
drawScrollingString(guiGraphics, MekanismLang.MIN.translate(""), screenEnd, 32, TextAlignment.LEFT, titleTextColor(), 173 - screenEnd, 2, false);
drawScrollingString(guiGraphics, MekanismLang.MAX.translate(""), screenEnd, 44, TextAlignment.LEFT, titleTextColor(), 173 - screenEnd, 2, false);
if (isSingleItem() && filter.sizeMode) {
drawScrollingString(guiGraphics, MekanismLang.SORTER_FILTER_SIZE_MODE.translateColored(EnumColor.RED, OnOff.ON), 159, 58, TextAlignment.LEFT, titleTextColor(), getXSize() - 159, 2, false);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
public class GuiSorterItemStackFilter extends GuiItemStackFilter<SorterItemStackFilter, TileEntityLogisticalSorter> implements GuiSorterFilterHelper {

public static GuiSorterItemStackFilter create(IGuiWrapper gui, TileEntityLogisticalSorter tile) {
return new GuiSorterItemStackFilter(gui, (gui.getXSize() - 195) / 2, 30, tile, null);
return new GuiSorterItemStackFilter(gui, (gui.getXSize() - SORTER_FILTER_WIDTH) / 2, 30, tile, null);
}

public static GuiSorterItemStackFilter edit(IGuiWrapper gui, TileEntityLogisticalSorter tile, SorterItemStackFilter filter) {
return new GuiSorterItemStackFilter(gui, (gui.getXSize() - 195) / 2, 30, tile, filter);
return new GuiSorterItemStackFilter(gui, (gui.getXSize() - SORTER_FILTER_WIDTH) / 2, 30, tile, filter);
}

private GuiTextField minField;
private GuiTextField maxField;

private GuiSorterItemStackFilter(IGuiWrapper gui, int x, int y, TileEntityLogisticalSorter tile, @Nullable SorterItemStackFilter origFilter) {
super(gui, x, y, 195, 90, tile, origFilter);
super(gui, x, y, SORTER_FILTER_WIDTH, 90, tile, origFilter);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
public class GuiSorterModIDFilter extends GuiModIDFilter<SorterModIDFilter, TileEntityLogisticalSorter> implements GuiSorterFilterHelper {

public static GuiSorterModIDFilter create(IGuiWrapper gui, TileEntityLogisticalSorter tile) {
return new GuiSorterModIDFilter(gui, (gui.getXSize() - 182) / 2, 30, tile, null);
return new GuiSorterModIDFilter(gui, (gui.getXSize() - SORTER_FILTER_WIDTH) / 2, 30, tile, null);
}

public static GuiSorterModIDFilter edit(IGuiWrapper gui, TileEntityLogisticalSorter tile, SorterModIDFilter filter) {
return new GuiSorterModIDFilter(gui, (gui.getXSize() - 182) / 2, 30, tile, filter);
return new GuiSorterModIDFilter(gui, (gui.getXSize() - SORTER_FILTER_WIDTH) / 2, 30, tile, filter);
}

private GuiTextField minField;
private GuiTextField maxField;

private GuiSorterModIDFilter(IGuiWrapper gui, int x, int y, TileEntityLogisticalSorter tile, @Nullable SorterModIDFilter origFilter) {
super(gui, x, y, 195, 90, tile, origFilter);
super(gui, x, y, SORTER_FILTER_WIDTH, 90, tile, origFilter);
}

@Override
Expand Down
Loading

0 comments on commit cb1a182

Please sign in to comment.