Пример #1
0
 /**
  * Set the current value of this entry. This is a internal function that is required to update the
  * state of this instance.
  *
  * @param val the value the current value is supposed to be set to
  */
 void setCurrentValue(final int val) {
   currentValue = FastMath.clamp(val, entry.getRange());
   display.setText(Integer.toString(currentValue));
 }
 /**
  * This functions returns if this pointer is on the mini map right now or outside of it.
  *
  * @return {@code true} in case the pointer is on the map
  */
 private boolean isOnMapArea() {
   return FastMath.sqrt(FastMath.sqr(currentDeltaX) + FastMath.sqr(currentDeltaY)) < 71;
 }
Пример #3
0
 /** Save the value in this text entry to the configuration. */
 @Override
 public void save() {
   entry.setValue(FastMath.clamp(currentValue, entry.getRange()));
 }
  @Override
  public void renderImage(
      @Nonnull final Graphics g,
      final int x,
      final int y,
      final int w,
      final int h,
      final int srcX,
      final int srcY,
      final int srcW,
      final int srcH,
      @Nonnull final Color color,
      final float scale,
      final int centerX,
      final int centerY) {
    final int scaledWidth = Math.round(w * scale);
    final int scaledHeight = Math.round(h * scale);

    final int fixedX = x + Math.round((w - scaledWidth) * ((float) centerX / (float) w));
    final int fixedY = y + Math.round((h - scaledHeight) * ((float) centerY / (float) h));

    if (isOnMapArea()) {
      final int offsetX =
          (FastMath.sqrt(FastMath.sqr(currentDeltaX) / 2) * -FastMath.sign(currentDeltaX))
              + (FastMath.sqrt(FastMath.sqr(currentDeltaY) / 2) * -FastMath.sign(currentDeltaY));
      final int offsetY =
          (FastMath.sqrt(FastMath.sqr(currentDeltaX) / 2) * FastMath.sign(currentDeltaX))
              + (FastMath.sqrt(FastMath.sqr(currentDeltaY) / 2) * -FastMath.sign(currentDeltaY));

      final Color renderColor;
      if (available) {
        renderColor = POINTER_COLOR;
      } else {
        renderColor = color;
      }

      g.drawTexture(
          pointSprite.getFrame(0),
          fixedX - offsetX,
          fixedY - offsetY,
          scaledWidth,
          scaledHeight,
          srcX,
          srcY,
          srcW,
          srcH,
          centerX - fixedX,
          centerY - fixedY,
          0.f,
          renderColor);
    }
  }