ConfigObjectImpl.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. /*
  2. * Roughly Enough Items by Danielshe.
  3. * Licensed under the MIT License.
  4. */
  5. package me.shedaniel.rei.impl;
  6. import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
  7. import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
  8. import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry;
  9. import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment;
  10. import me.shedaniel.clothconfig2.api.Modifier;
  11. import me.shedaniel.clothconfig2.api.ModifierKeyCode;
  12. import me.shedaniel.rei.api.ConfigObject;
  13. import me.shedaniel.rei.api.annotations.Internal;
  14. import me.shedaniel.rei.gui.config.ItemListOrdering;
  15. import me.shedaniel.rei.gui.config.ItemListOrderingConfig;
  16. import me.shedaniel.rei.gui.config.RecipeScreenType;
  17. import me.shedaniel.rei.gui.config.SearchFieldLocation;
  18. import net.minecraft.client.util.InputUtil;
  19. import java.util.ArrayList;
  20. import java.util.List;
  21. @Deprecated
  22. @Internal
  23. @Config(name = "roughlyenoughitems/config")
  24. public class ConfigObjectImpl implements ConfigObject, ConfigData {
  25. @ConfigEntry.Category("!general") @ConfigEntry.Gui.TransitiveObject @DontApplyFieldName public General general = new General();
  26. @ConfigEntry.Category("appearance") @ConfigEntry.Gui.TransitiveObject @DontApplyFieldName private Appearance appearance = new Appearance();
  27. @ConfigEntry.Category("modules") @ConfigEntry.Gui.TransitiveObject @DontApplyFieldName private Modules modules = new Modules();
  28. @ConfigEntry.Category("technical") @ConfigEntry.Gui.TransitiveObject @DontApplyFieldName private Technical technical = new Technical();
  29. @ConfigEntry.Category("performance") @ConfigEntry.Gui.TransitiveObject @DontApplyFieldName private Performance performance = new Performance();
  30. @Override
  31. public boolean isLighterButtonHover() {
  32. return true;
  33. }
  34. @Override
  35. public boolean isOverlayVisible() {
  36. return general.overlayVisible;
  37. }
  38. @Override
  39. public void setOverlayVisible(boolean overlayVisible) {
  40. general.overlayVisible = overlayVisible;
  41. }
  42. @Override
  43. public boolean isCheating() {
  44. return general.cheating;
  45. }
  46. @Override
  47. public void setCheating(boolean cheating) {
  48. general.cheating = cheating;
  49. }
  50. @Override
  51. public ItemListOrdering getItemListOrdering() {
  52. return appearance.itemListOrdering.getOrdering();
  53. }
  54. @Override
  55. public boolean isItemListAscending() {
  56. return appearance.itemListOrdering.isAscending();
  57. }
  58. @Override
  59. public boolean isUsingDarkTheme() {
  60. return appearance.darkTheme;
  61. }
  62. @Override
  63. public boolean isToastDisplayedOnCopyIdentifier() {
  64. return modules.toastDisplayedOnCopyIdentifier;
  65. }
  66. @Override
  67. public boolean doesRenderEntryEnchantmentGlint() {
  68. return performance.renderEntryEnchantmentGlint;
  69. }
  70. @Override
  71. public boolean isEntryListWidgetScrolled() {
  72. return appearance.scrollingEntryListWidget;
  73. }
  74. @Override
  75. public boolean shouldAppendModNames() {
  76. return appearance.appendModNames;
  77. }
  78. @Override
  79. public RecipeScreenType getRecipeScreenType() {
  80. return appearance.recipeScreenType;
  81. }
  82. @Override
  83. public void setRecipeScreenType(RecipeScreenType recipeScreenType) {
  84. appearance.recipeScreenType = recipeScreenType;
  85. }
  86. @Override
  87. public boolean isLoadingDefaultPlugin() {
  88. return technical.loadDefaultPlugin;
  89. }
  90. @Override
  91. public SearchFieldLocation getSearchFieldLocation() {
  92. return appearance.searchFieldLocation;
  93. }
  94. @Override
  95. public boolean isLeftHandSidePanel() {
  96. return appearance.mirrorItemPanel;
  97. }
  98. @Override
  99. public boolean isCraftableFilterEnabled() {
  100. return modules.enableCraftableOnlyButton;
  101. }
  102. @Override
  103. public String getGamemodeCommand() {
  104. return technical.gamemodeCommand;
  105. }
  106. @Override
  107. public String getGiveCommand() {
  108. return technical.giveCommand;
  109. }
  110. @Override
  111. public String getWeatherCommand() {
  112. return technical.weatherCommand;
  113. }
  114. @Override
  115. public int getMaxRecipePerPage() {
  116. return appearance.maxRecipePerPage;
  117. }
  118. @Override
  119. public boolean doesShowUtilsButtons() {
  120. return modules.showUtilsButtons;
  121. }
  122. @Override
  123. public boolean doesDisableRecipeBook() {
  124. return modules.disableRecipeBook;
  125. }
  126. @Override
  127. public boolean doesFixTabCloseContainer() {
  128. return modules.fixTabCloseContainer;
  129. }
  130. @Override
  131. public boolean areClickableRecipeArrowsEnabled() {
  132. return appearance.clickableRecipeArrows;
  133. }
  134. @Override
  135. public boolean isUsingLightGrayRecipeBorder() {
  136. return appearance.lightGrayRecipeBorder;
  137. }
  138. @Override
  139. public boolean doesVillagerScreenHavePermanentScrollBar() {
  140. return appearance.villagerScreenPermanentScrollBar;
  141. }
  142. @Override
  143. public boolean doesRegisterRecipesInAnotherThread() {
  144. return technical.registerRecipesInAnotherThread;
  145. }
  146. @Override
  147. public boolean doesSnapToRows() {
  148. return appearance.snapToRows;
  149. }
  150. @Override
  151. public boolean isFavoritesEnabled() {
  152. return general.favoritesEnabled;
  153. }
  154. @Override
  155. public boolean doDisplayFavoritesTooltip() {
  156. return isFavoritesEnabled() && appearance.displayFavoritesTooltip;
  157. }
  158. @Override
  159. public boolean doDisplayFavoritesOnTheLeft() {
  160. return appearance.displayFavoritesOnTheLeft;
  161. }
  162. @Override
  163. public boolean doesFastEntryRendering() {
  164. return performance.newFastEntryRendering;
  165. }
  166. @Override
  167. public boolean doDebugRenderTimeRequired() {
  168. return technical.debugRenderTimeRequired;
  169. }
  170. @Override
  171. public boolean doSearchFavorites() {
  172. return appearance.searchFavorites;
  173. }
  174. @Override
  175. public ModifierKeyCode getFavoriteKeyCode() {
  176. return general.favoriteKeybind == null ? ModifierKeyCode.unknown() : general.favoriteKeybind;
  177. }
  178. @Override
  179. public ModifierKeyCode getRecipeKeybind() {
  180. return general.recipeKeybind == null ? ModifierKeyCode.unknown() : general.recipeKeybind;
  181. }
  182. @Override
  183. public ModifierKeyCode getUsageKeybind() {
  184. return general.usageKeybind == null ? ModifierKeyCode.unknown() : general.usageKeybind;
  185. }
  186. @Override
  187. public ModifierKeyCode getHideKeybind() {
  188. return general.hideKeybind == null ? ModifierKeyCode.unknown() : general.hideKeybind;
  189. }
  190. @Override
  191. public ModifierKeyCode getPreviousPageKeybind() {
  192. return general.previousPageKeybind == null ? ModifierKeyCode.unknown() : general.previousPageKeybind;
  193. }
  194. @Override
  195. public ModifierKeyCode getNextPageKeybind() {
  196. return general.nextPageKeybind == null ? ModifierKeyCode.unknown() : general.nextPageKeybind;
  197. }
  198. @Override
  199. public ModifierKeyCode getFocusSearchFieldKeybind() {
  200. return general.focusSearchFieldKeybind == null ? ModifierKeyCode.unknown() : general.focusSearchFieldKeybind;
  201. }
  202. @Override
  203. public ModifierKeyCode getCopyRecipeIdentifierKeybind() {
  204. return general.copyRecipeIdentifierKeybind == null ? ModifierKeyCode.unknown() : general.copyRecipeIdentifierKeybind;
  205. }
  206. @Override
  207. public double getEntrySize() {
  208. return appearance.entrySize;
  209. }
  210. @Deprecated
  211. @Override
  212. public General getGeneral() {
  213. return general;
  214. }
  215. @Override
  216. public boolean isUsingCompactTabs() {
  217. return appearance.useCompactTabs;
  218. }
  219. public static class General {
  220. @ConfigEntry.Gui.Excluded public List<String> favorites = new ArrayList<>();
  221. @Comment("Declares whether cheating mode is on.") private boolean cheating = false;
  222. @Comment("Declares whether REI is visible.") @ConfigEntry.Gui.Excluded private boolean overlayVisible = true;
  223. private boolean favoritesEnabled = true;
  224. private ModifierKeyCode recipeKeybind = ModifierKeyCode.of(InputUtil.Type.KEYSYM.createFromCode(82), Modifier.none());
  225. private ModifierKeyCode usageKeybind = ModifierKeyCode.of(InputUtil.Type.KEYSYM.createFromCode(85), Modifier.none());
  226. private ModifierKeyCode hideKeybind = ModifierKeyCode.of(InputUtil.Type.KEYSYM.createFromCode(79), Modifier.of(false, true, false));
  227. private ModifierKeyCode previousPageKeybind = ModifierKeyCode.unknown();
  228. private ModifierKeyCode nextPageKeybind = ModifierKeyCode.unknown();
  229. private ModifierKeyCode focusSearchFieldKeybind = ModifierKeyCode.unknown();
  230. private ModifierKeyCode copyRecipeIdentifierKeybind = ModifierKeyCode.unknown();
  231. private ModifierKeyCode favoriteKeybind = ModifierKeyCode.of(InputUtil.Type.KEYSYM.createFromCode(65), Modifier.none());
  232. }
  233. public static class Appearance {
  234. @UseSpecialRecipeTypeScreen private RecipeScreenType recipeScreenType = RecipeScreenType.UNSET;
  235. @Comment("The ordering of the items on the item panel.") @UseEnumSelectorInstead
  236. private ItemListOrderingConfig itemListOrdering = ItemListOrderingConfig.REGISTRY_ASCENDING;
  237. @Comment("Declares the appearance of REI windows.") private boolean darkTheme = false;
  238. @Comment("Declares the position of the search field.") @UseEnumSelectorInstead
  239. private SearchFieldLocation searchFieldLocation = SearchFieldLocation.CENTER;
  240. @Comment("Declares the position of the item list panel.") private boolean mirrorItemPanel = false;
  241. @Comment("Declares the maximum amount of recipes displayed in a page if possible.") @ConfigEntry.BoundedDiscrete(min = 2, max = 99)
  242. private int maxRecipePerPage = 3;
  243. private boolean clickableRecipeArrows = true;
  244. @Comment("Declares the appearance of recipe's border.") private boolean lightGrayRecipeBorder = false;
  245. @Comment("Declares whether REI should append mod names to item stacks.") private boolean appendModNames = true;
  246. @Comment("Declares how the scrollbar in villager screen should act.") private boolean villagerScreenPermanentScrollBar = false;
  247. @Comment("Declares whether entry list widget is scrolled.") private boolean scrollingEntryListWidget = false;
  248. private boolean snapToRows = false;
  249. private boolean displayFavoritesOnTheLeft = true;
  250. private boolean displayFavoritesTooltip = false;
  251. @Comment("Declares whether favorites will be searched.") private boolean searchFavorites = true;
  252. @UsePercentage(min = 0.5, max = 4.0) private double entrySize = 1.0;
  253. private boolean useCompactTabs = true;
  254. }
  255. public static class Technical {
  256. @Comment("To disable REI's default plugin.\nDon't change this unless you understand what you are doing!") private boolean loadDefaultPlugin = true;
  257. @Comment("Declares the command used to change gamemode.") private String gamemodeCommand = "/gamemode {gamemode}";
  258. @Comment("Declares the command used in servers to cheat items.") private String giveCommand = "/give {player_name} {item_identifier}{nbt} {count}";
  259. @Comment("Declares the command used to change weather.") private String weatherCommand = "/weather {weather}";
  260. private boolean registerRecipesInAnotherThread = true;
  261. private boolean debugRenderTimeRequired = false;
  262. }
  263. public static class Modules {
  264. @Comment("Declares whether the craftable filter button is enabled.") private boolean enableCraftableOnlyButton = true;
  265. private boolean toastDisplayedOnCopyIdentifier = true;
  266. @Comment("Declares whether the utils buttons are shown.") private boolean showUtilsButtons = false;
  267. @Comment("Declares whether REI should remove the recipe book.") private boolean disableRecipeBook = false;
  268. @Comment("Declares whether REI should fix closing container with tab.") private boolean fixTabCloseContainer = false;
  269. }
  270. public static class Performance {
  271. @Comment("Whether REI should render entry's enchantment glint") private boolean renderEntryEnchantmentGlint = true;
  272. private boolean newFastEntryRendering = true;
  273. }
  274. }