diff options
| author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2023-01-13 13:11:13 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-13 13:11:13 +0900 |
| commit | 87df9a914624b295e3e93db621ed2a8256eaf846 (patch) | |
| tree | 538414a186e12b7ad1846462e8406c761a156a69 /mod/src/main/java/kr | |
| parent | d3f5b4df809fd03919952285a1906652097f00e6 (diff) | |
| download | Skyblock-Dungeons-Guide-87df9a914624b295e3e93db621ed2a8256eaf846.tar.gz Skyblock-Dungeons-Guide-87df9a914624b295e3e93db621ed2a8256eaf846.tar.bz2 Skyblock-Dungeons-Guide-87df9a914624b295e3e93db621ed2a8256eaf846.zip | |
Dg4.0 guisystem (#269)
* - XML Like configuration for GUI
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Stylesheets were never a good idea
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Ref's are always bindable
Signed-off-by: syeyoung <cyoung06@naver.com>
* - cool components
Column
Background (color_
Row
SizedBox
Stack
Padding
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Update copyright header v2
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Bunch of stuff
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Few more elements
Signed-off-by: syeyoung <cyoung06@naver.com>
* - View!!
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Better click handlign
- Popups
Signed-off-by: syeyoung <cyoung06@naver.com>
* - ComponentCreator for DX
- test view (for testin
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Column and Row shrink to crossAxisSize if its max is infinity
- Gui test.
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Load attributes after super constructor
- Fix Stackoverflow in RootDom.setCursor
- Test Gui Command
- Test Gui to testview.gui
- XML Parser settings to ignore comments
- Controller check if element is actually an element, not a textnode.
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Component Parent propagation
- better placeholder
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Line needs texture2d
Signed-off-by: syeyoung <cyoung06@naver.com>
* - igitignore update
Signed-off-by: syeyoung <cyoung06@naver.com>
* - gradle build file update
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Flexible
- Background uses singlehcildpassinglayouter
- Helper methods in ConstraintBox
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Line and Border
- add updating code
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Textfield
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Column and Row with flex elements when given maximum mainAxis now throws an error
- Column and Row when given maximum mainAxis now shrinks to children
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Better architecture
- I'll document it later on separate repo
Signed-off-by: syeyoung <cyoung06@naver.com>
* LGTM.
- Might change rendering architecture.
Separate child rendering and itself rendering
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Fix some typo's and issues
Signed-off-by: syeyoung <cyoung06@naver.com>
* - make it work
Signed-off-by: syeyoung <cyoung06@naver.com>
* - smth
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Button
Signed-off-by: syeyoung <cyoung06@naver.com>
* - colored button
- passthroughs
Signed-off-by: syeyoung <cyoung06@naver.com>
* - fix issue in text
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Delegating widgets and scrollbar
Signed-off-by: syeyoung <cyoung06@naver.com>
* - scrollbar
Signed-off-by: syeyoung <cyoung06@naver.com>
* - list
Signed-off-by: syeyoung <cyoung06@naver.com>
* - popup
- align
- stack now only propagates events to first child (lol)
Signed-off-by: syeyoung <cyoung06@naver.com>
* - Event propagation changes
- some presets
Signed-off-by: syeyoung <cyoung06@naver.com>
* - moving stuff
Signed-off-by: syeyoung <cyoung06@naver.com>
Signed-off-by: syeyoung <cyoung06@naver.com>
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 mod |
