Advertisement
ViiRuS

Gui Tutorial #4

Dec 30th, 2011
884
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.17 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.awt.image.BufferedImage;
  4. import org.lwjgl.opengl.GL11;
  5.  
  6. public class GuiWhatever extends GuiScreen
  7. {
  8.  
  9.     private BufferedImage img;
  10.     private int imgID = 1000;
  11.     private int page = 0;
  12.     private GuiButton disabled;
  13.    
  14.     public void initGui()
  15.     {
  16.          try {
  17.              img = ModLoader.loadImage(mc.renderEngine, "/mods/test1.png");
  18.              mc.renderEngine.setupTexture(img, imgID);
  19.         } catch (Exception e) {
  20.              e.printStackTrace();
  21.         }
  22.             controlList.clear();
  23.             tabs();
  24.            
  25.            
  26.             switch(page){
  27.             case 0:
  28.                 controlList.add(new GuiButton(1, width / 2 - 6, height / 2 + 20, 78, 20, "Make it Rain!"));
  29.                 controlList.add(new GuiButton(2, width / 2 - 90, height / 2 + 20, 78, 20, "Stop the Rain!"));
  30.                 break;
  31.             case 1:
  32.                 controlList.add(disabled = new GuiButton(1, width / 2 - 90, height / 2 + 20, 160, 20, "Disabled"));
  33.                 disabled.drawButton = true;
  34.                 disabled.enabled = false;
  35.                 break;
  36.             }
  37.     }
  38.    
  39.     private void tabs() {
  40.         controlList.add(new GuiButton(3, width / 2 - 91, height / 2 - 56, 40, 20, "Page 1"));
  41.         controlList.add(new GuiButton(4, width / 2 - 51, height / 2 - 56, 40, 20, "Page 2"));
  42.         controlList.add(new GuiButton(5, width / 2 - 11, height / 2 - 56, 40, 20, "Page 3"));
  43.         controlList.add(new GuiButton(6, width / 2 + 29, height / 2 - 56, 40, 20, "Page 4"));
  44.        
  45.        
  46.        
  47.     }
  48.  
  49.     protected void actionPerformed(GuiButton guibutton)
  50.     {
  51.         if(guibutton.id == 1)
  52.         {
  53.             ModLoader.getMinecraftInstance().theWorld.setRainStrength(5F);
  54.             ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Rain Started!");
  55.         }
  56.         if(guibutton.id == 2)
  57.         {
  58.             ModLoader.getMinecraftInstance().theWorld.setRainStrength(0F);
  59.             ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Rain Stopped!");
  60.         }
  61.         if(guibutton.id == 3)
  62.         {
  63.             page = 0;
  64.             initGui();
  65.         }
  66.         if(guibutton.id == 4)
  67.         {
  68.             page = 1;
  69.             initGui();
  70.         }
  71.         if(guibutton.id == 5)
  72.         {
  73.             page = 2;
  74.             initGui();
  75.         }
  76.         if(guibutton.id == 6)
  77.         {
  78.             page = 3;
  79.             initGui();
  80.         }
  81.     }
  82.    
  83.     public boolean doesGuiPauseGame()
  84.     {
  85.         return false;
  86.     }
  87.    
  88.     public void drawScreen(int i, int j, float f)
  89.     {
  90.         drawDefaultBackground();
  91.          int x = width / 2 - 95;
  92.          int y = height / 2 - 60;
  93.          try{
  94.                  int wtf = mc.renderEngine.getTexture("/mods/test1.png");
  95.                  GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  96.                  mc.renderEngine.bindTexture(wtf);
  97.                  drawTexturedModalRect(x, y, 0, 0, 176, 166);
  98.         }
  99.         finally {
  100.         }
  101.         GL11.glPushMatrix();
  102.         GL11.glScalef(2.0F, 2.0F, 2.0F);
  103.         drawCenteredString(fontRenderer, "Weather Controller", width / 4, height / 4 - 50, 0x44ff11);
  104.         GL11.glPopMatrix();
  105.        
  106.         switch(page){
  107.         case 0:
  108.             drawString(fontRenderer, "Page 1", width / 2 - 90, height / 2 - 20, 0xCCCCCC);
  109.             break;
  110.         case 1:
  111.             drawString(fontRenderer, "Page 2", width / 2 - 90, height / 2 - 20, 0xCCCCCC);
  112.             break;
  113.         case 2:
  114.             drawString(fontRenderer, "Page 3", width / 2 - 90, height / 2 - 20, 0xCCCCCC);
  115.             break;
  116.         case 3:
  117.             drawString(fontRenderer, "Page 4", width / 2 - 90, height / 2 - 20, 0xCCCCCC);
  118.             break;
  119.         }
  120.         super.drawScreen(i, j, f);
  121.     }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement