diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-08-28 20:48:46 +0900 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-08-28 21:14:21 +0900 |
| commit | fb91ed996b01f986492de4007cb86be5e68ad192 (patch) | |
| tree | b1176be6374ac6d56094c9bcf2b48226b31e68ec /shared-internals/src | |
| parent | 94e323f75c17e297c33fba1d3afb5c47ae66a8ad (diff) | |
| download | RoughlyEnoughItems-fb91ed996b01f986492de4007cb86be5e68ad192.tar.gz RoughlyEnoughItems-fb91ed996b01f986492de4007cb86be5e68ad192.tar.bz2 RoughlyEnoughItems-fb91ed996b01f986492de4007cb86be5e68ad192.zip | |
More internal changes
Diffstat (limited to 'shared-internals/src')
4 files changed, 72 insertions, 1 deletions
diff --git a/shared-internals/src/main/java/me/shedaniel/rei/impl/client/gui/hints/HintProvider.java b/shared-internals/src/main/java/me/shedaniel/rei/impl/client/gui/hints/HintProvider.java index 66a9f6a20..475e48f44 100644 --- a/shared-internals/src/main/java/me/shedaniel/rei/impl/client/gui/hints/HintProvider.java +++ b/shared-internals/src/main/java/me/shedaniel/rei/impl/client/gui/hints/HintProvider.java @@ -27,6 +27,7 @@ import me.shedaniel.math.Color; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.impl.client.gui.menu.MenuAccess; import me.shedaniel.rei.impl.common.Internals; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -52,7 +53,7 @@ public interface HintProvider { Color getColor(); - List<HintButton> getButtons(); + List<HintButton> getButtons(MenuAccess access); record HintButton(Component name, Consumer<Rectangle> action) {} } diff --git a/shared-internals/src/main/java/me/shedaniel/rei/impl/client/gui/menu/MenuAccess.java b/shared-internals/src/main/java/me/shedaniel/rei/impl/client/gui/menu/MenuAccess.java new file mode 100644 index 000000000..79daeb3f0 --- /dev/null +++ b/shared-internals/src/main/java/me/shedaniel/rei/impl/client/gui/menu/MenuAccess.java @@ -0,0 +1,51 @@ +/* + * 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.menu; + +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.favorites.FavoriteMenuEntry; + +import java.util.Collection; +import java.util.UUID; +import java.util.function.Predicate; +import java.util.function.Supplier; + +public interface MenuAccess { + boolean isOpened(UUID uuid); + + boolean isAnyOpened(); + + boolean isInBounds(UUID uuid); + + void open(UUID uuid, Rectangle selfBounds, Supplier<Collection<FavoriteMenuEntry>> menuSupplier); + + void open(UUID uuid, Rectangle selfBounds, Supplier<Collection<FavoriteMenuEntry>> menuSupplier, Predicate<Point> or, Predicate<Point> and); + + void openOrClose(UUID uuid, Rectangle selfBounds, Supplier<Collection<FavoriteMenuEntry>> menuSupplier); + + boolean isValidPoint(Point point); + + void close(); +} diff --git a/shared-internals/src/main/java/me/shedaniel/rei/impl/client/search/AsyncSearchManager.java b/shared-internals/src/main/java/me/shedaniel/rei/impl/client/search/AsyncSearchManager.java index eab390d90..be9216e72 100644 --- a/shared-internals/src/main/java/me/shedaniel/rei/impl/client/search/AsyncSearchManager.java +++ b/shared-internals/src/main/java/me/shedaniel/rei/impl/client/search/AsyncSearchManager.java @@ -29,6 +29,7 @@ import me.shedaniel.rei.api.client.search.SearchFilter; import me.shedaniel.rei.api.client.search.SearchProvider; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.util.CollectionUtils; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -152,4 +153,10 @@ public class AsyncSearchManager implements SearchManager { public boolean matches(EntryStack<?> stack) { return filter.test(stack); } + + @Override + @Nullable + public SearchFilter getSearchFilter() { + return filter; + } } diff --git a/shared-internals/src/main/java/me/shedaniel/rei/impl/client/util/InternalEntryBounds.java b/shared-internals/src/main/java/me/shedaniel/rei/impl/client/util/InternalEntryBounds.java new file mode 100644 index 000000000..30569d0a0 --- /dev/null +++ b/shared-internals/src/main/java/me/shedaniel/rei/impl/client/util/InternalEntryBounds.java @@ -0,0 +1,12 @@ +package me.shedaniel.rei.impl.client.util; + +import me.shedaniel.rei.api.client.config.ConfigObject; +import net.minecraft.util.Mth; + +public class InternalEntryBounds { + private static final int SIZE = 18; + + public static int entrySize() { + return Mth.ceil(SIZE * ConfigObject.getInstance().getEntrySize()); + } +} |
