diff options
Diffstat (limited to 'src/main/java/gregtech')
54 files changed, 392 insertions, 391 deletions
diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 69f9447998..f59c7c18df 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -64,7 +64,6 @@ import gregtech.loaders.load.GT_SonictronLoader; import gregtech.loaders.misc.GT_Achievements; import gregtech.loaders.misc.GT_Bees; import gregtech.loaders.misc.GT_CoverLoader; -import gregtech.loaders.misc.GT_JsonLoader; import gregtech.loaders.postload.*; import gregtech.loaders.preload.*; import gregtech.nei.IMCForNEI; @@ -157,9 +156,6 @@ public class GT_Mod implements IGT_Mod { public static final String aTextIC2 = "ic2_"; public static final Logger GT_FML_LOGGER = LogManager.getLogger("GregTech GTNH"); - @SideOnly(Side.CLIENT) - public static GT_JsonLoader jsonGuiColors; - static { if ((509 != GregTech_API.VERSION) || (509 != GT_ModHandler.VERSION) || (509 != GT_OreDictUnificator.VERSION) || (509 != GT_Recipe.VERSION) || (509 != GT_Utility.VERSION) || (509 != GT_RecipeRegistrator.VERSION) || (509 != Element.VERSION) || (509 != Materials.VERSION) || (509 != OrePrefixes.VERSION)) { throw new GT_ItsNotMyFaultException("One of your Mods included GregTech-API Files inside it's download, mention this to the Mod Author, who does this bad thing, and tell him/her to use reflection. I have added a Version check, to prevent Authors from breaking my Mod that way."); diff --git a/src/main/java/gregtech/api/enums/GuiColors.java b/src/main/java/gregtech/api/enums/GuiColors.java deleted file mode 100644 index 8c0a32954a..0000000000 --- a/src/main/java/gregtech/api/enums/GuiColors.java +++ /dev/null @@ -1,101 +0,0 @@ -package gregtech.api.enums; - -import gregtech.api.util.GT_Log; - -import java.util.function.Function; - -public enum GuiColors { - //RGB Colors: Name and default value - oneByOne(0x404040), - twoByTwo(0x404040), - twoByTwoFluid(0x404040), - twoByTwoFluidInventory(0x404040), - threeByThree(0x404040), - fourByFour(0x404040), - basicMachine(0x404040), - basicTankTitle(0x404040), - basicTankInventory(0x404040), - basicTankLiquidAmount(0xFAFAFF), - basicTankLiquidValue(0xFAFAFF), - maintenanceHatch(0x404040), - maintenanceHatchRepair(0x404040), - - multiMachineTitle(0xFAFAFF), - multiMachineDrillBaseText(0xFAFAFF), - multiMachineIncompleteStructure(0xFAFAFF), - multiMachineLargeTurbineText(0xFAFAFF), - multiMachineMaintenanceText(0xFAFAFF), - multiMachineMalletRestart(0xFAFAFF), - multiMachineRunningPerfectly(0xFAFAFF), - - outputHatchTitle(0x404040), - outputHatchInventory(0x404040), - outputHatchAmount(0xFAFAFF), - outputHatchValue(0xFAFAFF), - outputHatchFluidName(0xFAFAFF), - outputHatchLockedFluid(0xFAFAFF), - - boiler(0x404040), - bronzeBlastFurnace(0x404040), - fusionReactor(0xFF0000), - industrialApiary(0x404040), - microwaveEnergyTransmitter(0xFAFAFF), - primitiveBlastFurnace(0x404040), - quantumChestTitle(0x404040), - quantumChestAmount(0xFAFAFF), - regulator(0xFAFAFF), - teleporter(0xFAFAFF), - - fluidDisplayStackRenderer(0xFFFFFF), - - //ARGB Colors: Name and default value - dialogSelectItem(0xFF555555), - pollutionRenderer(0xFFFFFFFF), - screenText(0xFF222222), - - coverArm(0xFF555555), - coverControlsWork(0xFF555555), - coverConveyor(0xFF555555), - coverDoesWork(0xFF555555), - coverEUMeter(0xFF555555), - coverFluidFilterName(0xFF222222), - coverFluidFilter(0xFF555555), - coverFluidRegulatorWarn(0xFFFF0000), - coverFluidRegulator(0xFF555555), - coverItemFilter(0xFF555555), - coverItemMeter(0xFF555555), - coverLiquidMeter(0xFF555555), - coverMaintenance(0xFF555555), - coverPlayerDetector(0xFF555555), - coverPump(0xFF555555), - coverRedstoneWirelessBase(0xFF555555), - coverShutter(0xFF555555), - - NEIText(0xFF000000); - - private final int defaultColor; - private int color; - - GuiColors(final int hex) { - this.defaultColor = hex; - this.color = hex; - } - - public void reload(Function<String, String> l) { - color = this.defaultColor; - - String hex = l.apply("GT5U.gui.color." + this); - - try { - if (!hex.isEmpty()) { - color = Integer.parseUnsignedInt(hex, 16); - } - } catch (final NumberFormatException e) { - GT_Log.err.println("Couldn't format color correctly for: GT5U.gui.color." + this + " -> " + hex); - } - } - - public int getColor() { - return color; - } -} diff --git a/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java b/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java new file mode 100644 index 0000000000..c2a833503e --- /dev/null +++ b/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java @@ -0,0 +1,39 @@ +package gregtech.api.gui; + +import gregtech.api.util.ColorsMetadataSection; +import gregtech.api.GregTech_API; +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.IResource; +import net.minecraft.util.ResourceLocation; + +import java.io.IOException; + +public class GT_GUIColorOverride { + + private ColorsMetadataSection cmSection; + + public GT_GUIColorOverride(String guiTexturePath) { + try { + IResource ir = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(guiTexturePath)); + if (ir.hasMetadata()) { + cmSection = (ColorsMetadataSection) ir.getMetadata("colors"); + } + } catch (IOException ignore) {} + } + + public int getTextColorOrDefault(String textType, int defaultColor) { + return sLoaded() ? cmSection.getTextColorOrDefault(textType, defaultColor) : defaultColor; + } + + public int getGuiTintOrDefault(String key, int defaultColor) { + return sLoaded() ? cmSection.getGuiTintOrDefault(key, defaultColor) : defaultColor; + } + + public boolean sGuiTintingEnabled() { + return sLoaded() ? cmSection.sGuiTintingEnabled() : GregTech_API.sColoredGUI; + } + + public boolean sLoaded() { + return cmSection != null; + } +} diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer.java b/src/main/java/gregtech/api/gui/GT_GUIContainer.java index 1f1ae9037e..5d3f0a59a1 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer.java @@ -1,5 +1,6 @@ package gregtech.api.gui; +import gregtech.api.gui.GT_GUIColorOverride; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.inventory.Container; @@ -7,6 +8,8 @@ import net.minecraft.inventory.Slot; import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Mouse; +import java.io.IOException; + import static gregtech.GT_Mod.GT_FML_LOGGER; /** @@ -20,11 +23,18 @@ public class GT_GUIContainer extends GuiContainer { public ResourceLocation mGUIbackground; + public GT_GUIColorOverride colorOverride; + public String mGUIbackgroundPath; public GT_GUIContainer(Container aContainer, String aGUIbackground) { super(aContainer); mGUIbackground = new ResourceLocation(mGUIbackgroundPath = aGUIbackground); + colorOverride = new GT_GUIColorOverride(aGUIbackground); + } + + protected int getTextColorOrDefault(String textType, int defaultColor) { + return colorOverride.getTextColorOrDefault(textType, defaultColor); } public int getLeft() { diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java index d25abd9137..4ab5f9f921 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java @@ -13,9 +13,10 @@ import gregtech.api.gui.widgets.GT_GuiTabLine.GT_ITabRenderer; import gregtech.api.gui.widgets.GT_GuiTooltipManager.GT_IToolTipRenderer; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_TooltipDataCache; +import gregtech.api.util.GT_Util; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.entity.RenderItem; -import gregtech.api.util.GT_TooltipDataCache; import net.minecraft.entity.player.InventoryPlayer; import java.util.List; @@ -34,6 +35,8 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements protected GT_GuiTooltipManager mTooltipManager = new GT_GuiTooltipManager(); protected GT_TooltipDataCache mTooltipCache = new GT_TooltipDataCache(); + private final int guiTint; + // Cover Tabs support. Subclasses can override display position, style and visuals by overriding setupCoverTabs public GT_GuiCoverTabLine coverTabs; private static final int @@ -63,6 +66,8 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements if (GT_Mod.gregtechproxy.mTooltipVerbosity > 0 || GT_Mod.gregtechproxy.mTooltipShiftVerbosity > 0) { setupTooltips(); } + + guiTint = getColorization(); } public GT_GUIContainerMetaTile_Machine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, @@ -106,8 +111,7 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements coverTabs.drawTabs(parTicks, mouseX, mouseY); // Applying machine coloration, which subclasses rely on - Dyes color = getColorization(); - GL11.glColor3ub((byte) color.mRGBa[0], (byte) color.mRGBa[1], (byte) color.mRGBa[2]); + GL11.glColor3ub((byte) ((guiTint >> 16) & 0xFF), (byte) ((guiTint >> 8) & 0xFF), (byte) (guiTint & 0xFF)); // Binding machine's own texture, which subclasses rely on being set super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); @@ -116,20 +120,25 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements /** * @return The color used to render this machine's GUI */ - private Dyes getColorization() { - if (GregTech_API.sMachineMetalGUI) { - return Dyes.MACHINE_METAL; - } else if (GregTech_API.sColoredGUI && mContainer != null && mContainer.mTileEntity != null) { - byte colorByte = mContainer.mTileEntity.getColorization(); - Dyes color; - if (colorByte != -1) - color = Dyes.get(colorByte); - else - color = Dyes.MACHINE_METAL; - return color; - } else { - return Dyes.dyeWhite; + private int getColorization() { + Dyes dye = Dyes.dyeWhite; + if (this.colorOverride.sLoaded()) { + if (this.colorOverride.sGuiTintingEnabled()) { + dye = getDyeFromIndex(mContainer.mTileEntity.getColorization()); + return this.colorOverride.getGuiTintOrDefault(dye.mName, GT_Util.getRGBInt(dye.getRGBA())); + } + } else if (GregTech_API.sColoredGUI) { + if (GregTech_API.sMachineMetalGUI) { + dye = Dyes.MACHINE_METAL; + } else if (mContainer != null && mContainer.mTileEntity != null) { + dye = getDyeFromIndex(mContainer.mTileEntity.getColorization()); + } } + return GT_Util.getRGBInt(dye.getRGBA()); + } + + private Dyes getDyeFromIndex(short index) { + return index != -1 ? Dyes.get(index) : Dyes.MACHINE_METAL; } /** diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_1by1.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_1by1.java index 8682a77bae..7e85cb60f0 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_1by1.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_1by1.java @@ -1,6 +1,5 @@ package gregtech.api.gui; -import gregtech.api.enums.GuiColors; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; @@ -9,7 +8,7 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI; public class GT_GUIContainer_1by1 extends GT_GUIContainerMetaTile_Machine { private final String mName; - private final int textColor = GuiColors.oneByOne.getColor(); + private final int textColor = this.getTextColorOrDefault("title", 0x404040); public GT_GUIContainer_1by1(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { super(new GT_Container_1by1(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "1by1.png"); diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java index 72afda851b..acefe12459 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java @@ -1,6 +1,5 @@ package gregtech.api.gui; -import gregtech.api.enums.GuiColors; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; @@ -9,7 +8,7 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI; public class GT_GUIContainer_2by2 extends GT_GUIContainerMetaTile_Machine { private final String mName; - private final int textColor = GuiColors.twoByTwo.getColor(); + private final int textColor = this.getTextColorOrDefault("title", 0x404040); public GT_GUIContainer_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { super(new GT_Container_2by2(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "2by2.png"); diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2_Fluid.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2_Fluid.java index 860f33c2bb..afabaa0a80 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2_Fluid.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2_Fluid.java @@ -1,6 +1,5 @@ package gregtech.api.gui; -import gregtech.api.enums.GuiColors; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.StatCollector; @@ -10,9 +9,7 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI; public class GT_GUIContainer_2by2_Fluid extends GT_GUIContainerMetaTile_Machine { private final String mName; - private final int - textColorTitle = GuiColors.twoByTwoFluid.getColor(), - textColorInventory = GuiColors.twoByTwoFluidInventory.getColor(); + private final int textColor = this.getTextColorOrDefault("title", 0x404040); public GT_GUIContainer_2by2_Fluid(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { super(new GT_Container_2by2_Fluid(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "2by2fluid.png"); @@ -21,8 +18,8 @@ public class GT_GUIContainer_2by2_Fluid extends GT_GUIContainerMetaTile_Machine @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, textColorInventory); - fontRendererObj.drawString(mName, 8, 6, textColorTitle); + fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, textColor); + fontRendererObj.drawString(mName, 8, 6, textColor); } @Override diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_3by3.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_3by3.java index 12b3f81754..c2911fc67f 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_3by3.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_3by3.java @@ -1,6 +1,5 @@ package gregtech.api.gui; -import gregtech.api.enums.GuiColors; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; @@ -9,7 +8,7 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI; public class GT_GUIContainer_3by3 extends GT_GUIContainerMetaTile_Machine { private final String mName; - private final int textColor = GuiColors.threeByThree.getColor(); + private final int textColor = this.getTextColorOrDefault("title", 0x404040); public GT_GUIContainer_3by3(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { super(new GT_Container_3by3(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "3by3.png"); diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_4by4.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_4by4.java index fa2695b633..b28129eede 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_4by4.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_4by4.java @@ -1,6 +1,5 @@ package gregtech.api.gui; -import gregtech.api.enums.GuiColors; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; @@ -9,7 +8,7 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI; public class GT_GUIContainer_4by4 extends GT_GUIContainerMetaTile_Machine { private final String mName; - private final int textColor = GuiColors.fourByFour.getColor(); + private final int textColor = this.getTextColorOrDefault("title", 0x404040); public GT_GUIContainer_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { super(new GT_Container_4by4(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "4by4.png"); diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java index 29168a53bb..8f26c00216 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java @@ -1,7 +1,6 @@ package gregtech.api.gui; import gregtech.api.enums.GT_Values; -import gregtech.api.enums.GuiColors; import gregtech.api.gui.widgets.GT_GuiIcon; import gregtech.api.gui.widgets.GT_GuiTabLine.GT_GuiTabIconSet; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -41,7 +40,7 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin GT_GuiIcon.TAB_NORMAL_STEEL, GT_GuiIcon.TAB_HIGHLIGHT_STEEL, GT_GuiIcon.TAB_DISABLED_STEEL); - private final int textColor = GuiColors.basicMachine.getColor(); + private final int textColor = this.getTextColorOrDefault("title", 0x404040); public final String mName, mNEI; diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicTank.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicTank.java index 4a9e6751a6..a24060aaa4 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicTank.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicTank.java @@ -1,6 +1,5 @@ package gregtech.api.gui; -import gregtech.api.enums.GuiColors; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; @@ -11,11 +10,10 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI; public class GT_GUIContainer_BasicTank extends GT_GUIContainerMetaTile_Machine { private final String mName; - private final int - textColorTitle = GuiColors.basicTankTitle.getColor(), - textColorInventory = GuiColors.basicTankInventory.getColor(), - textColorLiquidAmount = GuiColors.basicTankLiquidAmount.getColor(), - textColorLiquidValue = GuiColors.basicTankLiquidValue.getColor(); + private final int + textColor = this.getTextColorOrDefault("text", 0xFAFAFF), + textColorTitle = this.getTextColorOrDefault("title", 0x404040), + textColorValue = this.getTextColorOrDefault("value", 0xFAFAFF); public GT_GUIContainer_BasicTank(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { super(new GT_Container_BasicTank(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "BasicTank.png"); @@ -24,11 +22,11 @@ public class GT_GUIContainer_BasicTank extends GT_GUIContainerMetaTile_Machine { @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, textColorInventory); + fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, textColorTitle); fontRendererObj.drawString(mName, 8, 6, textColorTitle); |
