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 __init__(self, appWindow): self.appWindow = appWindow self.uiElements = [] self.uiElements.append( UIElement("CyclistPower", appWindow, 225, 10, 96, 'W')) self.uiElements.append( UIElement("BikeSpeedKmh", appWindow, 115, 130, 48, 'km/h', ".1f")) self.uiElements.append( UIElement("BikeCadence", appWindow, 265, 130, 48, 'rpm')) self.uiElements.append( UIElement("BikeIncline", appWindow, 115, 200, 48, '%', ".1f")) self.uiElements.append( UIElement("CyclistHeartRate", appWindow, 265, 200, 48, 'bpm')) self.uiElements.append( UIElement("LapPosition", appWindow, 115, 270, 32, 'km', ".1f")) self.uiElements.append( UIElement("TrackLength", appWindow, 265, 270, 32, 'km (lap)', ".1f")) self.uiElements.append( TimerUIElement("TripTotalTime", appWindow, 166, 310, 32)) self.uiElements.append( UIElement("TripTotalKm", appWindow, 166, 350, 32, 'km (session)', ".1f")) self.btn1 = ac.addButton(self.appWindow, "start") self.btn2 = ac.addButton(self.appWindow, "stop")
def acMain(ac_version): global appWindow, label1, logPrefix, appName, splitsRenderer ac.console(logPrefix + "acMain") try: appWindow = ac.newApp(appName) ac.setTitle(appWindow, "") ac.setSize(appWindow, 300, 300) ac.drawBorder(appWindow, 0) ac.setBackgroundOpacity(appWindow, 0.3) resetBtn = ac.addButton(appWindow, "R") ac.setPosition(resetBtn, 5, 30) ac.setSize(resetBtn, 30, 30) ac.addOnClickedListener(resetBtn, onResetClicked) newSplitBtn = ac.addButton(appWindow, "N") ac.setPosition(newSplitBtn, 40, 30) ac.setSize(newSplitBtn, 30, 30) ac.addOnClickedListener(newSplitBtn, onNewSplitClicked) #label1 = ac.addLabel(appWindow, "____") #ac.setPosition(label1, 0, 70) splitsRenderer = SplitsRenderer(2, 62, 10, 10) ac.addRenderCallback(appWindow, onRender) ac.addOnAppActivatedListener(appWindow, onActivate) ac.addOnAppDismissedListener(appWindow, onDismiss) ac.console(logPrefix + "Initialized") except: printExceptionInfo("acMain") return appName
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 __init__(self): self.driversCount = ac.getCarsCount() appWindow = ac.newApp('ACTelemetry') ac.setSize(appWindow, 200, 87) self.driverLabel = ac.addLabel(appWindow, self.getDriverString()) ac.setPosition(self.driverLabel, 10, 35) nextButton = ac.addButton(appWindow, 'Next') ac.setPosition(nextButton, 5, 60) ac.setSize(nextButton, 92, 22) ac.addOnClickedListener(nextButton, clickNext) startButton = ac.addButton(appWindow, 'Start') ac.setPosition(startButton, 103, 60) ac.setSize(startButton, 92, 22) ac.addOnClickedListener(startButton, clickStart)
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 __init__(self, parent: ACWidget, text: str = '', h_alignment: str = 'left', font: Font = None, texture: str = ''): super().__init__(parent, text, h_alignment, font) self.id = ac.addButton(self.app, text) self.background_texture = texture
def _create_button(self, name, x, y, size_x, size_y, callback, border=0, opacity=0, texture=None): button = ac.addButton(self.widget, '') ac.setPosition(button, x, y) ac.setSize(button, size_x, size_y) ac.addOnClickedListener(button, callback) ac.drawBorder(button, border) ac.setBackgroundOpacity(button, opacity) if texture: texture = os.path.join(session.app_path, 'img', texture) ac.setBackgroundTexture(button, texture) self.buttons[name] = button
def __init__(self, app): global appWindow appWindow = app self.button = ac.addButton(appWindow, 'Start Countdown') self.btnEvent = functools.partial(self.onClick, msg='Countdown started') ac.setPosition(self.button, 1, 35) ac.setSize(self.button, 175, 25) ac.addOnClickedListener(self.button, self.btnEvent)
def acMain(ac_version): global app, rainStrengthValue, rainWiperSpeedValue app = ac.newApp("Shaders Patch Rain") ac.setTitle(app, "Rain") ac.setSize(app, 174, 108) y = 40 rainStrengthLabel = ac.addLabel(app, "Strength") ac.setPosition(rainStrengthLabel, 110, y) rainStrengthValue = ac.addLabel(app, "") ac.setPosition(rainStrengthValue, 48, y) rainStrengthDownButton = ac.addButton(app, "-") ac.setPosition(rainStrengthDownButton, 16, y) ac.setSize(rainStrengthDownButton, 24, 24) ac.setFontSize(rainStrengthDownButton, 14) ac.addOnClickedListener(rainStrengthDownButton, rainStrengthDown) rainStrengthUpButton = ac.addButton(app, "+") ac.setPosition(rainStrengthUpButton, 80, y) ac.setSize(rainStrengthUpButton, 24, 24) ac.setFontSize(rainStrengthUpButton, 14) ac.addOnClickedListener(rainStrengthUpButton, rainStrengthUp) y = 72 rainWiperSpeedLabel = ac.addLabel(app, "Wiper") ac.setPosition(rainWiperSpeedLabel, 110, y) rainWiperSpeedValue = ac.addLabel(app, "") ac.setPosition(rainWiperSpeedValue, 48, y) rainWiperSpeedDownButton = ac.addButton(app, "-") ac.setPosition(rainWiperSpeedDownButton, 16, y) ac.setSize(rainWiperSpeedDownButton, 24, 24) ac.setFontSize(rainWiperSpeedDownButton, 14) ac.addOnClickedListener(rainWiperSpeedDownButton, rainWiperSpeedDown) rainWiperSpeedUpButton = ac.addButton(app, "+") ac.setPosition(rainWiperSpeedUpButton, 80, y) ac.setSize(rainWiperSpeedUpButton, 24, 24) ac.setFontSize(rainWiperSpeedUpButton, 14) ac.addOnClickedListener(rainWiperSpeedUpButton, rainWiperSpeedUp) return "AccExtRain"
def __init__(self): self.messages = [] self.historySize = 10 self.unusedLabels = [] self.labels = [] self.delayedChat = None self.firstLayout = True self.appWindow = ac.newApp("In-race Chat") self.textInput = ac.addTextInput(self.appWindow, "TEXT_INPUT") ac.addOnValidateListener(self.textInput, globalValidateInput) self.shrinkButton = ac.addButton(self.appWindow, "-") self.expandButton = ac.addButton(self.appWindow, "+") ac.addOnClickedListener(self.shrinkButton, globalShrinkButtonClicked) ac.addOnClickedListener(self.expandButton, globalExpandButtonClicked) ac.addOnChatMessageListener(self.appWindow, globalChat) self.initGui()
def addButton(self, event, options): options.x = options.x | 0 options.y = options.y | 0 options.fontSize = options.fontSize | 10 options.border = options.border | 0 options.opacity = options.opacity | 1 item = ac.addButton(self.appWindow, "") ac.setPosition(item, self.x + options.x * self.scale, self.y + options.y * self.scale) ac.setFontSize(item, options.fontSize) ac.drawBorder(item, options.border) ac.setBackgroundOpacity(item, options.opacity) ac.addonClickListener(item, event) ac.setText(item, options.content) return item
def acMain(ac_version): global appWindow, labelStorage, spinner_y_offset, scale_factor, fov_setting appWindow = ac.newApp("VR-Names") ac.setTitle(appWindow, "VR-names") ac.setSize(appWindow, 200, 200) ac.drawBorder(appWindow, 0) ac.setBackgroundOpacity(appWindow, 0) # ac.setIconPosition(appWindow, -9000, 0) spinner_y_offset = ac.addSpinner(appWindow, "Name Height Offset") ac.setRange(spinner_y_offset, -100, 100) ac.setValue(spinner_y_offset, 0) ac.setStep(spinner_y_offset, 1) ac.setPosition(spinner_y_offset, 10, 90) ac.setSize(spinner_y_offset, 180, 20) scale_factor = ac.addSpinner(appWindow, "scale text factor") ac.setRange(scale_factor, 1, 30) ac.setValue(scale_factor, 10) ac.setStep(scale_factor, 1) ac.setPosition(scale_factor, 10, 135) ac.setSize(scale_factor, 180, 20) fov_setting = ac.addSpinner(appWindow, "scale text factor") ac.setRange(fov_setting, 0, 360) ac.setValue(fov_setting, 110) ac.setStep(fov_setting, 1) ac.setPosition(fov_setting, 10, 180) ac.setSize(fov_setting, 180, 20) button_toggle_name = ac.addButton(appWindow, "Toggle name") ac.addOnClickedListener(button_toggle_name, toggle_name) ac.setSize(button_toggle_name, 180, 20) ac.setPosition(button_toggle_name, 10, 40) for x in range(ac.getCarsCount()): label = ac.addLabel(appWindow, "") ac.setPosition(label, 10, 0 + (20 * x)) labelStorage.append(label) setInitialLabel() return "vrnames"
def __init__(self, window, clickFunc, width=60, height=20, x=0, y=0, text="", texture=""): self.width = width self.height = height self.x = x self.y = y self.button = ac.addButton(window, text) # adding default settings self.setSize(width, height) self.setPos(x, y) if texture != "": self.setBgTexture(texture) # default settings ac.drawBorder(self.button, 0) ac.setBackgroundOpacity(self.button, 0) # adding a click event ac.addOnClickedListener(self.button, clickFunc)
def acMain(ac_version): global appWindow, car_inputs, car_g, car_speed, track_times, perf_delta global csvfile, writer global sct, mon_select, monitor, recButton # Start new application in session appWindow = ac.newApp("SyncLogger") ac.setSize(appWindow, 200, 50) # Print initial log confirmation ac.log(__name__) ac.console(__name__) # Init individual readouts # Number values are for x/y positioning of readouts if enabled car_inputs = InputReadout(appWindow, 3, 30) car_g = GReadout(appWindow, 3, 48) car_speed = SpeedReadout(appWindow, 3, 66) track_times = LaptimeReadout(appWindow, 3, 84) perf_delta = DeltaReadout(appWindow, 3, 102) # Init Record button recButton = ac.addButton(appWindow, "Start Recording") ac.setPosition(recButton, 0, 30) ac.setSize(recButton, 200, 20) ac.addOnClickedListener(recButton, toggle) # Init screen reader helper sct = mss.mss() monitor = sct.monitors[mon_select] # get data of monitor desired monitor = sct.adj_monitor(monitor) csvfile = open(folder + 'data.csv', 'w', newline='') writer = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) return "SyncLogger"
def __init__(self, configs: Config): """ Default constructor. """ self.__buttons = {} self.__options = { "Camber": configs.get_bool_option("Camber"), "Dirt": configs.get_bool_option("Dirt"), "Height": configs.get_bool_option("Height"), "Load": configs.get_bool_option("Load"), "Lock": configs.get_bool_option("Lock"), "Logging": configs.get_bool_option("Logging"), "Pressure": configs.get_bool_option("Pressure"), "RPMPower": configs.get_bool_option("RPMPower"), "Size": configs.get_option("Size"), "Suspension": configs.get_bool_option("Suspension"), "Temps": configs.get_bool_option("Temps"), "Tire": configs.get_bool_option("Tire"), "Wear": configs.get_bool_option("Wear") } self.__window_id = ac.newApp("Live Telemetry") ac.setIconPosition(self.__window_id, 0, -10000) title = "Live Telemetry {}".format(configs.get_version()) ac.setTitle(self.__window_id, title) position = configs.get_window_position("OP") ac.setPosition(self.__window_id, *position) ac.setSize(self.__window_id, 395, 195) for index, name in enumerate(sorted(self.__options.keys())): text = str(name) if name != "Size" else self.__options[name] self.__buttons[name] = ac.addButton(self.__window_id, text) x = 30 + (floor(index / 4) * 85) y = 30 + (floor(index % 4) * 35) ac.setPosition(self.__buttons[name], x, y) ac.setSize(self.__buttons[name], 80, 30) ac.setFontAlignment(self.__buttons[name], "center") self.set_option(name, self.__options[name])
def __init__(self, parent, text, sizex, sizey, posx, posy): self.btn = ac.addButton(parent, text) ac.setSize(self.btn, sizex, sizey) ac.setPosition(self.btn, posx, posy)
def createUI(): global uiCreated, x_app_size, y_app_size, defaultFontSize global isTimedRace, timedRaceCheckbox, averageFuelPerLapValue, raceTotalLapsText, raceTotalLapsValue, bestLapTimeText, bestLapTimeValue, timedRaceMinutesSpinner, raceLapsSpinner, resetButton, timedRacePlusLapButton, timedRaceMinLapButton global extraLiters, extraLitersMinButton, extraLitersPlusButton, extraLitersValue, averageFuelPerLapText, extraLitersText, timedRaceText, toggleAppSizeButton, fuelLapsCountedText, fuelLapsCountedValue, calcTypeText, calcTypeCurrentButton, calcTypeMultipleButton, calcTypeStoredButton, completedLapsText, completedLapsValue, averageLapTimeText, averageLapTimeValue global tableCurrentFuel, tableCurrentTime, tableCurrentLaps, tableRaceFuel, tableRaceTime, tableRaceLaps, tableRowRace try: row = 0 x_offset = 5 y_offset = 20 createLabel("tableHeaderFuel", "Fuel", ((x_app_size)/5) * 2, row * y_offset, defaultFontSize, "center") createLabel("tableHeaderTime", "Time", ((x_app_size)/5) * 3, row * y_offset, defaultFontSize, "center") createLabel("tableHeaderLaps", "Laps", ((x_app_size)/5) * 4, row * y_offset, defaultFontSize, "center") row += 1 createLabel("tableRowCurrent", "Current", x_offset, row * y_offset, defaultFontSize, "left") tableCurrentFuel = createLabel("tableCurrentFuel", "--", ((x_app_size)/5) * 2, row * y_offset, defaultFontSize+2, "center") tableCurrentTime = createLabel("tableCurrentTime", "--", ((x_app_size)/5) * 3, row * y_offset, defaultFontSize+2, "center") tableCurrentLaps = createLabel("tableCurrentLaps", "--", ((x_app_size)/5) * 4, row * y_offset, defaultFontSize+2, "center") row += 1 tableRowRace = createLabel("tableRowRace", "Total Race", x_offset, row * y_offset, defaultFontSize, "left") tableRaceFuel = createLabel("tableRaceFuel", "--", ((x_app_size)/5) * 2, row * y_offset, defaultFontSize+2, "center") tableRaceTime = createLabel("tableRaceTime", "--", ((x_app_size)/5) * 3, row * y_offset, defaultFontSize+2, "center") tableRaceLaps = createLabel("tableRaceLaps", "--", ((x_app_size)/5) * 4, row * y_offset, defaultFontSize+2, "center") toggleAppSizeButton = ac.addButton(mainApp, "+") ac.setPosition(toggleAppSizeButton, x_app_size - 20 - x_offset, (row * y_offset) + 5) ac.setSize(toggleAppSizeButton, 20, 20) ac.addOnClickedListener(toggleAppSizeButton, onToggleAppSizeButtonClickedListener) row += 2 calcTypeText = createLabel("calcTypeText", "Session : ", x_offset, row * y_offset, defaultFontSize, "left") calcTypeWidth = 60 calcTypeOffset = x_offset + 70 calcTypeCurrentButton = ac.addButton(mainApp, "current") ac.setPosition(calcTypeCurrentButton, calcTypeOffset, row * y_offset) ac.setSize(calcTypeCurrentButton, calcTypeWidth, 20) ac.addOnClickedListener(calcTypeCurrentButton, onCalcTypeCurrentButtonClickedListener) calcTypeMultipleButton = ac.addButton(mainApp, "multiple") ac.setPosition(calcTypeMultipleButton, calcTypeOffset + calcTypeWidth + 10, row * y_offset) ac.setSize(calcTypeMultipleButton, calcTypeWidth, 20) ac.addOnClickedListener(calcTypeMultipleButton, onCalcTypeMultipleButtonClickedListener) calcTypeStoredButton = ac.addButton(mainApp, "stored") ac.setPosition(calcTypeStoredButton, calcTypeOffset + (2*calcTypeWidth) + 20, row * y_offset) ac.setSize(calcTypeStoredButton, calcTypeWidth, 20) ac.addOnClickedListener(calcTypeStoredButton, onCalcTypeStoredButtonClickedListener) row += 2 averageFuelPerLapText = createLabel("averageFuelPerLapText", "Avg fuel per lap : ", x_offset, row * y_offset, defaultFontSize, "left") averageFuelPerLapValue = createLabel("averageFuelPerLapValue", "--", x_app_size - x_offset, row * y_offset, defaultFontSize, "right") row += 1 fuelLapsCountedText = createLabel("fuelLapsCountedText", "Counted laps for fuel average : ", x_offset, row * y_offset, defaultFontSize, "left") fuelLapsCountedValue = createLabel("averageFuelPerLapValue", "--", x_app_size - x_offset, row * y_offset, defaultFontSize, "right") row += 1 completedLapsText = createLabel("completedLapsText", "Completed laps : ", x_offset, row * y_offset, defaultFontSize, "left") completedLapsValue = createLabel("completedLapsValue", "--", x_app_size - x_offset, row * y_offset, defaultFontSize, "right") row += 1 extraLitersText = createLabel("extraLitersText", "Extra liters : ", x_offset, row * y_offset, defaultFontSize, "left") extraLitersValue = createLabel("extraLitersValue", "--", x_app_size - x_offset, row * y_offset, defaultFontSize, "right") extraLitersMinButton = ac.addButton(mainApp, "-") ac.setPosition(extraLitersMinButton, 180, row * y_offset) ac.setSize(extraLitersMinButton, 20, 20) ac.addOnClickedListener(extraLitersMinButton, onExtraLitersMinButtonClickedListener) extraLitersPlusButton = ac.addButton(mainApp, "+") ac.setPosition(extraLitersPlusButton, 205, row * y_offset) ac.setSize(extraLitersPlusButton, 20, 20) ac.addOnClickedListener(extraLitersPlusButton, onExtraLitersPlusButtonClickedListener) row += 1 timedRaceText = createLabel("timedRaceText", "Is timed race : ", x_offset, row * y_offset, defaultFontSize, "left") timedRaceCheckbox = ac.addCheckBox(mainApp, "") ac.setPosition(timedRaceCheckbox, x_app_size - (x_offset + 15), row * y_offset + 4) ac.setSize(timedRaceCheckbox, 15, 15) ac.setValue(timedRaceCheckbox, isTimedRace) ac.addOnCheckBoxChanged(timedRaceCheckbox, onTimedRaceChangedListener) row += 1 raceTypeRow = row raceTotalLapsText = createLabel("raceTotalLapsText", "Expected race laps : ", x_offset, row * y_offset, defaultFontSize, "left") raceTotalLapsValue = createLabel("raceTotalLapsValue", "--", x_app_size - x_offset, row * y_offset, defaultFontSize, "right") timedRaceMinLapButton = ac.addButton(mainApp, "-") ac.setPosition(timedRaceMinLapButton, 180, row * y_offset) ac.setSize(timedRaceMinLapButton, 20, 20) ac.addOnClickedListener(timedRaceMinLapButton, onTimedRaceMinLapButtonClickedListener) timedRacePlusLapButton = ac.addButton(mainApp, "+") ac.setPosition(timedRacePlusLapButton, 205, row * y_offset) ac.setSize(timedRacePlusLapButton, 20, 20) ac.addOnClickedListener(timedRacePlusLapButton, onTimedRacePlusLapButtonClickedListener) row += 1 averageLapTimeText = createLabel("averageLapTimeText", "Average lap time : ", x_offset, row * y_offset, defaultFontSize, "left") averageLapTimeValue = createLabel("averageLapTimeValue", "--", x_app_size - x_offset, row * y_offset, defaultFontSize, "right") row += 1 bestLapTimeText = createLabel("bestLapTimeText", "Best lap time : ", x_offset, row * y_offset, defaultFontSize, "left") bestLapTimeValue = createLabel("bestLapTimeValue", "--", x_app_size - x_offset, row * y_offset, defaultFontSize, "right") row += 3 timedRaceMinutesSpinner = ac.addSpinner(mainApp, "Timed race minutes") ac.setRange(timedRaceMinutesSpinner, 0, 240) ac.setValue(timedRaceMinutesSpinner, timedRaceMinutes) ac.setStep(timedRaceMinutesSpinner, 1) ac.setPosition(timedRaceMinutesSpinner, x_app_size / 6, row * y_offset) ac.addOnValueChangeListener(timedRaceMinutesSpinner, onTimedRaceMinutesChangedListener) row += 2 resetButton = ac.addButton(mainApp, "Reset") ac.setPosition(resetButton, x_offset + 5, (row * y_offset) + (y_offset / 2)) ac.setSize(resetButton, 50, 22) ac.addOnClickedListener(resetButton, onResetClickedListener) row = raceTypeRow row += 5 raceLapsSpinner = ac.addSpinner(mainApp, "Race laps") ac.setRange(raceLapsSpinner, 0, 100) ac.setValue(raceLapsSpinner, raceLaps) ac.setStep(raceLapsSpinner, 1) ac.setPosition(raceLapsSpinner, x_app_size / 6, row * y_offset) ac.addOnValueChangeListener(raceLapsSpinner, onRaceLapsChangedListener) updateUIVisibility() uiCreated = True except exception: debug(repr(traceback.format_exception(exc_type, exc_value, exc_traceback))) showMessage("Error: " + traceback.format_exc())
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, dbgLabel global xyro_dev global DebugInput, DebugInput2, DebugInput3 global BtnStart, BtnStop try: import sam_secondz_xyro_config sam_secondz_xyro_config.handleIni('3secondz_xyro') ac.log("3secondz_xyro:: xyro created") xyro_dev = xyrodevice.XyroDevice(UDP_IP, UDP_PORT, DEVICE_ID, FW_VERSION, STEERING_ANGLE_RANGE, ALIVE_PACKET_PERIOD, CAN_PACKET_PERIOD, NAV_PACKET_PERIOD, MEAS_PACKET_PERIOD) appWindow = ac.newApp("3secondz_xyro") ac.setSize(appWindow, 300, 100) ac.drawBorder(appWindow, 0) ac.setBackgroundOpacity(appWindow, 0) ac.setTitle(appWindow, '3secondz_xyro') IPAddrInput = ac.addTextInput(appWindow, "TEXT_INPUT") ac.setPosition(IPAddrInput, 10, 30) ac.setSize(IPAddrInput, 120, 20) ac.setText(IPAddrInput, str(UDP_IP)) PortInput = ac.addTextInput(appWindow, "TEXT_INPUT") ac.setPosition(PortInput, 140, 30) ac.setSize(PortInput, 50, 20) ac.setText(PortInput, str(UDP_PORT)) DebugInput = ac.addTextInput(appWindow, "TEXT_INPUT") ac.setPosition(DebugInput, 10, 60) ac.setSize(DebugInput, 280, 20) ac.setText(DebugInput, "") DebugInput2 = ac.addTextInput(appWindow, "TEXT_INPUT") ac.setPosition(DebugInput2, 10, 90) ac.setSize(DebugInput2, 280, 20) ac.setText(DebugInput2, "") DebugInput3 = ac.addTextInput(appWindow, "TEXT_INPUT") ac.setPosition(DebugInput3, 10, 120) ac.setSize(DebugInput3, 280, 20) ac.setText(DebugInput3, "") BtnStart = ac.addButton(appWindow, "Start") ac.setPosition(BtnStart, 10, 150) ac.setSize(BtnStart, 90, 20) ac.addOnClickedListener(BtnStart, onClickBtnStart) BtnStop = ac.addButton(appWindow, "Stop") ac.setPosition(BtnStop, 110, 150) ac.setSize(BtnStop, 90, 20) ac.addOnClickedListener(BtnStop, onClickBtnStop) ac.addRenderCallback(appWindow, onFormRender) ac.addOnAppActivatedListener(appWindow, onAppActivated) appWindowActivated = time.clock() showWindowTitle = True dbgLabel = ac.addLabel(appWindow, "") ac.setPosition(dbgLabel, 15, 405) #xyro_dev.turnOn() ac.log("3secondz_xyro::acMain finished") except Exception as e: ac.log("3secondz_xyro::acMain() %s" % e) return "3secondz_xyro"
def acMain(ac_version): global label_lapcount, label_ERSRecovery, label_ERSDelivery, label_ERSHeatCharging, label_ERSCurrentKJ, label_ERSMaxJ, label_KersCharge, label_KersInput, label_SpeedMS, button_ChangeUnit, energy_unit_counter, current_energy_unit, label_BarCharge appWindow = ac.newApp(APP_NAME) ac.setSize(appWindow, 600, 500) ac_log("Testando a função de log") ac_console("Testando a função de console") ac.addOnAppActivatedListener(appWindow, on_activation) ac.addOnAppDismissedListener(appWindow, on_desactivation) button_ChangeUnit = ac.addButton(appWindow, "Change energy unit") ac.setSize(button_ChangeUnit, 150, 30) ac.setPosition(button_ChangeUnit, 300, 30) ac.addOnClickedListener(button_ChangeUnit, changeEnergyUnit) label_SpeedMS = ac.addLabel( appWindow, "Speed: {:.1f}m/s".format(ac.getCarState(0, acsys.CS.SpeedMS))) ac.setPosition(label_SpeedMS, 3, 300) label_ERSRecovery = ac.addLabel( appWindow, "MGU-K recovery mode: {}".format( ac.getCarState(0, acsys.CS.ERSRecovery))) ac.setPosition(label_ERSRecovery, 3, 90) label_ERSDelivery = ac.addLabel( appWindow, "MGU-K deploy mode: {}".format(ac.getCarState(0, acsys.CS.ERSDelivery))) ac.setPosition(label_ERSDelivery, 3, 120) label_ERSHeatCharging = ac.addLabel( appWindow, "MGU-H mode: {}".format(ac.getCarState(0, acsys.CS.ERSHeatCharging))) ac.setPosition(label_ERSHeatCharging, 3, 150) label_ERSCurrentKJ = ac.addLabel( appWindow, "Energy consumed in this lap: {:03.3f}{}".format( getErsCurrent(), current_energy_unit[energy_unit_counter])) ac.setPosition(label_ERSCurrentKJ, 3, 180) label_ERSMaxJ = ac.addLabel( appWindow, "Maximum energy allowed per lap: {:03.3f}{}".format( getERSMax(), current_energy_unit[energy_unit_counter])) ac.setPosition(label_ERSMaxJ, 3, 210) label_KersCharge = ac.addLabel( appWindow, "Stored energy: {:.2f}%".format( ac.getCarState(0, acsys.CS.KersCharge) * 100)) ac.setPosition(label_KersCharge, 3, 240) label_KersInput = ac.addLabel( appWindow, "MGU-K power level: {}".format( ac.getCarState(0, acsys.CS.KersInput) * 100)) ac.setPosition(label_KersInput, 3, 270) label_BarCharge = ac.addLabel( appWindow, "{}%".format(ac.getCarState(0, acsys.CS.KersCharge))) ac.setPosition(label_BarCharge, 341, 130) ac.addRenderCallback(appWindow, onFormRender) return "ERS Info"
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, parent, app_win, text=""): super().__init__(parent) self.ac_obj = ac.addButton(app_win.app, text) self._text = text self._callback = None
def window(self, value): self._window = value self.id = ac.addButton(self._window, '') ac.addOnClickedListener(self.id, self.listener) self._draw()
def acMain(ac_version): global app, label, stepBackButton, resetButton, sVer global vaoToggleButton, vaoDebugButton, lightsDebugButton, copyCameraCoordsButton global doorToggleButton, driverToggleButton try: app = ac.newApp("Shaders Patch Debug") ac.setTitle(app, " Shaders Patch Debug") ac.setSize(app, 180, 358) ac.drawBackground(app, 0) driverToggleButton = ac.addButton(app, "Driver") ac.setPosition(driverToggleButton, 20, 25) ac.setSize(driverToggleButton, 40, 20) ac.setFontSize(driverToggleButton, 12) ac.addOnClickedListener(driverToggleButton, driverToggle) doorToggleButton = ac.addButton(app, "🚪") ac.setPosition(doorToggleButton, 70, 25) ac.setCustomFont(doorToggleButton, "Segoe UI Symbol; Weight=UltraLight", 0, 0) ac.setSize(doorToggleButton, 40, 20) ac.setFontSize(doorToggleButton, 14) ac.addOnClickedListener(doorToggleButton, doorToggle) copyCameraCoordsButton = ac.addButton(app, "Copy") ac.setPosition(copyCameraCoordsButton, 120, 25) ac.setSize(copyCameraCoordsButton, 40, 20) ac.setFontSize(copyCameraCoordsButton, 12) ac.addOnClickedListener(copyCameraCoordsButton, copyCameraCoords) vaoToggleButton = ac.addButton(app, "V +/−") ac.setPosition(vaoToggleButton, 20, 45) ac.setSize(vaoToggleButton, 40, 20) ac.setFontSize(vaoToggleButton, 12) ac.addOnClickedListener(vaoToggleButton, vaoToggle) vaoDebugButton = ac.addButton(app, "V o/N") ac.setPosition(vaoDebugButton, 70, 45) ac.setSize(vaoDebugButton, 40, 20) ac.setFontSize(vaoDebugButton, 12) ac.addOnClickedListener(vaoDebugButton, vaoDebug) lightsDebugButton = ac.addButton(app, "🔦") ac.setPosition(lightsDebugButton, 120, 45) ac.setSize(lightsDebugButton, 40, 20) ac.setFontSize(lightsDebugButton, 14) ac.addOnClickedListener(lightsDebugButton, lightsDebug) stepBackButton = ac.addButton(app, "Step back") ac.setPosition(stepBackButton, 20, 65) ac.setSize(stepBackButton, 140, 20) ac.setFontSize(stepBackButton, 12) ac.addOnClickedListener(stepBackButton, takeAStepBack) ac.setCustomFont(stepBackButton, "Segoe UI; Weight=UltraBlack", 0, 0) resetButton = ac.addButton(app, "Reset") ac.setPosition(resetButton, 20, 85) ac.setSize(resetButton, 140, 20) ac.setFontSize(resetButton, 12) ac.addOnClickedListener(resetButton, resetCar) ac.setCustomFont(resetButton, "Segoe UI; Weight=UltraBlack", 0, 0) label = ac.addLabel(app, "") ac.setFontSize(label, 12) ac.setPosition(label, 5, 103) sVer = "CSP v" + str(ac.ext_patchVersion()) + "-code" + str( ac.ext_patchVersionCode()) # i = 0 # while i < 1200: # labelTemp = ac.setPosition(ac.addLabel(app, "Label #" + str(i)), 5, 30 + i) # ac.setFontSize(labelTemp, 14 + (i % 10)) # i += 1 except: ac.log("Unexpected error:" + traceback.format_exc()) return "AccExtHelper"
def __init__(self, appName): self.id = -1 self.visible = True self.extended = False self.position = -1 self.window = ac.newApp(appName) ac.setTitle(self.window, "") ac.drawBorder(self.window, 0) ac.setIconPosition(self.window, 0, -10000) ac.setSize(self.window, 300, 100) ac.setBackgroundOpacity(self.window, 0) self.backgroundTexture = ac.addLabel(self.window, "") w, h = get_image_size(FC.DRIVER_WIDGET_BACKGROUND) ac.setPosition(self.backgroundTexture, 0, 0) ac.setSize(self.backgroundTexture, w, h) ac.setBackgroundTexture(self.backgroundTexture, FC.DRIVER_WIDGET_BACKGROUND) self.rolexLabel = ac.addLabel(self.window, "") ac.setPosition(self.rolexLabel, 0, -72) ac.setSize(self.rolexLabel, 123, 70) ac.setBackgroundTexture(self.rolexLabel, FC.ROLEX_LOGO) self.positionLabel = ac.addLabel(self.window, "") ac.setPosition(self.positionLabel, 3, 3) ac.setSize(self.positionLabel, 62, 62) self.teamLabel = ac.addLabel(self.window, "") ac.setPosition(self.teamLabel, 71, 10) ac.setSize(self.teamLabel, 6, 45) self.nameLabel = ac.addLabel(self.window, "") ac.setPosition(self.nameLabel, 90, 11) ac.setFontSize(self.nameLabel, 23) ac.setCustomFont(self.nameLabel, FC.FONT_NAME, 0, 1) ac.setFontColor(self.nameLabel, 0.86, 0.86, 0.86, 1) ac.setFontAlignment(self.nameLabel, "left") self.teamNameLabel = ac.addLabel(self.window, "") ac.setPosition(self.teamNameLabel, 90, 40) ac.setFontSize(self.teamNameLabel, 18) ac.setCustomFont(self.teamNameLabel, FC.FONT_NAME, 0, 1) ac.setFontColor(self.teamNameLabel, 0.66, 0.66, 0.66, 1) ac.setFontAlignment(self.teamNameLabel, "left") self.numberLabel = ac.addLabel(self.window, "") ac.setPosition(self.numberLabel, w - 63, 7) ac.setSize(self.numberLabel, 55, 55) self.button = ac.addButton(self.window, "") ac.setPosition(self.button, 0, 0) ac.setSize(self.button, w, h) ac.addOnClickedListener(self.button, self.toogle_extended) ac.setBackgroundOpacity(self.button, 0) ac.drawBorder(self.button, 0) self.extendedBackgroundTexture = ac.addLabel(self.window, "") ac.setPosition(self.extendedBackgroundTexture, 0, h) w, h = get_image_size(FC.DRIVER_WIDGET_EXTENDED_BACKGROUND) ac.setSize(self.extendedBackgroundTexture, w, h) ac.setBackgroundTexture(self.extendedBackgroundTexture, FC.DRIVER_WIDGET_EXTENDED_BACKGROUND) self.startedTextLabel = ac.addLabel(self.window, "STARTED") ac.setPosition(self.startedTextLabel, 70, 135) ac.setFontSize(self.startedTextLabel, 18) ac.setCustomFont(self.startedTextLabel, FC.FONT_NAME, 0, 0) ac.setFontColor(self.startedTextLabel, 0.86, 0.86, 0.86, 1) ac.setFontAlignment(self.startedTextLabel, "center") self.placesTextLabel = ac.addLabel(self.window, "PLACES") ac.setPosition(self.placesTextLabel, 175, 135) ac.setFontSize(self.placesTextLabel, 18) ac.setCustomFont(self.placesTextLabel, FC.FONT_NAME, 0, 0) ac.setFontColor(self.placesTextLabel, 0.86, 0.86, 0.86, 1) ac.setFontAlignment(self.placesTextLabel, "center") self.tyreTextLabel = ac.addLabel(self.window, "TYRES") ac.setPosition(self.tyreTextLabel, 285, 135) ac.setFontSize(self.tyreTextLabel, 18) ac.setCustomFont(self.tyreTextLabel, FC.FONT_NAME, 0, 0) ac.setFontColor(self.tyreTextLabel, 0.86, 0.86, 0.86, 1) ac.setFontAlignment(self.tyreTextLabel, "center") self.pitStopTextLabel = ac.addLabel(self.window, "PIT STOPS") ac.setPosition(self.pitStopTextLabel, 395, 135) ac.setFontSize(self.pitStopTextLabel, 18) ac.setCustomFont(self.pitStopTextLabel, FC.FONT_NAME, 0, 0) ac.setFontColor(self.pitStopTextLabel, 0.86, 0.86, 0.86, 1) ac.setFontAlignment(self.pitStopTextLabel, "center") self.startedLabel = ac.addLabel(self.window, "") ac.setPosition(self.startedLabel, 70, 86) ac.setFontSize(self.startedLabel, 34) ac.setCustomFont(self.startedLabel, FC.FONT_NAME, 0, 1) ac.setFontColor(self.startedLabel, 0.86, 0.86, 0.86, 1) ac.setFontAlignment(self.startedLabel, "center") self.placesLabel = ac.addLabel(self.window, "") ac.setPosition(self.placesLabel, 175, 86) ac.setFontSize(self.placesLabel, 34) ac.setCustomFont(self.placesLabel, FC.FONT_NAME, 0, 1) ac.setFontColor(self.placesLabel, 0.86, 0.86, 0.86, 1) ac.setFontAlignment(self.placesLabel, "center") self.placesIconLabel = ac.addLabel(self.window, "") ac.setPosition(self.placesIconLabel, 135, 84) ac.setSize(self.placesIconLabel, 35, 35) self.tyreLabel = ac.addLabel(self.window, "") ac.setPosition(self.tyreLabel, 263, 78) ac.setSize(self.tyreLabel, 46, 46) self.pitStopLabel = ac.addLabel(self.window, "") ac.setPosition(self.pitStopLabel, 395, 86) ac.setFontSize(self.pitStopLabel, 34) ac.setCustomFont(self.pitStopLabel, FC.FONT_NAME, 0, 1) ac.setFontColor(self.pitStopLabel, 0.86, 0.86, 0.86, 1) ac.setFontAlignment(self.pitStopLabel, "center") ac.setVisible(self.extendedBackgroundTexture, 0) ac.setVisible(self.startedLabel, 0) ac.setVisible(self.startedTextLabel, 0) ac.setVisible(self.placesLabel, 0) ac.setVisible(self.placesTextLabel, 0) ac.setVisible(self.placesIconLabel, 0) ac.setVisible(self.tyreTextLabel, 0) ac.setVisible(self.tyreLabel, 0) ac.setVisible(self.pitStopTextLabel, 0) ac.setVisible(self.pitStopLabel, 0)
def __init__(self, leaderboardWindow, row): # SET SOME VARIABLES self.row = row px, py = LeaderboardRow.X_BASE, LeaderboardRow.Y_BASE + LeaderboardRow.ROW_HEIGHT * self.row # position of the names self.px = px self.py = py self.positionLabelId = 0 # 0 white, 1 red, 2 green - to prevent loading the labels all the time self.out = False self.pit = False self.highlightLabel = ac.addLabel(leaderboardWindow, "") ac.setPosition(self.highlightLabel, px - 5, py - 6) ac.setSize(self.highlightLabel, 258, LeaderboardRow.ROW_HEIGHT + 1) ac.setBackgroundTexture(self.highlightLabel, FC.LEADERBOARD_PLAYER_HIGHLIGHT) ac.setVisible(self.highlightLabel, 0) # CREATE LABELS self.positionLabel = ac.addLabel(leaderboardWindow, "") ac.setPosition(self.positionLabel, px - 4, py - 7) ac.setSize(self.positionLabel, 38, 38) ac.setBackgroundTexture(self.positionLabel, FC.LEADERBOARD_POSITION_LABEL[self.row + 1]) self.driverName = ac.getDriverName(row) self.driverId = -1 self.nameLabel = ac.addLabel(leaderboardWindow, self.driverName[:3].upper()) ac.setPosition(self.nameLabel, px + 65, py + 4) ac.setFontSize(self.nameLabel, 18) ac.setCustomFont(self.nameLabel, FC.FONT_NAME, 0, 1) ac.setFontColor(self.nameLabel, 0.86, 0.86, 0.86, 1) ac.setFontAlignment(self.nameLabel, "left") self.teamLabel = ac.addLabel(leaderboardWindow, "") ac.setPosition(self.teamLabel, px + 47, py + 2) ac.setSize(self.teamLabel, 5, 18) if FC.TEAM_COLORS: try: ac.setBackgroundTexture(self.teamLabel, FC.TEAM_COLORS[self.driverName]) except KeyError: ac.log("%s:Name Missing in teams.txt %s" % (FC.APP_NAME, self.driverName)) self.infoLabel = ac.addLabel(leaderboardWindow, "Interval") ac.setPosition(self.infoLabel, 250, py + 4) ac.setFontSize(self.infoLabel, 18) ac.setCustomFont(self.infoLabel, FC.FONT_NAME, 0, 1) ac.setFontColor(self.infoLabel, 0.86, 0.86, 0.86, 1) ac.setFontAlignment(self.infoLabel, "right") self.positionChangeLabel = ac.addLabel(leaderboardWindow, "") ac.setPosition(self.positionChangeLabel, 205, py + 4) ac.setSize(self.positionChangeLabel, 18, 18) ac.setVisible(self.positionChangeLabel, 0) self.fastestLapLabel = ac.addLabel(leaderboardWindow, "") ac.setPosition(self.fastestLapLabel, px - 41, py - 6) ac.setSize(self.fastestLapLabel, 37, 37) ac.setBackgroundTexture(self.fastestLapLabel, FC.LEADERBOARD_FASTEST_LAP) ac.setVisible(self.fastestLapLabel, 0) self.focus_button = ac.addButton(leaderboardWindow, "") ac.setPosition(self.focus_button, px, py - 7) ac.setSize(self.focus_button, 140, 38) self.on_click_focus_func = functools.partial(self.on_click_focus, row=self) ac.addOnClickedListener(self.focus_button, self.on_click_focus_func) ac.setBackgroundOpacity(self.focus_button, 0) ac.drawBorder(self.focus_button, 0)
def acMain(ac_version): try: global app, debug, mirrorrole, mirrorindex, toggleMonButton, fovValue, arUp, arDown, isPatch global fovLabel, fovUpButton, fovDownButton, prevButton, nextButton, leftButton, rightButton, upButton, downButton app = ac.newApp("AccExtMirrors") ac.setTitle(app, "Mirrors") ac.setSize(app, 144, 213) debug = ac.addLabel(app, "") ac.setPosition(debug, 6, 65) mirrorrole = ac.addLabel(app, "") # ac.setPosition(mirrorrole, 44, 40) ac.setPosition(mirrorrole, 35, 25) mirrorindex = ac.addLabel(app, "") ac.setPosition(mirrorindex, 54, 46) ac.setFontSize(mirrorindex, 12) fovLabel = ac.addLabel(app, "FOV") ac.setPosition(fovLabel, 102, 164) fovValue = ac.addLabel(app, "") ac.setPosition(fovValue, 108, 112) fovUpButton = ac.addButton(app, "+") ac.setPosition(fovUpButton, 104, 84) ac.setSize(fovUpButton, 24, 24) ac.setFontSize(fovUpButton, 14) ac.addOnClickedListener(fovUpButton, fovUpMirror) fovDownButton = ac.addButton(app, "-") ac.setPosition(fovDownButton, 104, 132) ac.setSize(fovDownButton, 24, 24) ac.setFontSize(fovDownButton, 14) ac.addOnClickedListener(fovDownButton, fovDownMirror) toggleMonButton = ac.addButton(app, "m") ac.setPosition(toggleMonButton, 104, 40) ac.setSize(toggleMonButton, 24, 24) ac.setFontSize(toggleMonButton, 14) ac.addOnClickedListener(toggleMonButton, toggleMonMirror) prevButton = ac.addButton(app, "-") ac.setPosition(prevButton, 16, 40) ac.setSize(prevButton, 24, 24) ac.setFontSize(prevButton, 14) ac.addOnClickedListener(prevButton, prevMirror) nextButton = ac.addButton(app, "+") ac.setPosition(nextButton, 64, 40) ac.setSize(nextButton, 24, 24) ac.setFontSize(nextButton, 14) ac.addOnClickedListener(nextButton, nextMirror) leftButton = ac.addButton(app, "L") ac.setPosition(leftButton, 16, 108) ac.setSize(leftButton, 24, 24) ac.setFontSize(leftButton, 14) ac.addOnClickedListener(leftButton, leftMirror) rightButton = ac.addButton(app, "R") ac.setPosition(rightButton, 64, 108) ac.setSize(rightButton, 24, 24) ac.setFontSize(rightButton, 14) ac.addOnClickedListener(rightButton, rightMirror) upButton = ac.addButton(app, "U") ac.setPosition(upButton, 40, 84) ac.setSize(upButton, 24, 24) ac.setFontSize(upButton, 14) ac.addOnClickedListener(upButton, upMirror) downButton = ac.addButton(app, "D") ac.setPosition(downButton, 40, 132) ac.setSize(downButton, 24, 24) ac.setFontSize(downButton, 14) ac.addOnClickedListener(downButton, downMirror) arDown = ac.addButton(app, " -") ac.setPosition(arDown, 15, 168) ac.setSize(arDown, 24, 24) ac.setFontSize(arDown, 14) ac.addOnClickedListener(arDown, downAR) ac.setFontAlignment(arDown, "left") arUp = ac.addButton(app, "+") ac.setPosition(arUp, 65, 168) ac.setSize(arUp, 24, 24) ac.setFontSize(arUp, 14) ac.addOnClickedListener(arUp, upAR) isPatch = int(ac.ext_patchVersionCode()) > 0 # ac.log('AccExtMirrors: isPatch: \n' + str(isPatch) ) except: isPatch = 0 ac.log('AccExtMirrors main: \n' + traceback.format_exc()) return "AccExtMirrors"
def acMain(ac_version): global app, debug, mirrorrole, mirrorindex, toggleMonButton, fovValue, isPatch try: app = ac.newApp("Shaders Patch Mirrors") ac.setTitle(app, "Mirrors") ac.setSize(app, 144, 188) debug = ac.addLabel(app, "") ac.setPosition(debug, 16, 164) mirrorrole = ac.addLabel(app, "") ac.setPosition(mirrorrole, 44, 40) mirrorindex = ac.addLabel(app, "") ac.setPosition(mirrorindex, 54, 46) ac.setFontSize(mirrorindex, 12) fovLabel = ac.addLabel(app, "FOV") ac.setPosition(fovLabel, 102, 164) fovValue = ac.addLabel(app, "") ac.setPosition(fovValue, 108, 112) fovUpButton = ac.addButton(app, "+") ac.setPosition(fovUpButton, 104, 88) ac.setSize(fovUpButton, 24, 24) ac.setFontSize(fovUpButton, 14) ac.addOnClickedListener(fovUpButton, fovUpMirror) fovDownButton = ac.addButton(app, "-") ac.setPosition(fovDownButton, 104, 136) ac.setSize(fovDownButton, 24, 24) ac.setFontSize(fovDownButton, 14) ac.addOnClickedListener(fovDownButton, fovDownMirror) toggleMonButton = ac.addButton(app, "m") ac.setPosition(toggleMonButton, 104, 40) ac.setSize(toggleMonButton, 24, 24) ac.setFontSize(toggleMonButton, 14) ac.addOnClickedListener(toggleMonButton, toggleMonMirror) prevButton = ac.addButton(app, "-") ac.setPosition(prevButton, 16, 40) ac.setSize(prevButton, 24, 24) ac.setFontSize(prevButton, 14) ac.addOnClickedListener(prevButton, prevMirror) nextButton = ac.addButton(app, "+") ac.setPosition(nextButton, 64, 40) ac.setSize(nextButton, 24, 24) ac.setFontSize(nextButton, 14) ac.addOnClickedListener(nextButton, nextMirror) leftButton = ac.addButton(app, "L") ac.setPosition(leftButton, 16, 112) ac.setSize(leftButton, 24, 24) ac.setFontSize(leftButton, 14) ac.addOnClickedListener(leftButton, leftMirror) rightButton = ac.addButton(app, "R") ac.setPosition(rightButton, 64, 112) ac.setSize(rightButton, 24, 24) ac.setFontSize(rightButton, 14) ac.addOnClickedListener(rightButton, rightMirror) upButton = ac.addButton(app, "U") ac.setPosition(upButton, 40, 88) ac.setSize(upButton, 24, 24) ac.setFontSize(upButton, 14) ac.addOnClickedListener(upButton, upMirror) downButton = ac.addButton(app, "D") ac.setPosition(downButton, 40, 136) ac.setSize(downButton, 24, 24) ac.setFontSize(downButton, 14) ac.addOnClickedListener(downButton, downMirror) except: isPatch = 0 acTrace() return "AccExtMirrors"
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
def __init__(self, window, clickFunc, width=60, height=20, x=0, y=0, text=""): self.button = ac.addButton(window, text) self.setSize(width, height) self.setPos(x, y) ac.addOnClickedListener(self.button, clickFunc)
def appCreateMyself(): global app, label, labeldate global timeOffsetMinusSmallButton, timeOffsetPlusSmallButton, timeOffsetMinusBigButton, timeOffsetPlusBigButton, timeOffsetMinusHugeButton, timeOffsetPlusHugeButton, timeOffsetMinusPlayButton, timeOffsetPlusPlayButton global timeOffsetMinusSmallerButton, timeOffsetPlusSmallerButton, timeOffsetMinusPlaySmallButton, timeOffsetPlusPlaySmallButton global timeOffsetMinusMonthButton, timeOffsetPlusMonthButton, timeOffsetMinusYearButton, timeOffsetPlusYearButton global sizeToggle, gAppsize, gHideBG, gHideWeather xpos=10 ypos=35 dx=50 dy=20 fntsize=12 mult=1.0 if gAppsize>=0.5 and gAppsize<=4.0: mult=gAppsize dx=dx*mult dy=dy*mult fntsize=fntsize*mult app = ac.newApp("Shaders Patch Weather") ac.setTitle(app, " Weather FX") #ac.setSize(app, 420, 360) # v0.1 if gHideWeather: ac.setSize(app, 335*mult, ypos+dy*3.5) else: ac.setSize(app, 335*mult, 380*mult) label = ac.addLabel(app, "") ac.setFontSize(label, fntsize-1) ac.setPosition(label, 10, ypos+dy*3+3) #labeldate = ac.addLabel(app, "") #ac.setFontSize(labeldate, fntsize+1) #ac.setPosition(labeldate, 300*mult, ypos+dy*3+30) timeOffsetMinusSmallerButton = ac.addButton(app, "−5min") ac.setPosition(timeOffsetMinusSmallerButton, xpos, ypos) ac.setSize(timeOffsetMinusSmallerButton, 50*mult, dy-1) ac.setFontSize(timeOffsetMinusSmallerButton, fntsize) ac.addOnClickedListener(timeOffsetMinusSmallerButton, timeOffsetMinusSmaller) xpos+=dx timeOffsetPlusSmallerButton = ac.addButton(app, "+5min") ac.setPosition(timeOffsetPlusSmallerButton, xpos, ypos) ac.setSize(timeOffsetPlusSmallerButton, 50*mult, dy-1) ac.setFontSize(timeOffsetPlusSmallerButton, fntsize) ac.addOnClickedListener(timeOffsetPlusSmallerButton, timeOffsetPlusSmaller) xpos+=dx+10*mult timeOffsetMinusHugeButton = ac.addButton(app, "−day") ac.setPosition(timeOffsetMinusHugeButton, xpos, ypos) ac.setSize(timeOffsetMinusHugeButton, 50*mult, dy-1) ac.setFontSize(timeOffsetMinusHugeButton, fntsize) ac.addOnClickedListener(timeOffsetMinusHugeButton, timeOffsetMinusHuge) xpos+=dx timeOffsetPlusHugeButton = ac.addButton(app, "+day") ac.setPosition(timeOffsetPlusHugeButton, xpos, ypos) ac.setSize(timeOffsetPlusHugeButton, 50*mult, dy-1) ac.setFontSize(timeOffsetPlusHugeButton, fntsize) ac.addOnClickedListener(timeOffsetPlusHugeButton, timeOffsetPlusHuge) xpos+=dx+10*mult timeOffsetMinusPlaySmallButton = ac.addButton(app, "- 1x") ac.setPosition(timeOffsetMinusPlaySmallButton, xpos, ypos) ac.setSize(timeOffsetMinusPlaySmallButton, 50*mult, dy-1) ac.setFontSize(timeOffsetMinusPlaySmallButton, fntsize) ac.addOnClickedListener(timeOffsetMinusPlaySmallButton, timeOffsetMinusPlaySmall) xpos+=dx timeOffsetPlusPlaySmallButton = ac.addButton(app, "+ 1x") ac.setPosition(timeOffsetPlusPlaySmallButton, xpos, ypos) ac.setSize(timeOffsetPlusPlaySmallButton, 50*mult, dy-1) ac.setFontSize(timeOffsetPlusPlaySmallButton, fntsize) ac.addOnClickedListener(timeOffsetPlusPlaySmallButton, timeOffsetPlusPlaySmall) xpos=10 ypos=35+dy timeOffsetMinusSmallButton = ac.addButton(app, "−45min") ac.setPosition(timeOffsetMinusSmallButton, xpos, ypos) ac.setSize(timeOffsetMinusSmallButton, 50*mult, dy-1) ac.setFontSize(timeOffsetMinusSmallButton, fntsize) ac.addOnClickedListener(timeOffsetMinusSmallButton, timeOffsetMinusSmall) xpos+=dx timeOffsetPlusSmallButton = ac.addButton(app, "+45min") ac.setPosition(timeOffsetPlusSmallButton, xpos, ypos) ac.setSize(timeOffsetPlusSmallButton, 50*mult, dy-1) ac.setFontSize(timeOffsetPlusSmallButton, fntsize) ac.addOnClickedListener(timeOffsetPlusSmallButton, timeOffsetPlusSmall) xpos+=dx+10*mult timeOffsetMinusMonthButton = ac.addButton(app, "−month") ac.setPosition(timeOffsetMinusMonthButton, xpos, ypos) ac.setSize(timeOffsetMinusMonthButton, 50*mult, dy-1) ac.setFontSize(timeOffsetMinusMonthButton, fntsize) ac.addOnClickedListener(timeOffsetMinusMonthButton, timeOffsetMinusMonth) xpos+=dx timeOffsetPlusMonthButton = ac.addButton(app, "+month") ac.setPosition(timeOffsetPlusMonthButton, xpos, ypos) ac.setSize(timeOffsetPlusMonthButton, 50*mult, dy-1) ac.setFontSize(timeOffsetPlusMonthButton, fntsize) ac.addOnClickedListener(timeOffsetPlusMonthButton, timeOffsetPlusMonth) xpos+=dx+10*mult timeOffsetMinusPlayButton = ac.addButton(app, "- 10x") ac.setPosition(timeOffsetMinusPlayButton, xpos, ypos) ac.setSize(timeOffsetMinusPlayButton, 50*mult, dy-1) ac.setFontSize(timeOffsetMinusPlayButton, fntsize) ac.addOnClickedListener(timeOffsetMinusPlayButton, timeOffsetMinusPlay) xpos+=dx timeOffsetPlusPlayButton = ac.addButton(app, "+ 10x") ac.setPosition(timeOffsetPlusPlayButton, xpos, ypos) ac.setSize(timeOffsetPlusPlayButton, 50*mult, dy-1) ac.setFontSize(timeOffsetPlusPlayButton, fntsize) ac.addOnClickedListener(timeOffsetPlusPlayButton, timeOffsetPlusPlay) xpos=10 ypos=35+dy*2 timeOffsetMinusBigButton = ac.addButton(app, "−6hr") ac.setPosition(timeOffsetMinusBigButton, xpos, ypos) ac.setSize(timeOffsetMinusBigButton, 50*mult, dy-1) ac.setFontSize(timeOffsetMinusBigButton, fntsize) ac.addOnClickedListener(timeOffsetMinusBigButton, timeOffsetMinusBig) xpos+=dx timeOffsetPlusBigButton = ac.addButton(app, "+6hr") ac.setPosition(timeOffsetPlusBigButton, xpos, ypos) ac.setSize(timeOffsetPlusBigButton, 50*mult, dy-1) ac.setFontSize(timeOffsetPlusBigButton, fntsize) ac.addOnClickedListener(timeOffsetPlusBigButton, timeOffsetPlusBig) xpos+=dx+10*mult timeOffsetMinusYearButton = ac.addButton(app, "−year") ac.setPosition(timeOffsetMinusYearButton, xpos, ypos) ac.setSize(timeOffsetMinusYearButton, 50*mult, dy-1) ac.setFontSize(timeOffsetMinusYearButton, fntsize) ac.addOnClickedListener(timeOffsetMinusYearButton, timeOffsetMinusYear) xpos+=dx timeOffsetPlusYearButton = ac.addButton(app, "+year") ac.setPosition(timeOffsetPlusYearButton, xpos, ypos) ac.setSize(timeOffsetPlusYearButton, 50*mult, dy-1) ac.setFontSize(timeOffsetPlusYearButton, fntsize) ac.addOnClickedListener(timeOffsetPlusYearButton, timeOffsetPlusYear) xpos+=dx+10*mult timeOffsetMinusPlayBigButton = ac.addButton(app, "- 50x") ac.setPosition(timeOffsetMinusPlayBigButton, xpos, ypos) ac.setSize(timeOffsetMinusPlayBigButton, 50*mult, dy-1) ac.setFontSize(timeOffsetMinusPlayBigButton, fntsize) ac.addOnClickedListener(timeOffsetMinusPlayBigButton, timeOffsetMinusBigPlay) xpos+=dx timeOffsetPlusPlayBigButton = ac.addButton(app, "+ 50x") ac.setPosition(timeOffsetPlusPlayBigButton, xpos, ypos) ac.setSize(timeOffsetPlusPlayBigButton, 50*mult, dy-1) ac.setFontSize(timeOffsetPlusPlayBigButton, fntsize) ac.addOnClickedListener(timeOffsetPlusPlayBigButton, timeOffsetPlusBigPlay)