예제 #1
0
 public Point getDrag() {
   Point mouse = getMousePosition();
   Point drag = new Point(mouse.x - dragDown.x, mouse.y - dragDown.y);
   Dimension size = displaySize();
   Dimension sample = sampleSize();
   drag.x *= 10000;
   drag.y *= 10000;
   drag.x /= (size.width - sample.width);
   drag.y /= (size.height - sample.height);
   Point pos = getPos();
   drag.x = (int) MathHelper.clip(drag.x, -pos.x, 10000 - pos.x);
   drag.y = (int) MathHelper.clip(drag.y, -pos.y, 10000 - pos.y);
   return drag;
 }
예제 #2
0
  public static void drawMultilineTip(int x, int y, List<String> list) {
    if (list.isEmpty()) return;

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    RenderHelper.disableStandardItemLighting();

    int w = 0;
    int h = -2;
    for (int i = 0; i < list.size(); i++) {
      String s = list.get(i);
      ITooltipLineHandler line = getTipLine(s);
      Dimension d =
          line != null
              ? line.getSize()
              : new Dimension(
                  getStringWidth(s),
                  list.get(i).endsWith(TOOLTIP_LINESPACE) && i + 1 < list.size() ? 12 : 10);
      w = Math.max(w, d.width);
      h += d.height;
    }

    if (x < 8) x = 8;
    else if (x > displaySize().width - w - 8) x -= 24 + w; // flip side of cursor
    y = (int) MathHelper.clip(y, 8, displaySize().height - 8 - h);

    gui.incZLevel(300);
    drawTooltipBox(x - 4, y - 4, w + 7, h + 7);
    for (String s : list) {
      ITooltipLineHandler line = getTipLine(s);
      if (line != null) {
        line.draw(x, y);
        y += line.getSize().height;
      } else {
        fontRenderer.drawStringWithShadow(s, x, y, -1);
        y += s.endsWith(TOOLTIP_LINESPACE) ? 12 : 10;
      }
    }

    tipLineHandlers.clear();
    gui.incZLevel(-300);

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    RenderHelper.enableGUIStandardItemLighting();
  }