diff options
Diffstat (limited to 'src')
9 files changed, 51 insertions, 21 deletions
diff --git a/src/main/java/me/shedaniel/rei/api/ConfigObject.java b/src/main/java/me/shedaniel/rei/api/ConfigObject.java index b2763a577..f60d6bc35 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigObject.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigObject.java @@ -8,6 +8,7 @@ package me.shedaniel.rei.api; import me.shedaniel.rei.gui.config.ItemCheatingMode; import me.shedaniel.rei.gui.config.ItemListOrdering; import me.shedaniel.rei.gui.config.RecipeScreenType; +import me.shedaniel.rei.gui.config.SearchFieldLocation; import me.zeroeightsix.fiber.tree.ConfigNode; public interface ConfigObject { @@ -34,7 +35,7 @@ public interface ConfigObject { boolean isLoadingDefaultPlugin(); - boolean isSideSearchField(); + SearchFieldLocation getSearchFieldLocation(); boolean isLeftHandSidePanel(); diff --git a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java index 33cc985ba..2fe8be295 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java @@ -7,6 +7,7 @@ package me.shedaniel.rei.api; import me.shedaniel.math.api.Rectangle; import me.shedaniel.rei.RoughlyEnoughItemsCore; +import me.shedaniel.rei.gui.config.SearchFieldLocation; import net.minecraft.util.ActionResult; import java.util.List; @@ -112,7 +113,7 @@ public interface DisplayHelper { * @return the item list bounds */ default Rectangle getItemListArea(Rectangle rectangle) { - return new Rectangle(rectangle.x + 1, rectangle.y + 2 + (RoughlyEnoughItemsCore.getConfigManager().getConfig().isEntryListWidgetScrolled() ? 0 : 22), rectangle.width - 2, rectangle.height - (RoughlyEnoughItemsCore.getConfigManager().getConfig().isSideSearchField() ? 27 + 22 : 27) + (!RoughlyEnoughItemsCore.getConfigManager().getConfig().isEntryListWidgetScrolled() ? 0 : 22)); + return new Rectangle(rectangle.x + 1, rectangle.y + 2 + (RoughlyEnoughItemsCore.getConfigManager().getConfig().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + (RoughlyEnoughItemsCore.getConfigManager().getConfig().isEntryListWidgetScrolled() ? 0 : 22), rectangle.width - 2, rectangle.height - (RoughlyEnoughItemsCore.getConfigManager().getConfig().getSearchFieldLocation() != SearchFieldLocation.CENTER ? 27 + 22 : 27) + (!RoughlyEnoughItemsCore.getConfigManager().getConfig().isEntryListWidgetScrolled() ? 0 : 22)); } /** diff --git a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index 4d7b513c5..bd21cf910 100644 --- a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -15,6 +15,7 @@ import me.shedaniel.rei.api.ClientHelper; import me.shedaniel.rei.api.DisplayHelper; import me.shedaniel.rei.api.Entry; import me.shedaniel.rei.api.RecipeHelper; +import me.shedaniel.rei.gui.config.SearchFieldLocation; import me.shedaniel.rei.gui.widget.*; import me.shedaniel.rei.impl.RecipeHelperImpl; import me.shedaniel.rei.impl.ScreenHelper; @@ -327,8 +328,11 @@ public class ContainerScreenOverlay extends Widget { private Rectangle getTextFieldArea() { int widthRemoved = RoughlyEnoughItemsCore.getConfigManager().getConfig().isCraftableFilterEnabled() ? 22 : 2; - if (RoughlyEnoughItemsCore.getConfigManager().getConfig().isSideSearchField()) + SearchFieldLocation searchFieldLocation = RoughlyEnoughItemsCore.getConfigManager().getConfig().getSearchFieldLocation(); + if (searchFieldLocation == SearchFieldLocation.BOTTOM_SIDE) return new Rectangle(rectangle.x + 2, window.getScaledHeight() - 22, rectangle.width - 6 - widthRemoved, 18); + if (searchFieldLocation == SearchFieldLocation.TOP_SIDE) + return new Rectangle(rectangle.x + 2, 4, rectangle.width - 6 - widthRemoved, 18); if (MinecraftClient.getInstance().currentScreen instanceof RecipeViewingScreen) { RecipeViewingScreen widget = (RecipeViewingScreen) MinecraftClient.getInstance().currentScreen; return new Rectangle(widget.getBounds().x, window.getScaledHeight() - 22, widget.getBounds().width - widthRemoved, 18); diff --git a/src/main/java/me/shedaniel/rei/gui/config/SearchFieldLocation.java b/src/main/java/me/shedaniel/rei/gui/config/SearchFieldLocation.java new file mode 100644 index 000000000..37bc7a0b9 --- /dev/null +++ b/src/main/java/me/shedaniel/rei/gui/config/SearchFieldLocation.java @@ -0,0 +1,19 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + +package me.shedaniel.rei.gui.config; + +import net.minecraft.client.resource.language.I18n; + +import java.util.Locale; + +public enum SearchFieldLocation { + CENTER, BOTTOM_SIDE, TOP_SIDE; + + @Override + public String toString() { + return I18n.translate("config.roughlyenoughitems.searchFieldLocation.%s", name().toLowerCase(Locale.ROOT)); + } +} diff --git a/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java b/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java index 9f3b11e68..5fc06cdd5 100644 --- a/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java @@ -6,10 +6,7 @@ package me.shedaniel.rei.impl; import me.shedaniel.rei.api.ConfigObject; -import me.shedaniel.rei.gui.config.ItemCheatingMode; -import me.shedaniel.rei.gui.config.ItemListOrdering; -import me.shedaniel.rei.gui.config.ItemListOrderingConfig; -import me.shedaniel.rei.gui.config.RecipeScreenType; +import me.shedaniel.rei.gui.config.*; import me.zeroeightsix.fiber.exception.FiberException; import me.zeroeightsix.fiber.tree.ConfigNode; import me.zeroeightsix.fiber.tree.ConfigValue; @@ -59,11 +56,11 @@ public class ConfigObjectImpl implements ConfigObject { .withName("loadDefaultPlugin") .build(); - private ConfigValue<Boolean> sideSearchField = ConfigValue.builder(Boolean.class) + private ConfigValue<SearchFieldLocation> sideSearchField = ConfigValue.builder(SearchFieldLocation.class) .withParent(appearance) - .withDefaultValue(false) + .withDefaultValue(SearchFieldLocation.CENTER) .withComment("Declares the position of the search field.") - .withName("sideSearchField") + .withName("searchFieldLocation") .build(); private ConfigValue<Boolean> mirrorItemPanel = ConfigValue.builder(Boolean.class) @@ -238,8 +235,8 @@ public class ConfigObjectImpl implements ConfigObject { } @Override - public boolean isSideSearchField() { - return sideSearchField.getValue().booleanValue(); + public SearchFieldLocation getSearchFieldLocation() { + return sideSearchField.getValue(); } @Override diff --git a/src/main/java/me/shedaniel/rei/utils/ClothScreenRegistry.java b/src/main/java/me/shedaniel/rei/utils/ClothScreenRegistry.java index dfda85b2b..df4cb4c0c 100644 --- a/src/main/java/me/shedaniel/rei/utils/ClothScreenRegistry.java +++ b/src/main/java/me/shedaniel/rei/utils/ClothScreenRegistry.java @@ -12,6 +12,7 @@ import me.shedaniel.rei.api.ConfigManager; import me.shedaniel.rei.gui.config.ItemCheatingMode; import me.shedaniel.rei.gui.config.ItemListOrderingConfig; import me.shedaniel.rei.gui.config.RecipeScreenType; +import me.shedaniel.rei.gui.config.SearchFieldLocation; import me.zeroeightsix.fiber.exception.FiberException; import me.zeroeightsix.fiber.tree.ConfigValue; import net.minecraft.client.gui.screen.Screen; @@ -57,6 +58,14 @@ public class ClothScreenRegistry { .setSaveConsumer(var -> configValue.setValue((ItemCheatingMode) var)) .setErrorSupplier(var -> error((List) configValue.getConstraints(), var, ItemCheatingMode.class)) .build(); + }).registerConfigEntryFunction(SearchFieldLocation.class, o -> { + ConfigValue<SearchFieldLocation> configValue = (ConfigValue<SearchFieldLocation>) o; + return configEntryBuilder.startEnumSelector("config.roughlyenoughitems." + configValue.getName(), SearchFieldLocation.class, configValue.getValue()) + .setDefaultValue(configValue.getDefaultValue()) + .setTooltip(splitLine(configValue.getComment())) + .setSaveConsumer(var -> configValue.setValue((SearchFieldLocation) var)) + .setErrorSupplier(var -> error((List) configValue.getConstraints(), var, SearchFieldLocation.class)) + .build(); }).build().getScreen(); } diff --git a/src/main/resources/assets/roughlyenoughitems/lang/en_us.json b/src/main/resources/assets/roughlyenoughitems/lang/en_us.json index fa26d0d4a..69b46ff52 100755 --- a/src/main/resources/assets/roughlyenoughitems/lang/en_us.json +++ b/src/main/resources/assets/roughlyenoughitems/lang/en_us.json @@ -96,9 +96,10 @@ "config.roughlyenoughitems.mirrorItemPanel": "Item List Position:", "config.roughlyenoughitems.mirrorItemPanel.boolean.true": "Left Side", "config.roughlyenoughitems.mirrorItemPanel.boolean.false": "Right Side", - "config.roughlyenoughitems.sideSearchField": "Search Field Position:", - "config.roughlyenoughitems.sideSearchField.boolean.true": "Left / Right Side", - "config.roughlyenoughitems.sideSearchField.boolean.false": "Middle", + "config.roughlyenoughitems.searchFieldLocation": "Search Field Position:", + "config.roughlyenoughitems.searchFieldLocation.bottom_side": "Bottom Left / Right", + "config.roughlyenoughitems.searchFieldLocation.top_side": "Top Left / Right", + "config.roughlyenoughitems.searchFieldLocation.center": "Middle", "config.roughlyenoughitems.villagerScreenPermanentScrollBar": "Villager Recipe Screen Scrollbar:", "config.roughlyenoughitems.villagerScreenPermanentScrollBar.boolean.true": "Permanent", "config.roughlyenoughitems.villagerScreenPermanentScrollBar.boolean.false": "Auto Fade Out", diff --git a/src/main/resources/assets/roughlyenoughitems/lang/ja_jp.json b/src/main/resources/assets/roughlyenoughitems/lang/ja_jp.json index a21c83ac3..d51f20d1a 100644 --- a/src/main/resources/assets/roughlyenoughitems/lang/ja_jp.json +++ b/src/main/resources/assets/roughlyenoughitems/lang/ja_jp.json @@ -84,9 +84,8 @@ "config.roughlyenoughitems.mirrorItemPanel": "アイテムリストの位置:", "config.roughlyenoughitems.mirrorItemPanel.boolean.true": "左", "config.roughlyenoughitems.mirrorItemPanel.boolean.false": "右", - "config.roughlyenoughitems.sideSearchField": "Search Field Position:", - "config.roughlyenoughitems.sideSearchField.boolean.true": "左 / 右", - "config.roughlyenoughitems.sideSearchField.boolean.false": "中間", + "config.roughlyenoughitems.searchFieldLocation": "Search Field Position:", + "config.roughlyenoughitems.searchFieldLocation.false": "中間", "config.roughlyenoughitems.villagerScreenPermanentScrollBar": "Villager Recipe Screen Scrollbar:", "config.roughlyenoughitems.villagerScreenPermanentScrollBar.boolean.true": "Permanent", "config.roughlyenoughitems.villagerScreenPermanentScrollBar.boolean.false": "Auto Fade Out", diff --git a/src/main/resources/assets/roughlyenoughitems/lang/zh_tw.json b/src/main/resources/assets/roughlyenoughitems/lang/zh_tw.json index fab9794c3..9d940c755 100644 --- a/src/main/resources/assets/roughlyenoughitems/lang/zh_tw.json +++ b/src/main/resources/assets/roughlyenoughitems/lang/zh_tw.json @@ -94,9 +94,8 @@ "config.roughlyenoughitems.mirrorItemPanel": "物品列表的位置:", "config.roughlyenoughitems.mirrorItemPanel.boolean.true": "左邊", "config.roughlyenoughitems.mirrorItemPanel.boolean.false": "右邊", - "config.roughlyenoughitems.sideSearchField": "搜索框的位置:", - "config.roughlyenoughitems.sideSearchField.boolean.true": "左 / 右邊", - "config.roughlyenoughitems.sideSearchField.boolean.false": "中間", + "config.roughlyenoughitems.searchFieldLocation": "搜索框的位置:", + "config.roughlyenoughitems.searchFieldLocation.center": "中間", "config.roughlyenoughitems.villagerScreenPermanentScrollBar": "合成介面的滾動條:", "config.roughlyenoughitems.villagerScreenPermanentScrollBar.boolean.true": "永久顯示", "config.roughlyenoughitems.villagerScreenPermanentScrollBar.boolean.false": "自動淡出", |
