Guest User

GuiScreen.drawScreen() with Button Hovering Text

a guest
Apr 9th, 2014
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. @Override
  2. public void drawScreen(int mouseX, int mouseY, float f) {
  3. // Draw your stuff like Textures and Strings
  4. this.drawDefaultBackground();
  5. drawRect(width / 2 - 105, 60, width / 2 - 35, height / 2 + 5, new Color(50, 170, 170, 70).getRGB());
  6. this.drawCenteredString(fontRendererObj, I18n.format("menu.title"), width / 2, 25, Color.WHITE.getRGB());
  7.  
  8. // Call this methods super, as it draws buttons and stuff
  9. super.drawScreen(x, y, f);
  10.  
  11. // Add the hovering for all GuiButtons in the buttonList
  12. for (int i = 0; i < buttonList.size(); i++) {
  13. if (buttonList.get(i) instanceof GuiButton) {
  14. GuiButton btn = (GuiButton) buttonList.get(i);
  15. if (btn.func_146115_a()) { // Tells you if the button is hovered by mouse
  16. String[] desc = { "WHAT_EVER_TEXT_YOU_WANT" };
  17. @SuppressWarnings("rawtypes")
  18. List temp = Arrays.asList(desc);
  19. drawHoveringText(temp, x, y, fontRendererObj);
  20. }
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment