diff options
Diffstat (limited to 'mod/src/main/java/kr')
77 files changed, 5931 insertions, 0 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java index 0bdcacfc..9dd515c7 100755 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java @@ -38,6 +38,7 @@ import kr.syeyoung.dungeonsguide.mod.events.listener.PacketListener; import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.mod.party.PartyManager; import kr.syeyoung.dungeonsguide.mod.resources.DGTexturePack; +import kr.syeyoung.dungeonsguide.mod.stomp.StompManager; import kr.syeyoung.dungeonsguide.mod.utils.AhUtils; import kr.syeyoung.dungeonsguide.mod.utils.BlockCache; import kr.syeyoung.dungeonsguide.mod.utils.TimeScoreUtil; @@ -238,6 +239,7 @@ public class DungeonsGuide implements DGInterface { progressbar.step("Opening connection"); + StompManager.getInstance().init(); registerEventsForge(cosmeticsManager = new CosmeticsManager()); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDgDebug.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDgDebug.java index ab69fec6..5b553bdc 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDgDebug.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDgDebug.java @@ -40,6 +40,10 @@ import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightPr import kr.syeyoung.dungeonsguide.mod.events.impl.DungeonLeftEvent; import kr.syeyoung.dungeonsguide.mod.features.AbstractFeature; import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.DomElementRegistry; +import kr.syeyoung.dungeonsguide.mod.guiv2.GuiScreenAdapter; +import kr.syeyoung.dungeonsguide.mod.guiv2.RootDom; +import kr.syeyoung.dungeonsguide.mod.guiv2.view.TestView; import kr.syeyoung.dungeonsguide.mod.party.PartyContext; import kr.syeyoung.dungeonsguide.mod.party.PartyManager; import kr.syeyoung.dungeonsguide.mod.utils.*; @@ -452,6 +456,13 @@ public class CommandDgDebug extends CommandBase { } catch (Exception e) { e.printStackTrace(); } + } else if ("testgui".equals(arg)) { + GuiScreenAdapter adapter = new GuiScreenAdapter(new TestView()); + new Thread(DungeonsGuide.THREAD_GROUP, () -> { + Minecraft.getMinecraft().addScheduledTask(() -> { + Minecraft.getMinecraft().displayGuiScreen(adapter); + }); + }).start(); } else { sender.addChatMessage(new ChatComponentText("ain't gonna find much anything here")); sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg loadrooms §7-§f Reloads dungeon roomdata.")); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/BindableAttribute.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/BindableAttribute.java new file mode 100644 index 00000000..2070aef3 --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/BindableAttribute.java @@ -0,0 +1,99 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2022 cyoung06 (syeyoung) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.mod.guiv2; + +import lombok.Getter; + +import java.util.*; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + +public class BindableAttribute<T> { + public BindableAttribute(Class<T> type) { + this.type = type; + initialized = false; + } + public BindableAttribute(Class<T> type, T defaultValue) { + this.type = type; + value = defaultValue; + initialized = true; + } + + private boolean initialized = false; + @Getter + private final Class<T> type; + private T value; + private List<BiConsumer<T,T>> onUpdates = new ArrayList<>(); + + private boolean updating = false; + public void setValue(T t) { + if (updating) return; + updating = true; + T old = this.value; + this.value = t; + if (!Objects.equals(t, old)) + for (BiConsumer<T, T> onUpdate : onUpdates) { + onUpdate.accept(old, value); + } + updating = false; + initialized = true; + } + public T getValue() { + return value; + } + + public void addOnUpdate(BiConsumer<T,T> onUpdate) { + onUpdates.add(onUpdate); + } + public void removeOnUpdate(BiConsumer<T,T> onUpdate) { + onUpdates.remove(onUpdate); + } + + private Set<BindableAttribute<T>> linkedWith = new HashSet<>(); + + private void boundSet(T old, T neu) { + setValue(neu); + } + + public void exportTo(BindableAttribute<T> bindableAttribute) { // This method has to be called by exporting bindable attribute + if (bindableAttribute.type != type) throw new IllegalArgumentException("Different type!!"); + + this.addOnUpdate(bindableAttribute::boundSet); + bindableAttribute.addOnUpdate(this::boundSet); + linkedWith.add(bindableAttribute); + + if (bindableAttribute.initialized) + setValue(bindableAttribute.getValue()); + else + bindableAttribute.setValue(getValue()); + } + + public void unexport(BindableAttribute<T> bindableAttribute) { + bindableAttribute.removeOnUpdate(this::boundSet); + removeOnUpdate(bindableAttribute::boundSet); + linkedWith.remove(bindableAttribute); + } + + public void unexportAll() { + Set<BindableAttribute<T>> copy = new HashSet<>(linkedWith); + for (BindableAttribute<T> tBindableAttribute : copy) { + unexport(tBindableAttribute); + } + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/Context.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/Context.java new file mode 100644 index 00000000..b05c1e65 --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/Context.java @@ -0,0 +1,31 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2022 cyoung06 (syeyoung) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.mod.guiv2; + +import java.util.HashMap; +import java.util.Map; + +// TODO: get rid of this and change it with tree walking. +public class Context { + public Map<String, Object> CONTEXT = new HashMap<>(); + + public <T> T getValue(Class<T> clazz, String key) { + return (T) CONTEXT.get(key); + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/DomElement.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/DomElement.java new file mode 100644 index 00000000..44c538d6 --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/DomElement.java @@ -0,0 +1,242 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2022 cyoung06 (syeyoung) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.mod.guiv2; + +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.Stack; +import kr.syeyoung.dungeonsguide.mod.guiv2.layouter.Layouter; +import kr.syeyoung.dungeonsguide.mod.guiv2.layouter.NullLayouter; +import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Position; +import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect; +import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Size; +import kr.syeyoung.dungeonsguide.mod.guiv2.renderer.DrawNothingRenderer; +import kr.syeyoung.dungeonsguide.mod.guiv2.renderer.Renderer; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +public class DomElement { + @Getter + @Setter(AccessLevel.PACKAGE) + private Widget widget; + @Getter + @Setter(AccessLevel.PACKAGE) + private Renderer renderer = DrawNothingRenderer.INSTANCE; // renders element itself. + @Getter + @Setter(AccessLevel.PACKAGE) + private Layouter layouter = NullLayouter.INSTANCE; // layouts subelements + + @Getter |
