Skip to content

Commit

Permalink
Continued work on making it so our GUIs don't have to use scrolling t…
Browse files Browse the repository at this point in the history
…ext for default configs in english
  • Loading branch information
pupnewfster committed Sep 24, 2024
1 parent cfcba1f commit dad6311
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 55 deletions.
6 changes: 3 additions & 3 deletions src/main/java/mekanism/client/gui/GuiModificationStation.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ public GuiModificationStation(MekanismTileContainer<TileEntityModificationStatio
@Override
protected void addGuiElements() {
super.addGuiElements();
addRenderableWidget(new GuiVerticalPowerBar(this, tile.getEnergyContainer(), 154, 40));
addRenderableWidget(new GuiVerticalPowerBar(this, tile.getEnergyContainer(), 156, 40));
addRenderableWidget(new GuiEnergyTab(this, tile.getEnergyContainer(), tile::usedEnergy));
addRenderableWidget(new GuiProgress(tile::getScaledProgress, ProgressType.LARGE_RIGHT, this, 65, 123));
removeButton = addRenderableWidget(new TranslationButton(this, 34, 96, 108, 17, MekanismLang.BUTTON_REMOVE, (element, mouseX, mouseY) -> {
removeButton = addRenderableWidget(new TranslationButton(this, 28, 96, 120, 17, MekanismLang.BUTTON_REMOVE, (element, mouseX, mouseY) -> {
GuiModificationStation gui = (GuiModificationStation) element.gui();
return PacketUtils.sendToServer(new PacketRemoveModule(gui.tile.getBlockPos(), gui.selectedModule.getData(), Screen.hasShiftDown()));
})).setTooltip(MekanismLang.REMOVE_ALL_MODULES_TOOLTIP);
removeButton.active = selectedModule != null;

addRenderableWidget(new GuiModuleScrollList(this, 34, 20, 108, 74, () -> tile.containerSlot.getStack().copy(), this::onModuleSelected));
addRenderableWidget(new GuiModuleScrollList(this, 28, 20, 74, () -> tile.containerSlot.getStack().copy(), this::onModuleSelected));
}

private void onModuleSelected(@Nullable IModule<?> module) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/mekanism/client/gui/GuiModuleTweaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ public GuiModuleTweaker(ModuleTweakerContainer container, Inventory inv, Compone
}
}
};
imageWidth = 248;
imageWidth = 266;
imageHeight += 20;
}

@Override
protected void addGuiElements() {
super.addGuiElements();
Supplier<ItemStack> itemSupplier = () -> getStack(selected);
moduleScreen = addRenderableWidget(new GuiModuleScreen(this, 138, 20, itemSupplier, saveCallback, armorPreview));
scrollList = addRenderableWidget(new GuiModuleScrollList(this, 30, 20, 108, 116, itemSupplier, this::onModuleSelected));
addRenderableWidget(new GuiElementHolder(this, 30, 136, 108, 18));
optionsButton = addRenderableWidget(new TranslationButton(this, 31, 137, 106, 16, MekanismLang.BUTTON_OPTIONS, (element, mouseX, mouseY) -> {
addRenderableWidget(new GuiElementHolder(this, 30, 136, 120, 18));
moduleScreen = addRenderableWidget(new GuiModuleScreen(this, 150, 20, itemSupplier, saveCallback, armorPreview));
scrollList = addRenderableWidget(new GuiModuleScrollList(this, 30, 20, 116, itemSupplier, this::onModuleSelected));
optionsButton = addRenderableWidget(new TranslationButton(this, 31, 137, 118, 16, MekanismLang.BUTTON_OPTIONS, (element, mouseX, mouseY) -> {
((GuiModuleTweaker) element.gui()).openOptions();
return true;
}));
Expand All @@ -97,7 +97,7 @@ private void onModuleSelected(Module<?> module) {
}

private void openOptions() {
addWindow(new GuiMekaSuitHelmetOptions(this, imageWidth / 2 - 140 / 2, imageHeight / 2 - 90 / 2));
addWindow(new GuiMekaSuitHelmetOptions(this, (imageWidth - 140) / 2, (imageHeight - 140) / 2));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class GuiModuleScreen extends GuiScrollableElement {
private int maxElements;

public GuiModuleScreen(IGuiWrapper gui, int x, int y, Supplier<ItemStack> itemSupplier, Consumer<ModuleConfig<?>> saveCallback, ArmorPreview armorPreview) {
this(gui, x, y, 102, 134, itemSupplier, saveCallback, armorPreview);
this(gui, x, y, 108, 134, itemSupplier, saveCallback, armorPreview);
}

private GuiModuleScreen(IGuiWrapper gui, int x, int y, int width, int height, Supplier<ItemStack> itemSupplier, Consumer<ModuleConfig<?>> saveCallback, ArmorPreview armorPreview) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class GuiModuleScrollList extends GuiScrollList {

private static final ResourceLocation MODULE_SELECTION = MekanismUtils.getResource(ResourceType.GUI, "module_selection.png");
private static final int TEXTURE_WIDTH = 100;
private static final int TEXTURE_WIDTH = 112;
private static final int TEXTURE_HEIGHT = 36;

private final Consumer<Module<?>> callback;
Expand All @@ -51,8 +51,8 @@ public class GuiModuleScrollList extends GuiScrollList {
@Nullable
private ScreenRectangle cachedTooltipRect;

public GuiModuleScrollList(IGuiWrapper gui, int x, int y, int width, int height, Supplier<ItemStack> itemSupplier, Consumer<Module<?>> callback) {
super(gui, x, y, width, height, TEXTURE_HEIGHT / 3, GuiElementHolder.HOLDER, GuiElementHolder.HOLDER_SIZE);
public GuiModuleScrollList(IGuiWrapper gui, int x, int y, int height, Supplier<ItemStack> itemSupplier, Consumer<Module<?>> callback) {
super(gui, x, y, TEXTURE_WIDTH + 8, height, TEXTURE_HEIGHT / 3, GuiElementHolder.HOLDER, GuiElementHolder.HOLDER_SIZE);
this.itemSupplier = itemSupplier;
this.callback = callback;
updateItemAndList(itemSupplier.get());
Expand Down Expand Up @@ -136,7 +136,7 @@ public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) {
if (instance != null) {
boolean enabled = instance.isEnabled();
int color = module.isExclusive(ExclusiveFlag.ANY) ? (enabled ? 0x635BD4 : 0x2E2A69) : (enabled ? titleTextColor() : 0x5E1D1D);
drawScaledScrollingString(guiGraphics, TextComponentUtil.build(module), 12, 3 + multipliedElement, TextAlignment.LEFT, color, barXShift - 14, 2, false, 0.7F);
drawScaledScrollingString(guiGraphics, TextComponentUtil.build(module), 11, 3 + multipliedElement, TextAlignment.LEFT, color, barXShift - 12, 2, false, 0.7F);
}
}
});
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/mekanism/client/gui/item/GuiSeismicReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class GuiSeismicReader extends GuiMekanism<SeismicReaderContainer> {

public GuiSeismicReader(SeismicReaderContainer container, Inventory inv, Component title) {
super(container, inv, title);
imageWidth = 147;
imageWidth = 150;
imageHeight = 182;
Player player = inv.player;
Level level = player.level();
Expand Down Expand Up @@ -100,7 +100,7 @@ public GuiSeismicReader(SeismicReaderContainer container, Inventory inv, Compone
@Override
protected void addGuiElements() {
super.addGuiElements();
addRenderableWidget(new GuiInnerScreen(this, 7, 11, 63, 50, () -> {
addRenderableWidget(new GuiInnerScreen(this, 5, 11, 69, 50, () -> {
// Get the name from the stack and render it
int currentLayer = getCurrentLayer();
if (currentLayer >= 0) {
Expand All @@ -118,13 +118,13 @@ protected void addGuiElements() {
return text;
}
return Collections.emptyList();
}));
addRenderableWidget(new GuiInnerScreen(this, 74, 11, 51, 160));
scrollBar = addRenderableWidget(new GuiScrollBar(this, 126, 25, 132, blockList::size, () -> 1));
addRenderableWidget(new GuiArrowSelection(this, 76, 81, () -> TextComponentUtil.build(minHeight + getCurrentLayer())));
upButton = addRenderableWidget(new MekanismImageButton(this, 126, 11, 14,
}).padding(3));
addRenderableWidget(new GuiInnerScreen(this, 77, 11, 51, 160));
scrollBar = addRenderableWidget(new GuiScrollBar(this, 129, 25, 132, blockList::size, () -> 1));
addRenderableWidget(new GuiArrowSelection(this, 79, 81, () -> TextComponentUtil.build(minHeight + getCurrentLayer())));
upButton = addRenderableWidget(new MekanismImageButton(this, 129, 11, 14,
MekanismUtils.getResource(ResourceType.GUI_BUTTON, "up.png"), (element, mouseX, mouseY) -> scrollBar.adjustScroll(1)));
downButton = addRenderableWidget(new MekanismImageButton(this, 126, 157, 14,
downButton = addRenderableWidget(new MekanismImageButton(this, 129, 157, 14,
MekanismUtils.getResource(ResourceType.GUI_BUTTON, "down.png"), (element, mouseX, mouseY) -> scrollBar.adjustScroll(-1)));
updateEnabledButtons();
}
Expand Down Expand Up @@ -157,7 +157,7 @@ protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX,
if (info.renderTarget == null) {
continue;
}
int renderX = 92;
int renderX = 95;
int renderY = 146 - 16 * i;
if (i == 4) {
info.render(guiGraphics, renderX, renderY);
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/mekanism/client/gui/machine/GuiPRC.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import mekanism.api.recipes.cache.CachedRecipe.OperationTracker.RecipeError;
import mekanism.client.gui.GuiConfigurableTile;
import mekanism.client.gui.element.GuiElement;
import mekanism.client.gui.element.bar.GuiVerticalPowerBar;
import mekanism.client.gui.element.gauge.GaugeType;
import mekanism.client.gui.element.gauge.GuiChemicalGauge;
Expand All @@ -20,32 +19,32 @@

public class GuiPRC extends GuiConfigurableTile<TileEntityPressurizedReactionChamber, MekanismTileContainer<TileEntityPressurizedReactionChamber>> {

private GuiElement secondGauge;

public GuiPRC(MekanismTileContainer<TileEntityPressurizedReactionChamber> container, Inventory inv, Component title) {
super(container, inv, title);
dynamicSlots = true;
imageHeight += 5;
inventoryLabelY += 5;
}

@Override
protected void addGuiElements() {
super.addGuiElements();
addRenderableWidget(new GuiEnergyTab(this, tile.getEnergyContainer(), tile::getActive));
addRenderableWidget(new GuiFluidGauge(() -> tile.inputFluidTank, () -> tile.getFluidTanks(null), GaugeType.STANDARD, this, 5, 10)
addRenderableWidget(new GuiFluidGauge(() -> tile.inputFluidTank, () -> tile.getFluidTanks(null), GaugeType.STANDARD, this, 5, 15)
.warning(WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(TileEntityPressurizedReactionChamber.NOT_ENOUGH_FLUID_INPUT_ERROR)));
secondGauge = addRenderableWidget(new GuiChemicalGauge(() -> tile.inputGasTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 28, 10)
addRenderableWidget(new GuiChemicalGauge(() -> tile.inputGasTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 28, 15)
.warning(WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(TileEntityPressurizedReactionChamber.NOT_ENOUGH_CHEMICAL_INPUT_ERROR)));
addRenderableWidget(new GuiChemicalGauge(() -> tile.outputGasTank, () -> tile.getChemicalTanks(null), GaugeType.SMALL, this, 140, 40)
addRenderableWidget(new GuiChemicalGauge(() -> tile.outputGasTank, () -> tile.getChemicalTanks(null), GaugeType.SMALL, this, 140, 45)
.warning(WarningType.NO_SPACE_IN_OUTPUT, tile.getWarningCheck(TileEntityPressurizedReactionChamber.NOT_ENOUGH_SPACE_GAS_OUTPUT_ERROR)));
addRenderableWidget(new GuiVerticalPowerBar(this, tile.getEnergyContainer(), 163, 16)
addRenderableWidget(new GuiVerticalPowerBar(this, tile.getEnergyContainer(), 163, 21)
.warning(WarningType.NOT_ENOUGH_ENERGY, tile.getWarningCheck(RecipeError.NOT_ENOUGH_ENERGY)));
addRenderableWidget(new GuiProgress(tile::getScaledProgress, ProgressType.RIGHT, this, 77, 38).recipeViewerCategory(tile))
addRenderableWidget(new GuiProgress(tile::getScaledProgress, ProgressType.RIGHT, this, 77, 43).recipeViewerCategory(tile))
.warning(WarningType.INPUT_DOESNT_PRODUCE_OUTPUT, tile.getWarningCheck(RecipeError.INPUT_DOESNT_PRODUCE_OUTPUT));
}

@Override
protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) {
renderTitleTextWithOffset(guiGraphics, secondGauge.getRelativeRight(), getXSize(), 4, TextAlignment.LEFT);
renderTitleText(guiGraphics);
renderInventoryText(guiGraphics);
super.drawForegroundText(guiGraphics, mouseX, mouseY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public PressurizedReactionEmiRecipe(MekanismEmiRecipeCategory category, RecipeHo

@Override
public void addWidgets(WidgetHolder widgetHolder) {
addSlot(widgetHolder, SlotType.INPUT, 54, 35, input(0));
addSlot(widgetHolder, SlotType.OUTPUT, 116, 35, output(0)).recipeContext(this);
addSlot(widgetHolder, SlotType.POWER, 141, 17).with(SlotOverlay.POWER);
initTank(widgetHolder, GuiFluidGauge.getDummy(GaugeType.STANDARD.with(DataType.INPUT), this, 5, 10), input(1));
addSlot(widgetHolder, SlotType.INPUT, 54, 40, input(0));
addSlot(widgetHolder, SlotType.OUTPUT, 116, 40, output(0)).recipeContext(this);
addSlot(widgetHolder, SlotType.POWER, 141, 22).with(SlotOverlay.POWER);
initTank(widgetHolder, GuiFluidGauge.getDummy(GaugeType.STANDARD.with(DataType.INPUT), this, 5, 15), input(1));
GaugeType type1 = GaugeType.STANDARD.with(DataType.INPUT);
initTank(widgetHolder, GuiChemicalGauge.getDummy(type1, this, 28, 10), input(2));
initTank(widgetHolder, GuiChemicalGauge.getDummy(type1, this, 28, 15), input(2));
GaugeType type = GaugeType.SMALL.with(DataType.OUTPUT);
initTank(widgetHolder, GuiChemicalGauge.getDummy(type, this, 140, 40), output(1)).recipeContext(this);
addElement(widgetHolder, new GuiVerticalPowerBar(this, RecipeViewerUtils.FULL_BAR, 164, 15));
addSimpleProgress(widgetHolder, ProgressType.RIGHT, 77, 38, recipe.getDuration());
initTank(widgetHolder, GuiChemicalGauge.getDummy(type, this, 140, 45), output(1)).recipeContext(this);
addElement(widgetHolder, new GuiVerticalPowerBar(this, RecipeViewerUtils.FULL_BAR, 164, 21));
addSimpleProgress(widgetHolder, ProgressType.RIGHT, 77, 43, recipe.getDuration());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ public class PressurizedReactionRecipeCategory extends HolderRecipeCategory<Pres

public PressurizedReactionRecipeCategory(IGuiHelper helper, IRecipeViewerRecipeType<PressurizedReactionRecipe> recipeType) {
super(helper, recipeType);
inputItem = addSlot(SlotType.INPUT, 54, 35);
outputItem = addSlot(SlotType.OUTPUT, 116, 35);
addSlot(SlotType.POWER, 141, 17).with(SlotOverlay.POWER);
inputFluid = addElement(GuiFluidGauge.getDummy(GaugeType.STANDARD.with(DataType.INPUT), this, 5, 10));
inputItem = addSlot(SlotType.INPUT, 54, 40);
outputItem = addSlot(SlotType.OUTPUT, 116, 40);
addSlot(SlotType.POWER, 141, 22).with(SlotOverlay.POWER);
inputFluid = addElement(GuiFluidGauge.getDummy(GaugeType.STANDARD.with(DataType.INPUT), this, 5, 15));
GaugeType type1 = GaugeType.STANDARD.with(DataType.INPUT);
inputChemical = addElement(GuiChemicalGauge.getDummy(type1, this, 28, 10));
inputChemical = addElement(GuiChemicalGauge.getDummy(type1, this, 28, 15));
GaugeType type = GaugeType.SMALL.with(DataType.OUTPUT);
outputChemical = addElement(GuiChemicalGauge.getDummy(type, this, 140, 40));
addElement(new GuiVerticalPowerBar(this, RecipeViewerUtils.FULL_BAR, 164, 15));
addSimpleProgress(ProgressType.RIGHT, 77, 38);
outputChemical = addElement(GuiChemicalGauge.getDummy(type, this, 140, 45));
addElement(new GuiVerticalPowerBar(this, RecipeViewerUtils.FULL_BAR, 164, 21));
addSimpleProgress(ProgressType.RIGHT, 77, 43);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private RecipeViewerRecipeType() {

//Note: This previously had a lang key for a shorter string. Though ideally especially due to translations we will eventually instead just make the text scale
//TODO - 1.20.4: Re-evaluate ^^
public static final RVRecipeTypeWrapper<?, PressurizedReactionRecipe, ?> REACTION = new RVRecipeTypeWrapper<>(MekanismRecipeType.REACTION, PressurizedReactionRecipe.class, -3, -10, 170, 60, MekanismBlocks.PRESSURIZED_REACTION_CHAMBER);
public static final RVRecipeTypeWrapper<?, PressurizedReactionRecipe, ?> REACTION = new RVRecipeTypeWrapper<>(MekanismRecipeType.REACTION, PressurizedReactionRecipe.class, -3, -15, 170, 60, MekanismBlocks.PRESSURIZED_REACTION_CHAMBER);

public static final RotaryRVRecipeType CONDENSENTRATING = new RotaryRVRecipeType(Mekanism.rl("condensentrating"), MekanismLang.CONDENSENTRATING);
public static final RotaryRVRecipeType DECONDENSENTRATING = new RotaryRVRecipeType(Mekanism.rl("decondensentrating"), MekanismLang.DECONDENSENTRATING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public boolean mayPlace(@NotNull ItemStack stack) {
});
}
for (int slotY = 0; slotY < Inventory.getSelectionSize(); slotY++) {
addSlot(new HotBarSlot(inv, slotY, 43 + slotY * 18, 161) {
addSlot(new HotBarSlot(inv, slotY, 58 + slotY * 18, 161) {
@Override
public boolean mayPickup(@NotNull Player player) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private MekanismContainerTypes() {
public static final ContainerTypeRegistryObject<MekanismTileContainer<TileEntityOredictionificator>> OREDICTIONIFICATOR = CONTAINER_TYPES.custom(MekanismBlocks.OREDICTIONIFICATOR, TileEntityOredictionificator.class).offset(30, 64).build();
public static final ContainerTypeRegistryObject<MekanismTileContainer<TileEntityOsmiumCompressor>> OSMIUM_COMPRESSOR = CONTAINER_TYPES.register(MekanismBlocks.OSMIUM_COMPRESSOR, TileEntityOsmiumCompressor.class);
public static final ContainerTypeRegistryObject<MekanismTileContainer<TileEntityPrecisionSawmill>> PRECISION_SAWMILL = CONTAINER_TYPES.register(MekanismBlocks.PRECISION_SAWMILL, TileEntityPrecisionSawmill.class);
public static final ContainerTypeRegistryObject<MekanismTileContainer<TileEntityPressurizedReactionChamber>> PRESSURIZED_REACTION_CHAMBER = CONTAINER_TYPES.register(MekanismBlocks.PRESSURIZED_REACTION_CHAMBER, TileEntityPressurizedReactionChamber.class);
public static final ContainerTypeRegistryObject<MekanismTileContainer<TileEntityPressurizedReactionChamber>> PRESSURIZED_REACTION_CHAMBER = CONTAINER_TYPES.custom(MekanismBlocks.PRESSURIZED_REACTION_CHAMBER, TileEntityPressurizedReactionChamber.class).offset(0, 5).build();
public static final ContainerTypeRegistryObject<MekanismTileContainer<TileEntityPurificationChamber>> PURIFICATION_CHAMBER = CONTAINER_TYPES.register(MekanismBlocks.PURIFICATION_CHAMBER, TileEntityPurificationChamber.class);
public static final ContainerTypeRegistryObject<MekanismTileContainer<TileEntityQuantumEntangloporter>> QUANTUM_ENTANGLOPORTER = CONTAINER_TYPES.custom(MekanismBlocks.QUANTUM_ENTANGLOPORTER, TileEntityQuantumEntangloporter.class).offset(0, 74).build();
public static final ContainerTypeRegistryObject<MekanismTileContainer<TileEntityResistiveHeater>> RESISTIVE_HEATER = CONTAINER_TYPES.register(MekanismBlocks.RESISTIVE_HEATER, TileEntityResistiveHeater.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected IInventorySlotHolder getInitialInventory(IContentsListener listener) {
moduleSlot.setSlotType(ContainerSlotType.NORMAL);
moduleSlot.setSlotOverlay(SlotOverlay.MODULE);
containerSlot.setSlotType(ContainerSlotType.NORMAL);
builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, listener, 149, 21));
builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, listener, 151, 21));
return builder.build();
}

Expand Down
Loading

0 comments on commit dad6311

Please sign in to comment.