diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-08-27 13:23:37 +0900 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-08-27 13:23:37 +0900 |
| commit | 03b0adcf960c5e462fddc8e045b146a8c727670c (patch) | |
| tree | dcd998806437b6fea4e6ce0d34f5ddf97404d674 /runtime-frontend | |
| parent | 1ba613d9c97e722e76f459162de2e1a1c9e875bb (diff) | |
| download | RoughlyEnoughItems-03b0adcf960c5e462fddc8e045b146a8c727670c.tar.gz RoughlyEnoughItems-03b0adcf960c5e462fddc8e045b146a8c727670c.tar.bz2 RoughlyEnoughItems-03b0adcf960c5e462fddc8e045b146a8c727670c.zip | |
Refactors to overlays and reiruntime
Diffstat (limited to 'runtime-frontend')
12 files changed, 96 insertions, 25 deletions
diff --git a/runtime-frontend/overlay/src/main/java/me/shedaniel/rei/impl/client/gui/overlay/EntryListProvider.java b/runtime-frontend/overlay/src/main/java/me/shedaniel/rei/impl/client/gui/overlay/EntryListProvider.java new file mode 100644 index 000000000..8ad40444b --- /dev/null +++ b/runtime-frontend/overlay/src/main/java/me/shedaniel/rei/impl/client/gui/overlay/EntryListProvider.java @@ -0,0 +1,9 @@ +package me.shedaniel.rei.impl.client.gui.overlay; + +import me.shedaniel.rei.api.client.overlay.OverlayListWidget; +import org.jetbrains.annotations.ApiStatus; + +@ApiStatus.Internal +public interface EntryListProvider { + OverlayListWidget getEntryList(); +} diff --git a/runtime-frontend/overlay/src/main/java/me/shedaniel/rei/impl/client/gui/overlay/FavoritesListProvider.java b/runtime-frontend/overlay/src/main/java/me/shedaniel/rei/impl/client/gui/overlay/FavoritesListProvider.java new file mode 100644 index 000000000..07e329074 --- /dev/null +++ b/runtime-frontend/overlay/src/main/java/me/shedaniel/rei/impl/client/gui/overlay/FavoritesListProvider.java @@ -0,0 +1,11 @@ +package me.shedaniel.rei.impl.client.gui.overlay; + +import me.shedaniel.rei.api.client.overlay.OverlayListWidget; +import org.jetbrains.annotations.ApiStatus; + +import java.util.Optional; + +@ApiStatus.Internal +public interface FavoritesListProvider { + Optional<OverlayListWidget> getFavoritesList(); +} diff --git a/runtime-frontend/overlay/src/main/java/me/shedaniel/rei/impl/client/gui/overlay/TooltipQueueImpl.java b/runtime-frontend/overlay/src/main/java/me/shedaniel/rei/impl/client/gui/overlay/TooltipQueueImpl.java new file mode 100644 index 000000000..de285ef68 --- /dev/null +++ b/runtime-frontend/overlay/src/main/java/me/shedaniel/rei/impl/client/gui/overlay/TooltipQueueImpl.java @@ -0,0 +1,57 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.impl.client.gui.overlay; + +import com.google.common.collect.Lists; +import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.client.gui.widgets.TooltipQueue; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +import java.util.List; +import java.util.Objects; + +@ApiStatus.Internal +public final class TooltipQueueImpl implements TooltipQueue { + private final List<Tooltip> tooltips = Lists.newArrayList(); + + @Override + public void queue(@Nullable Tooltip tooltip) { + if (tooltip != null) + tooltips.add(tooltip); + } + + @Override + public void clear() { + tooltips.clear(); + } + + @Override + @Nullable + public Tooltip get() { + return tooltips.stream().filter(Objects::nonNull) + .reduce((tooltip, tooltip2) -> tooltip2) + .orElse(null); + } +} diff --git a/runtime-frontend/overlay/src/main/resources/META-INF/services/me.shedaniel.rei.api.client.gui.widgets.TooltipQueue b/runtime-frontend/overlay/src/main/resources/META-INF/services/me.shedaniel.rei.api.client.gui.widgets.TooltipQueue new file mode 100644 index 000000000..3c1bf18e1 --- /dev/null +++ b/runtime-frontend/overlay/src/main/resources/META-INF/services/me.shedaniel.rei.api.client.gui.widgets.TooltipQueue @@ -0,0 +1 @@ +me.shedaniel.rei.impl.client.gui.overlay.TooltipQueueImpl
\ No newline at end of file diff --git a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ArrowWidget.java b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ArrowWidget.java index aba9ae7b8..8afb30220 100644 --- a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ArrowWidget.java +++ b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ArrowWidget.java @@ -29,6 +29,7 @@ import me.shedaniel.clothconfig2.api.animator.NumberAnimator; import me.shedaniel.clothconfig2.api.animator.ValueAnimator; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIRuntime; +import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.widgets.Arrow; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.util.Mth; @@ -41,7 +42,7 @@ final class ArrowWidget extends Arrow { private Rectangle bounds; private double animationDuration = -1; private final NumberAnimator<Float> darkBackgroundAlpha = ValueAnimator.ofFloat() - .withConvention(() -> REIRuntime.getInstance().isDarkThemeEnabled() ? 1.0F : 0.0F, ValueAnimator.typicalTransitionTime()) + .withConvention(() -> ConfigObject.getInstance().isUsingDarkTheme() ? 1.0F : 0.0F, ValueAnimator.typicalTransitionTime()) .asFloat(); public ArrowWidget(Rectangle bounds) { diff --git a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/BatchedEntryRendererManager.java b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/BatchedSlotsImpl.java index 8626c30fc..dc1b2e4dc 100644 --- a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/BatchedEntryRendererManager.java +++ b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/BatchedSlotsImpl.java @@ -49,7 +49,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; -final class BatchedEntryRendererManager extends BatchedSlots implements ForwardingList<Slot> { +final class BatchedSlotsImpl extends BatchedSlots implements ForwardingList<Slot> { private final boolean fastEntryRendering = ConfigObject.getInstance().doesFastEntryRendering(); private final Int2ObjectMap<List<Object>> grouping = new Int2ObjectOpenHashMap<>(); private final List<Slot> toRender = new ArrayList<>(); @@ -59,14 +59,8 @@ final class BatchedEntryRendererManager extends BatchedSlots implements Forwardi public MutableInt debugSize = new MutableInt(); public MutableLong debugTime = new MutableLong(); - public BatchedEntryRendererManager() { - } - - public BatchedEntryRendererManager(Collection<? extends Slot> widgets) { - addAll(widgets); - } - - public boolean isFastEntryRendering() { + @Override + public boolean isBatched() { return fastEntryRendering; } @@ -82,11 +76,6 @@ final class BatchedEntryRendererManager extends BatchedSlots implements Forwardi } @Override - public boolean isBatched() { - return isFastEntryRendering(); - } - - @Override public void addDebugger(MutableInt size, MutableLong time) { this.debug = true; this.debugSize = size; diff --git a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/BurningFireWidget.java b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/BurningFireWidget.java index 550f98626..4140de261 100644 --- a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/BurningFireWidget.java +++ b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/BurningFireWidget.java @@ -29,6 +29,7 @@ import me.shedaniel.clothconfig2.api.animator.NumberAnimator; import me.shedaniel.clothconfig2.api.animator.ValueAnimator; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIRuntime; +import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.widgets.BurningFire; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.util.Mth; @@ -41,7 +42,7 @@ final class BurningFireWidget extends BurningFire { private Rectangle bounds; private double animationDuration = -1; private final NumberAnimator<Float> darkBackgroundAlpha = ValueAnimator.ofFloat() - .withConvention(() -> REIRuntime.getInstance().isDarkThemeEnabled() ? 1.0F : 0.0F, ValueAnimator.typicalTransitionTime()) + .withConvention(() -> ConfigObject.getInstance().isUsingDarkTheme() ? 1.0F : 0.0F, ValueAnimator.typicalTransitionTime()) .asFloat(); public BurningFireWidget(Rectangle bounds) { diff --git a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ButtonWidget.java b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ButtonWidget.java index f7efdc712..ae46a15d4 100644 --- a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ButtonWidget.java +++ b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ButtonWidget.java @@ -32,6 +32,7 @@ import me.shedaniel.math.Color; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIRuntime; +import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.widgets.Button; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import net.minecraft.client.gui.GuiComponent; @@ -78,7 +79,7 @@ final class ButtonWidget extends Button { this.bounds = Objects.requireNonNull(rectangle); this.text = Objects.requireNonNull(text); this.darkBackground = ValueAnimator.ofColor() - .withConvention(() -> Color.ofTransparent(REIRuntime.getInstance().isDarkThemeEnabled() ? 0xFFFFFFFF : 0x00FFFFFF), ValueAnimator.typicalTransitionTime()); + .withConvention(() -> Color.ofTransparent(ConfigObject.getInstance().isUsingDarkTheme() ? 0xFFFFFFFF : 0x00FFFFFF), ValueAnimator.typicalTransitionTime()); this.alpha = ValueProvider.constant(1.0); } @@ -303,7 +304,7 @@ final class ButtonWidget extends Button { } protected void renderBackground(PoseStack matrices, int x, int y, int width, int height, int textureOffset) { - renderBackground(matrices, x, y, width, height, textureOffset, REIRuntime.getInstance().isDarkThemeEnabled(), Color.ofTransparent(0xFFFFFFFF)); + renderBackground(matrices, x, y, width, height, textureOffset, ConfigObject.getInstance().isUsingDarkTheme(), Color.ofTransparent(0xFFFFFFFF)); } protected void renderBackground(PoseStack matrices, int x, int y, int width, int height, int textureOffset, boolean dark, Color color) { diff --git a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/EntryWidget.java b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/EntryWidget.java index b830b7d59..e3e6052b1 100644 --- a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/EntryWidget.java +++ b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/EntryWidget.java @@ -72,7 +72,7 @@ final class EntryWidget extends Slot implements DraggableStackProviderWidget { private static long stackDisplayOffset = 0; private final NumberAnimator<Float> darkHighlightedAlpha = ValueAnimator.ofFloat() - .withConvention(() -> REIRuntime.getInstance().isDarkThemeEnabled() ? 1.0F : 0.0F, ValueAnimator.typicalTransitionTime()); + .withConvention(() -> ConfigObject.getInstance().isUsingDarkTheme() ? 1.0F : 0.0F, ValueAnimator.typicalTransitionTime()); private final Rectangle bounds; @ApiStatus.Internal private byte noticeMark = Slot.UN_MARKED; @@ -267,7 +267,7 @@ final class EntryWidget extends Slot implements DraggableStackProviderWidget { } private final NumberAnimator<Float> darkBackgroundAlpha = ValueAnimator.ofFloat() - .withConvention(() -> REIRuntime.getInstance().isDarkThemeEnabled() ? 1.0F : 0.0F, ValueAnimator.typicalTransitionTime()) + .withConvention(() -> ConfigObject.getInstance().isUsingDarkTheme() ? 1.0F : 0.0F, ValueAnimator.typicalTransitionTime()) .asFloat(); @Override diff --git a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/LabelWidget.java b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/LabelWidget.java index b38e3b7fa..dd2da618b 100644 --- a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/LabelWidget.java +++ b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/LabelWidget.java @@ -31,6 +31,7 @@ import me.shedaniel.math.Color; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIRuntime; +import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.widgets.Label; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.api.client.gui.widgets.Widgets; @@ -57,9 +58,9 @@ final class LabelWidget extends Label { private boolean hasShadow = true; private boolean focusable = true; private ValueProvider<Color> color = ValueAnimator.ofColor() - .withConvention(() -> Color.ofTransparent(REIRuntime.getInstance().isDarkThemeEnabled() ? 0xFFBBBBBB : -1), 50); + .withConvention(() -> Color.ofTransparent(ConfigObject.getInstance().isUsingDarkTheme() ? 0xFFBBBBBB : -1), 50); private ValueProvider<Color> hoveredColor = ValueAnimator.ofColor() - .withConvention(() -> Color.ofTransparent(REIRuntime.getInstance().isDarkThemeEnabled() ? -1 : 0xFF66FFCC), 50); + .withConvention(() -> Color.ofTransparent(ConfigObject.getInstance().isUsingDarkTheme() ? -1 : 0xFF66FFCC), 50); private final ValueProvider<Color> finalColor = ValueAnimator.ofColor() .withConvention(() -> { if (!hovered) { @@ -169,7 +170,7 @@ final class LabelWidget extends Label { @Override public Label color(int lightModeColor, int darkModeColor) { this.color = ValueAnimator.ofColor() - .withConvention(() -> Color.ofTransparent(REIRuntime.getInstance().isDarkThemeEnabled() ? darkModeColor : lightModeColor), ValueAnimator.typicalTransitionTime()); + .withConvention(() -> Color.ofTransparent(ConfigObject.getInstance().isUsingDarkTheme() ? darkModeColor : lightModeColor), ValueAnimator.typicalTransitionTime()); this.color.completeImmediately(); this.finalColor.completeImmediately(); return this; diff --git a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/PanelWidget.java b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/PanelWidget.java index 98f90d6bf..cce955efd 100644 --- a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/PanelWidget.java +++ b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/PanelWidget.java @@ -52,7 +52,7 @@ final class PanelWidget extends Panel { private int yTextureOffset = RecipeBorderType.DEFAULT.getYOffset(); private Predicate<Panel> rendering = Predicates.alwaysTrue(); private final NumberAnimator<Float> darkBackgroundAlpha = ValueAnimator.ofFloat() - .withConvention(() -> REIRuntime.getInstance().isDarkThemeEnabled() ? 1.0F : 0.0F, ValueAnimator.typicalTransitionTime()) + .withConvention(() -> ConfigObject.getInstance().isUsingDarkTheme() ? 1.0F : 0.0F, ValueAnimator.typicalTransitionTime()) .asFloat(); public static boolean isRendering(Panel panel) { diff --git a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/WidgetsProviderImpl.java b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/WidgetsProviderImpl.java index 818a037dc..cae2c165c 100644 --- a/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/WidgetsProviderImpl.java +++ b/runtime-frontend/widgets/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/WidgetsProviderImpl.java @@ -162,6 +162,6 @@ public class WidgetsProviderImpl implements WidgetsProvider { @Override public BatchedSlots createBatchedSlots() { - return new BatchedEntryRendererManager(); + return new BatchedSlotsImpl(); } } |
