RecipeViewingScreen.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. /*
  2. * Roughly Enough Items by Danielshe.
  3. * Licensed under the MIT License.
  4. */
  5. package me.shedaniel.rei.gui;
  6. import com.google.common.collect.Lists;
  7. import com.mojang.blaze3d.systems.RenderSystem;
  8. import me.shedaniel.math.api.Point;
  9. import me.shedaniel.math.api.Rectangle;
  10. import me.shedaniel.math.impl.PointHelper;
  11. import me.shedaniel.rei.api.*;
  12. import me.shedaniel.rei.gui.widget.*;
  13. import me.shedaniel.rei.impl.ScreenHelper;
  14. import me.shedaniel.rei.utils.CollectionUtils;
  15. import net.minecraft.client.MinecraftClient;
  16. import net.minecraft.client.gui.Element;
  17. import net.minecraft.client.gui.screen.Screen;
  18. import net.minecraft.client.resource.language.I18n;
  19. import net.minecraft.client.sound.PositionedSoundInstance;
  20. import net.minecraft.client.util.Window;
  21. import net.minecraft.sound.SoundEvents;
  22. import net.minecraft.text.LiteralText;
  23. import net.minecraft.util.Formatting;
  24. import net.minecraft.util.Identifier;
  25. import net.minecraft.util.math.MathHelper;
  26. import javax.annotation.Nullable;
  27. import java.util.*;
  28. import java.util.function.Supplier;
  29. public class RecipeViewingScreen extends Screen {
  30. public static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png");
  31. private static final int TABS_PER_PAGE = 5;
  32. private final List<Widget> preWidgets;
  33. private final List<Widget> widgets;
  34. private final List<TabWidget> tabs;
  35. private final Map<RecipeCategory<?>, List<RecipeDisplay>> categoriesMap;
  36. private final List<RecipeCategory<?>> categories;
  37. public int guiWidth;
  38. public int guiHeight;
  39. public int page, categoryPages;
  40. public int largestWidth, largestHeight;
  41. public boolean choosePageActivated;
  42. public RecipeChoosePageWidget recipeChoosePageWidget;
  43. private Rectangle bounds;
  44. @Nullable private CategoryBaseWidget workingStationsBaseWidget;
  45. private RecipeCategory<RecipeDisplay> selectedCategory;
  46. private ButtonWidget recipeBack, recipeNext, categoryBack, categoryNext;
  47. public RecipeViewingScreen(Map<RecipeCategory<?>, List<RecipeDisplay>> categoriesMap) {
  48. super(new LiteralText(""));
  49. this.categoryPages = 0;
  50. this.preWidgets = Lists.newArrayList();
  51. this.widgets = Lists.newArrayList();
  52. Window window = MinecraftClient.getInstance().getWindow();
  53. this.bounds = new Rectangle(window.getScaledWidth() / 2 - guiWidth / 2, window.getScaledHeight() / 2 - guiHeight / 2, 176, 186);
  54. this.categoriesMap = categoriesMap;
  55. this.categories = Lists.newArrayList();
  56. for (RecipeCategory<?> category : RecipeHelper.getInstance().getAllCategories()) {
  57. if (categoriesMap.containsKey(category))
  58. categories.add(category);
  59. }
  60. this.selectedCategory = (RecipeCategory<RecipeDisplay>) categories.get(0);
  61. this.tabs = new ArrayList<>();
  62. this.choosePageActivated = false;
  63. }
  64. @Nullable
  65. public CategoryBaseWidget getWorkingStationsBaseWidget() {
  66. return workingStationsBaseWidget;
  67. }
  68. @Override
  69. public boolean keyPressed(int int_1, int int_2, int int_3) {
  70. if (int_1 == 256 && choosePageActivated) {
  71. choosePageActivated = false;
  72. init();
  73. return true;
  74. }
  75. if ((int_1 == 256 || this.minecraft.options.keyInventory.matchesKey(int_1, int_2)) && this.shouldCloseOnEsc()) {
  76. MinecraftClient.getInstance().openScreen(ScreenHelper.getLastContainerScreen());
  77. ScreenHelper.getLastOverlay().init();
  78. return true;
  79. }
  80. if (int_1 == 258) {
  81. boolean boolean_1 = !hasShiftDown();
  82. if (!this.changeFocus(boolean_1))
  83. this.changeFocus(boolean_1);
  84. return true;
  85. }
  86. if (choosePageActivated)
  87. return recipeChoosePageWidget.keyPressed(int_1, int_2, int_3);
  88. else if (ConfigObject.getInstance().getNextPageKeybind().matchesKey(int_1, int_2)) {
  89. if (recipeNext.enabled)
  90. recipeNext.onPressed();
  91. return recipeNext.enabled;
  92. } else if (ConfigObject.getInstance().getPreviousPageKeybind().matchesKey(int_1, int_2)) {
  93. if (recipeBack.enabled)
  94. recipeBack.onPressed();
  95. return recipeBack.enabled;
  96. }
  97. for (Element element : children())
  98. if (element.keyPressed(int_1, int_2, int_3))
  99. return true;
  100. if (int_1 == 259) {
  101. if (ScreenHelper.hasLastRecipeScreen())
  102. minecraft.openScreen(ScreenHelper.getLastRecipeScreen());
  103. else
  104. minecraft.openScreen(ScreenHelper.getLastContainerScreen());
  105. return true;
  106. }
  107. return super.keyPressed(int_1, int_2, int_3);
  108. }
  109. @Override
  110. public boolean isPauseScreen() {
  111. return false;
  112. }
  113. @Override
  114. public void init() {
  115. super.init();
  116. this.children.clear();
  117. this.tabs.clear();
  118. this.preWidgets.clear();
  119. this.widgets.clear();
  120. this.largestWidth = width - 100;
  121. this.largestHeight = height - 40;
  122. int maxWidthDisplay = CollectionUtils.mapAndMax(getCurrentDisplayed(), display -> selectedCategory.getDisplayWidth(display), (Comparator<Integer>) Comparator.naturalOrder()).orElse(150);
  123. this.guiWidth = MathHelper.clamp(maxWidthDisplay + 30, 0, largestWidth);
  124. this.guiHeight = MathHelper.floor(MathHelper.clamp((selectedCategory.getDisplayHeight() + 7d) * (getRecipesPerPage() + 1d) + 40d, 186d, largestHeight));
  125. this.bounds = new Rectangle(width / 2 - guiWidth / 2, height / 2 - guiHeight / 2, guiWidth, guiHeight);
  126. this.page = MathHelper.clamp(page, 0, getTotalPages(selectedCategory) - 1);
  127. ButtonWidget w, w2;
  128. this.widgets.add(w = new ButtonWidget(new Rectangle(bounds.x + 2, bounds.y - 16, 10, 10), I18n.translate("text.rei.left_arrow")) {
  129. @Override
  130. public void onPressed() {
  131. categoryPages--;
  132. if (categoryPages < 0)
  133. categoryPages = MathHelper.ceil(categories.size() / (float) TABS_PER_PAGE) - 1;
  134. RecipeViewingScreen.this.init();
  135. }
  136. });
  137. this.widgets.add(w2 = new ButtonWidget(new Rectangle(bounds.x + bounds.width - 12, bounds.y - 16, 10, 10), I18n.translate("text.rei.right_arrow")) {
  138. @Override
  139. public void onPressed() {
  140. categoryPages++;
  141. if (categoryPages > MathHelper.ceil(categories.size() / (float) TABS_PER_PAGE) - 1)
  142. categoryPages = 0;
  143. RecipeViewingScreen.this.init();
  144. }
  145. });
  146. w.enabled = w2.enabled = categories.size() > TABS_PER_PAGE;
  147. widgets.add(categoryBack = new ButtonWidget(new Rectangle(bounds.getX() + 5, bounds.getY() + 5, 12, 12), I18n.translate("text.rei.left_arrow")) {
  148. @Override
  149. public void onPressed() {
  150. int currentCategoryIndex = categories.indexOf(selectedCategory);
  151. currentCategoryIndex--;
  152. if (currentCategoryIndex < 0)
  153. currentCategoryIndex = categories.size() - 1;
  154. selectedCategory = (RecipeCategory<RecipeDisplay>) categories.get(currentCategoryIndex);
  155. categoryPages = MathHelper.floor(currentCategoryIndex / (double) TABS_PER_PAGE);
  156. page = 0;
  157. RecipeViewingScreen.this.init();
  158. }
  159. @Override
  160. public Optional<String> getTooltips() {
  161. return Optional.ofNullable(I18n.translate("text.rei.previous_category"));
  162. }
  163. });
  164. widgets.add(new ClickableLabelWidget(new Point(bounds.getCenterX(), bounds.getY() + 7), "") {
  165. @Override
  166. public void render(int mouseX, int mouseY, float delta) {
  167. setText(selectedCategory.getCategoryName());
  168. super.render(mouseX, mouseY, delta);
  169. }
  170. @Override
  171. public Optional<String> getTooltips() {
  172. return Optional.ofNullable(I18n.translate("text.rei.view_all_categories"));
  173. }
  174. @Override
  175. public void onLabelClicked() {
  176. MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
  177. ClientHelper.getInstance().executeViewAllRecipesKeyBind();
  178. }
  179. });
  180. widgets.add(categoryNext = new ButtonWidget(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 5, 12, 12), I18n.translate("text.rei.right_arrow")) {
  181. @Override
  182. public void onPressed() {
  183. int currentCategoryIndex = categories.indexOf(selectedCategory);
  184. currentCategoryIndex++;
  185. if (currentCategoryIndex >= categories.size())
  186. currentCategoryIndex = 0;
  187. selectedCategory = (RecipeCategory<RecipeDisplay>) categories.get(currentCategoryIndex);
  188. categoryPages = MathHelper.floor(currentCategoryIndex / (double) TABS_PER_PAGE);
  189. page = 0;
  190. RecipeViewingScreen.this.init();
  191. }
  192. @Override
  193. public Optional<String> getTooltips() {
  194. return Optional.ofNullable(I18n.translate("text.rei.next_category"));
  195. }
  196. });
  197. categoryBack.enabled = categories.size() > 1;
  198. categoryNext.enabled = categories.size() > 1;
  199. widgets.add(recipeBack = new ButtonWidget(new Rectangle(bounds.getX() + 5, bounds.getY() + 21, 12, 12), I18n.translate("text.rei.left_arrow")) {
  200. @Override
  201. public void onPressed() {
  202. page--;
  203. if (page < 0)
  204. page = getTotalPages(selectedCategory) - 1;
  205. RecipeViewingScreen.this.init();
  206. }
  207. @Override
  208. public Optional<String> getTooltips() {
  209. return Optional.ofNullable(I18n.translate("text.rei.previous_page"));
  210. }
  211. });
  212. widgets.add(new ClickableLabelWidget(new Point(bounds.getCenterX(), bounds.getY() + 23), "") {
  213. @Override
  214. public void render(int mouseX, int mouseY, float delta) {
  215. setText(String.format("%d/%d", page + 1, getTotalPages(selectedCategory)));
  216. super.render(mouseX, mouseY, delta);
  217. }
  218. @Override
  219. public Optional<String> getTooltips() {
  220. return Optional.ofNullable(I18n.translate("text.rei.choose_page"));
  221. }
  222. @Override
  223. public void onLabelClicked() {
  224. MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
  225. RecipeViewingScreen.this.choosePageActivated = true;
  226. RecipeViewingScreen.this.init();
  227. }
  228. }.clickable(categoriesMap.get(selectedCategory).size() > getRecipesPerPageByHeight()));
  229. widgets.add(recipeNext = new ButtonWidget(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 21, 12, 12), I18n.translate("text.rei.right_arrow")) {
  230. @Override
  231. public void onPressed() {
  232. page++;
  233. if (page >= getTotalPages(selectedCategory))
  234. page = 0;
  235. RecipeViewingScreen.this.init();
  236. }
  237. @Override
  238. public Optional<String> getTooltips() {
  239. return Optional.ofNullable(I18n.translate("text.rei.next_page"));
  240. }
  241. });
  242. recipeBack.enabled = recipeNext.enabled = categoriesMap.get(selectedCategory).size() > getRecipesPerPageByHeight();
  243. for (int i = 0; i < TABS_PER_PAGE; i++) {
  244. int j = i + categoryPages * TABS_PER_PAGE;
  245. if (categories.size() > j) {
  246. TabWidget tab;
  247. tabs.add(tab = new TabWidget(i, new Rectangle(bounds.x + bounds.width / 2 - Math.min(categories.size() - categoryPages * TABS_PER_PAGE, TABS_PER_PAGE) * 14 + i * 28, bounds.y - 28, 28, 28)) {
  248. @Override
  249. public boolean mouseClicked(double mouseX, double mouseY, int button) {
  250. if (getBounds().contains(mouseX, mouseY)) {
  251. MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
  252. if (getId() + categoryPages * TABS_PER_PAGE == categories.indexOf(selectedCategory))
  253. return false;
  254. selectedCategory = (RecipeCategory<RecipeDisplay>) categories.get(getId() + categoryPages * TABS_PER_PAGE);
  255. page = 0;
  256. RecipeViewingScreen.this.init();
  257. return true;
  258. }
  259. return false;
  260. }
  261. });
  262. tab.setRenderer(categories.get(j), categories.get(j).getLogo(), categories.get(j).getCategoryName(), tab.getId() + categoryPages * TABS_PER_PAGE == categories.indexOf(selectedCategory));
  263. }
  264. }
  265. Optional<ButtonAreaSupplier> supplier = RecipeHelper.getInstance().getAutoCraftButtonArea(selectedCategory);
  266. int recipeHeight = selectedCategory.getDisplayHeight();
  267. List<RecipeDisplay> currentDisplayed = getCurrentDisplayed();
  268. for (int i = 0; i < currentDisplayed.size(); i++) {
  269. int finalI = i;
  270. final Supplier<RecipeDisplay> displaySupplier = () -> currentDisplayed.get(finalI);
  271. int displayWidth = selectedCategory.getDisplayWidth(displaySupplier.get());
  272. final Rectangle displayBounds = new Rectangle(getBounds().getCenterX() - displayWidth / 2, getBounds().y + 40 + recipeHeight * i + 7 * i, displayWidth, recipeHeight);
  273. List<Widget> setupDisplay = selectedCategory.setupDisplay(displaySupplier, displayBounds);
  274. this.widgets.addAll(setupDisplay);
  275. if (supplier.isPresent() && supplier.get().get(displayBounds) != null)
  276. this.widgets.add(new AutoCraftingButtonWidget(displayBounds, supplier.get().get(displayBounds), supplier.get().getButtonText(), displaySupplier, setupDisplay, selectedCategory));
  277. }
  278. if (choosePageActivated)
  279. recipeChoosePageWidget = new RecipeChoosePageWidget(this, page, getTotalPages(selectedCategory));
  280. else
  281. recipeChoosePageWidget = null;
  282. workingStationsBaseWidget = null;
  283. List<List<EntryStack>> workingStations = RecipeHelper.getInstance().getWorkingStations(selectedCategory.getIdentifier());
  284. if (!workingStations.isEmpty()) {
  285. int hh = MathHelper.floor((bounds.height - 16) / 18f);
  286. int actualHeight = Math.min(hh, workingStations.size());
  287. int innerWidth = MathHelper.ceil(workingStations.size() / ((float) hh));
  288. int xx = bounds.x - (10 + innerWidth * 18) + 6;
  289. int yy = bounds.y + 16;
  290. preWidgets.add(workingStationsBaseWidget = new CategoryBaseWidget(new Rectangle(xx - 6, yy - 6, 15 + innerWidth * 18, 11 + actualHeight * 18)));
  291. int index = 0;
  292. List<String> list = Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("text.rei.working_station"));
  293. xx += (innerWidth - 1) * 18;
  294. for (List<EntryStack> workingStation : workingStations) {
  295. preWidgets.add(EntryWidget.create(xx, yy).entries(CollectionUtils.map(workingStation, stack -> stack.copy().setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, s -> list))));
  296. index++;
  297. yy += 18;
  298. if (index >= hh) {
  299. index = 0;
  300. yy = bounds.y + 16;
  301. xx -= 18;
  302. }
  303. }
  304. }
  305. children.addAll(tabs);
  306. children.add(ScreenHelper.getLastOverlay(true, false));
  307. children.addAll(widgets);
  308. children.addAll(preWidgets);
  309. }
  310. public List<Widget> getWidgets() {
  311. return widgets;
  312. }
  313. public List<RecipeDisplay> getCurrentDisplayed() {
  314. List<RecipeDisplay> list = Lists.newArrayList();
  315. int recipesPerPage = getRecipesPerPage();
  316. for (int i = 0; i <= recipesPerPage; i++)
  317. if (page * (recipesPerPage + 1) + i < categoriesMap.get(selectedCategory).size())
  318. list.add(categoriesMap.get(selectedCategory).get(page * (recipesPerPage + 1) + i));
  319. return list;
  320. }
  321. public RecipeCategory<RecipeDisplay> getSelectedCategory() {
  322. return selectedCategory;
  323. }
  324. public int getPage() {
  325. return page;
  326. }
  327. public int getCategoryPage() {
  328. return categoryPages;
  329. }
  330. @SuppressWarnings("deprecation")
  331. private int getRecipesPerPage() {
  332. if (selectedCategory.getFixedRecipesPerPage() > 0)
  333. return selectedCategory.getFixedRecipesPerPage() - 1;
  334. int height = selectedCategory.getDisplayHeight();
  335. return MathHelper.clamp(MathHelper.floor(((double) largestHeight - 40d) / ((double) height + 7d)) - 1, 0, Math.min(ConfigObject.getInstance().getMaxRecipePerPage() - 1, selectedCategory.getMaximumRecipePerPage() - 1));
  336. }
  337. private int getRecipesPerPageByHeight() {
  338. int height = selectedCategory.getDisplayHeight();
  339. return MathHelper.clamp(MathHelper.floor(((double) guiHeight - 40d) / ((double) height + 7d)), 0, Math.min(ConfigObject.getInstance().getMaxRecipePerPage() - 1, selectedCategory.getMaximumRecipePerPage() - 1));
  340. }
  341. @Override
  342. public void render(int mouseX, int mouseY, float delta) {
  343. this.fillGradient(0, 0, this.width, this.height, -1072689136, -804253680);
  344. for (Widget widget : preWidgets) {
  345. widget.render(mouseX, mouseY, delta);
  346. }
  347. if (selectedCategory != null)
  348. selectedCategory.drawCategoryBackground(bounds, mouseX, mouseY, delta);
  349. else {
  350. new CategoryBaseWidget(bounds).render();
  351. if (ScreenHelper.isDarkModeEnabled()) {
  352. fill(bounds.x + 17, bounds.y + 5, bounds.x + bounds.width - 17, bounds.y + 17, 0xFF404040);
  353. fill(bounds.x + 17, bounds.y + 21, bounds.x + bounds.width - 17, bounds.y + 33, 0xFF404040);
  354. } else {
  355. fill(bounds.x + 17, bounds.y + 5, bounds.x + bounds.width - 17, bounds.y + 17, 0xFF9E9E9E);
  356. fill(bounds.x + 17, bounds.y + 21, bounds.x + bounds.width - 17, bounds.y + 33, 0xFF9E9E9E);
  357. }
  358. }
  359. for (TabWidget tab : tabs) {
  360. if (!tab.isSelected())
  361. tab.render(mouseX, mouseY, delta);
  362. }
  363. super.render(mouseX, mouseY, delta);
  364. for (Widget widget : widgets) {
  365. widget.render(mouseX, mouseY, delta);
  366. }
  367. RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
  368. for (TabWidget tab : tabs) {
  369. if (tab.isSelected())
  370. tab.render(mouseX, mouseY, delta);
  371. }
  372. ScreenHelper.getLastOverlay().render(mouseX, mouseY, delta);
  373. ScreenHelper.getLastOverlay().lateRender(mouseX, mouseY, delta);
  374. if (choosePageActivated) {
  375. setBlitOffset(500);
  376. this.fillGradient(0, 0, this.width, this.height, -1072689136, -804253680);
  377. setBlitOffset(0);
  378. recipeChoosePageWidget.render(mouseX, mouseY, delta);
  379. }
  380. }
  381. public int getTotalPages(RecipeCategory<RecipeDisplay> category) {
  382. return MathHelper.ceil(categoriesMap.get(category).size() / (double) (getRecipesPerPage() + 1));
  383. }
  384. public Rectangle getBounds() {
  385. return bounds;
  386. }
  387. @Override
  388. public boolean charTyped(char char_1, int int_1) {
  389. if (choosePageActivated) {
  390. return recipeChoosePageWidget.charTyped(char_1, int_1);
  391. }
  392. for (Element listener : children())
  393. if (listener.charTyped(char_1, int_1))
  394. return true;
  395. return super.charTyped(char_1, int_1);
  396. }
  397. @Override
  398. public boolean mouseDragged(double double_1, double double_2, int int_1, double double_3, double double_4) {
  399. if (choosePageActivated) {
  400. return recipeChoosePageWidget.mouseDragged(double_1, double_2, int_1, double_3, double_4);
  401. }
  402. return super.mouseDragged(double_1, double_2, int_1, double_3, double_4);
  403. }
  404. @Override
  405. public boolean mouseReleased(double double_1, double double_2, int int_1) {
  406. if (choosePageActivated) {
  407. return recipeChoosePageWidget.mouseReleased(double_1, double_2, int_1);
  408. }
  409. return super.mouseReleased(double_1, double_2, int_1);
  410. }
  411. @Override
  412. public boolean mouseScrolled(double i, double j, double amount) {
  413. for (Element listener : children())
  414. if (listener.mouseScrolled(i, j, amount))
  415. return true;
  416. if (getBounds().contains(PointHelper.fromMouse())) {
  417. if (amount > 0 && recipeBack.enabled)
  418. recipeBack.onPressed();
  419. else if (amount < 0 && recipeNext.enabled)
  420. recipeNext.onPressed();
  421. }
  422. if ((new Rectangle(bounds.x, bounds.y - 28, bounds.width, 28)).contains(PointHelper.fromMouse())) {
  423. if (amount > 0 && categoryBack.enabled)
  424. categoryBack.onPressed();
  425. else if (amount < 0 && categoryNext.enabled)
  426. categoryNext.onPressed();
  427. }
  428. return super.mouseScrolled(i, j, amount);
  429. }
  430. @Override
  431. public boolean mouseClicked(double double_1, double double_2, int int_1) {
  432. if (choosePageActivated)
  433. if (recipeChoosePageWidget.containsMouse(double_1, double_2)) {
  434. return recipeChoosePageWidget.mouseClicked(double_1, double_2, int_1);
  435. } else {
  436. choosePageActivated = false;
  437. init();
  438. return false;
  439. }
  440. for (Element entry : children())
  441. if (entry.mouseClicked(double_1, double_2, int_1)) {
  442. setFocused(entry);
  443. if (int_1 == 0)
  444. setDragging(true);
  445. return true;
  446. }
  447. return false;
  448. }
  449. @Override
  450. public Element getFocused() {
  451. if (choosePageActivated)
  452. return recipeChoosePageWidget;
  453. return super.getFocused();
  454. }
  455. }