diff --git a/src/datagen/generated/mekanism/.cache/2ca94f3a6e22cb9eec299788405fc6e4ad158c09 b/src/datagen/generated/mekanism/.cache/2ca94f3a6e22cb9eec299788405fc6e4ad158c09 index c2c464f3ea9..2459bef7e61 100644 --- a/src/datagen/generated/mekanism/.cache/2ca94f3a6e22cb9eec299788405fc6e4ad158c09 +++ b/src/datagen/generated/mekanism/.cache/2ca94f3a6e22cb9eec299788405fc6e4ad158c09 @@ -1,6 +1,6 @@ -// 1.21.1 2024-08-26T11:19:54.2186095 ComputerHelp: mekanism +// 1.21.1 2024-09-28T11:00:15.3012517 ComputerHelp: mekanism 740491ca25c3ff0efd50f10d2427e4ceccb0c1e1 data/mekanism/computer_help/enums.csv e43ab1d9e5ae68f834035609a85af3c6ce4161a4 data/mekanism/computer_help/enums.json -7af50c5e4ca7a140661622533860cafbed24c64d data/mekanism/computer_help/jekyll.md +a61020bfab0b0525339f1b49417d2f7e17dbc7df data/mekanism/computer_help/jekyll.md 0442f235be0f36db5728aaf942c99e9c8638f662 data/mekanism/computer_help/methods.csv 366f1717990ae1860dc4739af4a8f441cd0acad5 data/mekanism/computer_help/methods.json diff --git a/src/datagen/generated/mekanism/.cache/c10fcd8abbb6a520fc3ac2cf14b627d36958dd55 b/src/datagen/generated/mekanism/.cache/c10fcd8abbb6a520fc3ac2cf14b627d36958dd55 index 0787aa9ffec..00b567bbc28 100644 --- a/src/datagen/generated/mekanism/.cache/c10fcd8abbb6a520fc3ac2cf14b627d36958dd55 +++ b/src/datagen/generated/mekanism/.cache/c10fcd8abbb6a520fc3ac2cf14b627d36958dd55 @@ -1,5 +1,5 @@ -// 1.21.1 2024-08-24T23:59:23.1423828 Languages: en_us for mod: mekanism +// 1.21.1 2024-09-28T11:00:15.3042814 Languages: en_us for mod: mekanism 8d915354d84b3a4d60c65f9280fdd7ceca016c35 assets/mekanism/lang/en_au.json 8d915354d84b3a4d60c65f9280fdd7ceca016c35 assets/mekanism/lang/en_gb.json -28d2fb3189f404bc44f12679cf7835e080185937 assets/mekanism/lang/en_ud.json -52699badc3d935f327983b454e5299e066efd880 assets/mekanism/lang/en_us.json +2cd403d1dc72293441a4c86b1b1ddc05978130e8 assets/mekanism/lang/en_ud.json +525157cafd0048a56223755ff5b66a357d3008b4 assets/mekanism/lang/en_us.json diff --git a/src/datagen/generated/mekanism/assets/mekanism/lang/en_ud.json b/src/datagen/generated/mekanism/assets/mekanism/lang/en_ud.json index bd296e74c3c..0d8f56e1208 100644 --- a/src/datagen/generated/mekanism/assets/mekanism/lang/en_ud.json +++ b/src/datagen/generated/mekanism/assets/mekanism/lang/en_ud.json @@ -2131,7 +2131,7 @@ "dictionary.mekanism.attribute.desc": "sᵷɐ⟘ ǝʇnqᴉɹʇʇⱯ ʎɐꞁdsᴉᗡ", "dictionary.mekanism.block": "ʞɔoꞁᗺ", "dictionary.mekanism.block.desc": "sᵷɐ⟘ ʞɔoꞁᗺ ʎɐꞁdsᴉᗡ", - "dictionary.mekanism.block_entity_type": "ǝdʎ⟘ ʎʇᴉʇuƎ ʞɔoꞁᗺ", + "dictionary.mekanism.block_entity_type": "ǝdʎ⟘ Ǝᗺ", "dictionary.mekanism.block_entity_type.desc": "sᵷɐ⟘ ǝdʎ⟘ ʎʇᴉʇuƎ ʞɔoꞁᗺ ʎɐꞁdsᴉᗡ", "dictionary.mekanism.chemical": "ꞁɐɔᴉɯǝɥƆ", "dictionary.mekanism.chemical.desc": "sᵷɐ⟘ ꞁɐɔᴉɯǝɥƆ ʎɐꞁdsᴉᗡ", diff --git a/src/datagen/generated/mekanism/assets/mekanism/lang/en_us.json b/src/datagen/generated/mekanism/assets/mekanism/lang/en_us.json index 3c10ae75f97..d78477a49c4 100644 --- a/src/datagen/generated/mekanism/assets/mekanism/lang/en_us.json +++ b/src/datagen/generated/mekanism/assets/mekanism/lang/en_us.json @@ -2132,7 +2132,7 @@ "dictionary.mekanism.attribute.desc": "Display Attribute Tags", "dictionary.mekanism.block": "Block", "dictionary.mekanism.block.desc": "Display Block Tags", - "dictionary.mekanism.block_entity_type": "Block Entity Type", + "dictionary.mekanism.block_entity_type": "BE Type", "dictionary.mekanism.block_entity_type.desc": "Display Block Entity Type Tags", "dictionary.mekanism.chemical": "Chemical", "dictionary.mekanism.chemical.desc": "Display Chemical Tags", diff --git a/src/datagen/generated/mekanism/data/mekanism/computer_help/jekyll.md b/src/datagen/generated/mekanism/data/mekanism/computer_help/jekyll.md index 910ba5bb439..8816e3b2faf 100644 --- a/src/datagen/generated/mekanism/data/mekanism/computer_help/jekyll.md +++ b/src/datagen/generated/mekanism/data/mekanism/computer_help/jekyll.md @@ -4495,5 +4495,5 @@ methods: returns: java_type: boolean type: boolean -version: 10.7.5 +version: 10.7.7 --- diff --git a/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java b/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java index 1d8dd9cf477..4cec72f0704 100644 --- a/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java +++ b/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java @@ -1244,7 +1244,7 @@ private void addMisc() { add(MekanismLang.DICTIONARY_MOB_EFFECT_DESC, "Display Mob Effect Tags"); add(MekanismLang.DICTIONARY_ENCHANTMENT, "Enchantment"); add(MekanismLang.DICTIONARY_ENCHANTMENT_DESC, "Display Enchantment Tags"); - add(MekanismLang.DICTIONARY_BLOCK_ENTITY_TYPE, "Block Entity Type"); + add(MekanismLang.DICTIONARY_BLOCK_ENTITY_TYPE, "BE Type"); add(MekanismLang.DICTIONARY_BLOCK_ENTITY_TYPE_DESC, "Display Block Entity Type Tags"); add(MekanismLang.DICTIONARY_CHEMICAL, "Chemical"); add(MekanismLang.DICTIONARY_CHEMICAL_DESC, "Display Chemical Tags"); diff --git a/src/datagen/main/java/mekanism/common/integration/crafttweaker/example/component/CrTExampleRecipeComponentBuilder.java b/src/datagen/main/java/mekanism/common/integration/crafttweaker/example/component/CrTExampleRecipeComponentBuilder.java index 0ccd56d16ca..58350e82404 100644 --- a/src/datagen/main/java/mekanism/common/integration/crafttweaker/example/component/CrTExampleRecipeComponentBuilder.java +++ b/src/datagen/main/java/mekanism/common/integration/crafttweaker/example/component/CrTExampleRecipeComponentBuilder.java @@ -274,7 +274,7 @@ private void validate() { for (RecipeMethod method : methods) { if (!method.hasExample) { StringBuilder signature = new StringBuilder(method.methodName); - signature.append("("); + signature.append('('); method.appendParameters(signature, (sb, name, type, generic) -> { sb.append(type.getSimpleName()) .append(' ') @@ -285,7 +285,7 @@ private void validate() { .append('>'); } }); - signature.append(")"); + signature.append(')'); throw new RuntimeException("Recipe method: '" + signature + "' has no example usage declared."); } } diff --git a/src/generators/java/mekanism/generators/client/gui/GuiBioGenerator.java b/src/generators/java/mekanism/generators/client/gui/GuiBioGenerator.java index fe8c2d3f24d..79c82a7a375 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiBioGenerator.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiBioGenerator.java @@ -47,7 +47,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/generators/java/mekanism/generators/client/gui/GuiFissionReactor.java b/src/generators/java/mekanism/generators/client/gui/GuiFissionReactor.java index 91c63be0a98..c977f55d6f6 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiFissionReactor.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiFissionReactor.java @@ -66,7 +66,7 @@ protected void addGuiElements() { MekanismLang.TEMPERATURE.translate(tile.getTempColor(), MekanismUtils.getTemperatureDisplay(multiblock.heatCapacitor.getTemperature(), TemperatureUnit.KELVIN, true)), GeneratorsLang.FISSION_DAMAGE.translate(tile.getDamageColor(), tile.getDamageString()) ); - }).spacing(2).recipeViewerCategories(GeneratorsRVRecipeType.FISSION)); + }).spacing(1).recipeViewerCategories(GeneratorsRVRecipeType.FISSION)); addRenderableWidget(new GuiMergedTankGauge<>(() -> tile.getMultiblock().coolantTank, tile::getMultiblock, GaugeType.STANDARD, this, 6, 13) .setLabel(GeneratorsLang.FISSION_COOLANT_TANK.translateColored(EnumColor.AQUA))); addRenderableWidget(new GuiChemicalGauge(() -> tile.getMultiblock().fuelTank, () -> tile.getMultiblock().getChemicalTanks((Direction) null), GaugeType.STANDARD, this, 25, 13) @@ -133,9 +133,9 @@ private void updateButtons() { protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { updateButtons(); renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); - drawString(guiGraphics, MekanismLang.TEMPERATURE_LONG.translate(""), 6, 93, titleTextColor()); - drawString(guiGraphics, GeneratorsLang.FISSION_HEAT_GRAPH.translate(), 6, 114, titleTextColor()); + renderInventoryText(guiGraphics); + drawScrollingString(guiGraphics, MekanismLang.TEMPERATURE_LONG.translate(""), 0, 93, TextAlignment.LEFT, titleTextColor(), 5, false); + drawScrollingString(guiGraphics, GeneratorsLang.FISSION_HEAT_GRAPH.translate(), 0, 114, TextAlignment.LEFT, titleTextColor(), 5, false); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/generators/java/mekanism/generators/client/gui/GuiFissionReactorLogicAdapter.java b/src/generators/java/mekanism/generators/client/gui/GuiFissionReactorLogicAdapter.java index 7f854a4f6a6..7faeb75f2ad 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiFissionReactorLogicAdapter.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiFissionReactorLogicAdapter.java @@ -26,16 +26,17 @@ public class GuiFissionReactorLogicAdapter extends GuiMekanismTile 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)); } } @@ -48,8 +49,8 @@ private void changeLogic(FissionReactorLogic type) { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawTextScaledBound(guiGraphics, GeneratorsLang.REACTOR_LOGIC_REDSTONE_MODE.translate(tile.logicType.getColor(), tile.logicType), 16, 123, titleTextColor(), 144); - drawCenteredText(guiGraphics, MekanismLang.STATUS.translate(EnumColor.RED, tile.getStatus()), 0, imageWidth, 136, titleTextColor()); + 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); } diff --git a/src/generators/java/mekanism/generators/client/gui/GuiFissionReactorStats.java b/src/generators/java/mekanism/generators/client/gui/GuiFissionReactorStats.java index 7593479c3bc..d5e0eeb603e 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiFissionReactorStats.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiFissionReactorStats.java @@ -84,16 +84,17 @@ protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, renderTitleText(guiGraphics); FissionReactorMultiblockData multiblock = tile.getMultiblock(); // heat stats - drawTextScaledBound(guiGraphics, GeneratorsLang.FISSION_HEAT_STATISTICS.translate(), 6, 20, headingTextColor(), imageWidth - 12); - drawTextScaledBound(guiGraphics, GeneratorsLang.FISSION_HEAT_CAPACITY.translate(TextUtils.format((long) multiblock.heatCapacitor.getHeatCapacity())), 6, 32, titleTextColor(), imageWidth - 12); - drawTextScaledBound(guiGraphics, GeneratorsLang.FISSION_SURFACE_AREA.translate(TextUtils.format(multiblock.surfaceArea)), 6, 42, titleTextColor(), imageWidth - 12); - drawTextScaledBound(guiGraphics, GeneratorsLang.FISSION_BOIL_EFFICIENCY.translate(tile.getBoilEfficiency()), 6, 52, titleTextColor(), imageWidth - 12); + drawScrollingString(guiGraphics, GeneratorsLang.FISSION_HEAT_STATISTICS.translate(), 0, 20, TextAlignment.LEFT, headingTextColor(), 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.FISSION_HEAT_CAPACITY.translate(TextUtils.format((long) multiblock.heatCapacitor.getHeatCapacity())), 0, 32, TextAlignment.LEFT, titleTextColor(), 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.FISSION_SURFACE_AREA.translate(TextUtils.format(multiblock.surfaceArea)), 0, 42, TextAlignment.LEFT, titleTextColor(), 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.FISSION_BOIL_EFFICIENCY.translate(tile.getBoilEfficiency()), 0, 52, TextAlignment.LEFT, titleTextColor(), 6, false); // fuel stats - drawTextScaledBound(guiGraphics, GeneratorsLang.FISSION_FUEL_STATISTICS.translate(), 6, 68, headingTextColor(), imageWidth - 12); - drawTextScaledBound(guiGraphics, GeneratorsLang.FISSION_MAX_BURN_RATE.translate(TextUtils.format(multiblock.getMaxBurnRate())), 6, 80, titleTextColor(), imageWidth - 12); - drawTextScaledBound(guiGraphics, GeneratorsLang.FISSION_RATE_LIMIT.translate(multiblock.rateLimit), 6, 90, titleTextColor(), imageWidth - 12); - drawTextScaledBound(guiGraphics, GeneratorsLang.FISSION_CURRENT_BURN_RATE.translate(), 6, 104, titleTextColor(), imageWidth - 12); - drawTextScaledBound(guiGraphics, GeneratorsLang.FISSION_SET_RATE_LIMIT.translate(), 6, 130, titleTextColor(), 69); + drawScrollingString(guiGraphics, GeneratorsLang.FISSION_FUEL_STATISTICS.translate(), 0, 68, TextAlignment.LEFT, headingTextColor(), 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.FISSION_MAX_BURN_RATE.translate(TextUtils.format(multiblock.getMaxBurnRate())), 0, 80, TextAlignment.LEFT, titleTextColor(), 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.FISSION_RATE_LIMIT.translate(multiblock.rateLimit), 0, 90, TextAlignment.LEFT, titleTextColor(), 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.FISSION_CURRENT_BURN_RATE.translate(), 0, 104, TextAlignment.LEFT, titleTextColor(), 6, false); + + drawScrollingString(guiGraphics, GeneratorsLang.FISSION_SET_RATE_LIMIT.translate(), 3, 130, TextAlignment.RIGHT, titleTextColor(), rateLimitField.getRelativeX() - 2, 3, false); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorController.java b/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorController.java index a057299a21f..1d0803b38ea 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorController.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorController.java @@ -24,6 +24,8 @@ public class GuiFusionReactorController extends GuiMekanismTile container, Inventory inv, Component title) { super(container, inv, title); dynamicSlots = true; + imageWidth += 10; + inventoryLabelX += 5; titleLabelY = 5; } @@ -52,7 +54,8 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, MekanismLang.MULTIBLOCK_FORMED.translate(), 8, 16, titleTextColor()); + renderInventoryText(guiGraphics); + drawScrollingString(guiGraphics, MekanismLang.MULTIBLOCK_FORMED.translate(), 0, 16, TextAlignment.LEFT, titleTextColor(), 13, false); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorFuel.java b/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorFuel.java index 0662b412937..3cc09a321f5 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorFuel.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorFuel.java @@ -30,14 +30,14 @@ public GuiFusionReactorFuel(EmptyTileContainer tile.getMultiblock().deuteriumTank, () -> tile.getMultiblock().getChemicalTanks(null), GaugeType.SMALL, this, 25, 64)); - addRenderableWidget(new GuiChemicalGauge(() -> tile.getMultiblock().fuelTank, () -> tile.getMultiblock().getChemicalTanks(null), GaugeType.STANDARD, this, 79, 50)); - addRenderableWidget(new GuiChemicalGauge(() -> tile.getMultiblock().tritiumTank, () -> tile.getMultiblock().getChemicalTanks(null), GaugeType.SMALL, this, 133, 64)); - addRenderableWidget(new GuiProgress(() -> tile.getMultiblock().isBurning(), ProgressType.SMALL_RIGHT, this, 47, 76)); - addRenderableWidget(new GuiProgress(() -> tile.getMultiblock().isBurning(), ProgressType.SMALL_LEFT, this, 101, 76)); + addRenderableWidget(new GuiChemicalGauge(() -> tile.getMultiblock().deuteriumTank, () -> tile.getMultiblock().getChemicalTanks(null), GaugeType.SMALL, this, 30, 64)); + addRenderableWidget(new GuiChemicalGauge(() -> tile.getMultiblock().fuelTank, () -> tile.getMultiblock().getChemicalTanks(null), GaugeType.STANDARD, this, 84, 50)); + addRenderableWidget(new GuiChemicalGauge(() -> tile.getMultiblock().tritiumTank, () -> tile.getMultiblock().getChemicalTanks(null), GaugeType.SMALL, this, 138, 64)); + addRenderableWidget(new GuiProgress(() -> tile.getMultiblock().isBurning(), ProgressType.SMALL_RIGHT, this, 52, 76)); + addRenderableWidget(new GuiProgress(() -> tile.getMultiblock().isBurning(), ProgressType.SMALL_LEFT, this, 106, 76)); addRenderableWidget(new GuiFusionReactorTab(this, tile, FusionReactorTab.HEAT)); addRenderableWidget(new GuiFusionReactorTab(this, tile, FusionReactorTab.STAT)); - injectionRateField = addRenderableWidget(new GuiTextField(this, 98, 115, 26, 11)); + injectionRateField = addRenderableWidget(new GuiTextField(this, 103, 115, 26, 11)); injectionRateField.setInputValidator(InputValidator.DIGIT) .setEnterHandler(this::setInjection) .setMaxLength(2); @@ -46,9 +46,8 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - renderTitleText(guiGraphics); - drawCenteredText(guiGraphics, GeneratorsLang.REACTOR_INJECTION_RATE.translate(tile.getMultiblock().getInjectionRate()), 0, imageWidth, 35, titleTextColor()); - drawString(guiGraphics, GeneratorsLang.REACTOR_EDIT_RATE.translate(), 50, 117, titleTextColor()); + drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_INJECTION_RATE.translate(tile.getMultiblock().getInjectionRate()), 0, 35, TextAlignment.CENTER, titleTextColor(), 16, false); + drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_EDIT_RATE.translate(), 4, 117, TextAlignment.RIGHT, titleTextColor(), 99, 2, false); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorHeat.java b/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorHeat.java index 4d6ae4f24bf..fe9a8a4138c 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorHeat.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorHeat.java @@ -18,12 +18,10 @@ import mekanism.generators.common.GeneratorsLang; import mekanism.generators.common.content.fusion.FusionReactorMultiblockData; import mekanism.generators.common.tile.fusion.TileEntityFusionReactorController; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.level.material.Fluids; -import org.jetbrains.annotations.NotNull; public class GuiFusionReactorHeat extends GuiFusionReactorInfo { @@ -56,11 +54,11 @@ public double getScaledLevel() { public Component getText() { return GeneratorsLang.REACTOR_PLASMA.translate(MekanismUtils.getTemperatureDisplay(getLevel(), TemperatureUnit.KELVIN, true)); } - }, GaugeType.STANDARD, this, 7, 50)); + }, GaugeType.STANDARD, this, 12, 50)); addRenderableWidget(new GuiProgress(() -> { FusionReactorMultiblockData multiblock = tile.getMultiblock(); return multiblock.getLastPlasmaTemp() > multiblock.getLastCaseTemp(); - }, ProgressType.SMALL_RIGHT, this, 29, 76)); + }, ProgressType.SMALL_RIGHT, this, 34, 76)); addRenderableWidget(new GuiNumberGauge(new INumberInfoHandler() { @Override public TextureAtlasSprite getIcon() { @@ -81,22 +79,16 @@ public double getScaledLevel() { public Component getText() { return GeneratorsLang.REACTOR_CASE.translate(MekanismUtils.getTemperatureDisplay(getLevel(), TemperatureUnit.KELVIN, true)); } - }, GaugeType.STANDARD, this, 61, 50)); - addRenderableWidget(new GuiProgress(() -> tile.getMultiblock().getCaseTemp() > 0, ProgressType.SMALL_RIGHT, this, 83, 61)); + }, GaugeType.STANDARD, this, 66, 50)); + addRenderableWidget(new GuiProgress(() -> tile.getMultiblock().getCaseTemp() > 0, ProgressType.SMALL_RIGHT, this, 88, 61)); addRenderableWidget(new GuiProgress(() -> { FusionReactorMultiblockData multiblock = tile.getMultiblock(); return multiblock.getCaseTemp() > 0 && !multiblock.waterTank.isEmpty() && multiblock.steamTank.getStored() < multiblock.steamTank.getCapacity(); - }, ProgressType.SMALL_RIGHT, this, 83, 91)); - addRenderableWidget(new GuiFluidGauge(() -> tile.getMultiblock().waterTank, () -> tile.getFluidTanks(null), GaugeType.SMALL, this, 115, 84)); - addRenderableWidget(new GuiChemicalGauge(() -> tile.getMultiblock().steamTank, () -> tile.getChemicalTanks(null), GaugeType.SMALL, this, 151, 84)); - addRenderableWidget(new GuiEnergyGauge(tile.getMultiblock().energyContainer, GaugeType.SMALL, this, 115, 46)); + }, ProgressType.SMALL_RIGHT, this, 88, 91)); + addRenderableWidget(new GuiFluidGauge(() -> tile.getMultiblock().waterTank, () -> tile.getFluidTanks(null), GaugeType.SMALL, this, 120, 84)); + addRenderableWidget(new GuiChemicalGauge(() -> tile.getMultiblock().steamTank, () -> tile.getChemicalTanks(null), GaugeType.SMALL, this, 156, 84)); + addRenderableWidget(new GuiEnergyGauge(tile.getMultiblock().energyContainer, GaugeType.SMALL, this, 120, 46)); addRenderableWidget(new GuiFusionReactorTab(this, tile, FusionReactorTab.FUEL)); addRenderableWidget(new GuiFusionReactorTab(this, tile, FusionReactorTab.STAT)); } - - @Override - protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - renderTitleText(guiGraphics); - super.drawForegroundText(guiGraphics, mouseX, mouseY); - } } \ No newline at end of file diff --git a/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorInfo.java b/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorInfo.java index 7e28d4832e5..49acc15fb27 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorInfo.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorInfo.java @@ -17,13 +17,16 @@ import mekanism.generators.common.GeneratorsLang; import mekanism.generators.common.content.fusion.FusionReactorMultiblockData; import mekanism.generators.common.tile.fusion.TileEntityFusionReactorController; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Inventory; +import org.jetbrains.annotations.NotNull; public abstract class GuiFusionReactorInfo extends GuiMekanismTile> { protected GuiFusionReactorInfo(EmptyTileContainer container, Inventory inv, Component title) { super(container, inv, title); + imageWidth += 10; titleLabelY = 5; } @@ -45,4 +48,10 @@ protected void addGuiElements() { return List.of(MekanismLang.TRANSFERRED_RATE.translate(transfer), MekanismLang.DISSIPATED_RATE.translate(environment)); })); } + + @Override + protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { + renderTitleTextWithOffset(guiGraphics, 18);//Adjust spacing for back button + super.drawForegroundText(guiGraphics, mouseX, mouseY); + } } \ No newline at end of file diff --git a/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorLogicAdapter.java b/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorLogicAdapter.java index e3d09b92228..f1d7dee8507 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorLogicAdapter.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorLogicAdapter.java @@ -30,19 +30,20 @@ public class GuiFusionReactorLogicAdapter extends GuiMekanismTile 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)); } } @@ -55,10 +56,11 @@ private void changeLogic(FusionReactorLogic type) { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawTextScaledBound(guiGraphics, GeneratorsLang.REACTOR_LOGIC_ACTIVE_COOLING.translate(EnumColor.RED, OnOff.of(tile.isActiveCooled())), 29, 20, titleTextColor(), 117); - drawTextScaledBound(guiGraphics, GeneratorsLang.REACTOR_LOGIC_REDSTONE_MODE.translate(EnumColor.RED, tile.logicType), 16, 123, titleTextColor(), 144); - drawCenteredText(guiGraphics, MekanismLang.STATUS.translate(EnumColor.RED, tile.checkMode() ? GeneratorsLang.REACTOR_LOGIC_OUTPUTTING : MekanismLang.IDLE), - 0, imageWidth, 136, titleTextColor()); + 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(), 4, false); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorStats.java b/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorStats.java index 5b2739f3778..34273405268 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorStats.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiFusionReactorStats.java @@ -31,32 +31,37 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - renderTitleText(guiGraphics); FusionReactorMultiblockData multiblock = tile.getMultiblock(); if (multiblock.isFormed()) { - drawString(guiGraphics, GeneratorsLang.REACTOR_PASSIVE.translateColored(EnumColor.DARK_GREEN), 6, 26, titleTextColor()); - drawTextScaledBound(guiGraphics, GeneratorsLang.REACTOR_MIN_INJECTION.translate(multiblock.getMinInjectionRate(false)), 16, 36, titleTextColor(), 156); - drawTextScaledBound(guiGraphics, GeneratorsLang.REACTOR_IGNITION.translate(MekanismUtils.getTemperatureDisplay(multiblock.getIgnitionTemperature(false), - TemperatureUnit.KELVIN, true)), 16, 46, titleTextColor(), 156); - drawTextScaledBound(guiGraphics, GeneratorsLang.REACTOR_MAX_PLASMA.translate(MekanismUtils.getTemperatureDisplay(multiblock.getMaxPlasmaTemperature(false), - TemperatureUnit.KELVIN, true)), 16, 56, titleTextColor(), 156); - drawTextScaledBound(guiGraphics, GeneratorsLang.REACTOR_MAX_CASING.translate(MekanismUtils.getTemperatureDisplay(multiblock.getMaxCasingTemperature(false), - TemperatureUnit.KELVIN, true)), 16, 66, titleTextColor(), 156); - drawTextScaledBound(guiGraphics, GeneratorsLang.REACTOR_PASSIVE_RATE.translate(EnergyDisplay.of(multiblock.getPassiveGeneration(false, false))), - 16, 76, titleTextColor(), 156); + int indentation = 4; + int textArea = getXSize() - indentation; + drawScrollingString(guiGraphics,GeneratorsLang.REACTOR_PASSIVE.translateColored(EnumColor.DARK_GREEN), + 0, 26, TextAlignment.LEFT, titleTextColor(), 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_MIN_INJECTION.translate(multiblock.getMinInjectionRate(false)), + indentation, 36, TextAlignment.LEFT, titleTextColor(), textArea, 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_IGNITION.translate(MekanismUtils.getTemperatureDisplay(multiblock.getIgnitionTemperature(false), TemperatureUnit.KELVIN, true)), + indentation, 46, TextAlignment.LEFT, titleTextColor(), textArea, 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_MAX_PLASMA.translate(MekanismUtils.getTemperatureDisplay(multiblock.getMaxPlasmaTemperature(false), TemperatureUnit.KELVIN, true)), + indentation, 56, TextAlignment.LEFT, titleTextColor(), textArea, 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_MAX_CASING.translate(MekanismUtils.getTemperatureDisplay(multiblock.getMaxCasingTemperature(false), TemperatureUnit.KELVIN, true)), + indentation, 66, TextAlignment.LEFT, titleTextColor(), textArea, 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_PASSIVE_RATE.translate(EnergyDisplay.of(multiblock.getPassiveGeneration(false, false))), + indentation, 76, TextAlignment.LEFT, titleTextColor(), textArea, 6, false); - drawString(guiGraphics, GeneratorsLang.REACTOR_ACTIVE.translateColored(EnumColor.DARK_BLUE), 6, 92, titleTextColor()); - drawTextScaledBound(guiGraphics, GeneratorsLang.REACTOR_MIN_INJECTION.translate(multiblock.getMinInjectionRate(true)), 16, 102, titleTextColor(), 156); - drawTextScaledBound(guiGraphics, GeneratorsLang.REACTOR_IGNITION.translate(MekanismUtils.getTemperatureDisplay(multiblock.getIgnitionTemperature(true), - TemperatureUnit.KELVIN, true)), 16, 112, titleTextColor(), 156); - drawTextScaledBound(guiGraphics, GeneratorsLang.REACTOR_MAX_PLASMA.translate(MekanismUtils.getTemperatureDisplay(multiblock.getMaxPlasmaTemperature(true), - TemperatureUnit.KELVIN, true)), 16, 122, titleTextColor(), 156); - drawTextScaledBound(guiGraphics, GeneratorsLang.REACTOR_MAX_CASING.translate(MekanismUtils.getTemperatureDisplay(multiblock.getMaxCasingTemperature(true), - TemperatureUnit.KELVIN, true)), 16, 132, titleTextColor(), 156); - drawTextScaledBound(guiGraphics, GeneratorsLang.REACTOR_PASSIVE_RATE.translate(EnergyDisplay.of(multiblock.getPassiveGeneration(true, false))), - 16, 142, titleTextColor(), 156); - drawTextScaledBound(guiGraphics, GeneratorsLang.REACTOR_STEAM_PRODUCTION.translate(TextUtils.format(multiblock.getSteamPerTick(false))), - 16, 152, titleTextColor(), 156); + drawScrollingString(guiGraphics,GeneratorsLang.REACTOR_ACTIVE.translateColored(EnumColor.DARK_BLUE), + 0, 92, TextAlignment.LEFT, titleTextColor(), 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_MIN_INJECTION.translate(multiblock.getMinInjectionRate(true)), + indentation, 102, TextAlignment.LEFT, titleTextColor(), textArea, 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_IGNITION.translate(MekanismUtils.getTemperatureDisplay(multiblock.getIgnitionTemperature(true), TemperatureUnit.KELVIN, true)), + indentation, 112, TextAlignment.LEFT, titleTextColor(), textArea, 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_MAX_PLASMA.translate(MekanismUtils.getTemperatureDisplay(multiblock.getMaxPlasmaTemperature(true), TemperatureUnit.KELVIN, true)), + indentation, 122, TextAlignment.LEFT, titleTextColor(), textArea, 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_MAX_CASING.translate(MekanismUtils.getTemperatureDisplay(multiblock.getMaxCasingTemperature(true), TemperatureUnit.KELVIN, true)), + indentation, 132, TextAlignment.LEFT, titleTextColor(), textArea, 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_PASSIVE_RATE.translate(EnergyDisplay.of(multiblock.getPassiveGeneration(true, false))), + indentation, 142, TextAlignment.LEFT, titleTextColor(), textArea, 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.REACTOR_STEAM_PRODUCTION.translate(TextUtils.format(multiblock.getSteamPerTick(false))), + indentation, 152, TextAlignment.LEFT, titleTextColor(), textArea, 6, false); } super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/generators/java/mekanism/generators/client/gui/GuiGasGenerator.java b/src/generators/java/mekanism/generators/client/gui/GuiGasGenerator.java index a9baec5a9f7..f9640f790cb 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiGasGenerator.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiGasGenerator.java @@ -44,12 +44,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); - Component component = GeneratorsLang.GAS_BURN_RATE.translate(tile.getUsed()); - int left = inventoryLabelX + getStringWidth(playerInventoryTitle) + 4; - int end = imageWidth - 8; - left = Math.max(left, end - getStringWidth(component)); - drawTextScaledBound(guiGraphics, component, left, inventoryLabelY, titleTextColor(), end - left); + renderInventoryTextAndOther(guiGraphics, GeneratorsLang.GAS_BURN_RATE.translate(tile.getUsed())); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/generators/java/mekanism/generators/client/gui/GuiHeatGenerator.java b/src/generators/java/mekanism/generators/client/gui/GuiHeatGenerator.java index fda319dc548..94713ae1488 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiHeatGenerator.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiHeatGenerator.java @@ -48,7 +48,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } diff --git a/src/generators/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java b/src/generators/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java index 92e35f85b8d..4866f6b869d 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java @@ -35,6 +35,8 @@ public class GuiIndustrialTurbine extends GuiMekanismTile container, Inventory inv, Component title) { super(container, inv, title); + imageWidth += 14; + inventoryLabelX += 7; inventoryLabelY += 2; titleLabelY = 5; dynamicSlots = true; @@ -43,7 +45,7 @@ public GuiIndustrialTurbine(MekanismTileContainer conta @Override protected void addGuiElements() { super.addGuiElements(); - addRenderableWidget(new GuiInnerScreen(this, 50, 18, 112, 50, () -> { + addRenderableWidget(new GuiInnerScreen(this, 50, 18, 126, 50, () -> { List list = new ArrayList<>(); TurbineMultiblockData multiblock = tile.getMultiblock(); if (multiblock.isFormed()) { @@ -73,7 +75,7 @@ public double getLevel() { } return 1; } - }, 164, 16)); + }, 178, 16)); addRenderableWidget(new GuiVerticalRateBar(this, new IBarInfoHandler() { @Override public Component getTooltip() { @@ -112,7 +114,7 @@ public double getLevel() { return List.of(MekanismLang.STORING.translate(storing), GeneratorsLang.PRODUCING_AMOUNT.translate(producing)); })); Component warning = GeneratorsLang.TURBINE_DUMPING_STEAM_WARNING.translateColored(EnumColor.RED); - addRenderableWidget(new GuiGasMode(this, 159, 72, true, () -> tile.getMultiblock().dumpMode, tile.getBlockPos(), 0, + addRenderableWidget(new GuiGasMode(this, 173, 72, true, () -> tile.getMultiblock().dumpMode, tile.getBlockPos(), 0, TooltipUtils.create(GeneratorsLang.TURBINE_DUMPING_EXCESS_STEAM.translate(), warning), TooltipUtils.create(GeneratorsLang.TURBINE_DUMPING_STEAM.translate(), warning))); } @@ -120,7 +122,7 @@ public double getLevel() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics, 99); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/generators/java/mekanism/generators/client/gui/GuiSolarGenerator.java b/src/generators/java/mekanism/generators/client/gui/GuiSolarGenerator.java index 6f553fd2b95..befcbd98c34 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiSolarGenerator.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiSolarGenerator.java @@ -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())) @@ -47,7 +47,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } diff --git a/src/generators/java/mekanism/generators/client/gui/GuiTurbineStats.java b/src/generators/java/mekanism/generators/client/gui/GuiTurbineStats.java index 98129d8cdaf..3a34d982f45 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiTurbineStats.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiTurbineStats.java @@ -26,6 +26,7 @@ public class GuiTurbineStats extends GuiMekanismTile container, Inventory inv, Component title) { super(container, inv, title); + imageWidth += 14; } @Override @@ -60,21 +61,21 @@ protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int lowerVolume = multiblock.lowerVolume; int dispersers = multiblock.getDispersers(); int vents = multiblock.vents; - drawString(guiGraphics, GeneratorsLang.TURBINE_TANK_VOLUME.translate(lowerVolume), 8, 26, titleTextColor()); + drawScrollingString(guiGraphics, GeneratorsLang.TURBINE_TANK_VOLUME.translate(lowerVolume), 0, 26, TextAlignment.LEFT, titleTextColor(), 6, false); boolean dispersersLimiting = lowerVolume * dispersers * MekanismGeneratorsConfig.generators.turbineDisperserChemicalFlow.get() < vents * MekanismGeneratorsConfig.generators.turbineVentChemicalFlow.get(); boolean ventsLimiting = lowerVolume * dispersers * MekanismGeneratorsConfig.generators.turbineDisperserChemicalFlow.get() > vents * MekanismGeneratorsConfig.generators.turbineVentChemicalFlow.get(); - drawString(guiGraphics, GeneratorsLang.TURBINE_STEAM_FLOW.translate(), 8, 40, subheadingTextColor()); - drawString(guiGraphics, GeneratorsLang.TURBINE_DISPERSERS.translate(dispersers, dispersersLimiting ? limiting : ""), 14, 49, titleTextColor()); - drawString(guiGraphics, GeneratorsLang.TURBINE_VENTS.translate(vents, ventsLimiting ? limiting : ""), 14, 58, titleTextColor()); + drawScrollingString(guiGraphics, GeneratorsLang.TURBINE_STEAM_FLOW.translate(), 0, 40, TextAlignment.LEFT, subheadingTextColor(), 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.TURBINE_DISPERSERS.translate(dispersers, dispersersLimiting ? limiting : ""), 4, 49, TextAlignment.LEFT, titleTextColor(), getXSize() - 4, 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.TURBINE_VENTS.translate(vents, ventsLimiting ? limiting : ""), 4, 58, TextAlignment.LEFT, titleTextColor(), getXSize() - 4, 6, false); int coils = multiblock.coils; int blades = multiblock.blades; - drawString(guiGraphics, GeneratorsLang.TURBINE_PRODUCTION.translate(), 8, 72, subheadingTextColor()); - drawString(guiGraphics, GeneratorsLang.TURBINE_BLADES.translate(blades, coils * 4 > blades ? limiting : ""), 14, 81, titleTextColor()); - drawString(guiGraphics, GeneratorsLang.TURBINE_COILS.translate(coils, coils * 4 < blades ? limiting : ""), 14, 90, titleTextColor()); - drawTextScaledBound(guiGraphics, GeneratorsLang.TURBINE_MAX_PRODUCTION.translate(EnergyDisplay.of(multiblock.getMaxProduction())), 8, 104, titleTextColor(), 164); - drawTextScaledBound(guiGraphics, GeneratorsLang.TURBINE_MAX_WATER_OUTPUT.translate(TextUtils.format(multiblock.getMaxWaterOutput())), 8, 113, titleTextColor(), 164); + drawScrollingString(guiGraphics, GeneratorsLang.TURBINE_PRODUCTION.translate(), 0, 72, TextAlignment.LEFT, subheadingTextColor(), 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.TURBINE_BLADES.translate(blades, coils * 4 > blades ? limiting : ""), 4, 81, TextAlignment.LEFT, titleTextColor(), getXSize() - 4, 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.TURBINE_COILS.translate(coils, coils * 4 < blades ? limiting : ""), 4, 90, TextAlignment.LEFT, titleTextColor(), getXSize() - 4, 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.TURBINE_MAX_PRODUCTION.translate(EnergyDisplay.of(multiblock.getMaxProduction())), 0, 104, TextAlignment.LEFT, titleTextColor(), 6, false); + drawScrollingString(guiGraphics, GeneratorsLang.TURBINE_MAX_WATER_OUTPUT.translate(TextUtils.format(multiblock.getMaxWaterOutput())), 0, 113, TextAlignment.LEFT, titleTextColor(), 6, false); } super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/generators/java/mekanism/generators/client/gui/GuiWindGenerator.java b/src/generators/java/mekanism/generators/client/gui/GuiWindGenerator.java index 1d6da9502ec..c64c514df54 100644 --- a/src/generators/java/mekanism/generators/client/gui/GuiWindGenerator.java +++ b/src/generators/java/mekanism/generators/client/gui/GuiWindGenerator.java @@ -60,7 +60,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/generators/java/mekanism/generators/client/gui/element/button/ReactorLogicButton.java b/src/generators/java/mekanism/generators/client/gui/element/button/ReactorLogicButton.java index f8d9cfb9f19..d88f799db47 100644 --- a/src/generators/java/mekanism/generators/client/gui/element/button/ReactorLogicButton.java +++ b/src/generators/java/mekanism/generators/client/gui/element/button/ReactorLogicButton.java @@ -17,7 +17,7 @@ import mekanism.generators.common.base.IReactorLogicMode; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Tooltip; -import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.CommonComponents; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -27,7 +27,6 @@ public class ReactorLogicButton & IReactorLogicMode tile; - private final int typeOffset; private final Supplier<@Nullable TYPE> modeSupplier; private final Map typeTooltips; private final Consumer onPress; @@ -35,17 +34,16 @@ public class ReactorLogicButton & IReactorLogicMode tile, Class clazz, IntSupplier indexSupplier, Supplier modeList, Consumer onPress) { - this(gui, x, y, index, tile, clazz, onPress, () -> { + this(gui, x, y, tile, clazz, onPress, () -> { int i = indexSupplier.getAsInt() + index; TYPE[] modes = modeList.get(); return i >= 0 && i < modes.length ? modes[i] : null; }); } - private ReactorLogicButton(IGuiWrapper gui, int x, int y, int index, @NotNull IReactorLogic tile, Class clazz, Consumer onPress, Supplier<@Nullable TYPE> modeSupplier) { - super(gui, x, y, 128, 22, Component.empty(), (element, mouseX, mouseY) -> ((ReactorLogicButton) element).click()); + private ReactorLogicButton(IGuiWrapper gui, int x, int y, @NotNull IReactorLogic tile, Class clazz, Consumer onPress, Supplier<@Nullable TYPE> modeSupplier) { + super(gui, x, y, 128, 22, CommonComponents.EMPTY, (element, mouseX, mouseY) -> ((ReactorLogicButton) element).click()); this.onPress = onPress; - this.typeOffset = 22 * index; this.modeSupplier = modeSupplier; this.tile = tile; this.typeTooltips = new EnumMap<>(clazz); @@ -73,8 +71,8 @@ public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mou public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { TYPE mode = modeSupplier.get(); if (mode != null) { - gui().renderItem(guiGraphics, mode.getRenderStack(), 20, 35 + typeOffset); - drawString(guiGraphics, TextComponentUtil.build(EnumColor.WHITE, mode), 39, 34 + typeOffset, titleTextColor()); + gui().renderItem(guiGraphics, mode.getRenderStack(), relativeX + 3, relativeY + 3); + drawScrollingString(guiGraphics, TextComponentUtil.build(EnumColor.WHITE, mode), 20, 2, TextAlignment.LEFT, titleTextColor(), width - 20, 2, false); super.renderForeground(guiGraphics, mouseX, mouseY); } } diff --git a/src/generators/java/mekanism/generators/client/recipe_viewer/emi/recipe/FissionReactorEmiRecipe.java b/src/generators/java/mekanism/generators/client/recipe_viewer/emi/recipe/FissionReactorEmiRecipe.java index f7109648d36..f8472bc079c 100644 --- a/src/generators/java/mekanism/generators/client/recipe_viewer/emi/recipe/FissionReactorEmiRecipe.java +++ b/src/generators/java/mekanism/generators/client/recipe_viewer/emi/recipe/FissionReactorEmiRecipe.java @@ -41,7 +41,7 @@ public void addWidgets(WidgetHolder widgetHolder) { GeneratorsLang.FISSION_HEATING_RATE.translate(0), MekanismLang.TEMPERATURE.translate(EnumColor.BRIGHT_GREEN, MekanismUtils.getTemperatureDisplay(HeatAPI.AMBIENT_TEMP, TemperatureUnit.KELVIN, true)), GeneratorsLang.FISSION_DAMAGE.translate(EnumColor.BRIGHT_GREEN, TextUtils.getPercent(0)) - )).spacing(2)); + )).spacing(1)); initTank(widgetHolder, GuiFluidGauge.getDummy(GaugeType.STANDARD, this, 6, 13).setLabel(GeneratorsLang.FISSION_COOLANT_TANK.translateColored(EnumColor.AQUA)), input(0)); initTank(widgetHolder, GuiChemicalGauge.getDummy(GaugeType.STANDARD, this, 25, 13).setLabel(GeneratorsLang.FISSION_FUEL_TANK.translateColored(EnumColor.DARK_GREEN)), input(1)); initTank(widgetHolder, GuiChemicalGauge.getDummy(GaugeType.STANDARD, this, 152, 13).setLabel(GeneratorsLang.FISSION_HEATED_COOLANT_TANK.translateColored(EnumColor.GRAY)), output(0)).recipeContext(this); diff --git a/src/generators/java/mekanism/generators/client/recipe_viewer/jei/FissionReactorRecipeCategory.java b/src/generators/java/mekanism/generators/client/recipe_viewer/jei/FissionReactorRecipeCategory.java index f07f03b85a2..1a29d990be5 100644 --- a/src/generators/java/mekanism/generators/client/recipe_viewer/jei/FissionReactorRecipeCategory.java +++ b/src/generators/java/mekanism/generators/client/recipe_viewer/jei/FissionReactorRecipeCategory.java @@ -41,7 +41,7 @@ public FissionReactorRecipeCategory(IGuiHelper helper, IRecipeViewerRecipeType inverseInsulation, () -> biomeAmbientTemp, this)); - inventorySlots.add(reactorSlot = ReactorInventorySlot.at(stack -> stack.getItem() instanceof ItemHohlraum, this, 80, 39)); + inventorySlots.add(reactorSlot = ReactorInventorySlot.at(stack -> stack.getItem() instanceof ItemHohlraum, this, 85, 39)); } @Override diff --git a/src/generators/java/mekanism/generators/common/registries/GeneratorsContainerTypes.java b/src/generators/java/mekanism/generators/common/registries/GeneratorsContainerTypes.java index d061353f3e3..07590e69b95 100644 --- a/src/generators/java/mekanism/generators/common/registries/GeneratorsContainerTypes.java +++ b/src/generators/java/mekanism/generators/common/registries/GeneratorsContainerTypes.java @@ -27,11 +27,11 @@ private GeneratorsContainerTypes() { public static final ContainerTypeRegistryObject> BIO_GENERATOR = CONTAINER_TYPES.custom(GeneratorsBlocks.BIO_GENERATOR, TileEntityBioGenerator.class).armorSideBar(-20, 11, 0).build(); public static final ContainerTypeRegistryObject> GAS_BURNING_GENERATOR = CONTAINER_TYPES.custom(GeneratorsBlocks.GAS_BURNING_GENERATOR, TileEntityGasGenerator.class).armorSideBar(-20, 11, 0).build(); public static final ContainerTypeRegistryObject> HEAT_GENERATOR = CONTAINER_TYPES.custom(GeneratorsBlocks.HEAT_GENERATOR, TileEntityHeatGenerator.class).armorSideBar(-20, 11, 0).build(); - public static final ContainerTypeRegistryObject> INDUSTRIAL_TURBINE = CONTAINER_TYPES.register("industrial_turbine", TileEntityTurbineCasing.class); + public static final ContainerTypeRegistryObject> INDUSTRIAL_TURBINE = CONTAINER_TYPES.custom("industrial_turbine", TileEntityTurbineCasing.class).offset(7, 0).build(); public static final ContainerTypeRegistryObject> FISSION_REACTOR = CONTAINER_TYPES.custom("fission_reactor", TileEntityFissionReactorCasing.class).offset(10, 91).build(); public static final ContainerTypeRegistryObject> FISSION_REACTOR_STATS = CONTAINER_TYPES.registerEmpty("fission_reactor_stats", TileEntityFissionReactorCasing.class); public static final ContainerTypeRegistryObject> FISSION_REACTOR_LOGIC_ADAPTER = CONTAINER_TYPES.registerEmpty(GeneratorsBlocks.FISSION_REACTOR_LOGIC_ADAPTER, TileEntityFissionReactorLogicAdapter.class); - public static final ContainerTypeRegistryObject> FUSION_REACTOR_CONTROLLER = CONTAINER_TYPES.register(GeneratorsBlocks.FUSION_REACTOR_CONTROLLER, TileEntityFusionReactorController.class); + public static final ContainerTypeRegistryObject> FUSION_REACTOR_CONTROLLER = CONTAINER_TYPES.custom(GeneratorsBlocks.FUSION_REACTOR_CONTROLLER, TileEntityFusionReactorController.class).offset(5, 0).build(); public static final ContainerTypeRegistryObject> FUSION_REACTOR_FUEL = CONTAINER_TYPES.registerEmpty("fusion_reactor_fuel", TileEntityFusionReactorController.class); public static final ContainerTypeRegistryObject> FUSION_REACTOR_HEAT = CONTAINER_TYPES.registerEmpty("fusion_reactor_heat", TileEntityFusionReactorController.class); public static final ContainerTypeRegistryObject> FUSION_REACTOR_LOGIC_ADAPTER = CONTAINER_TYPES.registerEmpty(GeneratorsBlocks.FUSION_REACTOR_LOGIC_ADAPTER, TileEntityFusionReactorLogicAdapter.class); diff --git a/src/main/java/mekanism/client/gui/GuiBoilerStats.java b/src/main/java/mekanism/client/gui/GuiBoilerStats.java index 56d8d59c975..c00eda2878c 100644 --- a/src/main/java/mekanism/client/gui/GuiBoilerStats.java +++ b/src/main/java/mekanism/client/gui/GuiBoilerStats.java @@ -44,13 +44,13 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - drawCenteredText(guiGraphics, title, 0, imageWidth, titleLabelY, titleTextColor()); + renderTitleText(guiGraphics); BoilerMultiblockData multiblock = tile.getMultiblock(); - drawString(guiGraphics, MekanismLang.BOILER_MAX_WATER.translate(TextUtils.format(multiblock.waterTank.getCapacity())), 8, 26, titleTextColor()); - drawString(guiGraphics, MekanismLang.BOILER_MAX_STEAM.translate(TextUtils.format(multiblock.steamTank.getCapacity())), 8, 35, titleTextColor()); - drawString(guiGraphics, MekanismLang.BOILER_HEAT_TRANSFER.translate(), 8, 49, subheadingTextColor()); - drawString(guiGraphics, MekanismLang.BOILER_HEATERS.translate(multiblock.superheatingElements), 14, 58, titleTextColor()); - drawString(guiGraphics, MekanismLang.BOILER_CAPACITY.translate(TextUtils.format(multiblock.getBoilCapacity())), 8, 72, titleTextColor()); + drawScrollingString(guiGraphics, MekanismLang.BOILER_MAX_WATER.translate(TextUtils.format(multiblock.waterTank.getCapacity())), 0, 26, TextAlignment.LEFT, titleTextColor(), 8, false); + drawScrollingString(guiGraphics, MekanismLang.BOILER_MAX_STEAM.translate(TextUtils.format(multiblock.steamTank.getCapacity())), 0, 35, TextAlignment.LEFT, titleTextColor(), 8, false); + drawScrollingString(guiGraphics, MekanismLang.BOILER_HEAT_TRANSFER.translate(), 0, 49, TextAlignment.LEFT, subheadingTextColor(), 8, false); + drawScrollingString(guiGraphics, MekanismLang.BOILER_HEATERS.translate(multiblock.superheatingElements), 6, 58, TextAlignment.LEFT, titleTextColor(), getXSize() - 6, 8, false); + drawScrollingString(guiGraphics, MekanismLang.BOILER_CAPACITY.translate(TextUtils.format(multiblock.getBoilCapacity())), 0, 72, TextAlignment.LEFT, titleTextColor(), 8, false); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiChemicalTank.java b/src/main/java/mekanism/client/gui/GuiChemicalTank.java index 0ec2a19c692..7d5f5b14e7b 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalTank.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalTank.java @@ -54,7 +54,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics, 85); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiDimensionalStabilizer.java b/src/main/java/mekanism/client/gui/GuiDimensionalStabilizer.java index 93b25d85d0a..b6880fdcc18 100644 --- a/src/main/java/mekanism/client/gui/GuiDimensionalStabilizer.java +++ b/src/main/java/mekanism/client/gui/GuiDimensionalStabilizer.java @@ -30,6 +30,9 @@ public class GuiDimensionalStabilizer extends GuiMekanismTile> { + //Note: We need a component that is a space so that the line doesn't get trimmed out when splitting to fit within the screen space + private static final Component BLANK_LINE = Component.literal(" "); + public GuiDimensionalStabilizer(MekanismTileContainer container, Inventory inv, Component title) { super(container, inv, title); inventoryLabelY += 2; @@ -83,16 +86,14 @@ public void updateTooltip(int mouseX, int mouseY) { // for now it doesn't really matter as given we only support a radius of two it only checks at most the inner radius (8 extra boolean lookups) for (int i = 1; i <= TileEntityDimensionalStabilizer.MAX_LOAD_RADIUS; i++) { if (hasAtRadius(i, false)) { - //Add an empty line for readability. Must be done by adding a string that just renders a space - tooltips.add(Component.literal(" ")); + tooltips.add(BLANK_LINE);//Add an empty line for readability tooltips.add(MekanismLang.STABILIZER_ENABLE_RADIUS.translate(EnumColor.INDIGO, i, EnumColor.INDIGO, chunkX, EnumColor.INDIGO, chunkZ)); break; } } for (int i = TileEntityDimensionalStabilizer.MAX_LOAD_RADIUS; i > 0; i--) { if (hasAtRadius(i, true)) { - //Add an empty line for readability. Must be done by adding a string that just renders a space - tooltips.add(Component.literal(" ")); + tooltips.add(BLANK_LINE);//Add an empty line for readability tooltips.add(MekanismLang.STABILIZER_DISABLE_RADIUS.translate(EnumColor.INDIGO, i, EnumColor.INDIGO, chunkX, EnumColor.INDIGO, chunkZ)); break; } @@ -134,8 +135,8 @@ private boolean hasAtRadius(int radius, boolean state) { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); - drawTextExact(guiGraphics, MekanismLang.NORTH_SHORT.translate(), 53.5F, 41F, titleTextColor()); + renderInventoryText(guiGraphics); + drawScrollingString(guiGraphics, MekanismLang.NORTH_SHORT.translate(), 49, 41, TextAlignment.CENTER, titleTextColor(), 15, 2, false); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } diff --git a/src/main/java/mekanism/client/gui/GuiDynamicTank.java b/src/main/java/mekanism/client/gui/GuiDynamicTank.java index 980bc4c1f80..33583b84bcc 100644 --- a/src/main/java/mekanism/client/gui/GuiDynamicTank.java +++ b/src/main/java/mekanism/client/gui/GuiDynamicTank.java @@ -56,7 +56,7 @@ protected void addGuiElements() { ret.add(MekanismLang.CAPACITY.translate("")); ret.add(MekanismLang.GENERIC_MB.translate(TextUtils.format(capacity))); return ret; - }).spacing(2)); + }).spacing(1)); addRenderableWidget(new GuiDownArrow(this, 150, 39)); addRenderableWidget(new GuiContainerEditModeTab<>(this, tile)); addRenderableWidget(new GuiMergedTankGauge<>(() -> tile.getMultiblock().mergedTank, tile::getMultiblock, GaugeType.MEDIUM, this, 7, 16, 34, 56)); @@ -74,7 +74,7 @@ private void addStored(List ret, STACK stack, ToLongFunction< @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiEnergyCube.java b/src/main/java/mekanism/client/gui/GuiEnergyCube.java index d97f2f466c2..ec451ff4e2d 100644 --- a/src/main/java/mekanism/client/gui/GuiEnergyCube.java +++ b/src/main/java/mekanism/client/gui/GuiEnergyCube.java @@ -42,7 +42,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiFilterHolder.java b/src/main/java/mekanism/client/gui/GuiFilterHolder.java index ad3e16af2b0..90a244c604a 100644 --- a/src/main/java/mekanism/client/gui/GuiFilterHolder.java +++ b/src/main/java/mekanism/client/gui/GuiFilterHolder.java @@ -32,6 +32,7 @@ public abstract class GuiFilterHolder, TILE extends Ti * The number of filters that can be displayed */ private static final int FILTER_COUNT = 4; + protected GuiInnerScreen leftScreen; private GuiScrollBar scrollBar; protected GuiFilterHolder(CONTAINER container, Inventory inv, Component title) { @@ -46,7 +47,7 @@ protected GuiFilterHolder(CONTAINER container, Inventory inv, Component title) { @Override protected void addGuiElements() { super.addGuiElements(); - addRenderableWidget(new GuiInnerScreen(this, 9, 17, 85, 140)); + leftScreen = addRenderableWidget(new GuiInnerScreen(this, 9, 17, 85, 140)); //Filter holder addRenderableWidget(new GuiElementHolder(this, 95, 17, 158, 118)); //new filter button border @@ -69,6 +70,17 @@ protected void addGuiElements() { } } + protected void drawScreenText(GuiGraphics guiGraphics, Component text, int y) { + drawScreenText(guiGraphics, text, 0, y); + } + + protected void drawScreenText(GuiGraphics guiGraphics, Component text, int x, int y) { + //TODO: Do we want to make usages of this method eventually set the text to be rendered within the gui element for the screen? + if (leftScreen != null) {//Validate it was properly set + leftScreen.drawScaledScrollingString(guiGraphics, text, x, y, TextAlignment.LEFT, screenTextColor(), leftScreen.getXSize() - x, 5, false, 0.8F); + } + } + private List getRenderStacks(@Nullable IFilter filter) { if (filter != null) { return switch (filter) { @@ -103,6 +115,6 @@ public boolean mouseScrolled(double mouseX, double mouseY, double xDelta, double @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { super.drawForegroundText(guiGraphics, mouseX, mouseY); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiFluidTank.java b/src/main/java/mekanism/client/gui/GuiFluidTank.java index 0710c5ffd8c..1ad239aaaa2 100644 --- a/src/main/java/mekanism/client/gui/GuiFluidTank.java +++ b/src/main/java/mekanism/client/gui/GuiFluidTank.java @@ -30,7 +30,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiInductionMatrix.java b/src/main/java/mekanism/client/gui/GuiInductionMatrix.java index 39809990903..e18f17fd2d6 100644 --- a/src/main/java/mekanism/client/gui/GuiInductionMatrix.java +++ b/src/main/java/mekanism/client/gui/GuiInductionMatrix.java @@ -45,7 +45,7 @@ protected void addGuiElements() { MekanismLang.CAPACITY.translate(EnergyDisplay.of(multiblock.getStorageCap())), MekanismLang.MATRIX_INPUT_AMOUNT.translate(MekanismLang.GENERIC_PER_TICK.translate(EnergyDisplay.of(multiblock.getLastInput()))), MekanismLang.MATRIX_OUTPUT_AMOUNT.translate(MekanismLang.GENERIC_PER_TICK.translate(EnergyDisplay.of(multiblock.getLastOutput())))); - }).spacing(2)); + }).spacing(1)); addRenderableWidget(new GuiMatrixTab(this, tile, MatrixTab.STAT)); addRenderableWidget(new GuiEnergyGauge(new IEnergyInfoHandler() { @Override @@ -69,7 +69,7 @@ public long getMaxEnergy() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java b/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java index 2c6408d97d0..0cffd8bed11 100644 --- a/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java +++ b/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java @@ -26,6 +26,7 @@ public class GuiLaserAmplifier extends GuiMekanismTile> { private GuiTextField minField, maxField, timerField; + private GuiEnergyGauge energyGauge; public GuiLaserAmplifier(MekanismTileContainer container, Inventory inv, Component title) { super(container, inv, title); @@ -35,7 +36,7 @@ public GuiLaserAmplifier(MekanismTileContainer contain @Override protected void addGuiElements() { super.addGuiElements(); - addRenderableWidget(new GuiEnergyGauge(tile.getEnergyContainer(), GaugeType.STANDARD, this, 6, 10)); + energyGauge = addRenderableWidget(new GuiEnergyGauge(tile.getEnergyContainer(), GaugeType.STANDARD, this, 6, 10)); addRenderableWidget(new GuiEnergyTab(this, () -> List.of(MekanismLang.STORING.translate(EnergyDisplay.of(tile.getEnergyContainer()))))); addRenderableWidget(new GuiAmplifierTab(this, tile)); timerField = addRenderableWidget(new GuiTextField(this, 96, 28, 36, 11)); @@ -54,15 +55,18 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderTitleTextWithOffset(guiGraphics, energyGauge.getRelativeRight()); + renderInventoryText(guiGraphics); + int start = energyGauge.getRelativeRight(); + Component delay; if (tile.getDelay() > 0) { - drawTextScaledBound(guiGraphics, MekanismLang.DELAY.translate(tile.getDelay()), 26, 30, titleTextColor(), 68); + delay = MekanismLang.DELAY.translate(tile.getDelay()); } else { - drawTextScaledBound(guiGraphics, MekanismLang.NO_DELAY.translate(), 26, 30, titleTextColor(), 68); + delay = MekanismLang.NO_DELAY.translate(); } - drawTextScaledBound(guiGraphics, MekanismLang.MIN.translate(EnergyDisplay.of(tile.getMinThreshold())), 26, 45, titleTextColor(), 68); - drawTextScaledBound(guiGraphics, MekanismLang.MAX.translate(EnergyDisplay.of(tile.getMaxThreshold())), 26, 60, titleTextColor(), 68); + drawScrollingString(guiGraphics, delay, start, 30, TextAlignment.LEFT, titleTextColor(), timerField.getRelativeX() - start, 2, false); + drawScrollingString(guiGraphics, MekanismLang.MIN.translate(EnergyDisplay.of(tile.getMinThreshold())), start, 45, TextAlignment.LEFT, titleTextColor(), minField.getRelativeX() - start, 2, false); + drawScrollingString(guiGraphics, MekanismLang.MAX.translate(EnergyDisplay.of(tile.getMaxThreshold())), start, 60, TextAlignment.LEFT, titleTextColor(), maxField.getRelativeX() - start, 2, false); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiLaserTractorBeam.java b/src/main/java/mekanism/client/gui/GuiLaserTractorBeam.java index ec27c71bbd7..2ae5c10969e 100644 --- a/src/main/java/mekanism/client/gui/GuiLaserTractorBeam.java +++ b/src/main/java/mekanism/client/gui/GuiLaserTractorBeam.java @@ -17,7 +17,7 @@ public GuiLaserTractorBeam(MekanismTileContainer con @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java b/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java index 6aae778aa10..acfe1b2bdee 100644 --- a/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java +++ b/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java @@ -71,14 +71,14 @@ protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, super.drawForegroundText(guiGraphics, mouseX, mouseY); // Write to info display renderTitleText(guiGraphics); - drawTextWithScale(guiGraphics, MekanismLang.FILTER_COUNT.translate(getFilterManager().count()), 14, 21, screenTextColor(), 0.8F); - drawTextWithScale(guiGraphics, MekanismLang.SORTER_SINGLE_ITEM.translate(), 14, 36, screenTextColor(), 0.8F); - drawTextWithScale(guiGraphics, OnOff.of(tile.getSingleItem()).getTextComponent(), 28, 49, screenTextColor(), 0.8F); - drawTextWithScale(guiGraphics, MekanismLang.SORTER_ROUND_ROBIN.translate(), 14, 66, screenTextColor(), 0.8F); - drawTextWithScale(guiGraphics, OnOff.of(tile.getRoundRobin()).getTextComponent(), 28, 79, screenTextColor(), 0.8F); - drawTextWithScale(guiGraphics, MekanismLang.SORTER_AUTO_EJECT.translate(), 14, 96, screenTextColor(), 0.8F); - drawTextWithScale(guiGraphics, OnOff.of(tile.getAutoEject()).getTextComponent(), 28, 109, screenTextColor(), 0.8F); - drawTextWithScale(guiGraphics, MekanismLang.SORTER_DEFAULT.translate(), 14, 126, screenTextColor(), 0.8F); + drawScreenText(guiGraphics, MekanismLang.FILTER_COUNT.translate(getFilterManager().count()), 4); + drawScreenText(guiGraphics, MekanismLang.SORTER_SINGLE_ITEM.translate(), 19); + drawScreenText(guiGraphics, OnOff.of(tile.getSingleItem()).getTextComponent(), 14, 32); + drawScreenText(guiGraphics, MekanismLang.SORTER_ROUND_ROBIN.translate(), 49); + drawScreenText(guiGraphics, OnOff.of(tile.getRoundRobin()).getTextComponent(), 14, 62); + drawScreenText(guiGraphics, MekanismLang.SORTER_AUTO_EJECT.translate(), 79); + drawScreenText(guiGraphics, OnOff.of(tile.getAutoEject()).getTextComponent(), 14, 92); + drawScreenText(guiGraphics, MekanismLang.SORTER_DEFAULT.translate(), 109); } @Override diff --git a/src/main/java/mekanism/client/gui/GuiMatrixStats.java b/src/main/java/mekanism/client/gui/GuiMatrixStats.java index f163b58f77c..6e9a601f715 100644 --- a/src/main/java/mekanism/client/gui/GuiMatrixStats.java +++ b/src/main/java/mekanism/client/gui/GuiMatrixStats.java @@ -24,6 +24,7 @@ public class GuiMatrixStats extends GuiMekanismTile container, Inventory inv, Component title) { super(container, inv, title); + titleLabelY = 5; } @Override @@ -80,17 +81,17 @@ public double getLevel() { protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); MatrixMultiblockData multiblock = tile.getMultiblock(); - drawString(guiGraphics, MekanismLang.INPUT.translate(), 53, 26, subheadingTextColor()); - drawString(guiGraphics, EnergyDisplay.of(multiblock.getLastInput(), multiblock.getTransferCap()).getTextComponent(), 59, 35, titleTextColor()); - drawString(guiGraphics, MekanismLang.OUTPUT.translate(), 53, 46, subheadingTextColor()); - drawString(guiGraphics, EnergyDisplay.of(multiblock.getLastOutput(), multiblock.getTransferCap()).getTextComponent(), 59, 55, titleTextColor()); - drawString(guiGraphics, MekanismLang.MATRIX_DIMENSIONS.translate(), 8, 82, subheadingTextColor()); + drawScrollingString(guiGraphics, MekanismLang.INPUT.translate(), 45, 26, TextAlignment.LEFT, subheadingTextColor(), getXSize() - 54, 8, false); + drawScrollingString(guiGraphics, EnergyDisplay.of(multiblock.getLastInput(), multiblock.getTransferCap()).getTextComponent(), 51, 35, TextAlignment.LEFT, titleTextColor(), getXSize() - 60, 8, false); + drawScrollingString(guiGraphics, MekanismLang.OUTPUT.translate(), 45, 46, TextAlignment.LEFT, subheadingTextColor(), getXSize() - 54, 8, false); + drawScrollingString(guiGraphics, EnergyDisplay.of(multiblock.getLastOutput(), multiblock.getTransferCap()).getTextComponent(), 51, 55, TextAlignment.LEFT, titleTextColor(), getXSize() - 60, 8, false); + drawScrollingString(guiGraphics, MekanismLang.MATRIX_DIMENSIONS.translate(), 0, 82, TextAlignment.LEFT, subheadingTextColor(), 8, false); if (multiblock.isFormed()) { - drawString(guiGraphics, MekanismLang.MATRIX_DIMENSION_REPRESENTATION.translate(multiblock.width(), multiblock.height(), multiblock.length()), 14, 91, titleTextColor()); + drawScrollingString(guiGraphics, MekanismLang.MATRIX_DIMENSION_REPRESENTATION.translate(multiblock.width(), multiblock.height(), multiblock.length()), 6, 91, TextAlignment.LEFT, titleTextColor(), getXSize() - 6, 8, false); } - drawString(guiGraphics, MekanismLang.MATRIX_CONSTITUENTS.translate(), 8, 102, subheadingTextColor()); - drawString(guiGraphics, MekanismLang.MATRIX_CELLS.translate(multiblock.getCellCount()), 14, 111, titleTextColor()); - drawString(guiGraphics, MekanismLang.MATRIX_PROVIDERS.translate(multiblock.getProviderCount()), 14, 120, titleTextColor()); + drawScrollingString(guiGraphics, MekanismLang.MATRIX_CONSTITUENTS.translate(), 0, 102, TextAlignment.LEFT, subheadingTextColor(), 8, false); + drawScrollingString(guiGraphics, MekanismLang.MATRIX_CELLS.translate(multiblock.getCellCount()), 6, 111, TextAlignment.LEFT, titleTextColor(), getXSize() - 6, 8, false); + drawScrollingString(guiGraphics, MekanismLang.MATRIX_PROVIDERS.translate(multiblock.getProviderCount()), 6, 120, TextAlignment.LEFT, titleTextColor(), getXSize() - 6, 8, false); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiMekanism.java b/src/main/java/mekanism/client/gui/GuiMekanism.java index 93f935579bd..a4712100c09 100644 --- a/src/main/java/mekanism/client/gui/GuiMekanism.java +++ b/src/main/java/mekanism/client/gui/GuiMekanism.java @@ -13,7 +13,6 @@ import mekanism.client.gui.element.slot.SlotType; import mekanism.client.gui.element.tab.GuiWarningTab; import mekanism.client.gui.element.window.GuiWindow; -import mekanism.client.render.IFancyFontRenderer; import mekanism.client.render.MekanismRenderer; import mekanism.common.Mekanism; import mekanism.common.inventory.container.MekanismContainer; @@ -31,6 +30,7 @@ import mekanism.common.tile.interfaces.ISideConfiguration; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; +import net.minecraft.Util; import net.minecraft.client.gui.ComponentPath; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; @@ -48,7 +48,7 @@ import org.jetbrains.annotations.Nullable; import org.lwjgl.glfw.GLFW; -public abstract class GuiMekanism extends VirtualSlotContainerScreen implements IGuiWrapper, IFancyFontRenderer { +public abstract class GuiMekanism extends VirtualSlotContainerScreen implements IGuiWrapper { public static final ResourceLocation BASE_BACKGROUND = MekanismUtils.getResource(ResourceType.GUI, "base.png"); public static final ResourceLocation SHADOW = MekanismUtils.getResource(ResourceType.GUI, "shadow.png"); @@ -60,6 +60,7 @@ public abstract class GuiMekanism exten public boolean switchingToRecipeViewer; @Nullable private IWarningTracker warningTracker; + private long lastMSInitialized; private boolean hasClicked = false; @@ -98,6 +99,9 @@ protected void init() { //If our warning tracker isn't null (so this isn't the first time we are initializing, such as after resizing) // clear out any tracked warnings, so we don't have duplicates being tracked when we add our elements again warningTracker.clearTrackedWarnings(); + } else { + //If we haven't been initialized yet, we can initialize it here + lastMSInitialized = Util.getMillis(); } addGuiElements(); if (warningTracker != null) { @@ -168,10 +172,45 @@ public void containerTick() { windows.forEach(GuiWindow::tick); } + @Override + public long getTimeOpened() { + return lastMSInitialized; + } + protected void renderTitleText(GuiGraphics guiGraphics) { drawTitleText(guiGraphics, title, titleLabelY); } + protected void renderTitleTextWithOffset(GuiGraphics guiGraphics, int x) { + renderTitleTextWithOffset(guiGraphics, x, getXSize()); + } + + protected void renderTitleTextWithOffset(GuiGraphics guiGraphics, int x, int end) { + drawTitleTextTextWithOffset(guiGraphics, title, x, titleLabelY, end); + } + + protected void renderTitleTextWithOffset(GuiGraphics guiGraphics, int x, int end, int maxLengthPad, TextAlignment alignment) { + drawTitleTextTextWithOffset(guiGraphics, title, x, titleLabelY, end, maxLengthPad, alignment); + } + + protected void renderInventoryText(GuiGraphics guiGraphics) { + renderInventoryText(guiGraphics, getXSize()); + } + + protected void renderInventoryText(GuiGraphics guiGraphics, int end) { + drawScrollingString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, TextAlignment.LEFT, titleTextColor(), end - inventoryLabelX - 6, 0, false); + } + + protected void renderInventoryTextAndOther(GuiGraphics guiGraphics, Component rightAlignedText) { + renderInventoryTextAndOther(guiGraphics, rightAlignedText, 0); + } + + protected void renderInventoryTextAndOther(GuiGraphics guiGraphics, Component rightAlignedText, int rightEndPad) { + drawScrollingString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, TextAlignment.LEFT, titleTextColor(), 53, 0, false); + int rightStart = inventoryLabelX + 51; + drawScrollingString(guiGraphics, rightAlignedText, rightStart, inventoryLabelY, TextAlignment.RIGHT, titleTextColor(), getXSize() - rightStart - rightEndPad, 6, false); + } + protected ResourceLocation getButtonLocation(String name) { return MekanismUtils.getResource(ResourceType.GUI_BUTTON, name + ".png"); } @@ -268,12 +307,16 @@ protected boolean hasClickedOutside(double mouseX, double mouseY, int guiLeftIn, @Override protected void repositionElements() { - //Mark that we are not switching to JEI if we start being initialized again - // Note: We can do this here as the screen will always have initialized as true, so we don't need to definalize init(mc, width, height) - // as it will never potentially have init() with no params be the call path - // Additionally, as the screen is not actively being used we shouldn't have cases this is called from resize while we are not present - // and setting this to false when it is already false does nothing - switchingToRecipeViewer = false; + if (switchingToRecipeViewer) { + //Mark that we are not switching to JEI if we start being initialized again + // Note: We can do this here as the screen will always have initialized as true, so we don't need to definalize init(mc, width, height) + // as it will never potentially have init() with no params be the call path + // Additionally, as the screen is not actively being used we shouldn't have cases this is called from resize while we are not present + // and setting this to false when it is already false does nothing + switchingToRecipeViewer = false; + //If we were switching to a recipe viewer, then we also want to restart the time the scrolling text is using + lastMSInitialized = Util.getMillis(); + } super.repositionElements(); } @@ -670,7 +713,7 @@ protected void renderBg(@NotNull GuiGraphics guiGraphics, float partialTick, int //Ensure the GL color is white as mods adding an overlay (such as JEI for bookmarks), might have left // it in an unexpected state. MekanismRenderer.resetColor(guiGraphics); - if (width < 8 || height < 8) { + if (getXSize() < 8 || getYSize() < 8) { Mekanism.logger.warn("Gui: {}, was too small to draw the background of. Unable to draw a background for a gui smaller than 8 by 8.", getClass().getSimpleName()); return; } @@ -678,10 +721,11 @@ protected void renderBg(@NotNull GuiGraphics guiGraphics, float partialTick, int } @Override - @SuppressWarnings("ConstantValue") - public Font getFont() { - //In theory font is never null here, but we validate it in case we are called before init finishes happening - return font == null ? minecraft.font : font; + public Font font() { + //Note: In theory font is never null here, as we should only be calling it after init has happened + // Previously we checked if it was and then fell back to Minecraft's overall font. But as the minecraft + // object we queried was actually null as well, we know that this doesn't ever get called before init + return font; } @Override diff --git a/src/main/java/mekanism/client/gui/GuiModificationStation.java b/src/main/java/mekanism/client/gui/GuiModificationStation.java index 834bf00e7c2..6ac89868d8d 100644 --- a/src/main/java/mekanism/client/gui/GuiModificationStation.java +++ b/src/main/java/mekanism/client/gui/GuiModificationStation.java @@ -35,16 +35,16 @@ public GuiModificationStation(MekanismTileContainer { + 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) { @@ -54,8 +54,8 @@ private void onModuleSelected(@Nullable IModule module) { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderTitleTextWithOffset(guiGraphics, 24); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiModuleTweaker.java b/src/main/java/mekanism/client/gui/GuiModuleTweaker.java index 86b70e6d48b..c63abe2bba6 100644 --- a/src/main/java/mekanism/client/gui/GuiModuleTweaker.java +++ b/src/main/java/mekanism/client/gui/GuiModuleTweaker.java @@ -61,7 +61,7 @@ public GuiModuleTweaker(ModuleTweakerContainer container, Inventory inv, Compone } } }; - imageWidth = 248; + imageWidth = 266; imageHeight += 20; } @@ -69,10 +69,10 @@ public GuiModuleTweaker(ModuleTweakerContainer container, Inventory inv, Compone protected void addGuiElements() { super.addGuiElements(); Supplier 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; })); @@ -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 @@ -145,7 +145,7 @@ public boolean mouseReleased(double mouseX, double mouseY, int button) { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - renderTitleText(guiGraphics); + renderTitleTextWithOffset(guiGraphics, 24); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiPersonalStorageTile.java b/src/main/java/mekanism/client/gui/GuiPersonalStorageTile.java index 1d39a535f66..9073859f09c 100644 --- a/src/main/java/mekanism/client/gui/GuiPersonalStorageTile.java +++ b/src/main/java/mekanism/client/gui/GuiPersonalStorageTile.java @@ -19,7 +19,7 @@ public GuiPersonalStorageTile(MekanismTileContainer c @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiQuantumEntangloporter.java b/src/main/java/mekanism/client/gui/GuiQuantumEntangloporter.java index a8d6dbbf2bc..821de71b082 100644 --- a/src/main/java/mekanism/client/gui/GuiQuantumEntangloporter.java +++ b/src/main/java/mekanism/client/gui/GuiQuantumEntangloporter.java @@ -49,7 +49,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiSPS.java b/src/main/java/mekanism/client/gui/GuiSPS.java index e3b3c2a9ad3..4dfc12fbc38 100644 --- a/src/main/java/mekanism/client/gui/GuiSPS.java +++ b/src/main/java/mekanism/client/gui/GuiSPS.java @@ -62,7 +62,7 @@ public double getLevel() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } diff --git a/src/main/java/mekanism/client/gui/GuiSecurityDesk.java b/src/main/java/mekanism/client/gui/GuiSecurityDesk.java index b78deb88c09..1fb8707596e 100644 --- a/src/main/java/mekanism/client/gui/GuiSecurityDesk.java +++ b/src/main/java/mekanism/client/gui/GuiSecurityDesk.java @@ -179,16 +179,17 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); Component ownerComponent = OwnerDisplay.of(tile.getOwnerUUID(), tile.getOwnerName()).getTextComponent(); - drawString(guiGraphics, ownerComponent, imageWidth - 7 - getStringWidth(ownerComponent), inventoryLabelY, titleTextColor()); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); - drawCenteredText(guiGraphics, MekanismLang.TRUSTED_PLAYERS.translate(), 74, 57, subheadingTextColor()); + renderInventoryTextAndOther(guiGraphics, ownerComponent); + drawScrollingString(guiGraphics, MekanismLang.TRUSTED_PLAYERS.translate(), 13, 57, TextAlignment.CENTER, subheadingTextColor(), 122, 0, false); SecurityFrequency frequency = tile.getFreq(); - if (frequency != null) { - drawString(guiGraphics, MekanismLang.SECURITY.translate(frequency.getSecurity()), 13, 103, titleTextColor()); + Component frequencyText; + if (frequency == null) { + frequencyText = MekanismLang.SECURITY_OFFLINE.translateColored(EnumColor.RED); } else { - drawString(guiGraphics, MekanismLang.SECURITY_OFFLINE.translateColored(EnumColor.RED), 13, 103, titleTextColor()); + frequencyText = MekanismLang.SECURITY.translate(frequency.getSecurity()); } - drawTextScaledBound(guiGraphics, MekanismLang.SECURITY_ADD.translate(), 13, 70, titleTextColor(), 20); + drawScrollingString(guiGraphics, frequencyText, 13, 103, TextAlignment.LEFT, titleTextColor(), 122, 0, false); + drawScrollingString(guiGraphics, MekanismLang.SECURITY_ADD.translate(), 1, 70, TextAlignment.RIGHT, titleTextColor(), trustedField.getRelativeX() - 1, 3, false); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiTeleporter.java b/src/main/java/mekanism/client/gui/GuiTeleporter.java index b32d85ab5b5..81559b36931 100644 --- a/src/main/java/mekanism/client/gui/GuiTeleporter.java +++ b/src/main/java/mekanism/client/gui/GuiTeleporter.java @@ -17,6 +17,8 @@ public class GuiTeleporter extends GuiMekanismTile> implements ITileGuiFrequencySelector, IGuiColorFrequencySelector { + private GuiTeleporterStatus status; + public GuiTeleporter(MekanismTileContainer container, Inventory inv, Component title) { super(container, inv, title); imageHeight += 74; @@ -28,15 +30,15 @@ public GuiTeleporter(MekanismTileContainer container, Inve @Override protected void addGuiElements() { super.addGuiElements(); - addRenderableWidget(new GuiTeleporterStatus(this, () -> getFrequency() != null, () -> tile.status)); + status = addRenderableWidget(new GuiTeleporterStatus(this, () -> getFrequency() != null, () -> tile.status)); addRenderableWidget(new GuiVerticalPowerBar(this, tile.getEnergyContainer(), 158, 26)); addRenderableWidget(new GuiFrequencySelector<>(this, 14)); } @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderTitleTextWithOffset(guiGraphics, status.getRelativeRight(), tile.getEnergySlotX()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiThermalEvaporationController.java b/src/main/java/mekanism/client/gui/GuiThermalEvaporationController.java index 04e5d7b2249..50b00f54df9 100644 --- a/src/main/java/mekanism/client/gui/GuiThermalEvaporationController.java +++ b/src/main/java/mekanism/client/gui/GuiThermalEvaporationController.java @@ -5,6 +5,7 @@ import java.util.function.BooleanSupplier; import mekanism.api.recipes.cache.CachedRecipe.OperationTracker.RecipeError; import mekanism.client.gui.element.GuiDownArrow; +import mekanism.client.gui.element.GuiElement; import mekanism.client.gui.element.GuiInnerScreen; import mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler; import mekanism.client.gui.element.bar.GuiHorizontalRateBar; @@ -28,24 +29,27 @@ public class GuiThermalEvaporationController extends GuiMekanismTile> { + private GuiElement inputGauge, outputGauge; + public GuiThermalEvaporationController(MekanismTileContainer container, Inventory inv, Component title) { super(container, inv, title); + imageWidth += 20; + inventoryLabelX += 10; inventoryLabelY += 2; - titleLabelY = 4; dynamicSlots = true; } @Override protected void addGuiElements() { super.addGuiElements(); - addRenderableWidget(new GuiInnerScreen(this, 48, 19, 80, 40, () -> { + addRenderableWidget(new GuiInnerScreen(this, 48, 19, 100, 40, () -> { EvaporationMultiblockData multiblock = tile.getMultiblock(); return List.of(MekanismLang.MULTIBLOCK_FORMED.translate(), MekanismLang.EVAPORATION_HEIGHT.translate(multiblock.height()), MekanismLang.TEMPERATURE.translate(MekanismUtils.getTemperatureDisplay(multiblock.getTemperature(), TemperatureUnit.KELVIN, true)), MekanismLang.FLUID_PRODUCTION.translate(Math.round(multiblock.lastGain * 100D) / 100D)); - }).spacing(1).recipeViewerCategories(RecipeViewerRecipeType.EVAPORATING)); + }).padding(3).clearSpacing().recipeViewerCategories(RecipeViewerRecipeType.EVAPORATING)); addRenderableWidget(new GuiDownArrow(this, 32, 39)); - addRenderableWidget(new GuiDownArrow(this, 136, 39)); + addRenderableWidget(new GuiDownArrow(this, 156, 39)); addRenderableWidget(new GuiHorizontalRateBar(this, new IBarInfoHandler() { @Override public Component getTooltip() { @@ -56,12 +60,12 @@ public Component getTooltip() { public double getLevel() { return Math.min(1, tile.getMultiblock().getTemperature() / EvaporationMultiblockData.MAX_MULTIPLIER_TEMP); } - }, 48, 63)) + }, 58, 62)) //Note: We just apply this warning to the bar as we don't have an arrow or anything here .warning(WarningType.INPUT_DOESNT_PRODUCE_OUTPUT, getWarningCheck(RecipeError.INPUT_DOESNT_PRODUCE_OUTPUT)); - addRenderableWidget(new GuiFluidGauge(() -> tile.getMultiblock().inputTank, () -> tile.getMultiblock().getFluidTanks(null), GaugeType.STANDARD, this, 6, 13)) + inputGauge = addRenderableWidget(new GuiFluidGauge(() -> tile.getMultiblock().inputTank, () -> tile.getMultiblock().getFluidTanks(null), GaugeType.STANDARD, this, 6, 13)) .warning(WarningType.NO_MATCHING_RECIPE, getWarningCheck(RecipeError.NOT_ENOUGH_INPUT)); - addRenderableWidget(new GuiFluidGauge(() -> tile.getMultiblock().outputTank, () -> tile.getMultiblock().getFluidTanks(null), GaugeType.STANDARD, this, 152, 13)) + outputGauge = addRenderableWidget(new GuiFluidGauge(() -> tile.getMultiblock().outputTank, () -> tile.getMultiblock().getFluidTanks(null), GaugeType.STANDARD, this, 172, 13)) .warning(WarningType.NO_SPACE_IN_OUTPUT, getWarningCheck(RecipeError.NOT_ENOUGH_OUTPUT_SPACE)); addRenderableWidget(new GuiHeatTab(this, () -> { Component environment = MekanismUtils.getTemperatureDisplay(tile.getMultiblock().lastEnvironmentLoss, TemperatureUnit.KELVIN, false); @@ -81,8 +85,8 @@ protected void addWarningTab(IWarningTracker warningTracker) { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderTitleTextWithOffset(guiGraphics, inputGauge.getRelativeRight(), outputGauge.getRelativeX()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiThermoelectricBoiler.java b/src/main/java/mekanism/client/gui/GuiThermoelectricBoiler.java index 94bada5964f..0de135543a0 100644 --- a/src/main/java/mekanism/client/gui/GuiThermoelectricBoiler.java +++ b/src/main/java/mekanism/client/gui/GuiThermoelectricBoiler.java @@ -33,7 +33,8 @@ public class GuiThermoelectricBoiler extends GuiMekanismTile container, Inventory inv, Component title) { super(container, inv, title); dynamicSlots = true; - imageWidth += 40; + imageWidth += 42; + inventoryLabelX += 21; inventoryLabelY += 2; titleLabelY = 5; } @@ -41,11 +42,11 @@ public GuiThermoelectricBoiler(MekanismTileContainer con @Override protected void addGuiElements() { super.addGuiElements(); - addRenderableWidget(new GuiInnerScreen(this, 60, 23, 96, 40, () -> { + addRenderableWidget(new GuiInnerScreen(this, 54, 23, 110, 40, () -> { BoilerMultiblockData multiblock = tile.getMultiblock(); return List.of(MekanismLang.TEMPERATURE.translate(MekanismUtils.getTemperatureDisplay(multiblock.getTotalTemperature(), TemperatureUnit.KELVIN, true)), MekanismLang.BOIL_RATE.translate(TextUtils.format(multiblock.lastBoilRate)), MekanismLang.MAX_BOIL_RATE.translate(TextUtils.format(multiblock.lastMaxBoil))); - }).recipeViewerCategories(RecipeViewerRecipeType.BOILER)); + }).padding(3).recipeViewerCategories(RecipeViewerRecipeType.BOILER)); addRenderableWidget(new GuiBoilerTab(this, tile, BoilerTab.STAT)); addRenderableWidget(new GuiVerticalRateBar(this, new IBarInfoHandler() { @Override @@ -71,14 +72,14 @@ public double getLevel() { return Math.min(1, multiblock.lastMaxBoil * HeatUtils.getWaterThermalEnthalpy() / (multiblock.superheatingElements * MekanismConfig.general.superheatingHeatTransfer.get())); } - }, 164, 13)); + }, 166, 13)); addRenderableWidget(new GuiChemicalGauge(() -> tile.getMultiblock().superheatedCoolantTank, () -> tile.getMultiblock().getChemicalTanks((Direction) null), GaugeType.STANDARD, this, 6, 13) .setLabel(MekanismLang.BOILER_HEATED_COOLANT_TANK.translateColored(EnumColor.ORANGE))); addRenderableWidget(new GuiFluidGauge(() -> tile.getMultiblock().waterTank, () -> tile.getMultiblock().getFluidTanks(null), GaugeType.STANDARD, this, 26, 13) .setLabel(MekanismLang.BOILER_WATER_TANK.translateColored(EnumColor.INDIGO))); - addRenderableWidget(new GuiChemicalGauge(() -> tile.getMultiblock().steamTank, () -> tile.getMultiblock().getChemicalTanks((Direction) null), GaugeType.STANDARD, this, 172, 13) + addRenderableWidget(new GuiChemicalGauge(() -> tile.getMultiblock().steamTank, () -> tile.getMultiblock().getChemicalTanks((Direction) null), GaugeType.STANDARD, this, 174, 13) .setLabel(MekanismLang.BOILER_STEAM_TANK.translateColored(EnumColor.GRAY))); - addRenderableWidget(new GuiChemicalGauge(() -> tile.getMultiblock().cooledCoolantTank, () -> tile.getMultiblock().getChemicalTanks((Direction) null), GaugeType.STANDARD, this, 192, 13) + addRenderableWidget(new GuiChemicalGauge(() -> tile.getMultiblock().cooledCoolantTank, () -> tile.getMultiblock().getChemicalTanks((Direction) null), GaugeType.STANDARD, this, 194, 13) .setLabel(MekanismLang.BOILER_COOLANT_TANK.translateColored(EnumColor.AQUA))); addRenderableWidget(new GuiHeatTab(this, () -> { Component environment = MekanismUtils.getTemperatureDisplay(tile.getMultiblock().lastEnvironmentLoss, TemperatureUnit.KELVIN, false); @@ -89,7 +90,7 @@ public double getLevel() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiUtils.java b/src/main/java/mekanism/client/gui/GuiUtils.java index 15434a9ec82..ab1e6099f7f 100644 --- a/src/main/java/mekanism/client/gui/GuiUtils.java +++ b/src/main/java/mekanism/client/gui/GuiUtils.java @@ -73,7 +73,7 @@ public static void fill(GuiGraphics guiGraphics, int x, int y, int width, int he } public static void drawBackdrop(GuiGraphics guiGraphics, Minecraft minecraft, int x, int y, int width, int alpha) { - drawBackdrop(guiGraphics, minecraft, x, y, width, 9, alpha); + drawBackdrop(guiGraphics, minecraft, x, y, width, minecraft.font.lineHeight, alpha); } public static void drawBackdrop(GuiGraphics guiGraphics, Minecraft minecraft, int x, int y, int width, int height, int alpha) { @@ -251,10 +251,6 @@ public interface CharTypedPredicate { boolean test(ELEMENT element, char c, int keyCode); } - public static int drawString(GuiGraphics guiGraphics, Font font, Component component, float x, float y, int color, boolean drawShadow) { - return guiGraphics.drawString(font, component.getVisualOrderText(), x, y, color, drawShadow); - } - public static int drawStringNoFlush(GuiGraphics graphics, Font font, Component component, float x, float y, int color, boolean drawShadow) { return drawStringNoFlush(graphics, graphics.pose().last().pose(), font, component, x, y, color, drawShadow); } diff --git a/src/main/java/mekanism/client/gui/IGuiWrapper.java b/src/main/java/mekanism/client/gui/IGuiWrapper.java index 6896fb2a6eb..70aba332464 100644 --- a/src/main/java/mekanism/client/gui/IGuiWrapper.java +++ b/src/main/java/mekanism/client/gui/IGuiWrapper.java @@ -4,11 +4,11 @@ import java.util.List; import java.util.function.BooleanSupplier; import mekanism.client.gui.element.window.GuiWindow; +import mekanism.client.render.IFancyFontRenderer; import mekanism.common.Mekanism; import mekanism.common.inventory.container.SelectedWindowData; import mekanism.common.inventory.warning.WarningTracker.WarningType; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.ContainerEventHandler; import net.minecraft.client.gui.screens.Screen; @@ -17,7 +17,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public interface IGuiWrapper extends ContainerEventHandler { +public interface IGuiWrapper extends ContainerEventHandler, IFancyFontRenderer { @NotNull default ItemStack getCarriedItem() { @@ -28,6 +28,7 @@ default ItemStack getCarriedItem() { int getGuiTop(); + @Override int getXSize(); int getYSize(); @@ -55,32 +56,26 @@ default BooleanSupplier trackWarning(@NotNull WarningType type, @NotNull Boolean return warningSupplier; } - Font getFont(); - default void renderItem(GuiGraphics guiGraphics, @NotNull ItemStack stack, int xAxis, int yAxis) { renderItem(guiGraphics, stack, xAxis, yAxis, 1); } default void renderItem(GuiGraphics guiGraphics, @NotNull ItemStack stack, int xAxis, int yAxis, float scale) { - GuiUtils.renderItem(guiGraphics, stack, xAxis, yAxis, scale, getFont(), null, false); - } - - default void renderItemTooltip(GuiGraphics guiGraphics, @NotNull ItemStack stack, int xAxis, int yAxis) { - guiGraphics.renderTooltip(getFont(), stack, xAxis, yAxis); + GuiUtils.renderItem(guiGraphics, stack, xAxis, yAxis, scale, font(), null, false); } default void renderItemTooltipWithExtra(GuiGraphics guiGraphics, @NotNull ItemStack stack, int xAxis, int yAxis, List toAppend) { if (toAppend.isEmpty()) { - renderItemTooltip(guiGraphics, stack, xAxis, yAxis); + guiGraphics.renderTooltip(font(), stack, xAxis, yAxis); } else { List tooltip = new ArrayList<>(Screen.getTooltipFromItem(Minecraft.getInstance(), stack)); tooltip.addAll(toAppend); - guiGraphics.renderTooltip(getFont(), tooltip, stack.getTooltipImage(), stack, xAxis, yAxis); + guiGraphics.renderTooltip(font(), tooltip, stack.getTooltipImage(), stack, xAxis, yAxis); } } default void renderItemWithOverlay(GuiGraphics guiGraphics, @NotNull ItemStack stack, int xAxis, int yAxis, float scale, @Nullable String text) { - GuiUtils.renderItem(guiGraphics, stack, xAxis, yAxis, scale, getFont(), text, true); + GuiUtils.renderItem(guiGraphics, stack, xAxis, yAxis, scale, font(), text, true); } default void setSelectedWindow(SelectedWindowData selectedWindow) { diff --git a/src/main/java/mekanism/client/gui/element/GuiArrowSelection.java b/src/main/java/mekanism/client/gui/element/GuiArrowSelection.java index 3445aab962a..e0c50a1f31b 100644 --- a/src/main/java/mekanism/client/gui/element/GuiArrowSelection.java +++ b/src/main/java/mekanism/client/gui/element/GuiArrowSelection.java @@ -1,8 +1,6 @@ package mekanism.client.gui.element; -import com.mojang.blaze3d.vertex.PoseStack; import java.util.function.Supplier; -import mekanism.client.gui.GuiUtils; import mekanism.client.gui.IGuiWrapper; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -15,11 +13,11 @@ public class GuiArrowSelection extends GuiTexturedElement { private static final ResourceLocation ARROW = MekanismUtils.getResource(ResourceType.GUI, "arrow_selection.png"); - private final Supplier textComponentSupplier; + private final Supplier targetText; - public GuiArrowSelection(IGuiWrapper gui, int x, int y, Supplier textComponentSupplier) { + public GuiArrowSelection(IGuiWrapper gui, int x, int y, Supplier targetText) { super(ARROW, gui, x, y, 33, 19); - this.textComponentSupplier = textComponentSupplier; + this.targetText = targetText; } @Override @@ -29,19 +27,11 @@ public boolean isMouseOver(double xAxis, double yAxis) { } @Override - public void renderToolTip(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - super.renderToolTip(guiGraphics, mouseX, mouseY); - Component component = textComponentSupplier.get(); + public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { + super.renderForeground(guiGraphics, mouseX, mouseY); + Component component = targetText.get(); if (component != null) { - int tooltipX = mouseX + 5; - int tooltipY = mouseY - 5; - PoseStack pose = guiGraphics.pose(); - pose.pushPose(); - //Mirror vanilla's tooltip rendering offset - pose.translate(0, 0, 400); - GuiUtils.renderBackgroundTexture(guiGraphics, GuiInnerScreen.SCREEN, GuiInnerScreen.SCREEN_SIZE, GuiInnerScreen.SCREEN_SIZE, tooltipX - 3, tooltipY - 4, getStringWidth(component) + 6, 16, 256, 256); - drawString(guiGraphics, component, tooltipX, tooltipY, screenTextColor()); - pose.popPose(); + drawScrollingString(guiGraphics, component, getWidth(), 6, TextAlignment.LEFT, screenTextColor(), 15, 1, false); } } diff --git a/src/main/java/mekanism/client/gui/element/GuiColorPickerSlot.java b/src/main/java/mekanism/client/gui/element/GuiColorPickerSlot.java index da795830fba..2c02ceb560b 100644 --- a/src/main/java/mekanism/client/gui/element/GuiColorPickerSlot.java +++ b/src/main/java/mekanism/client/gui/element/GuiColorPickerSlot.java @@ -52,6 +52,6 @@ public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { @Override public void onClick(double mouseX, double mouseY, int button) { - gui().addWindow(new GuiColorWindow(gui(), getGuiWidth() / 2 - 160 / 2, getGuiHeight() / 2 - 120 / 2, handlesAlpha, supplier.get(), consumer)); + gui().addWindow(new GuiColorWindow(gui(), (getGuiWidth() - 160) / 2, (getGuiHeight() - 120) / 2, handlesAlpha, supplier.get(), consumer)); } } diff --git a/src/main/java/mekanism/client/gui/element/GuiDigitalSwitch.java b/src/main/java/mekanism/client/gui/element/GuiDigitalSwitch.java index 314357ff104..6f03f7624d2 100644 --- a/src/main/java/mekanism/client/gui/element/GuiDigitalSwitch.java +++ b/src/main/java/mekanism/client/gui/element/GuiDigitalSwitch.java @@ -42,8 +42,8 @@ public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mou @Override public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); - drawScaledCenteredText(guiGraphics, MekanismLang.ON.translate(), relativeX + type.switchX + 8, relativeY + type.switchY, 0x101010, 0.5F); - drawScaledCenteredText(guiGraphics, MekanismLang.OFF.translate(), relativeX + type.switchX + 8, relativeY + type.switchY + 9, 0x101010, 0.5F); + drawScaledScrollingString(guiGraphics, MekanismLang.ON.translate(), type.switchX, type.switchY, TextAlignment.CENTER, 0x101010, BUTTON_SIZE_X, 1, false, 0.5F); + drawScaledScrollingString(guiGraphics, MekanismLang.OFF.translate(), type.switchX, type.switchY + BUTTON_SIZE_Y + 1, TextAlignment.CENTER, 0x101010, BUTTON_SIZE_X, 1, false, 0.5F); } @Override diff --git a/src/main/java/mekanism/client/gui/element/GuiDropdown.java b/src/main/java/mekanism/client/gui/element/GuiDropdown.java index a8932065d6f..35bb862fc9d 100644 --- a/src/main/java/mekanism/client/gui/element/GuiDropdown.java +++ b/src/main/java/mekanism/client/gui/element/GuiDropdown.java @@ -9,6 +9,7 @@ import mekanism.client.gui.tooltip.TooltipUtils; import mekanism.common.inventory.GuiComponents.IDropdownEnum; import mekanism.common.registries.MekanismSounds; +import net.minecraft.Util; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Tooltip; import net.minecraft.client.gui.navigation.ScreenRectangle; @@ -18,6 +19,11 @@ public class GuiDropdown & IDropdownEnum> extends GuiTexturedElement { + private static final int ELEMENT_HEIGHT = 12; + private static final int ICON_SIZE = 6; + //one for the screen border, one for the hover border, and one more to have a spot between the hover border and the icon + private static final int ICON_OFFSET = ICON_SIZE + 3; + private final Map typeTooltips; private final Consumer handler; private final Supplier curType; @@ -26,10 +32,11 @@ public class GuiDropdown & IDropdownEnum> extends @Nullable private ScreenRectangle cachedTooltipRect; + private long msOpened; private boolean isOpen; public GuiDropdown(IGuiWrapper gui, int x, int y, int width, Class enumClass, Supplier curType, Consumer handler) { - super(GuiInnerScreen.SCREEN, gui, x, y, width, 12); + super(GuiInnerScreen.SCREEN, gui, x, y, width, ELEMENT_HEIGHT); this.curType = curType; this.handler = handler; this.options = enumClass.getEnumConstants(); @@ -51,7 +58,10 @@ public void onRelease(double mouseX, double mouseY) { boolean wasDragging = isDragging(); super.onRelease(mouseX, mouseY); if (wasDragging && isOpen && mouseY > getY() + 11) { - handler.accept(options[getHoveredIndex(mouseX, mouseY)]); + int hoveredIndex = getHoveredIndex(mouseX, mouseY); + if (hoveredIndex != -1) { + handler.accept(options[hoveredIndex]); + } setOpen(false); } } @@ -59,16 +69,21 @@ public void onRelease(double mouseX, double mouseY) { @Override public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); - int maxWidth = width - 11; - TYPE current = curType.get(); - drawScaledTextScaledBound(guiGraphics, current.getShortName(), relativeX + 4, relativeY + 2, screenTextColor(), maxWidth, 0.8F); + drawOptionName(guiGraphics, curType.get(), 2, true); if (isOpen) { for (int i = 0; i < options.length; i++) { - drawScaledTextScaledBound(guiGraphics, options[i].getShortName(), relativeX + 4, relativeY + 11 + 2 + 10 * i, screenTextColor(), maxWidth, 0.8F); + drawOptionName(guiGraphics, options[i], ELEMENT_HEIGHT + 1 + 10 * i, false); } } } + private void drawOptionName(GuiGraphics guiGraphics, TYPE option, int y, boolean alwaysDisplayed) { + //Note: We add one for if we are rendering with an icon so that we allow going closer to the icon + int maxWidth = option.getIcon() == null ? getWidth() : getWidth() - ICON_OFFSET + 1; + drawScaledScrollingString(guiGraphics, option.getShortName(), 0, y, TextAlignment.LEFT, screenTextColor(), maxWidth, 10, 3, false, + 0.8F, alwaysDisplayed ? getTimeOpened() : msOpened); + } + @Override public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { super.drawBackground(guiGraphics, mouseX, mouseY, partialTicks); @@ -76,19 +91,19 @@ public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mou int index = getHoveredIndex(mouseX, mouseY); if (index != -1) { - GuiUtils.drawOutline(guiGraphics, relativeX + 1, relativeY + 12 + index * 10, width - 2, 10, screenTextColor()); + GuiUtils.drawOutline(guiGraphics, relativeX + 1, relativeY + ELEMENT_HEIGHT + index * 10, width - 2, 10, screenTextColor()); } TYPE current = curType.get(); if (current.getIcon() != null) { - guiGraphics.blit(current.getIcon(), relativeX + width - 9, relativeY + 3, 0, 0, 6, 6, 6, 6); + guiGraphics.blit(current.getIcon(), relativeX + width - ICON_OFFSET, relativeY + 3, 0, 0, ICON_SIZE, ICON_SIZE, ICON_SIZE, ICON_SIZE); } if (isOpen) { for (int i = 0; i < options.length; i++) { ResourceLocation icon = options[i].getIcon(); if (icon != null) { - guiGraphics.blit(icon, relativeX + width - 9, relativeY + 12 + 2 + 10 * i, 0, 0, 6, 6, 6, 6); + guiGraphics.blit(icon, relativeX + width - ICON_OFFSET, relativeY + ELEMENT_HEIGHT + 2 + 10 * i, 0, 0, ICON_SIZE, ICON_SIZE, ICON_SIZE, ICON_SIZE); } } } @@ -105,7 +120,7 @@ public void updateTooltip(int mouseX, int mouseY) { int index = getHoveredIndex(mouseX, mouseY); if (index != -1) { Tooltip text = typeTooltips.computeIfAbsent(options[index], t -> TooltipUtils.create(t.getTooltip())); - cachedTooltipRect = new ScreenRectangle(getX() + 1, getY() + 12 + index * 10, width - 2, 10); + cachedTooltipRect = new ScreenRectangle(getX() + 1, getY() + ELEMENT_HEIGHT + index * 10, width - 2, 10); setTooltip(text); } else { clearTooltip(); @@ -122,12 +137,25 @@ private int getHoveredIndex(double mouseX, double mouseY) { private void setOpen(boolean open) { if (isOpen != open) { - if (open) { + isOpen = open; + if (isOpen) { height += options.length * 10 + 1; + msOpened = Util.getMillis(); } else { - height -= options.length * 10 + 1; + height = ELEMENT_HEIGHT; } } - isOpen = open; + } + + @Override + public void syncFrom(GuiElement element) { + super.syncFrom(element); + GuiDropdown old = (GuiDropdown) element; + if (old.isOpen) { + //Sync the fact it is open, and how long it has been open for + isOpen = true; + height += options.length * 10 + 1; + msOpened = old.msOpened; + } } } diff --git a/src/main/java/mekanism/client/gui/element/GuiElement.java b/src/main/java/mekanism/client/gui/element/GuiElement.java index 9160b0c3177..470c8523796 100644 --- a/src/main/java/mekanism/client/gui/element/GuiElement.java +++ b/src/main/java/mekanism/client/gui/element/GuiElement.java @@ -36,6 +36,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.client.sounds.SoundManager; +import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; @@ -77,7 +78,7 @@ public abstract class GuiElement extends AbstractWidget implements IFancyFontRen private boolean isDragging; public GuiElement(IGuiWrapper gui, int x, int y, int width, int height) { - this(gui, x, y, width, height, Component.empty()); + this(gui, x, y, width, height, CommonComponents.EMPTY); } public GuiElement(IGuiWrapper gui, int x, int y, int width, int height, Component text) { @@ -110,6 +111,14 @@ public int getRelativeY() { return relativeY; } + public int getRelativeRight() { + return getRelativeX() + getWidth(); + } + + public int getRelativeBottom() { + return getRelativeY() + getHeight(); + } + /** * Transfers this {@link GuiElement} to a new parent {@link IGuiWrapper}, and moves elements as needed. */ @@ -467,8 +476,8 @@ public boolean mouseScrolled(double mouseX, double mouseY, double xDelta, double } @Override - public Font getFont() { - return guiObj.getFont(); + public Font font() { + return guiObj.font(); } @Override @@ -611,12 +620,19 @@ protected int getButtonTextColor(int mouseX, int mouseY) { return getFGColor(); } + protected boolean displayButtonTextShadow() { + return true; + } + protected void drawButtonText(GuiGraphics guiGraphics, int mouseX, int mouseY) { Component text = getMessage(); //Only attempt to draw the message if we have a message to draw if (!text.getString().isEmpty()) { int color = getButtonTextColor(mouseX, mouseY) | Mth.ceil(alpha * 255.0F) << 24; - drawCenteredTextScaledBound(guiGraphics, text, width - 4, height / 2F - 4, color); + //Note: We add one to the button height as it is considered bounds, and we want to include the bottom pixel of the button in our calculations of where the text should land + //Note: We call super as currently getButtonX and getButtonY already factor in the relative positioning + IFancyFontRenderer.super.drawScrollingString(guiGraphics, text, getButtonX(), getButtonY(), TextAlignment.CENTER, color, getButtonWidth(), + getButtonHeight() + 1, 2, displayButtonTextShadow(), getTimeOpened()); } } @@ -667,7 +683,6 @@ protected static void playClickSound(Supplier sound) { } private static void playClickSound(@NotNull SoundManager soundHandler, @NotNull Supplier sound, float clickVolume) { - soundHandler.play(SimpleSoundInstance.forUI(sound.get(), 1.0F, clickVolume)); } @@ -677,8 +692,20 @@ protected void drawTiledSprite(GuiGraphics guiGraphics, int xPosition, int yPosi } @Override - public void drawCenteredTextScaledBound(GuiGraphics guiGraphics, Component text, float maxLength, float x, float y, int color) { - IFancyFontRenderer.super.drawCenteredTextScaledBound(guiGraphics, text, maxLength, relativeX + x, relativeY + y, color); + public long getTimeOpened() { + return guiObj.getTimeOpened(); + } + + @Override + public final void drawScrollingString(GuiGraphics graphics, Component text, int x, int y, TextAlignment alignment, int color, int width, int height, int maxLengthPad, + boolean shadow, long msVisible) { + IFancyFontRenderer.super.drawScrollingString(graphics, text, relativeX + x, relativeY + y, alignment, color, width, height, maxLengthPad, shadow, msVisible); + } + + @Override + public final void drawScaledScrollingString(GuiGraphics graphics, Component text, int x, int y, TextAlignment alignment, int color, int width, int height, int maxLengthPad, + boolean shadow, float scale, long msVisible) { + IFancyFontRenderer.super.drawScaledScrollingString(graphics, text, relativeX + x, relativeY + y, alignment, color, width, height, maxLengthPad, shadow, scale, msVisible); } public enum ButtonBackground { diff --git a/src/main/java/mekanism/client/gui/element/GuiInnerScreen.java b/src/main/java/mekanism/client/gui/element/GuiInnerScreen.java index 9624f615ee6..c1d2f122903 100644 --- a/src/main/java/mekanism/client/gui/element/GuiInnerScreen.java +++ b/src/main/java/mekanism/client/gui/element/GuiInnerScreen.java @@ -13,6 +13,7 @@ import net.minecraft.client.gui.components.Tooltip; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,7 +31,7 @@ public class GuiInnerScreen extends GuiScalableElement implements IRecipeViewerR private IRecipeViewerRecipeType[] recipeCategories; private boolean centerY; - private int spacing = 1; + private int spacing; private int padding = 3; private float textScale = 1.0F; @@ -55,11 +56,19 @@ public GuiInnerScreen spacing(int spacing) { return this; } + public GuiInnerScreen clearSpacing() { + return spacing(0); + } + public GuiInnerScreen padding(int padding) { this.padding = padding; return this; } + public GuiInnerScreen clearScale() { + return textScale(1); + } + public GuiInnerScreen textScale(float textScale) { this.textScale = textScale; return this; @@ -76,23 +85,38 @@ public GuiInnerScreen clearFormat() { } public GuiInnerScreen defaultFormat() { - return padding(5).spacing(3).textScale(0.8F).centerY(); + return padding(5).spacing(2).textScale(0.8F).centerY(); + } + + protected List getRenderStrings() { + return renderStrings == null ? Collections.emptyList() : renderStrings.get(); } @Override public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); - if (renderStrings != null) { - List list = renderStrings.get(); - float startY = relativeY + padding; + List list = getRenderStrings(); + if (!list.isEmpty()) { + int lineHeight = font().lineHeight; + int minY = relativeY + padding; + int maxY = minY + lineHeight; + int heightToNextLine = lineHeight + spacing; if (centerY) { - int listSize = list.size(); - int totalHeight = listSize * 8 + spacing * (listSize - 1); - startY = relativeY + (getHeight() - totalHeight) / 2F; + int totalHeight = heightToNextLine * list.size() - spacing; + float center = (getHeight() - totalHeight) / 2F; + //If center is not evenly divisible, this will make it so that when we divide to find the target y in scrolling string + // it gets the correct position + minY = relativeY + Mth.floor(center); + maxY = relativeY + lineHeight + Mth.ceil(center); } - for (Component text : renderStrings.get()) { - drawText(guiGraphics, text, relativeX + padding, startY); - startY += 8 + spacing; + int minX = relativeX + padding; + int screenTextColor = screenTextColor(); + for (int i = 0, size = list.size(); i < size; i++) { + Component text = list.get(i); + int maxX = relativeX + getMaxTextWidth(i) - padding; + drawScaledScrollingString(guiGraphics, text, minX, minY, maxX, maxY, TextAlignment.LEFT, screenTextColor, false, textScale, getTimeOpened()); + minY += heightToNextLine; + maxY += heightToNextLine; } } } @@ -112,12 +136,8 @@ public void updateTooltip(int mouseX, int mouseY) { setTooltip(lastTooltip); } - private void drawText(GuiGraphics guiGraphics, Component text, float x, float y) { - drawScaledTextScaledBound(guiGraphics, text, x, y, screenTextColor(), getMaxTextWidth(), textScale); - } - - protected int getMaxTextWidth() { - return getWidth() - padding * 2; + protected int getMaxTextWidth(int row) { + return getWidth(); } @NotNull diff --git a/src/main/java/mekanism/client/gui/element/GuiScreenSwitch.java b/src/main/java/mekanism/client/gui/element/GuiScreenSwitch.java index 928e60770fa..d68bcd3fd52 100644 --- a/src/main/java/mekanism/client/gui/element/GuiScreenSwitch.java +++ b/src/main/java/mekanism/client/gui/element/GuiScreenSwitch.java @@ -15,12 +15,13 @@ public class GuiScreenSwitch extends GuiInnerScreen { private final IClickable onToggle; public GuiScreenSwitch(IGuiWrapper gui, int x, int y, int width, Component buttonName, BooleanSupplier stateSupplier, IClickable onToggle) { - super(gui, x, y, width, GuiDigitalSwitch.BUTTON_SIZE_Y * 2 + 5, () -> Collections.singletonList(buttonName)); + super(gui, x, y, width, GuiDigitalSwitch.BUTTON_SIZE_Y * 2 + 6, () -> Collections.singletonList(buttonName)); this.stateSupplier = stateSupplier; this.onToggle = onToggle; this.active = true; this.clickSound = () -> this.stateSupplier.getAsBoolean() ? MekanismSounds.BEEP_OFF.get() : MekanismSounds.BEEP_ON.get(); this.clickVolume = 1.0F; + padding(4); } @Override @@ -28,15 +29,18 @@ public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mou super.drawBackground(guiGraphics, mouseX, mouseY, partialTicks); int buttonSizeX = GuiDigitalSwitch.BUTTON_SIZE_X; int buttonSizeY = GuiDigitalSwitch.BUTTON_SIZE_Y; - guiGraphics.blit(GuiDigitalSwitch.SWITCH, relativeX + width - 2 - buttonSizeX, relativeY + 2, 0, stateSupplier.getAsBoolean() ? 0 : buttonSizeY, buttonSizeX, buttonSizeY, buttonSizeX, buttonSizeY * 2); - guiGraphics.blit(GuiDigitalSwitch.SWITCH, relativeX + width - 2 - buttonSizeX, relativeY + 2 + buttonSizeY + 1, 0, stateSupplier.getAsBoolean() ? buttonSizeY : 0, buttonSizeX, buttonSizeY, buttonSizeX, buttonSizeY * 2); + int buttonXOffset = width - 2 - buttonSizeX; + guiGraphics.blit(GuiDigitalSwitch.SWITCH, relativeX + buttonXOffset, relativeY + 2, 0, stateSupplier.getAsBoolean() ? 0 : buttonSizeY, buttonSizeX, buttonSizeY, buttonSizeX, buttonSizeY * 2); + guiGraphics.blit(GuiDigitalSwitch.SWITCH, relativeX + buttonXOffset, relativeY + 2 + buttonSizeY + 1, 0, stateSupplier.getAsBoolean() ? buttonSizeY : 0, buttonSizeX, buttonSizeY, buttonSizeX, buttonSizeY * 2); } @Override public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); - drawScaledCenteredText(guiGraphics, MekanismLang.ON.translate(), relativeX + width - 9, relativeY + 2, 0x101010, 0.5F); - drawScaledCenteredText(guiGraphics, MekanismLang.OFF.translate(), relativeX + width - 9, relativeY + 11, 0x101010, 0.5F); + int buttonSizeX = GuiDigitalSwitch.BUTTON_SIZE_X; + int buttonXOffset = width - 2 - buttonSizeX; + drawScaledScrollingString(guiGraphics, MekanismLang.ON.translate(), buttonXOffset, 2, TextAlignment.CENTER, 0x101010, buttonSizeX, 1, false, 0.5F); + drawScaledScrollingString(guiGraphics, MekanismLang.OFF.translate(), buttonXOffset, 11, TextAlignment.CENTER, 0x101010, buttonSizeX, 1, false, 0.5F); } @Override @@ -45,7 +49,7 @@ public void onClick(double mouseX, double mouseY, int button) { } @Override - protected int getMaxTextWidth() { - return super.getMaxTextWidth() - 2 - GuiDigitalSwitch.BUTTON_SIZE_X; + protected int getMaxTextWidth(int row) { + return super.getMaxTextWidth(row) - 2 - GuiDigitalSwitch.BUTTON_SIZE_X; } } diff --git a/src/main/java/mekanism/client/gui/element/button/BasicColorButton.java b/src/main/java/mekanism/client/gui/element/button/BasicColorButton.java index d1217737c82..9fb13751122 100644 --- a/src/main/java/mekanism/client/gui/element/button/BasicColorButton.java +++ b/src/main/java/mekanism/client/gui/element/button/BasicColorButton.java @@ -7,7 +7,7 @@ import mekanism.client.render.MekanismRenderer; import mekanism.common.lib.Color; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.CommonComponents; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -20,7 +20,7 @@ public static BasicColorButton toggle(IGuiWrapper gui, int x, int y, int size, E private final Supplier colorSupplier; public BasicColorButton(IGuiWrapper gui, int x, int y, int size, Supplier color, @NotNull IClickable onLeftClick, @Nullable IClickable onRightClick) { - super(gui, x, y, size, size, Component.empty(), onLeftClick, onRightClick); + super(gui, x, y, size, size, CommonComponents.EMPTY, onLeftClick, onRightClick); this.colorSupplier = color; } diff --git a/src/main/java/mekanism/client/gui/element/button/ColorButton.java b/src/main/java/mekanism/client/gui/element/button/ColorButton.java index 030dade289a..595929389f3 100644 --- a/src/main/java/mekanism/client/gui/element/button/ColorButton.java +++ b/src/main/java/mekanism/client/gui/element/button/ColorButton.java @@ -9,7 +9,7 @@ import mekanism.common.MekanismLang; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Tooltip; -import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.CommonComponents; import org.jetbrains.annotations.NotNull; public class ColorButton extends MekanismButton { @@ -20,7 +20,7 @@ public class ColorButton extends MekanismButton { private final Supplier colorSupplier; public ColorButton(IGuiWrapper gui, int x, int y, int width, int height, Supplier colorSupplier, @NotNull IClickable onPress, @NotNull IClickable onRightClick) { - super(gui, x, y, width, height, Component.empty(), onPress, onRightClick); + super(gui, x, y, width, height, CommonComponents.EMPTY, onPress, onRightClick); this.colorSupplier = colorSupplier; } diff --git a/src/main/java/mekanism/client/gui/element/button/DigitalButton.java b/src/main/java/mekanism/client/gui/element/button/DigitalButton.java index 0ea1fc5e474..eb6e00b7207 100644 --- a/src/main/java/mekanism/client/gui/element/button/DigitalButton.java +++ b/src/main/java/mekanism/client/gui/element/button/DigitalButton.java @@ -22,4 +22,9 @@ protected int getButtonTextColor(int mouseX, int mouseY) { } return Color.argb(screenTextColor()).darken(0.4).argb(); } + + @Override + protected boolean displayButtonTextShadow() { + return false; + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/element/button/FilterButton.java b/src/main/java/mekanism/client/gui/element/button/FilterButton.java index 404aa3e31aa..88450ee6b16 100644 --- a/src/main/java/mekanism/client/gui/element/button/FilterButton.java +++ b/src/main/java/mekanism/client/gui/element/button/FilterButton.java @@ -7,6 +7,7 @@ import java.util.function.ObjIntConsumer; import java.util.function.Predicate; import mekanism.api.text.EnumColor; +import mekanism.api.text.TextComponentUtil; import mekanism.client.gui.GuiUtils; import mekanism.client.gui.IGuiWrapper; import mekanism.client.gui.element.slot.GuiSequencedSlotDisplay; @@ -27,6 +28,7 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; @@ -58,7 +60,7 @@ private static IFilter getFilter(FilterManager filterManager, int index) { public FilterButton(IGuiWrapper gui, int x, int y, int width, int height, int index, IntSupplier filterIndex, FilterManager filterManager, ObjIntConsumer> onPress, IntConsumer toggleButtonPress, Function, List> renderStackSupplier) { - super(gui, x, y, width, height, Component.empty(), (element, mouseX, mouseY) -> { + super(gui, x, y, width, height, CommonComponents.EMPTY, (element, mouseX, mouseY) -> { FilterButton button = (FilterButton) element; int actualIndex = button.filterIndex.getAsInt() + button.index; button.onPress.accept(getFilter(button.filterManager, actualIndex), actualIndex); @@ -132,12 +134,15 @@ public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { } Component filterDescriptor = switch (filter) { case IItemStackFilter item -> item.getItemStack().getHoverName(); - case ITagFilter tag -> Component.literal(tag.getTagName()); - case IModIDFilter modId -> Component.literal(modId.getModID()); - case OredictionificatorFilter oredictionificatorFilter -> Component.literal(oredictionificatorFilter.getFilterText()); - case null, default -> Component.empty(); + case ITagFilter tag -> TextComponentUtil.getString(tag.getTagName()); + case IModIDFilter modId -> TextComponentUtil.getString(modId.getModID()); + case OredictionificatorFilter oredictionificatorFilter -> TextComponentUtil.getString(oredictionificatorFilter.getFilterText()); + case null, default -> null; }; - drawFilterDescriptor(guiGraphics, filterDescriptor, relativeX, relativeY); + int textWidth = toggleButton.getRelativeX() - relativeX - 20; + if (filterDescriptor != null) { + drawScrollingString(guiGraphics, filterDescriptor, 19, 3, TextAlignment.LEFT, titleTextColor(), textWidth, 3, false); + } if (filter instanceof SorterFilter sorterFilter) { int colorX = relativeX + 22; @@ -147,23 +152,16 @@ public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { guiGraphics.fill(colorX + 1, colorY + 1, colorX + 5, colorY + 5, sorterFilter.color.getPackedColor()); } - drawTextWithScale(guiGraphics, sorterFilter.color == null ? MekanismLang.NO_COLOR.translate() : sorterFilter.color.getName(), relativeX + 22 + 8, relativeY + 12, - titleTextColor(), 0.5f); + Component color = sorterFilter.color == null ? MekanismLang.NO_COLOR.translate() : sorterFilter.color.getName(); + drawScaledScrollingString(guiGraphics, color, 27, 12, TextAlignment.LEFT, titleTextColor(), textWidth - 8, 3, false, 0.7F); } else if (filter instanceof OredictionificatorItemFilter oreDictFilter) { - drawTextWithScale(guiGraphics, oreDictFilter.getResult().getHoverName().copy().append(" (" + BuiltInRegistries.ITEM.getKey(oreDictFilter.getResultElement()).getNamespace() + ")"), relativeX + 22, relativeY + 12, - titleTextColor(), 0.5f); + ItemStack result = oreDictFilter.getResult(); + Component text = TextComponentUtil.build(result, " (", BuiltInRegistries.ITEM.getKey(result.getItem()).getNamespace(), ")"); + drawScaledScrollingString(guiGraphics, text, 19, 12, TextAlignment.LEFT, titleTextColor(), textWidth, 3, false, 0.7F); } else if (filter instanceof QIOItemStackFilter itemFilter) { if (itemFilter.fuzzyMode) { - drawTextWithScale(guiGraphics, MekanismLang.FUZZY_MODE.translate(), relativeX + 22, relativeY + 12, titleTextColor(), 0.5f); + drawScaledScrollingString(guiGraphics, MekanismLang.FUZZY_MODE.translate(), 19, 12, TextAlignment.LEFT, titleTextColor(), textWidth, 3, false, 0.7F); } } } - - private void drawFilterDescriptor(GuiGraphics guiGraphics, Component component, int x, int y) { - drawTextScaledBound(guiGraphics, component, x + 22, y + 3, titleTextColor(), getMaxLength()); - } - - protected int getMaxLength() { - return width - 22 - RadioButton.RADIO_SIZE - 11; - } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/element/button/FilterSelectButton.java b/src/main/java/mekanism/client/gui/element/button/FilterSelectButton.java index 5426b1d1730..b9f4ea71f60 100644 --- a/src/main/java/mekanism/client/gui/element/button/FilterSelectButton.java +++ b/src/main/java/mekanism/client/gui/element/button/FilterSelectButton.java @@ -6,7 +6,7 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.CommonComponents; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; @@ -19,7 +19,7 @@ public class FilterSelectButton extends MekanismButton { private final boolean down; public FilterSelectButton(IGuiWrapper gui, int x, int y, boolean down, @NotNull IClickable onPress) { - super(gui, x, y, 11, 7, Component.empty(), onPress); + super(gui, x, y, 11, 7, CommonComponents.EMPTY, onPress); this.down = down; } diff --git a/src/main/java/mekanism/client/gui/element/button/GuiGasMode.java b/src/main/java/mekanism/client/gui/element/button/GuiGasMode.java index 91eec01551c..2dc834fccec 100644 --- a/src/main/java/mekanism/client/gui/element/button/GuiGasMode.java +++ b/src/main/java/mekanism/client/gui/element/button/GuiGasMode.java @@ -11,7 +11,6 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Tooltip; import net.minecraft.core.BlockPos; -import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; public class GuiGasMode extends MekanismImageButton { @@ -22,7 +21,7 @@ public class GuiGasMode extends MekanismImageButton { private final Tooltip dumpExcess; private final Tooltip dump; - private final boolean left; + private final TextAlignment textSide; private final Supplier gasModeSupplier; public GuiGasMode(IGuiWrapper gui, int x, int y, boolean left, Supplier gasModeSupplier, BlockPos pos, int tank) { @@ -31,7 +30,7 @@ public GuiGasMode(IGuiWrapper gui, int x, int y, boolean left, Supplier public GuiGasMode(IGuiWrapper gui, int x, int y, boolean left, Supplier gasModeSupplier, BlockPos pos, int tank, Tooltip dumpExcess, Tooltip dump) { super(gui, x, y, 10, IDLE, (element, mouseX, mouseY) -> PacketUtils.sendToServer(new PacketGuiInteract(GuiInteraction.GAS_MODE_BUTTON, pos, tank))); - this.left = left; + this.textSide = left ? TextAlignment.RIGHT : TextAlignment.LEFT; this.gasModeSupplier = gasModeSupplier; this.dumpExcess = dumpExcess; this.dump = dump; @@ -49,12 +48,8 @@ protected ResourceLocation getResource() { @Override public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { //Draw the text next to the button - Component component = gasModeSupplier.get().getTextComponent(); - if (left) { - drawTextScaledBound(guiGraphics, component, relativeX - 3 - (int) (getStringWidth(component) * getNeededScale(component, 66)), relativeY + 1, titleTextColor(), 66); - } else { - drawTextScaledBound(guiGraphics, component, relativeX + width + 5, relativeY + 1, titleTextColor(), 66); - } + int start = textSide == TextAlignment.RIGHT ? -69 : getWidth(); + drawScrollingString(guiGraphics, gasModeSupplier.get().getTextComponent(), start, 1, textSide, titleTextColor(), 69, 2, false); super.renderForeground(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/element/button/MekanismImageButton.java b/src/main/java/mekanism/client/gui/element/button/MekanismImageButton.java index 1da39c4cfe1..e6c986c7ba4 100644 --- a/src/main/java/mekanism/client/gui/element/button/MekanismImageButton.java +++ b/src/main/java/mekanism/client/gui/element/button/MekanismImageButton.java @@ -2,7 +2,7 @@ import mekanism.client.gui.IGuiWrapper; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.CommonComponents; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; @@ -28,7 +28,7 @@ public MekanismImageButton(IGuiWrapper gui, int x, int y, int width, int height, public MekanismImageButton(IGuiWrapper gui, int x, int y, int width, int height, int textureWidth, int textureHeight, ResourceLocation resource, @NotNull IClickable onLeftClick, @NotNull IClickable onRightClick) { - super(gui, x, y, width, height, Component.empty(), onLeftClick, onRightClick); + super(gui, x, y, width, height, CommonComponents.EMPTY, onLeftClick, onRightClick); this.resourceLocation = resource; this.textureWidth = textureWidth; this.textureHeight = textureHeight; diff --git a/src/main/java/mekanism/client/gui/element/button/MovableFilterButton.java b/src/main/java/mekanism/client/gui/element/button/MovableFilterButton.java index 0efd44e8e90..e0fdcccceba 100644 --- a/src/main/java/mekanism/client/gui/element/button/MovableFilterButton.java +++ b/src/main/java/mekanism/client/gui/element/button/MovableFilterButton.java @@ -90,9 +90,4 @@ public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mou } updateButtonVisibility(filter); } - - @Override - protected int getMaxLength() { - return super.getMaxLength() - 12; - } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/element/button/RadioButton.java b/src/main/java/mekanism/client/gui/element/button/RadioButton.java index f45f999db2d..5f24989b6de 100644 --- a/src/main/java/mekanism/client/gui/element/button/RadioButton.java +++ b/src/main/java/mekanism/client/gui/element/button/RadioButton.java @@ -8,6 +8,7 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Tooltip; +import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; @@ -22,7 +23,7 @@ public class RadioButton extends MekanismButton { private final BooleanSupplier toggled; public RadioButton(IGuiWrapper gui, int x, int y, BooleanSupplier toggled, @NotNull IClickable onPress, Component toggledComponent, Component altComponent) { - super(gui, x, y, RADIO_SIZE, RADIO_SIZE, Component.empty(), onPress); + super(gui, x, y, RADIO_SIZE, RADIO_SIZE, CommonComponents.EMPTY, onPress); this.toggled = toggled; this.toggledComponent = TooltipUtils.create(toggledComponent); this.altComponent = TooltipUtils.create(altComponent); diff --git a/src/main/java/mekanism/client/gui/element/button/SideDataButton.java b/src/main/java/mekanism/client/gui/element/button/SideDataButton.java index 7a60154ae15..23f2e4cc507 100644 --- a/src/main/java/mekanism/client/gui/element/button/SideDataButton.java +++ b/src/main/java/mekanism/client/gui/element/button/SideDataButton.java @@ -84,7 +84,7 @@ public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mou super.drawBackground(guiGraphics, mouseX, mouseY, partialTicks); if (!otherBlockItem.isEmpty()) { - GuiUtils.renderItem(guiGraphics, otherBlockItem, this.getRelativeX() + 3, this.getRelativeY() + 3, 1, getFont(), null, true); + GuiUtils.renderItem(guiGraphics, otherBlockItem, this.getRelativeX() + 3, this.getRelativeY() + 3, 1, font(), null, true); } } diff --git a/src/main/java/mekanism/client/gui/element/custom/GuiDictionaryTarget.java b/src/main/java/mekanism/client/gui/element/custom/GuiDictionaryTarget.java index 57fb1ef423b..bf509d03aa6 100644 --- a/src/main/java/mekanism/client/gui/element/custom/GuiDictionaryTarget.java +++ b/src/main/java/mekanism/client/gui/element/custom/GuiDictionaryTarget.java @@ -92,7 +92,7 @@ public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mou public void renderToolTip(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderToolTip(guiGraphics, mouseX, mouseY); if (target instanceof ItemStack stack) { - gui().renderItemTooltip(guiGraphics, stack, mouseX, mouseY); + guiGraphics.renderTooltip(font(), stack, mouseX, mouseY); } } diff --git a/src/main/java/mekanism/client/gui/element/custom/GuiFrequencySelector.java b/src/main/java/mekanism/client/gui/element/custom/GuiFrequencySelector.java index 3179a98f6d7..10db3d03006 100644 --- a/src/main/java/mekanism/client/gui/element/custom/GuiFrequencySelector.java +++ b/src/main/java/mekanism/client/gui/element/custom/GuiFrequencySelector.java @@ -37,6 +37,7 @@ import mekanism.common.util.text.OwnerDisplay; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import org.jetbrains.annotations.Nullable; @@ -50,7 +51,6 @@ public class GuiFrequencySelector extends GuiElement { private final MekanismButton deleteButton; private final GuiTextScrollList scrollList; private final GuiTextField frequencyField; - private final int yStart; //Used to keep track of the last list of frequencies, by taking advantage of container sync providing a new list object // each time things are synced currently so that we can just do an identity compare private List lastFrequencies = Collections.emptyList(); @@ -60,24 +60,23 @@ public class GuiFrequencySelector extends GuiElement { public > GuiFrequencySelector(SELECTOR frequencySelector, int yStart) { super(frequencySelector, 27, yStart, 132, 121); this.frequencySelector = frequencySelector; - this.yStart = yStart; boolean hasColor = frequencySelector instanceof IGuiColorFrequencySelector; - scrollList = addChild(new GuiTextScrollList(frequencySelector, 27, yStart + 22, 122, 42)); - publicButton = addChild(new MekanismImageButton(frequencySelector, 27, yStart, 38, 20, 38, 20, getButtonLocation("public"), + scrollList = addChild(new GuiTextScrollList(frequencySelector, relativeX, relativeY + 22, 122, 42)); + publicButton = addChild(new MekanismImageButton(frequencySelector, relativeX, relativeY, 38, 20, 38, 20, getButtonLocation("public"), (element, mouseX, mouseY) -> { this.securityMode = SecurityMode.PUBLIC; this.scrollList.clearSelection(); updateButtons(); return true; })).setTooltip(MekanismLang.PUBLIC_MODE); - trustedButton = addChild(new MekanismImageButton(frequencySelector, 69, yStart, 38, 20, 38, 20, getButtonLocation("trusted"), + trustedButton = addChild(new MekanismImageButton(frequencySelector, relativeX + 42, relativeY, 38, 20, 38, 20, getButtonLocation("trusted"), (element, mouseX, mouseY) -> { this.securityMode = SecurityMode.TRUSTED; this.scrollList.clearSelection(); updateButtons(); return true; })).setTooltip(MekanismLang.TRUSTED_MODE); - privateButton = addChild(new MekanismImageButton(frequencySelector, 111, yStart, 38, 20, 38, 20, getButtonLocation("private"), + privateButton = addChild(new MekanismImageButton(frequencySelector, relativeX + 84, relativeY, 38, 20, 38, 20, getButtonLocation("private"), (element, mouseX, mouseY) -> { this.securityMode = SecurityMode.PRIVATE; this.scrollList.clearSelection(); @@ -85,7 +84,7 @@ public > GuiFrequency return true; })).setTooltip(MekanismLang.PRIVATE_MODE); int buttonWidth = hasColor ? 50 : 60; - setButton = addChild(new TranslationButton(frequencySelector, 27, yStart + 113, buttonWidth, 18, MekanismLang.BUTTON_SET, (element, mouseX, mouseY) -> { + setButton = addChild(new TranslationButton(frequencySelector, relativeX, relativeY + 113, buttonWidth, 18, MekanismLang.BUTTON_SET, (element, mouseX, mouseY) -> { int selection = this.scrollList.getSelection(); if (selection != -1) { Frequency frequency = getFrequencies().get(selection); @@ -96,7 +95,7 @@ public > GuiFrequency updateButtons(); return true; })); - deleteButton = addChild(new TranslationButton(frequencySelector, 29 + buttonWidth, yStart + 113, buttonWidth, 18, MekanismLang.BUTTON_DELETE, (element, mouseX, mouseY) -> { + deleteButton = addChild(new TranslationButton(frequencySelector, relativeX + 2 + buttonWidth, relativeY + 113, buttonWidth, 18, MekanismLang.BUTTON_DELETE, (element, mouseX, mouseY) -> { GuiConfirmationDialog.show(gui(), MekanismLang.FREQUENCY_DELETE_CONFIRM.translate(), () -> { int selection = this.scrollList.getSelection(); if (selection != -1) { @@ -111,9 +110,9 @@ public > GuiFrequency return true; })); if (hasColor) { - addChild(new GuiSlot(SlotType.NORMAL, frequencySelector, 131, yStart + 113).setRenderAboveSlots()); + addChild(new GuiSlot(SlotType.NORMAL, frequencySelector, relativeX + 104, relativeY + 113)); IGuiColorFrequencySelector colorFrequencySelector = (IGuiColorFrequencySelector) frequencySelector; - addChild(new ColorButton(frequencySelector, 132, yStart + 114, 16, 16, () -> { + addChild(new ColorButton(frequencySelector, relativeX + 105, relativeY + 114, 16, 16, () -> { IColorableFrequency frequency = colorFrequencySelector.getFrequency(); return frequency == null ? null : frequency.getColor(); }, (element, mouseX, mouseY) -> { @@ -124,7 +123,7 @@ public > GuiFrequency return true; })); } - frequencyField = addChild(new GuiTextField(frequencySelector, this, 50, yStart + 99, 98, 11)); + frequencyField = addChild(new GuiTextField(frequencySelector, this, relativeX + 23, relativeY + 99, 98, 11)); frequencyField.setMaxLength(FrequencyManager.MAX_FREQ_LENGTH); frequencyField.setBackground(BackgroundType.INNER_SCREEN); frequencyField.setEnterHandler(this::setFrequency); @@ -212,20 +211,28 @@ private void setFrequency(String freq, @Nullable UUID ownerUUID) { public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); FREQ frequency = frequencySelector.getFrequency(); + Object frequencyName; + Component ownerComponent; + Object frequencySecurity; if (frequency == null) { MutableComponent noneComponent = MekanismLang.NONE.translateColored(EnumColor.DARK_RED); - drawString(guiGraphics, MekanismLang.FREQUENCY.translate(noneComponent), 27, yStart + 67, titleTextColor()); - drawString(guiGraphics, MekanismLang.OWNER.translate(noneComponent), 27, yStart + 77, titleTextColor()); - drawString(guiGraphics, MekanismLang.SECURITY.translate(noneComponent), 27, yStart + 87, titleTextColor()); + frequencyName = noneComponent; + ownerComponent = MekanismLang.OWNER.translate(noneComponent); + frequencySecurity = noneComponent; } else { //Color the name the same as the subheading text color should be - MutableComponent name = TextComponentUtil.color(TextComponentUtil.getString(frequency.getName()), subheadingTextColor()); - drawTextScaledBound(guiGraphics, MekanismLang.FREQUENCY.translate(name), 27, yStart + 67, titleTextColor(), getGuiWidth() - 36); - drawString(guiGraphics, OwnerDisplay.of(Minecraft.getInstance().player, frequency.getOwner(), frequency.getOwnerName(), false).getTextComponent(), - 27, yStart + 77, titleTextColor()); - drawString(guiGraphics, MekanismLang.SECURITY.translate(frequency.getSecurity()), 27, yStart + 87, titleTextColor()); + frequencyName = TextComponentUtil.color(TextComponentUtil.getString(frequency.getName()), subheadingTextColor()); + ownerComponent = OwnerDisplay.of(Minecraft.getInstance().player, frequency.getOwner(), frequency.getOwnerName(), false).getTextComponent(); + frequencySecurity = frequency.getSecurity(); } - drawTextScaledBound(guiGraphics, MekanismLang.SET.translate(), 27, yStart + 100, titleTextColor(), 20); + int textEnd = getGuiWidth() - relativeX - 10; + drawScrollingString(guiGraphics, MekanismLang.FREQUENCY.translate(frequencyName), 0, 67, TextAlignment.LEFT, titleTextColor(), textEnd, 0, false); + drawScrollingString(guiGraphics, ownerComponent, 0, 77, TextAlignment.LEFT, titleTextColor(), textEnd, 0, false); + drawScrollingString(guiGraphics, MekanismLang.SECURITY.translate(frequencySecurity), 0, 87, TextAlignment.LEFT, titleTextColor(), textEnd, 0, false); + + //If it gets to wide, allow it to go to the left of the area + //TODO: Re-evaluate this behavior, and if we should define some min bound in a different way + drawScrollingString(guiGraphics, MekanismLang.SET.translate(), -relativeX, 100, TextAlignment.RIGHT, titleTextColor(), frequencyField.getRelativeX(), 5, false); } public interface IGuiFrequencySelector { diff --git a/src/main/java/mekanism/client/gui/element/custom/GuiQIOCrystallizerScreen.java b/src/main/java/mekanism/client/gui/element/custom/GuiQIOCrystallizerScreen.java new file mode 100644 index 00000000000..66859d2412e --- /dev/null +++ b/src/main/java/mekanism/client/gui/element/custom/GuiQIOCrystallizerScreen.java @@ -0,0 +1,140 @@ +package mekanism.client.gui.element.custom; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import mekanism.api.MekanismAPI; +import mekanism.api.MekanismAPITags; +import mekanism.api.chemical.Chemical; +import mekanism.api.chemical.ChemicalStack; +import mekanism.api.recipes.ChemicalCrystallizerRecipe; +import mekanism.client.gui.IGuiWrapper; +import mekanism.client.gui.element.GuiInnerScreen; +import mekanism.client.gui.element.slot.GuiSequencedSlotDisplay; +import mekanism.client.gui.element.slot.GuiSlot; +import mekanism.client.gui.element.slot.SlotType; +import mekanism.common.MekanismLang; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class GuiQIOCrystallizerScreen extends GuiInnerScreen { + + @Nullable + private final GuiSequencedSlotDisplay slotDisplay; + private final List iterStacks; + private final IOreInfo oreInfo; + private final GuiSlot slot; + + @NotNull + private Chemical prevSlurry = MekanismAPI.EMPTY_CHEMICAL; + + public GuiQIOCrystallizerScreen(IGuiWrapper gui, int x, int y, int width, int height, IOreInfo oreInfo) { + 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, relativeY)); + if (this.oreInfo.usesSequencedDisplay()) { + this.iterStacks = new ArrayList<>(); + this.slotDisplay = addChild(new GuiSequencedSlotDisplay(gui, slotX + 1, relativeY + 1, () -> this.iterStacks)); + updateSlotContents(); + } else { + this.iterStacks = Collections.emptyList(); + this.slotDisplay = null; + } + defaultFormat(); + } + + public int getSlotX() { + return this.slot.getX(); + } + + public int getSlotY() { + return this.slot.getY(); + } + + @Override + public void tick() { + updateSlotContents(); + super.tick(); + } + + private void updateSlotContents() { + if (oreInfo.usesSequencedDisplay() && slotDisplay != null) {//Note: If we use the sequenced display, slotDisplay should never be null + ChemicalStack chemical = oreInfo.getInputChemical(); + if (!chemical.isEmpty()) { + Chemical inputSlurry = chemical.getChemical(); + if (prevSlurry != inputSlurry) { + prevSlurry = inputSlurry; + iterStacks.clear(); + if (!prevSlurry.isEmptyType() && !prevSlurry.is(MekanismAPITags.Chemicals.DIRTY)) { + TagKey oreTag = prevSlurry.getOreTag(); + if (oreTag != null) { + for (Holder ore : BuiltInRegistries.ITEM.getTagOrEmpty(oreTag)) { + iterStacks.add(new ItemStack(ore)); + } + } + } + slotDisplay.updateStackList(); + } + } else if (!prevSlurry.isEmptyType()) { + prevSlurry = MekanismAPI.EMPTY_CHEMICAL; + iterStacks.clear(); + slotDisplay.updateStackList(); + } + } + } + + @Override + protected List getRenderStrings() { + ChemicalStack chemical = oreInfo.getInputChemical(); + if (!chemical.isEmpty()) { + Component recipeComponent; + //Note: If we use the sequenced display, slotDisplay should never be null + ItemStack renderStack = oreInfo.usesSequencedDisplay() && slotDisplay != null ? slotDisplay.getRenderStack() : oreInfo.getRenderStack(); + if (!renderStack.isEmpty()) { + recipeComponent = MekanismLang.GENERIC_PARENTHESIS.translate(renderStack); + } else { + ChemicalCrystallizerRecipe recipe = oreInfo.getRecipe(); + if (recipe == null) { + recipeComponent = MekanismLang.NO_RECIPE.translate(); + } else { + recipeComponent = MekanismLang.GENERIC_PARENTHESIS.translate(recipe.getOutput(chemical)); + } + } + return List.of(chemical.getTextComponent(), recipeComponent); + } + return Collections.emptyList(); + } + + @Override + protected int getMaxTextWidth(int row) { + if (row == 0) {//Don't allow the first line of text to intersect with the slot we draw + return width - slot.getWidth(); + } + return super.getMaxTextWidth(row); + } + + public interface IOreInfo { + + @NotNull + ChemicalStack getInputChemical(); + + @Nullable + ChemicalCrystallizerRecipe getRecipe(); + + @NotNull + default ItemStack getRenderStack() { + return ItemStack.EMPTY; + } + + default boolean usesSequencedDisplay() { + return true; + } + } +} diff --git a/src/main/java/mekanism/client/gui/element/custom/GuiQIOFrequencyDataScreen.java b/src/main/java/mekanism/client/gui/element/custom/GuiQIOFrequencyDataScreen.java index a664c51b8c9..60028f30c88 100644 --- a/src/main/java/mekanism/client/gui/element/custom/GuiQIOFrequencyDataScreen.java +++ b/src/main/java/mekanism/client/gui/element/custom/GuiQIOFrequencyDataScreen.java @@ -33,7 +33,7 @@ public Component getTooltip() { return freq == null ? null : MekanismLang.QIO_ITEMS_DETAIL.translateColored(EnumColor.GRAY, EnumColor.INDIGO, TextUtils.format(freq.getTotalItemCount()), TextUtils.format(freq.getTotalItemCountCapacity())); } - }, relativeX + (width / 4) - (50 / 2), relativeY + 20, 50)); + }, relativeX + 11, relativeY + 20, 50)); addChild(new GuiDigitalBar(gui, new IBarInfoHandler() { @Override public double getLevel() { @@ -47,7 +47,7 @@ public Component getTooltip() { return freq == null ? null : MekanismLang.QIO_TYPES_DETAIL.translateColored(EnumColor.GRAY, EnumColor.INDIGO, TextUtils.format(freq.getTotalItemTypes(true)), TextUtils.format(freq.getTotalItemTypeCapacity())); } - }, relativeX + (3 * width / 4) - (50 / 2), relativeY + 20, 50)); + }, relativeX + 83, relativeY + 20, 50)); } @Override @@ -55,9 +55,9 @@ public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); QIOFrequency freq = frequencySupplier.get(); if (freq != null) { - drawScaledTextScaledBound(guiGraphics, MekanismLang.FREQUENCY.translate(freq.getName()), relativeX + 5, relativeY + 5, screenTextColor(), width - 10, 0.8F); + drawScaledScrollingString(guiGraphics, MekanismLang.FREQUENCY.translate(freq.getName()), 0, 5, TextAlignment.LEFT, screenTextColor(), 5, false, 0.8F); } - drawScaledCenteredText(guiGraphics, MekanismLang.QIO_ITEMS.translate(), relativeX + (width / 4), relativeY + 32, screenTextColor(), 0.8F); - drawScaledCenteredText(guiGraphics, MekanismLang.QIO_TYPES.translate(), relativeX + (3 * width / 4), relativeY + 32, screenTextColor(), 0.8F); + drawScaledScrollingString(guiGraphics, MekanismLang.QIO_ITEMS.translate(), 11, 32, TextAlignment.CENTER, screenTextColor(), 50, 0, false, 0.8F); + drawScaledScrollingString(guiGraphics, MekanismLang.QIO_TYPES.translate(), 83, 32, TextAlignment.CENTER, screenTextColor(), 50, 0, false, 0.8F); } } diff --git a/src/main/java/mekanism/client/gui/element/custom/GuiResizeControls.java b/src/main/java/mekanism/client/gui/element/custom/GuiResizeControls.java index 1145438c5c3..cfbd8cc1a1e 100644 --- a/src/main/java/mekanism/client/gui/element/custom/GuiResizeControls.java +++ b/src/main/java/mekanism/client/gui/element/custom/GuiResizeControls.java @@ -29,10 +29,10 @@ public class GuiResizeControls extends GuiSideHolder { private static final ResourceLocation PLUS = MekanismUtils.getResource(ResourceType.GUI_BUTTON, "plus.png"); public GuiResizeControls(GUI gui, int y) { - super(gui, -26, y, 39, true, false); + super(gui, -26, y, 40, true, false); expandButton = addChild(new MekanismImageButton(gui, relativeX + 4, relativeY + 5, 19, 9, 19, 9, PLUS, (element, mouseX, mouseY) -> handleResize(ResizeType.EXPAND_Y, Screen.hasShiftDown()))); - shrinkButton = addChild(new MekanismImageButton(gui, relativeX + 4, relativeY + 25, 19, 9, 19, 9, MINUS, + shrinkButton = addChild(new MekanismImageButton(gui, relativeX + 4, relativeY + 26, 19, 9, 19, 9, MINUS, (element, mouseX, mouseY) -> handleResize(ResizeType.SHRINK_Y, Screen.hasShiftDown()))); updateButtonState(); active = true; @@ -56,7 +56,7 @@ public void updateTooltip(int mouseX, int mouseY) { @Override public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); - drawScaledCenteredTextScaledBound(guiGraphics, MekanismLang.HEIGHT.translate(), relativeX + 13.5F, relativeY + 15.5F, titleTextColor(), width - 4, 0.7F); + drawScaledScrollingString(guiGraphics, MekanismLang.HEIGHT.translate(), 0, 16, TextAlignment.CENTER, titleTextColor(), 4, false, 0.6F); } @Override diff --git a/src/main/java/mekanism/client/gui/element/custom/GuiSupportedUpgrades.java b/src/main/java/mekanism/client/gui/element/custom/GuiSupportedUpgrades.java index 4132b6135de..311b4a31436 100644 --- a/src/main/java/mekanism/client/gui/element/custom/GuiSupportedUpgrades.java +++ b/src/main/java/mekanism/client/gui/element/custom/GuiSupportedUpgrades.java @@ -9,6 +9,7 @@ import mekanism.client.gui.element.GuiElement; import mekanism.client.gui.element.GuiElementHolder; import mekanism.client.gui.tooltip.TooltipUtils; +import mekanism.client.render.IFancyFontRenderer; import mekanism.common.MekanismLang; import mekanism.common.lib.Color; import mekanism.common.util.EnumUtils; @@ -23,20 +24,33 @@ public class GuiSupportedUpgrades extends GuiElement { + private static final Component SUPPORTED = MekanismLang.UPGRADES_SUPPORTED.translate(); + private static final int ELEMENT_WIDTH = 167; + private static final int PADDED_ELEMENT_WIDTH = ELEMENT_WIDTH - 2; private static final int ELEMENT_SIZE = 12; - private static final int FIRST_ROW_ROOM = (123 - 55) / ELEMENT_SIZE; - private static final int ROW_ROOM = 123 / ELEMENT_SIZE; + private static final int ROW_ROOM = PADDED_ELEMENT_WIDTH / ELEMENT_SIZE; - public static int calculateNeededRows() { + private static int getFirstRowStart(IFancyFontRenderer fontRenderer) { + return Math.min(fontRenderer.font().width(SUPPORTED) + 1, PADDED_ELEMENT_WIDTH); + } + + private static int getFirstRowRoom(int firstRowStart) { + return (PADDED_ELEMENT_WIDTH - firstRowStart) / ELEMENT_SIZE; + } + + public static int calculateNeededRows(IFancyFontRenderer fontRenderer) { int count = EnumUtils.UPGRADES.length; - if (count <= FIRST_ROW_ROOM) { + int firstRowRoom = getFirstRowRoom(getFirstRowStart(fontRenderer)); + if (count <= firstRowRoom) { return 1; } - count -= FIRST_ROW_ROOM; + count -= firstRowRoom; return 2 + count / ROW_ROOM; } private final Set supportedUpgrades; + private final int firstRowRoom; + private final int firstRowStart; private List lastInfo = Collections.emptyList(); @Nullable @@ -45,8 +59,10 @@ public static int calculateNeededRows() { private ScreenRectangle cachedTooltipRect; public GuiSupportedUpgrades(IGuiWrapper gui, int x, int y, Set supportedUpgrades) { - super(gui, x, y, 125, ELEMENT_SIZE * calculateNeededRows() + 2); + super(gui, x, y, ELEMENT_WIDTH, ELEMENT_SIZE * calculateNeededRows(gui) + 2); this.supportedUpgrades = supportedUpgrades; + this.firstRowStart = getFirstRowStart(this); + this.firstRowRoom = getFirstRowRoom(this.firstRowStart); } @Override @@ -71,7 +87,9 @@ public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mou @Override public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); - drawTextScaledBound(guiGraphics, MekanismLang.UPGRADES_SUPPORTED.translate(), relativeX + 2, relativeY + 3, titleTextColor(), 54); + //Note: We don't have to specify where the upgrades start, because the upgrades get moved out of the way. This is only a scrolling string + // in case the translation needs more space than the entire width of the first row + drawScrollingString(guiGraphics, SUPPORTED, 0, 3, TextAlignment.LEFT, titleTextColor(), 2, false); } @NotNull @@ -111,13 +129,13 @@ public void updateTooltip(int mouseX, int mouseY) { } private UpgradePos getUpgradePos(int index) { - int row = index < FIRST_ROW_ROOM ? 0 : 1 + (index - FIRST_ROW_ROOM) / ROW_ROOM; + int row = index < firstRowRoom ? 0 : 1 + (index - firstRowRoom) / ROW_ROOM; if (row == 0) { //First row has x start a lot further in - return new UpgradePos(55 + (index % FIRST_ROW_ROOM) * ELEMENT_SIZE, 0); + return new UpgradePos(firstRowStart + (index % firstRowRoom) * ELEMENT_SIZE, 0); } //Shift the index so that we don't have to deal with the weird first row in terms of counting - index -= FIRST_ROW_ROOM; + index -= firstRowRoom; return new UpgradePos((index % ROW_ROOM) * ELEMENT_SIZE, row * ELEMENT_SIZE); } diff --git a/src/main/java/mekanism/client/gui/element/custom/module/BooleanToggle.java b/src/main/java/mekanism/client/gui/element/custom/module/BooleanToggle.java index 7170b1fa90d..51ef789ea5e 100644 --- a/src/main/java/mekanism/client/gui/element/custom/module/BooleanToggle.java +++ b/src/main/java/mekanism/client/gui/element/custom/module/BooleanToggle.java @@ -3,6 +3,7 @@ import mekanism.api.gear.config.ModuleBooleanConfig; import mekanism.client.gui.element.button.RadioButton; import mekanism.client.gui.element.scroll.GuiScrollList; +import mekanism.client.render.IFancyFontRenderer.TextAlignment; import mekanism.common.MekanismLang; import mekanism.common.registries.MekanismSounds; import net.minecraft.client.Minecraft; @@ -41,9 +42,15 @@ private void drawRadio(GuiGraphics guiGraphics, int mouseX, int mouseY, boolean @Override protected void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { int textColor = parent.screenTextColor(); - parent.drawScaledTextScaledBound(guiGraphics, description, getRelativeX() + 3, getRelativeY(), textColor, this.parent.getScreenWidth() - 3 - GuiScrollList.TEXTURE_WIDTH, 0.8F); - parent.drawTextWithScale(guiGraphics, MekanismLang.TRUE.translate(), getRelativeX() + 16, getRelativeY() + 11, textColor, 0.8F); - parent.drawTextWithScale(guiGraphics, MekanismLang.FALSE.translate(), getRelativeX() + 62, getRelativeY() + 11, textColor, 0.8F); + parent.drawScaledScrollingString(guiGraphics, description, xPos, yPos, TextAlignment.LEFT, textColor, parent.getScreenWidth() - GuiScrollList.TEXTURE_WIDTH, + 2, false, 0.8F); + + int trueShift = 4 + RADIO_SIZE; + int falseShift = 50 + RADIO_SIZE; + parent.drawScaledScrollingString(guiGraphics, MekanismLang.TRUE.translate(), xPos + trueShift, yPos + 11, TextAlignment.LEFT, textColor, + 50 - trueShift, 3, false, 0.8F); + parent.drawScaledScrollingString(guiGraphics, MekanismLang.FALSE.translate(), xPos + falseShift, yPos + 11, TextAlignment.LEFT, textColor, + parent.getScreenWidth() - GuiScrollList.TEXTURE_WIDTH - falseShift, 3, false, 0.8F); } @Override diff --git a/src/main/java/mekanism/client/gui/element/custom/module/ColorSelection.java b/src/main/java/mekanism/client/gui/element/custom/module/ColorSelection.java index 69c8e48535e..c467c6ce2f1 100644 --- a/src/main/java/mekanism/client/gui/element/custom/module/ColorSelection.java +++ b/src/main/java/mekanism/client/gui/element/custom/module/ColorSelection.java @@ -7,9 +7,9 @@ import mekanism.api.gear.config.ModuleColorConfig; import mekanism.client.gui.GuiModuleTweaker; import mekanism.client.gui.GuiUtils; -import mekanism.client.gui.element.scroll.GuiScrollList; import mekanism.client.gui.element.text.GuiTextField; import mekanism.client.gui.element.window.GuiColorWindow; +import mekanism.client.render.IFancyFontRenderer.TextAlignment; import mekanism.common.MekanismLang; import mekanism.common.content.gear.shared.ModuleColorModulationUnit; import mekanism.common.lib.Color; @@ -63,14 +63,15 @@ protected void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY) @Override protected void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { int textColor = parent.screenTextColor(); - parent.drawScaledTextScaledBound(guiGraphics, description, getRelativeX() + 3, getRelativeY(), textColor, this.parent.getScreenWidth() - 3 - GuiScrollList.TEXTURE_WIDTH, 0.8F); + parent.drawScaledScrollingString(guiGraphics, description, xPos, yPos, TextAlignment.LEFT, textColor, OFFSET_X, 3, false, 0.8F); String hex; if (supportsAlpha) { hex = TextUtils.hex(false, 4, data.get()); } else { hex = TextUtils.hex(false, 3, getColor().rgb()); } - parent.drawTextExact(guiGraphics, MekanismLang.GENERIC_HEX.translate(hex), getRelativeX() + 3, getRelativeY() + 11, textColor); + //TODO: Do we want to draw the hex in the RGB color it is set to (intentionally ignore alpha) + parent.drawScrollingString(guiGraphics, MekanismLang.GENERIC_HEX.translate(hex), xPos, yPos + 11, TextAlignment.LEFT, textColor, OFFSET_X, 3, false); } @Override @@ -98,7 +99,7 @@ protected void click(double mouseX, double mouseY) { previewReset = () -> armorPreview.resetToDefault(slot); } } - parent.gui().addWindow(new GuiColorWindow(parent.gui(), parent.getGuiWidth() / 2 - 160 / 2, parent.getGuiHeight() / 2 - 120 / 2, supportsAlpha, + parent.gui().addWindow(new GuiColorWindow(parent.gui(), (parent.getGuiWidth() - 160) / 2, (parent.getGuiHeight() - 120) / 2, supportsAlpha, getColor(), color -> setData(color.argb()), armorPreview, updatePreviewColor, previewReset)); } } diff --git a/src/main/java/mekanism/client/gui/element/custom/module/EnumToggle.java b/src/main/java/mekanism/client/gui/element/custom/module/EnumToggle.java index dd1e00eb157..bdc46d42324 100644 --- a/src/main/java/mekanism/client/gui/element/custom/module/EnumToggle.java +++ b/src/main/java/mekanism/client/gui/element/custom/module/EnumToggle.java @@ -6,6 +6,7 @@ import mekanism.api.text.IHasTextComponent; import mekanism.client.gui.GuiUtils; import mekanism.client.gui.element.scroll.GuiScrollList; +import mekanism.client.render.IFancyFontRenderer.TextAlignment; import mekanism.common.MekanismLang; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -31,7 +32,7 @@ class EnumToggle & IHasTextComponent> extends MiniElemen BAR_LENGTH = this.parent.getScreenWidth() - 24; enumConstants = data.getEnumConstants(); this.optionDistance = (BAR_LENGTH / (enumConstants.size() - 1)); - this.usesIcons = enumConstants.stream().findFirst().filter(option -> option instanceof IHasModeIcon).isPresent(); + this.usesIcons = !enumConstants.isEmpty() && enumConstants.getFirst() instanceof IHasModeIcon; } @Override @@ -53,24 +54,11 @@ protected void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) if (usesIcons) { description = MekanismLang.GENERIC_STORED.translate(description, data.get()); } - parent.drawScaledTextScaledBound(guiGraphics, description, getRelativeX() + 3, getRelativeY(), textColor, this.parent.getScreenWidth() - 3 - GuiScrollList.TEXTURE_WIDTH, 0.8F); + parent.drawScaledScrollingString(guiGraphics, description, xPos, yPos, TextAlignment.LEFT, textColor, parent.getScreenWidth() - GuiScrollList.TEXTURE_WIDTH, + 2, false, 0.8F); for (TYPE option : enumConstants) { Component text = option.getTextComponent(); - //Similar to logic for drawScaledCenteredText except shifts values slightly if they go past the max length - int textWidth = parent.getStringWidth(text); - float widthScaling = usesIcons ? 2.5F : (textWidth / 2F) * TEXT_SCALE; int optionCenter = BAR_START + optionDistance * option.ordinal(); - float left = optionCenter - widthScaling; - if (left < 0) { - left = 0; - } else { - int max = parent.getScreenWidth() - 1; - float objectWidth = usesIcons ? 5 : textWidth * TEXT_SCALE; - int end = xPos + Mth.ceil(left + objectWidth); - if (end > max) { - left -= end - max; - } - } int color = textColor; if (text.getStyle().getColor() != null) { color = 0xFF000000 | text.getStyle().getColor().getValue(); @@ -80,7 +68,25 @@ protected void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) IHasModeIcon hasModeIcon = (IHasModeIcon) option; guiGraphics.blit(hasModeIcon.getModeIcon(), getRelativeX() + optionCenter - 8, getRelativeY() + 19, 0, 0, 16, 16, 16, 16); } else { - parent.drawTextWithScale(guiGraphics, text, getRelativeX() + left, getRelativeY() + 20, textColor, TEXT_SCALE); + //Similar to logic for drawScaledCenteredText except shifts values slightly if they go past the max length + int textWidth = parent.font().width(text); + float objectWidth = textWidth * TEXT_SCALE; + if (optionCenter < objectWidth / 2) { + //Note: We know it will overflow, so it doesn't actually matter if we center it here or not + // We can also take some shortcuts calculating the width, as it goes all the way to zero + parent.drawScaledScrollingString(guiGraphics, text, xPos, yPos + 20, TextAlignment.CENTER, textColor, BAR_START + optionDistance / 2, + 1, false, TEXT_SCALE); + } else { + int max = parent.getScreenWidth() - 1; + int start = xPos + optionCenter - optionDistance / 2; + if (start + Mth.ceil(objectWidth) > max) { + //Note: We know it will overflow, so it doesn't actually matter if we center it here or not + parent.drawScaledScrollingString(guiGraphics, text, start, yPos + 20, TextAlignment.CENTER, textColor, max - start, 1, false, TEXT_SCALE); + } else { + //TODO: For some things like locomotive boosting unit, this is ever so slightly off-center. Do we care enough to adjust it? + parent.drawScaledScrollingString(guiGraphics, text, start, yPos + 20, TextAlignment.CENTER, textColor, optionDistance, 1, false, TEXT_SCALE); + } + } } } } diff --git a/src/main/java/mekanism/client/gui/element/custom/module/GuiModuleScreen.java b/src/main/java/mekanism/client/gui/element/custom/module/GuiModuleScreen.java index 1a4af8a61e3..5e3ab085866 100644 --- a/src/main/java/mekanism/client/gui/element/custom/module/GuiModuleScreen.java +++ b/src/main/java/mekanism/client/gui/element/custom/module/GuiModuleScreen.java @@ -43,7 +43,7 @@ public class GuiModuleScreen extends GuiScrollableElement { private int maxElements; public GuiModuleScreen(IGuiWrapper gui, int x, int y, Supplier itemSupplier, Consumer> 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 itemSupplier, Consumer> saveCallback, ArmorPreview armorPreview) { @@ -95,7 +95,7 @@ public void setModule(@Nullable Module module) { } private static int getStartY(@Nullable IModule module) { - int startY = 5; + int startY = ELEMENT_SPACER + 1; if (module != null) { if (module.getData().isExclusive(ExclusiveFlag.ANY)) { startY += 13; @@ -191,18 +191,19 @@ public void drawBackground(@NotNull GuiGraphics guiGraphics, int mx, int my, flo public void renderForeground(GuiGraphics guiGraphics, int mx, int my) { super.renderForeground(guiGraphics, mx, my); scissorScreen(guiGraphics, mx, my, (g, mouseX, mouseY, module, shift) -> { - int startY = 5; + int startY = ELEMENT_SPACER + 1; if (module != null) { if (module.getData().isExclusive(ExclusiveFlag.ANY)) { if (startY + 13 > shift) { - drawTextWithScale(g, MekanismLang.MODULE_EXCLUSIVE.translate(), relativeX + 5, relativeY + startY, 0x635BD4, 0.8F); + drawScaledScrollingString(g, MekanismLang.MODULE_EXCLUSIVE.translate(), 2, startY, TextAlignment.LEFT, 0x635BD4, + getScreenWidth() - GuiScrollList.TEXTURE_WIDTH, 2, false, 0.8F); } startY += 13; } if (module.getData().getMaxStackSize() > 1) { if (startY + 13 > shift) { - drawTextWithScale(g, MekanismLang.MODULE_INSTALLED.translate(module.getInstalledCount()), relativeX + 5, relativeY + startY, - screenTextColor(), 0.8F); + drawScaledScrollingString(g, MekanismLang.MODULE_INSTALLED.translate(module.getInstalledCount()), 2, startY, TextAlignment.LEFT, screenTextColor(), + getScreenWidth() - GuiScrollList.TEXTURE_WIDTH, 2, false, 0.8F); } startY += 13; } diff --git a/src/main/java/mekanism/client/gui/element/scroll/GuiInstallableScrollList.java b/src/main/java/mekanism/client/gui/element/scroll/GuiInstallableScrollList.java new file mode 100644 index 00000000000..f2acd66975f --- /dev/null +++ b/src/main/java/mekanism/client/gui/element/scroll/GuiInstallableScrollList.java @@ -0,0 +1,130 @@ +package mekanism.client.gui.element.scroll; + +import java.util.List; +import mekanism.api.text.EnumColor; +import mekanism.client.gui.IGuiWrapper; +import mekanism.client.render.MekanismRenderer; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.navigation.ScreenRectangle; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public abstract class GuiInstallableScrollList extends GuiScrollList { + + private final ResourceLocation texture; + private final int textureWidth; + private final int textureHeight; + @Nullable + protected TYPE selectedType; + @Nullable + protected ScreenRectangle cachedTooltipRect; + + protected GuiInstallableScrollList(IGuiWrapper gui, int x, int y, int height, ResourceLocation background, int backgroundSideSize, + ResourceLocation texture, int textureWidth, int textureHeight) { + super(gui, x, y, textureWidth + 8, height, textureHeight / 3, background, backgroundSideSize); + this.texture = texture; + this.textureWidth = textureWidth; + this.textureHeight = textureHeight; + } + + protected abstract List getCurrentInstalled(); + + protected abstract void drawName(GuiGraphics guiGraphics, TYPE type, int multipliedElement); + + protected abstract ItemStack getRenderStack(TYPE type); + + @Nullable + public TYPE getSelection() { + return selectedType; + } + + @Override + public boolean hasSelection() { + return selectedType != null; + } + + @Override + protected int getMaxElements() { + return getCurrentInstalled().size(); + } + + @Override + protected void setSelected(int index) { + if (index >= 0) { + List currentInstalled = getCurrentInstalled(); + if (index < currentInstalled.size()) { + setSelected(currentInstalled.get(index)); + } + } + } + + protected abstract void setSelected(TYPE newType); + + @Override + public void clearSelection() { + setSelected(null); + } + + @Override + public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { + super.renderForeground(guiGraphics, mouseX, mouseY); + int currentSelection = getCurrentSelection(); + List currentInstalled = getCurrentInstalled(); + int max = Math.min(getFocusedElements(), currentInstalled.size()); + for (int i = 0; i < max; i++) { + drawName(guiGraphics, currentInstalled.get(currentSelection + i), 3 + i * elementHeight); + } + } + + protected void drawNameText(GuiGraphics guiGraphics, int y, Component name, int color, float scale) { + drawScaledScrollingString(guiGraphics, name, 13, y, TextAlignment.LEFT, color, barXShift - 16, 0, false, scale); + } + + @NotNull + @Override + protected ScreenRectangle getTooltipRectangle(int mouseX, int mouseY) { + return cachedTooltipRect == null ? super.getTooltipRectangle(mouseX, mouseY) : cachedTooltipRect; + } + + @Nullable + protected EnumColor getColor(TYPE type) { + return null; + } + + @Override + public void renderElements(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { + //Draw elements + List currentInstalled = getCurrentInstalled(); + int currentSelection = getCurrentSelection(); + int max = Math.min(getFocusedElements(), currentInstalled.size()); + for (int i = 0; i < max; i++) { + TYPE type = currentInstalled.get(currentSelection + i); + int multipliedElement = i * elementHeight; + int shiftedY = getY() + 1 + multipliedElement; + int j = 1; + if (type == getSelection()) { + j = 2; + } else if (mouseX >= getX() + 1 && mouseX < getX() + barXShift - 1 && mouseY >= shiftedY && mouseY < shiftedY + elementHeight) { + j = 0; + } + EnumColor color = getColor(type); + if (color != null) { + MekanismRenderer.color(guiGraphics, color); + } + guiGraphics.blit(texture, relativeX + 1, relativeY + 1 + multipliedElement, 0, elementHeight * j, textureWidth, + elementHeight, textureWidth, textureHeight); + if (color != null) { + MekanismRenderer.resetColor(guiGraphics); + } + } + //Note: This needs to be in its own loop as rendering the items is likely to cause the texture manager to be bound to a different texture + // and thus would make the selection area background get all screwed up + for (int i = 0; i < max; i++) { + TYPE type = currentInstalled.get(currentSelection + i); + gui().renderItem(guiGraphics, getRenderStack(type), relativeX + 3, relativeY + 3 + i * elementHeight, 0.5F); + } + } +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/element/scroll/GuiModuleScrollList.java b/src/main/java/mekanism/client/gui/element/scroll/GuiModuleScrollList.java index fd6e16e1080..ca653a49553 100644 --- a/src/main/java/mekanism/client/gui/element/scroll/GuiModuleScrollList.java +++ b/src/main/java/mekanism/client/gui/element/scroll/GuiModuleScrollList.java @@ -3,13 +3,11 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; -import java.util.function.ObjIntConsumer; import java.util.function.Supplier; import mekanism.api.gear.IModule; import mekanism.api.gear.ModuleData; import mekanism.api.gear.ModuleData.ExclusiveFlag; import mekanism.api.text.EnumColor; -import mekanism.api.text.TextComponentUtil; import mekanism.client.gui.IGuiWrapper; import mekanism.client.gui.element.GuiElement; import mekanism.client.gui.element.GuiElementHolder; @@ -26,14 +24,11 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class GuiModuleScrollList extends GuiScrollList { +public class GuiModuleScrollList extends GuiInstallableScrollList> { 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_HEIGHT = 36; private final Consumer> callback; private final List> currentList = new ArrayList<>(); @@ -41,18 +36,14 @@ public class GuiModuleScrollList extends GuiScrollList { private ItemStack currentItem; @Nullable private ModuleContainer currentContainer; - @Nullable - private ModuleData selected; @Nullable private Component lastInfo = null; @Nullable private Tooltip lastTooltip; - @Nullable - private ScreenRectangle cachedTooltipRect; - public GuiModuleScrollList(IGuiWrapper gui, int x, int y, int width, int height, Supplier itemSupplier, Consumer> 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 itemSupplier, Consumer> callback) { + super(gui, x, y, height, GuiElementHolder.HOLDER, GuiElementHolder.HOLDER_SIZE, MODULE_SELECTION, 112, 36); this.itemSupplier = itemSupplier; this.callback = callback; updateItemAndList(itemSupplier.get()); @@ -85,74 +76,55 @@ private void recheckItem() { } @Override - protected int getMaxElements() { - return currentList.size(); - } - - @Override - public boolean hasSelection() { - return selected != null; - } - - @Override - protected void setSelected(int index) { - if (index >= 0 && index < currentList.size()) { - setSelected(currentList.get(index)); - } - } - - private void setSelected(@Nullable ModuleData newData) { - if (selected != newData) { - selected = newData; + protected void setSelected(@Nullable ModuleData newData) { + if (selectedType != newData) { + selectedType = newData; onSelectedChange(); } } private void onSelectedChange() { - if (selected == null || currentContainer == null) { + if (selectedType == null || currentContainer == null) { callback.accept(null); } else { - callback.accept(currentContainer.get(selected)); + callback.accept(currentContainer.get(selectedType)); } } - @Nullable - public ModuleData getSelection() { - return selected; + @Override + protected List> getCurrentInstalled() { + return currentList; } @Override - public void clearSelection() { - setSelected(null); + protected void drawName(GuiGraphics guiGraphics, ModuleData module, int y) { + if (currentContainer != null) { + IModule instance = currentContainer.get(module); + if (instance != null) { + boolean enabled = instance.isEnabled(); + int color = module.isExclusive(ExclusiveFlag.ANY) ? (enabled ? 0x635BD4 : 0x2E2A69) : (enabled ? titleTextColor() : 0x5E1D1D); + drawNameText(guiGraphics, y, module.getTextComponent(), color, 0.7F); + } + } } @Override - public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { - super.renderForeground(guiGraphics, mouseX, mouseY); - recheckItem(); - forEachModule((module, multipliedElement) -> { - if (currentContainer != null) { - IModule instance = currentContainer.get(module); - if (instance != null) { - boolean enabled = instance.isEnabled(); - int color = module.isExclusive(ExclusiveFlag.ANY) ? (enabled ? 0x635BD4 : 0x2E2A69) : (enabled ? titleTextColor() : 0x5E1D1D); - drawScaledTextScaledBound(guiGraphics, TextComponentUtil.build(module), relativeX + 13, relativeY + 3 + multipliedElement, color, 86, 0.7F); - } - } - }); + protected ItemStack getRenderStack(ModuleData moduleData) { + return moduleData.getItemProvider().getItemStack(); } - @NotNull @Override - protected ScreenRectangle getTooltipRectangle(int mouseX, int mouseY) { - return cachedTooltipRect == null ? super.getTooltipRectangle(mouseX, mouseY) : cachedTooltipRect; + public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { + recheckItem(); + super.renderForeground(guiGraphics, mouseX, mouseY); } @Override public void updateTooltip(int mouseX, int mouseY) { if (currentContainer != null && mouseX >= getX() + 1 && mouseX < getX() + barXShift - 1) { - for (int i = 0; i < getFocusedElements(); i++) { - int index = getCurrentSelection() + i; + int currentSelection = getCurrentSelection(); + for (int i = 0, focused = getFocusedElements(); i < focused; i++) { + int index = currentSelection + i; if (index > currentList.size() - 1) { break; } @@ -176,34 +148,6 @@ public void updateTooltip(int mouseX, int mouseY) { setTooltip(lastTooltip = null); } - @Override - public void renderElements(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { - //Draw elements - forEachModule((module, multipliedElement) -> { - int shiftedY = getY() + 1 + multipliedElement; - int j = 1; - if (module == getSelection()) { - j = 2; - } else if (mouseX >= getX() + 1 && mouseX < getX() + barXShift - 1 && mouseY >= shiftedY && mouseY < shiftedY + elementHeight) { - j = 0; - } - guiGraphics.blit(MODULE_SELECTION, relativeX + 1, relativeY + 1 + multipliedElement, 0, elementHeight * j, TEXTURE_WIDTH, elementHeight, TEXTURE_WIDTH, TEXTURE_HEIGHT); - }); - //Note: This needs to be in its own loop as rendering the items is likely to cause the texture manager to be bound to a different texture - // and thus would make the selection area background get all screwed up - forEachModule((module, multipliedElement) -> gui().renderItem(guiGraphics, module.getItemProvider().getItemStack(), relativeX + 3, relativeY + 3 + multipliedElement, 0.5F)); - } - - private void forEachModule(ObjIntConsumer> consumer) { - for (int i = 0; i < getFocusedElements(); i++) { - int index = getCurrentSelection() + i; - if (index > currentList.size() - 1) { - break; - } - consumer.accept(currentList.get(index), elementHeight * i); - } - } - @Override public void syncFrom(GuiElement element) { super.syncFrom(element); @@ -212,12 +156,12 @@ public void syncFrom(GuiElement element) { //If the item is the same just change what module data we have as our selected // and don't notify the callback with a fresh read of the module data as it // should have the data it expects already - selected = old.selected; - } else if (old.selected != null) { - if (currentList.contains(old.selected)) { + selectedType = old.selectedType; + } else if (old.selectedType != null) { + if (currentList.contains(old.selectedType)) { //If the item doesn't match (in general it will) and it still has the corresponding module, // we need to update the selected value and fire the corresponding callbacks - setSelected(old.selected); + setSelected(old.selectedType); } else { //If the data is no longer present we need to fire the callbacks to ensure we propagate the clear to the current selection onSelectedChange(); diff --git a/src/main/java/mekanism/client/gui/element/scroll/GuiSlotScroll.java b/src/main/java/mekanism/client/gui/element/scroll/GuiSlotScroll.java index 7f7f8b43d8d..4acbf7565f6 100644 --- a/src/main/java/mekanism/client/gui/element/scroll/GuiSlotScroll.java +++ b/src/main/java/mekanism/client/gui/element/scroll/GuiSlotScroll.java @@ -1,13 +1,12 @@ package mekanism.client.gui.element.scroll; import com.mojang.blaze3d.vertex.PoseStack; -import java.math.RoundingMode; -import java.text.DecimalFormat; import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.function.Supplier; import mekanism.api.text.EnumColor; +import mekanism.api.text.TextComponentUtil; import mekanism.client.gui.IGuiWrapper; import mekanism.client.gui.element.GuiElement; import mekanism.client.gui.element.slot.GuiSlot; @@ -19,12 +18,13 @@ import mekanism.common.lib.inventory.HashedItem; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; +import mekanism.common.util.UnitDisplayUtils; import mekanism.common.util.text.TextUtils; -import net.minecraft.Util; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.Rect2i; import net.minecraft.client.renderer.RenderType; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.item.ItemStack; @@ -35,7 +35,6 @@ public class GuiSlotScroll extends GuiElement implements IRecipeViewerIngredient private static final ResourceLocation SLOTS = MekanismUtils.getResource(ResourceType.GUI_SLOT, "slots.png"); private static final ResourceLocation SLOTS_DARK = MekanismUtils.getResource(ResourceType.GUI_SLOT, "slots_dark.png"); - private static final DecimalFormat COUNT_FORMAT = Util.make(new DecimalFormat("#.#"), format -> format.setRoundingMode(RoundingMode.FLOOR)); private final GuiScrollBar scrollBar; @@ -67,8 +66,7 @@ public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mou if (slot >= list.size()) { break; } - int slotX = relativeX + (i % xSlots) * 18, slotY = relativeY + (i / xSlots) * 18; - renderSlot(guiGraphics, list.get(slot), slotX, slotY); + renderSlot(guiGraphics, list.get(slot), 18 * (i % xSlots), 18 * (i / xSlots)); } } } @@ -139,9 +137,18 @@ private void renderSlot(GuiGraphics guiGraphics, IScrollableSlot slot, int slotX if (isSlotEmpty(slot)) { return; } - gui().renderItemWithOverlay(guiGraphics, slot.item().getInternalStack(), slotX + 1, slotY + 1, 1, ""); - if (slot.count() > 1) { - renderSlotText(guiGraphics, getCountText(slot.count()), slotX + 1, slotY + 1); + gui().renderItemWithOverlay(guiGraphics, slot.item().getInternalStack(), relativeX + slotX + 1, relativeY + slotY + 1, 1, ""); + long count = slot.count(); + if (count > 1) { + Component text; + //Note: For cases like 9,999,999 we intentionally display as 9999.9K instead of 10M so that people + // do not think they have more stored than they actually have just because it is rounding up + if (count < 10_000) { + text = TextComponentUtil.getString(Long.toString(count)); + } else { + text = UnitDisplayUtils.getDisplay(count, 1); + } + renderSlotText(guiGraphics, text, slotX + 1, slotY + 1); } } @@ -153,7 +160,7 @@ private void renderSlotTooltip(GuiGraphics guiGraphics, IScrollableSlot slot, in ItemStack stack = slot.item().getInternalStack(); long count = slot.count(); if (count < 10_000) { - gui().renderItemTooltip(guiGraphics, stack, slotX, slotY); + guiGraphics.renderTooltip(font(), stack, slotX, slotY); } else { //If the slot's displayed count is truncated, make sure we also add the actual amount to the tooltip gui().renderItemTooltipWithExtra(guiGraphics, stack, slotX, slotY, Collections.singletonList(MekanismLang.QIO_STORED_COUNT.translateColored(EnumColor.GRAY, @@ -172,38 +179,21 @@ private boolean isSlotEmpty(IScrollableSlot slot) { return item == null || item.getInternalStack().isEmpty(); } - private void renderSlotText(GuiGraphics guiGraphics, String text, int x, int y) { + private void renderSlotText(GuiGraphics guiGraphics, Component text, int x, int y) { + float scale = 0.6F; + float scaledWidth = font().width(text) * scale; + if (scaledWidth >= 16) { + //If we need a lower scale slightly due to having a lot of text, calculate it + //Note: If it would still overflow, then we just let the scrolling text handle it + scale = 0.5F; + } PoseStack pose = guiGraphics.pose(); pose.pushPose(); - float scale = 0.6F; - int width = getFont().width(text); - //If we need a lower scale due to having a lot of text, calculate it - scale = Math.min(1, 16F / (width * scale)) * scale; - float yAdd = 4 - (scale * 8) / 2F; - pose.translate(x + 16 - width * scale, y + 9 + yAdd, 200F); - pose.scale(scale, scale, scale); - - guiGraphics.drawString(getFont(), text, 0, 0, 0xFFFFFF); + pose.translate(0, 0, 200); + drawScaledScrollingString(guiGraphics, text, x, y + 9, TextAlignment.RIGHT, 0xFFFFFF, 16, 0, true, scale); pose.popPose(); } - private String getCountText(long count) { - //Note: For cases like 9,999,999 we intentionally display as 9999.9K instead of 10M so that people - // do not think they have more stored than they actually have just because it is rounding up - if (count <= 1) { - return null; - } else if (count < 10_000) { - return Long.toString(count); - } else if (count < 10_000_000) { - return COUNT_FORMAT.format(count / 1_000D) + "K"; - } else if (count < 10_000_000_000L) { - return COUNT_FORMAT.format(count / 1_000_000D) + "M"; - } else if (count < 10_000_000_000_000L) { - return COUNT_FORMAT.format(count / 1_000_000_000D) + "B"; - } - return ">10T"; - } - private List getSlotList() { return slotList.get(); } diff --git a/src/main/java/mekanism/client/gui/element/scroll/GuiTextScrollList.java b/src/main/java/mekanism/client/gui/element/scroll/GuiTextScrollList.java index 6676ef6d800..2949ec9a747 100644 --- a/src/main/java/mekanism/client/gui/element/scroll/GuiTextScrollList.java +++ b/src/main/java/mekanism/client/gui/element/scroll/GuiTextScrollList.java @@ -67,8 +67,8 @@ public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { for (int i = 0; i < focusedElements; i++) { int index = scrollIndex + i; if (index < maxElements) { - drawScaledTextScaledBound(guiGraphics, TextComponentUtil.getString(textEntries.get(index)), relativeX + 2, relativeY + 2 + elementHeight * i, - screenTextColor(), barXShift - 2, 0.8F); + drawScaledScrollingString(guiGraphics, TextComponentUtil.getString(textEntries.get(index)), 0, 2 + elementHeight * i, TextAlignment.LEFT, + screenTextColor(), barXShift, 2, false, 0.8F); } } } diff --git a/src/main/java/mekanism/client/gui/element/scroll/GuiUpgradeScrollList.java b/src/main/java/mekanism/client/gui/element/scroll/GuiUpgradeScrollList.java index bf9315b0c25..fd6aae07287 100644 --- a/src/main/java/mekanism/client/gui/element/scroll/GuiUpgradeScrollList.java +++ b/src/main/java/mekanism/client/gui/element/scroll/GuiUpgradeScrollList.java @@ -1,16 +1,15 @@ package mekanism.client.gui.element.scroll; +import java.util.ArrayList; import java.util.EnumMap; +import java.util.List; import java.util.Map; -import java.util.Set; -import java.util.function.ObjIntConsumer; import mekanism.api.Upgrade; -import mekanism.api.text.TextComponentUtil; +import mekanism.api.text.EnumColor; import mekanism.client.gui.IGuiWrapper; import mekanism.client.gui.element.GuiElement; import mekanism.client.gui.element.GuiElementHolder; import mekanism.client.gui.tooltip.TooltipUtils; -import mekanism.client.render.MekanismRenderer; import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -19,92 +18,68 @@ import net.minecraft.client.gui.components.Tooltip; import net.minecraft.client.gui.navigation.ScreenRectangle; import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.NotNull; +import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.Nullable; -public class GuiUpgradeScrollList extends GuiScrollList { +public class GuiUpgradeScrollList extends GuiInstallableScrollList { private static final ResourceLocation UPGRADE_SELECTION = MekanismUtils.getResource(ResourceType.GUI, "upgrade_selection.png"); - private static final int TEXTURE_WIDTH = 58; - private static final int TEXTURE_HEIGHT = 36; private final Map tooltips = new EnumMap<>(Upgrade.class); private final TileComponentUpgrade component; private final Runnable onSelectionChange; - @Nullable - private Upgrade selectedType; - @Nullable - private ScreenRectangle cachedTooltipRect; - public GuiUpgradeScrollList(IGuiWrapper gui, int x, int y, int width, int height, TileComponentUpgrade component, Runnable onSelectionChange) { - super(gui, x, y, width, height, TEXTURE_HEIGHT / 3, GuiElementHolder.HOLDER, GuiElementHolder.HOLDER_SIZE); + public GuiUpgradeScrollList(IGuiWrapper gui, int x, int y, int height, TileComponentUpgrade component, Runnable onSelectionChange) { + super(gui, x, y, height, GuiElementHolder.HOLDER, GuiElementHolder.HOLDER_SIZE, UPGRADE_SELECTION, 100, 36); this.component = component; this.onSelectionChange = onSelectionChange; } - private Set getCurrentUpgrades() { - return component.getInstalledTypes(); - } - @Override protected int getMaxElements() { - return getCurrentUpgrades().size(); - } - - @Override - public boolean hasSelection() { - return selectedType != null; + return component.getInstalledTypes().size(); } @Override - protected void setSelected(int index) { - Set currentUpgrades = getCurrentUpgrades(); - if (index >= 0 && index < currentUpgrades.size()) { - Upgrade newSelection = currentUpgrades.toArray(new Upgrade[0])[index]; - if (selectedType != newSelection) { - selectedType = newSelection; - onSelectionChange.run(); - } + protected void setSelected(Upgrade newSelection) { + if (selectedType != newSelection) { + selectedType = newSelection; + onSelectionChange.run(); } } - @Nullable - public Upgrade getSelection() { - return selectedType; + @Override + protected List getCurrentInstalled() { + return new ArrayList<>(component.getInstalledTypes()); } @Override - public void clearSelection() { - if (selectedType != null) { - selectedType = null; - onSelectionChange.run(); - } + protected void drawName(GuiGraphics guiGraphics, Upgrade upgrade, int y) { + drawNameText(guiGraphics, y, upgrade.getTranslatedName(), titleTextColor(), 1F); } @Override - public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { - super.renderForeground(guiGraphics, mouseX, mouseY); - forEachUpgrade((upgrade, multipliedElement) -> drawTextScaledBound(guiGraphics, TextComponentUtil.build(upgrade), relativeX + 13, relativeY + 3 + multipliedElement, - titleTextColor(), 44)); + protected ItemStack getRenderStack(Upgrade upgrade) { + return UpgradeUtils.getStack(upgrade); } - @NotNull + @Nullable @Override - protected ScreenRectangle getTooltipRectangle(int mouseX, int mouseY) { - return cachedTooltipRect == null ? super.getTooltipRectangle(mouseX, mouseY) : cachedTooltipRect; + protected EnumColor getColor(Upgrade upgrade) { + return upgrade.getColor(); } @Override public void updateTooltip(int mouseX, int mouseY) { if (mouseX >= getX() + 1 && mouseX < getX() + barXShift - 1) { - Upgrade[] upgrades = getCurrentUpgrades().toArray(new Upgrade[0]); + List currentInstalled = getCurrentInstalled(); int currentSelection = getCurrentSelection(); - for (int i = 0; i < getFocusedElements(); i++) { + for (int i = 0, focused = getFocusedElements(); i < focused; i++) { int index = currentSelection + i; - if (index > upgrades.length - 1) { + if (index > currentInstalled.size() - 1) { break; } - Upgrade upgrade = upgrades[index]; + Upgrade upgrade = currentInstalled.get(index); int multipliedElement = elementHeight * i; if (mouseY >= getY() + 1 + multipliedElement && mouseY < getY() + 1 + multipliedElement + elementHeight) { cachedTooltipRect = new ScreenRectangle(getX() + 1, getY() + 1 + multipliedElement, barXShift - 2, elementHeight); @@ -123,33 +98,7 @@ public void renderElements(GuiGraphics guiGraphics, int mouseX, int mouseY, floa if (hasSelection() && component.getUpgrades(getSelection()) == 0) { clearSelection(); } - forEachUpgrade((upgrade, multipliedElement) -> { - int shiftedY = getY() + 1 + multipliedElement; - int j = 1; - if (upgrade == getSelection()) { - j = 2; - } else if (mouseX >= getX() + 1 && mouseX < getX() + barXShift - 1 && mouseY >= shiftedY && mouseY < shiftedY + elementHeight) { - j = 0; - } - MekanismRenderer.color(guiGraphics, upgrade.getColor()); - guiGraphics.blit(UPGRADE_SELECTION, relativeX + 1, relativeY + 1 + multipliedElement, 0, elementHeight * j, TEXTURE_WIDTH, elementHeight, TEXTURE_WIDTH, TEXTURE_HEIGHT); - MekanismRenderer.resetColor(guiGraphics); - }); - //Note: This needs to be in its own loop as rendering the items is likely to cause the texture manager to be bound to a different texture - // and thus would make the selection area background get all screwed up - forEachUpgrade((upgrade, multipliedElement) -> gui().renderItem(guiGraphics, UpgradeUtils.getStack(upgrade), relativeX + 3, relativeY + 3 + multipliedElement, 0.5F)); - } - - private void forEachUpgrade(ObjIntConsumer consumer) { - Upgrade[] upgrades = getCurrentUpgrades().toArray(new Upgrade[0]); - int currentSelection = getCurrentSelection(); - for (int i = 0; i < getFocusedElements(); i++) { - int index = currentSelection + i; - if (index > upgrades.length - 1) { - break; - } - consumer.accept(upgrades[index], elementHeight * i); - } + super.renderElements(guiGraphics, mouseX, mouseY, partialTicks); } @Override diff --git a/src/main/java/mekanism/client/gui/element/tab/GuiSortingTab.java b/src/main/java/mekanism/client/gui/element/tab/GuiSortingTab.java index 915a0fad07b..d73319f1881 100644 --- a/src/main/java/mekanism/client/gui/element/tab/GuiSortingTab.java +++ b/src/main/java/mekanism/client/gui/element/tab/GuiSortingTab.java @@ -25,7 +25,7 @@ public GuiSortingTab(IGuiWrapper gui, TileEntityFactory tile) { @Override public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { super.drawBackground(guiGraphics, mouseX, mouseY, partialTicks); - drawTextScaledBound(guiGraphics, OnOff.of(dataSource.isSorting()).getTextComponent(), relativeX + 3, relativeY + 24, titleTextColor(), 21); + drawScrollingString(guiGraphics, OnOff.of(dataSource.isSorting()).getTextComponent(), 0, 24, TextAlignment.CENTER, titleTextColor(), 3, false); } @Override diff --git a/src/main/java/mekanism/client/gui/element/tab/window/GuiCraftingWindowTab.java b/src/main/java/mekanism/client/gui/element/tab/window/GuiCraftingWindowTab.java index d2042990633..26e8640d196 100644 --- a/src/main/java/mekanism/client/gui/element/tab/window/GuiCraftingWindowTab.java +++ b/src/main/java/mekanism/client/gui/element/tab/window/GuiCraftingWindowTab.java @@ -108,6 +108,6 @@ protected List getValidWindows() { @Override protected GuiWindow createWindow(SelectedWindowData windowData) { openWindows[windowData.extraData] = true; - return new GuiCraftingWindow(gui(), getGuiWidth() / 2 - 156 / 2, 15, container, windowData); + return new GuiCraftingWindow(gui(), (getGuiWidth() - 124) / 2, 15, container, windowData); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/element/tab/window/GuiSideConfigurationTab.java b/src/main/java/mekanism/client/gui/element/tab/window/GuiSideConfigurationTab.java index 89855ea2caf..6d9aee6b97a 100644 --- a/src/main/java/mekanism/client/gui/element/tab/window/GuiSideConfigurationTab.java +++ b/src/main/java/mekanism/client/gui/element/tab/window/GuiSideConfigurationTab.java @@ -31,7 +31,7 @@ protected void colorTab(GuiGraphics guiGraphics) { @Override protected GuiWindow createWindow(SelectedWindowData windowData) { - return new GuiSideConfiguration<>(gui(), getGuiWidth() / 2 - 156 / 2, 15, dataSource, windowData); + return new GuiSideConfiguration<>(gui(), (getGuiWidth() - 156) / 2, 15, dataSource, windowData); } @Override diff --git a/src/main/java/mekanism/client/gui/element/tab/window/GuiTransporterConfigTab.java b/src/main/java/mekanism/client/gui/element/tab/window/GuiTransporterConfigTab.java index 05a71a8c173..483ab7c0cfc 100644 --- a/src/main/java/mekanism/client/gui/element/tab/window/GuiTransporterConfigTab.java +++ b/src/main/java/mekanism/client/gui/element/tab/window/GuiTransporterConfigTab.java @@ -31,7 +31,7 @@ protected void colorTab(GuiGraphics guiGraphics) { @Override protected GuiWindow createWindow(SelectedWindowData windowData) { - return new GuiTransporterConfig<>(gui(), getGuiWidth() / 2 - 156 / 2, 15, dataSource, windowData); + return new GuiTransporterConfig<>(gui(), (getGuiWidth() - 156) / 2, 15, dataSource, windowData); } @Override diff --git a/src/main/java/mekanism/client/gui/element/tab/window/GuiUpgradeWindowTab.java b/src/main/java/mekanism/client/gui/element/tab/window/GuiUpgradeWindowTab.java index bb9743614f7..229b733d42a 100644 --- a/src/main/java/mekanism/client/gui/element/tab/window/GuiUpgradeWindowTab.java +++ b/src/main/java/mekanism/client/gui/element/tab/window/GuiUpgradeWindowTab.java @@ -30,7 +30,7 @@ protected void colorTab(GuiGraphics guiGraphics) { @Override protected GuiWindow createWindow(SelectedWindowData windowData) { - return new GuiUpgradeWindow(gui(), getGuiWidth() / 2 - 156 / 2, 15, dataSource, windowData); + return new GuiUpgradeWindow(gui(), (getGuiWidth() - 198) / 2, 15, dataSource, windowData); } @Override diff --git a/src/main/java/mekanism/client/gui/element/text/ButtonType.java b/src/main/java/mekanism/client/gui/element/text/ButtonType.java index 70f372e06ae..0b59b66f1cc 100644 --- a/src/main/java/mekanism/client/gui/element/text/ButtonType.java +++ b/src/main/java/mekanism/client/gui/element/text/ButtonType.java @@ -8,10 +8,10 @@ import mekanism.common.util.MekanismUtils.ResourceType; public enum ButtonType { - NORMAL((field, callback) -> new MekanismImageButton(field.gui(), field.getRelativeX() + field.getWidth() - field.getHeight(), field.getRelativeY(), + NORMAL((field, callback) -> new MekanismImageButton(field.gui(), field.getRelativeRight() - field.getHeight(), field.getRelativeY(), field.getHeight(), 12, MekanismUtils.getResource(ResourceType.GUI_BUTTON, "checkmark.png"), callback)), DIGITAL((field, callback) -> { - MekanismImageButton ret = new MekanismImageButton(field.gui(), field.getRelativeX() + field.getWidth() - field.getHeight(), field.getRelativeY(), + MekanismImageButton ret = new MekanismImageButton(field.gui(), field.getRelativeRight() - field.getHeight(), field.getRelativeY(), field.getHeight(), 12, MekanismUtils.getResource(ResourceType.GUI_BUTTON, "checkmark_digital.png"), callback); ret.setButtonBackground(ButtonBackground.DIGITAL); return ret; diff --git a/src/main/java/mekanism/client/gui/element/text/GuiTextField.java b/src/main/java/mekanism/client/gui/element/text/GuiTextField.java index 3ac28cdce01..3730a31b57f 100644 --- a/src/main/java/mekanism/client/gui/element/text/GuiTextField.java +++ b/src/main/java/mekanism/client/gui/element/text/GuiTextField.java @@ -17,6 +17,7 @@ import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.events.ContainerEventHandler; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import net.minecraft.util.StringUtil; @@ -60,7 +61,7 @@ public GuiTextField(IGuiWrapper gui, ContainerEventHandler parent, int x, int y, super(gui, x, y, width, height); this.parent = parent; - textField = new ClearingEditBox(getFont(), getX(), getY(), width, height, Component.empty()); + textField = new ClearingEditBox(font(), getX(), getY(), width, height, CommonComponents.EMPTY); textField.setBordered(false); textField.setResponder(s -> { if (responder != null) { @@ -214,10 +215,10 @@ public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mou textField.render(guiGraphics, mouseX, mouseY, partialTicks); } else { // hacky. we should write our own renderer at some point. - float reverse = (1 / textScale) - 1; - float yAdd = 4 - (textScale * 8) / 2F; + float reverse = (1 - textScale) / textScale; pose.scale(textScale, textScale, textScale); - pose.translate(textField.getX() * reverse, textField.getY() * reverse + yAdd / textScale, 0); + //Note: We use 4 instead of half line height (4.5) as text fields use 8 for calculating text positioning + pose.translate(textField.getX() * reverse, (textField.getY() + 4) * reverse, 0); textField.render(guiGraphics, mouseX, mouseY, partialTicks); } pose.popPose(); diff --git a/src/main/java/mekanism/client/gui/element/window/GuiColorWindow.java b/src/main/java/mekanism/client/gui/element/window/GuiColorWindow.java index 3ceb94abed1..11d2b4bb7de 100644 --- a/src/main/java/mekanism/client/gui/element/window/GuiColorWindow.java +++ b/src/main/java/mekanism/client/gui/element/window/GuiColorWindow.java @@ -124,8 +124,7 @@ public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); drawTitleText(guiGraphics, MekanismLang.COLOR_PICKER.translate(), 6); ILangEntry entry = handlesAlpha ? MekanismLang.RGBA : MekanismLang.RGB; - int textOffset = handlesAlpha ? 6 : 0; - drawTextScaledBound(guiGraphics, entry.translate(), relativeX + 7, relativeY + height - 18F, titleTextColor(), 20 + textOffset); + drawScrollingString(guiGraphics, entry.translate(), 2, height - 18, TextAlignment.RIGHT, titleTextColor(), textField.getRelativeX() - relativeX - 2, 2, false); } private void drawTiledGradient(GuiGraphics guiGraphics, int x, int y, int width, int height) { diff --git a/src/main/java/mekanism/client/gui/element/window/GuiConfirmationDialog.java b/src/main/java/mekanism/client/gui/element/window/GuiConfirmationDialog.java index e47916a8efa..f079a3c8044 100644 --- a/src/main/java/mekanism/client/gui/element/window/GuiConfirmationDialog.java +++ b/src/main/java/mekanism/client/gui/element/window/GuiConfirmationDialog.java @@ -11,11 +11,13 @@ public class GuiConfirmationDialog extends GuiWindow { + private static final int PADDING = 5; + private final WrappedTextRenderer wrappedTextRenderer; - private GuiConfirmationDialog(IGuiWrapper gui, int x, int y, int width, int height, Component title, Runnable onConfirm, DialogType type) { + private GuiConfirmationDialog(IGuiWrapper gui, int x, int y, int width, int height, ReplaceableWrappedTextRenderer renderer, Runnable onConfirm, DialogType type) { super(gui, x, y, width, height, WindowType.CONFIRMATION); - this.wrappedTextRenderer = new WrappedTextRenderer(this, title); + this.wrappedTextRenderer = renderer.replaceFont(this); active = true; addChild(new TranslationButton(gui, relativeX + width / 2 - 51, relativeY + height - 24, 50, 18, MekanismLang.BUTTON_CANCEL, this::close)); @@ -27,14 +29,15 @@ private GuiConfirmationDialog(IGuiWrapper gui, int x, int y, int width, int heig public static void show(IGuiWrapper gui, Component title, Runnable onConfirm, DialogType type) { int width = 140; - int height = 33 + WrappedTextRenderer.calculateHeightRequired(gui.getFont(), title, width, width - 10); - gui.addWindow(new GuiConfirmationDialog(gui, (gui.getXSize() - width) / 2, (gui.getYSize() - height) / 2, width, height, title, onConfirm, type)); + ReplaceableWrappedTextRenderer renderer = new ReplaceableWrappedTextRenderer(gui, width, title); + int height = 33 + renderer.getRequiredHeight(width - 2 * PADDING); + gui.addWindow(new GuiConfirmationDialog(gui, (gui.getXSize() - width) / 2, (gui.getYSize() - height) / 2, width, height, renderer, onConfirm, type)); } @Override public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); - wrappedTextRenderer.renderCentered(guiGraphics, relativeX + (width / 2F), relativeY + 6, titleTextColor(), width - 10); + wrappedTextRenderer.render(guiGraphics, relativeX + PADDING, relativeY + 6, width - 2 * PADDING, TextAlignment.CENTER, titleTextColor()); } @Override diff --git a/src/main/java/mekanism/client/gui/element/window/GuiMekaSuitHelmetOptions.java b/src/main/java/mekanism/client/gui/element/window/GuiMekaSuitHelmetOptions.java index 654e269b254..68a65e4e379 100644 --- a/src/main/java/mekanism/client/gui/element/window/GuiMekaSuitHelmetOptions.java +++ b/src/main/java/mekanism/client/gui/element/window/GuiMekaSuitHelmetOptions.java @@ -59,13 +59,13 @@ public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); drawTitleText(guiGraphics, MekanismLang.HELMET_OPTIONS.translate(), 6); - drawTextExact(guiGraphics, MekanismLang.HUD_OVERLAY.translate(), relativeX + 7, relativeY + 20, headingTextColor()); + drawScrollingString(guiGraphics, MekanismLang.HUD_OVERLAY.translate(), 0, 20, TextAlignment.LEFT, headingTextColor(), 7, false); - drawScaledCenteredText(guiGraphics, MekanismLang.DEFAULT.translate(), relativeX + 21, relativeY + 52, subheadingTextColor(), 0.8F); - drawScaledCenteredText(guiGraphics, MekanismLang.WARNING.translate(), relativeX + 70, relativeY + 52, subheadingTextColor(), 0.8F); - drawScaledCenteredText(guiGraphics, MekanismLang.DANGER.translate(), relativeX + 119, relativeY + 52, subheadingTextColor(), 0.8F); + drawScaledScrollingString(guiGraphics, MekanismLang.DEFAULT.translate(), 6, 52, TextAlignment.CENTER, subheadingTextColor(), 32, 0, false, 0.8F); + drawScaledScrollingString(guiGraphics, MekanismLang.WARNING.translate(), 55, 52, TextAlignment.CENTER, subheadingTextColor(), 32, 0, false, 0.8F); + drawScaledScrollingString(guiGraphics, MekanismLang.DANGER.translate(), 104, 52, TextAlignment.CENTER, subheadingTextColor(), 32, 0, false, 0.8F); - drawScaledCenteredText(guiGraphics, MekanismLang.OPACITY.translate(Math.round(MekanismConfig.client.hudOpacity.get() * 100)), relativeX + 70, relativeY + 75, subheadingTextColor(), 0.8F); - drawScaledCenteredText(guiGraphics, MekanismLang.JITTER.translate((int) MekanismConfig.client.hudJitter.get()), relativeX + 70, relativeY + 100, subheadingTextColor(), 0.8F); + drawScaledScrollingString(guiGraphics, MekanismLang.OPACITY.translate(Math.round(MekanismConfig.client.hudOpacity.get() * 100)), 0, 75, TextAlignment.CENTER, subheadingTextColor(), 4, false, 0.8F); + drawScaledScrollingString(guiGraphics, MekanismLang.JITTER.translate((int) MekanismConfig.client.hudJitter.get()), 0, 100, TextAlignment.CENTER, subheadingTextColor(), 4, false, 0.8F); } } diff --git a/src/main/java/mekanism/client/gui/element/window/GuiSideConfiguration.java b/src/main/java/mekanism/client/gui/element/window/GuiSideConfiguration.java index b2d0240ef61..bb78ca5faea 100644 --- a/src/main/java/mekanism/client/gui/element/window/GuiSideConfiguration.java +++ b/src/main/java/mekanism/client/gui/element/window/GuiSideConfiguration.java @@ -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()); @@ -88,12 +88,12 @@ public GuiSideConfiguration(IGuiWrapper gui, int x, int y, TILE tile, SelectedWi DataType targetType = getTargetType(DataType::getPrevious); return PacketUtils.sendToServer(new PacketBatchConfiguration(this.tile.getBlockPos(), Screen.hasShiftDown() ? null : currentType, targetType)); }, TooltipUtils.create(MekanismLang.SIDE_CONFIG_CLEAR, MekanismLang.SIDE_CONFIG_CLEAR_ALL), TooltipUtils.create(MekanismLang.SIDE_CONFIG_INCREMENT))); - addSideDataButton(RelativeSide.BOTTOM, 68, 92); - addSideDataButton(RelativeSide.TOP, 68, 46); - addSideDataButton(RelativeSide.FRONT, 68, 69); - addSideDataButton(RelativeSide.BACK, 45, 92); - addSideDataButton(RelativeSide.LEFT, 45, 69); - addSideDataButton(RelativeSide.RIGHT, 91, 69); + addSideDataButton(RelativeSide.BOTTOM, 67, 92); + addSideDataButton(RelativeSide.TOP, 67, 46); + addSideDataButton(RelativeSide.FRONT, 67, 69); + addSideDataButton(RelativeSide.BACK, 44, 92); + addSideDataButton(RelativeSide.LEFT, 44, 69); + addSideDataButton(RelativeSide.RIGHT, 90, 69); updateTabs(); ((MekanismContainer) ((GuiMekanism) gui()).getMenu()).startTracking(MekanismContainer.SIDE_CONFIG_WINDOW, this.tile.getConfig()); PacketUtils.sendToServer(new PacketGuiInteract(GuiInteraction.CONTAINER_TRACK_SIDE_CONFIG, tile, MekanismContainer.SIDE_CONFIG_WINDOW)); @@ -171,11 +171,11 @@ public void updateTabs() { public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); drawTitleText(guiGraphics, MekanismLang.CONFIG_TYPE.translate(currentType), 5); - drawCenteredText(guiGraphics, MekanismLang.SLOTS.translate(), relativeX + 80, relativeY + 120, subheadingTextColor()); + drawScrollingString(guiGraphics, MekanismLang.SLOTS.translate(), 0, 120, TextAlignment.CENTER, subheadingTextColor(), 4, false); } @Override protected int getTitlePadEnd() { - return super.getTitlePadEnd() + 15; + return super.getTitlePadEnd() + 18; } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/element/window/GuiTransporterConfig.java b/src/main/java/mekanism/client/gui/element/window/GuiTransporterConfig.java index d0f6df8d411..917e9fbbfdf 100644 --- a/src/main/java/mekanism/client/gui/element/window/GuiTransporterConfig.java +++ b/src/main/java/mekanism/client/gui/element/window/GuiTransporterConfig.java @@ -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"), @@ -76,12 +76,12 @@ public void close() { public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); drawTitleText(guiGraphics, MekanismLang.TRANSPORTER_CONFIG.translate(), 5); - drawCenteredText(guiGraphics, MekanismLang.INPUT.translate(), relativeX + 51, relativeY + 105, subheadingTextColor()); - drawCenteredText(guiGraphics, MekanismLang.OUTPUT.translate(), relativeX + 121, relativeY + 68, subheadingTextColor()); + drawScrollingString(guiGraphics, MekanismLang.INPUT.translate(), 18, 105, TextAlignment.CENTER, subheadingTextColor(), 68, 0, false); + drawScrollingString(guiGraphics, MekanismLang.OUTPUT.translate(), 86, 68, TextAlignment.CENTER, subheadingTextColor(), width - 86, 4, false); } @Override protected int getTitlePadEnd() { - return super.getTitlePadEnd() + 15; + return super.getTitlePadEnd() + 18; } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/element/window/GuiUpgradeWindow.java b/src/main/java/mekanism/client/gui/element/window/GuiUpgradeWindow.java index a25a08c4621..749d01ef038 100644 --- a/src/main/java/mekanism/client/gui/element/window/GuiUpgradeWindow.java +++ b/src/main/java/mekanism/client/gui/element/window/GuiUpgradeWindow.java @@ -24,6 +24,7 @@ import mekanism.common.network.to_server.PacketGuiInteract.GuiInteraction; import mekanism.common.tile.base.TileEntityMekanism; import mekanism.common.util.UpgradeUtils; +import net.minecraft.Util; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; @@ -35,20 +36,26 @@ public class GuiUpgradeWindow extends GuiWindow { private final TileEntityMekanism tile; private final MekanismButton removeButton; private final GuiUpgradeScrollList scrollList; + private final GuiInnerScreen rightScreen; + + private long msSelected; public GuiUpgradeWindow(IGuiWrapper gui, int x, int y, TileEntityMekanism tile, SelectedWindowData windowData) { - super(gui, x, y, 156, 76 + 12 * GuiSupportedUpgrades.calculateNeededRows(), windowData); + super(gui, x, y, 198, 76 + Math.max(18, 12 * GuiSupportedUpgrades.calculateNeededRows(gui)), windowData); if (windowData.type != WindowType.UPGRADE) { throw new IllegalArgumentException("Upgrade windows must have an upgrade window type"); } this.tile = tile; interactionStrategy = InteractionStrategy.ALL; - scrollList = addChild(new GuiUpgradeScrollList(gui, relativeX + 6, relativeY + 18, 66, 50, tile.getComponent(), this::updateEnabledButtons)); + scrollList = addChild(new GuiUpgradeScrollList(gui, relativeX + 6, relativeY + 18, 50, tile.getComponent(), () -> { + updateEnabledButtons(); + msSelected = Util.getMillis(); + })); addChild(new GuiSupportedUpgrades(gui, relativeX + 6, relativeY + 68, tile.getComponent().getSupportedTypes())); - addChild(new GuiInnerScreen(gui, relativeX + 72, relativeY + 18, 59, 50)); - addChild(new GuiProgress(() -> this.tile.getComponent().getScaledUpgradeProgress(), ProgressType.INSTALLING, gui, relativeX + 134, relativeY + 37)); - addChild(new GuiProgress(() -> 0, ProgressType.UNINSTALLING, gui, relativeX + 134, relativeY + 59)); - removeButton = addChild(new DigitalButton(gui, relativeX + 73, relativeY + 54, 56, 12, MekanismLang.UPGRADE_UNINSTALL, (element, mouseX, mouseY) -> { + rightScreen = addChild(new GuiInnerScreen(gui, scrollList.getRelativeRight(), relativeY + 18, 59, 50)); + addChild(new GuiProgress(() -> this.tile.getComponent().getScaledUpgradeProgress(), ProgressType.INSTALLING, gui, rightScreen.getRelativeRight() + 3, relativeY + 37)); + addChild(new GuiProgress(() -> 0, ProgressType.UNINSTALLING, gui, rightScreen.getRelativeRight() + 3, relativeY + 58)); + removeButton = addChild(new DigitalButton(gui, scrollList.getRelativeRight() + 1, relativeY + 54, 56, 12, MekanismLang.UPGRADE_UNINSTALL, (element, mouseX, mouseY) -> { if (scrollList.hasSelection()) { return PacketUtils.sendToServer(new PacketGuiInteract(Screen.hasShiftDown() ? GuiInteraction.REMOVE_ALL_UPGRADE : GuiInteraction.REMOVE_UPGRADE, this.tile, scrollList.getSelection().ordinal())); @@ -56,8 +63,8 @@ public GuiUpgradeWindow(IGuiWrapper gui, int x, int y, TileEntityMekanism tile, return false; })).setTooltip(MekanismLang.UPGRADE_UNINSTALL_TOOLTIP); MekanismTileContainer container = (MekanismTileContainer) ((GuiMekanism) gui()).getMenu(); - addChild(new GuiVirtualSlot(this, SlotType.NORMAL, gui, relativeX + 133, relativeY + 18, container.getUpgradeSlot())); - addChild(new GuiVirtualSlot(this, SlotType.NORMAL, gui, relativeX + 133, relativeY + 73, container.getUpgradeOutputSlot())); + addChild(new GuiVirtualSlot(this, SlotType.NORMAL, gui, rightScreen.getRelativeRight() + 2, relativeY + 18, container.getUpgradeSlot())); + addChild(new GuiVirtualSlot(this, SlotType.NORMAL, gui, rightScreen.getRelativeRight() + 2, relativeY + 72, container.getUpgradeOutputSlot())); updateEnabledButtons(); container.startTracking(MekanismContainer.UPGRADE_WINDOW, tile.getComponent()); PacketUtils.sendToServer(new PacketGuiInteract(GuiInteraction.CONTAINER_TRACK_UPGRADES, tile, MekanismContainer.UPGRADE_WINDOW)); @@ -81,22 +88,25 @@ public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { if (scrollList.hasSelection()) { Upgrade selectedType = scrollList.getSelection(); int amount = tile.getComponent().getUpgrades(selectedType); - int textY = relativeY + 20; WrappedTextRenderer textRenderer = upgradeTypeData.get(selectedType); if (textRenderer == null) { textRenderer = new WrappedTextRenderer(this, MekanismLang.UPGRADE_TYPE.translate(selectedType)); upgradeTypeData.put(selectedType, textRenderer); } - int lines = textRenderer.renderWithScale(guiGraphics, relativeX + 74, textY, screenTextColor(), 56, 0.6F); - textY += 6 * lines + 2; - drawTextWithScale(guiGraphics, MekanismLang.UPGRADE_COUNT.translate(amount, selectedType.getMax()), relativeX + 74, textY, screenTextColor(), 0.6F); + int screenWidth = rightScreen.getWidth() - 2; + int lines = textRenderer.renderWithScale(guiGraphics, rightScreen.getRelativeX() + 2, rightScreen.getRelativeY() + 2, TextAlignment.LEFT, screenTextColor(), + screenWidth - 2, 0.6F); + int textY = 4 + 6 * lines; + rightScreen.drawScaledScrollingString(guiGraphics, MekanismLang.UPGRADE_COUNT.translate(amount, selectedType.getMax()), 0, textY, TextAlignment.LEFT, + screenTextColor(), screenWidth, 2, false, 0.6F, msSelected); for (Component component : UpgradeUtils.getInfo(tile, selectedType)) { //Note: We add the six here instead of after to account for the line above this for loop that draws the upgrade count textY += 6; - drawTextWithScale(guiGraphics, component, relativeX + 74, textY, screenTextColor(), 0.6F); + rightScreen.drawScaledScrollingString(guiGraphics, component, 0, textY, TextAlignment.LEFT, screenTextColor(), screenWidth, 2, + false, 0.6F, msSelected); } } else { - noSelection.renderWithScale(guiGraphics, relativeX + 74, relativeY + 20, screenTextColor(), 56, 0.8F); + noSelection.renderWithScale(guiGraphics, rightScreen.getRelativeX() + 2, rightScreen.getRelativeY() + 2, TextAlignment.LEFT, screenTextColor(), 56, 0.8F); } } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/element/window/GuiWindow.java b/src/main/java/mekanism/client/gui/element/window/GuiWindow.java index 411b9e690e4..fbb2763e32e 100644 --- a/src/main/java/mekanism/client/gui/element/window/GuiWindow.java +++ b/src/main/java/mekanism/client/gui/element/window/GuiWindow.java @@ -17,6 +17,7 @@ import mekanism.common.inventory.container.SelectedWindowData.WindowPosition; import mekanism.common.inventory.container.SelectedWindowData.WindowType; import mekanism.common.lib.Color; +import net.minecraft.Util; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; @@ -34,6 +35,7 @@ public class GuiWindow extends GuiTexturedElement implements IGUIWindow { private Consumer closeListener; private Consumer reattachListener; + private final long msOpened; protected InteractionStrategy interactionStrategy = InteractionStrategy.CONTAINER; @@ -79,6 +81,7 @@ private GuiWindow(IGuiWrapper gui, WindowPosition calculatedPosition, int width, this.pinned = calculatedPosition.pinned(); isOverlay = true; active = true; + msOpened = Util.getMillis(); if (!isFocusOverlay()) { addCloseButton(); if (this.windowData.type.canPin()) { @@ -87,6 +90,11 @@ private GuiWindow(IGuiWrapper gui, WindowPosition calculatedPosition, int width, } } + @Override + public long getTimeOpened() { + return msOpened; + } + public void onFocusLost() { } @@ -228,18 +236,12 @@ protected boolean isFocusOverlay() { } @Override - public void drawTitleText(GuiGraphics guiGraphics, Component text, float y) { + public void drawTitleText(GuiGraphics guiGraphics, Component text, int y) { if (isFocusOverlay()) { super.drawTitleText(guiGraphics, text, y); } else { //Adjust spacing for close button and any other buttons like side config's auto eject - int leftShift = getTitlePadStart(); - int xSize = getXSize() - leftShift - getTitlePadEnd(); - int maxLength = xSize - 12; - float textWidth = getStringWidth(text); - float scale = Math.min(1, maxLength / textWidth); - float left = relativeX + xSize / 2F; - drawScaledCenteredText(guiGraphics, text, left + leftShift, relativeY + y, titleTextColor(), scale); + drawTitleTextTextWithOffset(guiGraphics, text, getTitlePadStart(), y, getXSize() - getTitlePadEnd()); } } diff --git a/src/main/java/mekanism/client/gui/element/window/filter/GuiFilter.java b/src/main/java/mekanism/client/gui/element/window/filter/GuiFilter.java index 7e723156892..97ba46d642e 100644 --- a/src/main/java/mekanism/client/gui/element/window/filter/GuiFilter.java +++ b/src/main/java/mekanism/client/gui/element/window/filter/GuiFilter.java @@ -108,10 +108,11 @@ protected int getSlotOffset() { } protected int getScreenHeight() { - return 43; + return 42; } - protected int getScreenWidth() { + @Override + public int getScreenWidth() { return 116; } diff --git a/src/main/java/mekanism/client/gui/element/window/filter/GuiFilterHelper.java b/src/main/java/mekanism/client/gui/element/window/filter/GuiFilterHelper.java index 8010950562f..4675b90c884 100644 --- a/src/main/java/mekanism/client/gui/element/window/filter/GuiFilterHelper.java +++ b/src/main/java/mekanism/client/gui/element/window/filter/GuiFilterHelper.java @@ -20,4 +20,6 @@ default boolean hasFilterSelect() { int getRelativeY(); IFilter getFilter(); + + int getScreenWidth(); } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/element/window/filter/GuiOredictionificatorFilter.java b/src/main/java/mekanism/client/gui/element/window/filter/GuiOredictionificatorFilter.java index 1d6ae34cef7..dfcc5e48212 100644 --- a/src/main/java/mekanism/client/gui/element/window/filter/GuiOredictionificatorFilter.java +++ b/src/main/java/mekanism/client/gui/element/window/filter/GuiOredictionificatorFilter.java @@ -21,32 +21,29 @@ public class GuiOredictionificatorFilter extends GuiTextFilter { + 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 53; - } - - @Override - protected int getSlotOffset() { - return 32; + return 52; } @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(); @@ -54,7 +51,7 @@ protected void init() { } 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(); diff --git a/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerFilterHelper.java b/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerFilterHelper.java index 64bb8d5616c..18878ca23fc 100644 --- a/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerFilterHelper.java +++ b/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerFilterHelper.java @@ -22,6 +22,8 @@ public interface GuiMinerFilterHelper extends GuiFilterHelper { + int MINER_FILTER_WIDTH = 173; + @Override MinerFilter getFilter(); diff --git a/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerItemStackFilter.java b/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerItemStackFilter.java index f0c5072acc1..35380d85416 100644 --- a/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerItemStackFilter.java +++ b/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerItemStackFilter.java @@ -12,15 +12,15 @@ public class GuiMinerItemStackFilter extends GuiItemStackFilter 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 diff --git a/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerModIDFilter.java b/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerModIDFilter.java index 1e8a9987485..ca8e30d61d6 100644 --- a/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerModIDFilter.java +++ b/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerModIDFilter.java @@ -14,15 +14,15 @@ public class GuiMinerModIDFilter extends GuiModIDFilter 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 diff --git a/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerTagFilter.java b/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerTagFilter.java index 780e0afc88e..4367b41cd51 100644 --- a/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerTagFilter.java +++ b/src/main/java/mekanism/client/gui/element/window/filter/miner/GuiMinerTagFilter.java @@ -14,15 +14,15 @@ public class GuiMinerTagFilter extends GuiTagFilter 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 diff --git a/src/main/java/mekanism/client/gui/element/window/filter/qio/GuiQIOItemStackFilter.java b/src/main/java/mekanism/client/gui/element/window/filter/qio/GuiQIOItemStackFilter.java index 2b7058f3d0d..11d6d1d77dc 100644 --- a/src/main/java/mekanism/client/gui/element/window/filter/qio/GuiQIOItemStackFilter.java +++ b/src/main/java/mekanism/client/gui/element/window/filter/qio/GuiQIOItemStackFilter.java @@ -46,6 +46,6 @@ protected QIOItemStackFilter createNewFilter() { @Override public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); - drawString(guiGraphics, OnOff.of(filter.fuzzyMode).getTextComponent(), relativeX + 161, relativeY + 20, titleTextColor()); + drawScrollingString(guiGraphics, OnOff.of(filter.fuzzyMode).getTextComponent(), 159, 20, TextAlignment.LEFT, titleTextColor(), width - 161, 2, false); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterFilterHelper.java b/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterFilterHelper.java index e520491cb60..2f6a77339d0 100644 --- a/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterFilterHelper.java +++ b/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterFilterHelper.java @@ -28,6 +28,8 @@ public interface GuiSorterFilterHelper extends GuiFilterHelper, IFancyFontRenderer, ContainerEventHandler { + int SORTER_FILTER_WIDTH = 200; + @Override SorterFilter getFilter(); @@ -54,12 +56,12 @@ default void addSorterDefaults(IGuiWrapper gui, int slotOffset, UnaryOperator filter = getFilter(); - drawString(guiGraphics, OnOff.of(filter.allowDefault).getTextComponent(), relativeX + 161, relativeY + 20, titleTextColor()); - drawString(guiGraphics, MekanismLang.MIN.translate(""), relativeX + 148, relativeY + 32, titleTextColor()); - drawString(guiGraphics, MekanismLang.MAX.translate(""), relativeX + 148, relativeY + 44, titleTextColor()); + 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(), 173 - screenEnd, 2, false); + drawScrollingString(guiGraphics, MekanismLang.MAX.translate(""), screenEnd, 44, TextAlignment.LEFT, titleTextColor(), 173 - screenEnd, 2, false); if (isSingleItem() && filter.sizeMode) { - drawString(guiGraphics, MekanismLang.SORTER_FILTER_SIZE_MODE.translateColored(EnumColor.RED, OnOff.ON), relativeX + 161, relativeY + 58, titleTextColor()); + drawScrollingString(guiGraphics, MekanismLang.SORTER_FILTER_SIZE_MODE.translateColored(EnumColor.RED, OnOff.ON), 159, 58, TextAlignment.LEFT, titleTextColor(), getXSize() - 159, 2, false); } else { - drawString(guiGraphics, OnOff.of(filter.sizeMode).getTextComponent(), relativeX + 161, relativeY + 58, titleTextColor()); + drawScrollingString(guiGraphics, OnOff.of(filter.sizeMode).getTextComponent(), 159, 58, TextAlignment.LEFT, titleTextColor(), getXSize() - 161, 2, false); } } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterItemStackFilter.java b/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterItemStackFilter.java index 4d716783644..b879cf24f01 100644 --- a/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterItemStackFilter.java +++ b/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterItemStackFilter.java @@ -14,18 +14,18 @@ public class GuiSorterItemStackFilter extends GuiItemStackFilter 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 @@ -60,7 +60,7 @@ protected SorterItemStackFilter createNewFilter() { public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) { super.renderForeground(guiGraphics, mouseX, mouseY); renderSorterForeground(guiGraphics); - drawString(guiGraphics, OnOff.of(filter.fuzzyMode).getTextComponent(), relativeX + 161, relativeY + 71, titleTextColor()); + drawScrollingString(guiGraphics, OnOff.of(filter.fuzzyMode).getTextComponent(), 159, 71, TextAlignment.LEFT, titleTextColor(), width - 159, 2, false); } @Override diff --git a/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterModIDFilter.java b/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterModIDFilter.java index 506aad2dbe9..0d4301f5209 100644 --- a/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterModIDFilter.java +++ b/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterModIDFilter.java @@ -11,18 +11,18 @@ public class GuiSorterModIDFilter extends GuiModIDFilter 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 diff --git a/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterTagFilter.java b/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterTagFilter.java index 18851b914cd..19f04580728 100644 --- a/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterTagFilter.java +++ b/src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterTagFilter.java @@ -11,18 +11,18 @@ public class GuiSorterTagFilter extends GuiTagFilter implements GuiSorterFilterHelper { public static GuiSorterTagFilter create(IGuiWrapper gui, TileEntityLogisticalSorter tile) { - return new GuiSorterTagFilter(gui, (gui.getXSize() - 182) / 2, 30, tile, null); + return new GuiSorterTagFilter(gui, (gui.getXSize() - SORTER_FILTER_WIDTH) / 2, 30, tile, null); } public static GuiSorterTagFilter edit(IGuiWrapper gui, TileEntityLogisticalSorter tile, SorterTagFilter filter) { - return new GuiSorterTagFilter(gui, (gui.getXSize() - 182) / 2, 30, tile, filter); + return new GuiSorterTagFilter(gui, (gui.getXSize() - SORTER_FILTER_WIDTH) / 2, 30, tile, filter); } private GuiTextField minField; private GuiTextField maxField; private GuiSorterTagFilter(IGuiWrapper gui, int x, int y, TileEntityLogisticalSorter tile, @Nullable SorterTagFilter origFilter) { - super(gui, x, y, 195, 90, tile, origFilter); + super(gui, x, y, SORTER_FILTER_WIDTH, 90, tile, origFilter); } @Override diff --git a/src/main/java/mekanism/client/gui/item/GuiDictionary.java b/src/main/java/mekanism/client/gui/item/GuiDictionary.java index 9f109d9dff2..466e7ed2075 100644 --- a/src/main/java/mekanism/client/gui/item/GuiDictionary.java +++ b/src/main/java/mekanism/client/gui/item/GuiDictionary.java @@ -24,6 +24,7 @@ public class GuiDictionary extends GuiMekanism { private GuiTextScrollList scrollList; private GuiDictionaryTarget target; + private GuiDropdown dropdown; private DictionaryTagType currentType = DictionaryTagType.ITEM; public GuiDictionary(DictionaryContainer container, Inventory inv, Component title) { @@ -41,7 +42,7 @@ protected void addGuiElements() { scrollList = addRenderableWidget(new GuiTextScrollList(this, 7, 29, 162, 42)); //TODO: Ideally we would eventually replace this with some sort of tab system as it would probably look better // and could then be limited to just the tags the target supports - addRenderableWidget(new GuiDropdown<>(this, 124, 73, 45, DictionaryTagType.class, () -> currentType, this::setCurrentType)); + dropdown = addRenderableWidget(new GuiDropdown<>(this, 113, 73, 56, DictionaryTagType.class, () -> currentType, this::setCurrentType)); target = addRenderableWidget(new GuiDictionaryTarget(this, 6, 6, this::updateScrollList)); } @@ -59,9 +60,8 @@ private void updateScrollList(Set supportedTypes) { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); - drawTextScaledBound(guiGraphics, MekanismLang.DICTIONARY_TAG_TYPE.translate(), 77, inventoryLabelY, titleTextColor(), 45); + renderTitleTextWithOffset(guiGraphics, target.getRelativeRight()); + renderInventoryTextAndOther(guiGraphics, MekanismLang.DICTIONARY_TAG_TYPE.translate(), imageWidth - dropdown.getRelativeX() - 5); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/item/GuiPersonalStorageItem.java b/src/main/java/mekanism/client/gui/item/GuiPersonalStorageItem.java index 3d2e6807af9..9817a490aa8 100644 --- a/src/main/java/mekanism/client/gui/item/GuiPersonalStorageItem.java +++ b/src/main/java/mekanism/client/gui/item/GuiPersonalStorageItem.java @@ -26,7 +26,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/item/GuiPortableTeleporter.java b/src/main/java/mekanism/client/gui/item/GuiPortableTeleporter.java index 63c72e7bce0..057dd32b975 100644 --- a/src/main/java/mekanism/client/gui/item/GuiPortableTeleporter.java +++ b/src/main/java/mekanism/client/gui/item/GuiPortableTeleporter.java @@ -28,6 +28,7 @@ public class GuiPortableTeleporter extends GuiMekanism implements IItemGuiFrequencySelector, IGuiColorFrequencySelector { + private GuiTeleporterStatus status; private MekanismButton teleportButton; public GuiPortableTeleporter(PortableTeleporterContainer container, Inventory inv, Component title) { @@ -39,7 +40,7 @@ public GuiPortableTeleporter(PortableTeleporterContainer container, Inventory in @Override protected void addGuiElements() { super.addGuiElements(); - addRenderableWidget(new GuiTeleporterStatus(this, () -> getFrequency() != null, menu::getStatus)); + status = addRenderableWidget(new GuiTeleporterStatus(this, () -> getFrequency() != null, menu::getStatus)); addRenderableWidget(new GuiVerticalPowerBar(this, new IBarInfoHandler() { @Override public Component getTooltip() { @@ -82,7 +83,7 @@ public void buttonsUpdated() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - renderTitleText(guiGraphics); + renderTitleTextWithOffset(guiGraphics, status.getRelativeRight()); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/item/GuiSeismicReader.java b/src/main/java/mekanism/client/gui/item/GuiSeismicReader.java index 86c9fed303d..70ced1c9fe3 100644 --- a/src/main/java/mekanism/client/gui/item/GuiSeismicReader.java +++ b/src/main/java/mekanism/client/gui/item/GuiSeismicReader.java @@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.objects.Reference2IntMap; import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import mekanism.api.text.TextComponentUtil; import mekanism.client.gui.GuiMekanism; @@ -27,19 +28,23 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.BubbleColumnBlock; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.phys.BlockHitResult; import net.neoforged.neoforge.client.extensions.common.IClientFluidTypeExtensions; +import net.neoforged.neoforge.fluids.FluidType; import org.jetbrains.annotations.NotNull; public class GuiSeismicReader extends GuiMekanism { private final List> blockList = new ArrayList<>(); - private final Reference2IntMap frequencies = new Reference2IntOpenHashMap<>(); + private final Reference2IntMap blockFrequencies = new Reference2IntOpenHashMap<>(); + private final Reference2IntMap fluidFrequencies = new Reference2IntOpenHashMap<>(); private final int minHeight; private MekanismButton upButton; private MekanismButton downButton; @@ -47,7 +52,7 @@ public class GuiSeismicReader extends GuiMekanism { 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(); @@ -56,28 +61,40 @@ public GuiSeismicReader(SeismicReaderContainer container, Inventory inv, Compone //Calculate all the blocks in the column for (BlockPos p : BlockPos.betweenClosed(new BlockPos(pos.getX(), minHeight, pos.getZ()), pos)) { BlockState state = level.getBlockState(p); + if (state.isAir()) {//Ensure all types of air are treated as air for calculations + state = Blocks.AIR.defaultBlockState(); + } + Block block = state.getBlock(); + blockFrequencies.mergeInt(block, 1, Integer::sum); //Try to get the clone item stack as maybe it has one, though it might not have a corresponding block ItemStack stack = state.getCloneItemStack(new BlockHitResult(p.getCenter().relative(Direction.UP, 0.5), Direction.UP, p, false), level, p, player); if (stack.isEmpty()) { Fluid fluid = Fluids.EMPTY; - if (state.getBlock() instanceof LiquidBlock liquidBlock) { + if (block instanceof LiquidBlock liquidBlock) { fluid = liquidBlock.fluid; - } else if (state.getBlock() instanceof BubbleColumnBlock) { + } else if (block instanceof BubbleColumnBlock) { fluid = level.getFluidState(p).getType(); } if (fluid == Fluids.EMPTY) { blockList.add(new BlockInfo<>(state, state, null)); } else { - blockList.add(new BlockInfo<>(state, fluid, (graphics, f, x, y) -> { + FluidType fluidType = fluid.getFluidType(); + blockList.add(new BlockInfo<>(state, fluidType, (graphics, f, x, y) -> { IClientFluidTypeExtensions properties = IClientFluidTypeExtensions.of(f); MekanismRenderer.color(graphics, properties.getTintColor()); TextureAtlasSprite texture = MekanismRenderer.getSprite(properties.getStillTexture()); graphics.blit(x, y, 0, 16, 16, texture); MekanismRenderer.resetColor(graphics); })); + fluidFrequencies.mergeInt(fluidType, 1, Integer::sum); } } else { blockList.add(new BlockInfo<>(state, stack, this::renderItem)); + FluidState fluid = state.getFluidState(); + if (!fluid.isEmpty()) {//Take the fluid into account for frequency count + //TODO: Do we want to render the fact that it is fluid logged in some way? + fluidFrequencies.mergeInt(fluid.getFluidType(), 1, Integer::sum); + } } } } @@ -85,19 +102,36 @@ public GuiSeismicReader(SeismicReaderContainer container, Inventory inv, Compone @Override protected void addGuiElements() { super.addGuiElements(); - addRenderableWidget(new GuiInnerScreen(this, 7, 11, 63, 49)); - addRenderableWidget(new GuiInnerScreen(this, 74, 11, 51, 159)); - scrollBar = addRenderableWidget(new GuiScrollBar(this, 126, 25, 131, blockList::size, () -> 1)); - addRenderableWidget(new GuiArrowSelection(this, 76, 81, () -> { - int currentLayer = scrollBar.getCurrentSelection(); + addRenderableWidget(new GuiInnerScreen(this, 5, 11, 69, 50, () -> { + // Get the name from the stack and render it + int currentLayer = getCurrentLayer(); if (currentLayer >= 0) { - return blockList.get(blockList.size() - 1 - currentLayer).block().getName(); + List text = new ArrayList<>(4); + BlockInfo blockInfo = blockList.get(currentLayer); + BlockState state = blockInfo.state(); + Block block = state.getBlock(); + if (!(block instanceof LiquidBlock)) { + //If the block is a liquid, let the fluid handling display and calculate the quantity + //Note: Bubble columns, still get counted so that we display it is a bubble column, and how many there are + //TODO: Do we want to try and make it so that the first few lines of the block's name wraps instead of scrolls + // for very long names like waxed oxidized copper stairs? + text.add(block.getName()); + text.add(MekanismLang.ABUNDANCY.translate(blockFrequencies.getInt(block))); + } + if (blockInfo.type() instanceof FluidType fluidType) {//TODO: Improve this so it actually displays for fluid logged blocks + text.add(fluidType.getDescription()); + text.add(MekanismLang.ABUNDANCY.translate(fluidFrequencies.getInt(fluidType))); + } + return text; } - return null; - })); - upButton = addRenderableWidget(new MekanismImageButton(this, 126, 11, 14, + return Collections.emptyList(); + }).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, 156, 14, + downButton = addRenderableWidget(new MekanismImageButton(this, 129, 157, 14, MekanismUtils.getResource(ResourceType.GUI_BUTTON, "down.png"), (element, mouseX, mouseY) -> scrollBar.adjustScroll(-1))); updateEnabledButtons(); } @@ -114,14 +148,15 @@ private void updateEnabledButtons() { downButton.active = currentLayer + 1 < blockList.size(); } + private int getCurrentLayer() { + return blockList.size() - scrollBar.getCurrentSelection() - 1; + } + @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - int currentLayer = blockList.size() - scrollBar.getCurrentSelection() - 1; - //Render the layer text scaled, so that it does not start overlapping past 100 - drawTextScaledBound(guiGraphics, TextComponentUtil.build(minHeight + currentLayer), 111, 87, screenTextColor(), 13); - //TODO - V11: Eventually instead of just rendering the item stacks, it would be nice to be able to render the actual vertical column of blocks //Render the item stacks or fluids + int currentLayer = getCurrentLayer(); for (int i = 0; i < 9; i++) { int layer = currentLayer + (i - 4); if (0 <= layer && layer < blockList.size()) { @@ -129,7 +164,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); @@ -148,24 +183,6 @@ protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, } } } - int frequency = 0; - // Get the name from the stack and render it - if (currentLayer >= 0) { - Block block = blockList.get(currentLayer).block(); - Component displayName = block.getName(); - drawTextScaledBound(guiGraphics, displayName, 10, 16, screenTextColor(), 57); - if (frequencies.containsKey(block)) { - frequency = frequencies.getInt(block); - } else { - for (BlockInfo info : blockList) { - if (info.state().is(block)) { - frequency++; - } - } - frequencies.put(block, frequency); - } - } - drawTextScaledBound(guiGraphics, MekanismLang.ABUNDANCY.translate(frequency), 10, 26, screenTextColor(), 57); super.drawForegroundText(guiGraphics, mouseX, mouseY); } @@ -176,10 +193,6 @@ public boolean mouseScrolled(double mouseX, double mouseY, double xDelta, double private record BlockInfo(BlockState state, TYPE type, RenderTarget renderTarget) { - public Block block() { - return state.getBlock(); - } - public void render(GuiGraphics guiGraphics, int x, int y) { renderTarget.render(guiGraphics, type, x, y); } diff --git a/src/main/java/mekanism/client/gui/machine/GuiAdvancedElectricMachine.java b/src/main/java/mekanism/client/gui/machine/GuiAdvancedElectricMachine.java index 5cc492818a1..9971f3b5dae 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiAdvancedElectricMachine.java +++ b/src/main/java/mekanism/client/gui/machine/GuiAdvancedElectricMachine.java @@ -38,7 +38,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiAntiprotonicNucleosynthesizer.java b/src/main/java/mekanism/client/gui/machine/GuiAntiprotonicNucleosynthesizer.java index 1a25996ff67..4952d87510b 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiAntiprotonicNucleosynthesizer.java +++ b/src/main/java/mekanism/client/gui/machine/GuiAntiprotonicNucleosynthesizer.java @@ -46,6 +46,7 @@ public class GuiAntiprotonicNucleosynthesizer extends GuiConfigurableTile container, Inventory inv, Component title) { super(container, inv, title); @@ -58,7 +59,7 @@ public GuiAntiprotonicNucleosynthesizer(MekanismTileContainer tile.gasTank, () -> tile.getChemicalTanks(null), GaugeType.SMALL_MED, this, 5, 18)) .warning(WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(RecipeError.NOT_ENOUGH_SECONDARY_INPUT)); @@ -80,9 +81,10 @@ public double getLevel() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - drawString(guiGraphics, title, (imageWidth - getStringWidth(title)) / 2, titleLabelY, titleTextColor()); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); - drawTextScaledBound(guiGraphics, MekanismLang.PROCESS_RATE.translate(TextUtils.getPercent(tile.getProcessRate())), 48, 76, screenTextColor(), 100); + renderTitleText(guiGraphics); + renderInventoryText(guiGraphics); + screen.drawScrollingString(guiGraphics, MekanismLang.PROCESS_RATE.translate(TextUtils.getPercent(tile.getProcessRate())), 0, + screen.getHeight() - font().lineHeight - 2, TextAlignment.CENTER, screenTextColor(), 2, false); super.drawForegroundText(guiGraphics, mouseX, mouseY); PoseStack pose = guiGraphics.pose(); pose.pushPose(); diff --git a/src/main/java/mekanism/client/gui/machine/GuiChemicalCrystallizer.java b/src/main/java/mekanism/client/gui/machine/GuiChemicalCrystallizer.java index 6bbfd7a932d..0c1f738f557 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiChemicalCrystallizer.java +++ b/src/main/java/mekanism/client/gui/machine/GuiChemicalCrystallizer.java @@ -1,48 +1,32 @@ package mekanism.client.gui.machine; import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import mekanism.api.MekanismAPI; -import mekanism.api.MekanismAPITags; import mekanism.api.chemical.ChemicalStack; -import mekanism.api.chemical.Chemical; import mekanism.api.recipes.ChemicalCrystallizerRecipe; import mekanism.api.recipes.cache.CachedRecipe.OperationTracker.RecipeError; import mekanism.client.gui.GuiConfigurableTile; -import mekanism.client.gui.element.GuiInnerScreen; +import mekanism.client.gui.element.GuiElement; import mekanism.client.gui.element.bar.GuiVerticalPowerBar; +import mekanism.client.gui.element.custom.GuiQIOCrystallizerScreen; +import mekanism.client.gui.element.custom.GuiQIOCrystallizerScreen.IOreInfo; import mekanism.client.gui.element.gauge.GaugeType; import mekanism.client.gui.element.gauge.GuiChemicalGauge; import mekanism.client.gui.element.progress.GuiProgress; import mekanism.client.gui.element.progress.ProgressType; -import mekanism.client.gui.element.slot.GuiSequencedSlotDisplay; -import mekanism.client.gui.element.slot.GuiSlot; -import mekanism.client.gui.element.slot.SlotType; import mekanism.client.gui.element.tab.GuiEnergyTab; -import mekanism.common.MekanismLang; import mekanism.common.inventory.container.tile.MekanismTileContainer; import mekanism.common.inventory.warning.WarningTracker.WarningType; import mekanism.common.tile.machine.TileEntityChemicalCrystallizer; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.core.Holder; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; -import net.minecraft.tags.TagKey; import net.minecraft.world.entity.player.Inventory; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class GuiChemicalCrystallizer extends GuiConfigurableTile> { - private final List iterStacks = new ArrayList<>(); private final IOreInfo oreInfo = new OreInfo(); - private GuiSequencedSlotDisplay slotDisplay; - @NotNull - private Chemical prevSlurry = MekanismAPI.EMPTY_CHEMICAL; + private GuiElement inputGauge; public GuiChemicalCrystallizer(MekanismTileContainer container, Inventory inv, Component title) { super(container, inv, title); @@ -56,92 +40,26 @@ protected void addGuiElements() { addRenderableWidget(new GuiVerticalPowerBar(this, tile.getEnergyContainer(), 157, 23)) .warning(WarningType.NOT_ENOUGH_ENERGY, tile.getWarningCheck(RecipeError.NOT_ENOUGH_ENERGY)); addRenderableWidget(new GuiEnergyTab(this, tile.getEnergyContainer(), tile::getActive)); - addRenderableWidget(new GuiChemicalGauge(() -> tile.inputTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 7, 4)) + inputGauge = addRenderableWidget(new GuiChemicalGauge(() -> tile.inputTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 7, 4)) .warning(WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(RecipeError.NOT_ENOUGH_INPUT)); addRenderableWidget(new GuiProgress(tile::getScaledProgress, ProgressType.LARGE_RIGHT, this, 53, 61).recipeViewerCategory(tile)) .warning(WarningType.INPUT_DOESNT_PRODUCE_OUTPUT, tile.getWarningCheck(RecipeError.INPUT_DOESNT_PRODUCE_OUTPUT)); - //Init slot display before gui screen, so it can reference it, but add it after, so it renders above it - slotDisplay = new GuiSequencedSlotDisplay(this, 129, 14, () -> iterStacks); - updateSlotContents(); - addRenderableWidget(new GuiInnerScreen(this, 31, 13, 115, 42, () -> getScreenRenderStrings(this.oreInfo))); - addRenderableWidget(new GuiSlot(SlotType.ORE, this, 128, 13).setRenderAboveSlots()); - addRenderableWidget(slotDisplay); + addRenderableWidget(new GuiQIOCrystallizerScreen(this, 31, 13, 115, 42, oreInfo)); } @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - renderTitleText(guiGraphics); + renderTitleTextWithOffset(guiGraphics, inputGauge.getRelativeRight(), tile.getEnergySlotX()); super.drawForegroundText(guiGraphics, mouseX, mouseY); } - @Override - public void containerTick() { - updateSlotContents(); - super.containerTick(); - } - - private void updateSlotContents() { - ChemicalStack chemical = oreInfo.getInputChemical(); - if (!chemical.isEmpty()) { - Chemical inputSlurry = chemical.getChemical(); - if (prevSlurry != inputSlurry) { - prevSlurry = inputSlurry; - iterStacks.clear(); - if (!prevSlurry.isEmptyType() && !prevSlurry.is(MekanismAPITags.Chemicals.DIRTY)) { - TagKey oreTag = prevSlurry.getOreTag(); - if (oreTag != null) { - for (Holder ore : BuiltInRegistries.ITEM.getTagOrEmpty(oreTag)) { - iterStacks.add(new ItemStack(ore)); - } - } - } - slotDisplay.updateStackList(); - } - } else if (!prevSlurry.isEmptyType()) { - prevSlurry = MekanismAPI.EMPTY_CHEMICAL; - iterStacks.clear(); - slotDisplay.updateStackList(); - } - } - - public static List getScreenRenderStrings(IOreInfo oreInfo) { - ChemicalStack chemical = oreInfo.getInputChemical(); - if (!chemical.isEmpty()) { - List ret = new ArrayList<>(); - ret.add(chemical.getTextComponent()); - if (!oreInfo.getRenderStack().isEmpty()) { - ret.add(MekanismLang.GENERIC_PARENTHESIS.translate(oreInfo.getRenderStack())); - } else { - ChemicalCrystallizerRecipe recipe = oreInfo.getRecipe(); - if (recipe == null) { - ret.add(MekanismLang.NO_RECIPE.translate()); - } else { - ret.add(MekanismLang.GENERIC_PARENTHESIS.translate(recipe.getOutput(chemical))); - } - } - return ret; - } - return Collections.emptyList(); - } - - public interface IOreInfo { - - @NotNull - ChemicalStack getInputChemical(); - - @Nullable - ChemicalCrystallizerRecipe getRecipe(); - - @NotNull - ItemStack getRenderStack(); - } - private class OreInfo implements IOreInfo { private WeakReference cachedRecipe; + @NotNull @Override - public @NotNull ChemicalStack getInputChemical() { + public ChemicalStack getInputChemical() { return tile.inputTank.getStack(); } @@ -164,12 +82,6 @@ public ChemicalCrystallizerRecipe getRecipe() { return recipe; } - @NotNull - @Override - public ItemStack getRenderStack() { - return slotDisplay == null ? ItemStack.EMPTY : slotDisplay.getRenderStack(); - } - private ChemicalCrystallizerRecipe getRecipeAndCache() { ChemicalCrystallizerRecipe recipe = tile.getRecipe(0); if (recipe == null) { diff --git a/src/main/java/mekanism/client/gui/machine/GuiChemicalDissolutionChamber.java b/src/main/java/mekanism/client/gui/machine/GuiChemicalDissolutionChamber.java index 7abd8c91c59..0456f5af2bf 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/client/gui/machine/GuiChemicalDissolutionChamber.java @@ -2,6 +2,7 @@ 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.GuiHorizontalPowerBar; import mekanism.client.gui.element.gauge.GaugeType; import mekanism.client.gui.element.gauge.GuiChemicalGauge; @@ -18,6 +19,8 @@ public class GuiChemicalDissolutionChamber extends GuiConfigurableTile> { + private GuiElement inputGauge; + public GuiChemicalDissolutionChamber(MekanismTileContainer container, Inventory inv, Component title) { super(container, inv, title); dynamicSlots = true; @@ -31,7 +34,7 @@ protected void addGuiElements() { .warning(WarningType.NOT_ENOUGH_ENERGY, tile.getWarningCheck(RecipeError.NOT_ENOUGH_ENERGY)) .warning(WarningType.NOT_ENOUGH_ENERGY_REDUCED_RATE, tile.getWarningCheck(RecipeError.NOT_ENOUGH_ENERGY_REDUCED_RATE)); addRenderableWidget(new GuiEnergyTab(this, tile.getEnergyContainer(), tile::getActive)); - addRenderableWidget(new GuiChemicalGauge(() -> tile.injectTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 7, 4)) + inputGauge = addRenderableWidget(new GuiChemicalGauge(() -> tile.injectTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 7, 4)) .warning(WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(RecipeError.NOT_ENOUGH_SECONDARY_INPUT)); addRenderableWidget(new GuiChemicalGauge(() -> tile.outputTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 131, 13)) .warning(WarningType.NO_SPACE_IN_OUTPUT, tile.getWarningCheck(RecipeError.NOT_ENOUGH_OUTPUT_SPACE)); @@ -41,7 +44,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - renderTitleText(guiGraphics); + renderTitleTextWithOffset(guiGraphics, inputGauge.getRelativeRight()); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiChemicalInfuser.java b/src/main/java/mekanism/client/gui/machine/GuiChemicalInfuser.java index 1452157571a..30262ebfe57 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiChemicalInfuser.java +++ b/src/main/java/mekanism/client/gui/machine/GuiChemicalInfuser.java @@ -5,6 +5,7 @@ import mekanism.client.gui.element.bar.GuiHorizontalPowerBar; import mekanism.client.gui.element.gauge.GaugeType; import mekanism.client.gui.element.gauge.GuiChemicalGauge; +import mekanism.client.gui.element.gauge.GuiGauge; import mekanism.client.gui.element.progress.GuiProgress; import mekanism.client.gui.element.progress.ProgressType; import mekanism.client.gui.element.tab.GuiEnergyTab; @@ -18,10 +19,11 @@ public class GuiChemicalInfuser extends GuiConfigurableTile> { + private GuiGauge centerGauge; + public GuiChemicalInfuser(MekanismTileContainer container, Inventory inv, Component title) { super(container, inv, title); inventoryLabelY += 2; - titleLabelX = 5; titleLabelY = 5; dynamicSlots = true; } @@ -35,7 +37,7 @@ protected void addGuiElements() { addRenderableWidget(new GuiEnergyTab(this, tile.getEnergyContainer(), tile::getEnergyUsed)); addRenderableWidget(new GuiChemicalGauge(() -> tile.leftTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 25, 13)) .warning(WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(RecipeError.NOT_ENOUGH_LEFT_INPUT)); - addRenderableWidget(new GuiChemicalGauge(() -> tile.centerTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 79, 4)) + centerGauge = addRenderableWidget(new GuiChemicalGauge(() -> tile.centerTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 79, 4)) .warning(WarningType.NO_SPACE_IN_OUTPUT, tile.getWarningCheck(RecipeError.NOT_ENOUGH_OUTPUT_SPACE)); addRenderableWidget(new GuiChemicalGauge(() -> tile.rightTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 133, 13)) .warning(WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(RecipeError.NOT_ENOUGH_RIGHT_INPUT)); @@ -47,8 +49,8 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - drawString(guiGraphics, title, titleLabelX, titleLabelY, titleTextColor()); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderTitleTextWithOffset(guiGraphics, 1, centerGauge.getRelativeX(), 4, TextAlignment.LEFT); + renderInventoryText(guiGraphics, centerGauge.getRelativeX()); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiChemicalOxidizer.java b/src/main/java/mekanism/client/gui/machine/GuiChemicalOxidizer.java index fb316e4807c..8f01adc036f 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiChemicalOxidizer.java +++ b/src/main/java/mekanism/client/gui/machine/GuiChemicalOxidizer.java @@ -2,6 +2,7 @@ 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.GuiHorizontalPowerBar; import mekanism.client.gui.element.gauge.GaugeType; import mekanism.client.gui.element.gauge.GuiChemicalGauge; @@ -18,15 +19,18 @@ public class GuiChemicalOxidizer extends GuiConfigurableTile> { + private GuiElement energyBar; + public GuiChemicalOxidizer(MekanismTileContainer container, Inventory inv, Component title) { super(container, inv, title); dynamicSlots = true; + titleLabelY = 5; } @Override protected void addGuiElements() { super.addGuiElements(); - addRenderableWidget(new GuiHorizontalPowerBar(this, tile.getEnergyContainer(), 115, 75)) + energyBar = addRenderableWidget(new GuiHorizontalPowerBar(this, tile.getEnergyContainer(), 115, 75)) .warning(WarningType.NOT_ENOUGH_ENERGY, tile.getWarningCheck(RecipeError.NOT_ENOUGH_ENERGY)); addRenderableWidget(new GuiEnergyTab(this, tile.getEnergyContainer(), tile::getActive)); addRenderableWidget(new GuiChemicalGauge(() -> tile.gasTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 131, 13)) @@ -38,7 +42,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics, energyBar.getRelativeX()); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiCombiner.java b/src/main/java/mekanism/client/gui/machine/GuiCombiner.java index 11d30bbab17..f6f77b122e0 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiCombiner.java +++ b/src/main/java/mekanism/client/gui/machine/GuiCombiner.java @@ -36,7 +36,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiDigitalMiner.java b/src/main/java/mekanism/client/gui/machine/GuiDigitalMiner.java index 2e892e6c7b2..a16c6511069 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiDigitalMiner.java +++ b/src/main/java/mekanism/client/gui/machine/GuiDigitalMiner.java @@ -57,6 +57,7 @@ public GuiDigitalMiner(MekanismTileContainer container, @Override protected void addGuiElements() { super.addGuiElements(); + int missingStackX = 64; addRenderableWidget(new GuiInnerScreen(this, 7, 19, 77, 69, () -> { List list = new ArrayList<>(); ILangEntry runningType; @@ -71,7 +72,15 @@ protected void addGuiElements() { list.add(tile.searcher.state.getTextComponent()); list.add(MekanismLang.MINER_TO_MINE.translate(TextUtils.format(tile.getToMine()))); return list; - }).spacing(1).clearFormat()); + }) { + @Override + protected int getMaxTextWidth(int row) { + if (row < 2) { + return missingStackX - relativeX + 4; + } + return super.getMaxTextWidth(row); + } + }).clearSpacing().clearFormat(); addRenderableWidget(new GuiDigitalSwitch(this, 19, 56, EJECT, tile::getDoEject, (element, mouseX, mouseY) -> PacketUtils.sendToServer(new PacketGuiInteract(GuiInteraction.AUTO_EJECT_BUTTON, ((GuiDigitalMiner) element.gui()).tile)), SwitchType.LOWER_ICON)) .setTooltip(MekanismLang.AUTO_EJECT); @@ -87,7 +96,7 @@ protected void addGuiElements() { return energyContainer.getEnergyPerTick() > energyContainer.getEnergy(); }); addRenderableWidget(new GuiVisualsTab(this, tile)); - addRenderableWidget(new GuiSlot(SlotType.DIGITAL, this, 64, 21).setRenderAboveSlots().validity(() -> tile.missingStack) + addRenderableWidget(new GuiSlot(SlotType.DIGITAL, this, missingStackX, 21).setRenderAboveSlots().validity(() -> tile.missingStack) .with(() -> tile.missingStack.isEmpty() ? SlotOverlay.CHECK : null) .hover(element -> ((GuiDigitalMiner) element.gui()).tile.missingStack.isEmpty() ? List.of(MekanismLang.MINER_WELL.translate()) : List.of(MekanismLang.MINER_MISSING_BLOCK.translate()))); addRenderableWidget(new GuiEnergyTab(this, () -> { @@ -128,7 +137,7 @@ private void updateEnabledButtons() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiDigitalMinerConfig.java b/src/main/java/mekanism/client/gui/machine/GuiDigitalMinerConfig.java index 83591762eaa..3eb20136cc5 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiDigitalMinerConfig.java +++ b/src/main/java/mekanism/client/gui/machine/GuiDigitalMinerConfig.java @@ -133,22 +133,11 @@ protected void addGenericTabs() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { super.drawForegroundText(guiGraphics, mouseX, mouseY); - renderTitleText(guiGraphics); - drawScaledTextScaledBound(guiGraphics, MekanismLang.FILTER_COUNT.translate(getFilterManager().count()), 14, 22, screenTextColor(), 76, 0.8F); - drawScaledTextScaledBound(guiGraphics, MekanismLang.MINER_RADIUS.translate(tile.getRadius()), 14, 35, screenTextColor(), 76, 0.8F); - drawScaledTextScaledBound(guiGraphics, MekanismLang.MIN_DIGITAL_MINER.translate(tile.getMinY()), 14, 61, screenTextColor(), 76, 0.8F); - drawScaledTextScaledBound(guiGraphics, MekanismLang.MAX_DIGITAL_MINER.translate(tile.getMaxY()), 14, 88, screenTextColor(), 76, 0.8F); - } - - @Override - public void drawTitleText(GuiGraphics guiGraphics, Component text, float y) { - //Adjust spacing for back button - int leftShift = 11; - int xSize = getXSize() - leftShift; - int maxLength = xSize - 12; - float textWidth = getStringWidth(text); - float scale = Math.min(1, maxLength / textWidth); - drawScaledCenteredText(guiGraphics, text, leftShift + xSize / 2F, y, titleTextColor(), scale); + renderTitleTextWithOffset(guiGraphics, 14);//Adjust spacing for back button + drawScreenText(guiGraphics, MekanismLang.FILTER_COUNT.translate(getFilterManager().count()), 5); + drawScreenText(guiGraphics, MekanismLang.MINER_RADIUS.translate(tile.getRadius()), 18); + drawScreenText(guiGraphics, MekanismLang.MIN_DIGITAL_MINER.translate(tile.getMinY()), 44); + drawScreenText(guiGraphics, MekanismLang.MAX_DIGITAL_MINER.translate(tile.getMaxY()), 71); } @Override diff --git a/src/main/java/mekanism/client/gui/machine/GuiElectricMachine.java b/src/main/java/mekanism/client/gui/machine/GuiElectricMachine.java index a518d3d105c..bbfd2f8548e 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiElectricMachine.java +++ b/src/main/java/mekanism/client/gui/machine/GuiElectricMachine.java @@ -36,7 +36,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiElectricPump.java b/src/main/java/mekanism/client/gui/machine/GuiElectricPump.java index 0ce87fdc0c0..747b471504e 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiElectricPump.java +++ b/src/main/java/mekanism/client/gui/machine/GuiElectricPump.java @@ -26,6 +26,7 @@ public class GuiElectricPump extends GuiMekanismTile container, Inventory inv, Component title) { super(container, inv, title); + titleLabelY = 5; inventoryLabelY += 2; dynamicSlots = true; } @@ -33,7 +34,7 @@ public GuiElectricPump(MekanismTileContainer container, @Override protected void addGuiElements() { super.addGuiElements(); - addRenderableWidget(new GuiInnerScreen(this, 54, 23, 80, 41, () -> { + addRenderableWidget(new GuiInnerScreen(this, 54, 23, 80, 42, () -> { List list = new ArrayList<>(); list.add(EnergyDisplay.of(tile.getEnergyContainer()).getTextComponent()); FluidStack fluidStack = tile.fluidTank.getFluid(); @@ -64,7 +65,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiElectrolyticSeparator.java b/src/main/java/mekanism/client/gui/machine/GuiElectrolyticSeparator.java index 2f7a03c13a0..190e81886b8 100755 --- a/src/main/java/mekanism/client/gui/machine/GuiElectrolyticSeparator.java +++ b/src/main/java/mekanism/client/gui/machine/GuiElectrolyticSeparator.java @@ -2,6 +2,7 @@ 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.button.GuiGasMode; import mekanism.client.gui.element.gauge.GaugeType; @@ -20,6 +21,8 @@ public class GuiElectrolyticSeparator extends GuiConfigurableTile> { + private GuiElement fluidGauge; + public GuiElectrolyticSeparator(MekanismTileContainer container, Inventory inv, Component title) { super(container, inv, title); dynamicSlots = true; @@ -29,7 +32,7 @@ public GuiElectrolyticSeparator(MekanismTileContainer tile.fluidTank, () -> tile.getFluidTanks(null), GaugeType.STANDARD, this, 5, 10)) + fluidGauge = addRenderableWidget(new GuiFluidGauge(() -> tile.fluidTank, () -> tile.getFluidTanks(null), GaugeType.STANDARD, this, 5, 10)) .warning(WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(RecipeError.NOT_ENOUGH_INPUT)); addRenderableWidget(new GuiChemicalGauge(() -> tile.leftTank, () -> tile.getChemicalTanks(null), GaugeType.SMALL, this, 58, 18)) .warning(WarningType.NO_SPACE_IN_OUTPUT, tile.getWarningCheck(TileEntityElectrolyticSeparator.NOT_ENOUGH_SPACE_LEFT_OUTPUT_ERROR)); @@ -46,7 +49,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - renderTitleText(guiGraphics); + renderTitleTextWithOffset(guiGraphics, fluidGauge.getRelativeRight()); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiFactory.java b/src/main/java/mekanism/client/gui/machine/GuiFactory.java index a7d11ea958a..a408b4db6d2 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiFactory.java +++ b/src/main/java/mekanism/client/gui/machine/GuiFactory.java @@ -20,9 +20,13 @@ import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Inventory; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class GuiFactory extends GuiConfigurableTile, MekanismTileContainer>> { + @Nullable + private GuiDumpButton dumpButton; + public GuiFactory(MekanismTileContainer> container, Inventory inv, Component title) { super(container, inv, title); if (tile.hasSecondaryResourceBar()) { @@ -54,7 +58,7 @@ protected void addGuiElements() { addRenderableWidget(new GuiChemicalBar(this, GuiChemicalBar.getProvider(factory.getChemicalTank(), tile.getChemicalTanks(null)), 7, 76, tile.tier == FactoryTier.ULTIMATE ? 172 : 138, 4, true)) .warning(WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(RecipeError.NOT_ENOUGH_SECONDARY_INPUT, 0)); - addRenderableWidget(new GuiDumpButton<>(this, (TileEntityFactory & IHasDumpButton) tile, tile.tier == FactoryTier.ULTIMATE ? 182 : 148, 76)); + dumpButton = addRenderableWidget(new GuiDumpButton<>(this, (TileEntityFactory & IHasDumpButton) tile, tile.tier == FactoryTier.ULTIMATE ? 182 : 148, 76)); } } @@ -72,7 +76,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics, dumpButton == null ? getXSize() : dumpButton.getRelativeX()); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiFluidicPlenisher.java b/src/main/java/mekanism/client/gui/machine/GuiFluidicPlenisher.java index e0555a37d7c..7b73cca9463 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiFluidicPlenisher.java +++ b/src/main/java/mekanism/client/gui/machine/GuiFluidicPlenisher.java @@ -27,6 +27,7 @@ public class GuiFluidicPlenisher extends GuiMekanismTile container, Inventory inv, Component title) { super(container, inv, title); + titleLabelY = 5; inventoryLabelY += 2; dynamicSlots = true; } @@ -34,7 +35,7 @@ public GuiFluidicPlenisher(MekanismTileContainer con @Override protected void addGuiElements() { super.addGuiElements(); - addRenderableWidget(new GuiInnerScreen(this, 54, 23, 80, 41, () -> { + addRenderableWidget(new GuiInnerScreen(this, 54, 23, 80, 42, () -> { List list = new ArrayList<>(); list.add(EnergyDisplay.of(tile.getEnergyContainer()).getTextComponent()); list.add(MekanismLang.FINISHED.translate(YesNo.of(tile.finishedCalc))); @@ -59,7 +60,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiFormulaicAssemblicator.java b/src/main/java/mekanism/client/gui/machine/GuiFormulaicAssemblicator.java index 2f57dcaa238..dc549ad1d60 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiFormulaicAssemblicator.java +++ b/src/main/java/mekanism/client/gui/machine/GuiFormulaicAssemblicator.java @@ -103,7 +103,7 @@ private void updateEnabledButtons() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/machine/GuiFuelwoodHeater.java b/src/main/java/mekanism/client/gui/machine/GuiFuelwoodHeater.java index 41d3be47009..7cceed9853c 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiFuelwoodHeater.java +++ b/src/main/java/mekanism/client/gui/machine/GuiFuelwoodHeater.java @@ -52,7 +52,7 @@ public boolean isActive() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiIsotopicCentrifuge.java b/src/main/java/mekanism/client/gui/machine/GuiIsotopicCentrifuge.java index 21f508aebe8..fd4f843cc54 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiIsotopicCentrifuge.java +++ b/src/main/java/mekanism/client/gui/machine/GuiIsotopicCentrifuge.java @@ -2,6 +2,7 @@ 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.GuiHorizontalPowerBar; import mekanism.client.gui.element.gauge.GaugeType; import mekanism.client.gui.element.gauge.GuiChemicalGauge; @@ -18,6 +19,8 @@ public class GuiIsotopicCentrifuge extends GuiConfigurableTile> { + private GuiElement energyBar; + public GuiIsotopicCentrifuge(MekanismTileContainer container, Inventory inv, Component title) { super(container, inv, title); inventoryLabelY += 2; @@ -28,7 +31,7 @@ public GuiIsotopicCentrifuge(MekanismTileContainer @Override protected void addGuiElements() { super.addGuiElements(); - addRenderableWidget(new GuiHorizontalPowerBar(this, tile.getEnergyContainer(), 115, 75)) + energyBar = addRenderableWidget(new GuiHorizontalPowerBar(this, tile.getEnergyContainer(), 115, 75)) .warning(WarningType.NOT_ENOUGH_ENERGY, tile.getWarningCheck(RecipeError.NOT_ENOUGH_ENERGY)) .warning(WarningType.NOT_ENOUGH_ENERGY_REDUCED_RATE, tile.getWarningCheck(RecipeError.NOT_ENOUGH_ENERGY_REDUCED_RATE)); addRenderableWidget(new GuiEnergyTab(this, tile.getEnergyContainer(), tile::getEnergyUsed)); @@ -43,7 +46,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics, energyBar.getRelativeX()); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } diff --git a/src/main/java/mekanism/client/gui/machine/GuiMetallurgicInfuser.java b/src/main/java/mekanism/client/gui/machine/GuiMetallurgicInfuser.java index b17b1f03132..973cf70cf1f 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiMetallurgicInfuser.java +++ b/src/main/java/mekanism/client/gui/machine/GuiMetallurgicInfuser.java @@ -39,7 +39,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiNutritionalLiquifier.java b/src/main/java/mekanism/client/gui/machine/GuiNutritionalLiquifier.java index 6bc4441752b..ecde8106e70 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiNutritionalLiquifier.java +++ b/src/main/java/mekanism/client/gui/machine/GuiNutritionalLiquifier.java @@ -3,6 +3,7 @@ import mekanism.api.recipes.cache.CachedRecipe.OperationTracker.RecipeError; import mekanism.client.gui.GuiConfigurableTile; import mekanism.client.gui.element.GuiDownArrow; +import mekanism.client.gui.element.GuiElement; import mekanism.client.gui.element.bar.GuiHorizontalPowerBar; import mekanism.client.gui.element.gauge.GaugeType; import mekanism.client.gui.element.gauge.GuiFluidGauge; @@ -19,6 +20,8 @@ public class GuiNutritionalLiquifier extends GuiConfigurableTile> { + private GuiElement energyBar; + public GuiNutritionalLiquifier(MekanismTileContainer container, Inventory inv, Component title) { super(container, inv, title); dynamicSlots = true; @@ -27,7 +30,7 @@ public GuiNutritionalLiquifier(MekanismTileContainer tile.fluidTank, () -> tile.getFluidTanks(null), GaugeType.STANDARD, this, 133, 13)) @@ -40,7 +43,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics, energyBar.getRelativeX()); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } diff --git a/src/main/java/mekanism/client/gui/machine/GuiOredictionificator.java b/src/main/java/mekanism/client/gui/machine/GuiOredictionificator.java index 543b55efeb5..e7ed5f5b6bd 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiOredictionificator.java +++ b/src/main/java/mekanism/client/gui/machine/GuiOredictionificator.java @@ -84,7 +84,7 @@ protected void onClick(IFilter filter, int index) { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/machine/GuiPRC.java b/src/main/java/mekanism/client/gui/machine/GuiPRC.java index 3bebbc87510..3e31e769d04 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiPRC.java +++ b/src/main/java/mekanism/client/gui/machine/GuiPRC.java @@ -22,29 +22,30 @@ public class GuiPRC extends GuiConfigurableTile 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))); - 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) { - float widthThird = imageWidth / 3F; - drawTextScaledBound(guiGraphics, title, widthThird - 7, titleLabelY, titleTextColor(), 2 * widthThird); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderTitleText(guiGraphics); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiPaintingMachine.java b/src/main/java/mekanism/client/gui/machine/GuiPaintingMachine.java index f6186e55e49..cac6e67100d 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiPaintingMachine.java +++ b/src/main/java/mekanism/client/gui/machine/GuiPaintingMachine.java @@ -41,7 +41,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/machine/GuiPigmentExtractor.java b/src/main/java/mekanism/client/gui/machine/GuiPigmentExtractor.java index 1aa92a6f74f..8e140bb8c7b 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiPigmentExtractor.java +++ b/src/main/java/mekanism/client/gui/machine/GuiPigmentExtractor.java @@ -5,6 +5,7 @@ import mekanism.api.recipes.ItemStackToChemicalRecipe; 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.GuiHorizontalPowerBar; import mekanism.client.gui.element.gauge.GaugeType; import mekanism.client.gui.element.gauge.GuiChemicalGauge; @@ -23,6 +24,8 @@ public class GuiPigmentExtractor extends GuiConfigurableTile> { + private GuiElement energyBar; + public GuiPigmentExtractor(MekanismTileContainer container, Inventory inv, Component title) { super(container, inv, title); dynamicSlots = true; @@ -31,7 +34,7 @@ public GuiPigmentExtractor(MekanismTileContainer con @Override protected void addGuiElements() { super.addGuiElements(); - addRenderableWidget(new GuiHorizontalPowerBar(this, tile.getEnergyContainer(), 115, 75)) + energyBar = addRenderableWidget(new GuiHorizontalPowerBar(this, tile.getEnergyContainer(), 115, 75)) .warning(WarningType.NOT_ENOUGH_ENERGY, tile.getWarningCheck(RecipeError.NOT_ENOUGH_ENERGY)); addRenderableWidget(new GuiEnergyTab(this, tile.getEnergyContainer(), tile::getActive)); addRenderableWidget(new GuiChemicalGauge(() -> tile.pigmentTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 131, 13)) @@ -43,7 +46,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics, energyBar.getRelativeX()); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/machine/GuiPigmentMixer.java b/src/main/java/mekanism/client/gui/machine/GuiPigmentMixer.java index a443786b6d6..9d414864202 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiPigmentMixer.java +++ b/src/main/java/mekanism/client/gui/machine/GuiPigmentMixer.java @@ -8,6 +8,7 @@ import mekanism.client.gui.element.bar.GuiHorizontalPowerBar; import mekanism.client.gui.element.gauge.GaugeType; import mekanism.client.gui.element.gauge.GuiChemicalGauge; +import mekanism.client.gui.element.gauge.GuiGauge; import mekanism.client.gui.element.progress.GuiProgress; import mekanism.client.gui.element.progress.GuiProgress.ColorDetails; import mekanism.client.gui.element.progress.ProgressType; @@ -22,10 +23,11 @@ public class GuiPigmentMixer extends GuiConfigurableTile> { + private GuiGauge centerGauge; + public GuiPigmentMixer(MekanismTileContainer container, Inventory inv, Component title) { super(container, inv, title); inventoryLabelY += 2; - titleLabelX = 5; titleLabelY = 5; dynamicSlots = true; } @@ -39,7 +41,7 @@ protected void addGuiElements() { addRenderableWidget(new GuiEnergyTab(this, tile.getEnergyContainer(), tile::getEnergyUsed)); addRenderableWidget(new GuiChemicalGauge(() -> tile.leftInputTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 25, 13)) .warning(WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(RecipeError.NOT_ENOUGH_LEFT_INPUT)); - addRenderableWidget(new GuiChemicalGauge(() -> tile.outputTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 79, 4)) + centerGauge = addRenderableWidget(new GuiChemicalGauge(() -> tile.outputTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 79, 4)) .warning(WarningType.NO_SPACE_IN_OUTPUT, tile.getWarningCheck(RecipeError.NOT_ENOUGH_OUTPUT_SPACE)); addRenderableWidget(new GuiChemicalGauge(() -> tile.rightInputTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 133, 13)) .warning(WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(RecipeError.NOT_ENOUGH_RIGHT_INPUT)); @@ -51,8 +53,8 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - drawString(guiGraphics, title, titleLabelX, titleLabelY, titleTextColor()); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderTitleTextWithOffset(guiGraphics, 1, centerGauge.getRelativeX(), 4, TextAlignment.LEFT); + renderInventoryText(guiGraphics, centerGauge.getRelativeX()); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/machine/GuiPrecisionSawmill.java b/src/main/java/mekanism/client/gui/machine/GuiPrecisionSawmill.java index 9fe6c9d0d9d..200686f4ebd 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiPrecisionSawmill.java +++ b/src/main/java/mekanism/client/gui/machine/GuiPrecisionSawmill.java @@ -42,7 +42,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/machine/GuiResistiveHeater.java b/src/main/java/mekanism/client/gui/machine/GuiResistiveHeater.java index a2cb20fed26..a6a4ed8c2c2 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiResistiveHeater.java +++ b/src/main/java/mekanism/client/gui/machine/GuiResistiveHeater.java @@ -58,7 +58,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/machine/GuiRotaryCondensentrator.java b/src/main/java/mekanism/client/gui/machine/GuiRotaryCondensentrator.java index d6a2ad6b3a1..a854c5088cd 100644 --- a/src/main/java/mekanism/client/gui/machine/GuiRotaryCondensentrator.java +++ b/src/main/java/mekanism/client/gui/machine/GuiRotaryCondensentrator.java @@ -1,8 +1,10 @@ package mekanism.client.gui.machine; import mekanism.api.recipes.cache.CachedRecipe.OperationTracker.RecipeError; +import mekanism.api.text.ILangEntry; import mekanism.client.gui.GuiConfigurableTile; import mekanism.client.gui.element.GuiDownArrow; +import mekanism.client.gui.element.GuiElement; import mekanism.client.gui.element.bar.GuiHorizontalPowerBar; import mekanism.client.gui.element.button.ToggleButton; import mekanism.client.gui.element.gauge.GaugeType; @@ -27,6 +29,8 @@ public class GuiRotaryCondensentrator extends GuiConfigurableTile> { + private GuiElement energyBar; + public GuiRotaryCondensentrator(MekanismTileContainer container, Inventory inv, Component title) { super(container, inv, title); dynamicSlots = true; @@ -37,7 +41,7 @@ public GuiRotaryCondensentrator(MekanismTileContainer getFrequencyType() { public QIOFrequencySelectItemContainer getFrequencyContainer() { return menu; } - - @Override - public void drawTitleText(GuiGraphics guiGraphics, Component text, float y) { - //Adjust spacing for back button - int leftShift = 15; - int xSize = getXSize() - leftShift; - int maxLength = xSize - 12; - float textWidth = getStringWidth(text); - float scale = Math.min(1, maxLength / textWidth); - drawScaledCenteredText(guiGraphics, text, leftShift + xSize / 2F, y, titleTextColor(), scale); - } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/qio/GuiQIOItemViewer.java b/src/main/java/mekanism/client/gui/qio/GuiQIOItemViewer.java index 327eae4e965..c84d81f6ef0 100644 --- a/src/main/java/mekanism/client/gui/qio/GuiQIOItemViewer.java +++ b/src/main/java/mekanism/client/gui/qio/GuiQIOItemViewer.java @@ -48,6 +48,7 @@ public abstract class GuiQIOItemViewer protected final Inventory inv; private GuiTextField searchField; private GuiCraftingWindowTab craftingWindowTab; + private GuiDropdown searchDropdown; private boolean loadPinned = true; protected GuiQIOItemViewer(CONTAINER container, Inventory inv, Component title) { @@ -55,7 +56,7 @@ protected GuiQIOItemViewer(CONTAINER container, Inventory inv, Component title) this.inv = inv; imageWidth = 16 + MekanismConfig.client.qioItemViewerSlotsX.get() * 18 + 18; imageHeight = QIOItemViewerContainer.SLOTS_START_Y + MekanismConfig.client.qioItemViewerSlotsY.get() * 18 + 96; - inventoryLabelY = imageHeight - 94; + inventoryLabelY = imageHeight - 93; titleLabelY = 5; dynamicSlots = true; } @@ -94,7 +95,7 @@ protected void addGuiElements() { } addRenderableWidget(new GuiSlotScroll(this, 7, QIOItemViewerContainer.SLOTS_START_Y, MekanismConfig.client.qioItemViewerSlotsX.get(), slotsY, menu::getQIOItemList, menu)); - addRenderableWidget(new GuiDropdown<>(this, imageWidth - 9 - 54, QIOItemViewerContainer.SLOTS_START_Y + slotsY * 18 + 1, + searchDropdown = addRenderableWidget(new GuiDropdown<>(this, imageWidth - 9 - 54, QIOItemViewerContainer.SLOTS_START_Y + slotsY * 18 + 1, 41, ListSortType.class, menu::getSortType, menu::setSortType)); addRenderableWidget(new GuiDigitalIconToggle<>(this, imageWidth - 9 - 12, QIOItemViewerContainer.SLOTS_START_Y + slotsY * 18 + 1, 12, 12, SortDirection.class, menu::getSortDirection, menu::setSortDirection)); @@ -112,10 +113,8 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); - drawTextScaledBound(guiGraphics, MekanismLang.LIST_SEARCH.translate(), 7, 31, titleTextColor(), 41); - Component text = MekanismLang.LIST_SORT.translate(); - drawString(guiGraphics, text, imageWidth - 66 - getStringWidth(text), imageHeight - 92, titleTextColor()); + renderInventoryTextAndOther(guiGraphics, MekanismLang.LIST_SORT.translate(), imageWidth - searchDropdown.getRelativeX() - 5); + drawScrollingString(guiGraphics, MekanismLang.LIST_SEARCH.translate(), 4, 31, TextAlignment.RIGHT, titleTextColor(), searchField.getRelativeX() - 4, 3, false); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/qio/GuiQIORedstoneAdapter.java b/src/main/java/mekanism/client/gui/qio/GuiQIORedstoneAdapter.java index e3bea34362e..477f5ffccab 100644 --- a/src/main/java/mekanism/client/gui/qio/GuiQIORedstoneAdapter.java +++ b/src/main/java/mekanism/client/gui/qio/GuiQIORedstoneAdapter.java @@ -101,7 +101,7 @@ private void setCount() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { renderTitleText(guiGraphics); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderInventoryText(guiGraphics); renderItem(guiGraphics, tile.getItemType(), 8, 31); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/qio/GuiQIOTileFrequencySelect.java b/src/main/java/mekanism/client/gui/qio/GuiQIOTileFrequencySelect.java index 9d99e45cac2..6df6ba069e9 100644 --- a/src/main/java/mekanism/client/gui/qio/GuiQIOTileFrequencySelect.java +++ b/src/main/java/mekanism/client/gui/qio/GuiQIOTileFrequencySelect.java @@ -43,7 +43,7 @@ protected void addGenericTabs() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - renderTitleText(guiGraphics); + renderTitleTextWithOffset(guiGraphics, 17);//Adjust spacing for back button super.drawForegroundText(guiGraphics, mouseX, mouseY); } @@ -56,15 +56,4 @@ public FrequencyType getFrequencyType() { public TileEntityQIOComponent getTileEntity() { return tile; } - - @Override - public void drawTitleText(GuiGraphics guiGraphics, Component text, float y) { - //Adjust spacing for back button - int leftShift = 15; - int xSize = getXSize() - leftShift; - int maxLength = xSize - 12; - float textWidth = getStringWidth(text); - float scale = Math.min(1, maxLength / textWidth); - drawScaledCenteredText(guiGraphics, text, leftShift + xSize / 2F, y, titleTextColor(), scale); - } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/robit/GuiRobitCrafting.java b/src/main/java/mekanism/client/gui/robit/GuiRobitCrafting.java index 11ee287b647..7a100fb6ae1 100644 --- a/src/main/java/mekanism/client/gui/robit/GuiRobitCrafting.java +++ b/src/main/java/mekanism/client/gui/robit/GuiRobitCrafting.java @@ -23,8 +23,8 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - drawString(guiGraphics, title, titleLabelX, titleLabelY, titleTextColor()); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderTitleText(guiGraphics); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/robit/GuiRobitInventory.java b/src/main/java/mekanism/client/gui/robit/GuiRobitInventory.java index c3a3453a6d7..31aba4bf49a 100644 --- a/src/main/java/mekanism/client/gui/robit/GuiRobitInventory.java +++ b/src/main/java/mekanism/client/gui/robit/GuiRobitInventory.java @@ -16,8 +16,8 @@ public GuiRobitInventory(RobitContainer container, Inventory inv, Component titl @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - drawString(guiGraphics, title, titleLabelX, titleLabelY, titleTextColor()); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderTitleText(guiGraphics); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/robit/GuiRobitMain.java b/src/main/java/mekanism/client/gui/robit/GuiRobitMain.java index ca2dc904f5d..6d31e75fab6 100644 --- a/src/main/java/mekanism/client/gui/robit/GuiRobitMain.java +++ b/src/main/java/mekanism/client/gui/robit/GuiRobitMain.java @@ -1,5 +1,6 @@ package mekanism.client.gui.robit; +import java.util.List; import java.util.function.Supplier; import mekanism.client.SpecialColors; import mekanism.client.gui.GuiMekanism; @@ -26,6 +27,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Tooltip; +import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Inventory; import org.jetbrains.annotations.NotNull; @@ -46,7 +48,6 @@ public GuiRobitMain(MainRobitContainer container, Inventory inv, Component title super(container, inv, title); robit = container.getEntity(); dynamicSlots = true; - titleLabelX = 76; } private void openWindow(GuiWindow window, Supplier elementSupplier) { @@ -60,7 +61,14 @@ protected void addGuiElements() { super.addGuiElements(); addRenderableWidget(new GuiSecurityTab(this, robit, 120)); addRenderableWidget(GuiSideHolder.create(this, imageWidth, 6, 106, false, false, SpecialColors.TAB_ROBIT_MENU)); - addRenderableWidget(new GuiInnerScreen(this, 27, 16, 122, 56)); + addRenderableWidget(new GuiInnerScreen(this, 27, 16, 122, 56, () -> List.of( + MekanismLang.ROBIT_GREETING.translate(robit.getName()), + CommonComponents.EMPTY, + MekanismLang.ENERGY.translate(EnergyDisplay.of(robit.getEnergyContainer().getEnergy())), + MekanismLang.ROBIT_FOLLOWING.translate(robit.getFollowing()), + MekanismLang.ROBIT_DROP_PICKUP.translate(robit.getDropPickup()), + MekanismLang.ROBIT_OWNER.translate(robit.getOwnerName()) + ))).clearFormat().clearSpacing().clearScale().padding(2); addRenderableWidget(new GuiHorizontalPowerBar(this, robit.getEnergyContainer(), 27, 74, 120)); addRenderableWidget(new MekanismImageButton(this, 6, 16, 18, getButtonLocation("home"), (element, mouseX, mouseY) -> { PacketUtils.sendToServer(new PacketGuiInteract(GuiInteractionEntity.GO_HOME, ((GuiRobitMain) element.gui()).robit)); @@ -103,13 +111,7 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - drawString(guiGraphics, title, titleLabelX, titleLabelY, titleTextColor()); - drawTextScaledBound(guiGraphics, MekanismLang.ROBIT_GREETING.translate(robit.getName()), 29, 18, screenTextColor(), 119); - drawTextScaledBound(guiGraphics, MekanismLang.ENERGY.translate(EnergyDisplay.of(robit.getEnergyContainer())), 29, 36 - 4, screenTextColor(), 119); - drawTextScaledBound(guiGraphics, MekanismLang.ROBIT_FOLLOWING.translate(robit.getFollowing()), 29, 45 - 4, screenTextColor(), 119); - drawTextScaledBound(guiGraphics, MekanismLang.ROBIT_DROP_PICKUP.translate(robit.getDropPickup()), 29, 54 - 4, screenTextColor(), 119); - CharSequence owner = robit.getOwnerName().length() > 14 ? robit.getOwnerName().subSequence(0, 14) : robit.getOwnerName(); - drawTextScaledBound(guiGraphics, MekanismLang.ROBIT_OWNER.translate(owner), 29, 63 - 4, screenTextColor(), 119); + renderTitleText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/robit/GuiRobitRepair.java b/src/main/java/mekanism/client/gui/robit/GuiRobitRepair.java index 169a79ae94d..3c53914b9c4 100644 --- a/src/main/java/mekanism/client/gui/robit/GuiRobitRepair.java +++ b/src/main/java/mekanism/client/gui/robit/GuiRobitRepair.java @@ -4,6 +4,7 @@ import mekanism.client.gui.element.text.GuiTextField; import mekanism.common.MekanismLang; import mekanism.common.inventory.container.entity.robit.RepairRobitContainer; +import net.minecraft.Util; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.core.component.DataComponents; @@ -27,12 +28,12 @@ public class GuiRobitRepair extends GuiRobit implements Co private static final ResourceLocation ANVIL_LOCATION = ResourceLocation.withDefaultNamespace("textures/gui/container/anvil.png"); private final Player player; private GuiTextField itemNameField; + private long msDisplayCost; public GuiRobitRepair(RepairRobitContainer container, Inventory inv, Component title) { super(container, inv, title); this.player = inv.player; inventoryLabelY += 1; - titleLabelX = 60; } @Override @@ -78,30 +79,37 @@ public void removed() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - drawString(guiGraphics, title, titleLabelX, titleLabelY, titleTextColor()); + renderTitleTextWithOffset(guiGraphics, itemNameField.getRelativeX(), itemNameField.getRelativeRight() + 4, 0, TextAlignment.CENTER); + renderInventoryText(guiGraphics, 60); int maximumCost = menu.getCost(); if (maximumCost > 0) { - int k = 0x80FF20; + if (msDisplayCost == 0) { + msDisplayCost = Util.getMillis(); + } + int textColor = 0x80FF20; Component component = MekanismLang.REPAIR_COST.translate(maximumCost); if (maximumCost >= 40 && !getMinecraft().player.getAbilities().instabuild) { component = MekanismLang.REPAIR_EXPENSIVE.translate(); - k = 0xFF6060; + textColor = 0xFF6060; } else { Slot slot = menu.getSlot(2); if (!slot.hasItem()) { component = null; + msDisplayCost = 0; } else if (!slot.mayPickup(player)) { - k = 0xFF6060; + textColor = 0xFF6060; } } if (component != null) { - int width = imageWidth - 8 - getStringWidth(component) - 2; - guiGraphics.fill(width - 2, 67, imageWidth - 8, 79, 0x4F000000); - guiGraphics.drawString(getFont(), component, width, 69, k); + int min = Math.max(itemNameField.getRelativeX(), imageWidth - font().width(component) - 10); + int max = imageWidth - 8; + guiGraphics.fill(min, 67, max, 79, 0x4F000000); + drawScrollingString(guiGraphics, component, min, 69, TextAlignment.RIGHT, textColor, max - min, 1, true, msDisplayCost); } + } else { + msDisplayCost = 0; } - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/robit/GuiRobitSmelting.java b/src/main/java/mekanism/client/gui/robit/GuiRobitSmelting.java index 5382a8831fd..eac8eb030db 100644 --- a/src/main/java/mekanism/client/gui/robit/GuiRobitSmelting.java +++ b/src/main/java/mekanism/client/gui/robit/GuiRobitSmelting.java @@ -29,8 +29,8 @@ protected void addGuiElements() { @Override protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { - drawString(guiGraphics, title, titleLabelX, titleLabelY, titleTextColor()); - drawString(guiGraphics, playerInventoryTitle, inventoryLabelX, inventoryLabelY, titleTextColor()); + renderTitleText(guiGraphics); + renderInventoryText(guiGraphics); super.drawForegroundText(guiGraphics, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/recipe_viewer/emi/recipe/ChemicalCrystallizerEmiRecipe.java b/src/main/java/mekanism/client/recipe_viewer/emi/recipe/ChemicalCrystallizerEmiRecipe.java index 7836b199b61..c91356fc753 100644 --- a/src/main/java/mekanism/client/recipe_viewer/emi/recipe/ChemicalCrystallizerEmiRecipe.java +++ b/src/main/java/mekanism/client/recipe_viewer/emi/recipe/ChemicalCrystallizerEmiRecipe.java @@ -5,14 +5,12 @@ import mekanism.api.chemical.ChemicalStack; import mekanism.api.recipes.ChemicalCrystallizerRecipe; import mekanism.api.recipes.ingredients.ChemicalStackIngredient; -import mekanism.client.gui.element.GuiInnerScreen; +import mekanism.client.gui.element.custom.GuiQIOCrystallizerScreen; +import mekanism.client.gui.element.custom.GuiQIOCrystallizerScreen.IOreInfo; import mekanism.client.gui.element.gauge.GaugeType; import mekanism.client.gui.element.gauge.GuiChemicalGauge; import mekanism.client.gui.element.progress.ProgressType; -import mekanism.client.gui.element.slot.GuiSlot; import mekanism.client.gui.element.slot.SlotType; -import mekanism.client.gui.machine.GuiChemicalCrystallizer; -import mekanism.client.gui.machine.GuiChemicalCrystallizer.IOreInfo; import mekanism.client.recipe_viewer.RecipeViewerUtils; import mekanism.client.recipe_viewer.emi.MekanismEmiRecipeCategory; import mekanism.common.inventory.container.slot.SlotOverlay; @@ -35,8 +33,9 @@ public ChemicalCrystallizerEmiRecipe(MekanismEmiRecipeCategory category, RecipeH List inputRepresentations = input.getRepresentations(); displayItems = RecipeViewerUtils.getDisplayItems(input); oreInfo = new IOreInfo() { + @NotNull @Override - public @NotNull ChemicalStack getInputChemical() { + public ChemicalStack getInputChemical() { return inputRepresentations.isEmpty() ? ChemicalStack.EMPTY : RecipeViewerUtils.getCurrent(inputRepresentations); } @@ -50,6 +49,11 @@ public ChemicalCrystallizerRecipe getRecipe() { public ItemStack getRenderStack() { return displayItems.isEmpty() ? ItemStack.EMPTY : RecipeViewerUtils.getCurrent(displayItems); } + + @Override + public boolean usesSequencedDisplay() { + return false; + } }; } @@ -60,8 +64,7 @@ public void addWidgets(WidgetHolder widgetHolder) { addSlot(widgetHolder, SlotType.INPUT, 8, 65).with(SlotOverlay.PLUS); addSlot(widgetHolder, SlotType.OUTPUT, 129, 57, output(0)).recipeContext(this); addSimpleProgress(widgetHolder, ProgressType.LARGE_RIGHT, 53, 61, TileEntityChemicalCrystallizer.BASE_TICKS_REQUIRED); - addElement(widgetHolder, new GuiInnerScreen(this, 31, 13, 115, 42, () -> GuiChemicalCrystallizer.getScreenRenderStrings(this.oreInfo))); - GuiSlot slurryOreSlot = addElement(widgetHolder, new GuiSlot(SlotType.ORE, this, 128, 13).setRenderAboveSlots()); - initItem(widgetHolder, slurryOreSlot.getX(), slurryOreSlot.getY(), ingredient(displayItems)); + GuiQIOCrystallizerScreen screen = addElement(widgetHolder, new GuiQIOCrystallizerScreen(this, 31, 13, 115, 42, oreInfo)); + initItem(widgetHolder, screen.getSlotX(), screen.getSlotY(), ingredient(displayItems)); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/recipe_viewer/emi/recipe/FluidToFluidEmiRecipe.java b/src/main/java/mekanism/client/recipe_viewer/emi/recipe/FluidToFluidEmiRecipe.java index aabc84dc30f..8e959fd0632 100644 --- a/src/main/java/mekanism/client/recipe_viewer/emi/recipe/FluidToFluidEmiRecipe.java +++ b/src/main/java/mekanism/client/recipe_viewer/emi/recipe/FluidToFluidEmiRecipe.java @@ -28,19 +28,20 @@ public FluidToFluidEmiRecipe(MekanismEmiRecipeCategory category, RecipeHolder List.of( + //Note: All these elements except for the inputs are in slightly different x positions than in the normal GUI so that they fit properly in emi + addElement(widgetHolder, new GuiInnerScreen(this, 48, 19, 86, 40, () -> List.of( MekanismLang.MULTIBLOCK_FORMED.translate(), MekanismLang.EVAPORATION_HEIGHT.translate(EvaporationMultiblockData.MAX_HEIGHT), MekanismLang.TEMPERATURE.translate(MekanismUtils.getTemperatureDisplay(HeatAPI.AMBIENT_TEMP, TemperatureUnit.KELVIN, true)), MekanismLang.FLUID_PRODUCTION.translate(0.0)) - ).spacing(1)); + ).padding(3).clearSpacing()); addElement(widgetHolder, new GuiDownArrow(this, 32, 39)); - addElement(widgetHolder, new GuiDownArrow(this, 136, 39)); - addElement(widgetHolder, new GuiHorizontalRateBar(this, RecipeViewerUtils.FULL_BAR, 48, 63)); + addElement(widgetHolder, new GuiDownArrow(this, 142, 39)); + addElement(widgetHolder, new GuiHorizontalRateBar(this, RecipeViewerUtils.FULL_BAR, 51, 63)); addSlot(widgetHolder, SlotType.INPUT, 28, 20); addSlot(widgetHolder, SlotType.OUTPUT, 28, 51); - addSlot(widgetHolder, SlotType.INPUT, 132, 20); - addSlot(widgetHolder, SlotType.OUTPUT, 132, 51); + addSlot(widgetHolder, SlotType.INPUT, 138, 20); + addSlot(widgetHolder, SlotType.OUTPUT, 138, 51); initTank(widgetHolder, GuiFluidGauge.getDummy(GaugeType.STANDARD, this, 6, 13), input(0)); - initTank(widgetHolder, GuiFluidGauge.getDummy(GaugeType.STANDARD, this, 152, 13), output(0)).recipeContext(this); + initTank(widgetHolder, GuiFluidGauge.getDummy(GaugeType.STANDARD, this, 158, 13), output(0)).recipeContext(this); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/recipe_viewer/emi/recipe/MekanismEmiRecipe.java b/src/main/java/mekanism/client/recipe_viewer/emi/recipe/MekanismEmiRecipe.java index 00974a54946..1224b148c3c 100644 --- a/src/main/java/mekanism/client/recipe_viewer/emi/recipe/MekanismEmiRecipe.java +++ b/src/main/java/mekanism/client/recipe_viewer/emi/recipe/MekanismEmiRecipe.java @@ -12,7 +12,6 @@ import java.util.List; import java.util.function.Supplier; import mekanism.api.annotations.NothingNullByDefault; -import mekanism.api.chemical.Chemical; import mekanism.api.chemical.ChemicalStack; import mekanism.api.recipes.ingredients.ChemicalStackIngredient; import mekanism.api.recipes.ingredients.FluidStackIngredient; @@ -28,8 +27,6 @@ import mekanism.client.recipe_viewer.emi.MekanismEmiRecipeCategory; import mekanism.client.recipe_viewer.emi.widget.MekanismEmiWidget; import mekanism.client.recipe_viewer.emi.widget.MekanismTankEmiWidget; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.events.AbstractContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.resources.ResourceLocation; @@ -188,11 +185,6 @@ public RecipeHolder getBackingRecipe() { return null; } - @Override - public Font getFont() { - return Minecraft.getInstance().font; - } - @Override public List children() { //TODO: I believe returning empty for this is fine for now, though we could potentially gather the children and then diff --git a/src/main/java/mekanism/client/recipe_viewer/emi/recipe/PressurizedReactionEmiRecipe.java b/src/main/java/mekanism/client/recipe_viewer/emi/recipe/PressurizedReactionEmiRecipe.java index 90e3514abca..230e8ed7a59 100644 --- a/src/main/java/mekanism/client/recipe_viewer/emi/recipe/PressurizedReactionEmiRecipe.java +++ b/src/main/java/mekanism/client/recipe_viewer/emi/recipe/PressurizedReactionEmiRecipe.java @@ -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()); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/recipe_viewer/jei/BaseRecipeCategory.java b/src/main/java/mekanism/client/recipe_viewer/jei/BaseRecipeCategory.java index 009668fe460..93a4f2b8412 100644 --- a/src/main/java/mekanism/client/recipe_viewer/jei/BaseRecipeCategory.java +++ b/src/main/java/mekanism/client/recipe_viewer/jei/BaseRecipeCategory.java @@ -37,8 +37,6 @@ import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.SharedConstants; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.AbstractContainerEventHandler; import net.minecraft.client.gui.navigation.ScreenRectangle; @@ -186,7 +184,9 @@ protected void renderElements(RECIPE recipe, IRecipeSlotsView recipeSlotsView, G } //Note: We don't care that onRenderForeground updates the maxZOffset in the mekanism gui as that is just used for rendering windows // and as our categories don't support windows we don't need to worry about that - int zOffset = 200; + //TODO: Re-evaluate this zOffset. We use 200 in GuiMekanism, but at least in JEI everything seems to render fine using zero. + // When using 200 the crystallizer screen's ore type slot ends up rendering in front of JEI's item rendering, so for now we are just setting this to zero + int zOffset = 0;//200; for (GuiElement element : guiElements) { pose.pushPose(); element.onRenderForeground(guiGraphics, x, y, zOffset, zOffset); @@ -194,11 +194,6 @@ protected void renderElements(RECIPE recipe, IRecipeSlotsView recipeSlotsView, G } } - @Override - public Font getFont() { - return Minecraft.getInstance().font; - } - @Override public IDrawable getBackground() { return background; diff --git a/src/main/java/mekanism/client/recipe_viewer/jei/machine/ChemicalCrystallizerRecipeCategory.java b/src/main/java/mekanism/client/recipe_viewer/jei/machine/ChemicalCrystallizerRecipeCategory.java index d784de72f84..10e3dbc20c4 100644 --- a/src/main/java/mekanism/client/recipe_viewer/jei/machine/ChemicalCrystallizerRecipeCategory.java +++ b/src/main/java/mekanism/client/recipe_viewer/jei/machine/ChemicalCrystallizerRecipeCategory.java @@ -4,15 +4,14 @@ import mekanism.api.chemical.ChemicalStack; import mekanism.api.recipes.ChemicalCrystallizerRecipe; import mekanism.api.recipes.ingredients.ChemicalStackIngredient; -import mekanism.client.gui.element.GuiInnerScreen; +import mekanism.client.gui.element.custom.GuiQIOCrystallizerScreen; +import mekanism.client.gui.element.custom.GuiQIOCrystallizerScreen.IOreInfo; import mekanism.client.gui.element.gauge.GaugeType; import mekanism.client.gui.element.gauge.GuiChemicalGauge; import mekanism.client.gui.element.gauge.GuiGauge; import mekanism.client.gui.element.progress.ProgressType; import mekanism.client.gui.element.slot.GuiSlot; import mekanism.client.gui.element.slot.SlotType; -import mekanism.client.gui.machine.GuiChemicalCrystallizer; -import mekanism.client.gui.machine.GuiChemicalCrystallizer.IOreInfo; import mekanism.client.recipe_viewer.RecipeViewerUtils; import mekanism.client.recipe_viewer.jei.HolderRecipeCategory; import mekanism.client.recipe_viewer.type.IRecipeViewerRecipeType; @@ -40,7 +39,7 @@ public class ChemicalCrystallizerRecipeCategory extends HolderRecipeCategory gauge; private final GuiSlot output; - private final GuiSlot slurryOreSlot; + private final GuiQIOCrystallizerScreen screen; public ChemicalCrystallizerRecipeCategory(IGuiHelper helper, IRecipeViewerRecipeType recipeType) { super(helper, recipeType); @@ -49,8 +48,7 @@ public ChemicalCrystallizerRecipeCategory(IGuiHelper helper, IRecipeViewerRecipe addSlot(SlotType.INPUT, 8, 65).with(SlotOverlay.PLUS); output = addSlot(SlotType.OUTPUT, 129, 57); addSimpleProgress(ProgressType.LARGE_RIGHT, 53, 61); - addElement(new GuiInnerScreen(this, 31, 13, 115, 42, () -> GuiChemicalCrystallizer.getScreenRenderStrings(this.oreInfo))); - slurryOreSlot = addElement(new GuiSlot(SlotType.ORE, this, 128, 13).setRenderAboveSlots()); + screen = addElement(new GuiQIOCrystallizerScreen(this, 31, 13, 115, 42, oreInfo)); } @Override @@ -78,7 +76,7 @@ public void setRecipe(@NotNull IRecipeLayoutBuilder builder, RecipeHolder displayItems = RecipeViewerUtils.getDisplayItems(input); if (!displayItems.isEmpty()) { - initItem(builder, RecipeIngredientRole.RENDER_ONLY, slurryOreSlot, displayItems).setSlotName(DISPLAYED_ITEM); + initItem(builder, RecipeIngredientRole.RENDER_ONLY, screen.getSlotX(), screen.getSlotY(), displayItems).setSlotName(DISPLAYED_ITEM); } } @@ -90,8 +88,9 @@ private static class OreInfo implements IOreInfo { private ChemicalStack ingredient; private ItemStack itemIngredient = ItemStack.EMPTY; + @NotNull @Override - public @NotNull ChemicalStack getInputChemical() { + public ChemicalStack getInputChemical() { if (ingredient == null || ingredient.isEmpty()) { return ChemicalStack.EMPTY; } @@ -109,5 +108,10 @@ public ChemicalCrystallizerRecipe getRecipe() { public ItemStack getRenderStack() { return itemIngredient; } + + @Override + public boolean usesSequencedDisplay() { + return false; + } } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/recipe_viewer/jei/machine/FluidToFluidRecipeCategory.java b/src/main/java/mekanism/client/recipe_viewer/jei/machine/FluidToFluidRecipeCategory.java index ecd0d13d24f..564be9b99e1 100644 --- a/src/main/java/mekanism/client/recipe_viewer/jei/machine/FluidToFluidRecipeCategory.java +++ b/src/main/java/mekanism/client/recipe_viewer/jei/machine/FluidToFluidRecipeCategory.java @@ -31,20 +31,21 @@ public class FluidToFluidRecipeCategory extends HolderRecipeCategory recipeType) { super(helper, recipeType); - addElement(new GuiInnerScreen(this, 48, 19, 80, 40, () -> List.of( + //Note: All these elements except for the inputs are in slightly different x positions than in the normal GUI so that they fit properly in JEI + addElement(new GuiInnerScreen(this, 48, 19, 86, 40, () -> List.of( MekanismLang.MULTIBLOCK_FORMED.translate(), MekanismLang.EVAPORATION_HEIGHT.translate(EvaporationMultiblockData.MAX_HEIGHT), MekanismLang.TEMPERATURE.translate(MekanismUtils.getTemperatureDisplay(HeatAPI.AMBIENT_TEMP, TemperatureUnit.KELVIN, true)), MekanismLang.FLUID_PRODUCTION.translate(0.0)) - ).spacing(1)); + ).padding(3).clearSpacing()); addElement(new GuiDownArrow(this, 32, 39)); - addElement(new GuiDownArrow(this, 136, 39)); - addElement(new GuiHorizontalRateBar(this, RecipeViewerUtils.FULL_BAR, 48, 63)); + addElement(new GuiDownArrow(this, 142, 39)); + addElement(new GuiHorizontalRateBar(this, RecipeViewerUtils.FULL_BAR, 51, 63)); addSlot(SlotType.INPUT, 28, 20); addSlot(SlotType.OUTPUT, 28, 51); - addSlot(SlotType.INPUT, 132, 20); - addSlot(SlotType.OUTPUT, 132, 51); + addSlot(SlotType.INPUT, 138, 20); + addSlot(SlotType.OUTPUT, 138, 51); input = addElement(GuiFluidGauge.getDummy(GaugeType.STANDARD, this, 6, 13)); - output = addElement(GuiFluidGauge.getDummy(GaugeType.STANDARD, this, 152, 13)); + output = addElement(GuiFluidGauge.getDummy(GaugeType.STANDARD, this, 158, 13)); } @Override diff --git a/src/main/java/mekanism/client/recipe_viewer/jei/machine/PressurizedReactionRecipeCategory.java b/src/main/java/mekanism/client/recipe_viewer/jei/machine/PressurizedReactionRecipeCategory.java index 65d816aab7e..b003bd72dd3 100644 --- a/src/main/java/mekanism/client/recipe_viewer/jei/machine/PressurizedReactionRecipeCategory.java +++ b/src/main/java/mekanism/client/recipe_viewer/jei/machine/PressurizedReactionRecipeCategory.java @@ -41,16 +41,16 @@ public class PressurizedReactionRecipeCategory extends HolderRecipeCategory 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 diff --git a/src/main/java/mekanism/client/recipe_viewer/jei/machine/SawmillRecipeCategory.java b/src/main/java/mekanism/client/recipe_viewer/jei/machine/SawmillRecipeCategory.java index cc92ab873b3..c3abffdb365 100644 --- a/src/main/java/mekanism/client/recipe_viewer/jei/machine/SawmillRecipeCategory.java +++ b/src/main/java/mekanism/client/recipe_viewer/jei/machine/SawmillRecipeCategory.java @@ -1,7 +1,7 @@ package mekanism.client.recipe_viewer.jei.machine; +import com.mojang.blaze3d.vertex.PoseStack; import mekanism.api.recipes.SawmillRecipe; -import mekanism.client.SpecialColors; import mekanism.client.gui.element.GuiUpArrow; import mekanism.client.gui.element.bar.GuiVerticalPowerBar; import mekanism.client.gui.element.progress.ProgressType; @@ -49,7 +49,14 @@ public void draw(RecipeHolder recipeHolder, IRecipeSlotsView reci super.draw(recipeHolder, recipeSlotView, guiGraphics, mouseX, mouseY); double secondaryChance = recipeHolder.value().getSecondaryChance(); if (secondaryChance > 0) { - guiGraphics.drawString(getFont(), TextUtils.getPercent(secondaryChance), 104, 41, SpecialColors.TEXT_TITLE.argb(), false); + //Perform the same translations as super does + //TODO: Figure out how to replace this with using JEI's newer widget system + PoseStack pose = guiGraphics.pose(); + pose.pushPose(); + pose.translate(getGuiLeft(), getGuiTop(), 0); + drawScrollingString(guiGraphics, TextUtils.getPercent(secondaryChance), output.getRelativeX(), output.getRelativeBottom() + 1, TextAlignment.RIGHT, + titleTextColor(), output.getWidth(), 1, false); + pose.popPose(); } } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/recipe_viewer/type/RecipeViewerRecipeType.java b/src/main/java/mekanism/client/recipe_viewer/type/RecipeViewerRecipeType.java index c397d3c71cc..9908cbe1aa6 100644 --- a/src/main/java/mekanism/client/recipe_viewer/type/RecipeViewerRecipeType.java +++ b/src/main/java/mekanism/client/recipe_viewer/type/RecipeViewerRecipeType.java @@ -54,7 +54,7 @@ private RecipeViewerRecipeType() { public static final RVRecipeTypeWrapper WASHING = new RVRecipeTypeWrapper<>(MekanismRecipeType.WASHING, FluidChemicalToChemicalRecipe.class, -7, -13, 162, 60, MekanismBlocks.CHEMICAL_WASHER); - public static final RVRecipeTypeWrapper EVAPORATING = new RVRecipeTypeWrapper<>(MekanismRecipeType.EVAPORATING, FluidToFluidRecipe.class, -3, -12, 170, 62, MekanismBlocks.THERMAL_EVAPORATION_CONTROLLER, MekanismBlocks.THERMAL_EVAPORATION_VALVE, MekanismBlocks.THERMAL_EVAPORATION_BLOCK); + public static final RVRecipeTypeWrapper EVAPORATING = new RVRecipeTypeWrapper<>(MekanismRecipeType.EVAPORATING, FluidToFluidRecipe.class, -3, -12, 176, 62, MekanismBlocks.THERMAL_EVAPORATION_CONTROLLER, MekanismBlocks.THERMAL_EVAPORATION_VALVE, MekanismBlocks.THERMAL_EVAPORATION_BLOCK); public static final RVRecipeTypeWrapper ACTIVATING = new RVRecipeTypeWrapper<>(MekanismRecipeType.ACTIVATING, ChemicalToChemicalRecipe.class, -4, -13, 168, 60, MekanismBlocks.SOLAR_NEUTRON_ACTIVATOR); public static final RVRecipeTypeWrapper CENTRIFUGING = new RVRecipeTypeWrapper<>(MekanismRecipeType.CENTRIFUGING, ChemicalToChemicalRecipe.class, -4, -13, 168, 60, MekanismBlocks.ISOTOPIC_CENTRIFUGE); @@ -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 REACTION = new RVRecipeTypeWrapper<>(MekanismRecipeType.REACTION, PressurizedReactionRecipe.class, -3, -10, 170, 60, MekanismBlocks.PRESSURIZED_REACTION_CHAMBER); + public static final RVRecipeTypeWrapper 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); diff --git a/src/main/java/mekanism/client/recipe_viewer/type/VanillaRVRecipeType.java b/src/main/java/mekanism/client/recipe_viewer/type/VanillaRVRecipeType.java index 6037757a4cb..3b99054ef39 100644 --- a/src/main/java/mekanism/client/recipe_viewer/type/VanillaRVRecipeType.java +++ b/src/main/java/mekanism/client/recipe_viewer/type/VanillaRVRecipeType.java @@ -4,6 +4,7 @@ import java.util.Objects; import mekanism.api.annotations.NothingNullByDefault; import mekanism.api.providers.IItemProvider; +import mekanism.api.text.TextComponentUtil; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -25,7 +26,7 @@ public VanillaRVRecipeType(RecipeType vanillaType, Class areaWidth; + //Note: Instead of doing what vanilla does, we divide to float, and don't add one + // That way if min and max are not just lineHeight away they will be more accurate, and otherwise it won't render one line below where it should be + float targetY = (minY + maxY - font.lineHeight) / 2F; + float targetX; + if (isScrolling) { + targetX = prepScrollingString(graphics, font, textWidth, areaWidth, minX, minY, maxX, maxY, Util.getMillis() - msVisible); + } else { + targetX = alignment.getTarget(font, minX, maxX, textWidth); + } + graphics.drawString(font, text.getVisualOrderText(), targetX, targetY, color, shadow); + if (isScrolling) { + graphics.disableScissor(); + } } - default void drawTextExact(GuiGraphics guiGraphics, Component text, float x, float y, int color) { - PoseStack pose = guiGraphics.pose(); - pose.pushPose(); - pose.translate(x, y, 0); - drawString(guiGraphics, text, 0, 0, color); - pose.popPose(); + default void drawScaledScrollingString(GuiGraphics graphics, Component text, int x, int y, TextAlignment alignment, int color, int maxLengthPad, boolean shadow, + float scale) { + drawScaledScrollingString(graphics, text, x, y, alignment, color, maxLengthPad, shadow, scale, getTimeOpened()); } - default float getNeededScale(Component text, float maxLength) { - int length = getStringWidth(text); - return length <= maxLength ? 1 : maxLength / length; + default void drawScaledScrollingString(GuiGraphics graphics, Component text, int x, int y, TextAlignment alignment, int color, int maxLengthPad, boolean shadow, + float scale, long msVisible) { + drawScaledScrollingString(graphics, text, x, y, alignment, color, getXSize(), maxLengthPad, shadow, scale, msVisible); } - default void drawTextScaledBound(GuiGraphics guiGraphics, String text, float x, float y, int color, float maxLength) { - drawTextScaledBound(guiGraphics, TextComponentUtil.getString(text), x, y, color, maxLength); + default void drawScaledScrollingString(GuiGraphics graphics, Component text, int x, int y, TextAlignment alignment, int color, int width, int maxLengthPad, + boolean shadow, float scale) { + drawScaledScrollingString(graphics, text, x, y, alignment, color, width, maxLengthPad, shadow, scale, getTimeOpened()); } - default void drawTextScaledBound(GuiGraphics guiGraphics, Component component, float x, float y, int color, float maxLength) { - int length = getStringWidth(component); - if (length <= maxLength) { - drawTextExact(guiGraphics, component, x, y, color); + default void drawScaledScrollingString(GuiGraphics graphics, Component text, int x, int y, TextAlignment alignment, int color, int width, int maxLengthPad, + boolean shadow, float scale, long msVisible) { + drawScaledScrollingString(graphics, text, x, y, alignment, color, width, font().lineHeight, maxLengthPad, shadow, scale, msVisible); + } + + default void drawScaledScrollingString(GuiGraphics graphics, Component text, int x, int y, TextAlignment alignment, int color, int width, int height, int maxLengthPad, + boolean shadow, float scale, long msVisible) { + drawScaledScrollingString(graphics, text, x + maxLengthPad, y, x + width - maxLengthPad, y + height, alignment, color, shadow, scale, msVisible); + } + + default void drawScaledScrollingString(GuiGraphics graphics, Component text, int minX, int minY, int maxX, int maxY, TextAlignment alignment, int color, boolean shadow, + float scale, long msVisible) { + if (scale == 1.0F) { + drawScrollingString(graphics, text, minX, minY, maxX, maxY, alignment, color, shadow, msVisible); + return; + } + Font font = font(); + float textWidth = font.width(text) * scale; + int areaWidth = maxX - minX; + boolean isScrolling = textWidth > areaWidth; + //Note: Instead of doing what vanilla does, we divide to float, and don't add one + // That way if min and max are not just lineHeight away they will be more accurate, and otherwise it won't render one line below where it should be + float targetY = (minY + maxY - font.lineHeight) / 2F; + float targetX; + if (isScrolling) { + targetX = prepScrollingString(graphics, font, textWidth, areaWidth, minX, minY, maxX, maxY, Util.getMillis() - msVisible); } else { - drawTextWithScale(guiGraphics, component, x, y, color, maxLength / length); + targetX = alignment.getTarget(font, minX, maxX, textWidth); + } + PoseStack pose = prepTextScale(graphics, font, targetX, targetY, scale); + graphics.drawString(font, text, 0, 0, color, shadow); + pose.popPose(); + if (isScrolling) { + graphics.disableScissor(); } } - default void drawScaledTextScaledBound(GuiGraphics guiGraphics, Component text, float x, float y, int color, float maxX, float textScale) { - float width = getStringWidth(text) * textScale; - float scale = Math.min(1, maxX / width) * textScale; - drawTextWithScale(guiGraphics, text, x, y, color, scale); + /** + * Based off the logic for calculating the scissor area and draw target that vanilla does in + * {@link AbstractWidget#renderScrollingString(GuiGraphics, Font, Component, int, int, int, int, int, int)} + * + * @param visibleDuration Time in ms that this string has been visible for. + * + * @apiNote Call {@link GuiGraphics#disableScissor()} after using this method + */ + private static float prepScrollingString(GuiGraphics graphics, Font font, double textWidth, int areaWidth, int minX, int minY, int maxX, int maxY, long visibleDuration) { + //Note: We are drawing in relative coordinates, but GuiGraphics#enableScissor, is expecting absolute coordinates, + // so we need to get the translations from our pose stack + //Note: This is equivalent to what Matrix4f#getTranslation(Vector3f) would do, without all the extra allocations. + Matrix4f matrix4f = graphics.pose().last().pose(); + int left = (int) matrix4f.m30(); + int top = (int) matrix4f.m31(); + graphics.enableScissor(left + minX, top + minY, left + maxX, top + maxY); + //TODO: Re-evaluate this, as for text (especially scaled text) when moving very slowly near the edges, it makes the text a bit blurry + // Though maybe it is better to just make it not move so insanely slowly near the edges + //Note: Vanilla casts overflowedBy to an int, as it only bothers drawing based on int pixels. + // As we already handle and calculates with floats, casting to a float here provides a much smoother looking scroll + return minX - (float) getOverflowedBy(font, textWidth - areaWidth, visibleDuration); } - default void drawTextWithScale(GuiGraphics guiGraphics, Component text, float x, float y, int color, float scale) { - PoseStack pose = prepTextScale(guiGraphics, x, y, scale); - drawString(guiGraphics, text, 0, 0, color); - pose.popPose(); + private static double getOverflowedBy(Font font, double overflowWidth, long visibleDuration) { + //Seconds since the gui was opened + double seconds = visibleDuration / 1_000D; + double scrollPeriod = Math.max(overflowWidth * AbstractWidget.PERIOD_PER_SCROLLED_PIXEL, AbstractWidget.MIN_SCROLL_PERIOD); + //Controls the speed at which we go between the start of the scroll and the end + double scrollSpeedModifier = Math.cos((2 * Math.PI) * seconds / scrollPeriod); + if (!font.isBidirectional()) { + //If the text is left to right (such as english). We need to start the modifier at the opposite peak so that it starts + // at the beginning of the string + //Note: Mojang doesn't include this negative for rendering text in english, but that is because they just use the current ms + // for the seconds calculation, which means that they don't care where in the wave they start + scrollSpeedModifier = -scrollSpeedModifier; + } + //TODO: Do we want to improve this in some way or another, as it moves very slowly at the edges, and much quicker in the middle + // Potentially replace this with a sigmoid function? + // It is particularly slow when there is a large amount of overflow + //Shift it so that the range is from [0, 1] + double scrolledSoFar = Math.sin((Math.PI / 2) * scrollSpeedModifier) / 2.0 + 0.5; + //Vanilla uses: Mth.lerp(scrolledSoFar, 0.0, overflowWidth); to calculate overflowedBy. But that is equivalent to just performing the following multiplication + return scrolledSoFar * overflowWidth; } - private PoseStack prepTextScale(GuiGraphics guiGraphics, float x, float y, float scale) { - float yAdd = 4 - (scale * 8) / 2F; - PoseStack pose = guiGraphics.pose(); + //Note: As translate will implicitly cast x and y to being floats, we might as well pass these in as floats to reduce duplicate code + private static PoseStack prepTextScale(GuiGraphics graphics, Font font, float x, float y, float scale) { + PoseStack pose = graphics.pose(); pose.pushPose(); + float halfLineHeight = font.lineHeight / 2F; + float yAdd = halfLineHeight - halfLineHeight * scale; pose.translate(x, y + yAdd, 0); pose.scale(scale, scale, scale); return pose; } - /** - * @apiNote Consider caching the {@link WrappedTextRenderer} instead of using this method. - */ - default int drawWrappedTextWithScale(GuiGraphics guiGraphics, Component text, float x, float y, int color, float maxLength, float scale) { - return new WrappedTextRenderer(this, text).renderWithScale(guiGraphics, x, y, color, maxLength, scale); - } - - /** - * @apiNote Consider caching the {@link WrappedTextRenderer} instead of using this method. - */ - default void drawWrappedCenteredText(GuiGraphics guiGraphics, Component text, float x, float y, int color, float maxLength) { - new WrappedTextRenderer(this, text).renderCentered(guiGraphics, x, y, color, maxLength); + enum TextAlignment { + LEFT, + CENTER, + RIGHT, + /** + * Represents that for left to right languages this will be left aligned, and for right to left it will be right aligned. + */ + RELATIVE;//TODO: Make use of this in various spots that make sense + + public float getTarget(Font font, int minX, int maxX, float textWidth) { + return switch (this) { + case LEFT -> minX; + case CENTER -> minX + ((maxX - minX) - textWidth) / 2F; + case RIGHT -> maxX - textWidth; + case RELATIVE -> font.isBidirectional() ? maxX - textWidth : minX; + }; + } } - // efficient tool to draw word-by-word wrapped text based on a horizontal bound. looks intimidating but runs in O(n) class WrappedTextRenderer { - private final List linesToDraw = new ArrayList<>(); - private final IFancyFontRenderer font; - private final String text; + private final Component text; + private List linesToDraw = Collections.emptyList(); + + IFancyFontRenderer fontRenderer; @Nullable private Font lastFont; - private float lastMaxLength = -1; - private float lineLength = 0; + private int lastMaxLength = -1; - public WrappedTextRenderer(IFancyFontRenderer font, Component text) { - this(font, text.getString()); + public WrappedTextRenderer(IFancyFontRenderer fontRenderer, Component text) { + this.fontRenderer = fontRenderer; + this.text = text; } - public WrappedTextRenderer(IFancyFontRenderer font, String text) { - this.font = font; - this.text = text; + public void render(GuiGraphics graphics, int x, int y, int maxLength, TextAlignment alignment, int color) { + render(graphics, x, y, maxLength, alignment, color, 1); } - public void renderCentered(GuiGraphics guiGraphics, float x, float y, int color, float maxLength) { - calculateLines(maxLength); - float startY = y; - for (LineData line : linesToDraw) { - font.drawTextExact(guiGraphics, line.component(), x - line.length() / 2, startY, color); - startY += 9; - } + public int renderWithScale(GuiGraphics graphics, int x, int y, TextAlignment alignment, int color, int maxLength, float scale) { + PoseStack pose = prepTextScale(graphics, fontRenderer.font(), x, y, scale); + render(graphics, 0, 0, maxLength, alignment, color, scale); + pose.popPose(); + return linesToDraw.size(); } - public int renderWithScale(GuiGraphics guiGraphics, float x, float y, int color, float maxLength, float scale) { + private void render(GuiGraphics graphics, int x, int startY, int maxLength, TextAlignment alignment, int color, float scale) { + Font font = fontRenderer.font(); //Divide by scale for calculating actual max length so that when the text is scaled it has the proper total space available - calculateLines(maxLength / scale); - PoseStack pose = font.prepTextScale(guiGraphics, x, y, scale); - int startY = 0; - for (LineData line : linesToDraw) { - font.drawString(guiGraphics, line.component(), 0, startY, color); - startY += 9; + calculateLines(font, scale == 1 ? maxLength : Mth.floor(maxLength / scale)); + int maxX = x + maxLength; + for (FormattedCharSequence line : linesToDraw) { + graphics.drawString(font, line, alignment.getTarget(font, x, maxX, scale * font.width(line)), startY, color, false); + startY += font.lineHeight; } - pose.popPose(); - return linesToDraw.size(); } - void calculateLines(float maxLength) { + private void calculateLines(Font font, int maxLength) { //If something changed since the last time we calculated it - Font font = this.font.getFont(); if (font != null && (lastFont != font || lastMaxLength != maxLength)) { lastFont = font; lastMaxLength = maxLength; - linesToDraw.clear(); - StringBuilder lineBuilder = new StringBuilder(); - StringBuilder wordBuilder = new StringBuilder(); - int spaceLength = lastFont.width(" "); - int wordLength = 0; - for (char c : text.toCharArray()) { - if (c == ' ') { - lineBuilder = addWord(lineBuilder, wordBuilder, maxLength, spaceLength, wordLength); - wordBuilder = new StringBuilder(); - wordLength = 0; - continue; - } - wordBuilder.append(c); - wordLength += lastFont.width(Character.toString(c)); - } - if (!wordBuilder.isEmpty()) { - lineBuilder = addWord(lineBuilder, wordBuilder, maxLength, spaceLength, wordLength); - } - if (!lineBuilder.isEmpty()) { - linesToDraw.add(new LineData(TextComponentUtil.getString(lineBuilder.toString()), lineLength)); - } + linesToDraw = font.split(text, maxLength); } } - StringBuilder addWord(StringBuilder lineBuilder, StringBuilder wordBuilder, float maxLength, int spaceLength, int wordLength) { - // ignore spacing if this is the first word of the line - float spacingLength = lineBuilder.isEmpty() ? 0 : spaceLength; - if (lineLength + spacingLength + wordLength > maxLength) { - linesToDraw.add(new LineData(TextComponentUtil.getString(lineBuilder.toString()), lineLength)); - lineBuilder = new StringBuilder(wordBuilder); - lineLength = wordLength; - } else { - if (spacingLength > 0) { - lineBuilder.append(" "); - } - lineBuilder.append(wordBuilder); - lineLength += spacingLength + wordLength; - } - return lineBuilder; + public int getRequiredHeight(int maxLength) { + Font font = fontRenderer.font(); + calculateLines(font, maxLength); + return font.lineHeight * linesToDraw.size(); } + } + + class ReplaceableWrappedTextRenderer extends WrappedTextRenderer { - public static int calculateHeightRequired(Font font, Component text, int width, float maxLength) { - return calculateHeightRequired(font, text.getString(), width, maxLength); + public ReplaceableWrappedTextRenderer(IFancyFontRenderer parent, int width, Component text) { + super(new SimpleFancyFontRenderer(parent.font(), width), text); } - public static int calculateHeightRequired(Font font, String text, int width, float maxLength) { - //TODO: Come up with a better way of doing this - WrappedTextRenderer wrappedTextRenderer = new WrappedTextRenderer(new IFancyFontRenderer() { - @Override - public int getXSize() { - return width; - } - - @Override - public Font getFont() { - return font; - } - }, text); - wrappedTextRenderer.calculateLines(maxLength); - return 9 * wrappedTextRenderer.linesToDraw.size(); + public WrappedTextRenderer replaceFont(IFancyFontRenderer font) { + this.fontRenderer = font; + return this; } - private record LineData(Component component, float length) { + private record SimpleFancyFontRenderer(Font font, int getXSize) implements IFancyFontRenderer { } } } diff --git a/src/main/java/mekanism/common/content/evaporation/EvaporationMultiblockData.java b/src/main/java/mekanism/common/content/evaporation/EvaporationMultiblockData.java index 34bb8bf6b23..40baa2b1687 100644 --- a/src/main/java/mekanism/common/content/evaporation/EvaporationMultiblockData.java +++ b/src/main/java/mekanism/common/content/evaporation/EvaporationMultiblockData.java @@ -121,8 +121,8 @@ public EvaporationMultiblockData(TileEntityThermalEvaporationBlock tile) { outputHandler = OutputHelper.getOutputHandler(outputTank, RecipeError.NOT_ENOUGH_OUTPUT_SPACE); inventorySlots.add(inputInputSlot = FluidInventorySlot.fill(inputTank, this, 28, 20)); inventorySlots.add(outputInputSlot = OutputInventorySlot.at(this, 28, 51)); - inventorySlots.add(inputOutputSlot = FluidInventorySlot.drain(outputTank, this, 132, 20)); - inventorySlots.add(outputOutputSlot = OutputInventorySlot.at(this, 132, 51)); + inventorySlots.add(inputOutputSlot = FluidInventorySlot.drain(outputTank, this, 152, 20)); + inventorySlots.add(outputOutputSlot = OutputInventorySlot.at(this, 152, 51)); inputInputSlot.setSlotType(ContainerSlotType.INPUT); inputOutputSlot.setSlotType(ContainerSlotType.INPUT); heatCapacitors.add(heatCapacitor = VariableHeatCapacitor.create(MekanismConfig.general.evaporationHeatCapacity.get() * 3, () -> biomeAmbientTemp, this)); diff --git a/src/main/java/mekanism/common/entity/EntityRobit.java b/src/main/java/mekanism/common/entity/EntityRobit.java index ec9fdde488b..61ed54b8c46 100644 --- a/src/main/java/mekanism/common/entity/EntityRobit.java +++ b/src/main/java/mekanism/common/entity/EntityRobit.java @@ -143,6 +143,7 @@ private static EntityDataAccessor define(EntityDataSerializer dataSeri private static final TicketType ROBIT_CHUNK_UNLOAD = TicketType.create("robit_chunk_unload", Integer::compareTo, SharedConstants.TICKS_PER_SECOND); private static final EntityDataAccessor OWNER_UUID = define(MekanismDataSerializers.UUID.value()); + //TODO: Ensure this properly updates if the user's name changes but uuid is the same private static final EntityDataAccessor OWNER_NAME = define(EntityDataSerializers.STRING); private static final EntityDataAccessor SECURITY = define(MekanismDataSerializers.SECURITY.value()); private static final EntityDataAccessor FOLLOW = define(EntityDataSerializers.BOOLEAN); diff --git a/src/main/java/mekanism/common/integration/lookingat/LookingAtElement.java b/src/main/java/mekanism/common/integration/lookingat/LookingAtElement.java index 22960a36134..390a8a46ad7 100644 --- a/src/main/java/mekanism/common/integration/lookingat/LookingAtElement.java +++ b/src/main/java/mekanism/common/integration/lookingat/LookingAtElement.java @@ -1,17 +1,16 @@ package mekanism.common.integration.lookingat; -import com.mojang.blaze3d.vertex.PoseStack; import mekanism.client.gui.GuiUtils; import mekanism.client.gui.GuiUtils.TilingDirection; +import mekanism.client.render.IFancyFontRenderer; import mekanism.client.render.MekanismRenderer; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.network.chat.Component; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public abstract class LookingAtElement implements ILookingAtElement { +public abstract class LookingAtElement implements ILookingAtElement, IFancyFontRenderer { private final int borderColor; private final int textColor; @@ -40,13 +39,18 @@ public void render(@NotNull GuiGraphics guiGraphics, int x, int y) { } } } - renderScaledText(Minecraft.getInstance(), guiGraphics, x + 4, y + 3, textColor, width - 8, getText()); + drawScrollingString(guiGraphics, getText(), x, y + 3, TextAlignment.LEFT, textColor, 4, false); } public int getWidth() { return 100; } + @Override + public int getXSize() { + return getWidth(); + } + public int getHeight() { return 13; } @@ -61,20 +65,4 @@ public int getHeight() { protected boolean applyRenderColor(GuiGraphics guiGraphics) { return false; } - - public static void renderScaledText(Minecraft mc, @NotNull GuiGraphics guiGraphics, float x, float y, int color, float maxWidth, Component component) { - int length = mc.font.width(component); - if (length <= maxWidth) { - GuiUtils.drawString(guiGraphics, mc.font, component, x, y, color, false); - } else { - float scale = maxWidth / length; - float reverse = 1 / scale; - float yAdd = 4 - (scale * 8) / 2F; - PoseStack pose = guiGraphics.pose(); - pose.pushPose(); - pose.scale(scale, scale, scale); - guiGraphics.drawString(mc.font, component, (int) (x * reverse), (int) ((y * reverse) + yAdd), color, false); - pose.popPose(); - } - } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/lookingat/jade/JadeTooltipRenderer.java b/src/main/java/mekanism/common/integration/lookingat/jade/JadeTooltipRenderer.java index 0a498357bce..b7d79fa0003 100644 --- a/src/main/java/mekanism/common/integration/lookingat/jade/JadeTooltipRenderer.java +++ b/src/main/java/mekanism/common/integration/lookingat/jade/JadeTooltipRenderer.java @@ -1,6 +1,5 @@ package mekanism.common.integration.lookingat.jade; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.datafixers.util.Either; import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; @@ -8,13 +7,13 @@ import java.util.Optional; import java.util.function.Function; import mekanism.api.SerializationConstants; +import mekanism.client.render.IFancyFontRenderer.TextAlignment; import mekanism.common.integration.lookingat.ChemicalElement; import mekanism.common.integration.lookingat.EnergyElement; import mekanism.common.integration.lookingat.FluidElement; import mekanism.common.integration.lookingat.ILookingAtElement; import mekanism.common.integration.lookingat.LookingAtElement; import mekanism.common.integration.lookingat.TextElement; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -23,6 +22,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; import net.minecraft.world.phys.Vec2; import net.neoforged.neoforge.common.util.NeoForgeExtraCodecs; import org.jetbrains.annotations.Nullable; @@ -125,16 +125,14 @@ public Vec2 getSize() { } @Override - public void render(GuiGraphics guiGraphics, float x, float y, float maxX, float maxY) { + public void render(GuiGraphics guiGraphics, float rawX, float rawY, float maxX, float maxY) { + int x = Mth.floor(rawX); + int y = Mth.floor(rawY); if (text != null) { - LookingAtElement.renderScaledText(Minecraft.getInstance(), guiGraphics, x + 4, y + 3, 0xFFFFFF, 92, text); + element.drawScrollingString(guiGraphics, text, x,y + 3, TextAlignment.LEFT, 0xFFFFFF, 4, false); y += 13; } - PoseStack pose = guiGraphics.pose(); - pose.pushPose(); - pose.translate(x, y, 0); - element.render(guiGraphics, 0, 1); - pose.popPose(); + element.render(guiGraphics, x, y + 1); } } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/lookingat/wthit/WTHITTooltipRenderer.java b/src/main/java/mekanism/common/integration/lookingat/wthit/WTHITTooltipRenderer.java index 9c8c84d436c..ab4931d9a72 100644 --- a/src/main/java/mekanism/common/integration/lookingat/wthit/WTHITTooltipRenderer.java +++ b/src/main/java/mekanism/common/integration/lookingat/wthit/WTHITTooltipRenderer.java @@ -1,6 +1,5 @@ package mekanism.common.integration.lookingat.wthit; -import com.mojang.blaze3d.vertex.PoseStack; import mcp.mobius.waila.api.IBlockAccessor; import mcp.mobius.waila.api.IBlockComponentProvider; import mcp.mobius.waila.api.IDataReader; @@ -9,11 +8,11 @@ import mcp.mobius.waila.api.IPluginConfig; import mcp.mobius.waila.api.ITooltip; import mcp.mobius.waila.api.ITooltipComponent; +import mekanism.client.render.IFancyFontRenderer.TextAlignment; import mekanism.common.integration.lookingat.ILookingAtElement; import mekanism.common.integration.lookingat.LookingAtElement; import mekanism.common.integration.lookingat.TextElement; import net.minecraft.client.DeltaTracker; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import org.jetbrains.annotations.Nullable; @@ -80,14 +79,10 @@ public int getHeight() { @Override public void render(GuiGraphics guiGraphics, int x, int y, DeltaTracker delta) { if (text != null) { - LookingAtElement.renderScaledText(Minecraft.getInstance(), guiGraphics, x + 4, y + 3, 0xFFFFFF, 92, text); + element.drawScrollingString(guiGraphics, text, x, y + 3, TextAlignment.LEFT, 0xFFFFFF, 4, false); y += 13; } - PoseStack pose = guiGraphics.pose(); - pose.pushPose(); - pose.translate(x, y, 0); - element.render(guiGraphics, 0, 1); - pose.popPose(); + element.render(guiGraphics, x, y + 1); } } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/ModuleTweakerContainer.java b/src/main/java/mekanism/common/inventory/container/ModuleTweakerContainer.java index 6c89eee404a..d76bb68801d 100644 --- a/src/main/java/mekanism/common/inventory/container/ModuleTweakerContainer.java +++ b/src/main/java/mekanism/common/inventory/container/ModuleTweakerContainer.java @@ -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; diff --git a/src/main/java/mekanism/common/inventory/slot/BasicInventorySlot.java b/src/main/java/mekanism/common/inventory/slot/BasicInventorySlot.java index b22e83fb272..d3226a5d189 100644 --- a/src/main/java/mekanism/common/inventory/slot/BasicInventorySlot.java +++ b/src/main/java/mekanism/common/inventory/slot/BasicInventorySlot.java @@ -111,6 +111,10 @@ protected BasicInventorySlot(int limit, BiPredicate<@NotNull ItemStack, @NotNull this.y = y; } + public int getGuiX() { + return x; + } + @Override public ItemStack getStack() { return current; diff --git a/src/main/java/mekanism/common/registries/MekanismContainerTypes.java b/src/main/java/mekanism/common/registries/MekanismContainerTypes.java index 05901ee1a62..c566bef674b 100644 --- a/src/main/java/mekanism/common/registries/MekanismContainerTypes.java +++ b/src/main/java/mekanism/common/registries/MekanismContainerTypes.java @@ -133,7 +133,7 @@ private MekanismContainerTypes() { public static final ContainerTypeRegistryObject> OREDICTIONIFICATOR = CONTAINER_TYPES.custom(MekanismBlocks.OREDICTIONIFICATOR, TileEntityOredictionificator.class).offset(30, 64).build(); public static final ContainerTypeRegistryObject> OSMIUM_COMPRESSOR = CONTAINER_TYPES.register(MekanismBlocks.OSMIUM_COMPRESSOR, TileEntityOsmiumCompressor.class); public static final ContainerTypeRegistryObject> PRECISION_SAWMILL = CONTAINER_TYPES.register(MekanismBlocks.PRECISION_SAWMILL, TileEntityPrecisionSawmill.class); - public static final ContainerTypeRegistryObject> PRESSURIZED_REACTION_CHAMBER = CONTAINER_TYPES.register(MekanismBlocks.PRESSURIZED_REACTION_CHAMBER, TileEntityPressurizedReactionChamber.class); + public static final ContainerTypeRegistryObject> PRESSURIZED_REACTION_CHAMBER = CONTAINER_TYPES.custom(MekanismBlocks.PRESSURIZED_REACTION_CHAMBER, TileEntityPressurizedReactionChamber.class).offset(0, 5).build(); public static final ContainerTypeRegistryObject> PURIFICATION_CHAMBER = CONTAINER_TYPES.register(MekanismBlocks.PURIFICATION_CHAMBER, TileEntityPurificationChamber.class); public static final ContainerTypeRegistryObject> QUANTUM_ENTANGLOPORTER = CONTAINER_TYPES.custom(MekanismBlocks.QUANTUM_ENTANGLOPORTER, TileEntityQuantumEntangloporter.class).offset(0, 74).build(); public static final ContainerTypeRegistryObject> RESISTIVE_HEATER = CONTAINER_TYPES.register(MekanismBlocks.RESISTIVE_HEATER, TileEntityResistiveHeater.class); @@ -145,7 +145,7 @@ private MekanismContainerTypes() { public static final ContainerTypeRegistryObject> SEISMIC_VIBRATOR = CONTAINER_TYPES.register(MekanismBlocks.SEISMIC_VIBRATOR, TileEntitySeismicVibrator.class); public static final ContainerTypeRegistryObject> SOLAR_NEUTRON_ACTIVATOR = CONTAINER_TYPES.register(MekanismBlocks.SOLAR_NEUTRON_ACTIVATOR, TileEntitySolarNeutronActivator.class); public static final ContainerTypeRegistryObject> TELEPORTER = CONTAINER_TYPES.custom(MekanismBlocks.TELEPORTER, TileEntityTeleporter.class).offset(0, 74).build(); - public static final ContainerTypeRegistryObject> THERMAL_EVAPORATION_CONTROLLER = CONTAINER_TYPES.register(MekanismBlocks.THERMAL_EVAPORATION_CONTROLLER, TileEntityThermalEvaporationController.class); + public static final ContainerTypeRegistryObject> THERMAL_EVAPORATION_CONTROLLER = CONTAINER_TYPES.custom(MekanismBlocks.THERMAL_EVAPORATION_CONTROLLER, TileEntityThermalEvaporationController.class).offset(10, 0).build(); public static final ContainerTypeRegistryObject> ANTIPROTONIC_NUCLEOSYNTHESIZER = CONTAINER_TYPES.custom(MekanismBlocks.ANTIPROTONIC_NUCLEOSYNTHESIZER, TileEntityAntiprotonicNucleosynthesizer.class).offset(10, 27).build(); public static final ContainerTypeRegistryObject> PIGMENT_EXTRACTOR = CONTAINER_TYPES.register(MekanismBlocks.PIGMENT_EXTRACTOR, TileEntityPigmentExtractor.class); public static final ContainerTypeRegistryObject> PIGMENT_MIXER = CONTAINER_TYPES.register(MekanismBlocks.PIGMENT_MIXER, TileEntityPigmentMixer.class); @@ -164,7 +164,7 @@ private MekanismContainerTypes() { public static final ContainerTypeRegistryObject> FLUID_TANK = CONTAINER_TYPES.custom("fluid_tank", TileEntityFluidTank.class).armorSideBar().build(); public static final ContainerTypeRegistryObject> ENERGY_CUBE = CONTAINER_TYPES.custom("energy_cube", TileEntityEnergyCube.class).armorSideBar(180, 41, 0).build(); public static final ContainerTypeRegistryObject> INDUCTION_MATRIX = CONTAINER_TYPES.custom("induction_matrix", TileEntityInductionCasing.class).armorSideBar(-20, 41, 0).build(); - public static final ContainerTypeRegistryObject> THERMOELECTRIC_BOILER = CONTAINER_TYPES.custom("thermoelectric_boiler", TileEntityBoilerCasing.class).offset(20, 0).build(); + public static final ContainerTypeRegistryObject> THERMOELECTRIC_BOILER = CONTAINER_TYPES.custom("thermoelectric_boiler", TileEntityBoilerCasing.class).offset(21, 0).build(); public static final ContainerTypeRegistryObject PERSONAL_STORAGE_ITEM = CONTAINER_TYPES.registerMenu("personal_storage_item", () -> MekanismItemContainerType.item(ItemBlockPersonalStorage.class, PersonalStorageItemContainer::new)); public static final ContainerTypeRegistryObject> PERSONAL_STORAGE_BLOCK = CONTAINER_TYPES.custom("personal_storage_block", TileEntityPersonalStorage.class).offset(0, 56).build(); public static final ContainerTypeRegistryObject> QIO_FREQUENCY_SELECT_TILE = CONTAINER_TYPES.registerEmpty("qio_frequency_select_tile", TileEntityQIOComponent.class); diff --git a/src/main/java/mekanism/common/tile/TileEntityModificationStation.java b/src/main/java/mekanism/common/tile/TileEntityModificationStation.java index ef82c468ef5..57066cb0894 100644 --- a/src/main/java/mekanism/common/tile/TileEntityModificationStation.java +++ b/src/main/java/mekanism/common/tile/TileEntityModificationStation.java @@ -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(); } diff --git a/src/main/java/mekanism/common/tile/TileEntityTeleporter.java b/src/main/java/mekanism/common/tile/TileEntityTeleporter.java index c8131d79c0e..67db853aa6f 100644 --- a/src/main/java/mekanism/common/tile/TileEntityTeleporter.java +++ b/src/main/java/mekanism/common/tile/TileEntityTeleporter.java @@ -645,6 +645,10 @@ public MachineEnergyContainer getEnergyContainer() { return energyContainer; } + public int getEnergySlotX() { + return energySlot.getGuiX(); + } + public EnumColor getColor() { return color; } diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityChemicalCrystallizer.java b/src/main/java/mekanism/common/tile/machine/TileEntityChemicalCrystallizer.java index c39ec438eb6..b42782069b9 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityChemicalCrystallizer.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityChemicalCrystallizer.java @@ -124,6 +124,10 @@ protected boolean onUpdateServer() { return sendUpdatePacket; } + public int getEnergySlotX() { + return energySlot.getGuiX(); + } + @Override public @NotNull IMekanismRecipeTypeProvider> getRecipeType() { return MekanismRecipeType.CRYSTALLIZING; diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityPressurizedReactionChamber.java b/src/main/java/mekanism/common/tile/machine/TileEntityPressurizedReactionChamber.java index 207d58c9ba6..66877f2cef8 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityPressurizedReactionChamber.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityPressurizedReactionChamber.java @@ -153,11 +153,11 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this); builder.addSlot(inputSlot = InputInventorySlot.at(item -> containsRecipeABC(item, inputFluidTank.getFluid(), inputGasTank.getStack()), this::containsRecipeA, - recipeCacheListener, 54, 35)) + recipeCacheListener, 54, 40)) .tracksWarnings(slot -> slot.warning(WarningType.NO_MATCHING_RECIPE, getWarningCheck(NOT_ENOUGH_ITEM_INPUT_ERROR))); - builder.addSlot(outputSlot = OutputInventorySlot.at(recipeCacheUnpauseListener, 116, 35)) + builder.addSlot(outputSlot = OutputInventorySlot.at(recipeCacheUnpauseListener, 116, 40)) .tracksWarnings(slot -> slot.warning(WarningType.NO_SPACE_IN_OUTPUT, getWarningCheck(NOT_ENOUGH_SPACE_ITEM_OUTPUT_ERROR))); - builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, listener, 141, 17)); + builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, listener, 141, 22)); return builder.build(); } diff --git a/src/main/java/mekanism/common/util/UnitDisplayUtils.java b/src/main/java/mekanism/common/util/UnitDisplayUtils.java index fdd7634ecad..b89278353f9 100644 --- a/src/main/java/mekanism/common/util/UnitDisplayUtils.java +++ b/src/main/java/mekanism/common/util/UnitDisplayUtils.java @@ -31,6 +31,24 @@ public class UnitDisplayUtils { //TODO: Maybe at some point improve on the ITextComponents the two getDisplay methods build, and have them have better translation keys with formats // That would improve how well this handles en_ud as currently the order of the number and the unit is not reversed and the unit is not upside down + private static final Unit IGNORED_UNIT = new Unit() { + + @Override + public Component appendTo(Object existing, boolean isShort, boolean spaceBetweenSymbol, boolean singular) { + return TextComponentUtil.build(existing); + } + + @Override + public Object getSymbol(boolean singular) { + return null; + } + + @Override + public ILangEntry getLabel(boolean singular) { + return null; + } + }; + public static Component getDisplayShort(double value, EnergyUnit unit) { return getDisplayBase(value, unit, 2, true, true); } @@ -39,15 +57,13 @@ public static Component getDisplay(double temp, TemperatureUnit unit, int decima return getDisplayBase(unit.convertFromK(temp, shift), unit, decimalPlaces, isShort, spaceBetweenSymbol); } + public static Component getDisplay(double value, int decimalPlaces) { + return getDisplayBase(value, IGNORED_UNIT, decimalPlaces, true, false); + } + private static Component getDisplayBase(double value, Unit unit, int decimalPlaces, boolean isShort, boolean spaceBetweenSymbol) { if (value == 0) { - if (isShort) { - if (spaceBetweenSymbol) { - return TextComponentUtil.build(value + " ", unit.getSymbol(false)); - } - return TextComponentUtil.build(value, unit.getSymbol(false)); - } - return TextComponentUtil.build(value, unit.getLabel(false)); + return unit.appendTo(value, isShort, spaceBetweenSymbol, false); } boolean singular = Mth.equal(value, 1); boolean negative = value < 0; @@ -101,6 +117,16 @@ public static double roundDecimals(double d) { private interface Unit { + default Component appendTo(Object existing, boolean isShort, boolean spaceBetweenSymbol, boolean singular) { + if (isShort) { + if (spaceBetweenSymbol) { + return TextComponentUtil.build(existing + " ", getSymbol(singular)); + } + return TextComponentUtil.build(existing, getSymbol(singular)); + } + return TextComponentUtil.build(existing, getLabel(singular)); + } + Object getSymbol(boolean singular); ILangEntry getLabel(boolean singular); @@ -357,10 +383,8 @@ private Component getDisplay(double value, Unit unit, int decimalPlaces, boolean if (spaceBetweenSymbol || !isShort) { name = " " + name; } - if (isShort) { - return TextComponentUtil.build(rounded + name, unit.getSymbol(singular)); - } - return TextComponentUtil.build(rounded + name, unit.getLabel(singular)); + //Note: We handle the space between symbols above + return unit.appendTo(rounded + name, isShort, false, singular); } } } \ No newline at end of file diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 12154e9c524..741effb3c85 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -7,6 +7,9 @@ public-f net.minecraft.client.gui.components.AbstractWidget render(Lnet/minecraf public net.minecraft.client.gui.components.events.ContainerEventHandler handleArrowNavigation(Lnet/minecraft/client/gui/navigation/FocusNavigationEvent$ArrowNavigation;)Lnet/minecraft/client/gui/ComponentPath; public net.minecraft.client.gui.components.events.ContainerEventHandler handleTabNavigation(Lnet/minecraft/client/gui/navigation/FocusNavigationEvent$TabNavigation;)Lnet/minecraft/client/gui/ComponentPath; +public net.minecraft.client.gui.components.AbstractWidget MIN_SCROLL_PERIOD +public net.minecraft.client.gui.components.AbstractWidget PERIOD_PER_SCROLLED_PIXEL + public net.minecraft.client.gui.components.EditBox canLoseFocus public net.minecraft.client.gui.components.EditBox maxLength public net.minecraft.client.gui.components.EditBox highlightPos diff --git a/src/main/resources/assets/mekanism/gui/module_selection.png b/src/main/resources/assets/mekanism/gui/module_selection.png index 58a624373f9..f979bbe020f 100644 Binary files a/src/main/resources/assets/mekanism/gui/module_selection.png and b/src/main/resources/assets/mekanism/gui/module_selection.png differ diff --git a/src/main/resources/assets/mekanism/gui/upgrade_selection.png b/src/main/resources/assets/mekanism/gui/upgrade_selection.png index 25409664de4..58a624373f9 100644 Binary files a/src/main/resources/assets/mekanism/gui/upgrade_selection.png and b/src/main/resources/assets/mekanism/gui/upgrade_selection.png differ