Example #1
0
  @Override
  protected void drawWidget(
      Clock clock,
      boolean needsCompleteRedraw,
      LiveGameData gameData,
      boolean isEditorMode,
      TextureImage2D texture,
      int offsetX,
      int offsetY,
      int width,
      int height) {

    AmbientTemp.update((int) Math.floor(gameData.getWeatherInfo().getAmbientTemperature()));
    TrackTemp.update((int) Math.floor(gameData.getWeatherInfo().getTrackTemperature()));

    if (ShowAmbiant.getValue() && (needsCompleteRedraw || AmbientTemp.hasChanged())) {
      dsAmbient.draw(offsetX, offsetY, Loc.ambiant_temp, texture);
      dsAmbientTemp.draw(offsetX, offsetY, AmbientTemp.getValueAsString(), texture);
    }
    if (needsCompleteRedraw || TrackTemp.hasChanged()) {
      dsTrack.draw(offsetX, offsetY, Loc.track_temp, texture);
      dsTrackTemp.draw(offsetX, offsetY, TrackTemp.getValueAsString(), texture);
    }
  }
  @Override
  protected void drawWidget(
      Clock clock,
      boolean needsCompleteRedraw,
      LiveGameData gameData,
      boolean isEditorMode,
      TextureImage2D texture,
      int offsetX,
      int offsetY,
      int width,
      int height) {
    /*
     * Here you can see one of the very important tricks, that rfDynHUD uses to optimize performace.
     *
     * Dynamic texts need to be redrawn frequently. And the changed pixel data needs to be sent to
     * the graphics card. This cannot be done every single frame, since this would eysily drop your
     * FPS by a huge amount.
     *
     * We only need and want the text to be redrawn when it has actually changed. And we want all changed
     * pixels to be sent at certain time slots, because sending a hundred pixels at once is not much more
     * expensive then sending a single pixel. Yet, sending one pixel at a hundred frames in a row IS expensive.
     *
     * This is, what the two clock parameters are good for. clock1 is for very dynamic content and will
     * always be 'true', when you can safely send new pixel data at a high frequency.
     * clock2 is the same, but has 1/3 of the frequency of clock1.
     *
     * We will use the car's velocity, since this is one of the most dynamic values here.
     *
     * All we need to do, is to redraw the text, if the whole widget needs to be redrawn or the value has changed
     * AND we hit a time spot to redraw. Since the velocity will most likely change most of the time,
     * we simply ask for that time spot (clock).
     */
    if (needsCompleteRedraw || clock.c()) {
      /*
       * Here we can use getScalarVelocityKPH() or getScalarVelocityMPH() to explicitly use these units
       * or use getScalarVelocity() to use rFactor's setting to decide about that.
       */
      int velocity = (int) gameData.getTelemetryData().getScalarVelocity();

      ds.draw(offsetX, offsetY, String.valueOf(velocity), texture);
    }
  }
  @Override
  protected void drawWidget(
      Clock clock,
      boolean needsCompleteRedraw,
      LiveGameData gameData,
      boolean isEditorMode,
      TextureImage2D texture,
      int offsetX,
      int offsetY,
      int width,
      int height) {
    ScoringInfo scoringInfo = gameData.getScoringInfo();
    sessionTime.update(scoringInfo.getSessionTime());

    if (needsCompleteRedraw) {
      VehicleScoringInfo currentcarinfos = gameData.getScoringInfo().getViewedVehicleScoringInfo();

      name.update(PrunnWidgetSetPorscheSupercup.ShortName(currentcarinfos.getDriverNameShort()));
      pos.update(NumberUtil.formatFloat(currentcarinfos.getPlace(false), 0, true));
      team.update(
          PrunnWidgetSetPorscheSupercup.generateShortTeamNames(
              currentcarinfos.getVehicleInfo().getTeamName(),
              gameData.getFileSystem().getConfigFolder()));

      if (team.getValue().length() > 8
          && (team.getValue().substring(0, 5).equals("PMSCS")
              || team.getValue().substring(0, 5).equals("PCCAU")))
        team.update(team.getValue().substring(8));
      else if (team.getValue().length() > 7
          && (team.getValue().substring(0, 4).equals("PMSC")
              || team.getValue().substring(0, 4).equals("PCCG")
              || team.getValue().substring(0, 4).equals("PCCA")
              || team.getValue().substring(0, 4).equals("ALMS")))
        team.update(team.getValue().substring(7));
      else if (team.getValue().length() > 6
          && (team.getValue().substring(0, 3).equals("LMS")
              || team.getValue().substring(0, 3).equals("FIA")))
        team.update(team.getValue().substring(6));
      else if (team.getValue().length() > 5 && (team.getValue().substring(0, 2).equals("LM")))
        team.update(team.getValue().substring(5));

      if (team.getValue().length() > MaxTeamLengh.getValue())
        team.update(team.getValue().substring(0, MaxTeamLengh.getValue()));

      /*if( currentcarinfos.getFastestLaptime() != null && currentcarinfos.getFastestLaptime().getLapTime() > 0 )
      {
          if(currentcarinfos.getPlace( false ) > 1)
          {
              time.update( TimingUtil.getTimeAsLaptimeString(currentcarinfos.getBestLapTime() ));
              gap.update( "+ " +  TimingUtil.getTimeAsLaptimeString( currentcarinfos.getBestLapTime() - gameData.getScoringInfo().getLeadersVehicleScoringInfo().getBestLapTime() ));
          }
          else
          {
              time.update("");
              gap.update( TimingUtil.getTimeAsLaptimeString(currentcarinfos.getBestLapTime()));
          }

      }
      else
      {
          time.update("");
          gap.update("");
      }*/
      dsName.draw(
          offsetX,
          offsetY,
          name.getValue(),
          (currentcarinfos.getPlace(false) == 1) ? fontColor2.getColor() : fontColor1.getColor(),
          texture);
      dsTeam.draw(offsetX, offsetY, team.getValue(), texture);
    }
  }