mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-15 17:44:46 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93485e1525 | ||
|
|
ceb94e3e2c | ||
|
|
8ea26bf073 | ||
|
|
2aabfdb64c | ||
|
|
a34460c159 | ||
|
|
1f3fd64a38 | ||
|
|
191a916896 | ||
|
|
ee1ed27a3a | ||
|
|
07b9d1bf92 | ||
|
|
e82729a113 | ||
|
|
c938ccf542 | ||
|
|
c2e8b44f2b | ||
|
|
c4e3537957 | ||
|
|
9bc1e79f64 |
No files matched your search
+3
-1
@@ -1,7 +1,9 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.7.91-GTNH:dev')
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.8.20-GTNH:dev')
|
||||
|
||||
shadowImplementation('au.com.bytecode:opencsv:2.4')
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.52.69:dev") { transitive = false }
|
||||
}
|
||||
+3
-1
@@ -96,7 +96,9 @@ usesMixinDebug = false
|
||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||
mixinPlugin =
|
||||
|
||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||
# 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.
|
||||
mixinsPackage =
|
||||
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.44'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.46'
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public interface IWailaDataProvider {
|
||||
* @param config Current configuration of Waila.
|
||||
* @return True if advanced body information is available, false otherwise.
|
||||
*/
|
||||
default boolean hasAdvancedBody(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
default boolean hasWailaAdvancedBody(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return false; // Default to false for backward compatibility
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
/**
|
||||
* Return the size of the tooltip. for variable width renderers it is recommended to return the minimum width needed
|
||||
* for the line, then draw the actual width using getMaxLineWidth(). They do not need to actually match.
|
||||
*
|
||||
* @param params Array of string parameters as passed to the RENDER arg in the tooltip
|
||||
* ({rendername,param1,param2,...})
|
||||
* @param accessor A global accessor for TileEntities and Entities
|
||||
* @return Dimension of the reserved area
|
||||
*/
|
||||
Dimension getSize(String[] params, IWailaCommonAccessor accessor);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
}
|
||||
@@ -33,6 +33,7 @@ public class SpecialChars {
|
||||
public static String WailaStyle = "\u00A4";
|
||||
public static String WailaIcon = "\u00A5";
|
||||
public static String WailaRenderer = "\u00A6";
|
||||
public static String WailaRendererComma = "\u0082";
|
||||
public static String TAB = WailaStyle + WailaStyle + "a";
|
||||
public static String ALIGNRIGHT = WailaStyle + WailaStyle + "b";
|
||||
public static String ALIGNCENTER = WailaStyle + WailaStyle + "c";
|
||||
@@ -43,12 +44,19 @@ 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>..))");
|
||||
public static final Pattern patternRender = Pattern
|
||||
.compile("(?i)(" + RENDER + "\\{(?<name>[^,}]*),?(?<args>[^}]*)\\})");
|
||||
// (?i)(¤¦a\{(?<name>[^U+0082}]*)U+0082?(?<args>[^}]*)\})
|
||||
public static final Pattern patternRender = Pattern.compile(
|
||||
"(?i)(" + RENDER
|
||||
+ "\\{(?<name>[^"
|
||||
+ WailaRendererComma
|
||||
+ "}]*)"
|
||||
+ WailaRendererComma
|
||||
+ "?(?<args>[^}]*)\\})");
|
||||
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>[^}]*)\}|[^¤]+)
|
||||
public static final Pattern patternLineSplit = Pattern.compile(
|
||||
"(?i)(" + WailaStyle
|
||||
+ WailaStyle
|
||||
@@ -60,7 +68,11 @@ public class SpecialChars {
|
||||
+ "[0-9A-Z]|"
|
||||
+ WailaStyle
|
||||
+ WailaRenderer
|
||||
+ "a\\{([^,}]*),?([^}]*)\\}|[^"
|
||||
+ "a\\{(?<name>[^"
|
||||
+ WailaRendererComma
|
||||
+ "}]*)"
|
||||
+ WailaRendererComma
|
||||
+ "?(?<args>[^}]*)\\}|[^"
|
||||
+ WailaStyle
|
||||
+ "]+)");
|
||||
|
||||
@@ -71,7 +83,7 @@ public class SpecialChars {
|
||||
public static String getRenderString(String name, String... params) {
|
||||
StringBuilder result = new StringBuilder(RENDER + "{" + name);
|
||||
for (String s : params) {
|
||||
result.append(",").append(s);
|
||||
result.append(WailaRendererComma).append(s);
|
||||
}
|
||||
result.append("}");
|
||||
return result.toString();
|
||||
|
||||
@@ -34,6 +34,8 @@ 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));
|
||||
}
|
||||
@@ -150,6 +152,7 @@ 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();
|
||||
|
||||
@@ -155,7 +155,7 @@ public class MetaDataProvider {
|
||||
for (IWailaDataProvider dataProvider : providersList) try {
|
||||
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
|
||||
if (dataProvider.hasAdvancedBody(itemStack, accessor, ConfigHandler.instance())) {
|
||||
if (dataProvider.hasWailaAdvancedBody(itemStack, accessor, ConfigHandler.instance())) {
|
||||
hasAdvancedBodyAvailable = true;
|
||||
|
||||
if (isAdvancedKeyDown) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import mcp.mobius.waila.handlers.HUDHandlerEntities;
|
||||
import mcp.mobius.waila.handlers.VanillaTooltipHandler;
|
||||
import mcp.mobius.waila.handlers.nei.NEIHandler;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderAspectString;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderFluidBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderHealth;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderProgressBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderStack;
|
||||
@@ -54,6 +55,7 @@ public class ProxyClient extends ProxyServer {
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.health", new TTRenderHealth());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.stack", new TTRenderStack());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.progress", new TTRenderProgressBar());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.fluid", new TTRenderFluidBar());
|
||||
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.tcaspect", new TTRenderAspectString());
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package mcp.mobius.waila.handlers;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.BLUE;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.RENDER;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -72,7 +71,7 @@ public class HUDHandlerBlocks implements IWailaDataProvider {
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
currenttip.add(RENDER + "{Plip}" + RENDER + "{Plop,thisisatest,222,333}");
|
||||
// currenttip.add(RENDER + "{Plip}" + RENDER + "{Plop,thisisatest,222,333}");
|
||||
|
||||
String modName = ModIdentification.nameFromStack(itemStack);
|
||||
if (modName != null && !modName.isEmpty()) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
@@ -41,8 +42,9 @@ public class DisplayUtil {
|
||||
Matcher renderMatcher = patternRender.matcher(s);
|
||||
while (renderMatcher.find()) {
|
||||
IWailaTooltipRenderer renderer = ModuleRegistrar.instance().getTooltipRenderer(renderMatcher.group("name"));
|
||||
if (renderer != null)
|
||||
width += renderer.getSize(renderMatcher.group("args").split(","), DataAccessorCommon.instance).width;
|
||||
if (renderer != null) width += renderer.getSize(
|
||||
renderMatcher.group("args").split(SpecialChars.WailaRendererComma),
|
||||
DataAccessorCommon.instance).width;
|
||||
}
|
||||
|
||||
Matcher iconMatcher = patternIcon.matcher(s);
|
||||
|
||||
@@ -21,6 +21,8 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.api.IWailaVariableWidthTooltipRenderer;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
@@ -180,7 +182,10 @@ public class Tooltip {
|
||||
renderable = new Renderable(
|
||||
renderer,
|
||||
new Point(offsetX, offsetY),
|
||||
renderMatcher.group("args").split(","));
|
||||
renderMatcher.group("args").split(SpecialChars.WailaRendererComma));
|
||||
if (renderer instanceof IWailaVariableWidthTooltipRenderer variableWidthRenderer) {
|
||||
variableWidthRenderer.setMaxLineWidth(maxStringW);
|
||||
}
|
||||
this.elements2nd.add(renderable);
|
||||
}
|
||||
} else if (iconMatcher.find()) {
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
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.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
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;
|
||||
|
||||
public class TTRenderFluidBar implements IWailaVariableWidthTooltipRenderer {
|
||||
|
||||
int maxStringW;
|
||||
|
||||
private final Consumer<String> bindColor;
|
||||
private final Function<Integer, String> formatNumber;
|
||||
private static final int height = 12;
|
||||
|
||||
public TTRenderFluidBar() {
|
||||
if (Loader.isModLoaded("gregtech_nh")) {
|
||||
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,
|
||||
height);
|
||||
}
|
||||
|
||||
public static final ResourceLocation gradient = new ResourceLocation("waila", "textures/gradient.png");
|
||||
|
||||
@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]);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
IIcon icon = FluidRegistry.getFluid(fluidName).getIcon();
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
|
||||
bindColor.accept(fluidName);
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
// Intentionally draw 2 pixels taller than needed than cover with the border to make the texture more visible
|
||||
int i = (int) ((double) (maxStringW - 2) * amount / capacity);
|
||||
int j = 0;
|
||||
for (; i > height; i = i - height) {
|
||||
drawRectFromIcon(tessellator, 1 + (j * height), 0, 0, icon, height, height);
|
||||
j++;
|
||||
}
|
||||
if (i > 0) drawRect(
|
||||
tessellator,
|
||||
1 + (j * height),
|
||||
0,
|
||||
0,
|
||||
i,
|
||||
height,
|
||||
icon.getMinU(),
|
||||
icon.getMinV(),
|
||||
icon.getMinU() + ((icon.getMaxU() - icon.getMinU()) * ((double) i / height)),
|
||||
icon.getMaxV());
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.70F);
|
||||
mc.getTextureManager().bindTexture(gradient);
|
||||
tessellator.startDrawingQuads();
|
||||
drawRect(tessellator, 1, 0, 0, maxStringW - 2, height - 1, 0, 0, 1, 1);
|
||||
tessellator.draw();
|
||||
|
||||
drawThickBeveledBox(0, 0, maxStringW, height, 1, 0xFF505050, 0xFF505050, -1);
|
||||
|
||||
DisplayUtil.drawString(
|
||||
formatNumber.apply((int) amount) + " / "
|
||||
+ formatNumber.apply((int) capacity)
|
||||
+ " "
|
||||
+ ConfigHandler.instance().fluidUnit
|
||||
+ " "
|
||||
+ localizedName,
|
||||
2,
|
||||
2,
|
||||
0xFFFFFFFF,
|
||||
true);
|
||||
|
||||
}
|
||||
|
||||
public static void drawRectFromIcon(Tessellator tessellator, int x, int y, double z, IIcon icon, int width,
|
||||
int height) {
|
||||
drawRect(tessellator, x, y, z, width, height, icon.getMinU(), icon.getMinV(), icon.getMaxU(), icon.getMaxV());
|
||||
}
|
||||
|
||||
public static void drawRect(Tessellator tessellator, int x, int y, double z, int width, int height, double minU,
|
||||
double minV, double maxU, double maxV) {
|
||||
tessellator.addVertexWithUV(x, y + height, z, minU, maxV);
|
||||
tessellator.addVertexWithUV(x + width, y + height, z, maxU, maxV);
|
||||
tessellator.addVertexWithUV(x + width, y, z, maxU, minV);
|
||||
tessellator.addVertexWithUV(x, y, z, minU, minV);
|
||||
}
|
||||
|
||||
public static void drawThickBeveledBox(int x1, int y1, int x2, int y2, int thickness, int topleftcolor,
|
||||
int botrightcolor, int fillcolor) {
|
||||
if (fillcolor != -1) {
|
||||
Gui.drawRect(x1 + 1, y1 + 1, x2 - 1, y2 - 1, fillcolor);
|
||||
}
|
||||
Gui.drawRect(x1, y1, x2 - 1, y1 + thickness, topleftcolor);
|
||||
Gui.drawRect(x1, y1, x1 + thickness, y2 - 1, topleftcolor);
|
||||
Gui.drawRect(x2 - thickness, y1, x2, y2 - 1, botrightcolor);
|
||||
Gui.drawRect(x1, y2 - thickness, x2, y2, botrightcolor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxLineWidth(int width) {
|
||||
maxStringW = width + 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLineWidth() {
|
||||
return maxStringW;
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ 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";
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 145 B |
Reference in new issue
Block a user