Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// Add your dependencies here
configurations.create('gtnhlibEmbed') {
canBeConsumed = false
canBeResolved = true
}

dependencies {
api('com.github.GTNewHorizons:CodeChickenCore:1.4.15:dev')
Expand All @@ -17,4 +21,16 @@ dependencies {

testRuntimeOnly('org.junit.platform:junit-platform-launcher')
testRuntimeOnly("org.lwjgl.lwjgl:lwjgl:2.9.3");

compileOnly("com.github.GTNewHorizons:GTNHLib:0.11.15") { transitive = false }
gtnhlibEmbed("com.github.GTNewHorizons:GTNHLib:0.11.15") { transitive = false }
}

[tasks.jar, tasks.shadowJar].each {
it.configure {
from({ project.configurations.getByName('gtnhlibEmbed').collect { zipTree(it) } }) {
include 'com/gtnewhorizon/gtnhlib/color/ColorResource.class'
include 'com/gtnewhorizon/gtnhlib/color/ColorResource$*.class'
}
}
}
4 changes: 4 additions & 0 deletions src/main/java/codechicken/nei/Button.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public String getRenderLabel() {
return label;
}

public int getRenderLabelColor() {
return 0;
}

public final String label;
public Image icon;

Expand Down
22 changes: 22 additions & 0 deletions src/main/java/codechicken/nei/ColorUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package codechicken.nei;

import com.gtnewhorizon.gtnhlib.color.ColorResource;

public class ColorUtils {

private static final ColorResource.Factory color = new ColorResource.Factory("nei");

public static final ColorResource
// spotless:off
textGray = color.rgb("textGray", "0x404040"),
textLightGray = color.rgb("textLightGray", "0x606060"),
recipeTitle = color.rgb("recipeTitle", "0xFFFFFF"),
recipeTitleHover = color.rgb("recipeTitleHover", "0xFFFF55"),
subsetWidget = color.rgb("subsetWidget", "0xAA00AA"),
recipeBadge = color.rgb("recipeBadge", "0xFDD835"),
buttonLabelNormal = color.rgb("buttonLabelNormal", "0xE0E0E0"),
buttonLabelHover = color.rgb("buttonLabelHover", "0xFFFFA0"),
buttonLabelDisabled = color.rgb("buttonLabelDisabled", "0x601010"),
buttonLabelInactive = color.rgb("buttonLabelInactive", "0xA0A0A0");
// spotless:on
}
10 changes: 7 additions & 3 deletions src/main/java/codechicken/nei/GuiEnchantmentModifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public GuiEnchantmentModifier(InventoryPlayer inventoryplayer, World world, int

@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
fontRendererObj.drawString(translate("enchant"), 12, 6, 0x404040);
fontRendererObj.drawString(translate("enchant.level"), 19, 20, 0x404040);
fontRendererObj.drawString(translate("enchant"), 12, 6, ColorUtils.textGray.getColor());
fontRendererObj.drawString(translate("enchant.level"), 19, 20, ColorUtils.textGray.getColor());
}

protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
Expand All @@ -39,7 +39,11 @@ protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
container.drawScrollBar(this);

String levelstring = "" + container.level;
fontRendererObj.drawString(levelstring, 33 - fontRendererObj.getStringWidth(levelstring) / 2, 34, 0xFF606060);
fontRendererObj.drawString(
levelstring,
33 - fontRendererObj.getStringWidth(levelstring) / 2,
34,
ColorUtils.textLightGray.getColor());

GL11.glTranslatef(-guiLeft, -guiTop, 0);
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/codechicken/nei/GuiNEIButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,14 @@ public void drawButton(Minecraft minecraft, int x, int y) {
}

protected int getTextColour(boolean mouseOver) {
int color = 0xe0e0e0;

if (!enabled) {
color = 0xffa0a0a0;
return ColorUtils.buttonLabelInactive.getColor();
} else if (mouseOver) {
color = 0xffffa0;
return ColorUtils.buttonLabelHover.getColor();
}

return color;
return ColorUtils.buttonLabelNormal.getColor();
}

protected void drawContent(Minecraft minecraft, int y, int x, boolean mouseOver) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/codechicken/nei/GuiPotionCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@ public void drawBackground() {
CCRenderState.changeTexture("nei:textures/gui/potion.png");
drawTexturedModalRect(0, 0, 0, 0, xSize, ySize);

FontUtils.drawCenteredString(translate("potion.favourite"), xSize / 2, 4, 0x404040);
fontRendererObj.drawString(translate("potion.duration"), 12, 40, 0x404040);
fontRendererObj.drawString(translate("potion.level"), 19, 73, 0x404040);
FontUtils.drawCenteredString(translateAmplifier(amplifier), 33, 86, 0xFF606060);
FontUtils.drawCenteredString(translate("potion.favourite"), xSize / 2, 4, ColorUtils.textGray.getColor());
fontRendererObj.drawString(translate("potion.duration"), 12, 40, ColorUtils.textGray.getColor());
fontRendererObj.drawString(translate("potion.level"), 19, 73, ColorUtils.textGray.getColor());
FontUtils.drawCenteredString(translateAmplifier(amplifier), 33, 86, ColorUtils.textGray.getColor());
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/codechicken/nei/LayoutStyleMinecraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,11 @@ else if ((b.state & 0x4) == 0 && b.contains(mousex, mousey) || // not a state bu

Image icon = b.getRenderIcon();
if (icon == null) {
int colour = tex == 2 ? 0xffffa0 : tex == 0 ? 0x601010 : 0xe0e0e0;
int labelColor = b.getRenderLabelColor();
int colour = labelColor != 0 ? labelColor
: tex == 2 ? ColorUtils.buttonLabelHover.getColor()
: tex == 0 ? ColorUtils.buttonLabelDisabled.getColor()
: ColorUtils.buttonLabelNormal.getColor();

drawStringC(b.getRenderLabel(), b.x + b.w / 2, b.y + (b.h - 8) / 2, colour);
} else {
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/codechicken/nei/NEIClientUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,6 @@ public static void reportErrorBuffered(Throwable e, Set<String> buffer, ItemStac
}
}

public static String getTextColorOrDefault(String key, String defaultColor) {
final String translated = NEIClientUtils.translate(key); // Optional localization string for resource packs
return translated.startsWith("nei.") ? defaultColor : translated;
}

public static void drawRect(double left, double top, double width, double height, Color color) {
final boolean is2DTexture = GL11.glGetBoolean(GL11.GL_TEXTURE_2D);
final boolean isBlend = GL11.glGetBoolean(GL11.GL_BLEND);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/codechicken/nei/SubsetWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -689,17 +689,17 @@ public SubsetWidget() {
}

@Override
public String getRenderLabel() {
public int getRenderLabelColor() {
return NEIClientConfig.subsetWidgetOnTop() ? 0 : ColorUtils.subsetWidget.getColor();
}

@Override
public String getRenderLabel() {
if (NEIClientConfig.subsetWidgetOnTop()) {
return NEIClientUtils.translate("inventory.item_subsets");
} else {
return NEIClientUtils.getTextColorOrDefault(
"gui.button.label.subset",
EnumChatFormatting.DARK_PURPLE
+ String.valueOf(SearchField.searchParser.getRedefinedPrefix(PREFIX)));
return String.valueOf(SearchField.searchParser.getRedefinedPrefix(PREFIX));
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.lwjgl.opengl.GL11;

import codechicken.nei.Button;
import codechicken.nei.ColorUtils;
import codechicken.nei.LayoutManager;

public abstract class CheckboxButton extends Button {
Expand Down Expand Up @@ -38,7 +39,8 @@ public void draw(int mousex, int mousey) {
tex = 1;
}

int colour = tex == 2 ? 0xffffa0 : tex == 0 ? 0x601010 : 0xe0e0e0;
int colour = tex == 2 ? ColorUtils.buttonLabelHover.getColor()
: tex == 0 ? ColorUtils.buttonLabelDisabled.getColor() : ColorUtils.buttonLabelNormal.getColor();
LayoutManager.drawButtonBackground(x, y, w, h, true, isChecked() ? 0 : tex);
drawStringC(getRenderLabel(), x + w / 2, y + (h - 8) / 2, colour);
}
Expand Down
15 changes: 3 additions & 12 deletions src/main/java/codechicken/nei/recipe/Badge.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@
import net.minecraft.util.EnumChatFormatting;

import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.ColorUtils;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.NEIClientUtils.Alignment;

public class Badge {

protected final String text;
protected final List<String> tooltip;
protected int badgeTextColor = 0xFDD835;
protected int badgeTextColor;
protected boolean shadow = false;
protected Alignment alignment = Alignment.TopLeft;

public Badge(String text, String... tooltip) {
this.text = text;
this.tooltip = Arrays.stream(tooltip).map(t -> EnumChatFormatting.GRAY + t).collect(Collectors.toList());
this.badgeTextColor = getHexValue(
NEIClientUtils.getTextColorOrDefault("recipe.badge.color", "0xFDD835"),
0xFDD835);
this.badgeTextColor = ColorUtils.recipeBadge.getColor();
}

public String getText() {
Expand Down Expand Up @@ -61,14 +60,6 @@ public Alignment getAlignment() {
return this.alignment;
}

private static int getHexValue(String color, int defaultValue) {
try {
return (int) Long.parseLong(color.replace("0x", ""), 16);
} catch (NumberFormatException e) {
return defaultValue;
}
}

public void draw(Rectangle4i rect) {
NEIClientUtils.drawNEIOverlayText(getText(), rect, 0.5f, getColor(), hasShadow(), getAlignment());
}
Expand Down
20 changes: 6 additions & 14 deletions src/main/java/codechicken/nei/recipe/GuiRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;

import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;

import codechicken.lib.gui.GuiDraw;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.Button;
import codechicken.nei.ColorUtils;
import codechicken.nei.GuiNEIButton;
import codechicken.nei.NEICPH;
import codechicken.nei.NEIClientConfig;
Expand Down Expand Up @@ -878,13 +878,13 @@ private void drawJEITabs(int mouseX, int mouseY) {
0x30000000);

final String handlerTitle = this.handler.original.getRecipeName().trim();
final String titleColorCode = getHandlerTitleColorCode(isHandlerTitleHovered(mouseX, mouseY));
final int titleColor = getHandlerTitleColor(isHandlerTitleHovered(mouseX, mouseY));
drawCenteredString(
this.fontRendererObj,
titleColorCode + handlerTitle + EnumChatFormatting.RESET,
handlerTitle,
this.guiLeft + this.xSize / 2,
this.typeArea.y + textMiddle,
0xffffff);
titleColor);

if (this.handler.searchingAvailable()) {
GuiRecipe.toggleSearch.draw(mouseX, mouseY);
Expand Down Expand Up @@ -938,16 +938,8 @@ private boolean isHandlerTitleHovered(int mousex, int mousey) {
return new Rectangle(titleX, titleY, titleWidth, this.fontRendererObj.FONT_HEIGHT).contains(mousex, mousey);
}

private String getHandlerTitleColorCode(boolean hovered) {

if (hovered) {
return NEIClientUtils
.getTextColorOrDefault("recipe.title.color.hover", EnumChatFormatting.YELLOW.toString());
} else {
return NEIClientUtils
.getTextColorOrDefault("recipe.title.color.normal", EnumChatFormatting.WHITE.toString());
}

private int getHandlerTitleColor(boolean hovered) {
return hovered ? ColorUtils.recipeTitleHover.getColor() : ColorUtils.recipeTitle.getColor();
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/codechicken/nei/recipe/GuiRecipeTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.lwjgl.opengl.GL12;

import codechicken.lib.gui.GuiDraw;
import codechicken.nei.ColorUtils;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.Widget;
Expand Down Expand Up @@ -127,7 +128,7 @@ public void drawForeground(int mouseX, int mouseY) {

int textCenterX = x + (int) (getWidth() / 2f);
int textCenterY = y + (int) (getHeight() / 2f) - 3;
int color = selected ? 0xffffa0 : 0xe0e0e0;
int color = selected ? ColorUtils.buttonLabelHover.getColor() : ColorUtils.buttonLabelNormal.getColor();
fontRenderer.drawStringWithShadow(
text,
textCenterX - (int) (fontRenderer.getStringWidth(text) / 2f),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import codechicken.core.TaskProfiler.ProfilerResult;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.ColorUtils;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.PositionedStack;
Expand Down Expand Up @@ -161,7 +162,7 @@ public void drawForeground(int recipe) {
3,
hovered ? 0xFFFFDD00 : 0xFF808080,
false);
GuiDraw.drawString(info.time, WIDTH - valueWidth, 3, 0xFF404040, false);
GuiDraw.drawString(info.time, WIDTH - valueWidth, 3, ColorUtils.textGray.getColor(), false);
}

private boolean isHandlerTitleHovered(int recipe, Point mouse) {
Expand Down