@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; }
@Override public void onCockpitEntered(LiveGameData gameData, boolean isEditorMode) { super.onCockpitEntered(gameData, isEditorMode); String cpid = "Y29weXJpZ2h0QFBydW5uMjAxMQ"; if (!isEditorMode) log(cpid); drawnCars.reset(); visibleEnd = 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 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; }
@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 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); } } } }