Пример #1
0
    def __init__(self, font_name, italic, bold):
        if ac.initFont(0, font_name, italic, bold) == -1:
            CONSOLE("Error while loading Font: " + font_name)

        self.font_name = font_name
        self.italic = italic
        self.bold = bold
Пример #2
0
def acMain(ac_version):
    """Run upon startup of Assetto Corsa.
    
    Args:
        ac_version (str): Version of Assetto Corsa.
            AC passes this argument automatically.
    """
    # Read config
    global cfg
    cfg = Config()

    # Initialize session data object
    global session
    session = Session(cfg)

    # Set up app window
    global app_window
    app_window = AppWindow(cfg)
    ac.addRenderCallback(app_window.id, app_render)

    # Initialize fonts
    ac.initFont(0, 'ACRoboto300', 0, 0)
    ac.initFont(0, 'ACRoboto700', 0, 0)

    # Set up labels
    global label_speed, label_gear
    label_speed = ACLabel(app_window.id, font='ACRoboto300', alignment='center')
    label_speed.fit_height(
        Point(cfg.app_width * 0.5,
              cfg.app_height * cfg.app_padding),
        cfg.app_scale * 100)

    # Speed unit selection
    if cfg.use_kmh:
        label_speed.set_postfix(" km/h")
    else:
        label_speed.set_postfix(" mph")

    label_gear = ACLabel(app_window.id, font='ACRoboto700', alignment='center')
    label_gear.fit_height(
        Point(cfg.app_width * 0.5,
              cfg.app_scale * 200),
        cfg.app_scale * 250)
Пример #3
0
 def __init__(self):
     self.window = Window(name="ACTV Delta", icon=False, width=240, height=184, texture="")
     self.cursor = Value(False)
     self.session = Value(-1)
     self.performance = Value(0)
     self.spline = Value(0)
     self.laptime = Value(0)
     self.TimeLeftUpdate = Value(0)
     self.referenceLap = []
     self.referenceLapTime = Value(0)
     self.lastLapTime = Value(0)
     self.lapCount = 0
     self.lastLapIsValid = True
     self.currentLap = []
     self.deltaLoaded = False
     self.thread_save = False
     self.highlight_end = 0
     self.rowHeight = Value(-1)
     self.lbl_delta = (
         Label(self.window.app, "+0.000")
         .setSize(150, 36)
         .setPos(0, 60)
         .setFontSize(26)
         .setAlign("right")
         .setVisible(1)
     )
     self.lbl_lap = (
         Label(self.window.app, "0.000")
         .setSize(150, 32)
         .setPos(0, 86)
         .setFontSize(17)
         .setAlign("right")
         .setVisible(1)
     )
     self.btn_reset = (
         Button(self.window.app, self.onResetPress)
         .setPos(90, 68)
         .setSize(60, 20)
         .setText("Reset")
         .setAlign("center")
         .setBgColor(rgb([255, 12, 12], bg=True))
         .setVisible(0)
     )
     self.spin_row_height = ac.addSpinner(self.window.app, "")
     ac.setRange(self.spin_row_height, 20, 48)
     ac.setPosition(self.spin_row_height, 20, 28)
     ac.setValue(self.spin_row_height, self.__class__.ui_row_height)
     ac.addOnValueChangeListener(self.spin_row_height, self.onSpinRowHeightChanged)
     ac.setVisible(self.spin_row_height, 0)
     fontName = "Segoe UI"
     if ac.initFont(0, fontName, 0, 0) > 0:
         self.lbl_delta.setFont(fontName, 0, 1)
     self.cfg = Config("apps/python/prunn/", "config.ini")
     self.loadCFG()
Пример #4
0
def acMain(ac_version):
    global DRS_ALLOWED_CARS, SOUND_ON, SERVERS
    global tyreLabels, tyrePressureLabels
    global drsLabel, ersLabel, ersModeLabel, ersRecoveryLabel, fuelLabel, drsPenaltyLabel, drsPenaltyBackgroundLabel

    global drsZones, totalDrivers, trackLength, drsAvailableZones, driversList

    global carValue, trackConfigValue, trackValue

    global compounds, modCompounds

    carValue = ac.getCarName(0)
    trackValue = ac.getTrackName(0)
    trackConfigValue = ac.getTrackConfiguration(0)

    settings = configparser.ConfigParser()
    settings.read("apps/python/%s/config.ini" % APP_NAME)
    if settings.has_section('CARS'):
        DRS_ALLOWED_CARS.extend(
            [c for c in settings['CARS'] if settings['CARS'][c] == '1'])
    if settings.has_section('SETTINGS'):
        SOUND_ON = True if 'sound' in settings['SETTINGS'] and settings[
            'SETTINGS']['sound'] == '1' else False
    if settings.has_section('SERVERS'):
        SERVERS = list(settings['SERVERS'].values())

    drsZones = loadDRSZones()
    totalDrivers = ac.getCarsCount()
    trackLength = getTrackLength()

    driversList = [Driver(i, len(drsZones)) for i in range(totalDrivers)]
    drsAvailableZones = [False] * len(drsZones)

    compounds = configparser.ConfigParser()
    compounds.read(COMPOUNDSPATH + "compounds.ini")
    modCompounds = configparser.ConfigParser()
    modCompounds.read(COMPOUNDSPATH + carValue + ".ini")

    ac.initFont(0, FONT_NAME, 0, 0)

    appWindow = ac.newApp(APP_NAME)
    ac.setTitle(appWindow, "")
    ac.drawBorder(appWindow, 0)
    ac.setIconPosition(appWindow, 0, -10000)
    ac.setSize(appWindow, 280, 70)
    ac.setBackgroundOpacity(appWindow, 0.2)

    # =================================================================================================================
    #                                             TYRE LABELS
    # =================================================================================================================

    tyreLabelFL = ac.addLabel(appWindow, "")
    tyreLabelFR = ac.addLabel(appWindow, "")
    tyreLabelRL = ac.addLabel(appWindow, "")
    tyreLabelRR = ac.addLabel(appWindow, "")
    tyreLabels = [tyreLabelFL, tyreLabelFR, tyreLabelRL, tyreLabelRR]
    for label in tyreLabels:
        ac.setFontSize(label, 15)
        ac.setFontColor(label, 0, 0, 0, 1)
        ac.setFontAlignment(label, "center")
        ac.setSize(label, 15, 23)

    tyrePressureLabelFL = ac.addLabel(appWindow, "PFL")
    tyrePressureLabelFR = ac.addLabel(appWindow, "PFR")
    tyrePressureLabelRL = ac.addLabel(appWindow, "PRL")
    tyrePressureLabelRR = ac.addLabel(appWindow, "PRR")
    tyrePressureLabels = [
        tyrePressureLabelFL, tyrePressureLabelFR, tyrePressureLabelRL,
        tyrePressureLabelRR
    ]
    for label in tyrePressureLabels:
        ac.setFontSize(label, 15)
        ac.setFontColor(label, 0.86, 0.86, 0.86, 1)
        ac.setCustomFont(label, FONT_NAME, 0, 0)

    ac.setFontAlignment(tyrePressureLabels[0], "right")
    ac.setFontAlignment(tyrePressureLabels[1], "left")
    ac.setFontAlignment(tyrePressureLabels[2], "right")
    ac.setFontAlignment(tyrePressureLabels[3], "left")

    #position all the labels
    tlpx = 180
    tlpy = 10

    ac.setPosition(tyreLabels[0], tlpx + 5, tlpy + 0)
    ac.setPosition(tyreLabels[1], tlpx + 25, tlpy + 0)
    ac.setPosition(tyreLabels[2], tlpx + 5, tlpy + 28)
    ac.setPosition(tyreLabels[3], tlpx + 25, tlpy + 28)

    ac.setPosition(tyrePressureLabels[0], tlpx, tlpy + 2)
    ac.setPosition(tyrePressureLabels[1], tlpx + 43, tlpy + 2)
    ac.setPosition(tyrePressureLabels[2], tlpx, tlpy + 30)
    ac.setPosition(tyrePressureLabels[3], tlpx + 43, tlpy + 30)

    # =================================================================================================================
    #                                      ERS MODES LABELS
    # =================================================================================================================

    elpx = 15
    elpy = 10

    ersModeLabel = ac.addLabel(appWindow, "🗲0")
    ac.setPosition(ersModeLabel, elpx + 50, elpy)
    ac.setFontSize(ersModeLabel, 18)
    ac.setCustomFont(ersModeLabel, FONT_NAME, 0, 0)
    ac.setFontColor(ersModeLabel, 1.0, 1.0, 0.2, 1)
    ac.setFontAlignment(ersModeLabel, "left")

    ersRecoveryLabel = ac.addLabel(appWindow, "")
    ac.setPosition(ersRecoveryLabel, elpx + 85, elpy)
    ac.setFontSize(ersRecoveryLabel, 18)
    ac.setCustomFont(ersRecoveryLabel, FONT_NAME, 0, 0)
    ac.setFontColor(ersRecoveryLabel, 1.0, 1.0, 0.2, 1)
    ac.setFontAlignment(ersRecoveryLabel, "left")

    ersLabel = ac.addLabel(appWindow, "ERS:")
    ac.setPosition(ersLabel, elpx, elpy)
    ac.setFontSize(ersLabel, 18)
    ac.setCustomFont(ersLabel, FONT_NAME, 0, 0)
    ac.setFontColor(ersLabel, 1.0, 1.0, 0.2, 1)
    ac.setFontAlignment(ersLabel, "left")

    # =================================================================================================================
    #                                      FUEL LABEL
    # =================================================================================================================

    fuelLabel = ac.addLabel(appWindow, "💧 --.- Laps")
    ac.setPosition(fuelLabel, 15, 36)
    ac.setFontSize(fuelLabel, 18)
    ac.setCustomFont(fuelLabel, FONT_NAME, 0, 0)
    ac.setFontColor(fuelLabel, 0.86, 0.86, 0.86, 1)
    ac.setFontAlignment(fuelLabel, "left")

    # =================================================================================================================
    #                                             DRS LABELS
    # =================================================================================================================

    drsLabel = ac.addLabel(appWindow, "")
    ac.setPosition(drsLabel, -70, 0)
    ac.setSize(drsLabel, 70, 70)
    ac.setVisible(drsLabel, 0)

    drsPenaltyBackgroundLabel = ac.addLabel(appWindow, "")
    ac.setPosition(drsPenaltyBackgroundLabel, 0, 70)
    ac.setSize(drsPenaltyBackgroundLabel, 280, 25)
    ac.setBackgroundTexture(drsPenaltyBackgroundLabel, DRS_PENALTY_TEXTURE)
    ac.setVisible(drsPenaltyBackgroundLabel, 0)

    drsPenaltyLabel = ac.addLabel(appWindow, "")
    ac.setPosition(drsPenaltyLabel, 150, 70)
    ac.setFontSize(drsPenaltyLabel, 18)
    ac.setCustomFont(drsPenaltyLabel, FONT_NAME, 0, 1)
    ac.setFontColor(drsPenaltyLabel, 0.86, 0.86, 0.86, 1)
    ac.setFontAlignment(drsPenaltyLabel, "center")
    ac.setVisible(drsPenaltyLabel, 0)

    # Announce Start
    timer = threading.Timer(10, announceStart)
    timer.start()

    return APP_NAME
if platform.architecture()[0] == "64bit":
    sysdir = os.path.dirname(__file__) + '/lib/stdlib64'
else:
    sysdir = os.path.dirname(__file__) + '/lib/stdlib'

sys.path.insert(0, sysdir)
os.environ['PATH'] = os.environ['PATH'] + ";."

from lib.sim_info import info

import ctypes
from ctypes import wintypes

# Initialize custom font
ac.initFont(0, "Roboto", 1, 1)

# loading config
update_config = False
config_path = 'config.ini'
config = configparser.ConfigParser()
config.read(config_path)

if not config.has_section('Better_Flags'):
    config.add_section('Better_Flags')
    update_config = True


# helper function
def get_val_or_set_def(config, key, default):
    global update_config
def acMain(ac_version):
    # VARIABLES
    global totalDrivers
    global drivers

    global leaderboardWindow, driverWidget, driverComparisonWidget, fastest_lap_banner
    # LABELS
    global leaderboard
    global lapCountTimerLabel, leaderboardBaseLabel, leaderboardInfoBackgroundLabel, leaderboardBackgroundLabel
    global flagLabel

    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)
    ac.setTitle(leaderboardWindow, "")
    ac.drawBorder(leaderboardWindow, 0)
    ac.setIconPosition(leaderboardWindow, 0, -10000)
    ac.setSize(leaderboardWindow, 200, 200)
    ac.setBackgroundOpacity(leaderboardWindow, 0)

    # ===============================
    # Leaderboard Background
    leaderboardBaseLabel = ac.addLabel(leaderboardWindow, "")
    ac.setPosition(leaderboardBaseLabel, 0, 0)
    w, h = get_image_size(FC.LEADERBOARD_BASE_RACE)
    ac.setSize(leaderboardBaseLabel, w, h)
    ac.setBackgroundTexture(leaderboardBaseLabel, FC.LEADERBOARD_BASE_RACE)

    leaderboardBackgroundLabel = ac.addLabel(leaderboardWindow, "")
    ac.setPosition(leaderboardBackgroundLabel, 0, h)
    ac.setSize(leaderboardBackgroundLabel, w, totalDrivers*LeaderboardRow.ROW_HEIGHT + 2)
    ac.setBackgroundTexture(leaderboardBackgroundLabel, FC.LEADERBOARD_BACKGROUND);
    
    # ===============================
    # Lap Counter / Time
    lapCountTimerLabel = ac.addLabel(leaderboardWindow, "")
    ac.setPosition(lapCountTimerLabel, 74, 52)
    ac.setFontSize(lapCountTimerLabel, 22)
    ac.setCustomFont(lapCountTimerLabel, FC.FONT_NAME, 0, 1)
    ac.setFontAlignment(lapCountTimerLabel, "center")
    ac.setFontColor(lapCountTimerLabel, 0.86, 0.86, 0.86, 1)

    # ===============================
    # Flags
    flagLabel = ac.addLabel(leaderboardWindow, "")
    ac.setPosition(flagLabel, w, 8)
    ac.setSize(flagLabel, 110, h-8)
    ac.setVisible(flagLabel, 0)

    # ===============================
    # Info Background
    leaderboardInfoBackgroundLabel = ac.addLabel(leaderboardWindow, "")
    ac.setPosition(leaderboardInfoBackgroundLabel, w, h)
    ac.setSize(leaderboardInfoBackgroundLabel, 110, totalDrivers*LeaderboardRow.ROW_HEIGHT + 2)
    ac.setBackgroundTexture(leaderboardInfoBackgroundLabel, FC.LEADERBOARD_INFO_BACKGROUNG)

    info_button = ac.addButton(leaderboardWindow, "")
    ac.setPosition(info_button, w, h)
    ac.setSize(info_button, 110, totalDrivers*LeaderboardRow.ROW_HEIGHT + 2)
    ac.addOnClickedListener(info_button, on_click_info)
    ac.setBackgroundOpacity(info_button, 0)
    ac.drawBorder(info_button, 0)

    # ===============================
    # 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+" Top Banner")
    fastest_lap_banner.hide()

    leaderboard = [None] * totalDrivers
    for i in range(totalDrivers):
        leaderboard[i] = LeaderboardRow(leaderboardWindow, i)

    return FC.APP_NAME
Пример #7
0
 def __init__(self):
     self.window = Window(name="ACTV Delta",
                          icon=False,
                          width=240,
                          height=246,
                          texture="")
     self.cursor = Value(False)
     self.session = Value(-1)
     self.performance = Value(0)
     self.performance_session = Value(0)
     self.spline = Value(0)
     self.laptime = Value(0)
     self.TimeLeftUpdate = Value(0)
     self.referenceLap = []
     self.referenceLap_session = []
     self.referenceLapTime = Value(0)
     self.referenceLapTime_session = Value(0)
     self.lastLapTime = Value(0)
     self.lapCount = 0
     self.lastLapIsValid = True
     self.currentLap = []
     self.deltaLoaded = False
     self.thread_save = False
     self.highlight_end = 0
     self.rowHeight = Value(-1)
     self.lbl_delta = Label(self.window.app, "+0.000")\
         .set(w=150, h=36,
              x=0, y=60,
              font_size=26,
              align="right",
              visible=1)
     self.lbl_session_delta = Label(self.window.app, "+0.000")\
         .set(w=150, h=36,
              x=0, y=40,
              font_size=14,
              align="right",
              visible=1)
     self.lbl_lap = Label(self.window.app, "0.000")\
         .set(w=150, h=32,
              x=0, y=80,
              font_size=17,
              align="right",
              visible=1)
     self.btn_reset = Button(self.window.app, self.on_reset_press)\
         .setPos(90, 68).setSize(60, 20)\
         .setText("Reset")\
         .setAlign("center")\
         .setBgColor(rgb([255, 12, 12], bg=True))\
         .setVisible(0)
     self.spin_row_height = ac.addSpinner(self.window.app, "")
     ac.setRange(self.spin_row_height, 20, 70)
     ac.setPosition(self.spin_row_height, 20, 28)
     ac.setValue(self.spin_row_height, self.__class__.ui_row_height)
     ac.addOnValueChangeListener(self.spin_row_height,
                                 self.on_spin_row_height_changed)
     ac.setVisible(self.spin_row_height, 0)
     font_name = "Segoe UI"
     if ac.initFont(0, font_name, 0, 0) > 0:
         self.lbl_delta.setFont(font_name, 0, 1)
         self.lbl_session_delta.setFont(font_name, 0, 1)
     self.cfg = Config("apps/python/prunn/", "config.ini")
     self.load_cfg()
def acMain(ac_version):
    global appWindow, CamberIndicators, CheckBoxes, Buttons, Options, Labels, UIData

    try:
        loadOptions()
        appWindow = ac.newApp("CamberExtravaganza")
        ac.setSize(appWindow, 200, 200)
        ac.drawBorder(appWindow, 0)
        ac.setBackgroundOpacity(appWindow, 0)
        ac.setIconPosition(appWindow, 0, -10000)

        # Only enable rendering if app is activated
        ac.addOnAppActivatedListener(appWindow, onAppActivated)
        ac.addOnAppDismissedListener(appWindow, onAppDismissed)

        # Custom monospace font
        ac.initFont(0, customFont, 0, 0)

        # Target Camber Labels
        Labels["target"] = ac.addLabel(appWindow, "Target:")
        if Options["showDelta"]:
            ac.setText(Labels["target"], "Delta:")
        else:
            ac.setText(Labels["target"], "Target:")
        ac.setPosition(Labels["target"], 85, 100)
        ac.setCustomFont(Labels["target"], customFont, 0, 0)
        ac.setFontSize(Labels["target"], 10)
        Labels["targetCamberF"] = ac.addLabel(appWindow, "")
        ac.setPosition(Labels["targetCamberF"], 65, 76)
        ac.setCustomFont(Labels["targetCamberF"], customFont, 0, 0)
        ac.setFontSize(Labels["targetCamberF"], 24)
        Labels["targetCamberR"] = ac.addLabel(appWindow, "")
        ac.setPosition(Labels["targetCamberR"], 65, 105)
        ac.setCustomFont(Labels["targetCamberR"], customFont, 0, 0)
        ac.setFontSize(Labels["targetCamberR"], 24)

        # Options Checkbox
        CheckBoxes["options"] = ac.addCheckBox(appWindow, "Options")
        ac.setPosition(CheckBoxes["options"], 50, 225)
        ac.addOnCheckBoxChanged(CheckBoxes["options"], checkboxHandler)

        # Option Buttons
        uidata = [["drawGraphs", "Draw Graphs", drawGraphsHandler],
                  ["normalize", "Normalize", normalizeHandler],
                  ["useSpectrum", "Use Spectrum", useSpectrumHandler],
                  ["showDelta", "Show Delta", showDeltaHandler]]
        x = 50
        y = 255
        dy = 30
        for d in uidata:
            Buttons[d[0]] = ac.addButton(appWindow, d[1])
            ac.setPosition(Buttons[d[0]], x, y)
            ac.setSize(Buttons[d[0]], 100, 25)
            ac.addOnClickedListener(Buttons[d[0]], d[2])
            ac.setVisible(Buttons[d[0]], 0)
            y += dy

        # Get optimal camber from files
        loadTireData()

        CamberIndicators["FL"] = CamberIndicator(appWindow, 15, 75)
        CamberIndicators["FR"] = CamberIndicator(appWindow, 135, 75)
        CamberIndicators["RL"] = CamberIndicator(appWindow, 15, 175)
        CamberIndicators["RR"] = CamberIndicator(appWindow, 135, 175)
        ac.addRenderCallback(appWindow, onFormRender)

    except Exception:
        ac.log("CamberExtravaganza ERROR: acMain(): %s" %
               traceback.format_exc())

    return "CamberExtravaganza"
Пример #9
0
def acMain(acVersion):
    global appName, appWindow, info, imagePath
    global fName, fSmall, fNormal, fLarge, fxLarge, fGear, fSpeed
    global output_speed, speed, gear, output_gear
    global absVal, text_abs, tcsVal, text_tcs
    global output_Fuel_R

    # App Window MAIN
    appWindow = ac.newApp(appName)
    ac.setTitle(appWindow, "")
    ac.setSize(appWindow, 640, 78)
    ac.setIconPosition(appWindow, 0, -10000)
    ac.drawBorder(appWindow, 0)
    ac.initFont(0, fName, 0, 0)

    # Gear
    text_gear = ac.addLabel(appWindow, "gear")
    ac.setFontSize(text_gear, fNormal)
    ac.setPosition(text_gear, 0, 52)
    ac.setFontColor(text_gear, 1, 1, 1, 0.83)
    ac.setCustomFont(text_gear, fName, 0, 0)

    output_gear = ac.addLabel(appWindow, "")
    ac.setFontSize(output_gear, fGear)
    ac.setFontAlignment(output_gear, "center")
    ac.setPosition(output_gear, 26, 4)
    ac.setCustomFont(output_gear, fName, 0, 0)
    ac.setFontColor(output_gear, 0, 0, 0, 0.55)

    # TCS
    text_tcs = ac.addLabel(appWindow, "tcs")
    ac.setPosition(text_tcs, 65, 52)
    ac.setFontSize(text_tcs, fNormal)
    ac.setFontColor(text_tcs, 1, 1, 1, 0.83)
    ac.setCustomFont(text_tcs, fName, 0, 0)

    # ABS
    text_abs = ac.addLabel(appWindow, "abs")
    ac.setPosition(text_abs, 110, 52)
    ac.setFontSize(text_abs, fNormal)
    ac.setFontColor(text_abs, 1, 1, 1, 0.83)
    ac.setCustomFont(text_abs, fName, 0, 0)

    #Speed
    text_speed = ac.addLabel(appWindow, "km\h")
    ac.setPosition(text_speed, 610, 52)
    ac.setFontAlignment(text_speed, "right")
    ac.setFontSize(text_speed, fNormal)
    ac.setFontColor(text_speed, 1, 1, 1, 0.83)
    ac.setCustomFont(text_speed, fName, 0, 0)

    output_speed = ac.addLabel(appWindow, "")
    ac.setFontSize(output_speed, fSpeed)
    ac.setFontAlignment(output_speed, "right")
    ac.setPosition(output_speed, 610, -6)
    ac.setFontColor(output_speed, 1, 1, 1, 0.83)
    ac.setCustomFont(output_speed, fName, 0, 0)

    #Fuel - Remaining litres
    text_Fuel_R = ac.addLabel(appWindow, "Fuel:")
    ac.setFontSize(text_Fuel_R, fNormal)
    ac.setFontAlignment(text_Fuel_R, "right")
    ac.setPosition(text_Fuel_R, 360, 52)
    ac.setFontColor(text_Fuel_R, 1, 1, 1, 0.83)
    ac.setCustomFont(text_Fuel_R, fName, 0, 0)

    output_Fuel_R = ac.addLabel(appWindow, "%01d")
    ac.setFontSize(output_Fuel_R, fNormal)
    ac.setFontAlignment(output_Fuel_R, "right")
    ac.setPosition(output_Fuel_R, 460, 52)
    ac.setFontColor(output_Fuel_R, 1, 1, 1, 0.83)
    ac.setCustomFont(output_Fuel_R, fName, 0, 0)

    return appName
Пример #10
0
def acMain(ac_version):
    """Run upon startup of Assetto Corsa.
    
    Args:
        ac_version (str): Version of Assetto Corsa.
            AC passes this argument automatically.
    """
    # Read config
    global cfg
    cfg = Config()

    # Initialize session data object
    global session
    session = Session(cfg)

    # Set up app window
    global app_window
    app_window = AppWindow(cfg)
    ac.addRenderCallback(app_window.id, app_render)

    # Set up wind indicator object and add to list of drawables
    global wind_indicator
    wind_indicator = WindIndicator(cfg, session)
    app_window.add_drawable(wind_indicator)

    # Initialize font
    ac.initFont(0, 'ACRoboto300', 0, 0)

    # Add text labels
    global label_grip_text, label_wind_text, label_road_text, label_air_text
    label_grip_text = ACLabel(app_window.id, text="GRIP:")
    label_wind_text = ACLabel(app_window.id, text="WIND:")
    label_road_text = ACLabel(app_window.id, text="ROAD:")
    label_air_text = ACLabel(app_window.id, text="AIR:")

    text_labels_list = [
        label_grip_text, label_wind_text, label_road_text, label_air_text
    ]
    for n, label in enumerate(text_labels_list):
        label.set_custom_font('ACRoboto300')
        label.fit_height(
            Point(cfg.app_padding_px,
                  cfg.app_padding_px + (100 * n * cfg.app_scale)),
            100 * cfg.app_scale)

    global label_grip_val, label_wind_val, label_road_val, label_air_val
    label_grip_val = ACLabel(app_window.id, postfix=" %")
    label_wind_val = ACLabel(app_window.id, postfix=" km/h")
    label_road_val = ACLabel(app_window.id, postfix=" C")
    label_air_val = ACLabel(app_window.id, postfix=" C")

    data_labels_list = [
        label_grip_val, label_wind_val, label_road_val, label_air_val
    ]
    for n, label in enumerate(data_labels_list):
        label.set_custom_font('ACRoboto300')
        label.set_alignment('right')
        label.fit_height(
            Point(
                cfg.app_height * (cfg.app_aspect_ratio - 1 - cfg.app_padding),
                cfg.app_padding_px + (100 * n * cfg.app_scale)),
            100 * cfg.app_scale)