def acMain(ac_version): """Main function that is invoked by Assetto Corsa.""" global NOTIFICATION, LAPTIME_LABELS app = ac.newApp("AC-Ranking") ac.setSize(app, 400, 300) NOTIFICATION = ac.addLabel(app, '') ac.setPosition(NOTIFICATION, 15, 20) ac.setSize(NOTIFICATION, 190, 20) auth = read_auth() validate_token(auth['user'], auth['token']) validate_token_button = ac.addButton(app, 'Validate token') ac.setPosition(validate_token_button, 20, 40) ac.setSize(validate_token_button, 120, 20) ac.addOnClickedListener(validate_token_button, validate_token_button_func) refresh_button = ac.addButton(app, '\u21BB') ac.setPosition(refresh_button, 300, 5) ac.setSize(refresh_button, 15, 18) ac.addOnClickedListener(refresh_button, refresh_button_func) LAPTIME_LABELS = tuple(ac.addLabel(app, '#' + str(i)) for i in range(10)) for index, label in enumerate(LAPTIME_LABELS): ac.setSize(label, 120, 20) ac.setPosition(label, 200, (index * 20) + 50) get_laptimes(ac.getCarName(0), ac.getTrackName(0), ac.getTrackConfiguration(0) or None) return "ACR"
def acMain(ac_version): #app window init; global variables for later updating go here global appWindow appWindow = ac.newApp(appName) ac.setTitle(appWindow, appName) ac.setSize(appWindow, width, height) ac.log("z3D Gauge loaded") ac.console("z3D Gauge console test") ####################################################declaring gauge elements # gonna need new textures like # rpm_bar = ac.newTexture(app_path + theme_path + "rpm_bar.png") global l_kmph, l_rpm, l_gear, acceleration global ascii_RPM l_kmph = ac.addLabel(appWindow, "KMPH") l_rpm = ac.addLabel(appWindow, "RPM") l_gear = ac.addLabel(appWindow, "Current gear") ascii_RPM = ac.addLabel(appWindow, "") acceleration = ac.addLabel(appWindow, "") #l_TC = ac.addLabel(appWindow, "TC on/off") #non-functional #l_ABS = ac.addLabel(appWindow, "ABS on/off") #non-functional ac.setPosition(l_kmph, 3, 30) ac.setPosition(l_rpm, 3, 60) ac.setPosition(l_gear, 3, 80) ac.setPosition(ascii_RPM, 3, 160) ac.setPosition(acceleration, 3, 580) ac.addRenderCallback(appWindow, appGL) # -> links this app's window to an OpenGL render function return appName
def acMain(ac_version): global DRIVER, TRACK, CAR, WINDOW, LAP_LABELS, LAP_VALID_INDICATOR DRIVER = ac.getDriverName(DRIVER_ID_SELF) TRACK = '%s-%s' % (ac.getTrackName(DRIVER_ID_SELF), ac.getTrackConfiguration(DRIVER_ID_SELF)) CAR = ac.getCarName(DRIVER_ID_SELF) ac.console('Initialize %s: driver %s on %s in %s' % (NAME, DRIVER, TRACK, CAR)) WINDOW = ac.newApp(NAME) ac.setSize(WINDOW, *SIZE) ac.setTitle(NAME) if ac.addOnAppActivatedListener(WINDOW, onActivate) == -1: ac.console('Failed to add listener activate') if ac.addOnAppDismissedListener(WINDOW, onDeactivate) == -1: ac.console('Failed to add listener deactivate') i = 0 while i < LAP_COUNT: label = ac.addLabel(WINDOW, 'Waiting for lap time...') LAP_LABELS.append(label) i += 1 LAP_VALID_INDICATOR = ac.addLabel(WINDOW, 'Clean') refreshLapDisplay() return NAME
def __init__(self, app, x, y): self.AverageFuelPerLap = 0.0 self.FuelLastLap = 0.0 self.completedLaps = 0.0 self.fuelAtLapStart = 0.0 self.distanceTraveledAtStart = 0.0 self.fuelAtStart = 0.0 self.lastFuelMeasurement = 0.0 self.lastDistanceTraveled = 0.0 self.counter = 0 self.updatecounter = 0 self.inifilepath = inidir + self.getValidFileName(ac.getCarName(0)) +"_" + self.getValidFileName(ac.getTrackName(0)) + self.getValidFileName(ac.getTrackConfiguration(0)) + ".ini" ##initialize labels self.remainingLabel = ac.addLabel(app, "remainingLabel") self.averageFuelPerLapLabel = ac.addLabel(app, "averageFuelPerLapLabel") self.lapsLeftLabel = ac.addLabel(app, "lapsLeftLabel") self.averageFuelPer100kmLabel = ac.addLabel(app, "averageFuelPer100km") self.instFuelLabel = ac.addLabel(app, "instFuel") ##set label positions ac.setPosition(self.remainingLabel, x, y) ac.setPosition(self.averageFuelPerLapLabel, x + 208, y) ac.setPosition(self.lapsLeftLabel, 150 - x, y) ac.setPosition(self.averageFuelPer100kmLabel, x + 208, y + 19) ac.setPosition(self.instFuelLabel, 150 - x, y + 19) ##set label alignments ac.setFontAlignment(self.remainingLabel, "left") ac.setFontAlignment(self.averageFuelPerLapLabel, "left") ac.setFontAlignment(self.lapsLeftLabel, "right") ac.setFontAlignment(self.averageFuelPer100kmLabel, "left") ac.setFontAlignment(self.instFuelLabel, "right") ##set font size ac.setFontSize(self.remainingLabel, 32) ac.setFontSize(self.averageFuelPerLapLabel, 16) ac.setFontSize(self.lapsLeftLabel, 16) ac.setFontSize(self.averageFuelPer100kmLabel, 16) ac.setFontSize(self.instFuelLabel, 16) if os.path.exists(self.inifilepath): f = open(self.inifilepath, "r") self.AverageFuelPerLap = float(f.readline()[6:]) f.close() ac.setText(self.remainingLabel, "--- l") ac.setText(self.averageFuelPerLapLabel, "--- l/lap") ac.setText(self.lapsLeftLabel, "--- laps") if milesPerGallon: ac.setText(self.averageFuelPer100kmLabel, "--- mpg") else: ac.setText(self.averageFuelPer100kmLabel, "--- l/100km") ac.setText(self.instFuelLabel, "--- inst.")
def reinitialize(self): ac.setTitle(self.data.app_id, "") self.hide_app_background() ac.drawBorder(self.data.app_id, 0) ac.setIconPosition(self.data.app_id, 0, -10000) ac.setSize(self.data.app_id, config.APP_WIDTH, config.APP_HEIGHT) # Click on app area handling - used for toggling modes if not hasattr(self.data, 'click_label'): self.data.click_label = ac.addLabel(self.data.app_id, '') ac.addOnClickedListener(self.data.click_label, sys.modules['deltabar'].onClick) ac.setPosition(self.data.click_label, 0, 0) ac.setSize(self.data.click_label, config.APP_WIDTH, config.APP_HEIGHT) # Delta bar main area if not hasattr(self.data, 'bar_area'): self.data.bar_area = ac.addLabel(self.data.app_id, '') ac.setPosition(self.data.bar_area, config.BAR_CORNER_RADIUS, 0) ac.setSize(self.data.bar_area, config.BAR_WIDTH - 2 * config.BAR_CORNER_RADIUS, config.BAR_HEIGHT) ac.setBackgroundColor(self.data.bar_area, *config.BACKGROUND_COLOR.rgb) ac.setBackgroundOpacity(self.data.bar_area, config.BACKGROUND_COLOR.alpha) # Delta label background area if not hasattr(self.data, 'delta_label_area'): self.data.delta_label_area = ac.addLabel(self.data.app_id, '') ac.setPosition(self.data.delta_label_area, config.BAR_WIDTH_HALF - config.DELTA_LABEL_WIDTH_HALF, config.DELTA_LABEL_Y) ac.setSize(self.data.delta_label_area, config.DELTA_LABEL_WIDTH, config.DELTA_LABEL_HEIGHT) ac.setBackgroundTexture(self.data.delta_label_area, 'apps/python/deltabar/background_delta.png') # Delta label text if not hasattr(self.data, 'delta_label'): self.data.delta_label = ac.addLabel(self.data.app_id, '') ac.setPosition(self.data.delta_label, config.BAR_WIDTH_HALF - config.DELTA_LABEL_WIDTH_HALF, config.DELTA_LABEL_TEXT_Y) ac.setSize(self.data.delta_label, config.DELTA_LABEL_WIDTH, config.DELTA_LABEL_FONT_SIZE) ac.setFontAlignment(self.data.delta_label, 'center') ac.setFontSize(self.data.delta_label, config.DELTA_LABEL_FONT_SIZE) # Banner label (displays current selected mode) if not hasattr(self.data, 'banner_label'): self.data.banner_label = ac.addLabel(self.data.app_id, '') ac.setPosition(self.data.banner_label, config.BAR_WIDTH_HALF - config.BANNER_TEXT_WIDTH / 2, config.BANNER_Y) ac.setSize(self.data.banner_label, config.BANNER_TEXT_WIDTH, config.BANNER_FONT_SIZE) ac.setFontAlignment(self.data.banner_label, 'center') ac.setFontSize(self.data.banner_label, config.BANNER_FONT_SIZE) ac.setFontColor(self.data.banner_label, *config.SLOW_COLOR.rgba)
def getUnusedRow(self): if len(self.unusedLabels) > 0: return self.unusedLabels.pop() else: return { "author": ac.addLabel(self.appWindow, "author"), "message": ac.addLabel(self.appWindow, "message") }
def acMain(ac_version): global appWindow, CamberIndicators, CheckBoxes, Buttons, Options, Labels, UIData 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) # Target Camber Labels Labels["target"] = ac.addLabel(appWindow, "Target:") ac.setPosition(Labels["target"], 85, 100) ac.setFontSize(Labels["target"], 10) Labels["targetCamberF"] = ac.addLabel(appWindow, "") ac.setPosition(Labels["targetCamberF"], 75, 76) ac.setFontSize(Labels["targetCamberF"], 24) Labels["targetCamberR"] = ac.addLabel(appWindow, "") ac.setPosition(Labels["targetCamberR"], 75, 105) 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] ] 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, 25, 75) CamberIndicators["FR"] = CamberIndicator(appWindow,125, 75) CamberIndicators["RL"] = CamberIndicator(appWindow, 25,175) CamberIndicators["RR"] = CamberIndicator(appWindow,125,175) ac.addRenderCallback(appWindow, onFormRender) return "CamberExtravaganza"
def acMain(ac_version): global appWindow, Labels, gearSpacing, fontSize, gears, PxPer1000RPM, RPMdivs appWindow = ac.newApp("Reventach") ac.setSize(appWindow, appWidth, appHeight) ac.drawBorder(appWindow, 0) ac.setBackgroundOpacity(appWindow, 0) ac.setIconPosition(appWindow, 0, -10000) ac.setTitle(appWindow, "") # Only enable rendering if app is activated ac.addOnAppActivatedListener(appWindow, onAppActivated) ac.addOnAppDismissedListener(appWindow, onAppDismissed) loadCarData() PxPer1000RPM = 1000 * appHeight / CarData["maxRPM"] RPMdivs = CarData["maxRPM"] // 10000 + 1 #~ fontSize = PxPer1000RPM * 0.5 * RPMdivs fontSize = appHeight / 15 y = appHeight - PxPer1000RPM * RPMdivs count = RPMdivs while y > -1: dx = (appHeight - y) / lineSlope Labels["rpmL" + str(count)] = ac.addLabel(appWindow, str(count)) ac.setPosition(Labels["rpmL" + str(count)], dx - fontSize, y - fontSize / 2) ac.setFontSize(Labels["rpmL" + str(count)], fontSize) ac.setFontAlignment(Labels["rpmL" + str(count)], "center") Labels["rpmR" + str(count)] = ac.addLabel(appWindow, str(count)) ac.setPosition(Labels["rpmR" + str(count)], appWidth - dx + fontSize, y - fontSize / 2) ac.setFontSize(Labels["rpmR" + str(count)], fontSize) ac.setFontAlignment(Labels["rpmR" + str(count)], "center") if y < PxPer1000RPM * RPMdivs - 1: ac.setFontColor(Labels["rpmL" + str(count)], 0.7, 0.0, 0.0, 0.9) ac.setFontColor(Labels["rpmR" + str(count)], 0.7, 0.0, 0.0, 0.9) y -= (PxPer1000RPM * RPMdivs) count += RPMdivs for n in range(CarData["totalGears"]): gears.insert(0, str(n + 1)) gearSpacing = appHeight / (CarData["totalGears"] + 2) fontSize = gearSpacing * 0.8 for n, c in enumerate(gears): Labels["gear" + c] = ac.addLabel(appWindow, c) ac.setPosition(Labels["gear" + c], appWidth / 2, (n * gearSpacing)) ac.setFontSize(Labels["gear" + c], fontSize) ac.setFontAlignment(Labels["gear" + c], "center") ac.addRenderCallback(appWindow, onFormRender) return "Reventach"
def __init__(self, app, name, x, y): global space self.temp = 1 self.xPosition = x self.yPosition = y self.name = name # create a label using the tyre name and a placeholder for the associated temperature self.labelTemperature = ac.addLabel(app, self.name + ":") ac.setPosition(self.labelTemperature, self.xPosition, self.yPosition) self.labelTemperatureValue = ac.addLabel(app, str(self.temp)) ac.setPosition(self.labelTemperatureValue, self.xPosition + space, self.yPosition)
def __init__(self, name, tyre=None, render_function=None): self.window = ac.newApp(name) self.tyre = tyre ac.setIconPosition(self.window, 9999999, 99999999) # hide the icon ac.setSize(self.window, TyreWindow.width, TyreWindow.height) self.opt_label = ac.addLabel(self.window, "Opt:") ac.setPosition(self.opt_label, 5, 50) self.slip_label = ac.addLabel(self.window, "Slip:\nSkid:") ac.setPosition(self.slip_label, 5, 70) self.starting_label_no = ac.addLabel(self.window, "") ac.addRenderCallback(self.window, render_function) ac.setFontSize(self.starting_label_no, 25) ac.setPosition(self.starting_label_no, 35, 20)
def __init__(self, valueName, appWindow, x, y, fontSize=48, unit="", format=None, title=None, alignment="right"): self.valueName = valueName self.unit = unit self.label = ac.addLabel(appWindow, "0") self.unitLabel = ac.addLabel(appWindow, self.unit) self.format = format self.x = x self.y = y self.fontSize = fontSize self.title = title self.alignment = alignment if self.title is not None: self.titleLabel = ac.addLabel(appWindow, self.title)
def acMain(ac_version): global appwindow, speed_meters_s, angular_vel, gas_brake_clutch_handbrake, steer_pos, lap_invalidated, current_lap, last_lap, performance_meter appWindow = ac.newApp("TensorTrainer") ac.setSize(appWindow, 200, 200) speed_meters_s = ac.addLabel(appWindow, "Speed(M/s): 0") angular_vel = ac.addLabel(appWindow, "Ang.Vel.: 0") gas_brake_clutch_handbrake = ac.addLabel(appWindow, "GBCH: 0000") steer_pos = ac.addLabel(appWindow, "Steer: 0") lap_invalidated = ac.addLabel(appWindow, "LapValid: Yes") current_lap = ac.addLabel(appWindow, "Current: 0") last_lap = ac.addLabel(appWindow, "Last: 0") performance_meter = ac.addLabel(appWindow, "Perf: 0") ac.setPosition(speed_meters_s, 3, 30) ac.setPosition(angular_vel, 3, 45) ac.setPosition(gas_brake_clutch_handbrake, 3, 60) ac.setPosition(steer_pos, 3, 75) ac.setPosition(lap_invalidated, 3, 90) ac.setPosition(current_lap, 3, 105) ac.setPosition(last_lap, 3, 120) ac.setPosition(performance_meter, 3, 135) return "TensorTrainer"
def acMain(ac_version): global scorelabel, currentscorelabel appWindow = ac.newApp("clubhighscores") ac.setSize(appWindow, 200, 200) ac.console("Club highsscores active!") currentscorelabel = ac.addLabel(appWindow, "") ac.setPosition(currentscorelabel, 3, 27) #lastlaptimelabel = ac.addLabel(appWindow, ""); #ac.setPosition(lastlaptimelabel, 3, 50); scorelabel = ac.addLabel(appWindow, "No connection to Server") ac.setPosition(scorelabel, 3, 50) #73 UpdateScores() return "clubhighscores"
def acMain(ac_version): global l_lapcount, b_benzina appWindow = ac.newApp("benza") ac.setSize(appWindow, 200, 200) ac.log("Benza Start") ac.console("Benza is running") l_lapcount = ac.addLabel(appWindow, "Laps: 0") b_benzina = ac.addLabel(appWindow, "Fuel: 0") ac.setPosition(l_lapcount, 3, 30) return "benza"
def __init__(self, app, x, y): global Options self.xPosition = x self.yPosition = y self.value = 0 self.avgValue = 0 self.color = {'r':1,'g':1,'b':1,'a':1} self.serie = collections.deque(maxlen=Options["graphWidth"]) self.minVal = 6 self.maxVal = 1.5 self.valueLabel = ac.addLabel(appWindow, "0.0°") ac.setPosition(self.valueLabel, x, y) self.avgValueLabel = ac.addLabel(appWindow, "0.0°") ac.setPosition(self.avgValueLabel, x, y + 18)
def __init__(self, name, headerName): self.headerName = headerName self.window = ac.newApp(name) self.lapNumberLabel = [] self.timeLabel = [] self.deltaLabel = [] self.lastLapDataRefreshed = -1 self.lastLapViewRefreshed = 0 self.total = 0 self.bestLapAc = 0 self.bestLapTimeSession = 0 self.bestLapTime = 0 self.referenceTime = 0 self.laps = [] self.bestLapData = [] self.currentLapData = [(0.0,0.0)] self.sfCrossed = 0 self.session = info.graphics.session self.lastSession = 0 self.lapInvalidated = 0 self.justCrossedSf = False self.position = 0 self.lastPosition = 0 self.currentTime = 0 self.lastCurrentTime = 0 self.pitExitState = 0 self.pitExitDeltaOffset = 0 self.pitExitLap = 0 self.readBestLap() self.currLabelId = lapLabelCount self.refLabelId = lapLabelCount+1 self.totalLabelId = lapLabelCount+2 for index in range(lapLabelCount+3): self.lapNumberLabel.append(ac.addLabel(self.window, "%d." % (index+1))) ac.setFontAlignment(self.lapNumberLabel[index], 'left') self.timeLabel.append(ac.addLabel(self.window, timeToString(0))) ac.setFontAlignment(self.timeLabel[index], 'right') self.deltaLabel.append(ac.addLabel(self.window, "-.---")) ac.setFontAlignment(self.deltaLabel[index], 'right') ac.setText(self.lapNumberLabel[self.currLabelId], "Curr.") ac.setText(self.lapNumberLabel[self.totalLabelId], "Tot.")
def __init__(self, window_id, position=Point(), text=" ", font=None, italic=0, size=None, color=None, alignment='left', prefix="", postfix=""): # Create label self.id = ac.addLabel(window_id, "") # Set position self.set_position(position) # Set text self.prefix = prefix self.postfix = postfix self.set_text(text) # Set alignment self.set_alignment(alignment) # Optional items if font is not None: self.set_custom_font(font, italic) if size is not None: self.set_font_size(size) if color is not None: self.set_color(color)
def acMain(ac_version): global l_velocity, f time.strftime('%Y-%m-%d %H:%M:%S') app_name = "SAE Dummy Data Generator" app_window = ac.newApp(app_name) ac.setSize(app_window, 200, 200) l_velocity = ac.addLabel(app_window, "Velocity: --") ac.setPosition(l_velocity, 3, 30) f = open('apps\python\SAE\dummydata.txt', 'w') f.write('INSERT INTO SensorData (CanId, Data, UTCTimestamp) VALUES') # ac.console("CONNECTING TO DATABASE...") # connection = connector.connect( # host="ts20.billydasdev.com", # user="******", # passwd="ts20", # port="3306", # db="ts20" # ) # cursor = connection.cursor(prepared=True) # ac.console("CONNECTED!") return app_name
def acMain(ac_version): global appWindow, label1, logPrefix, appName, cfg, ui_enableButton ac.console(logPrefix + "acMain") try: appWindow = ac.newApp(appName) cfg = Configuration() cfg.load() ac.setTitle(appWindow, "") ac.setSize(appWindow, 400, 200) ac.drawBorder(appWindow, 0) ac.setBackgroundOpacity(appWindow, 0) ac.addRenderCallback(appWindow, onRender) ui_enableButton = ac.addButton(appWindow, "Enable") ac.setPosition(ui_enableButton, 0, 30) ac.setSize(ui_enableButton, 70, 30) ac.addOnClickedListener(ui_enableButton, onEnableButtonClicked) label1 = ac.addLabel(appWindow, "____") ac.setPosition(label1, 0, 65) if cfg.enable > 0: ac.setText(ui_enableButton, "Disable") startTelemetry() ac.console(logPrefix + "Initialized") except: printExceptionInfo("acMain") return appName
def acMain(ac_version): global l_lapcount, b_benzina appWindow = ac.newApp("benza") ac.setSize(appWindow, 200, 200) ac.log("Benza Start") ac.console("Benza is running") l_lapcount = ac.addLabel(appWindow, "Laps: 0"); b_benzina = ac.addLabel(appWindow, "Fuel: 0"); ac.setPosition(l_lapcount, 3, 30) return "benza"
def acMain(acVerison): global serPort, tick, appWindow, statusLabel try: ac.log("opening serial port {}".format(serialPortName)) tick = ticker( ) # class below: keeps track of game tick rate and can be used to update over serial less frequently serPort = serial.Serial(port=serialPortName, baudrate=9600, timeout=0) time.sleep(3) serPort.write("0 0 \n".encode()) appWindow = ac.newApp("vr-wind") ac.setSize(appWindow, 200, 200) statusLabel = ac.addLabel(appWindow, "Output: none yet") ac.setPosition(statusLabel, 5, 32) ac.log("vr-wind ready") return "vr-wind" except Exception as e: ac.log("startup error: {}".format(e))
def __init__(self, parent: ACWidget, text: str = '', h_alignment: str = 'left', font: Font = None): super().__init__(parent, text, h_alignment, font) self.id = ac.addLabel(self.app, text)
def __init__(self,appWindow,text = ""): self.label = ac.addLabel(appWindow, " ") self.labelText = text self.labelSize = {"width" : 0, "height" : 0} self.labelPosition = {"xpos" : 0, "ypos" : 0} self.labelFontSize = 12 self.labelFontAlign = "left" self.labelFontColor = {"red" : 1, "green" : 1, "blue" : 1, "alpha" : 0} self.labelbgTexture = ""
def addImage(self, texture, options): options.x = options.x | 0 options.y = options.y | 0 options.width = options.width | 100 options.height = options.height | 100 item = ac.addLabel(self.appWindow, "") ac.setPosition(item, self.x + options.x * self.scale, self.y + options.y * self.scale) ac.setSize(item, options.width * self.scale, options.height * self.scale)
def __init__(self, parent, text, size, posx, posy, font, align): self.lbl = ac.addLabel(parent, str(text)) ac.setPosition(self.lbl, posx, posy) if size: ac.setFontSize(self.lbl, size) if font: ac.setCustomFont(self.lbl, font, 0, 0) if align: ac.setFontAlignment(self.lbl, align)
def __init__(self, appWindow, text=""): self.label = ac.addLabel(appWindow, " ") self.labelText = text self.labelSize = {"width": 0, "height": 0} self.labelPosition = {"xpos": 0, "ypos": 0} self.labelFontSize = 12 self.labelFontAlign = "left" self.labelFontColor = {"red": 1, "green": 1, "blue": 1, "alpha": 0} self.labelbgTexture = ""
def acMain(ac_version): global l_lapcount, l_speed, l_fuel, topspeed appWindow = ac.newApp("Lap Counter") ac.setSize(appWindow, 250, 200) #ac.log(print("Hello Assetto Corsa log!") #ac.console("Hello Assetto Corsa console!") l_speed = ac.addLabel(appWindow, "Highest Top Speed: {}".format(topspeed)) l_lapcount = ac.addLabel(appWindow, "Laps: 0") l_fuel = ac.addLabel(appWindow, "Fuel: 0") ac.setPosition(l_lapcount, 3, 30) ac.setPosition(l_speed, 3, 60) ac.setPosition(l_fuel, 3, 90) return "Lap Counter"
def acMain(ac_version): appWindow = ac.newApp("Pedal Circles") ac.setSize(appWindow, 412, 250) ac.setTitle(appWindow, "") # ac.setBackgroundOpacity(appWindow, 0) ~ doesn't change anything ac.setIconPosition(appWindow, 0, -10000) ac.console("Hello Assetto, this is Pedal Circles") brake_display = ac.addLabel(appWindow, "") ac.setPosition(brake_display, 3, 25) ac.setSize(brake_display, 200, 200) gas_display = ac.addLabel(appWindow, "") ac.setPosition(gas_display, 207, 25) ac.setSize(gas_display, 200, 200) return "brake"
def createLabel(name, text, x, y, font_size = 14, align = "center"): global mainApp label = ac.addLabel(mainApp, name) ac.setText(label, text) ac.setPosition(label, x, y) ac.setFontSize(label, font_size) ac.setFontAlignment(label, align) return label
def createApp(label): app = ac.newApp(label) ac.setTitle(app, "") ac.setIconPosition(app, 0, -10000) ac.setSize(app, 100, 50) ac.drawBorder(app, 0) label = ac.addLabel(app, "") ac.setPosition(label, 10, 5) return app, label
def __init__(self, appName): self.timer = 0 self.window = ac.newApp(appName) ac.setTitle(self.window, "") ac.drawBorder(self.window, 0) ac.setIconPosition(self.window, 0, -10000) ac.setSize(self.window, 367, 73) ac.setBackgroundOpacity(self.window, 0) self.fastestLapBanner = ac.addLabel(self.window, "") ac.setPosition(self.fastestLapBanner, 0, 0) w, h = get_image_size(FC.FASTEST_LAP_BANNER) ac.setSize(self.fastestLapBanner, w, h) ac.setBackgroundTexture(self.fastestLapBanner, FC.FASTEST_LAP_BANNER) self.fastestLapBackground = ac.addLabel(self.window, "") ac.setPosition(self.fastestLapBackground, w, 0) ac.setSize(self.fastestLapBackground, 400, h) ac.setBackgroundTexture(self.fastestLapBackground, FC.DRIVER_WIDGET_BACKGROUND) self.nameLabel = ac.addLabel(self.window, "") ac.setPosition(self.nameLabel, w + 10, 11) ac.setFontSize(self.nameLabel, 22) ac.setCustomFont(self.nameLabel, FC.FONT_NAME, 0, 0) ac.setFontColor(self.nameLabel, 0.86, 0.86, 0.86, 1) ac.setFontAlignment(self.nameLabel, "left") self.lastNameLabel = ac.addLabel(self.window, "") ac.setPosition(self.lastNameLabel, w + 10, 37) ac.setFontSize(self.lastNameLabel, 28) ac.setCustomFont(self.lastNameLabel, FC.FONT_NAME, 0, 1) ac.setFontColor(self.lastNameLabel, 0.86, 0.86, 0.86, 1) ac.setFontAlignment(self.lastNameLabel, "left") self.timeLabel = ac.addLabel(self.window, "") ac.setPosition(self.timeLabel, w + 385, 22) ac.setFontSize(self.timeLabel, 35) ac.setCustomFont(self.timeLabel, FC.FONT_NAME, 0, 1) ac.setFontColor(self.timeLabel, 0.86, 0.86, 0.86, 1) ac.setFontAlignment(self.timeLabel, "right")
def __init__(self, app, x, y): global Options try: self.xPosition = x self.yPosition = y self.value = 0 self.avgValue = 0 self.color = {'r': 1, 'g': 1, 'b': 1, 'a': 1} self.serie = collections.deque(maxlen=Options["graphWidth"]) self.minVal = 6 self.maxVal = 1.5 self.valueLabel = ac.addLabel(appWindow, "0.0°") ac.setPosition(self.valueLabel, x, y) self.avgValueLabel = ac.addLabel(appWindow, "0.0°") ac.setPosition(self.avgValueLabel, x, y + 18) except Exception: ac.log("CamberExtravaganza ERROR: CamberIndicator.__init__(): %s" % traceback.format_exc())
def __init__(self, window, text = ""): self.text = text self.label = ac.addLabel(window, self.text) self.size = { "w" : 0, "h" : 0 } self.pos = { "x" : 0, "y" : 0 } self.color = (1, 1, 1, 1) self.bgColor = (0, 0, 0, 1) self.fontSize = 12 self.align = "left" self.bgTexture = "" self.opacity = 1
def acMain(ac_version): global l_lapcount, l_laptime # Define app window for lap count and lap timer. Create output csv file # The shortcut to access the console mid game is the Home key appWindow = ac.newApp("stint_tracker") ac.setSize(appWindow, 200, 200) ac.log("** Stint tracker** Hello, I fired up okay!") ac.console("** Stint Tracker** Hello, I fired up okay!") l_lapcount = ac.addLabel(appWindow, "Laps Completed: 0") ac.setPosition(l_lapcount, 3, 30) l_laptime = ac.addLabel(appWindow, "Start time: 0") ac.setPosition(l_laptime, 3, 60) with open('stintoutputfile.csv', 'a') as f: f.write("Lap Number, Lap Time\n") return "stint_tracker"
def __init__(self, acd: ACD, resolution: str, window_id: int): self.__calc = Power(acd.get_power_curve()) # Initial size is 512x85 super(RPMPower, self).__init__(0.0, 0.0, 512.0, 50.0) self._back.color = Colors.black self.__lb = ac.addLabel(window_id, "- RPM") ac.setFontAlignment(self.__lb, "center") self.resize(resolution)
def acMain(ac_version): global label1 appWindow = ac.newApp("Time") ac.setTitle(appWindow, '') ac.setSize(appWindow, 180, 30) ac.setPosition(appWindow, 1500, 50) label1 = ac.addLabel(appWindow, "") ac.setPosition(label1, 60, 5) return "Time"
def create_debug_labels(): global flLabel, frLabel, rlLabel, rrLabel, upperDistance, distanceFromLeft, tyreWidth, tyreHeight, angle_delta_label flLabel = ac.addLabel(appWindow, "0.0") ac.setPosition(flLabel, distanceFromLeft, upperDistance + tyreHeight) ac.setFontAlignment(flLabel, "right") frLabel = ac.addLabel(appWindow, "0.0") ac.setPosition(frLabel, distanceFromLeft + tyreWidth + tyreWidth, upperDistance + tyreHeight) ac.setFontAlignment(frLabel, "left") rlLabel = ac.addLabel(appWindow, "0.0") ac.setPosition(rlLabel, distanceFromLeft, upperDistance + tyreHeight * 2 + tyreHeight) ac.setFontAlignment(rlLabel, "right") rrLabel = ac.addLabel(appWindow, "0.0") ac.setPosition(rrLabel, distanceFromLeft + tyreWidth + tyreWidth, upperDistance + tyreHeight * 2 + tyreHeight) ac.setFontAlignment(rrLabel, "left") angle_delta_label = ac.addLabel(appWindow, "0.0") ac.setPosition(angle_delta_label, 0, upperDistance + tyreHeight * 3 + 50)
def acMain(ac_version): global appWindow, timeLabel appWindow=ac.newApp("Time") ac.setTitle(appWindow,"Time") ac.setSize(appWindow,160,60) ac.drawBorder(appWindow,0) ac.setBackgroundOpacity(appWindow,0) theTime=datetime.now() timeLabel=ac.addLabel(appWindow, "{}".format(theTime.strftime("%H:%M"))) ac.setPosition(timeLabel,70,30) ac.addRenderCallback(appWindow , onFormRender) return "Time"
def __init__(self, window, name, text=""): self.text = text self.name = name self.label_id = ac.addLabel(window, self.name) self.size = {"w": 0, "h": 0} self.pos = {"x": 0, "y": 0} self.color = (1, 1, 1, 1) self.bgColor = (0, 0, 0, 1) self.fontSize = 12 self.align = "left" self.bgTexture = "" self.opacity = 1
def acMain(ac_version): global appWindow, trackname, tracklength, l_lapcount, l_distance, l_fuel, conn, c appWindow = ac.newApp("acOdometer") ac.setSize(appWindow, 142, 142) l_lapcount = ac.addLabel(appWindow, "Laps: Outlap") ac.setPosition(l_lapcount, 3, 30) l_distance = ac.addLabel(appWindow, "Kilometers: Outlap") ac.setPosition(l_distance, 3, 45) l_fuel = ac.addLabel(appWindow, "Fuel used: 0") ac.setPosition(l_fuel, 3, 60) trackname = ac.getTrackName(0) carname = ac.getCarName(0) t = int(time.time()) c.execute("INSERT INTO session('date', 'track', 'car') values (?, ?, ?)", (t, trackname, carname)) # Commited atomically at end of session ac.log("*************************** NEW SESSION\n********* " + trackname) ac.log("acOdometer loaded, racing {} which has {:.3f} miles per lap".format(trackname, tracklength[trackname])) ac.console("acOdometer loaded, racing {} which has {:.3f} kilometers per lap.".format(trackname, tracklength[trackname])) return "acOdometer"
def acMain(ac_version): global textInput, appWindow, inputWindow, messages, lines, maxLines appWindow = ac.newApp('nChat') inputWindow = ac.newApp('nInput') ac.setSize(appWindow, 500, 100) ac.drawBorder(appWindow, 0) ac.setTitle(appWindow, '') ac.setIconPosition(appWindow, -9000, 0) ac.setBackgroundOpacity(appWindow, 0) ac.setSize(inputWindow, 435, 62) ac.drawBorder(inputWindow, 0) ac.setTitle(inputWindow, '') ac.setIconPosition(inputWindow, -9000, 0) ac.setBackgroundOpacity(inputWindow, 0) textInput = ac.addTextInput(inputWindow, 'TEXT_INPUT') ac.setPosition(textInput, 1, 32) ac.setSize(textInput, 435, 30) ac.addOnChatMessageListener(appWindow, onChatMessage) ac.addOnClickedListener(appWindow, onWindowClick) ac.addOnValidateListener(textInput, onValidateListener) ac.addOnClickedListener(inputWindow, onWindowClick) for i in range(0, maxLines): lines.append([ac.addLabel(appWindow, ''), ac.addLabel(appWindow, '')]) for x in range(0, 2): ac.setSize(lines[i][x], 14*60, 14) ac.setPosition(lines[i][x], 0, i*14+5) ac.setFontSize(lines[i][x], 14) # Maybe add back in later #lines.reverse() onChatMessage('Loaded...', 'nChat') return "nChat"
def __init__(self, window, text = ""): self.text = text self.label = ac.addLabel(window, self.text) self.params = {"x" : Value(0), "y" : Value(0), "w" : Value(0), "h" : Value(0),"br" : Value(1), "bg" : Value(1), "bb" : Value(1), "o" : Value(0), "r" : Value(1), "g" : Value(1), "b" : Value(1), "a" : Value(1) } self.f_params = {"x" : Value(0), "y" : Value(0), "w" : Value(0), "h" : Value(0),"br" : Value(1), "bg" : Value(1), "bb" : Value(1), "o" : Value(0), "r" : Value(1), "g" : Value(1), "b" : Value(1), "a" : Value(1) } self.o_params = {"x" : Value(0), "y" : Value(0), "w" : Value(0), "h" : Value(0),"br" : Value(1), "bg" : Value(1), "bb" : Value(1), "o" : Value(1), "r" : Value(1), "g" : Value(1), "b" : Value(1), "a" : Value(1) } self.multiplier = {"x" : Value(3), "y" : Value(3), "w" : Value(1), "h" : Value(1),"br" : Value(0.06), "bg" : Value(0.06), "bb" : Value(0.06), "o" : Value(0.02), "r" : Value(0.06), "g" : Value(0.06), "b" : Value(0.06), "a" : Value(0.02) } self.multiplier_mode = {"x" : "", "y" : "", "w" : "", "h" : "","br" : "", "bg" : "", "bb" : "", "o" : "", "r" : "", "g" : "", "b" : "", "a" : "" } self.fontSize = 12 self.spring_multiplier = 36 self.align = "left" self.bgTexture = "" self.fontName = "" #self.opacity = 1 self.visible=0 self.isVisible = Value(False) self.isTextVisible = Value(False)
def add(self, text, x1, x2, x3): single_column = not any((x2, x3)) for column_number, col in enumerate((x1, x2, x3)): if col is None: continue if not hasattr(self.data, col): setattr(self.data, col, ac.addLabel(self.window_id, "")) ident = getattr(self.data, col) ac.setPosition(ident, column_number * 100, self._next_line) width = 300 if single_column else 100 ac.setSize(ident, width, self._line_size) ac.setFontSize(ident, self._font_size) if not single_column: ac.setFontAlignment(ident, 'right') ac.setFontColor(ident, 1.0, 1.0, 1.0, 1.0) self._next_line += self._line_size self.set(x1, text)
def reinitialize_app(self): # Initialize all 'data' fields we use. if not hasattr(self.data, 'frame_count'): self.data.frame_count = 0 # Only create the text label once. if not hasattr(self.data, 'banner'): self.data.banner = ac.addLabel(self.data.app_id, '') # But set the size and positioning every time the app is hot reloaded. ac.setPosition(self.data.banner, 0, 0) # X, Y relative to main app window ac.setSize(self.data.banner, config.LABEL_WIDTH, config.LABEL_HEIGHT) ac.setFontAlignment(self.data.banner, 'center') ac.setFontSize(self.data.banner, config.FONT_SIZE) ac.setFontColor(self.data.banner, 0.945, 0.933, 0.102, 1.0) # yellow ac.setText(self.data.banner, '')
def acMain(ac_version): global imperial, debug_mode, window_x_pos, window_y_pos, tyre_mon_xpos, tyre_mon_ypos global gear_color, gear_background, speed_color, speed_background, throttle_gauge_color, brake_gauge_color, clutch_gauge_color, boost_bar_color, fuel_bar_color global draw_digital_speedo, draw_shift_light, draw_gear_indicator, draw_speedometer, draw_tachometer, draw_odometer, draw_g_meter, draw_boost_gauge global draw_fuel_gauge, draw_throttle_gauge, draw_brake_gauge, draw_clutch_gauge, draw_tyre_monitor, draw_background global tach_needle_end, speedo_needle_end, tach_radius, speedo_radius, rpm_pivot_y, speed_pivot_y, rpm_pivot_x, speed_pivot_x, speedo_tl_x, speedo_tl_y global speedo_total_width, speedo_total_height global tach_redline_color, tach_bigline_color, tach_smallline_color, tach_needle_color1 global speedo_bigline_color, speedo_smallline_color, speedo_needle_color1 global throttle_gauge_inner_radius, throttle_gauge_outer_radius, throttle_gauge_min_y, throttle_gauge_max_y global brake_gauge_inner_radius, brake_gauge_outer_radius, brake_gauge_min_y, brake_gauge_max_y global clutch_gauge_inner_radius, clutch_gauge_outer_radius, clutch_gauge_min_y, clutch_gauge_max_y global throttle_gauge_root_x, throttle_gauge_root_y global brake_gauge_root_x, brake_gauge_root_y global clutch_gauge_root_x, clutch_gauge_root_y global throttle_gauge_right, brake_gauge_right, clutch_gauge_right global boost_radius, fuel_radius, boost_pivot_y, fuel_pivot_y, boost_pivot_x, fuel_pivot_x, boost_needle_end, fuel_needle_end, boost_needle_color, fuel_needle_color global odometer_fg, odometer_bg, g_meter_range, g_meter_x_anchor, g_meter_y_anchor, g_meter_opacity, window_width, window_height, background_image_path, background_image_path_noboost global tyre_monitor_opacity, g_meter_opacity global window, debug_label, indicated_max_rpm global flt_label1, frt_label1, rlt_label1, rrt_label1 global flt_label2, frt_label2, rlt_label2, rrt_label2 global fuel_warning_label global config global telemetry_client global draw_abs_status, draw_tcs_status, abs_label, abs_off_label, tcs_label, tcs_off_label global gear_x, gear_y, shift_light_x, shift_light_y, shift_light_radius, gear_width, gear_height global tach_min_angle, tach_max_angle, speedo_min_angle, speedo_max_angle global shift_light_on_color, shift_light_off_color global rpms_file config_file = configparser.ConfigParser() config_file.read('apps/python/AnalogInstruments/settings.ini') config = config_file[config_file['settings']['theme']] rpms_file = configparser.ConfigParser() rpms_file.read('apps/python/AnalogInstruments/rpms.ini') # SETTINGS # # Change this to 'True' to have speed measured in MPH imperial = config.getboolean('imperial') # Debug mode (basically just some numbers) debug_mode = config.getboolean('debug_mode') # Main window positions, change those if you're not using a single monitor 1080p setup window_x_pos = int(config['window_x_pos'])# (Your horz. res-1320)/2 window_y_pos = int(config['window_y_pos']) # Your vert. res - 250 # These are relative to the window's position tyre_mon_xpos = int(config['tyre_mon_x_pos'])# 20 px from the left on single mon 1080p tyre_mon_ypos = int(config['tyre_mon_y_pos'])# 920 px from the top # Color settings gear_color = parse_color(config['gear_color']) gear_background = parse_color(config['gear_background']) speed_color = parse_color(config['digi_speedo_color']) speed_background = parse_color(config['digi_speedo_background']) throttle_gauge_color = parse_color(config['throttle_gauge_color']) brake_gauge_color = parse_color(config['brake_gauge_color']) clutch_gauge_color = parse_color(config['clutch_gauge_color']) boost_bar_color = parse_color(config['boost_bar_color']) fuel_bar_color = parse_color(config['fuel_bar_color']) shift_light_on_color = parse_color(config['shift_light_on_color']) shift_light_off_color = parse_color(config['shift_light_off_color']) # Some more settings, hopefully pretty self-explanatory draw_digital_speedo = config.getboolean('draw_digital_speedo') draw_shift_light = config.getboolean('draw_shift_light') draw_gear_indicator = config.getboolean('draw_gear_indicator') draw_speedometer = config.getboolean('draw_speedometer') draw_tachometer = config.getboolean('draw_tachometer') draw_odometer = config.getboolean('draw_odometer') draw_g_meter = config.getboolean('draw_g_meter') draw_boost_gauge = config.getboolean('draw_boost_gauge') draw_fuel_gauge = config.getboolean('draw_fuel_gauge') draw_throttle_gauge = config.getboolean('draw_throttle_gauge') draw_brake_gauge = config.getboolean('draw_brake_gauge') draw_clutch_gauge = config.getboolean('draw_clutch_gauge') draw_tyre_monitor = config.getboolean('draw_tyre_monitor') draw_background = config.getboolean('draw_background') draw_abs_status = config.getboolean('draw_abs_status') draw_tcs_status = config.getboolean('draw_tcs_status') # Dimensions of things, mess with those at your own risk tach_needle_end = int(config['tach_needle_end']) speedo_needle_end = int(config['speedo_needle_end']) tach_radius = int(config['tach_radius']) speedo_radius = int(config['speedo_radius']) rpm_pivot_y = int(config['tach_y_anchor']) speed_pivot_y = int(config['speedo_y_anchor']) rpm_pivot_x = int(config['tach_x_anchor']) speed_pivot_x = int(config['speedo_x_anchor']) speedo_tl_x = int(config['digi_speedo_x']) speedo_tl_y = int(config['digi_speedo_y']) speedo_total_width = int(config['digi_speedo_width']) speedo_total_height = int(config['digi_speedo_height']) tach_min_angle = int(config['tach_min_angle']) tach_max_angle = int(config['tach_max_angle']) speedo_min_angle = int(config['speedo_min_angle']) speedo_max_angle = int(config['speedo_max_angle']) tach_redline_color = parse_color(config['tach_redline_color']) tach_bigline_color = parse_color(config['tach_bigline_color']) tach_smallline_color = parse_color(config['tach_smallline_color']) tach_needle_color1 = parse_color(config['tach_needle_color1']) speedo_bigline_color = parse_color(config['speedo_bigline_color']) speedo_smallline_color = parse_color(config['speedo_smallline_color']) speedo_needle_color1 = parse_color(config['speedo_needle_color1']) # G-Meter: 500-820 # Brake/Throttle Max Y: 70 Min: 160 throttle_gauge_inner_radius = int(config['throttle_gauge_inner_radius']) throttle_gauge_outer_radius = int(config['throttle_gauge_outer_radius']) throttle_gauge_min_y = int(config['throttle_gauge_min_y']) throttle_gauge_max_y = int(config['throttle_gauge_max_y']) throttle_gauge_root_x = int(config['throttle_gauge_root_x']) throttle_gauge_root_y = int(config['throttle_gauge_root_y']) throttle_gauge_right = config.getboolean('throttle_gauge_right') brake_gauge_inner_radius = int(config['brake_gauge_inner_radius']) brake_gauge_outer_radius = int(config['brake_gauge_outer_radius']) brake_gauge_min_y = int(config['brake_gauge_min_y']) brake_gauge_max_y = int(config['brake_gauge_max_y']) brake_gauge_root_x = int(config['brake_gauge_root_x']) brake_gauge_root_y = int(config['brake_gauge_root_y']) brake_gauge_right = config.getboolean('brake_gauge_right') clutch_gauge_inner_radius = int(config['clutch_gauge_inner_radius']) clutch_gauge_outer_radius = int(config['clutch_gauge_outer_radius']) clutch_gauge_min_y = int(config['clutch_gauge_min_y']) clutch_gauge_max_y = int(config['clutch_gauge_max_y']) clutch_gauge_root_x = int(config['clutch_gauge_root_x']) clutch_gauge_root_y = int(config['clutch_gauge_root_y']) clutch_gauge_right = config.getboolean('clutch_gauge_right') boost_radius = int(config['boost_radius']) fuel_radius = int(config['fuel_radius']) boost_pivot_y = int(config['boost_y_anchor']) fuel_pivot_y = int(config['fuel_y_anchor']) boost_pivot_x = int(config['boost_x_anchor']) fuel_pivot_x = int(config['fuel_x_anchor']) boost_needle_end = int(config['boost_needle_end']) fuel_needle_end = int(config['fuel_needle_end']) boost_needle_color = parse_color(config['boost_needle_color']) fuel_needle_color = parse_color(config['fuel_needle_color']) odometer_fg = parse_color(config['odometer_foreground']) odometer_bg = parse_color(config['odometer_background']) tyre_monitor_opacity = float(config['tyre_monitor_opacity']) g_meter_range = int(config['g_meter_range']) g_meter_x_anchor = int(config['g_meter_x_anchor']) g_meter_y_anchor = int(config['g_meter_y_anchor']) g_meter_opacity = float(config['g_meter_opacity']) gear_x = int(config['gear_x']) gear_y = int(config['gear_y']) gear_width = int(config['gear_width']) gear_height = int(config['gear_height']) shift_light_x = int(config['shift_light_x']) shift_light_y = int(config['shift_light_y']) shift_light_radius = int(config['shift_light_radius']) # Kind of configurable but you'll have change most of the dimensions above so not recommended window_width = int(config['window_width']) window_height = int(config['window_height']) background_image_path = config['background_path'] background_image_path_noboost = config['background_noboost_path'] abs_img = config['abs_img'] abs_off_img = config['abs_off_img'] tcs_img = config['tcs_img'] tcs_off_img = config['tcs_off_img'] window = ac.newApp("AnalogInstruments") ac.setTitle(window," ") ac.setBackgroundOpacity(window,0) ac.drawBorder(window,0) ac.setIconPosition(window,0,-10000) if draw_background: ac.drawBackground(window,1) ac.setBackgroundTexture(window,background_image_path) ac.setSize(window,window_width,window_height) ac.setPosition(window,window_x_pos,window_y_pos) debug_label = ac.addLabel(window,"") ac.setPosition(debug_label,20,window_height/10*9) ac.addRenderCallback(window,onWindowRender) # Setting up the tyre monitor labels (this can be done here because it doesn't depend on any car info) if draw_tyre_monitor: flt_label1 = ac.addLabel(window," ") ac.setPosition(flt_label1,tyre_mon_xpos+37,tyre_mon_ypos+5) flt_label2 = ac.addLabel(window," ") ac.setPosition(flt_label2,tyre_mon_xpos+37,tyre_mon_ypos+37) frt_label1 = ac.addLabel(window," ") ac.setPosition(frt_label1,tyre_mon_xpos+117,tyre_mon_ypos+5) frt_label2 = ac.addLabel(window," ") ac.setPosition(frt_label2,tyre_mon_xpos+117,tyre_mon_ypos+37) rlt_label1 = ac.addLabel(window," ") ac.setPosition(rlt_label1,tyre_mon_xpos+37,tyre_mon_ypos+101) rlt_label2 = ac.addLabel(window," ") ac.setPosition(rlt_label2,tyre_mon_xpos+37,tyre_mon_ypos+133) rrt_label1 = ac.addLabel(window," ") ac.setPosition(rrt_label1,tyre_mon_xpos+117,tyre_mon_ypos+101) rrt_label2 = ac.addLabel(window," ") ac.setPosition(rrt_label2,tyre_mon_xpos+117,tyre_mon_ypos+133) if draw_fuel_gauge: fuel_warning_label = ac.addLabel(window,"") ac.setSize(fuel_warning_label,12,14) ac.setPosition(fuel_warning_label,fuel_pivot_x - 6,fuel_pivot_y - 30) ac.setBackgroundTexture(fuel_warning_label,fuel_icon_warning_path) if draw_abs_status: abs_label = ac.addLabel(window,"") ac.setSize(abs_label,window_width,window_height) ac.setPosition(abs_label,0,0) ac.setBackgroundTexture(abs_label,abs_img) abs_off_label = ac.addLabel(window,"") ac.setSize(abs_off_label,window_width,window_height) ac.setPosition(abs_off_label,0,0) ac.setBackgroundTexture(abs_off_label,abs_off_img) if draw_tcs_status: tcs_label = ac.addLabel(window,"") ac.setSize(tcs_label,window_width,window_height) ac.setPosition(tcs_label,0,0) ac.setBackgroundTexture(tcs_label,tcs_img) tcs_off_label = ac.addLabel(window,"") ac.setSize(tcs_off_label,window_width,window_height) ac.setPosition(tcs_off_label,0,0) ac.setBackgroundTexture(tcs_off_label,tcs_off_img) return "Analog Instruments"
def acMain(ac_version): global Status global appWindow, FuelSelection, FuelLabel, NoChange, Option1 global Option2, Option3, Option4, Option5, Body, Engine, Suspension, Fill, FuelOption, NotificationLabel, StatusLabel, Status global Preset1, Preset2, Preset3, Preset4 # appWindow = ac.newApp("BoxRadio") ac.setSize(appWindow, 180 * UiSize, 220 * UiSize) ac.setTitle(appWindow, "BoxRadio") ac.setBackgroundOpacity(appWindow, 0.5) ac.drawBorder(appWindow, 0) # FuelSelection = ac.addSpinner(appWindow, "") ac.setPosition(FuelSelection, 10 * UiSize, 99 * UiSize) ac.setSize(FuelSelection, 80 * UiSize, 18 * UiSize) ac.setFontColor(FuelSelection, 1, 1, 1, 1) ac.setFontSize(FuelSelection, 12 * UiSize) ac.setRange(FuelSelection, 0, int(FuelMax)) ac.setStep(FuelSelection, 1) ac.addOnValueChangeListener(FuelSelection, FuelEvent) # if FuelOption == True: FuelLabel = ac.addLabel(appWindow, "Fuel Add") ac.setPosition(FuelLabel, 10 * UiSize, 80 * UiSize) ac.setFontColor(FuelLabel, 1, 1, 1, 1) ac.setFontSize(FuelLabel, 13 * UiSize) else: FuelLabel = ac.addLabel(appWindow, "Fuel Total") ac.setPosition(FuelLabel, 10 * UiSize, 80 * UiSize) ac.setFontColor(FuelLabel, 1, 1, 1, 1) ac.setFontSize(FuelLabel, 13 * UiSize) # Fill = ac.addButton(appWindow, "") ac.setBackgroundOpacity(Fill, 0) ac.drawBorder(Fill, 0) ac.setSize(Fill, 20 * UiSize, 20 * UiSize) ac.setPosition(Fill, 95 * UiSize, 98 * UiSize) ac.setBackgroundTexture(Fill, "apps/python/BoxRadio/img/fuel_fill_OFF.png") ac.addOnClickedListener(Fill, FillEvent) # NoChange = ac.addButton(appWindow, "") ac.setBackgroundOpacity(NoChange, 0) ac.drawBorder(NoChange, 0) ac.setSize(NoChange, 25 * UiSize, 25 * UiSize) ac.setPosition(NoChange, 125 * UiSize, 27 * UiSize) ac.setBackgroundTexture(NoChange, "content/gui/pitstop/tyre_no_change_ON.png") ac.addOnClickedListener(NoChange, NoChangeEvent) # Nochangelabel = ac.addLabel(appWindow, "No") ac.setPosition(Nochangelabel, 153 * UiSize, 31 * UiSize) ac.setFontColor(Nochangelabel, 1, 1, 1, 1) ac.setFontSize(Nochangelabel, 12 * UiSize) # Option1 = ac.addButton(appWindow, "") ac.setBackgroundOpacity(Option1, 0) ac.drawBorder(Option1, 0) ac.setSize(Option1, 25 * UiSize, 25 * UiSize) ac.setPosition(Option1, 125 * UiSize, 52 * UiSize) ac.setBackgroundTexture(Option1, "content/gui/pitstop/tyre_1_OFF.png") ac.addOnClickedListener(Option1, Option1Event) if OptionLabel[1] == '': ac.setVisible(Option1, 0) # Option1label = ac.addLabel(appWindow, OptionLabel[1].upper()) ac.setPosition(Option1label, 153 * UiSize, 56 * UiSize) ac.setFontColor(Option1label, 1, 1, 1, 1) ac.setFontSize(Option1label, 13 * UiSize) # Option2 = ac.addButton(appWindow, "") ac.setBackgroundOpacity(Option2, 0) ac.drawBorder(Option2, 0) ac.setSize(Option2, 25 * UiSize, 25 * UiSize) ac.setPosition(Option2, 125 * UiSize, 77 * UiSize) ac.setBackgroundTexture(Option2, "content/gui/pitstop/tyre_2_OFF.png") ac.addOnClickedListener(Option2, Option2Event) if OptionLabel[2] == '': ac.setVisible(Option2, 0) # Option2label = ac.addLabel(appWindow, OptionLabel[2].upper()) ac.setPosition(Option2label, 153 * UiSize, 81 * UiSize) ac.setFontColor(Option2label, 1, 1, 1, 1) ac.setFontSize(Option2label, 13 * UiSize) # Option3 = ac.addButton(appWindow, "") ac.setBackgroundOpacity(Option3, 0) ac.drawBorder(Option3, 0) ac.setSize(Option3, 25 * UiSize, 25 * UiSize) ac.setPosition(Option3, 125 * UiSize, 102 * UiSize) ac.setBackgroundTexture(Option3, "content/gui/pitstop/tyre_3_OFF.png") ac.addOnClickedListener(Option3, Option3Event) if OptionLabel[3] == '': ac.setVisible(Option3, 0) # Option3label = ac.addLabel(appWindow, OptionLabel[3].upper()) ac.setPosition(Option3label, 153 * UiSize, 106 * UiSize) ac.setFontColor(Option3label, 1, 1, 1, 1) ac.setFontSize(Option3label, 13 * UiSize) # Option4 = ac.addButton(appWindow, "") ac.setBackgroundOpacity(Option4, 0) ac.drawBorder(Option4, 0) ac.setSize(Option4, 25 * UiSize, 25 * UiSize) ac.setPosition(Option4, 125 * UiSize, 127 * UiSize) ac.setBackgroundTexture(Option4, "content/gui/pitstop/tyre_4_OFF.png") ac.addOnClickedListener(Option4, Option4Event) if OptionLabel[4] == '': ac.setVisible(Option4, 0) # Option4label = ac.addLabel(appWindow, OptionLabel[4].upper()) ac.setPosition(Option4label, 153 * UiSize, 131 * UiSize) ac.setFontColor(Option4label, 1, 1, 1, 1) ac.setFontSize(Option4label, 13 * UiSize) # Option5 = ac.addButton(appWindow, "") ac.setBackgroundOpacity(Option5, 0) ac.drawBorder(Option5, 0) ac.setSize(Option5, 25 * UiSize, 25 * UiSize) ac.setPosition(Option5, 125 * UiSize, 152 * UiSize) ac.setBackgroundTexture(Option5, "content/gui/pitstop/tyre_5_OFF.png") ac.addOnClickedListener(Option5, Option5Event) if OptionLabel[5] == '': ac.setVisible(Option5, 0) # Option5label = ac.addLabel(appWindow, OptionLabel[5].upper()) ac.setPosition(Option5label, 153 * UiSize, 156 * UiSize) ac.setFontColor(Option5label, 1, 1, 1, 1) ac.setFontSize(Option5label, 13 * UiSize) # Suspension = ac.addButton(appWindow, "") ac.setBackgroundOpacity(Suspension, 0) ac.drawBorder(Suspension, 0) ac.setSize(Suspension, 30 * UiSize, 30 * UiSize) ac.setPosition(Suspension, 10 * UiSize, 136 * UiSize) ac.setBackgroundTexture(Suspension, "content/gui/pitstop/repair_sus_OFF.png") ac.addOnClickedListener(Suspension, SuspensionEvent) # Body = ac.addButton(appWindow, "") ac.setBackgroundOpacity(Body, 0) ac.drawBorder(Body, 0) ac.setSize(Body, 30 * UiSize, 30 * UiSize) ac.setPosition(Body, 48 * UiSize, 136 * UiSize) ac.setBackgroundTexture(Body, "content/gui/pitstop/repair_body_OFF.png") ac.addOnClickedListener(Body, BodyEvent) # Engine = ac.addButton(appWindow, "") ac.setBackgroundOpacity(Engine, 0) ac.drawBorder(Engine, 0) ac.setSize(Engine, 30 * UiSize, 30 * UiSize) ac.setPosition(Engine, 85 * UiSize, 136 * UiSize) ac.setBackgroundTexture(Engine, "content/gui/pitstop/repair_engine_OFF.png") ac.addOnClickedListener(Engine, EngineEvent) # Preset1 = ac.addCheckBox(appWindow, "") ac.setPosition(Preset1, 10 * UiSize, 50 * UiSize) ac.setSize(Preset1, 20 * UiSize, 20 * UiSize) ac.drawBorder(Preset1, 1) ac.addOnCheckBoxChanged(Preset1, Preset1Event) # Preset2 = ac.addCheckBox(appWindow, "") ac.setPosition(Preset2, 37 * UiSize, 50 * UiSize) ac.setSize(Preset2, 20 * UiSize, 20 * UiSize) ac.drawBorder(Preset2, 1) ac.addOnCheckBoxChanged(Preset2, Preset2Event) # Preset3 = ac.addCheckBox(appWindow, "") ac.setPosition(Preset3, 65 * UiSize, 50 * UiSize) ac.setSize(Preset3, 20 * UiSize, 20 * UiSize) ac.drawBorder(Preset3, 1) ac.addOnCheckBoxChanged(Preset3, Preset3Event) # Preset4 = ac.addCheckBox(appWindow, "") ac.setPosition(Preset4, 93 * UiSize, 50 * UiSize) ac.setSize(Preset4, 20 * UiSize, 20 * UiSize) ac.drawBorder(Preset4, 1) ac.addOnCheckBoxChanged(Preset4, Preset4Event) # PresetLabel = ac.addLabel(appWindow, "Preset") ac.setPosition(PresetLabel, 10 * UiSize, 30 * UiSize) ac.setFontColor(PresetLabel, 1, 1, 1, 1) ac.setFontSize(PresetLabel, 13 * UiSize) # Preset1Label = ac.addLabel(appWindow, "1") ac.setPosition(Preset1Label, 16 * UiSize, 50 * UiSize) ac.setFontColor(Preset1Label, 0, 0, 0, 1) ac.setFontSize(Preset1Label, 15 * UiSize) # Preset2Label = ac.addLabel(appWindow, "2") ac.setPosition(Preset2Label, 43 * UiSize, 50 * UiSize) ac.setFontColor(Preset2Label, 0, 0, 0, 1) ac.setFontSize(Preset2Label, 15 * UiSize) # Preset3Label = ac.addLabel(appWindow, "3") ac.setPosition(Preset3Label, 71 * UiSize, 50 * UiSize) ac.setFontColor(Preset3Label, 0, 0, 0, 1) ac.setFontSize(Preset3Label, 15 * UiSize) # Preset4Label = ac.addLabel(appWindow, "4") ac.setPosition(Preset4Label, 99 * UiSize, 50 * UiSize) ac.setFontColor(Preset4Label, 0, 0, 0, 1) ac.setFontSize(Preset4Label, 15 * UiSize) # StatusLabel = ac.addLabel(appWindow, Status) ac.setPosition(StatusLabel, 10 * UiSize, 175 * UiSize) ac.setFontColor(StatusLabel, 1, 1, 1, 1) ac.setFontSize(StatusLabel, 10 * UiSize) # NotificationLabel = ac.addLabel(appWindow, Notify) ac.setPosition(NotificationLabel, 10 * UiSize, 195 * UiSize) ac.setFontColor(NotificationLabel, 1, 1, 1, 1) ac.setFontSize(NotificationLabel, 9 * UiSize) # return "BoxRadio"
def __init__(self, app, x, y): x_pressure = x x_dirt = x_pressure x_maxt = x + 80 x_maxp = x_maxt y_pressure = y + 20 y_dirt = y_pressure + 20 y_maxt = y + 8 y_maxp = y_maxt + 20 self.maxtFL = 0 self.maxtFR = 0 self.maxtRL = 0 self.maxtRR = 0 self.maxpFL = 0 self.maxpFR = 0 self.maxpRL = 0 self.maxpRR = 0 self.unitChar = "C" if inFahrenheit: self.unitChar = "F" ##initialize labels self.tFLValue = ac.addLabel(app, "temp fl") self.tFRValue = ac.addLabel(app, "temp fr") self.tRLValue = ac.addLabel(app, "temp rl") self.tRRValue = ac.addLabel(app, "temp rr") self.pFLValue = ac.addLabel(app, "psi fl") self.pFRValue = ac.addLabel(app, "psi fr") self.pRLValue = ac.addLabel(app, "psi rl") self.pRRValue = ac.addLabel(app, "psi rr") self.dFLValue = ac.addLabel(app, "dirt fl") self.dFRValue = ac.addLabel(app, "dirt fr") self.dRLValue = ac.addLabel(app, "dirt rl") self.dRRValue = ac.addLabel(app, "dirt rr") self.maxFont = ac.addLabel(app, "Max") self.maxtFont = ac.addLabel(app, self.unitChar) self.maxpFont = ac.addLabel(app, "psi") self.maxtFontBottom = ac.addLabel(app, self.unitChar) self.maxpFontBottom = ac.addLabel(app, "psi") self.maxtFLValue = ac.addLabel(app, "maxtemp fl") self.maxtFRValue = ac.addLabel(app, "maxtemp fr") self.maxtRLValue = ac.addLabel(app, "maxtemp rl") self.maxtRRValue = ac.addLabel(app, "maxtemp rr") self.maxpFLValue = ac.addLabel(app, "maxpress fl") self.maxpFRValue = ac.addLabel(app, "maxpress fr") self.maxpRLValue = ac.addLabel(app, "maxpress rl") self.maxpRRValue = ac.addLabel(app, "maxpress rr") ##set label positions ac.setPosition(self.tFLValue, x - 152, y) ac.setPosition(self.tFRValue, x + x_space, y) ac.setPosition(self.tRLValue, x - 152, y + y_space) ac.setPosition(self.tRRValue, x + x_space, y + y_space) ac.setPosition(self.pFLValue, x_pressure - 152, y_pressure) ac.setPosition(self.pFRValue, x_pressure + x_space, y_pressure) ac.setPosition(self.pRLValue, x_pressure - 152, y_pressure + y_space) ac.setPosition(self.pRRValue, x_pressure + x_space, y_pressure + y_space) ac.setPosition(self.dFLValue, x_dirt - 152, y_dirt) ac.setPosition(self.dFRValue, x_dirt + x_space, y_dirt) ac.setPosition(self.dRLValue, x_dirt - 152, y_dirt + y_space) ac.setPosition(self.dRRValue, x_dirt + x_space, y_dirt + y_space) ac.setPosition(self.maxFont, 137, 28) ac.setPosition(self.maxtFont, 145, 48) ac.setPosition(self.maxpFont, 140, 68) ac.setPosition(self.maxtFontBottom, 145, 123) ac.setPosition(self.maxpFontBottom, 140, 143) ac.setPosition(self.maxtFLValue, x_maxt, y_maxt) ac.setPosition(self.maxtFRValue, x_maxt - 96, y_maxt) ac.setPosition(self.maxtRLValue, x_maxt, y_maxt + y_space) ac.setPosition(self.maxtRRValue, x_maxt - 96, y_maxt + y_space) ac.setPosition(self.maxpFLValue, x_maxp, y_maxp) ac.setPosition(self.maxpFRValue, x_maxp - 96, y_maxp) ac.setPosition(self.maxpRLValue, x_maxp, y_maxp + y_space) ac.setPosition(self.maxpRRValue, x_maxp - 96, y_maxp + y_space) ##set label alignments ac.setFontAlignment(self.tFLValue, "right") ac.setFontAlignment(self.tRLValue, "right") ac.setFontAlignment(self.pFLValue, "right") ac.setFontAlignment(self.pRLValue, "right") ac.setFontAlignment(self.dFLValue, "right") ac.setFontAlignment(self.dRLValue, "right") ac.setFontAlignment(self.maxtFLValue, "left") ac.setFontAlignment(self.maxtFRValue, "right") ac.setFontAlignment(self.maxtRLValue, "left") ac.setFontAlignment(self.maxtRRValue, "right") ac.setFontAlignment(self.maxpFLValue, "left") ac.setFontAlignment(self.maxpFRValue, "right") ac.setFontAlignment(self.maxpRLValue, "left") ac.setFontAlignment(self.maxpRRValue, "right") ##set font size ac.setFontSize(self.maxFont, 12) ac.setFontSize(self.maxtFont, 12) ac.setFontSize(self.maxpFont, 12) ac.setFontSize(self.maxtFontBottom, 12) ac.setFontSize(self.maxpFontBottom, 12) ac.setFontSize(self.maxtFLValue, 12) ac.setFontSize(self.maxtFRValue, 12) ac.setFontSize(self.maxtRLValue, 12) ac.setFontSize(self.maxtRRValue, 12) ac.setFontSize(self.maxpFLValue, 12) ac.setFontSize(self.maxpFRValue, 12) ac.setFontSize(self.maxpRLValue, 12) ac.setFontSize(self.maxpRRValue, 12)
def acUpdate(deltaT): global window_width, have_setup, indicated_max_rpm, max_rpm, indicated_max_speed global rpm_pivot_x, rpm_pivot_y, speed_pivot_x, speed_pivot_y, tach_radius, speedo_radius, max_fuel global fuel_warning_label, dt_ratio global draw_boost_gauge global rpms_file ac.setBackgroundOpacity(window,0) if have_setup: telemetry_client.tick() if debug_mode: ac.setText(debug_label,"%2.2f" % (ac.getCarState(0,acsys.CS.DriveTrainSpeed)/ac.getCarState(0,acsys.CS.SpeedKMH))) if have_setup == 0: max_rpm = sim_info.static.maxRpm ac.console("Maximum RPM for car %s: %d" %(ac.getCarName(0),max_rpm)) if max_rpm < 500: if rpms_file.has_section(ac.getCarName(0)): max_rpm = int(rpms_file[ac.getCarName(0)]['max_rpm']) else: ac.console("Don't know max RPMs for this car, go play with it in practice mode first!") max_rpm = 20000 else: if not rpms_file.has_section(ac.getCarName(0)): rpms_file.add_section(ac.getCarName(0)) rpms_file[ac.getCarName(0)]['max_rpm'] = str(max_rpm) with open('apps/python/AnalogInstruments/rpms.ini','w') as file: rpms_file.write(file) ac.console("Learned max RPM for this car") telemetry_client.connect() ac.log("Opening car info file") carinfo_file = configparser.ConfigParser() carinfo_file.read("apps/python/AnalogInstruments/carinfo.ini") ac.log("Got car info file") if carinfo_file.has_section(ac.getCarName(0)): ac.log("Found car in file") dt_ratio = float(carinfo_file[ac.getCarName(0)]['ratio']) ac.log("Got ratio") indicated_max_speed = int(carinfo_file[ac.getCarName(0)]['top_speed']) ac.log("Got top speed") has_turbo = carinfo_file[ac.getCarName(0)].getboolean('has_turbo') ac.log("Got turbo") else: ac.console("Car %s isn't in carinfo.ini!" % ac.getCarName(0)) dt_ratio = 1 indicated_max_speed = 320 has_turbo = True if (not has_turbo or not draw_boost_gauge) and draw_background: ac.setBackgroundTexture(window,background_image_path_noboost) draw_boost_gauge = False # Max fuel ac.log("Getting things from SHM") max_fuel = sim_info.static.maxFuel car_model = sim_info.static.carModel compound = str(sim_info.graphics.tyreCompound)#FIXME ac.log("Got things from SHM") # Optimal tyre temp range as taken from that forum post if "exos_125_s1" in car_model: if "SuperSoft" in compound: tyre_optimal_temp = range(85,111) elif "Soft" in compound: tyre_optimal_temp = range(105,126) elif "Medium" in compound: tyre_optimal_temp = range(90,116) elif "Hard" in compound: tyre_optimal_temp = range(110,136) elif "exos_125" in car_model: tyre_optimal_temp = range(90,121) elif "Semislick" in compound: tyre_optimal_temp = range(75,101) elif "Street" in compound: tyre_optimal_temp = range(75,86) elif "_gt2" in car_model: if "SuperSoft" in compound: tyre_optimal_temp = range(90,106) elif "Soft" in compound: tyre_optimal_temp = range(90,106) elif "Medium" in compound: tyre_optimal_temp = range(85,106) elif "Hard" in compound: tyre_optimal_temp = range(80,101) elif "SuperHard" in compound: tyre_optimal_temp = range(80,101) elif "70F1" in compound: tyre_optimal_temp = range(50,91) elif "Soft" in compound: tyre_optimal_temp = range(80,111) elif "Medium" in compound: tyre_optimal_temp = range(75,106) elif "Hard" in compound: tyre_optimal_temp = range(70,101) ac.log("Setting up tach") if draw_tachometer: # Tach setup indicated_max_rpm = max_rpm + 1000 - (max_rpm % 1000) # Tach labels for i in range(0,indicated_max_rpm+1,1000): r = abs(tach_min_angle - tach_max_angle) rad = math.radians(tach_max_angle - (i/indicated_max_rpm)*r) label = ac.addLabel(window," ") ac.setText(label,"%d" % (i/1000)) x_offset = 0 y_offset = 0 if rad < math.pi/2: x_offset = 15 - math.sin(rad)*15 y_offset = math.cos(rad)*5 ac.setPosition(label,math.cos(rad)*(tach_radius*4/5)+rpm_pivot_x-x_offset,rpm_pivot_y - math.sin(rad)*(tach_radius*4/5)-y_offset) ac.log("Setting up speedo") if draw_speedometer: # Speedo setup if imperial: indicated_max_speed = int(indicated_max_speed/1.6) #TODO: round up to multiple of 20 # Speedo labels for i in range(0,indicated_max_speed+1,20): r = abs(speedo_min_angle - speedo_max_angle) rad = math.radians(speedo_max_angle - (i/indicated_max_speed)*r) label = ac.addLabel(window," ") ac.setText(label,"%d" % i) x_offset = 0 y_offset = 0 if rad < math.pi/2: x_offset = 23 - math.sin(rad)*23 y_offset = math.cos(rad)*5 ac.setPosition(label,math.cos(rad)*speedo_radius*4/5+speed_pivot_x-x_offset,speed_pivot_y - math.sin(rad)*speedo_radius*4/5-y_offset) have_setup = 1
def window(self, value): self._window = value self.id = ac.addLabel(self._window, '') self._draw()
def initErrorLabel(widgetWidth): self.errorLabel = ac.addLabel(self.window,"") ac.setPosition(self.errorLabel, widgetWidth, 0) # print errors aside from the widget
def initInfoLabel(): self.infoLabel = ac.addLabel(self.window,"") ac.setPosition(self.infoLabel, 5, 25) # skip the customary top-left icon of the widget
def acMain(ac_version): global appWindow,FuelSelection,label1,label2,label3,NoChange,SuperSoft global SoftSlick,MediumSlick,HardSlick,SuperHard,Body,Engine,Suspension global DoOnce,ahk,response if DoOnce == 0: ahk = subprocess.Popen(["apps\python\PitVoice\Pitvoice.exe"]) DoOnce = 1 # appWindow = ac.newApp("PitVoice") ac.setSize(appWindow,350,250) ac.setTitle(appWindow,"") ac.setBackgroundOpacity(appWindow,0.5) ac.setBackgroundTexture(appWindow,"apps/python/PitVoice/PitMenu.png") # FuelSelection = ac.addSpinner(appWindow,"")#Fuel ac.setPosition(FuelSelection,87,110) ac.setSize(FuelSelection,175,25) ac.setFontColor(FuelSelection,1,1,0,1) ac.setFontSize(FuelSelection, 15) ac.setRange(FuelSelection,0,190) ac.setStep(FuelSelection,1) ac.addOnValueChangeListener(FuelSelection,FuelEvent) # NoChange = ac.addCheckBox(appWindow,"") ac.setPosition(NoChange,22,86) ac.setSize(NoChange,15,15) ac.addOnCheckBoxChanged(NoChange,NoChangeEvent) # SuperSoft = ac.addCheckBox(appWindow,"") ac.setPosition(SuperSoft,82,86) ac.setSize(SuperSoft,15,15) ac.addOnCheckBoxChanged(SuperSoft,SuperSoftEvent) # SoftSlick = ac.addCheckBox(appWindow,"") ac.setPosition(SoftSlick,138,86) ac.setSize(SoftSlick,15,15) ac.addOnCheckBoxChanged(SoftSlick,SoftSlickEvent) # MediumSlick = ac.addCheckBox(appWindow,"") ac.setPosition(MediumSlick,197,86) ac.setSize(MediumSlick,15,15) ac.addOnCheckBoxChanged(MediumSlick,MediumSlickEvent) # HardSlick = ac.addCheckBox(appWindow,"") ac.setPosition(HardSlick,255,86) ac.setSize(HardSlick,15,15) ac.addOnCheckBoxChanged(HardSlick,HardSlickEvent) # SuperHard = ac.addCheckBox(appWindow,"") ac.setPosition(SuperHard,313,86) ac.setSize(SuperHard,15,15) ac.addOnCheckBoxChanged(SuperHard,SuperHardEvent) # Body = ac.addCheckBox(appWindow,"") ac.setPosition(Body,59,229) ac.setSize(Body,15,15) ac.addOnCheckBoxChanged(Body,BodyEvent) # Engine = ac.addCheckBox(appWindow,"") ac.setPosition(Engine,169,229) ac.setSize(Engine,15,15) ac.addOnCheckBoxChanged(Engine,EngineEvent) # Suspension = ac.addCheckBox(appWindow,"") ac.setPosition(Suspension,276,229) ac.setSize(Suspension,15,15) ac.addOnCheckBoxChanged(Suspension,SuspensionEvent) # label1=ac.addLabel(appWindow,"Fuel +") ac.setPosition(label1,275,113) ac.setFontColor(label1,1,1,0,1) ac.setFontSize(label1, 15) # label2=ac.addLabel(appWindow,"Fuel -") ac.setPosition(label2,30,113) ac.setFontColor(label2,1,1,0,1) ac.setFontSize(label2, 15) # label3=ac.addLabel(appWindow,"0") ac.setPosition(label3,166,110) ac.setFontColor(label3,1,1,0,0) ac.setFontSize(label3, 15) # ResponseWit() return "PitVoice"
def __init__(self, name, headerName, fontSize, showHeader): self.headerName = headerName self.window = ac.newApp(name) if showHeader == 1: ac.setTitle(self.window, "") ac.setIconPosition(self.window, -10000, -10000) self.firstSpacing = 0 else: ac.setTitle(self.window, headerName) self.firstSpacing = firstSpacing self.fontSize = fontSize widthLeft = fontSize*8 widthCenter = fontSize*5 widthRight = fontSize*5 self.width = widthLeft + widthCenter + widthRight + 2*spacing height = self.firstSpacing + (fontSize*1.5 + spacing)*20 ac.setSize(self.window, self.width, height) self.leftLabel = [] self.centerLabel = [] self.changeButton = [] self.plusButton = [] self.minusButton = [] for index in range(20): self.leftLabel.append(ac.addLabel(self.window, "")) ac.setFontSize(self.leftLabel[index], fontSize) ac.setPosition(self.leftLabel[index], spacing, self.firstSpacing + index*(fontSize*1.5+spacing)) ac.setSize(self.leftLabel[index], widthLeft, fontSize+spacing) ac.setFontAlignment(self.leftLabel[index], 'left') self.centerLabel.append(ac.addLabel(self.window, "")) ac.setFontSize(self.centerLabel[index], fontSize) ac.setPosition(self.centerLabel[index], spacing + widthLeft, self.firstSpacing + index*(fontSize*1.5+spacing)) ac.setSize(self.centerLabel[index], widthCenter, fontSize+spacing) ac.setFontAlignment(self.centerLabel[index], 'left') self.changeButton.append(ac.addButton(self.window, "Change")) ac.setFontSize(self.changeButton[index], self.fontSize) ac.setPosition(self.changeButton[index], spacing + widthLeft + widthCenter, self.firstSpacing + index*(fontSize*1.5+spacing)) ac.setSize(self.changeButton[index], fontSize*4, fontSize*1.5) self.plusButton.append(ac.addButton(self.window, "+")) ac.setFontSize(self.plusButton[index], self.fontSize) ac.setPosition(self.plusButton[index], spacing + widthLeft + widthCenter, self.firstSpacing + index*(fontSize*1.5+spacing)) ac.setSize(self.plusButton[index], fontSize*1.5, fontSize*1.5) self.minusButton.append(ac.addButton(self.window, "-")) ac.setFontSize(self.minusButton[index], self.fontSize) ac.setPosition(self.minusButton[index], spacing + widthLeft + widthCenter + fontSize*2.5, self.firstSpacing + index*(fontSize*1.5+spacing)) ac.setSize(self.minusButton[index], fontSize*1.5, fontSize*1.5) rowIndex = 0 ac.setText(self.leftLabel[rowIndex], "Show header:") ac.addOnClickedListener(self.changeButton[rowIndex], toggleHeader) ac.setVisible(self.plusButton[rowIndex], 0) ac.setVisible(self.minusButton[rowIndex], 0) self.showHeaderId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Font size:") ac.setVisible(self.changeButton[rowIndex], 0) ac.addOnClickedListener(self.plusButton[rowIndex], fontSizePlus) ac.addOnClickedListener(self.minusButton[rowIndex], fontSizeMinus) self.fontSizeId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Opacity:") ac.setVisible(self.changeButton[rowIndex], 0) ac.addOnClickedListener(self.plusButton[rowIndex], opacityPlus) ac.addOnClickedListener(self.minusButton[rowIndex], opacityMinus) self.opacityId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Show border:") ac.addOnClickedListener(self.changeButton[rowIndex], toggleBorder) ac.setVisible(self.plusButton[rowIndex], 0) ac.setVisible(self.minusButton[rowIndex], 0) self.showBorderId = rowIndex rowIndex += 1 ac.setVisible(self.changeButton[rowIndex], 0) ac.setVisible(self.plusButton[rowIndex], 0) ac.setVisible(self.minusButton[rowIndex], 0) rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Lap count:") ac.setVisible(self.changeButton[rowIndex], 0) ac.addOnClickedListener(self.plusButton[rowIndex], lapCountPlus) ac.addOnClickedListener(self.minusButton[rowIndex], lapCountMinus) self.lapCountId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Show delta:") ac.addOnClickedListener(self.changeButton[rowIndex], toggleDelta) ac.setVisible(self.plusButton[rowIndex], 0) ac.setVisible(self.minusButton[rowIndex], 0) self.showDeltaId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Delta color:") ac.addOnClickedListener(self.changeButton[rowIndex], toggleColor) ac.setVisible(self.plusButton[rowIndex], 0) ac.setVisible(self.minusButton[rowIndex], 0) self.deltaColorId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Red at:") ac.setVisible(self.changeButton[rowIndex], 0) ac.addOnClickedListener(self.plusButton[rowIndex], redAtPlus) ac.addOnClickedListener(self.minusButton[rowIndex], redAtMinus) self.redAtId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Green at:") ac.setVisible(self.changeButton[rowIndex], 0) ac.addOnClickedListener(self.plusButton[rowIndex], greenAtPlus) ac.addOnClickedListener(self.minusButton[rowIndex], greenAtMinus) self.greenAtId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Show curr.:") ac.addOnClickedListener(self.changeButton[rowIndex], toggleCurrent) ac.setVisible(self.plusButton[rowIndex], 0) ac.setVisible(self.minusButton[rowIndex], 0) self.showCurrentId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Reference:") ac.addOnClickedListener(self.changeButton[rowIndex], toggleRefSource) ac.setVisible(self.plusButton[rowIndex], 0) ac.setVisible(self.minusButton[rowIndex], 0) self.referenceId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Show ref.:") ac.addOnClickedListener(self.changeButton[rowIndex], toggleRef) ac.setVisible(self.plusButton[rowIndex], 0) ac.setVisible(self.minusButton[rowIndex], 0) self.showReferenceId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Show total:") ac.addOnClickedListener(self.changeButton[rowIndex], toggleTotal) ac.setVisible(self.plusButton[rowIndex], 0) ac.setVisible(self.minusButton[rowIndex], 0) self.showTotalId = rowIndex rowIndex += 1 ac.setVisible(self.changeButton[rowIndex], 0) ac.setVisible(self.plusButton[rowIndex], 0) ac.setVisible(self.minusButton[rowIndex], 0) rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Refresh every:") ac.setVisible(self.changeButton[rowIndex], 0) ac.addOnClickedListener(self.plusButton[rowIndex], refreshPlus) ac.addOnClickedListener(self.minusButton[rowIndex], refreshMinus) self.refreshId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Log sessions:") ac.addOnClickedListener(self.changeButton[rowIndex], toggleLogLaps) ac.setVisible(self.plusButton[rowIndex], 0) ac.setVisible(self.minusButton[rowIndex], 0) self.logLapsId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Remember best:") ac.addOnClickedListener(self.changeButton[rowIndex], toggleLogBest) ac.setVisible(self.plusButton[rowIndex], 0) ac.setVisible(self.minusButton[rowIndex], 0) self.logBestId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Best lap:") ac.addOnClickedListener(self.changeButton[rowIndex], resetBestLap) ac.setText(self.changeButton[rowIndex], "Reset") ac.setVisible(self.plusButton[rowIndex], 0) ac.setVisible(self.minusButton[rowIndex], 0) self.resetBestLapId = rowIndex rowIndex += 1 ac.setText(self.leftLabel[rowIndex], "Lock best:") ac.addOnClickedListener(self.changeButton[rowIndex], toggleLockBest) ac.setVisible(self.plusButton[rowIndex], 0) ac.setVisible(self.minusButton[rowIndex], 0) self.lockBestId = rowIndex
def acMain(ac_version): global appWindow global sound_player, SoundPackSpinner, VolumeSpinner global Beforerace, Overtake, Suspense, Win, Lose, labeldesc, Hotlap global StatusLabel, NotificationLabel, audio, audiolist, BeforeraceLabel, OvertakeLabel, SuspenseLabel global WinLabel, LoseLabel, audiolabel, position, debuglabel # DEBUG INFO global enable_overtake, enable_lose, enable_win, enable_hotlap global enable_before_race, enable_suspense, suspense_laps, log global audio, overtake, position, newposition, start_time, finish_time, count_overtake global session, sessionTime, numberOfLaps, completedLaps appWindow = ac.newApp("Epic Race") ac.setSize(appWindow, 430, 350) ac.setTitle(appWindow, "Epic Race") ac.setBackgroundOpacity(appWindow, 0.5) ac.drawBorder(appWindow, 0) # SoundPackSpinner = ac.addSpinner(appWindow, "") ac.setFontColor(SoundPackSpinner, 1, 1, 1, 1) ac.setFontSize(SoundPackSpinner, 12) spinner_config(SoundPackSpinner, 10, 55, 80, 18, 0, 1, 10, 0, onSoundPackChanged) # VolumeSpinner = ac.addSpinner(appWindow, "") ac.setFontColor(VolumeSpinner, 1, 1, 1, 1) ac.setFontSize(VolumeSpinner, 12) spinner_config(VolumeSpinner, 10, 105, 80, 18, 0, 1, 100, audio_volume, onVolumeChanged) # audiolabel = ac.addLabel(appWindow, "") ac.setPosition(audiolabel, 10, 30) ac.setFontColor(audiolabel, 1, 1, 1, 1) ac.setFontSize(audiolabel, 15) # volumelabel = ac.addLabel(appWindow, "Volume") ac.setPosition(volumelabel, 10, 80) ac.setFontColor(volumelabel, 1, 1, 1, 1) ac.setFontSize(volumelabel, 15) Beforerace = ac.addCheckBox(appWindow, "") ac.setValue(Beforerace, enable_before_race) ac.setPosition(Beforerace, 10, 130) ac.setSize(Beforerace, 20, 20) ac.drawBorder(Beforerace, 1) ac.addOnCheckBoxChanged(Beforerace, onEnableBeforeRace) # Overtake = ac.addCheckBox(appWindow, "") ac.setValue(Overtake, enable_overtake) ac.setPosition(Overtake, 10, 160) ac.setSize(Overtake, 20, 20) ac.drawBorder(Overtake, 1) ac.addOnCheckBoxChanged(Overtake, onEnableOverTake) # Suspense = ac.addCheckBox(appWindow, "") ac.setValue(Suspense, enable_suspense) ac.setPosition(Suspense, 10, 190) ac.setSize(Suspense, 20, 20) ac.drawBorder(Suspense, 1) ac.addOnCheckBoxChanged(Suspense, onEnableSuspense) # Win = ac.addCheckBox(appWindow, "") ac.setValue(Win, enable_win) ac.setPosition(Win, 10, 220) ac.setSize(Win, 20, 20) ac.drawBorder(Win, 1) ac.addOnCheckBoxChanged(Win, onEnableWin) # Lose = ac.addCheckBox(appWindow, "") ac.setValue(Lose, enable_lose) ac.setPosition(Lose, 10, 250) ac.setSize(Lose, 20, 20) ac.drawBorder(Lose, 1) ac.addOnCheckBoxChanged(Lose, onEnableLose) # Hotlap = ac.addCheckBox(appWindow, "") ac.setValue(Hotlap, enable_hotlap) ac.setPosition(Hotlap, 10, 280) ac.setSize(Hotlap, 20, 20) ac.drawBorder(Hotlap, 1) ac.addOnCheckBoxChanged(Hotlap, onEnableHotlap) # BeforeraceLabel = ac.addLabel(appWindow, "Enable before race") ac.setPosition(BeforeraceLabel, 40, 130) ac.setFontColor(BeforeraceLabel, 1, 1, 1, 1) ac.setFontSize(BeforeraceLabel, 15) # OvertakeLabel = ac.addLabel(appWindow, "Enable overtake") ac.setPosition(OvertakeLabel, 40, 160) ac.setFontColor(OvertakeLabel, 1, 1, 1, 1) ac.setFontSize(OvertakeLabel, 15) # SuspenseLabel = ac.addLabel(appWindow, "Enable suspense") ac.setPosition(SuspenseLabel, 40, 190) ac.setFontColor(SuspenseLabel, 1, 1, 1, 1) ac.setFontSize(SuspenseLabel, 15) # WinLabel = ac.addLabel(appWindow, "Enable win") ac.setPosition(WinLabel, 40, 220) ac.setFontColor(WinLabel, 1, 1, 1, 1) ac.setFontSize(WinLabel, 15) # LoseLabel = ac.addLabel(appWindow, "Enable lose") ac.setPosition(LoseLabel, 40, 250) ac.setFontColor(LoseLabel, 1, 1, 1, 1) ac.setFontSize(LoseLabel, 15) # HotlapLabel = ac.addLabel(appWindow, "Enable hotlap") ac.setPosition(HotlapLabel, 40, 280) ac.setFontColor(HotlapLabel, 1, 1, 1, 1) ac.setFontSize(HotlapLabel, 15) # labeldesc = ac.addLabel(appWindow, "Something is broken") ac.setPosition(labeldesc, 180, 40) ac.setSize(labeldesc, 200, 200) # StatusLabel = ac.addLabel(appWindow, Status) ac.setPosition(StatusLabel, 10, 305) ac.setFontColor(StatusLabel, 1, 1, 1, 1) ac.setFontSize(StatusLabel, 15) # NotificationLabel = ac.addLabel(appWindow, Notify) ac.setPosition(NotificationLabel, 10, 325) ac.setFontColor(NotificationLabel, 1, 1, 1, 1) ac.setFontSize(NotificationLabel, 12) ac.setSize(NotificationLabel, 24, 310) # # DEBUG INFO # debuglabel = ac.addLabel(appWindow, "") ac.setPosition(debuglabel, 215, 30) ac.setSize(debuglabel, 200, 200) # # # box.FModSystem.init() sound_player = box.SoundPlayer(box.FModSystem) sound_player.set_volume(audio_volume / 100) sound_player.set_gain(2.0) audiolist = os.listdir(os.path.join(os.path.dirname(__file__), "SoundPacks")) ac.setRange(SoundPackSpinner, 0, len(audiolist) - 1) ac.setStep(SoundPackSpinner, 1) ac.setValue(SoundPackSpinner, audiolist.index(audio)) getNotification() if AutoUpdate: CheckNewUpdate() position = ac.getCarRealTimeLeaderboardPosition(0) return "EpicRace"
def setupUI(appWindow): global statusLabel statusLabel = ac.addLabel(appWindow, "Disconnected"); ac.setFontColor(statusLabel, 255, 0, 0, 0) ac.setPosition(statusLabel, 3, 30)
def __init__(self, window, text, xPos, yPos): self.label = ac.addLabel(window, text) ac.setPosition(self.label, xPos, yPos)
def _create_label(self, name, text, x, y): label = ac.addLabel(self.widget, name) ac.setText(label, text) ac.setPosition(label, x, y) self.labels[name] = label