From f0256ca0b98127b0760978836f6e668ff2a47909 Mon Sep 17 00:00:00 2001 From: NotAPenguin Date: Tue, 3 Sep 2024 10:30:39 +0200 Subject: update modularui to fix gt (#3019) --- .../java/gregtech/api/util/CoverBehaviorBase.java | 2 +- .../gregtech/api/util/GT_TooltipDataCache.java | 104 --------------------- 2 files changed, 1 insertion(+), 105 deletions(-) delete mode 100644 src/main/java/gregtech/api/util/GT_TooltipDataCache.java (limited to 'src/main/java/gregtech/api/util') diff --git a/src/main/java/gregtech/api/util/CoverBehaviorBase.java b/src/main/java/gregtech/api/util/CoverBehaviorBase.java index 0c8ef81533..cd8a1f5ba9 100644 --- a/src/main/java/gregtech/api/util/CoverBehaviorBase.java +++ b/src/main/java/gregtech/api/util/CoverBehaviorBase.java @@ -408,7 +408,7 @@ public abstract class CoverBehaviorBase { // region UI stuff - protected GT_TooltipDataCache mTooltipCache = new GT_TooltipDataCache(); + protected GTTooltipDataCache mTooltipCache = new GTTooltipDataCache(); protected GUIColorOverride colorOverride; private static final String guiTexturePath = "gregtech:textures/gui/GuiCover.png"; diff --git a/src/main/java/gregtech/api/util/GT_TooltipDataCache.java b/src/main/java/gregtech/api/util/GT_TooltipDataCache.java deleted file mode 100644 index 6b42a8e7fa..0000000000 --- a/src/main/java/gregtech/api/util/GT_TooltipDataCache.java +++ /dev/null @@ -1,104 +0,0 @@ -package gregtech.api.util; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.minecraft.util.StatCollector; - -import gregtech.GTMod; - -public class GT_TooltipDataCache { - - public static class TooltipData { - - public List text; - public List shiftText; - - public TooltipData(List text, List shiftText) { - this.text = text; - this.shiftText = shiftText; - } - } - - private final Map fetchedTooltipData = new HashMap<>(); - - /** - * Returns tooltip data respecting the user's configured verbosity levels, applying any formatting arguments. - * - * @param key the key to lookup - * @param args arguments for string formatting (prefer using positional arguments) - * @return The tooltip data the user asked for - */ - public TooltipData getData(String key, Object... args) { - TooltipData tooltipData = fetchedTooltipData.get(key); - if (tooltipData == null) { - tooltipData = getUncachedTooltipData(key, args); - fetchedTooltipData.put(key, tooltipData); - } - return tooltipData; - } - - /** - * Builds tooltip data respecting the user's configured verbosity levels, applying any formatting arguments. - * - * @param key the key to lookup - * @param args arguments for string formatting (prefer using positional arguments) - * @return The tooltip data the user asked for - */ - public TooltipData getUncachedTooltipData(String key, Object... args) { - List lines = getAllLines(key, args); - int normalLines = lines.size(); - if (Math.max(GTMod.gregtechproxy.mTooltipVerbosity, GTMod.gregtechproxy.mTooltipShiftVerbosity) >= 3) { - lines.addAll(getAllLines(key + ".extended", args)); // Are extended lines enabled? If so add them to the - // lines - } - if (lines.size() == 0) { - lines.add(key); // Fallback in case no lines could be found at all - } - return new TooltipData( - lines.subList(0, getVerbosityIndex(GTMod.gregtechproxy.mTooltipVerbosity, normalLines, lines.size())), - lines.subList(0, getVerbosityIndex(GTMod.gregtechproxy.mTooltipShiftVerbosity, normalLines, lines.size()))); - } - - /** - * Gets all the lines for the given key and every other subsequent consecutive key with a .n suffix, n in {1,2,3...} - * - * @param key the key to lookup - * @param args arguments for string formatting (prefer using positional arguments) - * @return The lines for the key and all of it's subkeys - */ - private List getAllLines(String key, Object... args) { - List lines = new ArrayList<>(); - String keyToLookup = key; - int i = 1; // First loop has no .number postfix - while (StatCollector.canTranslate(keyToLookup)) { - lines.add(StatCollector.translateToLocalFormatted(keyToLookup, args)); - keyToLookup = key + "." + i++; - } - return lines; - } - - /** - * Determines how many lines from a tooltip to include from the full line list to respect a given verbosity level. - * - * @param tooltipVerbosity the verbosity level we're applying - * @param defaultIndex return if tooltipVerbosity is 2 - * @param maxIndex return if tooltipVerbosity is greater than 2 - * @return verbosity appropriate index - */ - private static int getVerbosityIndex(int tooltipVerbosity, int defaultIndex, int maxIndex) { - int index; - if (tooltipVerbosity < 1) { - index = 0; - } else if (tooltipVerbosity == 1) { - index = 1; - } else if (tooltipVerbosity == 2) { - index = defaultIndex; - } else { - index = maxIndex; - } - return index; - } -} -- cgit