123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 |
- /*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020 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;
- import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
- import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
- import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry;
- import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment;
- import me.shedaniel.clothconfig2.api.Modifier;
- import me.shedaniel.clothconfig2.api.ModifierKeyCode;
- import me.shedaniel.rei.api.ConfigObject;
- import me.shedaniel.rei.api.EntryStack;
- import me.shedaniel.rei.gui.config.*;
- import me.shedaniel.rei.impl.ConfigObjectImpl.DontApplyFieldName;
- import me.shedaniel.rei.impl.ConfigObjectImpl.UseEnumSelectorInstead;
- import me.shedaniel.rei.impl.ConfigObjectImpl.UseFilteringScreen;
- import me.shedaniel.rei.impl.ConfigObjectImpl.UseSpecialRecipeTypeScreen;
- import net.minecraft.client.util.InputUtil;
- import org.jetbrains.annotations.ApiStatus;
- import java.lang.annotation.ElementType;
- import java.lang.annotation.Retention;
- import java.lang.annotation.RetentionPolicy;
- import java.lang.annotation.Target;
- import java.util.ArrayList;
- import java.util.List;
- @ApiStatus.Internal
- @Config(name = "roughlyenoughitems/config")
- public class ConfigObjectImpl implements ConfigObject, ConfigData {
-
- @ConfigEntry.Category("!general") @ConfigEntry.Gui.TransitiveObject @DontApplyFieldName public General general = new General();
- @ConfigEntry.Category("appearance") @ConfigEntry.Gui.TransitiveObject @DontApplyFieldName private Appearance appearance = new Appearance();
- @ConfigEntry.Category("modules") @ConfigEntry.Gui.TransitiveObject @DontApplyFieldName private Modules modules = new Modules();
- @ConfigEntry.Category("technical") @ConfigEntry.Gui.TransitiveObject @DontApplyFieldName private Technical technical = new Technical();
- @ConfigEntry.Category("performance") @ConfigEntry.Gui.TransitiveObject @DontApplyFieldName private Performance performance = new Performance();
- @ConfigEntry.Category("filtering") @ConfigEntry.Gui.TransitiveObject @DontApplyFieldName private Filtering filtering = new Filtering();
-
- @Override
- public boolean isOverlayVisible() {
- return general.overlayVisible;
- }
-
- @Override
- public void setOverlayVisible(boolean overlayVisible) {
- general.overlayVisible = overlayVisible;
- }
-
- @Override
- public boolean isCheating() {
- return general.cheating;
- }
-
- @Override
- public void setCheating(boolean cheating) {
- general.cheating = cheating;
- }
-
- @Override
- public ItemListOrdering getItemListOrdering() {
- return appearance.itemListOrdering.getOrdering();
- }
-
- @Override
- public boolean isItemListAscending() {
- return appearance.itemListOrdering.isAscending();
- }
-
- @Override
- public boolean isUsingDarkTheme() {
- return appearance.darkTheme;
- }
-
- @Override
- public boolean isToastDisplayedOnCopyIdentifier() {
- return modules.toastDisplayedOnCopyIdentifier;
- }
-
- @Override
- public boolean doesRenderEntryEnchantmentGlint() {
- return performance.renderEntryEnchantmentGlint;
- }
-
- @Override
- public boolean isEntryListWidgetScrolled() {
- return appearance.scrollingEntryListWidget;
- }
-
- @Override
- public boolean shouldAppendModNames() {
- return appearance.appendModNames;
- }
-
- @Override
- public RecipeScreenType getRecipeScreenType() {
- return appearance.recipeScreenType;
- }
-
- @Override
- public void setRecipeScreenType(RecipeScreenType recipeScreenType) {
- appearance.recipeScreenType = recipeScreenType;
- }
-
- @Override
- public boolean isLoadingDefaultPlugin() {
- return technical.loadDefaultPlugin;
- }
-
- @Override
- public SearchFieldLocation getSearchFieldLocation() {
- return appearance.searchFieldLocation;
- }
-
- @Override
- public boolean isLeftHandSidePanel() {
- return appearance.mirrorItemPanel;
- }
-
- @Override
- public boolean isCraftableFilterEnabled() {
- return modules.enableCraftableOnlyButton;
- }
-
- @Override
- public String getGamemodeCommand() {
- return technical.gamemodeCommand;
- }
-
- @Override
- public String getGiveCommand() {
- return technical.giveCommand;
- }
-
- @Override
- public String getWeatherCommand() {
- return technical.weatherCommand;
- }
-
- @Override
- public int getMaxRecipePerPage() {
- return appearance.maxRecipePerPage;
- }
-
- @Override
- public boolean doesShowUtilsButtons() {
- return modules.showUtilsButtons;
- }
-
- @Override
- public boolean doesDisableRecipeBook() {
- return modules.disableRecipeBook;
- }
-
- @Override
- public boolean doesFixTabCloseContainer() {
- return modules.fixTabCloseContainer;
- }
-
- @Override
- public boolean areClickableRecipeArrowsEnabled() {
- return appearance.clickableRecipeArrows;
- }
-
- @Override
- public RecipeBorderType getRecipeBorderType() {
- return appearance.recipeBorder;
- }
-
- @Override
- public boolean doesVillagerScreenHavePermanentScrollBar() {
- return appearance.villagerScreenPermanentScrollBar;
- }
-
- @Override
- public boolean doesRegisterRecipesInAnotherThread() {
- return technical.registerRecipesInAnotherThread;
- }
-
- @Override
- public boolean doesSnapToRows() {
- return appearance.snapToRows;
- }
-
- @Override
- public boolean isFavoritesEnabled() {
- return general.favoritesEnabled;
- }
-
- @Override
- public boolean doDisplayFavoritesTooltip() {
- return isFavoritesEnabled() && appearance.displayFavoritesTooltip;
- }
-
- @Override
- public boolean doDisplayFavoritesOnTheLeft() {
- return appearance.displayFavoritesOnTheLeft;
- }
-
- @Override
- public boolean doesFastEntryRendering() {
- return performance.newFastEntryRendering;
- }
-
- @Override
- public boolean doDebugRenderTimeRequired() {
- return technical.debugRenderTimeRequired;
- }
-
- @Override
- public boolean doSearchFavorites() {
- return appearance.searchFavorites;
- }
-
- @Override
- public ModifierKeyCode getFavoriteKeyCode() {
- return general.favoriteKeybind == null ? ModifierKeyCode.unknown() : general.favoriteKeybind;
- }
-
- @Override
- public ModifierKeyCode getRecipeKeybind() {
- return general.recipeKeybind == null ? ModifierKeyCode.unknown() : general.recipeKeybind;
- }
-
- @Override
- public ModifierKeyCode getUsageKeybind() {
- return general.usageKeybind == null ? ModifierKeyCode.unknown() : general.usageKeybind;
- }
-
- @Override
- public ModifierKeyCode getHideKeybind() {
- return general.hideKeybind == null ? ModifierKeyCode.unknown() : general.hideKeybind;
- }
-
- @Override
- public ModifierKeyCode getPreviousPageKeybind() {
- return general.previousPageKeybind == null ? ModifierKeyCode.unknown() : general.previousPageKeybind;
- }
-
- @Override
- public ModifierKeyCode getNextPageKeybind() {
- return general.nextPageKeybind == null ? ModifierKeyCode.unknown() : general.nextPageKeybind;
- }
-
- @Override
- public ModifierKeyCode getFocusSearchFieldKeybind() {
- return general.focusSearchFieldKeybind == null ? ModifierKeyCode.unknown() : general.focusSearchFieldKeybind;
- }
-
- @Override
- public ModifierKeyCode getCopyRecipeIdentifierKeybind() {
- return general.copyRecipeIdentifierKeybind == null ? ModifierKeyCode.unknown() : general.copyRecipeIdentifierKeybind;
- }
-
- @Override
- public ModifierKeyCode getExportImageKeybind() {
- return general.exportImageKeybind == null ? ModifierKeyCode.unknown() : general.exportImageKeybind;
- }
-
- @Override
- public double getEntrySize() {
- return appearance.entrySize;
- }
-
- @Deprecated
- @Override
- public General getGeneral() {
- return general;
- }
-
- @Override
- public boolean isUsingCompactTabs() {
- return appearance.useCompactTabs;
- }
-
- @Override
- public boolean isLowerConfigButton() {
- return appearance.lowerConfigButton;
- }
-
- @Override
- public List<EntryStack> getFavorites() {
- return general.favorites;
- }
-
- @Override
- public List<EntryStack> getFilteredStacks() {
- return filtering.filteredStacks;
- }
-
- @Override
- @ApiStatus.Experimental
- public boolean shouldAsyncSearch() {
- return performance.asyncSearch;
- }
-
- @Override
- @ApiStatus.Experimental
- public int getNumberAsyncSearch() {
- return performance.numberAsyncSearch;
- }
-
- @Override
- @ApiStatus.Experimental
- public boolean doDebugSearchTimeRequired() {
- return technical.debugSearchTimeRequired;
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target({ElementType.FIELD})
- @interface DontApplyFieldName {}
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target({ElementType.FIELD})
- @interface UseEnumSelectorInstead {}
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target({ElementType.FIELD})
- @interface UseSpecialRecipeTypeScreen {}
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target({ElementType.FIELD})
- @interface UseFilteringScreen {}
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target({ElementType.FIELD})
- @interface UsePercentage {
- double min();
-
- double max();
- }
-
- public static class General {
- @ConfigEntry.Gui.Excluded public List<EntryStack> favorites = new ArrayList<>();
- @Comment("Declares whether cheating mode is on.") private boolean cheating = false;
- @Comment("Declares whether REI is visible.") @ConfigEntry.Gui.Excluded private boolean overlayVisible = true;
- private boolean favoritesEnabled = true;
- private ModifierKeyCode recipeKeybind = ModifierKeyCode.of(InputUtil.Type.KEYSYM.createFromCode(82), Modifier.none());
- private ModifierKeyCode usageKeybind = ModifierKeyCode.of(InputUtil.Type.KEYSYM.createFromCode(85), Modifier.none());
- private ModifierKeyCode hideKeybind = ModifierKeyCode.of(InputUtil.Type.KEYSYM.createFromCode(79), Modifier.of(false, true, false));
- private ModifierKeyCode previousPageKeybind = ModifierKeyCode.unknown();
- private ModifierKeyCode nextPageKeybind = ModifierKeyCode.unknown();
- private ModifierKeyCode focusSearchFieldKeybind = ModifierKeyCode.unknown();
- private ModifierKeyCode copyRecipeIdentifierKeybind = ModifierKeyCode.unknown();
- private ModifierKeyCode favoriteKeybind = ModifierKeyCode.of(InputUtil.Type.KEYSYM.createFromCode(65), Modifier.none());
- @ConfigEntry.Gui.Excluded private ModifierKeyCode exportImageKeybind = ModifierKeyCode.unknown();
- }
-
- public static class Appearance {
- @UseSpecialRecipeTypeScreen private RecipeScreenType recipeScreenType = RecipeScreenType.UNSET;
- @Comment("Declares the appearance of REI windows.") private boolean darkTheme = false;
- @Comment("The ordering of the items on the item panel.") @UseEnumSelectorInstead
- private ItemListOrderingConfig itemListOrdering = ItemListOrderingConfig.REGISTRY_ASCENDING;
- @Comment("Declares the position of the search field.") @UseEnumSelectorInstead
- private SearchFieldLocation searchFieldLocation = SearchFieldLocation.CENTER;
- @Comment("Declares the position of the item list panel.") private boolean mirrorItemPanel = false;
- @Comment("Declares the maximum amount of recipes displayed in a page if possible.") @ConfigEntry.BoundedDiscrete(min = 2, max = 99)
- private int maxRecipePerPage = 3;
- private boolean clickableRecipeArrows = true;
- @Comment("Declares the appearance of recipe's border.") @UseEnumSelectorInstead private RecipeBorderType recipeBorder = RecipeBorderType.DEFAULT;
- @Comment("Declares whether REI should append mod names to item stacks.") private boolean appendModNames = true;
- @Comment("Declares how the scrollbar in villager screen should act.") private boolean villagerScreenPermanentScrollBar = false;
- @Comment("Declares whether entry list widget is scrolled.") private boolean scrollingEntryListWidget = false;
- @Comment("Declares whether scrolled entry list widget should snap to rows.") private boolean snapToRows = false;
- @Comment("Declares the location of the favorites list.") private boolean displayFavoritesOnTheLeft = true;
- @Comment("Declares whether favorites tooltip should be displayed.") private boolean displayFavoritesTooltip = false;
- @Comment("Declares whether favorites will be searched.") private boolean searchFavorites = true;
- @UsePercentage(min = 0.25, max = 4.0) private double entrySize = 1.0;
- private boolean useCompactTabs = true;
- private boolean lowerConfigButton = false;
- }
-
- public static class Technical {
- @Comment("To disable REI's default plugin.\nDon't change this unless you understand what you are doing!") private boolean loadDefaultPlugin = true;
- @Comment("Declares the command used to change gamemode.") private String gamemodeCommand = "/gamemode {gamemode}";
- @Comment("Declares the command used in servers to cheat items.") private String giveCommand = "/give {player_name} {item_identifier}{nbt} {count}";
- @Comment("Declares the command used to change weather.") private String weatherCommand = "/weather {weather}";
- private boolean registerRecipesInAnotherThread = true;
- private boolean debugRenderTimeRequired = false;
- @Comment("Experimental: Declares whether search time should be debugged.") private boolean debugSearchTimeRequired = false;
- }
-
- public static class Modules {
- @Comment("Declares whether the craftable filter button is enabled.") private boolean enableCraftableOnlyButton = true;
- private boolean toastDisplayedOnCopyIdentifier = true;
- @Comment("Declares whether the utils buttons are shown.") private boolean showUtilsButtons = false;
- @Comment("Declares whether REI should remove the recipe book.") private boolean disableRecipeBook = false;
- @Comment("Declares whether REI should fix closing container with tab.") private boolean fixTabCloseContainer = false;
- }
-
- public static class Performance {
- @Comment("Whether REI should render entry's enchantment glint") private boolean renderEntryEnchantmentGlint = true;
- private boolean newFastEntryRendering = true;
- @Comment("Experimental: Declares whether REI should search async.") private boolean asyncSearch = true;
- @Comment("Experimental: Declares how many entries should be grouped one async search.") @ConfigEntry.BoundedDiscrete(min = 25, max = 400)
- private int numberAsyncSearch = 50;
- }
-
- public static class Filtering {
- @UseFilteringScreen private List<EntryStack> filteredStacks = new ArrayList<>();
- }
- }
|