Ejemplo n.º 1
0
  @Override
  protected Boolean updateVisibility(LiveGameData gameData, boolean isEditorMode) {
    super.updateVisibility(gameData, isEditorMode);

    ScoringInfo scoringInfo = gameData.getScoringInfo();

    if (!startedPositionsInitialized) initStartedFromPositions(scoringInfo);
    if (RaceInfosWidget.visible()) return false;

    currentLap.update(scoringInfo.getLeadersVehicleScoringInfo().getLapsCompleted());

    if (currentLap.hasChanged()
            && currentLap.getValue() > 0
            && (short) (Math.random() * randMulti.getValue()) == 0
        || isEditorMode) {

      // fetch what data is shown others-gaps 1-places gained/lost
      if (scoringInfo.getLeadersVehicleScoringInfo().getFinishStatus().isFinished() || isEditorMode)
        shownData = 1;
      else shownData = (short) (Math.random() * 2);

      if (scoringInfo.getGamePhase() == GamePhase.SESSION_OVER)
        visibleEnd = scoringInfo.getSessionNanos() + visibleTime.getDelayNanos() * 3;
      else visibleEnd = scoringInfo.getSessionNanos() + visibleTime.getDelayNanos();

      clearArrayValues(scoringInfo.getNumVehicles());
      FillArrayValues(1, scoringInfo, isEditorMode, gameData);
      if (!isEditorMode) forceCompleteRedraw(true);

      return true;
    }

    if (scoringInfo.getSessionNanos() < visibleEnd || isEditorMode) {
      // how many on the same lap?
      int onlap = 0;
      for (int j = 0; j < scoringInfo.getNumVehicles(); j++) {
        if (scoringInfo.getVehicleScoringInfo(j).getLapsCompleted()
            == scoringInfo.getLeadersVehicleScoringInfo().getLapsCompleted()) onlap++;
      }

      carsOnLeadLap.update(onlap);
      if (carsOnLeadLap.hasChanged() && !isEditorMode) {
        FillArrayValues(onlap, scoringInfo, false, gameData);
        forceCompleteRedraw(true);
      }
      return true;
    }

    return false;
  }
Ejemplo n.º 2
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);
    }
  }
Ejemplo n.º 3
0
  @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();

    if (needsCompleteRedraw) {
      int drawncars = Math.min(scoringInfo.getNumVehicles(), numVeh.getValue());
      short posOffset;

      for (int i = 0; i < drawncars; i++) {
        if (carsOnLeadLap.getValue() > numVeh.getValue() && i != 0)
          posOffset = (short) (carsOnLeadLap.getValue() - numVeh.getValue());
        else posOffset = 0;

        if (positions[i + posOffset] != -1) {
          if (positions[i + posOffset] == 1) dsPosTH[i].draw(offsetX, offsetY, "ST", texture);
          else if (positions[i + posOffset] == 2) dsPosTH[i].draw(offsetX, offsetY, "ND", texture);
          else if (positions[i + posOffset] == 3) dsPosTH[i].draw(offsetX, offsetY, "RD", texture);
          else if (positions[i + posOffset] >= 10)
            dsPosTH[i].draw(offsetX, offsetY, "  TH", texture);
          else dsPosTH[i].draw(offsetX, offsetY, "TH", texture);

          dsPos[i].draw(offsetX, offsetY, String.valueOf(positions[i + posOffset]), texture);
          dsNumber[i].draw(offsetX, offsetY, String.valueOf(number[i + posOffset]), texture);
          dsPit[i].draw(offsetX, offsetY, String.valueOf(pit[i + posOffset]), texture);
          if (shownData != 1) dsPitLabel[i].draw(offsetX, offsetY, "PIT", texture);
        }
        /*else
        {
            dsPos[i].draw( offsetX, offsetY, "", texture );
            dsNumber[i].draw( offsetX, offsetY, "", texture );
        }*/

        dsName[i].draw(offsetX, offsetY, names[i + posOffset], texture);
        dsTime[i].draw(offsetX, offsetY, gaps[i + posOffset], 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);
    }
  }
Ejemplo n.º 5
0
  @Override
  protected Boolean updateVisibility(LiveGameData gameData, boolean isEditorMode) {

    super.updateVisibility(gameData, isEditorMode);
    ScoringInfo scoringInfo = gameData.getScoringInfo();
    cveh.update(scoringInfo.getViewedVehicleScoringInfo().getDriverId());
    cpit.update(scoringInfo.getViewedVehicleScoringInfo().isInPits());

    if (QualTimeWidget.visible()) return false;

    if ((cveh.hasChanged() || cpit.hasChanged()) && !isEditorMode) {
      forceCompleteRedraw(true);
      visibleEnd = scoringInfo.getSessionNanos() + visibleTime.getDelayNanos();
      return true;
    }

    if (scoringInfo.getSessionNanos() < visibleEnd || cpit.getValue()) return true;

    return false;
  }
Ejemplo n.º 6
0
  @Override
  protected void drawBackground(
      LiveGameData gameData,
      boolean isEditorMode,
      TextureImage2D texture,
      int offsetX,
      int offsetY,
      int width,
      int height,
      boolean isRoot) {
    super.drawBackground(gameData, isEditorMode, texture, offsetX, offsetY, width, height, isRoot);
    // logCS("test");
    ScoringInfo scoringInfo = gameData.getScoringInfo();
    int maxNumItems = numVeh.getValue();
    int rowHeight = height / maxNumItems;
    int drawncars = Math.min(scoringInfo.getNumVehicles(), maxNumItems);
    short posOffset;

    for (int i = 0; i < drawncars; i++) {
      if (carsOnLeadLap.getValue() > numVeh.getValue() && i != 0)
        posOffset = (short) (carsOnLeadLap.getValue() - numVeh.getValue());
      else posOffset = 0;

      if (positions[i + posOffset] != -1 || isEditorMode) {

        if (scoringInfo
                .getVehicleScoringInfo(positions[i + posOffset] - 1)
                .getVehicleInfo()
                .getManufacturer()
                .toUpperCase()
                .equals("FORD")
            || (isEditorMode && (short) (Math.random() * 2) == 0))
          texture.clear(imgFord.getTexture(), offsetX, offsetY + rowHeight * i, false, null);
        else texture.clear(imgHolden.getTexture(), offsetX, offsetY + rowHeight * i, false, null);

        if (shownData == 1) {
          if (gainedPlaces[i + posOffset] > 0)
            texGainedPlaces =
                imgPositive
                    .getImage()
                    .getScaledTextureImage(
                        width * 9 / 100, rowHeight, texGainedPlaces, isEditorMode);
          else if (gainedPlaces[i + posOffset] < 0)
            texGainedPlaces =
                imgNegative
                    .getImage()
                    .getScaledTextureImage(
                        width * 9 / 100, rowHeight, texGainedPlaces, isEditorMode);
          else
            texGainedPlaces =
                imgNeutral
                    .getImage()
                    .getScaledTextureImage(
                        width * 9 / 100, rowHeight, texGainedPlaces, isEditorMode);

          texture.drawImage(
              texGainedPlaces, offsetX + width * 171 / 200, offsetY + rowHeight * i, true, null);
        }
      }
    }
  }
Ejemplo n.º 7
0
  @Override
  protected void initialize(
      LiveGameData gameData,
      boolean isEditorMode,
      DrawnStringFactory drawnStringFactory,
      TextureImage2D texture,
      int width,
      int height) {

    team.update("");
    name.update("");
    pos.update("");
    // gap.update( "" );
    // time.update( "" );

    int rowHeight = height / 2;
    int fh = TextureImage2D.getStringHeight("0", GP2Font);

    imgName.updateSize(width, rowHeight * 95 / 100, isEditorMode);
    imgNameFirst.updateSize(width, rowHeight * 95 / 100, isEditorMode);

    int top1 = (rowHeight - fh) / 2;
    int top2 = rowHeight + (rowHeight - fh) / 2;
    dsName =
        drawnStringFactory.newDrawnString(
            "dsName",
            width * 8 / 100,
            top1 + fontyoffset.getValue(),
            Alignment.LEFT,
            false,
            GP2Font.getFont(),
            isFontAntiAliased(),
            fontColor1.getColor());
    dsTeam =
        drawnStringFactory.newDrawnString(
            "dsTeam",
            width * 8 / 100,
            top2 + fontyoffset.getValue(),
            Alignment.LEFT,
            false,
            GP2Font.getFont(),
            isFontAntiAliased(),
            fontColor1.getColor());
    // Scan Country Folder

    File dir =
        new File(
            gameData.getFileSystem().getImagesFolder().toString()
                + "/prunn/PorscheSupercup/Countries");

    String[] children = dir.list();
    NumOfPNG = 0;
    listPNG = new String[children.length];

    for (int i = 0; i < children.length; i++) {
      // Get filename of file or directory
      String filename = children[i];

      if (filename.substring(filename.length() - 4).toUpperCase().equals(".PNG")) {
        // log(filename.substring( 0, filename.length()-4 ));
        listPNG[NumOfPNG] = filename.substring(0, filename.length() - 4);
        NumOfPNG++;
      }
    }

    // end of scan
  }
Ejemplo n.º 8
0
  @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);
    }
  }
Ejemplo n.º 9
0
  @Override
  protected void drawBackground(
      LiveGameData gameData,
      boolean isEditorMode,
      TextureImage2D texture,
      int offsetX,
      int offsetY,
      int width,
      int height,
      boolean isRoot) {
    super.drawBackground(gameData, isEditorMode, texture, offsetX, offsetY, width, height, isRoot);
    VehicleScoringInfo currentcarinfos = gameData.getScoringInfo().getViewedVehicleScoringInfo();
    int rowHeight = height / 2;

    if (currentcarinfos.getPlace(false) == 1)
      texture.clear(imgNameFirst.getTexture(), offsetX, offsetY, false, null);
    else texture.clear(imgName.getTexture(), offsetX, offsetY, false, null);

    texture.clear(imgName.getTexture(), offsetX, offsetY + rowHeight, false, null);
    // player

    if (currentcarinfos.isPlayer()) {
      if (new File(
              gameData.getFileSystem().getImagesFolder()
                  + "/prunn/PorscheSupercup/Nations/"
                  + gameData.getProfileInfo().getNationality()
                  + ".png")
          .exists())
        imgCountry.setValue(
            "prunn/PorscheSupercup/Nations/" + gameData.getProfileInfo().getNationality() + ".png");
      else imgCountry.setValue("prunn/PorscheSupercup/Nations/Alien.png");

      texCountry =
          imgCountry
              .getImage()
              .getScaledTextureImage(
                  width * 14 / 100, rowHeight * 61 / 100, texCountry, isEditorMode);
      texture.drawImage(
          texCountry, offsetX + width * 78 / 100, offsetY + rowHeight * 20 / 100, true, null);
    }
    // team
    if (currentcarinfos.getVehicleInfo() != null) {
      String headquarters = currentcarinfos.getVehicleInfo().getTeamHeadquarters().toUpperCase();
      for (int j = 0; j < NumOfPNG; j++) {
        if (headquarters.length() >= listPNG[j].length()
            && headquarters.contains(listPNG[j].toUpperCase())) {
          imgCountry.setValue("prunn/PorscheSupercup/Countries/" + listPNG[j] + ".png");
          texCountry =
              imgCountry
                  .getImage()
                  .getScaledTextureImage(
                      width * 14 / 100, rowHeight * 61 / 100, texCountry, isEditorMode);
          texture.drawImage(
              texCountry,
              offsetX + width * 78 / 100,
              offsetY + rowHeight + rowHeight * 20 / 100,
              true,
              null);
          break;
        }
      }
    }
  }