Skip to content

Commit

Permalink
Why did I even try?
Browse files Browse the repository at this point in the history
  • Loading branch information
NGSpace committed Dec 18, 2024
1 parent dd0f593 commit 128f94f
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies {
provided 'org.mozilla:rhino:1.7.15'

modImplementation("com.terraformersmc:modmenu:13.0.0-beta.1")
modImplementation("me.shedaniel.cloth:cloth-config-fabric:17.0.142")
modImplementation("me.shedaniel.cloth:cloth-config-fabric:17.0.144")
}

processResources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@
import io.github.ngspace.hudder.Hudder;
import io.github.ngspace.hudder.compilers.utils.Compilers;
import io.github.ngspace.hudder.utils.HudFileUtils;
import me.shedaniel.clothconfig2.api.AbstractConfigListEntry;
import me.shedaniel.clothconfig2.api.ConfigBuilder;
import me.shedaniel.clothconfig2.api.ConfigCategory;
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
import me.shedaniel.clothconfig2.gui.entries.MultiElementListEntry;
import me.shedaniel.clothconfig2.gui.entries.NestedListListEntry;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.WidgetSprites;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ARGB;

public class ConfigMenu implements ConfigScreenFactory<Screen> {

Expand All @@ -36,6 +43,40 @@ public class ConfigMenu implements ConfigScreenFactory<Screen> {

@Override public Screen create(Screen parent) {

// ConfigBuilder builder = new ConfigBuilderImpl() {
// @Override
// @SuppressWarnings("unchecked")
// public Screen build() {
// try {
// var f = ConfigBuilderImpl.class.getDeclaredField("fallbackCategory");
//
// f.setAccessible(true);
// String fallbackCategory = (String) f.get(this);
//
// f = ConfigBuilderImpl.class.getDeclaredField("categoryMap");
// f.setAccessible(true);
// Map<String, ConfigCategory> categoryMap = (Map<String, ConfigCategory>) f.get(this);
//
//
// AbstractConfigScreen screen;
// screen = new ClothConfigScreen(parent, getTitle(), categoryMap, getDefaultBackgroundTexture()) {
//
// };
// screen.setSavingRunnable(getSavingRunnable());
// screen.setEditable(isEditable());
// screen.setFallbackCategory(fallbackCategory == null ? null : Component.literal(fallbackCategory));
// screen.setTransparentBackground(hasTransparentBackground());
// screen.setAlwaysShowTabs(isAlwaysShowTabs());
// screen.setConfirmSave(doesConfirmSave());
// screen.setAfterInitConsumer(getAfterInitConsumer());
// return screen;
// } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException
// | SecurityException e) {
// e.printStackTrace();
// return null;
// }
// }
// }
ConfigBuilder builder = ConfigBuilder.create()
.setTitle(Component.literal("Hudder"))
.setSavingRunnable(() -> {
Expand All @@ -61,6 +102,47 @@ public class ConfigMenu implements ConfigScreenFactory<Screen> {


/* General */
//Why am I doing this to myself?
// AbstractConfigListEntry<String> abstractConfigEntry = new AbstractConfigListEntry<String>(Component.literal("r"), false) {
//
// @Override public String getValue() {return "r";}
// @Override public List<? extends GuiEventListener> children() {return new ArrayList<GuiEventListener>();}
// @Override public Optional<String> getDefaultValue() {return Optional.of("r");}
//
// ResourceLocation highlighted = ResourceLocation.withDefaultNamespace("widget/button_highlighted");
// ResourceLocation not_highlighted = ResourceLocation.withDefaultNamespace("widget/button");
//
// @SuppressWarnings("unchecked") @Override public List narratables() {return new ArrayList<>();}
// public void render(GuiGraphics context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
// super.render(context, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
//// context.blit(RenderType::guiTextured,ResourceLocation.withDefaultNamespace("widget/button"),
//// x, y, 0, 0f, 100, 7, entryWidth, entryHeight);
//// var b = new Button.Builder(getFieldName(), bu->{});
//// b.build().renderWidget(context, mouseX, mouseY, delta);
// context.blitSprite(
// RenderType::guiTextured,
// isHovered ? highlighted : not_highlighted,
// x,
// y,
// entryWidth,
// entryHeight
// );
// }
// public boolean mouseClicked(double d, double e, int i) {
// boolean clicked = super.mouseClicked(d, e, i);
// Hudder.log(d);
// Hudder.log(e);
// Hudder.log(i);
// Hudder.log(this.isMouseOver(d, e));
// return clicked;
// }
// };
// general.addEntry(abstractConfigEntry);
general.addEntry(entryBuilder
.startTextDescription(Component.translatable("hudder.general.folder").withStyle(s -> s
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
Component.translatable("hudder.general.folder.tooltip")))
.withClickEvent(new ClickEvent(ClickEvent.Action.CHANGE_PAGE, HudFileUtils.FOLDER)))).build());
general.addEntry(entryBuilder
.startTextDescription(Component.translatable("hudder.general.wiki").withStyle(s -> s
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
Expand Down Expand Up @@ -205,7 +287,7 @@ public class ConfigMenu implements ConfigScreenFactory<Screen> {
.setYesNoTextSupplier(yesno)
.setDefaultValue(true)
.build());

return builder.build();
}
private List<Variable> getVarList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public Object execute(V2Runtime runtime, String functionName, AV2Value[] args, i
lst.add(value);
}
}
//TODO create array of predefined size
return lst;
}

Expand Down

0 comments on commit 128f94f

Please sign in to comment.