diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-06-17 18:13:58 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-06-17 18:13:58 +0800 |
| commit | 78f93b975c66b9345906e563e0f95c63ef285ac8 (patch) | |
| tree | 7afb62cf3ce91b38d9fccc1d284cfc4e5352c088 /runtime/src/main/java | |
| parent | d7ee88942e2085f9f5d4856c3de6de475b8b7733 (diff) | |
| download | RoughlyEnoughItems-78f93b975c66b9345906e563e0f95c63ef285ac8.tar.gz RoughlyEnoughItems-78f93b975c66b9345906e563e0f95c63ef285ac8.tar.bz2 RoughlyEnoughItems-78f93b975c66b9345906e563e0f95c63ef285ac8.zip | |
Fix duplicate display history
Diffstat (limited to 'runtime/src/main/java')
3 files changed, 14 insertions, 2 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java index d0ff40d6b..256d6b6de 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java @@ -78,6 +78,10 @@ public class DisplayEntry extends WidgetWithBounds { return uuid; } + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + public void markBoundsDirty() { widgets.reset(); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayHistoryManager.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayHistoryManager.java index 7f98c3122..87ef93cbe 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayHistoryManager.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayHistoryManager.java @@ -68,6 +68,7 @@ public class DisplayHistoryManager { if (CategoryRegistry.getInstance().tryGet(categoryIdentifier).isPresent()) { Display display = DisplaySerializerRegistry.getInstance().read(categoryIdentifier, tag.getCompound("DisplayHistoryData")); DisplayEntry newEntry = new DisplayEntry(parent, display, null); + newEntry.setUuid(UUID.fromString(uuid)); entries.put(newEntry.getUuid().toString(), newEntry); } } catch (Exception e) { @@ -109,7 +110,7 @@ public class DisplayHistoryManager { compoundTag.putBoolean("DisplayHistoryContains", false); compoundTag.putString("DisplayHistoryUUID", newEntry.getUuid().toString()); compoundTag.putString("DisplayHistoryCategory", display.getCategoryIdentifier().toString()); - displayHistory.add(compoundTag); + displayHistory.add(0, compoundTag); save(); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayHistoryWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayHistoryWidget.java index 6c95663aa..9450fbe39 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayHistoryWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayHistoryWidget.java @@ -61,6 +61,7 @@ public class DisplayHistoryWidget extends WidgetWithBounds implements DraggableC private final FavoritesListWidget parent; private final Rectangle bounds = new Rectangle(); private final NumberAnimator<Double> height; + private boolean ignoreNextMouse; private final NumberAnimator<Double> scroll = ValueAnimator.ofDouble(); @@ -263,7 +264,7 @@ public class DisplayHistoryWidget extends WidgetWithBounds implements DraggableC @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { for (DisplayEntry entry : DisplayHistoryManager.INSTANCE.getEntries(this)) { - if (entry.mouseClicked(mouseX, mouseY, button)) { + if (!ignoreNextMouse && entry.mouseClicked(mouseX, mouseY, button)) { return true; } } @@ -273,6 +274,11 @@ public class DisplayHistoryWidget extends WidgetWithBounds implements DraggableC @Override public boolean mouseReleased(double mouseX, double mouseY, int button) { + if (ignoreNextMouse) { + ignoreNextMouse = false; + return true; + } + Collection<DisplayEntry> entries = DisplayHistoryManager.INSTANCE.getEntries(this); for (DisplayEntry entry : entries) { @@ -343,6 +349,7 @@ public class DisplayHistoryWidget extends WidgetWithBounds implements DraggableC Point pos = context.getCurrentPosition(); if (containsMouse(pos)) { addDisplay(context.getCurrentBounds().clone(), display); + ignoreNextMouse = true; return true; } else { return false; |
