Guest User

Untitled

a guest
Aug 26th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.22 KB | None | 0 0
  1. package disconsented.anssrpg.gui;
  2.  
  3. import net.minecraft.client.Minecraft;
  4. import net.minecraft.client.gui.GuiButton;
  5. import net.minecraft.client.gui.GuiScreen;
  6. import net.minecraft.client.renderer.Tessellator;
  7.  
  8. import org.lwjgl.opengl.GL11;
  9.  
  10. import disconsented.anssrpg.helper.Color;
  11.  
  12. public class PerkGUI extends GuiScreen {
  13. //  private static final ResourceLocation TEXTURE = new ResourceLocation("anssrpg", "textures/gui/gui_perk.png");
  14.     public static final int GUI_ID = 1;
  15.     private GuiButton buttonNext;
  16.     private GuiButton buttonPrev;
  17.     private GuiButton buttonPerk1;
  18.     private GuiButton buttonPerk2;
  19.     private GuiButton buttonPerk3;
  20.     private GuiButton buttonPerk4;
  21.     private GuiButton buttonPerk5;
  22.     private GuiButton buttonPerk6;
  23.     //private Button next;
  24.  
  25.     @Override
  26.     public void updateScreen() {
  27.         this.drawDefaultBackground();
  28.     }
  29.     void drawRectangle(int x, int y, int width, int height, int color){
  30.         GuiScreen.drawRect(x, y, width, height, color);
  31.     }
  32.     void drawTriangle(int x, int y, int width, int height, int color, int mode){
  33.      GL11.glEnable(GL11.GL_BLEND);
  34.      GL11.glDisable(GL11.GL_TEXTURE_2D);
  35.      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  36.      Tessellator tes = Tessellator.instance;
  37.      tes.startDrawing(GL11.GL_TRIANGLES);
  38.      tes.setColorOpaque_I(color);
  39.      switch (mode){
  40.      case 1:
  41.          tes.addVertex(x, y, 0); //top left
  42.          tes.addVertex(x, y+height, 0); //Bottom left
  43.          tes.addVertex(x+width, y, 0); //top right  
  44.          break;
  45.      case 2:
  46.          break;
  47.      case 3:
  48.         tes.addVertex(x+width, y, 0); //top right
  49.         tes.addVertex(x, y+height, 0); //Bottom left
  50.         tes.addVertex(x+width, y+height, 0); //bottom right
  51.          break;
  52.      case 4:
  53.          break;
  54.      }       
  55.      tes.draw();
  56.     GL11.glEnable(GL11.GL_TEXTURE_2D);
  57.      GL11.glDisable(GL11.GL_BLEND);
  58.        
  59.     }
  60.  
  61.     @Override //Each frame
  62.     public void drawScreen(int par1, int par2, float par3) {
  63.         int xMod = 84;
  64.         int yMod = 48;
  65.         int border = 2;
  66.         this.drawDefaultBackground();
  67.        
  68.         //Black outline
  69.         drawRectangle(2*xMod-border, 2*yMod-border, 9*xMod+border, 9*yMod+border, 0xFF000000);
  70.         //Two triangles for the edges
  71.         drawTriangle(2*xMod, 2*yMod, 7*xMod, 7*yMod, 0xFFFFFF, 1);
  72.         drawTriangle(2*xMod, 2*yMod, 7*xMod, 7*yMod, 0x8B8B8B, 3);
  73.         //Overlay square
  74.         drawRectangle(2*xMod+border, 2*yMod+border, 9*xMod-border, 9*yMod-border, 0xFFC6C6C6);
  75.         for (int i = 0; i < 12; i++){
  76.             if(i%2==0){
  77.                 int x1 = 2*xMod+border*2;
  78.                 int y1 = 2*yMod+border+(yMod*i)/2;
  79.                 int x2 = 5*xMod;
  80.                 int y2 = (int) (y1+yMod/1.5);
  81.                 //System.out.println(i);
  82.                 //System.out.println(x1+"|"+y1+"|"+x2+"|"+y2);
  83.                 //drawTriangle(x1, y1, x2, y2,0xFFFFFFFF,1);//
  84.                 //drawTriangle(x1, y1, x2, y2,0xFF000000,3);
  85.                 //drawTriangle(x1+border-1,y1+border-1,x2-border+1,y2-border+1,Color.white, 1);//White - 1
  86.                 //drawTriangle(x1+border+1,y1+border+1,x2-border-1,y2-border-1,Color.greyDark, 3);//Dark Gery + 1
  87.                 drawRectangle(x1+border,y1+border,x2-border,y2-border,Color.greyDark);
  88.             }
  89.         }
  90.         //drawRectangle(6*xMod, 2*yMod+(border*2),(int)(8.5*xMod),(int)(8.5*yMod),Color.greyDark);
  91.         drawTriangle(6*xMod, 2*yMod+(border*2),(int)(3*xMod-border*2),(int)(5*yMod-border*2),Color.greyDeep,1);
  92.         drawTriangle(6*xMod, 2*yMod+(border*2),(int)(3*xMod-border*2),(int)(5*yMod-border*2),Color.black,3);
  93.         drawTriangle(6*xMod+border, 2*yMod+(border*3),(int)(3*xMod-(border*4)),(int)(5*yMod-(border*4)),Color.greyDark,1);
  94.         drawTriangle(6*xMod+border, 2*yMod+(border*3),(int)(3*xMod-(border*4)),(int)(5*yMod-(border*4)),Color.greyDark,3);
  95.         buttonPerk1.drawButton(Minecraft.getMinecraft(), 100, 100);
  96.         buttonPerk1.enabled = false;
  97.         buttonPerk2.drawButton(Minecraft.getMinecraft(), 20, 20);
  98.         buttonPerk3.drawButton(Minecraft.getMinecraft(), 20, 20);
  99.         buttonPerk4.drawButton(Minecraft.getMinecraft(), 20, 20);
  100.         buttonPerk5.drawButton(Minecraft.getMinecraft(), 20, 20);
  101.         buttonPerk6.drawButton(Minecraft.getMinecraft(), 20, 20);
  102. //draw from 6*xMod to 7*xMod
  103. //Draw from y1      
  104.     }
  105.    
  106.     @Override //Opened and resized
  107.     public void initGui() {
  108.         super.initGui(); //I see this done a ton and I don't understand why
  109.         //buttonNext = new GuiButton(1,);
  110.         buttonPerk1 = new GuiButton(1,172,98,248,32, "Stuff1");
  111.         buttonPerk2 = new GuiButton(2,172,146,248,32,"Stuff2");
  112.         buttonPerk3 = new GuiButton(3,172,194,248,32,"Stuff3");
  113.         buttonPerk4 = new GuiButton(4,172,242,248,32,"Stuff4");
  114.         buttonPerk5 = new GuiButton(5,172,290,248,32,"Stuff5");
  115.         buttonPerk6 = new GuiButton(6,172,338,248,32,"Stuff6");
  116.        
  117.     }
  118.  
  119.    /* @Override //Probably not needed
  120.     protected void keyTyped(char par1, int par2) {
  121.  
  122.     }*/
  123.  
  124.     @Override
  125.     protected void mouseClicked(int par1, int par2, int par3) {
  126.         System.out.println("A click "+par1+" "+par2+" "+par3);
  127.         System.out.println(buttonPerk1.getHoverState(true));
  128.         System.out.println(buttonPerk1.getHoverState(false));
  129.        
  130.         //buttonPerk1.
  131.     }
  132.  
  133.     @Override
  134.     protected void actionPerformed(GuiButton button) {
  135.         System.out.println(button.toString());
  136.     }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment