예제 #1
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);
    }
  }
예제 #2
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
  }
예제 #3
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;
        }
      }
    }
  }