VillagerRecipeViewingScreen.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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.google.common.collect.Maps;
  8. import com.mojang.blaze3d.platform.GlStateManager;
  9. import com.zeitheron.hammercore.client.utils.Scissors;
  10. import me.shedaniel.cloth.api.ClientUtils;
  11. import me.shedaniel.rei.RoughlyEnoughItemsCore;
  12. import me.shedaniel.rei.api.*;
  13. import me.shedaniel.rei.gui.renderers.RecipeRenderer;
  14. import me.shedaniel.rei.gui.widget.*;
  15. import me.shedaniel.rei.impl.ScreenHelper;
  16. import net.minecraft.client.MinecraftClient;
  17. import net.minecraft.client.gui.Element;
  18. import net.minecraft.client.gui.screen.Screen;
  19. import net.minecraft.client.render.BufferBuilder;
  20. import net.minecraft.client.render.GuiLighting;
  21. import net.minecraft.client.render.Tessellator;
  22. import net.minecraft.client.render.VertexFormats;
  23. import net.minecraft.client.resource.language.I18n;
  24. import net.minecraft.client.sound.PositionedSoundInstance;
  25. import net.minecraft.item.ItemStack;
  26. import net.minecraft.sound.SoundEvents;
  27. import net.minecraft.text.LiteralText;
  28. import net.minecraft.text.TranslatableText;
  29. import net.minecraft.util.Formatting;
  30. import net.minecraft.util.math.MathHelper;
  31. import java.awt.*;
  32. import java.util.Collections;
  33. import java.util.List;
  34. import java.util.Map;
  35. import java.util.Optional;
  36. import java.util.stream.Collectors;
  37. public class VillagerRecipeViewingScreen extends Screen {
  38. private static final int TABS_PER_PAGE = 8;
  39. private final Map<RecipeCategory<?>, List<RecipeDisplay>> categoryMap;
  40. private final List<RecipeCategory<?>> categories;
  41. private final List<Widget> widgets;
  42. private final List<ButtonWidget> buttonWidgets;
  43. private final List<Renderer> recipeRenderers;
  44. private final List<TabWidget> tabs;
  45. public Rectangle bounds, scrollListBounds;
  46. private int selectedCategoryIndex, selectedRecipeIndex;
  47. private double scroll;
  48. private float scrollBarAlpha = 0;
  49. private float scrollBarAlphaFuture = 0;
  50. private long scrollBarAlphaFutureTime = -1;
  51. private boolean draggingScrollBar = false;
  52. private int tabsPage;
  53. public VillagerRecipeViewingScreen(Map<RecipeCategory<?>, List<RecipeDisplay>> map) {
  54. super(new LiteralText(""));
  55. this.widgets = Lists.newArrayList();
  56. this.categoryMap = Maps.newLinkedHashMap();
  57. this.selectedCategoryIndex = 0;
  58. this.selectedRecipeIndex = 0;
  59. this.scrollBarAlpha = 0;
  60. this.scrollBarAlphaFuture = 0;
  61. this.scroll = 0;
  62. this.draggingScrollBar = false;
  63. this.tabsPage = 0;
  64. this.categories = Lists.newArrayList();
  65. this.buttonWidgets = Lists.newArrayList();
  66. this.tabs = Lists.newArrayList();
  67. this.recipeRenderers = Lists.newArrayList();
  68. RecipeHelper.getInstance().getAllCategories().forEach(category -> {
  69. if (map.containsKey(category)) {
  70. categories.add(category);
  71. categoryMap.put(category, map.get(category));
  72. }
  73. });
  74. }
  75. @Override
  76. protected void init() {
  77. super.init();
  78. this.draggingScrollBar = false;
  79. this.children.clear();
  80. this.widgets.clear();
  81. this.buttonWidgets.clear();
  82. this.recipeRenderers.clear();
  83. this.tabs.clear();
  84. int largestWidth = width - 100;
  85. int largestHeight = height - 40;
  86. RecipeCategory<RecipeDisplay> category = (RecipeCategory<RecipeDisplay>) categories.get(selectedCategoryIndex);
  87. RecipeDisplay display = categoryMap.get(category).get(selectedRecipeIndex);
  88. int guiWidth = MathHelper.clamp(category.getDisplayWidth(display) + 30, 0, largestWidth) + 100;
  89. int guiHeight = MathHelper.clamp(category.getDisplayHeight() + 40, 166, largestHeight);
  90. this.bounds = new Rectangle(width / 2 - guiWidth / 2, height / 2 - guiHeight / 2, guiWidth, guiHeight);
  91. List<List<ItemStack>> workingStations = RoughlyEnoughItemsCore.getRecipeHelper().getWorkingStations(category.getIdentifier());
  92. if (!workingStations.isEmpty()) {
  93. int ww = MathHelper.floor((bounds.width - 16) / 18f);
  94. int w = Math.min(ww, workingStations.size());
  95. int h = MathHelper.ceil(workingStations.size() / ((float) ww));
  96. int xx = bounds.x + 16;
  97. int yy = bounds.y + bounds.height + 5;
  98. widgets.add(new CategoryBaseWidget(new Rectangle(xx - 6, bounds.y + bounds.height - 5, 11 + w * 18, 15 + h * 18)));
  99. int index = 0;
  100. List<String> list = Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("text.rei.working_station"));
  101. for (List<ItemStack> workingStation : workingStations) {
  102. widgets.add(new SlotWidget(xx, yy, Renderer.fromItemStacks(workingStation), true, true, true) {
  103. @Override
  104. protected List<String> getExtraItemToolTips(ItemStack stack) {
  105. return list;
  106. }
  107. });
  108. index++;
  109. xx += 18;
  110. if (index >= ww) {
  111. index = 0;
  112. xx = bounds.x + 16;
  113. yy += 18;
  114. }
  115. }
  116. }
  117. this.widgets.add(new CategoryBaseWidget(bounds));
  118. this.scrollListBounds = new Rectangle(bounds.x + 4, bounds.y + 17, 97 + 5, guiHeight - 17 - 7);
  119. this.widgets.add(new SlotBaseWidget(scrollListBounds));
  120. Rectangle recipeBounds = new Rectangle(bounds.x + 100 + (guiWidth - 100) / 2 - category.getDisplayWidth(display) / 2, bounds.y + bounds.height / 2 - category.getDisplayHeight() / 2, category.getDisplayWidth(display), category.getDisplayHeight());
  121. List<Widget> setupDisplay = category.setupDisplay(() -> display, recipeBounds);
  122. this.widgets.addAll(setupDisplay);
  123. Optional<ButtonAreaSupplier> supplier = RecipeHelper.getInstance().getSpeedCraftButtonArea(category);
  124. if (supplier.isPresent() && supplier.get().get(recipeBounds) != null)
  125. this.widgets.add(new AutoCraftingButtonWidget(recipeBounds, supplier.get().get(recipeBounds), supplier.get().getButtonText(), () -> display, setupDisplay, category));
  126. int index = 0;
  127. for (RecipeDisplay recipeDisplay : categoryMap.get(category)) {
  128. int finalIndex = index;
  129. RecipeRenderer recipeRenderer;
  130. recipeRenderers.add(recipeRenderer = category.getSimpleRenderer(recipeDisplay));
  131. buttonWidgets.add(new ButtonWidget(bounds.x + 5, 0, recipeRenderer.getWidth(), recipeRenderer.getHeight(), "") {
  132. @Override
  133. public void onPressed() {
  134. selectedRecipeIndex = finalIndex;
  135. VillagerRecipeViewingScreen.this.init();
  136. }
  137. @Override
  138. protected int getTextureId(boolean boolean_1) {
  139. enabled = selectedRecipeIndex != finalIndex;
  140. return super.getTextureId(boolean_1);
  141. }
  142. });
  143. index++;
  144. }
  145. for (int i = 0; i < TABS_PER_PAGE; i++) {
  146. int j = i + tabsPage * TABS_PER_PAGE;
  147. if (categories.size() > j) {
  148. TabWidget tab;
  149. tabs.add(tab = new TabWidget(i, new Rectangle(bounds.x + bounds.width / 2 - Math.min(categories.size() - tabsPage * TABS_PER_PAGE, TABS_PER_PAGE) * 14 + i * 28, bounds.y - 28, 28, 28)) {
  150. @Override
  151. public boolean mouseClicked(double mouseX, double mouseY, int button) {
  152. if (getBounds().contains(mouseX, mouseY)) {
  153. MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
  154. if (getId() + tabsPage * TABS_PER_PAGE == selectedCategoryIndex)
  155. return false;
  156. selectedCategoryIndex = getId() + tabsPage * TABS_PER_PAGE;
  157. scroll = 0;
  158. selectedRecipeIndex = 0;
  159. VillagerRecipeViewingScreen.this.init();
  160. return true;
  161. }
  162. return false;
  163. }
  164. });
  165. tab.setRenderer(categories.get(j), categories.get(j).getIcon(), categories.get(j).getCategoryName(), tab.getId() + tabsPage * TABS_PER_PAGE == selectedCategoryIndex);
  166. }
  167. }
  168. ButtonWidget w, w2;
  169. this.widgets.add(w = new ButtonWidget(bounds.x + 2, bounds.y - 16, 10, 10, new TranslatableText("text.rei.left_arrow")) {
  170. @Override
  171. public void onPressed() {
  172. tabsPage--;
  173. if (tabsPage < 0)
  174. tabsPage = MathHelper.ceil(categories.size() / (float) TABS_PER_PAGE) - 1;
  175. VillagerRecipeViewingScreen.this.init();
  176. }
  177. });
  178. this.widgets.add(w2 = new ButtonWidget(bounds.x + bounds.width - 12, bounds.y - 16, 10, 10, new TranslatableText("text.rei.right_arrow")) {
  179. @Override
  180. public void onPressed() {
  181. tabsPage++;
  182. if (tabsPage > MathHelper.ceil(categories.size() / (float) TABS_PER_PAGE) - 1)
  183. tabsPage = 0;
  184. VillagerRecipeViewingScreen.this.init();
  185. }
  186. });
  187. w.enabled = w2.enabled = categories.size() > TABS_PER_PAGE;
  188. this.widgets.add(new ClickableLabelWidget(bounds.x + 4 + scrollListBounds.width / 2, bounds.y + 6, categories.get(selectedCategoryIndex).getCategoryName()) {
  189. @Override
  190. public void onLabelClicked() {
  191. MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
  192. ClientHelper.getInstance().executeViewAllRecipesKeyBind();
  193. }
  194. @Override
  195. public Optional<String> getTooltips() {
  196. return Optional.ofNullable(I18n.translate("text.rei.view_all_categories"));
  197. }
  198. @Override
  199. public void render(int mouseX, int mouseY, float delta) {
  200. GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
  201. font.draw((isHovered(mouseX, mouseY) ? Formatting.UNDERLINE.toString() : "") + text, x - font.getStringWidth(text) / 2, y, getDefaultColor());
  202. if (clickable && getTooltips().isPresent())
  203. if (!focused && containsMouse(mouseX, mouseY))
  204. ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(getTooltips().get().split("\n")));
  205. else if (focused)
  206. ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(new Point(x, y), getTooltips().get().split("\n")));
  207. }
  208. @Override
  209. public int getDefaultColor() {
  210. return ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 4210752;
  211. }
  212. });
  213. this.children.addAll(buttonWidgets);
  214. this.widgets.addAll(tabs);
  215. this.children.addAll(widgets);
  216. this.children.add(ScreenHelper.getLastOverlay(true, false));
  217. ScreenHelper.getLastOverlay().init();
  218. }
  219. @Override
  220. public boolean mouseClicked(double mouseX, double mouseY, int int_1) {
  221. double height = buttonWidgets.stream().map(ButtonWidget::getBounds).collect(Collectors.summingDouble(Rectangle::getHeight));
  222. int actualHeight = scrollListBounds.height - 2;
  223. if (height > actualHeight && scrollBarAlpha > 0 && mouseY >= scrollListBounds.y + 1 && mouseY <= scrollListBounds.getMaxY() - 1) {
  224. double scrollbarPositionMinX = scrollListBounds.getMaxX() - 6;
  225. if (mouseX >= scrollbarPositionMinX & mouseX <= scrollbarPositionMinX + 8) {
  226. this.draggingScrollBar = true;
  227. scrollBarAlpha = 1;
  228. return false;
  229. }
  230. }
  231. this.draggingScrollBar = false;
  232. return super.mouseClicked(mouseX, mouseY, int_1);
  233. }
  234. @Override
  235. public boolean charTyped(char char_1, int int_1) {
  236. for (Element listener : children())
  237. if (listener.charTyped(char_1, int_1))
  238. return true;
  239. return super.charTyped(char_1, int_1);
  240. }
  241. @Override
  242. public boolean mouseScrolled(double double_1, double double_2, double double_3) {
  243. double height = buttonWidgets.stream().map(ButtonWidget::getBounds).collect(Collectors.summingDouble(Rectangle::getHeight));
  244. if (scrollListBounds.contains(double_1, double_2) && height > scrollListBounds.height - 2) {
  245. if (double_3 > 0)
  246. scroll -= 16;
  247. else
  248. scroll += 16;
  249. scroll = MathHelper.clamp(scroll, 0, height - scrollListBounds.height + 2);
  250. if (scrollBarAlphaFuture == 0)
  251. scrollBarAlphaFuture = 1f;
  252. if (System.currentTimeMillis() - scrollBarAlphaFutureTime > 300f)
  253. scrollBarAlphaFutureTime = System.currentTimeMillis();
  254. return true;
  255. }
  256. for (Element listener : children())
  257. if (listener.mouseScrolled(double_1, double_2, double_3))
  258. return true;
  259. if (bounds.contains(ClientUtils.getMouseLocation())) {
  260. if (double_3 < 0 && categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) {
  261. selectedRecipeIndex++;
  262. if (selectedRecipeIndex >= categoryMap.get(categories.get(selectedCategoryIndex)).size())
  263. selectedRecipeIndex = 0;
  264. init();
  265. } else if (categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) {
  266. selectedRecipeIndex--;
  267. if (selectedRecipeIndex < 0)
  268. selectedRecipeIndex = categoryMap.get(categories.get(selectedCategoryIndex)).size() - 1;
  269. init();
  270. return true;
  271. }
  272. }
  273. return super.mouseScrolled(double_1, double_2, double_3);
  274. }
  275. @Override
  276. public void render(int mouseX, int mouseY, float delta) {
  277. if (RoughlyEnoughItemsCore.getConfigManager().getConfig().doesVillagerScreenHavePermanentScrollBar()) {
  278. scrollBarAlphaFutureTime = System.currentTimeMillis();
  279. scrollBarAlphaFuture = 0;
  280. scrollBarAlpha = 1;
  281. } else if (scrollBarAlphaFutureTime > 0) {
  282. long l = System.currentTimeMillis() - scrollBarAlphaFutureTime;
  283. if (l > 300f) {
  284. if (scrollBarAlphaFutureTime == 0) {
  285. scrollBarAlpha = scrollBarAlphaFuture;
  286. scrollBarAlphaFutureTime = -1;
  287. } else if (l > 2000f && scrollBarAlphaFuture == 1) {
  288. scrollBarAlphaFuture = 0;
  289. scrollBarAlphaFutureTime = System.currentTimeMillis();
  290. } else
  291. scrollBarAlpha = scrollBarAlphaFuture;
  292. } else {
  293. if (scrollBarAlphaFuture == 0)
  294. scrollBarAlpha = Math.min(scrollBarAlpha, 1 - Math.min(1f, l / 300f));
  295. else if (scrollBarAlphaFuture == 1)
  296. scrollBarAlpha = Math.max(Math.min(1f, l / 300f), scrollBarAlpha);
  297. }
  298. }
  299. this.fillGradient(0, 0, this.width, this.height, -1072689136, -804253680);
  300. int yOffset = 0;
  301. this.widgets.forEach(widget -> {
  302. GuiLighting.disable();
  303. widget.render(mouseX, mouseY, delta);
  304. });
  305. GuiLighting.disable();
  306. ScreenHelper.getLastOverlay().render(mouseX, mouseY, delta);
  307. GlStateManager.pushMatrix();
  308. Scissors.begin();
  309. Scissors.scissor(0, scrollListBounds.y + 1, width, scrollListBounds.height - 2);
  310. for (int i = 0; i < buttonWidgets.size(); i++) {
  311. ButtonWidget buttonWidget = buttonWidgets.get(i);
  312. buttonWidget.getBounds().y = scrollListBounds.y + 1 + yOffset - (int) scroll;
  313. if (buttonWidget.getBounds().getMaxY() > scrollListBounds.getMinY() && buttonWidget.getBounds().getMinY() < scrollListBounds.getMaxY()) {
  314. GuiLighting.disable();
  315. buttonWidget.render(mouseX, mouseY, delta);
  316. }
  317. yOffset += buttonWidget.getBounds().height;
  318. }
  319. for (int i = 0; i < buttonWidgets.size(); i++) {
  320. if (buttonWidgets.get(i).getBounds().getMaxY() > scrollListBounds.getMinY() && buttonWidgets.get(i).getBounds().getMinY() < scrollListBounds.getMaxY()) {
  321. GuiLighting.disable();
  322. recipeRenderers.get(i).setBlitOffset(1);
  323. recipeRenderers.get(i).render(buttonWidgets.get(i).getBounds().x, buttonWidgets.get(i).getBounds().y, mouseX, mouseY, delta);
  324. }
  325. }
  326. double height = buttonWidgets.stream().map(ButtonWidget::getBounds).collect(Collectors.summingDouble(Rectangle::getHeight));
  327. if (height > scrollListBounds.height - 2) {
  328. Tessellator tessellator = Tessellator.getInstance();
  329. BufferBuilder buffer = tessellator.getBufferBuilder();
  330. double maxScroll = height - scrollListBounds.height + 2;
  331. int scrollBarHeight = MathHelper.floor((scrollListBounds.height - 2) * (scrollListBounds.height - 2) / maxScroll);
  332. scrollBarHeight = MathHelper.clamp(scrollBarHeight, 32, scrollListBounds.height - 2 - 8);
  333. int minY = (int) (scroll * (scrollListBounds.height - 2 - scrollBarHeight) / maxScroll) + scrollListBounds.y + 1;
  334. if (minY < this.scrollListBounds.y + 1)
  335. minY = this.scrollListBounds.y + 1;
  336. double scrollbarPositionMinX = scrollListBounds.getMaxX() - 6, scrollbarPositionMaxX = scrollListBounds.getMaxX() - 2;
  337. GuiLighting.disable();
  338. GlStateManager.disableTexture();
  339. GlStateManager.enableBlend();
  340. GlStateManager.disableAlphaTest();
  341. GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
  342. GlStateManager.shadeModel(7425);
  343. buffer.begin(7, VertexFormats.POSITION_COLOR);
  344. float b = ScreenHelper.isDarkModeEnabled() ? 0.37f : 1f;
  345. buffer.vertex(scrollbarPositionMinX, minY + scrollBarHeight, 1000D).color(b, b, b, scrollBarAlpha).next();
  346. buffer.vertex(scrollbarPositionMaxX, minY + scrollBarHeight, 1000D).color(b, b, b, scrollBarAlpha).next();
  347. buffer.vertex(scrollbarPositionMaxX, minY, 1000D).color(b, b, b, scrollBarAlpha).next();
  348. buffer.vertex(scrollbarPositionMinX, minY, 1000D).color(b, b, b, scrollBarAlpha).next();
  349. tessellator.draw();
  350. GlStateManager.shadeModel(7424);
  351. GlStateManager.disableBlend();
  352. GlStateManager.enableAlphaTest();
  353. GlStateManager.enableTexture();
  354. }
  355. Scissors.end();
  356. GlStateManager.popMatrix();
  357. ScreenHelper.getLastOverlay().lateRender(mouseX, mouseY, delta);
  358. }
  359. @Override
  360. public boolean mouseDragged(double mouseX, double mouseY, int int_1, double double_3, double double_4) {
  361. if (int_1 == 0 && scrollBarAlpha > 0 && draggingScrollBar) {
  362. double height = buttonWidgets.stream().map(ButtonWidget::getBounds).collect(Collectors.summingDouble(Rectangle::getHeight));
  363. int actualHeight = scrollListBounds.height - 2;
  364. if (height > actualHeight && mouseY >= scrollListBounds.y + 1 && mouseY <= scrollListBounds.getMaxY() - 1) {
  365. int int_3 = MathHelper.clamp((int) ((actualHeight * actualHeight) / height), 32, actualHeight - 8);
  366. double double_6 = Math.max(1.0D, Math.max(1d, height) / (double) (actualHeight - int_3));
  367. scrollBarAlphaFutureTime = System.currentTimeMillis();
  368. scrollBarAlphaFuture = 1f;
  369. scroll = MathHelper.clamp(scroll + double_4 * double_6, 0, height - scrollListBounds.height + 2);
  370. return true;
  371. }
  372. }
  373. return super.mouseDragged(mouseX, mouseY, int_1, double_3, double_4);
  374. }
  375. private int getReal(int i) {
  376. return (int) (i / ((double) minecraft.window.getScaledWidth() / (double) minecraft.window.getWidth()));
  377. }
  378. @Override
  379. public boolean keyPressed(int int_1, int int_2, int int_3) {
  380. if ((int_1 == 256 || this.minecraft.options.keyInventory.matchesKey(int_1, int_2)) && this.shouldCloseOnEsc()) {
  381. MinecraftClient.getInstance().openScreen(ScreenHelper.getLastContainerScreen());
  382. ScreenHelper.getLastOverlay().init();
  383. return true;
  384. }
  385. if (int_1 == 258) {
  386. boolean boolean_1 = !hasShiftDown();
  387. if (!this.changeFocus(boolean_1))
  388. this.changeFocus(boolean_1);
  389. return true;
  390. }
  391. if (ClientHelper.getInstance().getNextPageKeyBinding().matchesKey(int_1, int_2)) {
  392. if (categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) {
  393. selectedRecipeIndex++;
  394. if (selectedRecipeIndex >= categoryMap.get(categories.get(selectedCategoryIndex)).size())
  395. selectedRecipeIndex = 0;
  396. init();
  397. return true;
  398. }
  399. return false;
  400. } else if (ClientHelper.getInstance().getPreviousPageKeyBinding().matchesKey(int_1, int_2)) {
  401. if (categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) {
  402. selectedRecipeIndex--;
  403. if (selectedRecipeIndex < 0)
  404. selectedRecipeIndex = categoryMap.get(categories.get(selectedCategoryIndex)).size() - 1;
  405. init();
  406. return true;
  407. }
  408. return false;
  409. }
  410. for (Element element : children())
  411. if (element.keyPressed(int_1, int_2, int_3))
  412. return true;
  413. return super.keyPressed(int_1, int_2, int_3);
  414. }
  415. }