diff --git a/src/main/java/mcjty/theoneprobe/config/ConfigSetup.java b/src/main/java/mcjty/theoneprobe/config/ConfigSetup.java index 6aa6ad67..3ba14872 100644 --- a/src/main/java/mcjty/theoneprobe/config/ConfigSetup.java +++ b/src/main/java/mcjty/theoneprobe/config/ConfigSetup.java @@ -87,6 +87,7 @@ public class ConfigSetup { public static boolean harvestStyleVanilla = true; public static int chestContentsBorderColor = 0xff006699; + public static int probeButtonColor = 0xff000000; private static int boxBorderColor = 0xff999999; private static int boxFillColor = 0x55006699; private static int boxThickness = 2; @@ -235,6 +236,7 @@ public static void setupStyleConfig(Configuration cfg) { holdKeyToMakeVisible = cfg.getBoolean("holdKeyToMakeVisible", CATEGORY_CLIENT, holdKeyToMakeVisible, "If true, the probe hotkey must be held down to show the tooltip"); compactEqualStacks = cfg.getBoolean("compactEqualStacks", CATEGORY_CLIENT, compactEqualStacks, "If true equal stacks will be compacted in the chest contents overlay"); tooltipScale = cfg.getFloat("tooltipScale", CATEGORY_CLIENT, tooltipScale, 0.4f, 5.0f, "The scale of the tooltips, 1 is default, 2 is smaller"); + probeButtonColor = parseColor(cfg.getString("probeButtonColor", CATEGORY_CLIENT, Integer.toHexString(probeButtonColor), "Color of the buttons in the probe note (0 to disable)")); chestContentsBorderColor = parseColor(cfg.getString("chestContentsBorderColor", CATEGORY_CLIENT, Integer.toHexString(chestContentsBorderColor), "Color of the border of the chest contents box (0 to disable)")); showBreakProgress = cfg.getInt("showBreakProgress", CATEGORY_CLIENT, showBreakProgress, 0, 2, "0 means don't show break progress, 1 is show as bar, 2 is show as text"); harvestStyleVanilla = cfg.getBoolean("harvestStyleVanilla", CATEGORY_CLIENT, harvestStyleVanilla, "true means shows harvestability with vanilla style icons"); @@ -332,6 +334,9 @@ public static boolean getShowProbeNoteGUI(){ public static int getProbeMaxChars(){ return probeMaxChars; } + public static int getProbeButtonColor(){ + return probeButtonColor; + } public static void setBoxStyle(int thickness, int borderColor, int fillcolor) { Configuration cfg = mainConfig; diff --git a/src/main/java/mcjty/theoneprobe/gui/GuiConfig.java b/src/main/java/mcjty/theoneprobe/gui/GuiConfig.java index b676b61b..59edecf5 100644 --- a/src/main/java/mcjty/theoneprobe/gui/GuiConfig.java +++ b/src/main/java/mcjty/theoneprobe/gui/GuiConfig.java @@ -121,7 +121,7 @@ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOEx private int addPreset(int x, int y, Preset preset) { - drawRect(x + 10, y - 1, x + 10 + WIDTH - 50, y + 10, 0xff000000); + drawRect(x + 10, y - 1, x + 10 + WIDTH - 50, y + 10, ConfigSetup.getProbeButtonColor()); RenderHelper.renderText(Minecraft.getMinecraft(), x + 20, y, preset.getName()); hitboxes.add(new HitBox(x + 10 - guiLeft, y - 1 - guiTop, x + 10 + WIDTH - 50 - guiLeft, y + 10 - guiTop, () -> PresetBuilder.applyPreset(preset))); y += 14; @@ -129,7 +129,7 @@ private int addPreset(int x, int y, Preset preset) { } private void addButton(int x, int y, String text, Runnable runnable) { - drawRect(x, y, x + 30 -1, y + 14 -1, 0xff000000); + drawRect(x, y, x + 30 -1, y + 14 -1, ConfigSetup.getProbeButtonColor()); RenderHelper.renderText(Minecraft.getMinecraft(), x + 3, y + 3, text); hitboxes.add(new HitBox(x - guiLeft, y - guiTop, x + 30 -1 - guiLeft, y + 14 -1 - guiTop, runnable)); } diff --git a/src/main/java/mcjty/theoneprobe/gui/GuiNote.java b/src/main/java/mcjty/theoneprobe/gui/GuiNote.java index efb02f7e..8eed72c7 100644 --- a/src/main/java/mcjty/theoneprobe/gui/GuiNote.java +++ b/src/main/java/mcjty/theoneprobe/gui/GuiNote.java @@ -129,15 +129,15 @@ private int setInConfig(int x, int y) { hitY = y + guiTop; hitX = x + guiLeft; - drawRect(x, y, x + BUTTON_WIDTH, y + BUTTON_HEIGHT, 0xff000000); + drawRect(x, y, x + BUTTON_WIDTH, y + BUTTON_HEIGHT, ConfigSetup.getProbeButtonColor()); RenderHelper.renderText(Minecraft.getMinecraft(), x + 3, y + 4, I18n.format("gui.theoneprobe.gui_note.button.needed")); x += BUTTON_MARGIN; - drawRect(x, y, x + BUTTON_WIDTH, y + BUTTON_HEIGHT, 0xff000000); + drawRect(x, y, x + BUTTON_WIDTH, y + BUTTON_HEIGHT, ConfigSetup.getProbeButtonColor()); RenderHelper.renderText(Minecraft.getMinecraft(), x + 3, y + 4, I18n.format("gui.theoneprobe.gui_note.button.not_needed")); x += BUTTON_MARGIN; - drawRect(x, y, x + BUTTON_WIDTH, y + BUTTON_HEIGHT, 0xff000000); + drawRect(x, y, x + BUTTON_WIDTH, y + BUTTON_HEIGHT, ConfigSetup.getProbeButtonColor()); RenderHelper.renderText(Minecraft.getMinecraft(), x + 3, y + 4, I18n.format("gui.theoneprobe.gui_note.button.extended")); y += BUTTON_HEIGHT - 4; diff --git a/src/main/java/mcjty/theoneprobe/gui/PresetBuilder.java b/src/main/java/mcjty/theoneprobe/gui/PresetBuilder.java index b203c035..764d5c61 100644 --- a/src/main/java/mcjty/theoneprobe/gui/PresetBuilder.java +++ b/src/main/java/mcjty/theoneprobe/gui/PresetBuilder.java @@ -9,6 +9,8 @@ import java.util.List; import java.util.Map; +import static mcjty.theoneprobe.config.ConfigSetup.defaultTextStyleClasses; + /** * The Builder to make a new preset, basically for GroovyScript compact * @@ -86,15 +88,29 @@ public Preset build() { * Applies the given preset configuration. * * @param preset The {@link Preset} object containing the configuration to apply. + * @throws IllegalArgumentException if the preset is null. */ public static void applyPreset(Preset preset) { + if (preset == null) { + throw new IllegalArgumentException("Preset cannot be null."); + } + // Apply text styles from the preset - for (Map.Entry entry : preset.getTextStyleClasses().entrySet()) { + for (Map.Entry entry : ConfigSetup.defaultTextStyleClasses.entrySet()) { ConfigSetup.setTextStyle(entry.getKey(), entry.getValue()); } - // Apply box styles from preset - ConfigSetup.setBoxStyle(preset.getBoxThickness(), preset.getBoxBorderColor(), preset.getBoxFillColor()); + // Apply box styles from the preset + ConfigSetup.setBoxStyle( + preset.getBoxThickness(), + preset.getBoxBorderColor(), + preset.getBoxFillColor() + ); + + // Apply text styles from the preset + for (Map.Entry entry : preset.getTextStyleClasses().entrySet()) { + ConfigSetup.setTextStyle(entry.getKey(), entry.getValue()); + } }