ConfigObjectImpl.java 13 KB

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