diff --git a/README.md b/README.md index e2e8c79..5584733 100644 --- a/README.md +++ b/README.md @@ -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!! diff --git a/apps/python/F12020Leaderboard/DriverComparisonWidget.py b/apps/python/F12020Leaderboard/DriverComparisonWidget.py index 78c6fb3..6a16bff 100644 --- a/apps/python/F12020Leaderboard/DriverComparisonWidget.py +++ b/apps/python/F12020Leaderboard/DriverComparisonWidget.py @@ -18,12 +18,12 @@ 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, "") @@ -31,53 +31,78 @@ def __init__(self, appName): 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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/apps/python/F12020Leaderboard/DriverWidget.py b/apps/python/F12020Leaderboard/DriverWidget.py index 0930f93..c8177e0 100644 --- a/apps/python/F12020Leaderboard/DriverWidget.py +++ b/apps/python/F12020Leaderboard/DriverWidget.py @@ -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) diff --git a/apps/python/F12020Leaderboard/F12020Leaderboard.py b/apps/python/F12020Leaderboard/F12020Leaderboard.py index 6ddaeb0..601501a 100644 --- a/apps/python/F12020Leaderboard/F12020Leaderboard.py +++ b/apps/python/F12020Leaderboard/F12020Leaderboard.py @@ -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): @@ -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") @@ -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)) @@ -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() # ================================================================ @@ -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 diff --git a/apps/python/F12020Leaderboard/constants.py b/apps/python/F12020Leaderboard/constants.py index b58170f..5c2c5e2 100644 --- a/apps/python/F12020Leaderboard/constants.py +++ b/apps/python/F12020Leaderboard/constants.py @@ -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 diff --git a/apps/python/F12020Leaderboard/ui/gaps.png b/apps/python/F12020Leaderboard/ui/gaps.png new file mode 100644 index 0000000..fa69a93 Binary files /dev/null and b/apps/python/F12020Leaderboard/ui/gaps.png differ diff --git a/apps/python/F12020Leaderboard/ui/icon.png b/apps/python/F12020Leaderboard/ui/icon.png new file mode 100644 index 0000000..c9135ea Binary files /dev/null and b/apps/python/F12020Leaderboard/ui/icon.png differ