aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-08-18 19:19:14 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-08-18 19:19:14 +0800
commit866a775b643b1d729ccaf79e5e1772d481046246 (patch)
tree0babf3420f349a93a2bc4ebbdc09fa7c44bfc748 /src/main/java
parentd02fc1b8dbccefb88c50e4a8780fb8212960041b (diff)
downloadRoughlyEnoughItems-866a775b643b1d729ccaf79e5e1772d481046246.tar.gz
RoughlyEnoughItems-866a775b643b1d729ccaf79e5e1772d481046246.tar.bz2
RoughlyEnoughItems-866a775b643b1d729ccaf79e5e1772d481046246.zip
Close #140
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/me/shedaniel/rei/api/ConfigObject.java3
-rw-r--r--src/main/java/me/shedaniel/rei/api/DisplayHelper.java3
-rw-r--r--src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java6
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/SearchFieldLocation.java19
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java15
-rw-r--r--src/main/java/me/shedaniel/rei/utils/ClothScreenRegistry.java9
6 files changed, 43 insertions, 12 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();
}