aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/gui/config/ConfigScreen.java
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-03-07 22:21:06 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-03-07 22:21:06 +0800
commit8cd1f1a9804f980c1666079c99bafb6330c77723 (patch)
tree449f74c31bf73a4106b2cb9bc7fb5635925b2328 /src/main/java/me/shedaniel/rei/gui/config/ConfigScreen.java
parente5909b2fa40428d2a25a4f727a49a4f4fc47ad01 (diff)
downloadRoughlyEnoughItems-8cd1f1a9804f980c1666079c99bafb6330c77723.tar.gz
RoughlyEnoughItems-8cd1f1a9804f980c1666079c99bafb6330c77723.tar.bz2
RoughlyEnoughItems-8cd1f1a9804f980c1666079c99bafb6330c77723.zip
Config with comments
Diffstat (limited to 'src/main/java/me/shedaniel/rei/gui/config/ConfigScreen.java')
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/ConfigScreen.java102
1 files changed, 53 insertions, 49 deletions
diff --git a/src/main/java/me/shedaniel/rei/gui/config/ConfigScreen.java b/src/main/java/me/shedaniel/rei/gui/config/ConfigScreen.java
index d1383c377..4af12577b 100644
--- a/src/main/java/me/shedaniel/rei/gui/config/ConfigScreen.java
+++ b/src/main/java/me/shedaniel/rei/gui/config/ConfigScreen.java
@@ -1,9 +1,11 @@
package me.shedaniel.rei.gui.config;
+import com.google.common.collect.Lists;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.client.ClientHelper;
import me.shedaniel.rei.client.GuiHelper;
-import me.shedaniel.rei.client.REIItemListOrdering;
+import me.shedaniel.rei.client.ItemListOrdering;
+import me.shedaniel.rei.gui.widget.QueuedTooltip;
import me.shedaniel.rei.gui.widget.TextFieldWidget;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.InputListener;
@@ -16,14 +18,17 @@ import net.minecraft.text.TranslatableTextComponent;
import java.awt.*;
import java.io.IOException;
import java.util.Arrays;
+import java.util.List;
public class ConfigScreen extends Screen {
+ private final List<QueuedTooltip> tooltipList;
private Screen parent;
private ConfigEntryListWidget entryListWidget;
public ConfigScreen(Screen parent) {
this.parent = parent;
+ this.tooltipList = Lists.newArrayList();
}
@Override
@@ -60,9 +65,9 @@ public class ConfigScreen extends Screen {
@Override
public boolean onPressed(int button, double mouseX, double mouseY) {
if (button == 0)
- RoughlyEnoughItemsCore.getConfigHelper().getConfig().sideSearchField = !RoughlyEnoughItemsCore.getConfigHelper().getConfig().sideSearchField;
+ RoughlyEnoughItemsCore.getConfigManager().getConfig().sideSearchField = !RoughlyEnoughItemsCore.getConfigManager().getConfig().sideSearchField;
try {
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ RoughlyEnoughItemsCore.getConfigManager().saveConfig();
} catch (IOException e) {
e.printStackTrace();
return false;
@@ -72,20 +77,20 @@ public class ConfigScreen extends Screen {
@Override
public String getText() {
- return getTrueFalseText(RoughlyEnoughItemsCore.getConfigHelper().getConfig().sideSearchField);
+ return getTrueFalseText(RoughlyEnoughItemsCore.getConfigManager().getConfig().sideSearchField);
}
}));
entryListWidget.configAddEntry(new ConfigEntry.ButtonConfigEntry(new TranslatableTextComponent("text.rei.config.list_ordering"), new ConfigEntry.ButtonConfigEntry.ConfigEntryButtonProvider() {
@Override
public boolean onPressed(int button, double mouseX, double mouseY) {
- int index = Arrays.asList(REIItemListOrdering.values()).indexOf(RoughlyEnoughItemsCore.getConfigHelper().getConfig().itemListOrdering) + 1;
- if (index >= REIItemListOrdering.values().length) {
+ int index = Arrays.asList(ItemListOrdering.values()).indexOf(RoughlyEnoughItemsCore.getConfigManager().getConfig().itemListOrdering) + 1;
+ if (index >= ItemListOrdering.values().length) {
index = 0;
- RoughlyEnoughItemsCore.getConfigHelper().getConfig().isAscending = !RoughlyEnoughItemsCore.getConfigHelper().getConfig().isAscending;
+ RoughlyEnoughItemsCore.getConfigManager().getConfig().isAscending = !RoughlyEnoughItemsCore.getConfigManager().getConfig().isAscending;
}
- RoughlyEnoughItemsCore.getConfigHelper().getConfig().itemListOrdering = REIItemListOrdering.values()[index];
+ RoughlyEnoughItemsCore.getConfigManager().getConfig().itemListOrdering = ItemListOrdering.values()[index];
try {
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ RoughlyEnoughItemsCore.getConfigManager().saveConfig();
} catch (IOException e) {
e.printStackTrace();
return false;
@@ -95,16 +100,16 @@ public class ConfigScreen extends Screen {
@Override
public String getText() {
- return I18n.translate("text.rei.config.list_ordering_button", I18n.translate(RoughlyEnoughItemsCore.getConfigHelper().getConfig().itemListOrdering.getNameTranslationKey()), I18n.translate(RoughlyEnoughItemsCore.getConfigHelper().getConfig().isAscending ? "ordering.rei.ascending" : "ordering.rei.descending"));
+ return I18n.translate("text.rei.config.list_ordering_button", I18n.translate(RoughlyEnoughItemsCore.getConfigManager().getConfig().itemListOrdering.getNameTranslationKey()), I18n.translate(RoughlyEnoughItemsCore.getConfigManager().getConfig().isAscending ? "ordering.rei.ascending" : "ordering.rei.descending"));
}
}));
entryListWidget.configAddEntry(new ConfigEntry.ButtonConfigEntry(new TranslatableTextComponent("text.rei.config.mirror_rei"), new ConfigEntry.ButtonConfigEntry.ConfigEntryButtonProvider() {
@Override
public boolean onPressed(int button, double mouseX, double mouseY) {
if (button == 0)
- RoughlyEnoughItemsCore.getConfigHelper().getConfig().mirrorItemPanel = !RoughlyEnoughItemsCore.getConfigHelper().getConfig().mirrorItemPanel;
+ RoughlyEnoughItemsCore.getConfigManager().getConfig().mirrorItemPanel = !RoughlyEnoughItemsCore.getConfigManager().getConfig().mirrorItemPanel;
try {
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ RoughlyEnoughItemsCore.getConfigManager().saveConfig();
} catch (IOException e) {
e.printStackTrace();
return false;
@@ -114,7 +119,7 @@ public class ConfigScreen extends Screen {
@Override
public String getText() {
- return getTrueFalseText(RoughlyEnoughItemsCore.getConfigHelper().getConfig().mirrorItemPanel);
+ return getTrueFalseText(RoughlyEnoughItemsCore.getConfigManager().getConfig().mirrorItemPanel);
}
}));
entryListWidget.configAddEntry(new ConfigEntry.CategoryTitleConfigEntry(new TranslatableTextComponent("text.rei.config.modules")));
@@ -122,9 +127,9 @@ public class ConfigScreen extends Screen {
@Override
public boolean onPressed(int button, double mouseX, double mouseY) {
if (button == 0)
- RoughlyEnoughItemsCore.getConfigHelper().getConfig().enableCraftableOnlyButton = !RoughlyEnoughItemsCore.getConfigHelper().getConfig().enableCraftableOnlyButton;
+ RoughlyEnoughItemsCore.getConfigManager().getConfig().enableCraftableOnlyButton = !RoughlyEnoughItemsCore.getConfigManager().getConfig().enableCraftableOnlyButton;
try {
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ RoughlyEnoughItemsCore.getConfigManager().saveConfig();
} catch (IOException e) {
e.printStackTrace();
return false;
@@ -134,16 +139,16 @@ public class ConfigScreen extends Screen {
@Override
public String getText() {
- return getTrueFalseText(RoughlyEnoughItemsCore.getConfigHelper().getConfig().enableCraftableOnlyButton);
+ return getTrueFalseText(RoughlyEnoughItemsCore.getConfigManager().getConfig().enableCraftableOnlyButton);
}
}));
entryListWidget.configAddEntry(new ConfigEntry.ButtonConfigEntry(new TranslatableTextComponent("text.rei.config.load_default_plugin"), new ConfigEntry.ButtonConfigEntry.ConfigEntryButtonProvider() {
@Override
public boolean onPressed(int button, double mouseX, double mouseY) {
if (button == 0)
- RoughlyEnoughItemsCore.getConfigHelper().getConfig().loadDefaultPlugin = !RoughlyEnoughItemsCore.getConfigHelper().getConfig().loadDefaultPlugin;
+ RoughlyEnoughItemsCore.getConfigManager().getConfig().loadDefaultPlugin = !RoughlyEnoughItemsCore.getConfigManager().getConfig().loadDefaultPlugin;
try {
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ RoughlyEnoughItemsCore.getConfigManager().saveConfig();
} catch (IOException e) {
e.printStackTrace();
return false;
@@ -153,26 +158,24 @@ public class ConfigScreen extends Screen {
@Override
public String getText() {
- return getTrueFalseText(RoughlyEnoughItemsCore.getConfigHelper().getConfig().loadDefaultPlugin);
+ return getTrueFalseText(RoughlyEnoughItemsCore.getConfigManager().getConfig().loadDefaultPlugin);
}
@Override
public void draw(me.shedaniel.rei.gui.widget.ButtonWidget button, Point mouse, float delta) {
button.draw(mouse.x, mouse.y, delta);
- if (button.isHighlighted(mouse)) {
- GuiLighting.disable();
- drawTooltip(Arrays.asList(I18n.translate("text.rei.config.load_default_plugin.restart_tooltip").split("\n")), mouse.x, mouse.y);
- GuiLighting.disable();
- }
+ if (button.isHighlighted(mouse))
+ tooltipList.add(QueuedTooltip.create(I18n.translate("text.rei.config.load_default_plugin.restart_tooltip").split("\n")));
+
}
}));
entryListWidget.configAddEntry(new ConfigEntry.ButtonConfigEntry(new TranslatableTextComponent("text.rei.config.disable_credits_button"), new ConfigEntry.ButtonConfigEntry.ConfigEntryButtonProvider() {
@Override
public boolean onPressed(int button, double mouseX, double mouseY) {
if (button == 0)
- RoughlyEnoughItemsCore.getConfigHelper().getConfig().disableCreditsButton = !RoughlyEnoughItemsCore.getConfigHelper().getConfig().disableCreditsButton;
+ RoughlyEnoughItemsCore.getConfigManager().getConfig().disableCreditsButton = !RoughlyEnoughItemsCore.getConfigManager().getConfig().disableCreditsButton;
try {
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ RoughlyEnoughItemsCore.getConfigManager().saveConfig();
} catch (IOException e) {
e.printStackTrace();
return false;
@@ -182,16 +185,16 @@ public class ConfigScreen extends Screen {
@Override
public String getText() {
- return getTrueFalseText(RoughlyEnoughItemsCore.getConfigHelper().getConfig().disableCreditsButton);
+ return getTrueFalseText(RoughlyEnoughItemsCore.getConfigManager().getConfig().disableCreditsButton);
}
}));
entryListWidget.configAddEntry(new ConfigEntry.ButtonConfigEntry(new TranslatableTextComponent("text.rei.config.enable_util_buttons"), new ConfigEntry.ButtonConfigEntry.ConfigEntryButtonProvider() {
@Override
public boolean onPressed(int button, double mouseX, double mouseY) {
if (button == 0)
- RoughlyEnoughItemsCore.getConfigHelper().getConfig().showUtilsButtons = !RoughlyEnoughItemsCore.getConfigHelper().getConfig().showUtilsButtons;
+ RoughlyEnoughItemsCore.getConfigManager().getConfig().showUtilsButtons = !RoughlyEnoughItemsCore.getConfigManager().getConfig().showUtilsButtons;
try {
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ RoughlyEnoughItemsCore.getConfigManager().saveConfig();
} catch (IOException e) {
e.printStackTrace();
return false;
@@ -201,7 +204,7 @@ public class ConfigScreen extends Screen {
@Override
public String getText() {
- return getTrueFalseText(RoughlyEnoughItemsCore.getConfigHelper().getConfig().showUtilsButtons);
+ return getTrueFalseText(RoughlyEnoughItemsCore.getConfigManager().getConfig().showUtilsButtons);
}
}));
entryListWidget.configAddEntry(new ConfigEntry.CategoryTitleConfigEntry(new TranslatableTextComponent("text.rei.config.advanced")));
@@ -209,15 +212,15 @@ public class ConfigScreen extends Screen {
@Override
public void onInitWidget(TextFieldWidget widget) {
widget.setMaxLength(99999);
- widget.setText(RoughlyEnoughItemsCore.getConfigHelper().getConfig().giveCommand);
+ widget.setText(RoughlyEnoughItemsCore.getConfigManager().getConfig().giveCommand);
widget.setSuggestion(I18n.translate("text.rei.give_command.suggestion"));
}
@Override
public void onUpdateText(TextFieldWidget button, String text) {
- RoughlyEnoughItemsCore.getConfigHelper().getConfig().giveCommand = text;
+ RoughlyEnoughItemsCore.getConfigManager().getConfig().giveCommand = text;
try {
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ RoughlyEnoughItemsCore.getConfigManager().saveConfig();
} catch (IOException e) {
e.printStackTrace();
}
@@ -226,25 +229,22 @@ public class ConfigScreen extends Screen {
@Override
public void draw(TextFieldWidget widget, Point mouse, float delta) {
widget.draw(mouse.x, mouse.y, delta);
- if (widget.isHighlighted(mouse)) {
- GuiLighting.disable();
- drawTooltip(Arrays.asList(I18n.translate("text.rei.give_command.tooltip").split("\n")), mouse.x, mouse.y);
- GuiLighting.disable();
- }
+ if (widget.isHighlighted(mouse))
+ tooltipList.add(QueuedTooltip.create(I18n.translate("text.rei.give_command.tooltip").split("\n")));
}
}));
entryListWidget.configAddEntry(new ConfigEntry.TextFieldConfigEntry(new TranslatableTextComponent("text.rei.gamemode_command"), new ConfigEntry.TextFieldConfigEntry.ConfigEntryTextFieldProvider() {
@Override
public void onInitWidget(TextFieldWidget widget) {
widget.setMaxLength(99999);
- widget.setText(RoughlyEnoughItemsCore.getConfigHelper().getConfig().gamemodeCommand);
+ widget.setText(RoughlyEnoughItemsCore.getConfigManager().getConfig().gamemodeCommand);
}
@Override
public void onUpdateText(TextFieldWidget button, String text) {
- RoughlyEnoughItemsCore.getConfigHelper().getConfig().gamemodeCommand = text;
+ RoughlyEnoughItemsCore.getConfigManager().getConfig().gamemodeCommand = text;
try {
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ RoughlyEnoughItemsCore.getConfigManager().saveConfig();
} catch (IOException e) {
e.printStackTrace();
}
@@ -254,14 +254,14 @@ public class ConfigScreen extends Screen {
@Override
public void onInitWidget(TextFieldWidget widget) {
widget.setMaxLength(99999);
- widget.setText(RoughlyEnoughItemsCore.getConfigHelper().getConfig().weatherCommand);
+ widget.setText(RoughlyEnoughItemsCore.getConfigManager().getConfig().weatherCommand);
}
-
+
@Override
public void onUpdateText(TextFieldWidget button, String text) {
- RoughlyEnoughItemsCore.getConfigHelper().getConfig().weatherCommand = text;
+ RoughlyEnoughItemsCore.getConfigManager().getConfig().weatherCommand = text;
try {
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ RoughlyEnoughItemsCore.getConfigManager().saveConfig();
} catch (IOException e) {
e.printStackTrace();
}
@@ -271,7 +271,7 @@ public class ConfigScreen extends Screen {
@Override
public void onInitWidget(TextFieldWidget widget) {
widget.setMaxLength(2);
- widget.setText(RoughlyEnoughItemsCore.getConfigHelper().getConfig().maxRecipePerPage + "");
+ widget.setText(RoughlyEnoughItemsCore.getConfigManager().getConfig().maxRecipePerPage + "");
widget.stripInvaild = s -> {
StringBuilder stringBuilder_1 = new StringBuilder();
char[] var2 = s.toCharArray();
@@ -291,8 +291,8 @@ public class ConfigScreen extends Screen {
public void onUpdateText(TextFieldWidget button, String text) {
if (isInvaildNumber(text))
try {
- RoughlyEnoughItemsCore.getConfigHelper().getConfig().maxRecipePerPage = Integer.valueOf(text);
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ RoughlyEnoughItemsCore.getConfigManager().getConfig().maxRecipePerPage = Integer.valueOf(text);
+ RoughlyEnoughItemsCore.getConfigManager().saveConfig();
} catch (Exception e) {
}
}
@@ -316,7 +316,7 @@ public class ConfigScreen extends Screen {
@Override
public void onPressed(double double_1, double double_2) {
try {
- RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+ RoughlyEnoughItemsCore.getConfigManager().saveConfig();
} catch (IOException e) {
e.printStackTrace();
}
@@ -337,6 +337,10 @@ public class ConfigScreen extends Screen {
this.entryListWidget.draw(int_1, int_2, float_1);
this.drawStringCentered(this.fontRenderer, I18n.translate("text.rei.config"), this.screenWidth / 2, 16, 16777215);
super.draw(int_1, int_2, float_1);
+ GuiLighting.disable();
+ tooltipList.forEach(queuedTooltip -> drawTooltip(queuedTooltip.getText(), queuedTooltip.getLocation().x, queuedTooltip.getLocation().y));
+ tooltipList.clear();
+ GuiLighting.disable();
}
@Override