diff options
| author | shedaniel <daniel@shedaniel.me> | 2019-12-12 22:06:26 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2019-12-12 22:06:26 +0800 |
| commit | cbfc32fa44fec1ed91c7ff811a4755a504c46082 (patch) | |
| tree | d8bf9030a60111dad2e6932d08241f46206f1b17 /src/main/java/me/shedaniel/rei/impl | |
| parent | 652c00c4017223fa02d63eba474ba35faa3e12c9 (diff) | |
| download | RoughlyEnoughItems-cbfc32fa44fec1ed91c7ff811a4755a504c46082.tar.gz RoughlyEnoughItems-cbfc32fa44fec1ed91c7ff811a4755a504c46082.tar.bz2 RoughlyEnoughItems-cbfc32fa44fec1ed91c7ff811a4755a504c46082.zip | |
3.2.19
Diffstat (limited to 'src/main/java/me/shedaniel/rei/impl')
7 files changed, 35 insertions, 12 deletions
diff --git a/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java b/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java index 7ebcdea23..a87e7b0a6 100644 --- a/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java @@ -138,12 +138,12 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { @Override public boolean isCheating() { - return ConfigManager.getInstance().getConfig().isCheating(); + return ConfigObject.getInstance().isCheating(); } @Override public void setCheating(boolean cheating) { - ConfigManager.getInstance().getConfig().setCheating(cheating); + ConfigObject.getInstance().setCheating(cheating); ConfigManager.getInstance().saveConfig(); } @@ -173,7 +173,7 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { if (identifier == null) return false; String tagMessage = cheatedStack.copy().getTag() != null && !cheatedStack.copy().getTag().isEmpty() ? cheatedStack.copy().getTag().asString() : ""; - String og = cheatedStack.getCount() == 1 ? ConfigManager.getInstance().getConfig().getGiveCommand().replaceAll(" \\{count}", "") : ConfigManager.getInstance().getConfig().getGiveCommand(); + String og = cheatedStack.getCount() == 1 ? ConfigObject.getInstance().getGiveCommand().replaceAll(" \\{count}", "") : ConfigObject.getInstance().getGiveCommand(); String madeUpCommand = og.replaceAll("\\{player_name}", MinecraftClient.getInstance().player.getEntityName()).replaceAll("\\{item_name}", identifier.getPath()).replaceAll("\\{item_identifier}", identifier.toString()).replaceAll("\\{nbt}", tagMessage).replaceAll("\\{count}", String.valueOf(cheatedStack.getCount())); if (madeUpCommand.length() > 256) { madeUpCommand = og.replaceAll("\\{player_name}", MinecraftClient.getInstance().player.getEntityName()).replaceAll("\\{item_name}", identifier.getPath()).replaceAll("\\{item_identifier}", identifier.toString()).replaceAll("\\{nbt}", "").replaceAll("\\{count}", String.valueOf(cheatedStack.getCount())); @@ -250,9 +250,9 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { @Override public void openRecipeViewingScreen(Map<RecipeCategory<?>, List<RecipeDisplay>> map) { Screen screen = null; - if (ConfigManager.getInstance().getConfig().getRecipeScreenType() == RecipeScreenType.VILLAGER) + if (ConfigObject.getInstance().getRecipeScreenType() == RecipeScreenType.VILLAGER) screen = new VillagerRecipeViewingScreen(map); - else if (ConfigManager.getInstance().getConfig().getRecipeScreenType() == RecipeScreenType.UNSET) + else if (ConfigObject.getInstance().getRecipeScreenType() == RecipeScreenType.UNSET) screen = new PreRecipeViewingScreen(map); else screen = new RecipeViewingScreen(map); diff --git a/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java b/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java index a5f06e8d2..54185727b 100644 --- a/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java @@ -79,6 +79,14 @@ public class ConfigManagerImpl implements ConfigManager { entries.add(entry); return entries; }, field -> field.getType() == InputUtil.KeyCode.class, ConfigObject.AddInFrontKeyCode.class); + guiRegistry.registerPredicateProvider((i13n, field, config, defaults, guiProvider) -> { + KeyCodeEntry entry = ConfigEntryBuilder.create().startKeyCodeField(i13n, getUnsafely(field, config, null)) + .setDefaultValue(() -> getUnsafely(field, defaults)) + .setSaveConsumer(newValue -> setUnsafely(field, config, newValue)) + .build(); + entry.setAllowMouse(false); + return Collections.singletonList(entry); + }, field -> field.getType() == InputUtil.KeyCode.class); loadFavoredEntries(); RoughlyEnoughItemsCore.LOGGER.info("[REI] Config is loaded."); } diff --git a/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java b/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java index a4a11343b..8a4493ba9 100644 --- a/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java @@ -205,6 +205,16 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { } @Override + public boolean doDisplayFavoritesTooltip() { + return isFavoritesEnabled() && appearance.displayFavoritesTooltip; + } + + @Override + public boolean doDisplayFavoritesOnTheLeft() { + return appearance.displayFavoritesOnTheLeft; + } + + @Override public InputUtil.KeyCode getFavoriteKeybind() { return general.favoriteKeybind; } @@ -255,6 +265,8 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @Comment("Declares whether if entry list widget is scrolled.") private boolean scrollingEntryListWidget = false; private boolean snapToRows = false; + private boolean displayFavoritesOnTheLeft = true; + private boolean displayFavoritesTooltip = true; } public static class Technical { diff --git a/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java b/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java index 231c12185..24bb8df5d 100644 --- a/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java +++ b/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java @@ -8,7 +8,7 @@ package me.shedaniel.rei.impl; import com.google.common.collect.Lists; import me.shedaniel.math.api.Rectangle; import me.shedaniel.rei.api.ClientHelper; -import me.shedaniel.rei.api.ConfigManager; +import me.shedaniel.rei.api.ConfigObject; import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.gui.widget.QueuedTooltip; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler; @@ -157,7 +157,7 @@ public class FluidEntryStack extends AbstractEntryStack { if (amountTooltip != null) for (String s : amountTooltip.split("\n")) toolTip.add(s); } toolTip.addAll(getSetting(Settings.TOOLTIP_APPEND_EXTRA).value().apply(this)); - if (getSetting(Settings.TOOLTIP_APPEND_MOD).value().get() && ConfigManager.getInstance().getConfig().shouldAppendModNames()) { + if (getSetting(Settings.TOOLTIP_APPEND_MOD).value().get() && ConfigObject.getInstance().shouldAppendModNames()) { final String modString = ClientHelper.getInstance().getFormattedModFromIdentifier(Registry.FLUID.getId(fluid)); boolean alreadyHasMod = false; for (String s : toolTip) diff --git a/src/main/java/me/shedaniel/rei/impl/ItemEntryStack.java b/src/main/java/me/shedaniel/rei/impl/ItemEntryStack.java index af0103d58..5527804d8 100644 --- a/src/main/java/me/shedaniel/rei/impl/ItemEntryStack.java +++ b/src/main/java/me/shedaniel/rei/impl/ItemEntryStack.java @@ -9,7 +9,7 @@ import com.google.common.collect.Lists; import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.math.api.Rectangle; import me.shedaniel.rei.api.ClientHelper; -import me.shedaniel.rei.api.ConfigManager; +import me.shedaniel.rei.api.ConfigObject; import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.ItemStackRenderOverlayHook; import me.shedaniel.rei.gui.widget.QueuedTooltip; @@ -123,7 +123,7 @@ public class ItemEntryStack extends AbstractEntryStack { return null; List<String> toolTip = Lists.newArrayList(SearchArgument.tryGetItemStackToolTip(getItemStack(), true)); toolTip.addAll(getSetting(Settings.TOOLTIP_APPEND_EXTRA).value().apply(this)); - if (getSetting(Settings.TOOLTIP_APPEND_MOD).value().get() && ConfigManager.getInstance().getConfig().shouldAppendModNames()) { + if (getSetting(Settings.TOOLTIP_APPEND_MOD).value().get() && ConfigObject.getInstance().shouldAppendModNames()) { final String modString = ClientHelper.getInstance().getFormattedModFromItem(getItem()); boolean alreadyHasMod = false; for (String s : toolTip) diff --git a/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java b/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java index 05ed5c04b..a3b30271b 100644 --- a/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java +++ b/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java @@ -10,6 +10,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import me.shedaniel.cloth.hooks.ClothClientHooks; import me.shedaniel.rei.api.ConfigManager; +import me.shedaniel.rei.api.ConfigObject; import me.shedaniel.rei.gui.ContainerScreenOverlay; import me.shedaniel.rei.gui.OverlaySearchField; import me.shedaniel.rei.listeners.ContainerScreenHooks; @@ -70,11 +71,11 @@ public class ScreenHelper implements ClientModInitializer { } public static boolean isOverlayVisible() { - return ConfigManager.getInstance().getConfig().isOverlayVisible(); + return ConfigObject.getInstance().isOverlayVisible(); } public static void toggleOverlayVisible() { - ConfigManager.getInstance().getConfig().setOverlayVisible(!ConfigManager.getInstance().getConfig().isOverlayVisible()); + ConfigObject.getInstance().setOverlayVisible(!ConfigObject.getInstance().isOverlayVisible()); ConfigManager.getInstance().saveConfig(); } @@ -86,6 +87,7 @@ public class ScreenHelper implements ClientModInitializer { if (overlay == null || reset) { overlay = new ContainerScreenOverlay(); overlay.init(); + getSearchField().setFocused(false); } return overlay; } @@ -122,7 +124,7 @@ public class ScreenHelper implements ClientModInitializer { } public static boolean isDarkModeEnabled() { - return ConfigManager.getInstance().getConfig().isUsingDarkTheme(); + return ConfigObject.getInstance().isUsingDarkTheme(); } @Override diff --git a/src/main/java/me/shedaniel/rei/impl/SearchArgument.java b/src/main/java/me/shedaniel/rei/impl/SearchArgument.java index 74d4bf8fc..4ed121aa7 100644 --- a/src/main/java/me/shedaniel/rei/impl/SearchArgument.java +++ b/src/main/java/me/shedaniel/rei/impl/SearchArgument.java @@ -127,6 +127,7 @@ public class SearchArgument { TEXT, MOD, TOOLTIP, + TAG, ALWAYS } |
