From 03b0adcf960c5e462fddc8e045b146a8c727670c Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 27 Aug 2022 13:23:37 +0900 Subject: Refactors to overlays and reiruntime --- .../impl/client/gui/overlay/EntryListProvider.java | 9 ++++ .../client/gui/overlay/FavoritesListProvider.java | 11 +++++ .../impl/client/gui/overlay/TooltipQueueImpl.java | 57 ++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 runtime-frontend/overlay/src/main/java/me/shedaniel/rei/impl/client/gui/overlay/EntryListProvider.java create mode 100644 runtime-frontend/overlay/src/main/java/me/shedaniel/rei/impl/client/gui/overlay/FavoritesListProvider.java create mode 100644 runtime-frontend/overlay/src/main/java/me/shedaniel/rei/impl/client/gui/overlay/TooltipQueueImpl.java (limited to 'runtime-frontend/overlay/src/main/java') 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 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 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); + } +} -- cgit