Skip to content
This repository has been archived by the owner on Jul 24, 2022. It is now read-only.

Commit

Permalink
bug fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
3ximus committed Jun 18, 2020
1 parent 390aee6 commit 75bdc37
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ App for our assetto corsa Formula 1 championship.

Can be tweaked for other championships using the "teams.ini" file.

During the race it saves a file that can be read when replaying the race to be able to load the whole UI again.
During the race a file is saved, that will be read by the app during a race replay to be able to load the whole UI again. However currently **it only saves different files for each combination of track and car**.

## STILL A WORK IN PROGRESS!!

Expand Down
55 changes: 43 additions & 12 deletions apps/python/F12020Leaderboard/DriverComparisonWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,66 +18,91 @@ def __init__(self, appName):

self.backgroundTexture = ac.addLabel(self.window, "")
ac.setPosition(self.backgroundTexture, 0,0)
ac.setSize(self.backgroundTexture, 700, 50)
ac.setSize(self.backgroundTexture, 800, 50)
ac.setBackgroundTexture(self.backgroundTexture, FC.DRIVER_WIDGET_BACKGROUND_ALTERNATE);

self.extendedBackgroundTexture = ac.addLabel(self.window, "")
ac.setPosition(self.extendedBackgroundTexture, 0, 50)
ac.setSize(self.extendedBackgroundTexture, 700, 100)
ac.setSize(self.extendedBackgroundTexture, 800, 92)
ac.setBackgroundTexture(self.extendedBackgroundTexture, FC.LEADERBOARD_BACKGROUND);

self.rolexLabel = ac.addLabel(self.window, "")
ac.setPosition(self.rolexLabel, 0, -72)
ac.setSize(self.rolexLabel, 123, 70)
ac.setBackgroundTexture(self.rolexLabel, FC.ROLEX_LOGO);

self.speedometerIconLabel = ac.addLabel(self.window, "")
ac.setPosition(self.speedometerIconLabel, 378, 3)
ac.setSize(self.speedometerIconLabel, 44, 44)
ac.setBackgroundTexture(self.speedometerIconLabel, FC.SPEEDOMETER_ICON);

# ==========================================

self.positionLabel1 = ac.addLabel(self.window, "")
ac.setPosition(self.positionLabel1, 3,3)
ac.setSize(self.positionLabel1, 44, 44)

self.positionLabel2 = ac.addLabel(self.window, "")
ac.setPosition(self.positionLabel2, 383,3)
ac.setPosition(self.positionLabel2, 433,3)
ac.setSize(self.positionLabel2, 44, 44)

# ==========================================

self.teamLabel1 = ac.addLabel(self.window, "")
ac.setPosition(self.teamLabel1, 57, 10)
ac.setPosition(self.teamLabel1, 56, 10)
ac.setSize(self.teamLabel1, 6, 27)

self.teamLabel2 = ac.addLabel(self.window, "")
ac.setPosition(self.teamLabel2, 437, 10)
ac.setPosition(self.teamLabel2, 486, 10)
ac.setSize(self.teamLabel2, 6, 27)

# ==========================================

self.nameLabel1 = ac.addLabel(self.window, "")
ac.setPosition(self.nameLabel1, 77, 15)
ac.setPosition(self.nameLabel1, 74, 15)
ac.setFontSize(self.nameLabel1, 25)
ac.setCustomFont(self.nameLabel1, FC.FONT_NAME, 0, 1)
ac.setFontColor(self.nameLabel1, 0.86, 0.86, 0.86, 1)
ac.setFontAlignment(self.nameLabel1, "left")

self.nameLabel2 = ac.addLabel(self.window, "")
ac.setPosition(self.nameLabel2, 457, 15)
ac.setPosition(self.nameLabel2, 504, 15)
ac.setFontSize(self.nameLabel2, 25)
ac.setCustomFont(self.nameLabel2, FC.FONT_NAME, 0, 1)
ac.setFontColor(self.nameLabel2, 0.86, 0.86, 0.86, 1)
ac.setFontAlignment(self.nameLabel2, "left")

# ==========================================

self.carLabel1 = ac.addLabel(self.window, "")
ac.setPosition(self.carLabel1, 80, 55)
ac.setPosition(self.carLabel1, 88, 55)
ac.setSize(self.carLabel1, 195, 85)

self.carLabel2 = ac.addLabel(self.window, "")
ac.setPosition(self.carLabel2, 430, 55)
ac.setPosition(self.carLabel2, 507, 55)
ac.setSize(self.carLabel2, 195, 85)

# ==========================================

self.gapsIconLabelL = ac.addLabel(self.window, "")
ac.setPosition(self.gapsIconLabelL, 310, 110)
ac.setSize(self.gapsIconLabelL, 40, 6)
ac.setBackgroundTexture(self.gapsIconLabelL, FC.GAPS);

self.gapsIconLabelR = ac.addLabel(self.window, "")
ac.setPosition(self.gapsIconLabelR, 454, 110)
ac.setSize(self.gapsIconLabelR, 40, 6)
ac.setBackgroundTexture(self.gapsIconLabelR, FC.GAPS);

self.gapLabel = ac.addLabel(self.window, "")
ac.setPosition(self.gapLabel, 350, 70)
ac.setFontSize(self.gapLabel, 30)
ac.setPosition(self.gapLabel, 400, 68)
ac.setFontSize(self.gapLabel, 40)
ac.setCustomFont(self.gapLabel, FC.FONT_NAME, 0, 1)
ac.setFontColor(self.gapLabel, 0.94, 0.87, 0.17, 1)
ac.setFontAlignment(self.gapLabel, "center")

self.secondsLabel = ac.addLabel(self.window, "SECONDS")
ac.setPosition(self.secondsLabel, 350, 105)
ac.setPosition(self.secondsLabel, 400, 107)
ac.setFontSize(self.secondsLabel, 16)
ac.setCustomFont(self.secondsLabel, FC.FONT_NAME, 0, 1)
ac.setFontColor(self.secondsLabel, 0.86, 0.86, 0.86, 1)
Expand All @@ -89,6 +114,7 @@ def hide(self):
ac.setVisible(self.backgroundTexture, 0)
ac.setVisible(self.extendedBackgroundTexture, 0)
ac.setVisible(self.rolexLabel, 0)
ac.setVisible(self.speedometerIconLabel, 0)
ac.setVisible(self.positionLabel1, 0)
ac.setVisible(self.positionLabel2, 0)
ac.setVisible(self.teamLabel1, 0)
Expand All @@ -97,6 +123,8 @@ def hide(self):
ac.setVisible(self.nameLabel2, 0)
ac.setVisible(self.carLabel1, 0)
ac.setVisible(self.carLabel2, 0)
ac.setVisible(self.gapsIconLabelL, 0)
ac.setVisible(self.gapsIconLabelR, 0)
ac.setVisible(self.gapLabel, 0)
ac.setVisible(self.secondsLabel, 0)

Expand All @@ -106,6 +134,7 @@ def show(self, id1, pos1, id2, pos2, time_gap):
ac.setText(self.gapLabel, time_to_string(time_gap))

ac.setVisible(self.rolexLabel, 1)
ac.setVisible(self.speedometerIconLabel, 1)
ac.setVisible(self.backgroundTexture, 1)
ac.setVisible(self.extendedBackgroundTexture, 1)
ac.setVisible(self.positionLabel1, 1)
Expand All @@ -114,6 +143,8 @@ def show(self, id1, pos1, id2, pos2, time_gap):
ac.setVisible(self.nameLabel2, 1)
ac.setVisible(self.carLabel1, 1)
ac.setVisible(self.carLabel2, 1)
ac.setVisible(self.gapsIconLabelL, 1)
ac.setVisible(self.gapsIconLabelR, 1)
ac.setVisible(self.gapLabel, 1)
ac.setVisible(self.secondsLabel, 1)

Expand Down
2 changes: 1 addition & 1 deletion apps/python/F12020Leaderboard/DriverWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def show(self, id, pos, starting_position, tyres, pit_stops):
if u == "3": subscript = "rd"
else: subscript = "th"
ac.setText(self.startedLabel, str(starting_position) + subscript)
ac.setBackgroundTexture(self.tyreLabel, FC.TYRE_BASE_NAME + tyres + ".png");
ac.setBackgroundTexture(self.tyreLabel, FC.TYRE_DIR + tyres + ".png");
ac.setBackgroundTexture(self.backgroundTexture, FC.DRIVER_WIDGET_BACKGROUND_ALTERNATE)
ac.setVisible(self.extendedBackgroundTexture, 1)
ac.setVisible(self.startedLabel, 1)
Expand Down
22 changes: 12 additions & 10 deletions apps/python/F12020Leaderboard/F12020Leaderboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ def acUpdate(deltaT):
ac.setBackgroundOpacity(driverComparisonWidget.window, 0)
ac.setBackgroundOpacity(fastest_lap_banner.window, 0)

ac.console("LAP >> " + str(ac.getCarState(0, acsys.CS.LapInvalidated)))

# ============================
# SERVER LAP
for i in range(totalDrivers):
Expand Down Expand Up @@ -386,13 +384,14 @@ def acUpdate(deltaT):
for i in range(totalDrivers):
# MARK IN/OUT DRIVERS
connected = ac.isConnected(i)
if connected == 0 and not dPosition[i].out: # mark unconnected drivers
if connected == 0: # mark unconnected drivers
leaderboard[i].mark_out()
dPosition[i].out = True
elif connected == 1 and dPosition[i].out:
dPosition[i].best_lap += 1 # checky hack to put unconnected drivers at the bottom of the leaderboard
else:
leaderboard[i].mark_in()
dPosition[i].out = False
if connected == 1:

leaderboard[i].update_name(dPosition[i].id)
if dPosition[i].best_lap == MAX_LAP_TIME:
leaderboard[i].update_time("NO TIME")
Expand All @@ -401,7 +400,7 @@ def acUpdate(deltaT):
else:
timeDiff = dPosition[i].best_lap - dPosition[0].best_lap
if timeDiff > 60000:
leaderboard[driver.position].update_time("+1 MIN")
leaderboard[i].update_time("+1 MIN")
else:
leaderboard[i].update_time("+" + time_to_string(timeDiff))

Expand Down Expand Up @@ -435,14 +434,17 @@ def acUpdate(deltaT):
ac.setBackgroundOpacity(driverComparisonWidget.window, 0)
ac.setBackgroundOpacity(fastest_lap_banner.window, 0)

ac.console("LAP >> " + str(ac.getCarState(0, acsys.CS.LapInvalidated)))

if quali_started:
ac.setText(lapCountTimerLabel, time_to_string(info.graphics.sessionTimeLeft)[:-4])
if info.graphics.sessionTimeLeft < 0:
ac.setText(lapCountTimerLabel, "0:00")
else:
timeText = time_to_string(info.graphics.sessionTimeLeft)[:-4]
ac.setText(lapCountTimerLabel, "0:00"[:-len(timeText)] + timeText)
if info.graphics.sessionTimeLeft < qualify_session_time / 5:
ac.setFontColor(lapCountTimerLabel, 1,0,0,1)

driverWidget.hide()
driverComparisonWidget.hide()


# ================================================================
Expand Down Expand Up @@ -476,7 +478,7 @@ def acUpdate(deltaT):
leaderboard[pos].mark_out()
else:
leaderboard[pos].mark_in()
leaderboard[pos].update_name(i)
leaderboard[pos].update_name(i)

# OVERTAKE
if pos != drivers[i].position: # there was an overtake
Expand Down
4 changes: 3 additions & 1 deletion apps/python/F12020Leaderboard/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ class FC:

# MISCELANEOUS
ROLEX_LOGO = "apps/python/%s/ui/rolex.png" % APP_NAME
SPEEDOMETER_ICON = "apps/python/%s/ui/icon.png" % APP_NAME
GAPS = "apps/python/%s/ui/gaps.png" % APP_NAME

TYRE_BASE_NAME = "apps/python/%s/ui/tyres/" % APP_NAME
TYRE_DIR = "apps/python/%s/ui/tyres/" % APP_NAME

# REPLAY DIRECTORY
REPLAY_DIR = "apps/python/%s/replays/" % APP_NAME
Expand Down
Binary file added apps/python/F12020Leaderboard/ui/gaps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/python/F12020Leaderboard/ui/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 75bdc37

Please sign in to comment.