aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/shedaniel/rei')
-rw-r--r--src/main/java/me/shedaniel/rei/client/ConfigHelper.java12
-rw-r--r--src/main/java/me/shedaniel/rei/client/REIConfig.java1
-rw-r--r--src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java43
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ConfigWidget.java44
4 files changed, 88 insertions, 12 deletions
diff --git a/src/main/java/me/shedaniel/rei/client/ConfigHelper.java b/src/main/java/me/shedaniel/rei/client/ConfigHelper.java
index 41996052e..ccc340af3 100644
--- a/src/main/java/me/shedaniel/rei/client/ConfigHelper.java
+++ b/src/main/java/me/shedaniel/rei/client/ConfigHelper.java
@@ -107,4 +107,16 @@ public class ConfigHelper {
return config.checkUpdates;
}
+ public void setCheckUpdates(boolean checkUpdates) {
+ config.checkUpdates = checkUpdates;
+ }
+
+ public boolean isMirrorItemPanel() {
+ return config.mirrorItemPanel;
+ }
+
+ public void setMirrorItemPanel(boolean mirrorItemPanel) {
+ config.mirrorItemPanel = mirrorItemPanel;
+ }
+
}
diff --git a/src/main/java/me/shedaniel/rei/client/REIConfig.java b/src/main/java/me/shedaniel/rei/client/REIConfig.java
index cdb5df330..b5b798371 100644
--- a/src/main/java/me/shedaniel/rei/client/REIConfig.java
+++ b/src/main/java/me/shedaniel/rei/client/REIConfig.java
@@ -13,5 +13,6 @@ public class REIConfig {
public boolean sideSearchField = false;
public String giveCommandPrefix = "/give";
public boolean checkUpdates = true;
+ public boolean mirrorItemPanel = false;
}
diff --git a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
index 3da3443cc..eb1daa9a4 100644
--- a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
+++ b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
@@ -62,7 +62,7 @@ public class ContainerScreenOverlay extends Screen {
}
});
page = MathHelper.clamp(page, 0, getTotalPage());
- widgets.add(new ButtonWidget(10, 10, 40, 20, "") {
+ widgets.add(new ButtonWidget(RoughlyEnoughItemsCore.getConfigHelper().isMirrorItemPanel() ? window.getScaledWidth() - 50 : 10, 10, 40, 20, "") {
@Override
public void draw(int int_1, int int_2, float float_1) {
this.text = getCheatModeText();
@@ -74,7 +74,7 @@ public class ContainerScreenOverlay extends Screen {
ClientHelper.setCheating(!ClientHelper.isCheating());
}
});
- widgets.add(new ButtonWidget(10, 35, 40, 20, I18n.translate("text.rei.config")) {
+ widgets.add(new ButtonWidget(RoughlyEnoughItemsCore.getConfigHelper().isMirrorItemPanel() ? window.getScaledWidth() - 50 : 10, 35, 40, 20, I18n.translate("text.rei.config")) {
@Override
public void onPressed(int button, double mouseX, double mouseY) {
ClientHelper.openConfigWindow(GuiHelper.getLastContainerScreen());
@@ -200,14 +200,22 @@ public class ContainerScreenOverlay extends Screen {
}
private Rectangle calculateBoundary() {
- int startX = GuiHelper.getLastMixinContainerScreen().getContainerLeft() + GuiHelper.getLastMixinContainerScreen().getContainerWidth() + 10;
- int width = window.getScaledWidth() - startX;
+ if (!RoughlyEnoughItemsCore.getConfigHelper().isMirrorItemPanel()) {
+ int startX = GuiHelper.getLastMixinContainerScreen().getContainerLeft() + GuiHelper.getLastMixinContainerScreen().getContainerWidth() + 10;
+ int width = window.getScaledWidth() - startX;
+ if (MinecraftClient.getInstance().currentScreen instanceof RecipeViewingWidgetScreen) {
+ RecipeViewingWidgetScreen widget = (RecipeViewingWidgetScreen) MinecraftClient.getInstance().currentScreen;
+ startX = widget.getBounds().x + widget.getBounds().width + 10;
+ width = window.getScaledWidth() - startX;
+ }
+ return new Rectangle(startX, 0, width, window.getScaledHeight());
+ }
+ int width = GuiHelper.getLastMixinContainerScreen().getContainerLeft() - 6;
if (MinecraftClient.getInstance().currentScreen instanceof RecipeViewingWidgetScreen) {
RecipeViewingWidgetScreen widget = (RecipeViewingWidgetScreen) MinecraftClient.getInstance().currentScreen;
- startX = widget.getBounds().x + widget.getBounds().width + 10;
- width = window.getScaledWidth() - startX;
+ width = widget.getBounds().x - 6;
}
- return new Rectangle(startX, 0, width, window.getScaledHeight());
+ return new Rectangle(4, 0, width, window.getScaledHeight());
}
private int getLeft() {
@@ -224,6 +232,8 @@ public class ContainerScreenOverlay extends Screen {
@Override
public boolean mouseScrolled(double amount) {
+ if (!GuiHelper.isOverlayVisible())
+ return false;
if (rectangle.contains(ClientHelper.getMouseLocation())) {
if (amount > 0 && buttonLeft.enabled)
buttonLeft.onPressed(0, 0, 0);
@@ -241,6 +251,12 @@ public class ContainerScreenOverlay extends Screen {
@Override
public boolean keyPressed(int int_1, int int_2, int int_3) {
+ if (ClientHelper.HIDE.matchesKey(int_1, int_2)) {
+ GuiHelper.toggleOverlayVisible();
+ return true;
+ }
+ if (!GuiHelper.isOverlayVisible())
+ return false;
for(GuiEventListener listener : listeners)
if (listener.keyPressed(int_1, int_2, int_3))
return true;
@@ -268,19 +284,24 @@ public class ContainerScreenOverlay extends Screen {
else if (ClientHelper.USAGE.matchesKey(int_1, int_2))
return ClientHelper.executeUsageKeyBind(this, itemStack);
}
- if (ClientHelper.HIDE.matchesKey(int_1, int_2)) {
- GuiHelper.toggleOverlayVisible();
- return true;
- }
return false;
}
@Override
public boolean charTyped(char char_1, int int_1) {
+ if (!GuiHelper.isOverlayVisible())
+ return false;
for(GuiEventListener listener : listeners)
if (listener.charTyped(char_1, int_1))
return true;
return super.charTyped(char_1, int_1);
}
+ @Override
+ public boolean mouseClicked(double double_1, double double_2, int int_1) {
+ if (!GuiHelper.isOverlayVisible())
+ return false;
+ return super.mouseClicked(double_1, double_2, int_1);
+ }
+
}
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/ConfigWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/ConfigWidget.java
index d1391d978..8637afd8a 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/ConfigWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/ConfigWidget.java
@@ -54,7 +54,7 @@ public class ConfigWidget extends Screen {
@Override
public void draw(int mouseX, int mouseY, float partialTicks) {
text = getTrueFalseText(RoughlyEnoughItemsCore.getConfigHelper().sideSearchField());
- String t = I18n.translate("text.rei.centre_searchbox");
+ String t = I18n.translate("text.rei.side_searchbox");
int width = fontRenderer.getStringWidth(t);
fontRenderer.drawWithShadow(t, this.x - width - 10, this.y + (this.height - 8) / 2, -1);
super.draw(mouseX, mouseY, partialTicks);
@@ -106,6 +106,48 @@ public class ConfigWidget extends Screen {
super.draw(int_1, int_2, float_1);
}
});
+ widgets.add(new ButtonWidget(window.getScaledWidth() / 2 - 20, 120, 40, 20, "") {
+ @Override
+ public void onPressed(int button, double mouseX, double mouseY) {
+ if (button == 0)
+ RoughlyEnoughItemsCore.getConfigHelper().setMirrorItemPanel(!RoughlyEnoughItemsCore.getConfigHelper().isMirrorItemPanel());
+ try {
+ RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void draw(int mouseX, int mouseY, float partialTicks) {
+ text = getTrueFalseText(RoughlyEnoughItemsCore.getConfigHelper().isMirrorItemPanel());
+ String t = I18n.translate("text.rei.mirror_rei");
+ int width = fontRenderer.getStringWidth(t);
+ fontRenderer.drawWithShadow(t, this.x - width - 10, this.y + (this.height - 8) / 2, -1);
+ super.draw(mouseX, mouseY, partialTicks);
+ }
+ });
+ widgets.add(new ButtonWidget(window.getScaledWidth() / 2 - 20, 150, 40, 20, "") {
+ @Override
+ public void onPressed(int button, double mouseX, double mouseY) {
+ if (button == 0)
+ RoughlyEnoughItemsCore.getConfigHelper().setCheckUpdates(!RoughlyEnoughItemsCore.getConfigHelper().checkUpdates());
+ try {
+ RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void draw(int mouseX, int mouseY, float partialTicks) {
+ text = getTrueFalseText(RoughlyEnoughItemsCore.getConfigHelper().checkUpdates());
+ String t = I18n.translate("text.rei.check_updates");
+ int width = fontRenderer.getStringWidth(t);
+ fontRenderer.drawWithShadow(t, this.x - width - 10, this.y + (this.height - 8) / 2, -1);
+ super.draw(mouseX, mouseY, partialTicks);
+ }
+ });
}
private String getTrueFalseText(boolean showCraftableOnlyButton) {