diff --git a/apps/python/F12020Leaderboard/DriverComparisonWidget.py b/apps/python/F12020Leaderboard/DriverComparisonWidget.py new file mode 100644 index 0000000..78c6fb3 --- /dev/null +++ b/apps/python/F12020Leaderboard/DriverComparisonWidget.py @@ -0,0 +1,146 @@ +import ac +from utils import get_image_size, time_to_string + +from constants import FC + +class DriverComparisonWidget: + def __init__(self, appName): + self.id1 = -1 + self.id2 = -1 + self.visible = True + + self.window = ac.newApp(appName) + ac.setTitle(self.window, "") + ac.drawBorder(self.window, 0) + ac.setIconPosition(self.window, 0, -10000) + ac.setSize(self.window, 300, 100) + ac.setBackgroundOpacity(self.window, 0) + + self.backgroundTexture = ac.addLabel(self.window, "") + ac.setPosition(self.backgroundTexture, 0,0) + ac.setSize(self.backgroundTexture, 700, 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.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.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.setSize(self.positionLabel2, 44, 44) + + self.teamLabel1 = ac.addLabel(self.window, "") + ac.setPosition(self.teamLabel1, 57, 10) + ac.setSize(self.teamLabel1, 6, 27) + + self.teamLabel2 = ac.addLabel(self.window, "") + ac.setPosition(self.teamLabel2, 437, 10) + ac.setSize(self.teamLabel2, 6, 27) + + self.nameLabel1 = ac.addLabel(self.window, "") + ac.setPosition(self.nameLabel1, 77, 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.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.setSize(self.carLabel1, 195, 85) + + self.carLabel2 = ac.addLabel(self.window, "") + ac.setPosition(self.carLabel2, 430, 55) + ac.setSize(self.carLabel2, 195, 85) + + self.gapLabel = ac.addLabel(self.window, "") + ac.setPosition(self.gapLabel, 350, 70) + ac.setFontSize(self.gapLabel, 30) + 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.setFontSize(self.secondsLabel, 16) + ac.setCustomFont(self.secondsLabel, FC.FONT_NAME, 0, 1) + ac.setFontColor(self.secondsLabel, 0.86, 0.86, 0.86, 1) + ac.setFontAlignment(self.secondsLabel, "center") + + def hide(self): + if not self.visible: return + self.visible = False + ac.setVisible(self.backgroundTexture, 0) + ac.setVisible(self.extendedBackgroundTexture, 0) + ac.setVisible(self.rolexLabel, 0) + ac.setVisible(self.positionLabel1, 0) + ac.setVisible(self.positionLabel2, 0) + ac.setVisible(self.teamLabel1, 0) + ac.setVisible(self.teamLabel2, 0) + ac.setVisible(self.nameLabel1, 0) + ac.setVisible(self.nameLabel2, 0) + ac.setVisible(self.carLabel1, 0) + ac.setVisible(self.carLabel2, 0) + ac.setVisible(self.gapLabel, 0) + ac.setVisible(self.secondsLabel, 0) + + def show(self, id1, pos1, id2, pos2, time_gap): + ac.setBackgroundTexture(self.positionLabel1, FC.LEADERBOARD_POSITION_LABEL[pos1+1]) + ac.setBackgroundTexture(self.positionLabel2, FC.LEADERBOARD_POSITION_LABEL[pos2+1]) + ac.setText(self.gapLabel, time_to_string(time_gap)) + + ac.setVisible(self.rolexLabel, 1) + ac.setVisible(self.backgroundTexture, 1) + ac.setVisible(self.extendedBackgroundTexture, 1) + ac.setVisible(self.positionLabel1, 1) + ac.setVisible(self.positionLabel2, 1) + ac.setVisible(self.nameLabel1, 1) + ac.setVisible(self.nameLabel2, 1) + ac.setVisible(self.carLabel1, 1) + ac.setVisible(self.carLabel2, 1) + ac.setVisible(self.gapLabel, 1) + ac.setVisible(self.secondsLabel, 1) + + if self.id1 != id1 and self.id2 != id2: + name1 = ac.getDriverName(id1) + ac.setText(self.nameLabel1, name1.split()[-1].upper()) + if FC.TEAM_COLORS: + try: + ac.setBackgroundTexture(self.teamLabel1, FC.TEAM_COLORS[name1]); + ac.setBackgroundTexture(self.carLabel1, FC.CARS[name1]); + ac.setVisible(self.teamLabel1, 1) + ac.setVisible(self.carLabel1, 1) + except KeyError: + ac.log("%s:Name Missing in teams.txt" % (FC.APP_NAME)) + + if self.id2 != id2: + name2 = ac.getDriverName(id2) + ac.setText(self.nameLabel2, name2.split()[-1].upper()) + if FC.TEAM_COLORS: + try: + ac.setBackgroundTexture(self.teamLabel2, FC.TEAM_COLORS[name2]); + ac.setBackgroundTexture(self.carLabel2, FC.CARS[name2]); + ac.setVisible(self.teamLabel2, 1) + ac.setVisible(self.carLabel2, 1) + except KeyError: + ac.log("%s:Name Missing in teams.txt" % (FC.APP_NAME)) + + self.id1 = id1 + self.id2 = id2 + self.visible = True diff --git a/apps/python/F12020Leaderboard/DriverWidget.py b/apps/python/F12020Leaderboard/DriverWidget.py index 0509392..0930f93 100644 --- a/apps/python/F12020Leaderboard/DriverWidget.py +++ b/apps/python/F12020Leaderboard/DriverWidget.py @@ -34,7 +34,7 @@ def __init__(self, appName): ac.setSize(self.positionLabel, 62, 62) self.teamLabel = ac.addLabel(self.window, "") - ac.setPosition(self.teamLabel, 70, 10) + ac.setPosition(self.teamLabel, 71, 10) ac.setSize(self.teamLabel, 6, 45) self.nameLabel = ac.addLabel(self.window, "") @@ -161,8 +161,11 @@ def hide(self): def show(self, id, pos, starting_position, tyres, pit_stops): ac.setBackgroundTexture(self.positionLabel, FC.LEADERBOARD_POSITION_LABEL[pos+1]) + ac.setVisible(self.positionLabel, 1) - self.visible = True + ac.setVisible(self.rolexLabel, 1) + ac.setVisible(self.backgroundTexture, 1) + ac.setVisible(self.nameLabel, 1) if self.extended: places = starting_position - (pos+1) @@ -183,9 +186,6 @@ def show(self, id, pos, starting_position, tyres, pit_stops): ac.setText(self.placesLabel, str(abs(places))) if self.id != id: - ac.setVisible(self.rolexLabel, 1) - ac.setVisible(self.backgroundTexture, 1) - ac.setVisible(self.nameLabel, 1) name = ac.getDriverName(id) sName = name.split() ac.setText(self.nameLabel, "%s %s" %(sName[0], sName[-1].upper())) @@ -212,7 +212,6 @@ def show(self, id, pos, starting_position, tyres, pit_stops): else: subscript = "th" ac.setText(self.startedLabel, str(starting_position) + subscript) ac.setBackgroundTexture(self.tyreLabel, FC.TYRE_BASE_NAME + tyres + ".png"); - ac.setBackgroundTexture(self.backgroundTexture, FC.DRIVER_WIDGET_BACKGROUND_ALTERNATE) ac.setVisible(self.extendedBackgroundTexture, 1) ac.setVisible(self.startedLabel, 1) @@ -236,7 +235,8 @@ def show(self, id, pos, starting_position, tyres, pit_stops): ac.setVisible(self.pitStopTextLabel, 0) ac.setVisible(self.pitStopLabel, 0) self.id = id - + self.visible = True + @staticmethod def toogle_extended(*args): DriverWidget.extended = not DriverWidget.extended diff --git a/apps/python/F12020Leaderboard/F12020Leaderboard.py b/apps/python/F12020Leaderboard/F12020Leaderboard.py index 40e0453..6ddaeb0 100644 --- a/apps/python/F12020Leaderboard/F12020Leaderboard.py +++ b/apps/python/F12020Leaderboard/F12020Leaderboard.py @@ -16,6 +16,7 @@ from utils import get_image_size, time_to_string from DriverWidget import DriverWidget +from DriverComparisonWidget import DriverComparisonWidget from LeaderboardRow import LeaderboardRow from FastestLapBanner import FastestLapBanner @@ -25,7 +26,7 @@ # TIMERS timer0, timer1, timer2 = 0, 0, 0 - + # VARIABLES totalDrivers = 0 drivers = None @@ -46,6 +47,7 @@ # WINDOWS leaderboardWindow = None driverWidget = None +driverComparisonWidget = None fastest_lap_banner = None # LABELS @@ -80,7 +82,7 @@ def acMain(ac_version): global totalDrivers global drivers - global leaderboardWindow, driverWidget, fastest_lap_banner + global leaderboardWindow, driverWidget, driverComparisonWidget, fastest_lap_banner # LABELS global leaderboard global lapCountTimerLabel, leaderboardBaseLabel, leaderboardInfoBackgroundLabel, leaderboardBackgroundLabel @@ -88,7 +90,7 @@ def acMain(ac_version): totalDrivers = ac.getCarsCount() n_splits = ac.getTrackLength(0) / FC.TRACK_SECTION_LENGTH drivers = [Driver(i, n_splits) for i in range(totalDrivers)] # driver positions and update times - + ac.initFont(0, FC.FONT_NAME, 0, 0) leaderboardWindow = ac.newApp(FC.APP_NAME) @@ -98,8 +100,6 @@ def acMain(ac_version): ac.setSize(leaderboardWindow, 200, 200) ac.setBackgroundOpacity(leaderboardWindow, 0) - driverWidget = DriverWidget(FC.APP_NAME+"_DriverWidget") - # =============================== # Leaderboard Background leaderboardBaseLabel = ac.addLabel(leaderboardWindow, "") @@ -114,7 +114,7 @@ def acMain(ac_version): ac.setBackgroundTexture(leaderboardBackgroundLabel, FC.LEADERBOARD_BACKGROUND); # =============================== - # Lap Counter / Time + # Lap Counter / Time lapCountTimerLabel = ac.addLabel(leaderboardWindow, "") ac.setPosition(lapCountTimerLabel, 74, 52) ac.setFontSize(lapCountTimerLabel, 22) @@ -129,15 +129,22 @@ def acMain(ac_version): ac.setSize(leaderboardInfoBackgroundLabel, 110, totalDrivers*LeaderboardRow.ROW_HEIGHT + 2) ac.setBackgroundTexture(leaderboardInfoBackgroundLabel, FC.LEADERBOARD_INFO_BACKGROUNG) + # =============================== + # Driver Widget + driverWidget = DriverWidget(FC.APP_NAME+" Driver") + + # =============================== + # Driver Comparison Widget + driverComparisonWidget = DriverComparisonWidget(FC.APP_NAME+" Driver Comparison") + # =============================== # FastestLap Banner - fastest_lap_banner = FastestLapBanner(FC.APP_NAME+"_FastestLap_Banner") + fastest_lap_banner = FastestLapBanner(FC.APP_NAME+" Top Banner") fastest_lap_banner.hide() leaderboard = [None] * totalDrivers for i in range(totalDrivers): leaderboard[i] = LeaderboardRow(leaderboardWindow, i) - return FC.APP_NAME @@ -148,7 +155,7 @@ def acMain(ac_version): def acUpdate(deltaT): # TIMERS global timer0, timer1, timer2 - + # VARIABLES global totalDrivers global drivers @@ -162,7 +169,7 @@ def acUpdate(deltaT): global replay_data # Widgets - global leaderboardWindow, driverWidget + global leaderboardWindow, driverWidget, driverComparisonWidget # LABELS global leaderboard @@ -204,9 +211,12 @@ def acUpdate(deltaT): # RESET THINGS fastest_lap = MAX_LAP_TIME LeaderboardRow.FASTEST_LAP_ID = -1 + for row in leaderboard: # clean the fastest lap marker + row.mark_fastest_lap() # in case we are coming from a qualify ac.setFontColor(lapCountTimerLabel, 0.86, 0.86, 0.86, 1) ac.setBackgroundTexture(leaderboardBaseLabel, FC.LEADERBOARD_BASE_RACE) + ac.setVisible(lapCountTimerLabel, 1) race_started = True quali_started = False @@ -221,14 +231,13 @@ def acUpdate(deltaT): for i in range(totalDrivers): pos = ac.getCarRealTimeLeaderboardPosition(i) connected = ac.isConnected(i) - if connected == 0 and not drivers[i].out: # mark unconnected drivers + if connected == 0: # mark unconnected drivers leaderboard[pos].mark_out() drivers[i].out = True - elif connected == 1 and drivers[i].out: + else: leaderboard[pos].mark_in() drivers[i].out = False - if connected == 1: - leaderboard[pos].update_name(i) + leaderboard[pos].update_name(i) # OVERTAKE if pos != drivers[i].position: # there was an overtake @@ -257,8 +266,11 @@ def acUpdate(deltaT): timer0 = 0 ac.setBackgroundOpacity(leaderboardWindow, 0) ac.setBackgroundOpacity(driverWidget.window, 0) + 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): @@ -279,7 +291,7 @@ def acUpdate(deltaT): if timeDiff < 0: continue # ignore these times, happens on overtakes if driver.position > totalDrivers: continue # might try to update before it is possible driver.timeDiff = timeDiff - if timeDiff > 60: + if timeDiff > 60: leaderboard[driver.position].update_time("+1 MIN") else: leaderboard[driver.position].update_time("+" + time_to_string(timeDiff*1000)) @@ -317,8 +329,16 @@ def acUpdate(deltaT): id = ac.getFocusedCar() if drivers[id].position <= totalDrivers: # in case it wasnt updated yet driverWidget.show(id, drivers[id].position, drivers[id].starting_position, drivers[id].tyre, drivers[id].pits) + if drivers[id].position == 0: + driverComparisonWidget.hide() + else: + for d in drivers: # find driver ahead + if d.position == drivers[id].position - 1: + driverComparisonWidget.show(d.id, d.position, id, drivers[id].position, drivers[id].timeDiff*1000) + break else: driverWidget.hide() + driverComparisonWidget.hide() # ======================================================== # SAVE DRIVER STATUS IN A FILE TO LOAD ON REPLAY @@ -380,7 +400,10 @@ def acUpdate(deltaT): leaderboard[i].update_time(time_to_string(dPosition[i].best_lap)) else: timeDiff = dPosition[i].best_lap - dPosition[0].best_lap - leaderboard[i].update_time("+" + time_to_string(timeDiff)) + if timeDiff > 60000: + leaderboard[driver.position].update_time("+1 MIN") + else: + leaderboard[i].update_time("+" + time_to_string(timeDiff)) # OVERTAKES if i != dPosition[i].position: # there was an overtake on this driver @@ -401,7 +424,7 @@ def acUpdate(deltaT): if fastest_lap_banner.timer > 0: fastest_lap_banner.timer -= timer1 fastest_lap_banner.hide() - + timer1 = 0 # Once per second @@ -409,10 +432,12 @@ def acUpdate(deltaT): timer0 = 0 ac.setBackgroundOpacity(leaderboardWindow, 0) ac.setBackgroundOpacity(driverWidget.window, 0) + 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.console(str(info.graphics.sessionTimeLeft)) ac.setText(lapCountTimerLabel, time_to_string(info.graphics.sessionTimeLeft)[:-4]) if info.graphics.sessionTimeLeft < qualify_session_time / 5: ac.setFontColor(lapCountTimerLabel, 1,0,0,1) @@ -466,7 +491,7 @@ def acUpdate(deltaT): drivers[i].timer -= timer1 drivers[i].position = pos # END OVERTAKE - + timer1 = 0 # Once per second @@ -474,6 +499,7 @@ def acUpdate(deltaT): timer0 = 0 ac.setBackgroundOpacity(leaderboardWindow, 0) ac.setBackgroundOpacity(driverWidget.window, 0) + ac.setBackgroundOpacity(driverComparisonWidget.window, 0) ac.setBackgroundOpacity(fastest_lap_banner.window, 0) # ============================ @@ -509,8 +535,16 @@ def acUpdate(deltaT): if replay_started: id = ac.getFocusedCar() driverWidget.show(id, drivers[id].position, drivers[id].starting_position, drivers[id].tyre, drivers[id].pits) + if drivers[id].position == 0: + driverComparisonWidget.hide() + else: + for d in drivers: # find driver ahead + if d.position == drivers[id].position - 1: + driverComparisonWidget.show(d.id, d.position, id, drivers[id].position, drivers[id].timeDiff*1000) + break else: driverWidget.hide() + driverComparisonWidget.hide() # ============================ # UPDATE TIMES @@ -630,6 +664,6 @@ def lookup_fastest_lap(lap, time, replay_data): if (time - replay_data['FL'][lap][it-1][0])/1000 < FC.FASTEST_LAP_DISPLAY_TIME: return replay_data['FL'][lap][it-1] return None - + diff --git a/apps/python/F12020Leaderboard/LeaderboardRow.py b/apps/python/F12020Leaderboard/LeaderboardRow.py index e7d6d5b..cf2bb44 100644 --- a/apps/python/F12020Leaderboard/LeaderboardRow.py +++ b/apps/python/F12020Leaderboard/LeaderboardRow.py @@ -8,6 +8,7 @@ class LeaderboardRow: Y_BASE = 84 ROW_HEIGHT = 37 FASTEST_LAP_ID = -1 + HIGHLIGHT_ID = -1 def __init__(self, leaderboardWindow, row): # SET SOME VARIABLES self.row = row @@ -18,6 +19,12 @@ def __init__(self, leaderboardWindow, row): self.out = False self.pit = False + self.highlightLabel = ac.addLabel(leaderboardWindow, "") + ac.setPosition(self.highlightLabel, px-5, py-6) + ac.setSize(self.highlightLabel, 258, LeaderboardRow.ROW_HEIGHT+1) + ac.setBackgroundTexture(self.highlightLabel, FC.LEADERBOARD_PLAYER_HIGHLIGHT); + ac.setVisible(self.highlightLabel, 0) + # CREATE LABELS self.positionLabel = ac.addLabel(leaderboardWindow, "") ac.setPosition(self.positionLabel, px-4, py-7) @@ -52,9 +59,9 @@ def __init__(self, leaderboardWindow, row): self.fastestLapLabel = ac.addLabel(leaderboardWindow, "") ac.setPosition(self.fastestLapLabel, px-41, py-6) ac.setSize(self.fastestLapLabel, 37, 37) - ac.setBackgroundTexture(self.fastestLapLabel, FC.LEADERBOARD_FASTEST_LAP); + ac.setBackgroundTexture(self.fastestLapLabel, FC.LEADERBOARD_FASTEST_LAP); ac.setVisible(self.fastestLapLabel, 0) - + self.button = ac.addButton(leaderboardWindow, "") ac.setPosition(self.button, px, py-7) ac.setSize(self.button, 140, 38) @@ -64,6 +71,10 @@ def __init__(self, leaderboardWindow, row): ac.drawBorder(self.button, 0) def update_name(self, id): + if id == ac.getFocusedCar(): + ac.setVisible(self.highlightLabel, 1) + else: + ac.setVisible(self.highlightLabel, 0) if self.driverId == id: return # no need to update self.driverId = id self.driverName = ac.getDriverName(id) @@ -73,11 +84,11 @@ def update_name(self, id): ac.setBackgroundTexture(self.teamLabel, FC.TEAM_COLORS[self.driverName]) except KeyError: ac.log("%s:Name Missing in teams.txt %s" % (FC.APP_NAME, self.driverName)) - + def update_time(self, time): if self.out or self.pit: return # no need to update ac.setText(self.infoLabel, time) - + def mark_red_position(self): if self.out or self.positionLabelId == 1: return # no need to update ac.setBackgroundTexture(self.positionLabel, FC.LEADERBOARD_POSITION_RED_LABEL[self.row+1]) @@ -87,12 +98,12 @@ def mark_green_position(self): if self.out or self.positionLabelId == 2: return # no need to update ac.setBackgroundTexture(self.positionLabel, FC.LEADERBOARD_POSITION_GREEN_LABEL[self.row+1]) self.positionLabelId = 2 - + def mark_white_position(self): if self.out or self.positionLabelId == 0: return # no need to update ac.setBackgroundTexture(self.positionLabel, FC.LEADERBOARD_POSITION_LABEL[self.row+1]) self.positionLabelId = 0 - + def mark_in(self): if not self.out: return self.out = False @@ -111,28 +122,27 @@ def mark_out(self): ac.setFontColor(self.nameLabel, .58,.53,.53, 1) ac.setText(self.infoLabel, "OUT") ac.setFontColor(self.infoLabel, .58,.53,.53, 1) - + def mark_enter_pits(self): if self.out or self.pit: return self.pit = True ac.setText(self.infoLabel, "IN PIT") ac.setFontColor(self.infoLabel, 0,.84,1, 1) - + def mark_left_pits(self): if self.out or not self.pit: return self.pit = False if self.driverId == 0: ac.setText(self.infoLabel, "Interval") ac.setFontColor(self.infoLabel, 0.86, 0.86, 0.86, 1) - + def mark_fastest_lap(self): - if self.out or self.pit: return if self.driverId == LeaderboardRow.FASTEST_LAP_ID: ac.setVisible(self.fastestLapLabel, 1) else: ac.setVisible(self.fastestLapLabel, 0) - + @staticmethod def on_click(*args, row=None): if row: - ac.focusCar(row.driverId) \ No newline at end of file + ac.focusCar(row.driverId) diff --git a/apps/python/F12020Leaderboard/constants.py b/apps/python/F12020Leaderboard/constants.py index dc7924b..b58170f 100644 --- a/apps/python/F12020Leaderboard/constants.py +++ b/apps/python/F12020Leaderboard/constants.py @@ -15,10 +15,11 @@ class FC: # LEADERBOARD BACKGROUNDS LEADERBOARD_BACKGROUND = "apps/python/%s/ui/background.png" % APP_NAME - LEADERBOARD_BASE_RACE = "apps/python/%s/ui/race_base.png" % APP_NAME - LEADERBOARD_BASE_QUALI = "apps/python/%s/ui/quali_base.png" % APP_NAME - LEADERBOARD_FINAL_LAP = "apps/python/%s/ui/final_lap.png" % APP_NAME + LEADERBOARD_BASE_RACE = "apps/python/%s/ui/race_base.png" % APP_NAME + LEADERBOARD_BASE_QUALI = "apps/python/%s/ui/quali_base.png" % APP_NAME + LEADERBOARD_FINAL_LAP = "apps/python/%s/ui/final_lap.png" % APP_NAME LEADERBOARD_INFO_BACKGROUNG = "apps/python/%s/ui/background_info.png" % APP_NAME + LEADERBOARD_PLAYER_HIGHLIGHT = "apps/python/%s/ui/highlight.png" % APP_NAME # FASTEST LAP LEADERBOARD_FASTEST_LAP = "apps/python/%s/ui/fastest_lap.png" % APP_NAME @@ -60,6 +61,7 @@ class FC: TEAM_NAME = None DRIVER_NUMBER = None NUMBER_TAGS = None + CARS = None try: if not FC.TEAM_COLORS: @@ -67,13 +69,15 @@ class FC: FC.TEAM_NAME = {} FC.DRIVER_NUMBER = {} FC.NUMBER_TAGS = {} + FC.CARS = {} with open("apps/python/%s/teams.ini" % APP_NAME) as fp: for line in fp: line = line.split(":") name = line[-1][:-1] FC.TEAM_NAME[name] = line[0] FC.TEAM_COLORS[name] = "apps/python/%s/ui/teams/%s.png" % (APP_NAME, line[1]) + FC.CARS[name] = "apps/python/%s/ui/cars/%s.png" % (APP_NAME, line[1]) FC.DRIVER_NUMBER[name] = line[2] FC.NUMBER_TAGS[name] = "apps/python/%s/ui/numbers/%s.png" % (APP_NAME, line[2]) except FileNotFoundError: - ac.log("File teams.ini not found.") \ No newline at end of file + ac.log("File teams.ini not found.") diff --git a/apps/python/F12020Leaderboard/ui/cars/alfa_romeo.png b/apps/python/F12020Leaderboard/ui/cars/alfa_romeo.png index 641696e..6272a59 100644 Binary files a/apps/python/F12020Leaderboard/ui/cars/alfa_romeo.png and b/apps/python/F12020Leaderboard/ui/cars/alfa_romeo.png differ diff --git a/apps/python/F12020Leaderboard/ui/cars/alpha_tauri.png b/apps/python/F12020Leaderboard/ui/cars/alpha_tauri.png index 8d52806..ce8bbad 100644 Binary files a/apps/python/F12020Leaderboard/ui/cars/alpha_tauri.png and b/apps/python/F12020Leaderboard/ui/cars/alpha_tauri.png differ diff --git a/apps/python/F12020Leaderboard/ui/cars/ferrari.png b/apps/python/F12020Leaderboard/ui/cars/ferrari.png index abcd8e3..66a2243 100644 Binary files a/apps/python/F12020Leaderboard/ui/cars/ferrari.png and b/apps/python/F12020Leaderboard/ui/cars/ferrari.png differ diff --git a/apps/python/F12020Leaderboard/ui/cars/haas.png b/apps/python/F12020Leaderboard/ui/cars/haas.png index 742ee5b..b748f3d 100644 Binary files a/apps/python/F12020Leaderboard/ui/cars/haas.png and b/apps/python/F12020Leaderboard/ui/cars/haas.png differ diff --git a/apps/python/F12020Leaderboard/ui/cars/mclaren.png b/apps/python/F12020Leaderboard/ui/cars/mclaren.png index 42dc53f..ae928e9 100644 Binary files a/apps/python/F12020Leaderboard/ui/cars/mclaren.png and b/apps/python/F12020Leaderboard/ui/cars/mclaren.png differ diff --git a/apps/python/F12020Leaderboard/ui/cars/mercedes.png b/apps/python/F12020Leaderboard/ui/cars/mercedes.png index ef9b52a..74e2d49 100644 Binary files a/apps/python/F12020Leaderboard/ui/cars/mercedes.png and b/apps/python/F12020Leaderboard/ui/cars/mercedes.png differ diff --git a/apps/python/F12020Leaderboard/ui/cars/racing_point.png b/apps/python/F12020Leaderboard/ui/cars/racing_point.png index b078fc6..55f484b 100644 Binary files a/apps/python/F12020Leaderboard/ui/cars/racing_point.png and b/apps/python/F12020Leaderboard/ui/cars/racing_point.png differ diff --git a/apps/python/F12020Leaderboard/ui/cars/red_bull.png b/apps/python/F12020Leaderboard/ui/cars/red_bull.png index a13f7b6..1ba5beb 100644 Binary files a/apps/python/F12020Leaderboard/ui/cars/red_bull.png and b/apps/python/F12020Leaderboard/ui/cars/red_bull.png differ diff --git a/apps/python/F12020Leaderboard/ui/cars/renault.png b/apps/python/F12020Leaderboard/ui/cars/renault.png index c2bec21..2c62581 100644 Binary files a/apps/python/F12020Leaderboard/ui/cars/renault.png and b/apps/python/F12020Leaderboard/ui/cars/renault.png differ diff --git a/apps/python/F12020Leaderboard/ui/cars/rokit_williams.png b/apps/python/F12020Leaderboard/ui/cars/rokit_williams.png index 067979d..925a981 100644 Binary files a/apps/python/F12020Leaderboard/ui/cars/rokit_williams.png and b/apps/python/F12020Leaderboard/ui/cars/rokit_williams.png differ diff --git a/apps/python/F12020Leaderboard/ui/highlight.png b/apps/python/F12020Leaderboard/ui/highlight.png new file mode 100644 index 0000000..8303124 Binary files /dev/null and b/apps/python/F12020Leaderboard/ui/highlight.png differ diff --git a/apps/python/F12020Leaderboard/utils.py b/apps/python/F12020Leaderboard/utils.py index 5bbefcd..54de1b9 100644 --- a/apps/python/F12020Leaderboard/utils.py +++ b/apps/python/F12020Leaderboard/utils.py @@ -19,12 +19,12 @@ def get_image_size(fname): return width, height def time_to_string(t, include_ms=True): - try: - hours, x = divmod(int(t), 3600000) - mins, x = divmod(x, 60000) - secs, ms = divmod(x, 1000) - if not include_ms: - return '%d:%02d' % (mins, secs) - return '%d.%03d' % (secs, ms) if mins == 0 else '%d:%02d.%03d' % (mins, secs, ms) - except Exception: - return '--:--.---' + try: + hours, x = divmod(int(t), 3600000) + mins, x = divmod(x, 60000) + secs, ms = divmod(x, 1000) + if not include_ms: + return '%d:%02d' % (mins, secs) + return '%d.%03d' % (secs, ms) if mins == 0 else '%d:%02d.%03d' % (mins, secs, ms) + except Exception: + return '--:--.---'