Ejemplo n.º 1
0
  public void draw(DrawWindow dw) {
    // Check if GPS enabled
    if (!ctx.gpsEnabled()) {
      ARXMessages.putMessage(
          "GPS_ENABLED",
          "GPS not Enabled (see Settings->Security & location->Enable GPS)",
          ARXMessages.errorIcon,
          500);
    } else if (!ctx.gpsSignalReceived()) {
      // Check if GPS signal received
      ARXMessages.putMessage("GPS_WAIT", "Waiting for GPS signal", ARXMessages.worldIcon, 500);
    }

    // Check for compass accuracy
    if (ctx.isCompassAccuracyLow()) {
      ARXMessages.putMessage(
          "COMPASS_ACCURACY", "Compass accuracy low", ARXMessages.compassIcon, 1000);
    }

    //        if (ctx.gpsEnabled()) {
    drawDimension(dw);
    //        } else {
    //            purgeEvents();
    //        }

    ARXMessages.expireMessages();
    int msgCount = ARXMessages.getMessageCount();
    float msgHeight = 0, msgWidth = 0;
    float msgPad = 10;
    int startMsg = 0, maxMsg = 1;

    if (state.isMessagesVisible() && msgCount > maxMsg) {
      startMsg = msgCount - maxMsg;
    }

    for (int i = startMsg; i < msgCount; i++) {
      Message msg = (Message) ARXMessages.getMessage(i);
      if (!msg.init) msg.init(dw, width - msgPad * 2);

      if (state.isMessagesVisible()) {
        msg.showFullMessage(true);
        msgHeight += msg.getHeight() + 1;
        dw.drawObject(msg, msgPad, height - msgHeight - msgPad, 0, 1);
      } else {
        if (msg.isImportant()) {
          msgHeight = msg.getHeight();
          msg.showFullMessage(false);
          dw.drawObject(msg, msgPad + msgWidth, height - msgHeight - msgPad, 0, 1);
          msgWidth += msg.getWidth() + 1;
        }
      }
    }
  }