Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make text more readable by using scrolling strings for bounded strings #8232

Merged
merged 17 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
bbb9bf7
Work on moving all the strings in our GUIs to supporting scrolling wh…
pupnewfster Sep 10, 2024
05aad4d
Continued work on unifying all our gui string rendering to supporting…
pupnewfster Sep 22, 2024
1548616
Remove unnecessary tooltip rendering from seismic vibrator as we alre…
pupnewfster Sep 22, 2024
91a46c5
Fix the majority of GUIs where certain text didn't declare proper bounds
pupnewfster Sep 24, 2024
284c313
Reduce duplicate code between crystallizer gui and recipe categories …
pupnewfster Sep 24, 2024
cb1a182
Work on adjusting various GUIs so that they don't have to make use of…
pupnewfster Sep 24, 2024
070f293
Slightly resize a handful of multiblock guis so that they don't have …
pupnewfster Sep 24, 2024
cfcba1f
Fix dropdowns not respecting icons for max text width, and make it so…
pupnewfster Sep 24, 2024
dad6311
Continued work on making it so our GUIs don't have to use scrolling t…
pupnewfster Sep 24, 2024
d500167
Make it so TEP production display doesn't have to use scrolling text …
pupnewfster Sep 25, 2024
0d1d299
Deduplicate a bit of code for scrolling strings, and fix scaled text …
pupnewfster Sep 26, 2024
50a38e8
Make it so that installed stone generator upgrades and remaining dict…
pupnewfster Sep 28, 2024
0896283
Don't draw the shadow behind text for digital buttons, and fix button…
pupnewfster Oct 6, 2024
69de805
Make use of vanilla's line splitter to ensure we properly maintain an…
pupnewfster Oct 12, 2024
ecb7368
Add support for specifying text alignment to our wrapped text renderer
pupnewfster Oct 12, 2024
5e507ac
Improve scrolling text so that it starts at the left or right of the …
pupnewfster Oct 16, 2024
abce9e9
Persist how long dropdown menus have been opened for when resizing MC…
pupnewfster Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ')
Expand All @@ -285,7 +285,7 @@ private void validate() {
.append('>');
}
});
signature.append(")");
signature.append(')');
throw new RuntimeException("Recipe method: '" + signature + "' has no example usage declared.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ public class GuiFissionReactorLogicAdapter extends GuiMekanismTile<TileEntityFis

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

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

Expand All @@ -48,8 +49,8 @@ private void changeLogic(FissionReactorLogic type) {
@Override
protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) {
renderTitleText(guiGraphics);
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class GuiFusionReactorController extends GuiMekanismTile<TileEntityFusion
public GuiFusionReactorController(MekanismTileContainer<TileEntityFusionReactorController> container, Inventory inv, Component title) {
super(container, inv, title);
dynamicSlots = true;
imageWidth += 10;
inventoryLabelX += 5;
titleLabelY = 5;
}

Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public GuiFusionReactorFuel(EmptyTileContainer<TileEntityFusionReactorController
@Override
protected void addGuiElements() {
super.addGuiElements();
addRenderableWidget(new GuiChemicalGauge(() -> 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);
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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() {
Expand All @@ -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);
}
}
Loading