aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/gui/widget
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/shedaniel/rei/gui/widget')
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ConfigWidget.java70
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/CraftableToggleButtonWidget.java6
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java10
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidgetGui.java2
4 files changed, 65 insertions, 23 deletions
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 1b5e01052..9519a949a 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/ConfigWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/ConfigWidget.java
@@ -1,7 +1,7 @@
package me.shedaniel.rei.gui.widget;
import com.google.common.collect.Lists;
-import me.shedaniel.rei.RoughlyEnoughItemsCore;
+import me.shedaniel.rei.client.ConfigHelper;
import me.shedaniel.rei.client.REIItemListOrdering;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;
@@ -43,9 +43,9 @@ public class ConfigWidget extends GuiScreen {
@Override
public void onPressed(int button, double mouseX, double mouseY) {
if (button == 0)
- RoughlyEnoughItemsCore.getConfigHelper().setSideSearchField(!RoughlyEnoughItemsCore.getConfigHelper().sideSearchField());
+ ConfigHelper.getInstance().setSideSearchField(!ConfigHelper.getInstance().sideSearchField());
try {
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ ConfigHelper.getInstance().saveConfig();
} catch (IOException e) {
e.printStackTrace();
}
@@ -53,8 +53,8 @@ public class ConfigWidget extends GuiScreen {
@Override
public void draw(int mouseX, int mouseY, float partialTicks) {
- text = getTrueFalseText(RoughlyEnoughItemsCore.getConfigHelper().sideSearchField());
- String t = I18n.format("text.rei.centre_searchbox");
+ text = getTrueFalseText(ConfigHelper.getInstance().sideSearchField());
+ String t = I18n.format("text.rei.side_searchbox");
int width = fontRenderer.getStringWidth(t);
fontRenderer.drawStringWithShadow(t, this.x - width - 10, this.y + (this.height - 8) / 2, -1);
super.draw(mouseX, mouseY, partialTicks);
@@ -64,9 +64,9 @@ public class ConfigWidget extends GuiScreen {
@Override
public void onPressed(int button, double mouseX, double mouseY) {
if (button == 0)
- RoughlyEnoughItemsCore.getConfigHelper().setShowCraftableOnlyButton(!RoughlyEnoughItemsCore.getConfigHelper().showCraftableOnlyButton());
+ ConfigHelper.getInstance().setShowCraftableOnlyButton(!ConfigHelper.getInstance().showCraftableOnlyButton());
try {
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ ConfigHelper.getInstance().saveConfig();
} catch (IOException e) {
e.printStackTrace();
}
@@ -74,7 +74,7 @@ public class ConfigWidget extends GuiScreen {
@Override
public void draw(int mouseX, int mouseY, float partialTicks) {
- text = getTrueFalseText(RoughlyEnoughItemsCore.getConfigHelper().showCraftableOnlyButton());
+ text = getTrueFalseText(ConfigHelper.getInstance().showCraftableOnlyButton());
String t = I18n.format("text.rei.enable_craftable_only");
int width = fontRenderer.getStringWidth(t);
fontRenderer.drawStringWithShadow(t, this.x - width - 10, this.y + (this.height - 8) / 2, -1);
@@ -84,14 +84,14 @@ public class ConfigWidget extends GuiScreen {
widgets.add(new ButtonWidget(window.getScaledWidth() / 2 - 90, 90, 150, 20, "") {
@Override
public void onPressed(int button, double mouseX, double mouseY) {
- int index = Arrays.asList(REIItemListOrdering.values()).indexOf(RoughlyEnoughItemsCore.getConfigHelper().getItemListOrdering()) + 1;
+ int index = Arrays.asList(REIItemListOrdering.values()).indexOf(ConfigHelper.getInstance().getItemListOrdering()) + 1;
if (index >= REIItemListOrdering.values().length) {
index = 0;
- RoughlyEnoughItemsCore.getConfigHelper().setAscending(!RoughlyEnoughItemsCore.getConfigHelper().isAscending());
+ ConfigHelper.getInstance().setAscending(!ConfigHelper.getInstance().isAscending());
}
- RoughlyEnoughItemsCore.getConfigHelper().setItemListOrdering(REIItemListOrdering.values()[index]);
+ ConfigHelper.getInstance().setItemListOrdering(REIItemListOrdering.values()[index]);
try {
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ ConfigHelper.getInstance().saveConfig();
} catch (IOException e) {
e.printStackTrace();
}
@@ -100,12 +100,54 @@ public class ConfigWidget extends GuiScreen {
@Override
public void draw(int int_1, int int_2, float float_1) {
RenderHelper.disableStandardItemLighting();
- this.text = I18n.format("text.rei.list_ordering_button", I18n.format(RoughlyEnoughItemsCore.getConfigHelper().getItemListOrdering().getNameTranslationKey()), I18n.format(RoughlyEnoughItemsCore.getConfigHelper().isAscending() ? "ordering.rei.ascending" : "ordering.rei.descending"));
+ this.text = I18n.format("text.rei.list_ordering_button", I18n.format(ConfigHelper.getInstance().getItemListOrdering().getNameTranslationKey()), I18n.format(ConfigHelper.getInstance().isAscending() ? "ordering.rei.ascending" : "ordering.rei.descending"));
String t = I18n.format("text.rei.list_ordering") + ": ";
- drawString(Minecraft.getInstance().fontRenderer, t, parent.width / 2 - 95 - Minecraft.getInstance().fontRenderer.getStringWidth(t), 90 + 6, -1);
+ fontRenderer.drawStringWithShadow(t, parent.width / 2 - 95 - Minecraft.getInstance().fontRenderer.getStringWidth(t), 90 + 6, -1);
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)
+ ConfigHelper.getInstance().setMirrorItemPanel(!ConfigHelper.getInstance().isMirrorItemPanel());
+ try {
+ ConfigHelper.getInstance().saveConfig();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void draw(int mouseX, int mouseY, float partialTicks) {
+ text = getTrueFalseText(ConfigHelper.getInstance().isMirrorItemPanel());
+ String t = I18n.format("text.rei.mirror_rei");
+ int width = fontRenderer.getStringWidth(t);
+ fontRenderer.drawStringWithShadow(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)
+ ConfigHelper.getInstance().setCheckUpdates(!ConfigHelper.getInstance().checkUpdates());
+ try {
+ ConfigHelper.getInstance().saveConfig();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void draw(int mouseX, int mouseY, float partialTicks) {
+ text = getTrueFalseText(ConfigHelper.getInstance().checkUpdates());
+ String t = I18n.format("text.rei.check_updates");
+ int width = fontRenderer.getStringWidth(t);
+ fontRenderer.drawStringWithShadow(t, this.x - width - 10, this.y + (this.height - 8) / 2, -1);
+ super.draw(mouseX, mouseY, partialTicks);
+ }
+ });
}
private String getTrueFalseText(boolean showCraftableOnlyButton) {
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/CraftableToggleButtonWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/CraftableToggleButtonWidget.java
index 035d5cac6..93086e661 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/CraftableToggleButtonWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/CraftableToggleButtonWidget.java
@@ -1,7 +1,7 @@
package me.shedaniel.rei.gui.widget;
-import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.client.ClientHelper;
+import me.shedaniel.rei.client.ConfigHelper;
import me.shedaniel.rei.client.GuiHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
@@ -42,14 +42,14 @@ public abstract class CraftableToggleButtonWidget extends ButtonWidget {
Minecraft.getInstance().getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.zLevel = 100f;
- this.drawTexturedModalRect(x, y, (56 + (RoughlyEnoughItemsCore.getConfigHelper().craftableOnly() ? 0 : 20)), 202, 20, 20);
+ this.drawTexturedModalRect(x, y, (56 + (ConfigHelper.getInstance().craftableOnly() ? 0 : 20)), 202, 20, 20);
this.zLevel = 0f;
if (getBounds().contains(mouseX, mouseY))
drawTooltip();
}
private void drawTooltip() {
- GuiHelper.getLastOverlay().addTooltip(new QueuedTooltip(ClientHelper.getMouseLocation(), Arrays.asList(I18n.format(RoughlyEnoughItemsCore.getConfigHelper().craftableOnly() ? "text.rei.showing_craftable" : "text.rei.showing_all"))));
+ GuiHelper.getLastOverlay().addTooltip(new QueuedTooltip(ClientHelper.getMouseLocation(), Arrays.asList(I18n.format(ConfigHelper.getInstance().craftableOnly() ? "text.rei.showing_craftable" : "text.rei.showing_all"))));
}
}
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java b/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java
index d2c7ef467..a413add52 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java
@@ -103,7 +103,7 @@ public class ItemListOverlay extends Gui implements IWidget {
List<ItemStack> os = new LinkedList<>(ol), stacks = Lists.newArrayList(), finalStacks = Lists.newArrayList();
List<ItemGroup> itemGroups = new LinkedList<>(Arrays.asList(ItemGroup.GROUPS));
itemGroups.add(null);
- REIItemListOrdering ordering = RoughlyEnoughItemsCore.getConfigHelper().getItemListOrdering();
+ REIItemListOrdering ordering = ConfigHelper.getInstance().getItemListOrdering();
if (ordering != REIItemListOrdering.REGISTRY)
Collections.sort(os, (itemStack, t1) -> {
if (ordering.equals(REIItemListOrdering.NAME))
@@ -112,7 +112,7 @@ public class ItemListOverlay extends Gui implements IWidget {
return itemGroups.indexOf(itemStack.getItem().getGroup()) - itemGroups.indexOf(t1.getItem().getGroup());
return 0;
});
- if (!RoughlyEnoughItemsCore.getConfigHelper().isAscending())
+ if (!ConfigHelper.getInstance().isAscending())
Collections.reverse(os);
String[] splitSearchTerm = StringUtils.splitByWholeSeparatorPreserveAllTokens(searchTerm, "|");
Arrays.stream(splitSearchTerm).forEachOrdered(s -> {
@@ -135,14 +135,14 @@ public class ItemListOverlay extends Gui implements IWidget {
});
if (splitSearchTerm.length == 0)
stacks.addAll(os);
- List<ItemStack> workingItems = RoughlyEnoughItemsCore.getConfigHelper().craftableOnly() && inventoryItems.size() > 0 ? new ArrayList<>() : new LinkedList<>(ol);
- if (RoughlyEnoughItemsCore.getConfigHelper().craftableOnly()) {
+ List<ItemStack> workingItems = ConfigHelper.getInstance().craftableOnly() && inventoryItems.size() > 0 ? new ArrayList<>() : new LinkedList<>(ol);
+ if (ConfigHelper.getInstance().craftableOnly()) {
RecipeHelper.getInstance().findCraftableByItems(inventoryItems).forEach(workingItems::add);
workingItems.addAll(inventoryItems);
}
final List<ItemStack> finalWorkingItems = workingItems;
finalStacks.addAll(stacks.stream().filter(itemStack -> {
- if (!RoughlyEnoughItemsCore.getConfigHelper().craftableOnly())
+ if (!ConfigHelper.getInstance().craftableOnly())
return true;
for(ItemStack workingItem : finalWorkingItems)
if (itemStack.isItemEqual(workingItem))
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidgetGui.java b/src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidgetGui.java
index a1b810b98..22bc5d03c 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidgetGui.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidgetGui.java
@@ -178,7 +178,7 @@ public class RecipeViewingWidgetGui extends GuiScreen {
SpeedCraftAreaSupplier supplier = RecipeHelper.getInstance().getSpeedCraftButtonArea(selectedCategory);
final SpeedCraftFunctional functional = getSpeedCraftFunctionalByCategory(GuiHelper.getLastGuiContainer(), selectedCategory);
if (page * getRecipesPerPage() < categoriesMap.get(selectedCategory).size()) {
- final Supplier<IRecipeDisplay> topDisplaySupplier = () -> categoriesMap.get(selectedCategory).get(page * getRecipesPerPage());
+ final Supplier<IRecipeDisplay> topDisplaySupplier = () -> categoriesMap.get(selectedCategory).get(page * getRecipesPerPage());
final Rectangle topBounds = new Rectangle((int) getBounds().getCenterX() - 75, getBounds().y + 40, 150, selectedCategory.usesFullPage() ? 140 : 66);
widgets.addAll(selectedCategory.setupDisplay(topDisplaySupplier, topBounds));
if (supplier != null)