Skip to content

Commit

Permalink
Key Color config + fix applyPreset() bleeding
Browse files Browse the repository at this point in the history
  • Loading branch information
strubium committed Oct 16, 2024
1 parent 5ec3db3 commit 4dc0c66
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/main/java/mcjty/theoneprobe/config/ConfigSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mcjty/theoneprobe/gui/GuiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ 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;
return y;
}

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));
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/mcjty/theoneprobe/gui/GuiNote.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 19 additions & 3 deletions src/main/java/mcjty/theoneprobe/gui/PresetBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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<TextStyleClass, String> entry : preset.getTextStyleClasses().entrySet()) {
for (Map.Entry<TextStyleClass, String> 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<TextStyleClass, String> entry : preset.getTextStyleClasses().entrySet()) {
ConfigSetup.setTextStyle(entry.getKey(), entry.getValue());
}
}


Expand Down

0 comments on commit 4dc0c66

Please sign in to comment.