Esempio n. 1
0
 public static void updateInterfaces(int mouseX, int mouseY, int width, int height, int scale)
 {
   int i;
   if (actionTimer <= 0)
   {
     if ((XaeroMinimap.events.lastGuiOpen instanceof GuiEditMode))
     {
       if (Mouse.isButtonDown(1)) {
         selectedId = -1;
       }
       i = getInterfaceId(mouseX, mouseY, width, height, scale);
       if (i == -1) {
         i = selectedId;
       }
       if (i != -1)
       {
         if ((Mouse.isButtonDown(0)) && (draggingId == -1))
         {
           draggingId = i;
           selectedId = i;
           if (((Interface)list.get(i)).fromRight) {
             ((Interface)list.get(i)).x = (width - ((Interface)list.get(i)).x);
           }
           draggingOffX = ((Interface)list.get(i)).x - mouseX;
           draggingOffY = ((Interface)list.get(i)).y - mouseY;
           if (((Interface)list.get(i)).fromRight) {
             ((Interface)list.get(i)).x = (width - ((Interface)list.get(i)).x);
           }
         }
         else if ((!Mouse.isButtonDown(0)) && (draggingId != -1))
         {
           draggingId = -1;
           draggingOffX = 0;
           draggingOffY = 0;
         }
         if (selectedId != -1) {
           i = selectedId;
         }
         if ((Keyboard.isKeyDown(33)) && (System.currentTimeMillis() - lastFlip > 300L))
         {
           lastFlip = System.currentTimeMillis();
           ((Interface)list.get(i)).flipped = (!((Interface)list.get(i)).flipped);
         }
         if ((Keyboard.isKeyDown(46)) && (System.currentTimeMillis() - lastFlip > 300L))
         {
           lastFlip = System.currentTimeMillis();
           ((Interface)list.get(i)).centered = (!((Interface)list.get(i)).centered);
         }
         if (Keyboard.isKeyDown(31))
         {
           selectedId = -1;
           draggingId = -1;
           switch (i)
           {
           case 4: 
             mc.a(new GuiMinimap(XaeroMinimap.getSettings()));
           }
         }
       }
       if (draggingId != -1)
       {
         if (!((Interface)list.get(draggingId)).centered)
         {
           ((Interface)list.get(draggingId)).actualx = (mouseX + draggingOffX);
           if (((Interface)list.get(draggingId)).fromRight) {
             ((Interface)list.get(draggingId)).actualx = (width - ((Interface)list.get(draggingId)).actualx);
           }
         }
         if (((Interface)list.get(draggingId)).actualx > width / 2)
         {
           ((Interface)list.get(draggingId)).fromRight = (!((Interface)list.get(draggingId)).fromRight);
           ((Interface)list.get(draggingId)).actualx = (width - ((Interface)list.get(draggingId)).actualx);
         }
         ((Interface)list.get(draggingId)).actualy = (mouseY + draggingOffY);
       }
     }
   }
   else {
     actionTimer -= 1;
   }
   for (Interface j : list)
   {
     j.x = j.actualx;
     j.y = j.actualy;
     if (j.fromRight) {
       j.x = (width - j.x);
     }
     if (j.centered)
     {
       if (j.multi)
       {
         j.w = j.getWC(scale);
         j.h = j.getHC(scale);
       }
       j.x = (width / 2 - j.getW(scale) / 2);
     }
     else if (j.multi)
     {
       j.w = j.getW0(scale);
       j.h = j.getH0(scale);
     }
     if (j.x < 5) {
       j.x = 0;
     }
     if (j.y < 5) {
       j.y = 0;
     }
     if (j.x + j.getW(scale) > width - 5) {
       j.x = (width - j.getW(scale));
     }
     if (j.y + j.getH(scale) > height - 5) {
       j.y = (height - j.getH(scale));
     }
   }
 }