Compare commits

..
10 Commits
9 changed files with 56 additions and 105 deletions

No files matched your search

+2 -2
View File
@@ -1,9 +1,9 @@
// Add your dependencies here
dependencies {
implementation('com.github.GTNewHorizons:NotEnoughItems:2.8.20-GTNH:dev')
implementation('com.github.GTNewHorizons:NotEnoughItems:2.8.16-GTNH:dev')
shadowImplementation('au.com.bytecode:opencsv:2.4')
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.52.69:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.52.57:dev") { transitive = false }
}
+1 -3
View File
@@ -96,9 +96,7 @@ usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.46'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.44'
}
@@ -1,29 +1,9 @@
package mcp.mobius.waila.api;
/**
* Interface for tooltip renderers that adjust their width depending on the width of the rest of the tooltip.
* setMaxLineWidth is called by {@link mcp.mobius.waila.overlay.Tooltip} before every tooltip render to inform the
* renderer of the width of the longest line in the tooltip.
*/
public interface IWailaVariableWidthTooltipRenderer extends IWailaTooltipRenderer {
/**
* Informs the renderer of what the length of the longest line is.</br>
* Called by {@link mcp.mobius.waila.overlay.Tooltip} before every tooltip render.</br>
*
* @param width The width of the longest line in the tooltip.
*
*/
void setMaxLineWidth(int width);
void setMaxStringW(int width);
/**
* Returns the width of the longest line in the current tooltip.</br>
* With icons disabled the tooltip's background box is always 2 pixels wider to the right of the line than it is to
* the left.</br>
*
* @return The width of the longest line in the tooltip
*
*/
int getMaxLineWidth();
int getMaxStringW();
}
@@ -33,6 +33,8 @@ public class SpecialChars {
public static String WailaStyle = "\u00A4";
public static String WailaIcon = "\u00A5";
public static String WailaRenderer = "\u00A6";
public static String WailaRendererBracketLeft = "\u0080";
public static String WailaRendererBracketRight = "\u0081";
public static String WailaRendererComma = "\u0082";
public static String TAB = WailaStyle + WailaStyle + "a";
public static String ALIGNRIGHT = WailaStyle + WailaStyle + "b";
@@ -44,19 +46,26 @@ public class SpecialChars {
public static final Pattern patternMinecraft = Pattern.compile("(?i)" + MCStyle + "[0-9A-FK-OR]");
public static final Pattern patternWaila = Pattern.compile("(?i)(" + WailaStyle + "(?<type>..))");
// (?i)(¤¦a\{(?<name>[^U+0082}]*)U+0082?(?<args>[^}]*)\})
// (?i)(¤¦a\U+0080(?<name>[^U+0082U+0081]*)U+0082?(?<args>[^U+0081]*)\U+0081)
public static final Pattern patternRender = Pattern.compile(
"(?i)(" + RENDER
+ "\\{(?<name>[^"
+ "\\"
+ WailaRendererBracketLeft
+ "(?<name>[^"
+ WailaRendererComma
+ "}]*)"
+ WailaRendererBracketRight
+ "]*)"
+ WailaRendererComma
+ "?(?<args>[^}]*)\\})");
+ "?(?<args>[^"
+ WailaRendererBracketRight
+ "]*)\\"
+ WailaRendererBracketRight
+ ")");
public static final Pattern patternTab = Pattern.compile("(?i)" + TAB);
public static final Pattern patternRight = Pattern.compile("(?i)" + ALIGNRIGHT);
public static final Pattern patternCenter = Pattern.compile("(?i)" + ALIGNCENTER);
public static final Pattern patternIcon = Pattern.compile("(?i)(" + WailaStyle + WailaIcon + "(?<type>[0-9a-z]))");
// (?i)(¤¤[^¤]+|¤¥[0-9A-Z]|¤¦a\{(?<name>[^U+0082}]*)U+0082?(?<args>[^}]*)\}|[^¤]+)
// (?i)(¤¤[^¤]+|¤¥[0-9A-Z]|¤¦a\U+0080(?<name>[^U+0082U+0081]*)U+0082?(?<args>[^U+0081]*)\U+0081|[^¤]+)
public static final Pattern patternLineSplit = Pattern.compile(
"(?i)(" + WailaStyle
+ WailaStyle
@@ -68,11 +77,18 @@ public class SpecialChars {
+ "[0-9A-Z]|"
+ WailaStyle
+ WailaRenderer
+ "a\\{(?<name>[^"
+ "a\\"
+ WailaRendererBracketLeft
+ "(?<name>[^"
+ WailaRendererComma
+ "}]*)"
+ WailaRendererBracketRight
+ "]*)"
+ WailaRendererComma
+ "?(?<args>[^}]*)\\}|[^"
+ "?(?<args>[^"
+ WailaRendererBracketRight
+ "]*)\\"
+ WailaRendererBracketRight
+ "|[^"
+ WailaStyle
+ "]+)");
@@ -81,11 +97,11 @@ public class SpecialChars {
* give back a directly usable String for the tooltip.
*/
public static String getRenderString(String name, String... params) {
StringBuilder result = new StringBuilder(RENDER + "{" + name);
StringBuilder result = new StringBuilder(RENDER + WailaRendererBracketLeft + name);
for (String s : params) {
result.append(WailaRendererComma).append(s);
}
result.append("}");
result.append(WailaRendererBracketRight);
return result.toString();
}
}
@@ -34,8 +34,6 @@ public class ConfigHandler implements IWailaConfigHandler {
public HashMap<String, Boolean> forcedConfigs = new HashMap<>();
public Configuration config = null;
public String fluidUnit;
public void addModule(String modName, HashMap<String, String> options) {
this.addModule(modName, new ConfigModule(modName, options));
}
@@ -152,7 +150,6 @@ public class ConfigHandler implements IWailaConfigHandler {
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_KEYBIND, true);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_NEWFILTERS, true);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOWICON, true);
fluidUnit = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_FLUIDUNIT, "mB").getString();
OverlayConfig.posX = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX, 5000).getInt();
OverlayConfig.posY = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY, 100).getInt();
@@ -42,6 +42,7 @@ public class Tooltip {
ArrayList<Renderable> elements = new ArrayList<>();
ArrayList<Renderable> elements2nd = new ArrayList<>();
ArrayList<Renderable> elements3rd = new ArrayList<>();
int w, h, x, y, ty;
int offsetX;
@@ -183,10 +184,10 @@ public class Tooltip {
renderer,
new Point(offsetX, offsetY),
renderMatcher.group("args").split(SpecialChars.WailaRendererComma));
if (renderer instanceof IWailaVariableWidthTooltipRenderer variableWidthRenderer) {
variableWidthRenderer.setMaxLineWidth(maxStringW);
}
this.elements2nd.add(renderable);
if (renderer instanceof IWailaVariableWidthTooltipRenderer) {
((IWailaVariableWidthTooltipRenderer) renderable.renderer).setMaxStringW(maxStringW);
this.elements3rd.add(renderable);
} else this.elements2nd.add(renderable);
}
} else if (iconMatcher.find()) {
renderable = new Renderable(
@@ -249,5 +250,6 @@ public class Tooltip {
public void draw2nd() {
for (Renderable r : this.elements2nd) r.draw(accessor, x + offsetX, y + ty);
for (Renderable r : this.elements3rd) r.draw(accessor, x + offsetX, y + ty);
}
}
@@ -1,13 +1,10 @@
package mcp.mobius.waila.overlay.tooltiprenderers;
import java.awt.Dimension;
import java.util.function.Consumer;
import java.util.function.Function;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
@@ -16,13 +13,11 @@ import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.Loader;
import gregtech.api.util.GTUtil;
import gregtech.api.util.GTUtility;
import gregtech.common.fluid.GTFluid;
import gtPlusPlus.api.objects.minecraft.FluidGT6;
import gtPlusPlus.core.util.minecraft.FluidUtils;
import mcp.mobius.waila.api.IWailaCommonAccessor;
import mcp.mobius.waila.api.IWailaVariableWidthTooltipRenderer;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.overlay.DisplayUtil;
import mcp.mobius.waila.overlay.OverlayConfig;
@@ -30,59 +25,33 @@ public class TTRenderFluidBar implements IWailaVariableWidthTooltipRenderer {
int maxStringW;
private final Consumer<String> bindColor;
private final Function<Integer, String> formatNumber;
public TTRenderFluidBar() {
if (Loader.isModLoaded("gregtech")) {
bindColor = (fluidName) -> {
FluidStack aCheck = FluidUtils.getWildcardFluidStack(fluidName, 1000);
if (aCheck != null && (aCheck.getFluid() instanceof FluidGT6 || aCheck.getFluid() instanceof GTFluid)) {
short[] RGBa = GTUtil.getRGBaArray(aCheck.getFluid().getColor());
GL11.glColor4f(RGBa[0] / 255F, RGBa[1] / 255F, RGBa[2] / 255F, 1F);
} else {
GL11.glColor4f(1F, 1F, 1F, 1F);
}
};
formatNumber = GTUtility::formatNumbers;
} else {
bindColor = (fluidName) -> GL11.glColor4f(1F, 1F, 1F, 1F);
formatNumber = (number) -> String.format("%,d", number);
}
}
@Override
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
int commaCount = (int) (Math.floor((params[2].length() - 1) / 3D) + Math.floor((params[3].length() - 1) / 3D));
// ",".repeat(commaCount) doesn't exist in java 8 so do this instead.
StringBuilder sb = new StringBuilder(commaCount);
for (int i = 0; i < commaCount; i++) {
sb.append(",");
}
return new Dimension(
DisplayUtil.getDisplayWidth(
params[2] + " / " + params[3] + ConfigHandler.instance().fluidUnit + params[1] + sb) + 4,
12);
return new Dimension(DisplayUtil.getDisplayWidth(params[1] + 2), 12);
}
@Override
public void draw(String[] params, IWailaCommonAccessor accessor) {
String fluidName = params[0];
String localizedName = params[1];
double amount = Double.parseDouble(params[2]);
double capacity = Double.parseDouble(params[3]);
drawThickBeveledBox(0, 0, maxStringW, 12, 1, 0xFF505050, 0xFF505050, -1);
IIcon icon = FluidRegistry.getFluid(fluidName).getIcon();
IIcon icon = FluidRegistry.getFluid(params[0]).getIcon();
Minecraft mc = Minecraft.getMinecraft();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
mc.getTextureManager().bindTexture(net.minecraft.client.renderer.texture.TextureMap.locationBlocksTexture);
bindColor.accept(fluidName);
if (Loader.isModLoaded("gregtech")) {
FluidStack aCheck = FluidUtils.getWildcardFluidStack(params[0], 1000);
if (aCheck != null && (aCheck.getFluid() instanceof FluidGT6 || aCheck.getFluid() instanceof GTFluid)) {
short[] RGBa = GTUtil.getRGBaArray(aCheck.getFluid().getColor());
GL11.glColor4f(RGBa[0] / 255F, RGBa[1] / 255F, RGBa[2] / 255F, 1F);
} else {
GL11.glColor4f(1F, 1F, 1F, 1F);
}
} else {
GL11.glColor4f(1F, 1F, 1F, 1F);
}
int i = (int) ((double) (maxStringW - 2) * amount / capacity);
int i = (int) ((maxStringW - 2) * Double.parseDouble(params[2]));
int j = 0;
for (; i > 10; i = i - 10) {
drawTexturedModelRectFromIcon(1 + (j * 10), 1, icon, 10, 10, 100);
@@ -98,17 +67,7 @@ public class TTRenderFluidBar implements IWailaVariableWidthTooltipRenderer {
icon.getMinU() + ((icon.getMaxU() - icon.getMinU()) * ((double) i / 10D)),
icon.getMaxV());
DisplayUtil.drawString(
formatNumber.apply((int) amount) + " / "
+ formatNumber.apply((int) capacity)
+ " "
+ ConfigHandler.instance().fluidUnit
+ " "
+ localizedName,
2,
2,
OverlayConfig.fontcolor,
true);
DisplayUtil.drawString(params[1], 2, 2, OverlayConfig.fontcolor, true);
}
@@ -139,12 +98,12 @@ public class TTRenderFluidBar implements IWailaVariableWidthTooltipRenderer {
}
@Override
public void setMaxLineWidth(int width) {
public void setMaxStringW(int width) {
maxStringW = width + 2;
}
@Override
public int getMaxLineWidth() {
public int getMaxStringW() {
return maxStringW;
}
}
@@ -29,7 +29,6 @@ public final class Constants {
public static String CFG_WAILA_NHEARTS = "waila.cfg.heartsperline";
public static String CFG_WAILA_MAXHP = "waila.cfg.maxhpbeforetext";
public static String CFG_WAILA_NEWFILTERS = "waila.cfg.newfilters";
public static String CFG_WAILA_FLUIDUNIT = "waila.cfg.fluid_unit";
public static String CFG_WAILA_ALPHA = "waila.cfg.alpha";
public static String CFG_WAILA_BGCOLOR = "waila.cfg.bgcolor";