Skip to content

Commit

Permalink
Fix GroovyCompact
Browse files Browse the repository at this point in the history
  • Loading branch information
strubium committed Oct 15, 2024
1 parent 982c2f5 commit b2d1d50
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,14 @@ public static void showStandardBlockInfo(IProbeConfig config, ProbeMode mode, IP
probeInfo.horizontal()
.item(pickBlock)
.vertical()
.text(blockDisplayName + "...")
.text(NAME + blockDisplayName + "...")
.text(MODNAME + modid);
}
else{
probeInfo.horizontal()
.item(pickBlock)
.vertical()
.text(blockDisplayName)
.text(NAME + blockDisplayName)
.text(MODNAME + modid);
}

Expand Down
18 changes: 1 addition & 17 deletions src/main/java/mcjty/theoneprobe/gui/GuiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import mcjty.theoneprobe.TheOneProbe;
import mcjty.theoneprobe.Tools;
import mcjty.theoneprobe.api.IOverlayStyle;
import mcjty.theoneprobe.api.TextStyleClass;
import mcjty.theoneprobe.apiimpl.ProbeInfo;
import mcjty.theoneprobe.config.ConfigSetup;
import mcjty.theoneprobe.rendering.RenderHelper;
Expand All @@ -23,7 +22,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import static mcjty.theoneprobe.api.TextStyleClass.*;

Expand Down Expand Up @@ -121,25 +119,11 @@ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOEx
}
}

/**
* Applies the given preset configuration.
*
* @param preset The {@link Preset} object containing the configuration to apply.
*/
private void applyPreset(Preset preset) {
// Apply box styles from 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());
}
}

private int addPreset(int x, int y, Preset preset) {
drawRect(x + 10, y - 1, x + 10 + WIDTH - 50, y + 10, 0xff000000);
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, () -> applyPreset(preset)));
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;
}
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/mcjty/theoneprobe/gui/Preset.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import org.apache.commons.lang3.tuple.Pair;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -67,4 +69,23 @@ public int getBoxOffset() {
public Map<TextStyleClass, String> getTextStyleClasses() {
return textStyleClasses;
}

/**
* Gets all TextStyleClass keys in the preset.
*
* @return A collection of TextStyleClass keys.
*/
public Collection<TextStyleClass> getTextStyleClassKeys() {
return textStyleClasses.keySet();
}

/**
* Gets the style name associated with a given TextStyleClass.
*
* @param styleClass The TextStyleClass to look up.
* @return The associated style name, or null if not found.
*/
public String getStyleName(TextStyleClass styleClass) {
return textStyleClasses.get(styleClass);
}
}
17 changes: 17 additions & 0 deletions src/main/java/mcjty/theoneprobe/gui/PresetBuilder.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mcjty.theoneprobe.gui;

import mcjty.theoneprobe.api.TextStyleClass;
import mcjty.theoneprobe.config.ConfigSetup;
import org.apache.commons.lang3.tuple.Pair;

import java.util.ArrayList;
Expand Down Expand Up @@ -85,6 +86,22 @@ public Preset build() {
return preset;
}

/**
* Applies the given preset configuration.
*
* @param preset The {@link Preset} object containing the configuration to apply.
*/
public static void applyPreset(Preset preset) {
// Apply text styles from the preset
for (Map.Entry<TextStyleClass, String> entry : preset.getTextStyleClasses().entrySet()) {
ConfigSetup.setTextStyle(entry.getKey(), entry.getValue());
}

// Apply box styles from preset
ConfigSetup.setBoxStyle(preset.getBoxThickness(), preset.getBoxBorderColor(), preset.getBoxFillColor());
}


/**
* Get the name of the preset.
*/
Expand Down

0 comments on commit b2d1d50

Please sign in to comment.