def acUpdate(deltaT): global timer, timer1, timer2, flagtype, appWindow timer += deltaT timer1 += deltaT if timer2 < 5: timer2 += deltaT # for keeping the app visible at beginning if timer2 <= 5: start_info() # normal app functionality else: # Limit frequency to 60hz if timer > 0.0166: timer = 0 flagtype = info.graphics.flag check_flag_type() ac.console(str(flagtype)) # Limit frequency to 0.5 hz to keep app background visible for 2 seconds if timer1 > 2: timer1 = 0 ac.setBackgroundOpacity(appWindow, 0)
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 reinitialize_statusbox(self): field = 'enable_timing_window' if field not in self.data.config: self.data.config[field] = False if not self.data.config[field]: # Window is explicitly disabled, bail out. return if not hasattr(self.data, 'app_id2'): app_id2 = ac.newApp('deltabar timer') if app_id2 < 0: return # bail out, new window did not work else: self.data.app_id2 = app_id2 ac.setTitle(self.data.app_id2, "") ac.setBackgroundOpacity(self.data.app_id2, 0.5) ac.drawBorder(self.data.app_id2, 0) ac.setIconPosition(self.data.app_id2, 0, -10000) ac.setSize(self.data.app_id2, 300, 200) self.statusbox = statusbox.StatusBox(self.data, self.track.sector_count, bar_mode=self.bar_mode) self.statusbox.update_all(self.bar_mode)
def acMain(ac_version): global TYREINFO, optimal_spinner_id, optimal_spinner_shown appWindow = ac.newApp("Tyre Temperatures") ac.drawBackground(appWindow, background) ac.drawBorder(appWindow, background) ac.setBackgroundOpacity(appWindow, background) ac.setSize(appWindow, x_app_size, y_app_size) TYREINFO = Tyre_Info(appWindow, x_start, y_start) ac.addRenderCallback(appWindow, onFormRender) TYREINFO.optimal_temp = d_optimal_temp TYREINFO.carinifilepath = inidir + getValidFileName(ac.getCarName(0)) + ".ini" TYREINFO.needwriteini = 1 if os.path.exists(TYREINFO.carinifilepath): f = open(TYREINFO.carinifilepath, "r") TYREINFO.optimal_temp = int(f.readline()[8:]) f.close() TYREINFO.needwriteini = 0 optimal_spinner_id = ac.addSpinner(appWindow, "optimal") ac.setPosition(optimal_spinner_id, 0, y_app_size + 28) ac.setStep(optimal_spinner_id, 1) if inFahrenheit: ac.setRange(optimal_spinner_id, int(CelsiusToFahrenheit(50)), int(CelsiusToFahrenheit(150))) ac.setValue(optimal_spinner_id, int(CelsiusToFahrenheit(TYREINFO.optimal_temp))) else: ac.setRange(optimal_spinner_id, 50, 150) ac.setValue(optimal_spinner_id, TYREINFO.optimal_temp) ac.addOnValueChangeListener(optimal_spinner_id, onValueChanged) optimal_spinner_shown = 1 ac.log("Danny Giusa Tyre Temperatures loaded") return "Danny Giusa Tyre Temperatures"
def acUpdate(delta_t): global error, timer, day_offset, gWrapDebugText, gAppsize, gHideBG, gHideWeather timer += delta_t day_offset += speed * delta_t if timer > 0.075: timer = 0.0 if abs(day_offset) > 1: try: ac.ext_weatherTimeOffset(24 * 60 * 60 * day_offset / abs(day_offset)) except: ac.log("AccExtWeatherFX: Unexpected error:" + traceback.format_exc()) day_offset = 0 if error < 1: try: if not gHideWeather: s = ac.ext_weatherDebugText() s = s.replace('current day:', ' > current day: ') if gWrapDebugText==True: s = '\n'.join(s.strip() for s in re.findall(r'.{1,80}(?:\s+|$)', s)) s = s.replace('>>> Sol weather: v', '\n>>> Sol weather: v') ac.setText(label, s) if gHideBG==True: ac.setBackgroundOpacity(app,0) ac.drawBorder(app,0) except: error = error + 1 ac.log("AccExtWeatherFX: Unexpected error:" + traceback.format_exc()) ac.setText(label, "Shaders patch not installed? Error: \n" + traceback.format_exc())
def __init__(self, acd, configs): """ Default constructor. """ self.__active = False self.__data = Data() self.__data_log = [] self.__info = info self.__options = { "Logging": configs.get_bool_option("Logging"), "RPMPower": configs.get_bool_option("RPMPower") } self.__window_id = ac.newApp("Live Telemetry Engine") ac.drawBorder(self.__window_id, 0) ac.setBackgroundOpacity(self.__window_id, 0.0) ac.setIconPosition(self.__window_id, 0, -10000) ac.setTitle(self.__window_id, "") position = configs.get_window_position("EN") ac.setPosition(self.__window_id, *position) size = configs.get_option("Size") mult = BoxComponent.resolution_map[size] ac.setSize(self.__window_id, 512 * mult, 85 * mult) self.__components = [] self.__components.append(RPMPower(acd, size, self.__window_id)) # Only starts to draw after the setup. self.set_active(configs.is_window_active("EN"))
def onFormRender(deltaT): global showWindowTitle, appWindowActivated, appWindow, dbgLabel, running if not running: return #Important: Other apps can alter the global ac.gl Color and Alpha; let's reset this to White ac.glColor4f(1, 1, 1, 1) #Show/Hide the title shortly after the app became visible if showWindowTitle: if (time.clock() - appWindowActivated > showTitle): showWindowTitle = False ac.setBackgroundOpacity(appWindow, 0) ac.setIconPosition(appWindow, -7000, -3000) ac.setTitle(appWindow, "") try: #we won't do all the calculations every time, so we have to sort out some frames. #But: We'll need the graphics stuff every single time, or we'll have flickering. But no worry, opengl is fast if timeForCalculationCame(): doCalculationStuff() #Now we draw the current cars on the minimap drawCars() except Exception as e: ac.log("helipicapew::onFormRender() %s" % e) #Important: We'll clean the color again, so we might not affect other apps ac.glColor4f(1, 1, 1, 1)
def acUpdate(deltaT): global appWindow global current_gear, current_rpm, max_rpm, shift_light, alpha, images_light, images_digits, gear_display, current_speed, max_fuel, current_fuel global rpm_display, boost_display, percentage_boost, current_boost, max_boost, percentage_rpm, truncated_rpm, fuel_display, percentage_fuel global min_rpm_spinner_Label, max_rpm_spinner_Label, units_spinner_Label #Keep app window transparent ac.setBackgroundOpacity(appWindow, 0) ac.drawBorder(appWindow, 0) max_rpm = sim_info.static.maxRpm if max_rpm == 0 else max_rpm #This is pulled from shared memory, read only once max_fuel = sim_info.static.maxFuel if max_fuel == 0 else max_fuel #This is read from shared memory, read only once current_fuel = sim_info.physics.fuel #This is read from shared memory, read every deltaT percentage_fuel = current_fuel/max_fuel*100 current_gear = ac.getCarState(0, acsys.CS.Gear) #This is read from the API every update current_gear = current_gear - 1 current_rpm = ac.getCarState(0, acsys.CS.RPM) #This is read from the API every update truncated_rpm = 100*round(current_rpm/100) current_boost = ac.getCarState(0,acsys.CS.TurboBoost) #This is read from the API every update if units == 1: current_speed = ac.getCarState(0,acsys.CS.SpeedMPH) if units == 2: current_speed = ac.getCarState(0,acsys.CS.SpeedKMH) if (current_boost > max_boost): #Calcualate maximum turbo boost pressure - Due to limitations in the api/shared memory currently the only way max_boost = current_boost percentage_boost = current_boost/max_boost*100 #Calculate the percent of turbo boost being generated percentage_rpm = current_rpm/max_rpm*100 speed_display.setText("%d" % current_speed) if (current_gear >0): if (percentage_rpm < max_user_rpm): gear_display.setText("%d" % current_gear).setFontColor(1,1,1,1) else: gear_display.setText("%d" % current_gear).setFontColor(1,0,0,1) if (current_gear == 0): if (percentage_rpm < max_user_rpm): gear_display.setText("N").setFontColor(1,1,1,1) else: gear_display.setText("N").setFontColor(1,0,0,1) if (current_gear < 0): if (percentage_rpm < max_user_rpm): gear_display.setText("R").setFontColor(1,1,1,1) else: gear_display.setText("R").setFontColor(1,0,0,1) rpm_display.setText("%d" % abs(truncated_rpm)) #fuel_display.setText("%0.1f" % percentage_fuel).setFontColor(1,0,1,1) if (percentage_fuel > 10): fuel_display.setText("%0.1f" % percentage_fuel).setFontColor(1,1,1,1) if (percentage_fuel < 10): fuel_display.setText("%0.1f" % percentage_fuel).setFontColor(1,1,0,1) if (percentage_fuel < 5): fuel_display.setText("%0.1f" % percentage_fuel).setFontColor(1,0,0,1)
def __init__(self, cfg): # Config data self.cfg = cfg # Set up app window self.id = ac.newApp(self.cfg.app_name) # Set app dimensions ac.setSize(self.id, self.cfg.app_width, self.cfg.app_height) # TODO Check if this works. self.bg_texture_path = cfg.app_dir + "/img/bg.png" # self.bg_texture_path = "apps/python/traces/img/bg.png" ac.setBackgroundTexture(self.id, self.bg_texture_path) # Hide default background and border ac.setBackgroundOpacity(self.id, 0) ac.drawBorder(self.id, 0) # Empty app title in order to hide it ac.setTitle(self.id, "") # Move app icon off-screen ac.setIconPosition(self.id, 0, -10000) # Initialize empty list of drawable objects. self.drawables = []
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 version, appName, mainApp, x_app_size, y_app_size, backgroundOpacity, customFontName try: debug("starting version " + version) mainApp = ac.newApp(appName) ac.setTitle(mainApp, "") ac.drawBorder(mainApp, 0) ac.setIconPosition(mainApp, 0, -10000) ac.setBackgroundOpacity(mainApp, backgroundOpacity) # ac.initFont(0, customFontName, 0, 0) ac.setSize(mainApp, x_app_size, y_app_size) ac.addOnAppActivatedListener(mainApp, onMainAppActivatedListener) ac.addOnAppDismissedListener(mainApp, onMainAppDismissedListener) ac.addRenderCallback(mainApp, onMainAppFormRender) getSettings() createUI() return appName except exception: debug(repr(traceback.format_exception(exc_type, exc_value, exc_traceback))) showMessage("Error: " + traceback.format_exc())
def background_color(self, background_color): self._background_color = background_color if self._ac_obj is not None: col = self._background_color ac.setBackgroundColor(self._ac_obj, col.r, col.g, col.b) ac.setBackgroundOpacity(self._ac_obj, col.a)
def acUpdate(delta_t): ac.setBackgroundOpacity(toe_app, 0) ac.setBackgroundOpacity(rpm_app, 0) rpm = ac.getCarState(0, acsys.CS.RPM) boost = ac.getCarState(0, acsys.CS.TurboBoost) fuel = simInfo.physics.fuel ac.setText(rpm_label, str(round(rpm)) + "\n" + str(round(boost, 3)) + "\n" + str(round(fuel, 1))) value_fl = ac.getCarState(0, acsys.CS.ToeInDeg, acsys.WHEELS.FL) value_fr = ac.getCarState(0, acsys.CS.ToeInDeg, acsys.WHEELS.FR) value_rl = ac.getCarState(0, acsys.CS.ToeInDeg, acsys.WHEELS.RL) value_rr = ac.getCarState(0, acsys.CS.ToeInDeg, acsys.WHEELS.RR) toeP(prev_fl, value_fl) toeP(prev_fr, value_fr) toeP(prev_rl, value_rl) toeP(prev_rr, value_rr) ac.setText( toe_label, toeSl(prev_fl, value_fl) + "\t" + toeSr(prev_fr, value_fr) + "\n" + toeSl(prev_rl, value_rl) + "\t" + toeSr(prev_rr, value_rr), )
def __init__(self, name="defaultAppWindow", title="", icon=True, width=100, height=100, scale=1, texture=""): # local variables self.name = name self.title = title self.width = width self.height = height self.x = 0 self.y = 0 self.is_attached = False self.attached_l = -1 self.attached_r = -1 # creating the app window self.app = ac.newApp(self.name) # default settings ac.drawBorder(self.app, 0) ac.setBackgroundOpacity(self.app, 0) if icon is False: ac.setIconPosition(self.app, 0, -10000) # applying settings ac.setTitle(self.app, self.title) ac.setBackgroundTexture(self.app, texture) ac.setSize(self.app, math.floor(self.width*scale), math.floor(self.height*scale))
def render_tyres(deltaT): for tyre, window in zip(TYRES, WINDOWS): tyre.compound = info.graphics.tyreCompound window.draw_tyre_temp_colors(tyre.temp) window.draw_tyre_slip(tyre) # opacity looses its value when window is clicked ac.setBackgroundOpacity(window.window, 1)
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 setBgOpacity(self, opacity, animated=False): self.f_params["o"].setValue(opacity) if not animated: self.o_params["o"].setValue(opacity) #self.opacity=opacity self.params["o"].setValue(opacity) ac.setBackgroundOpacity(self.label, self.params["o"].value) return self
def acMain(self, version): ac.setTitle(self.data.app_id, "") ac.setBackgroundOpacity(self.data.app_id, 0.0) 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) return 'hot_app'
def onAppActivated(*args): global appWindowActivated, showWindowTitle ac.log("helipicapew::onAppActivated({0})".format(args)) appWindowActivated = time.clock() showWindowTitle = True ac.setBackgroundOpacity(appWindow, 0.5) ac.setIconPosition(appWindow, 0, 0) ac.setTitle(appWindow, "helipicapew v{}".format(version))
def draw(self): """ Draws all info on screen. """ ac.setBackgroundOpacity(self.__window_id, 0.0) for component in self.__components: if self.__options[type(component).__name__] == True: ac.glColor4f(*Colors.white) component.draw(self.__data) ac.glColor4f(*Colors.white)
def update(self): if self._child is not None: self._child.update() if self._background: col = self._background_color if self._ac_obj is not None: ac.setBackgroundColor(self._ac_obj, col.r, col.g, col.b) ac.setBackgroundOpacity(self._ac_obj, col.a)
def animate(self): #adjust size +1 self.adjustParam("w").adjustParam("h") #adjust position +3 self.adjustParam("x").adjustParam("y") #adjust background self.adjustParam("br").adjustParam("bg").adjustParam("bb").adjustParam("o") #adjust colors + 0.02 self.adjustParam("r").adjustParam("g").adjustParam("b").adjustParam("a") #commit changes if self.params["x"].hasChanged() or self.params["y"].hasChanged(): ac.setPosition(self.label, self.params["x"].value, self.params["y"].value) if self.params["w"].hasChanged() or self.params["h"].hasChanged(): ac.setSize(self.label, self.params["w"].value, self.params["h"].value) if self.params["h"].value == 0: self.isVisible.setValue(False) else: self.isVisible.setValue(True) if self.params["br"].hasChanged() or self.params["bg"].hasChanged() or self.params["bb"].hasChanged(): ac.setBackgroundColor(self.label, self.params["br"].value, self.params["bg"].value, self.params["bb"].value) if self.f_params["o"].value > 0: ac.setBackgroundOpacity(self.label, self.params["o"].value) if self.params["o"].hasChanged(): if self.params["o"].value == 0: self.isVisible.setValue(False) else: self.isVisible.setValue(True) changed=self.isVisible.hasChanged() if changed and self.params["o"].value > 0: self.setVisible(1) elif changed: self.setVisible(0) #fg opacity ac.setBackgroundOpacity(self.label, self.params["o"].value) if self.params["o"].value >= 0.4 : self.isTextVisible.setValue(True) else: self.isTextVisible.setValue(False) if self.isTextVisible.hasChanged(): if self.isTextVisible.value: ac.setText(self.label, self.text) else: ac.setText(self.label, "") if self.params["r"].hasChanged() or self.params["g"].hasChanged() or self.params["b"].hasChanged() or self.params["a"].hasChanged(): ac.setFontColor(self.label, self.params["r"].value, self.params["g"].value, self.params["b"].value, self.params["a"].value) if self.params["a"].value == 0: self.isVisible.setValue(False) else: self.isVisible.setValue(True) changed=self.isVisible.hasChanged() if changed and self.params["a"].value > 0: self.setVisible(1) elif changed: self.setVisible(0)
def onAppActivated(*args): global appWindowActivated, showWindowTitle ac.log("3secondz_xyro::onAppActivated({0})".format(args)) appWindowActivated = time.clock() showWindowTitle = True ac.setBackgroundOpacity(appWindow, 0.5) ac.setIconPosition(appWindow, 0, 0) ac.setTitle(appWindow, '3secondz_xyro') running = True
def draw(self, delta_t: float) -> None: """ Draws all info on screen. """ ac.setBackgroundOpacity(self.__window_id, 0.0) for component in self.__components: if self.__options[type(component).__name__] == True: ac.glColor4f(*Colors.white) component.draw(self.__data, delta_t) else: component.clear() ac.glColor4f(*Colors.white)
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 updateButtons(): global Options, Buttons for key, button in Buttons.items(): if Options[key]: ac.setBackgroundColor(button, 1, 0, 0) ac.setFontColor(button, 1, 1, 1, 1) ac.setBackgroundOpacity(button, 1) else: ac.setBackgroundColor(button, 1, 1, 1) ac.setFontColor(button, 0, 0, 0, 1) ac.setBackgroundOpacity(button, 1)
def acUpdate(deltaT): global appName, appWindow, info, imagePath global output_speed, speed, gear, output_gear, max_rpm, rpm global output_Fuel_R global absVal, text_abs, tcsVal, text_tcs #Speed speed = ac.getCarState(0, acsys.CS.SpeedKMH) ac.setText(output_speed, "%01d" % (speed)) #Gear gear = ac.getCarState(0, acsys.CS.Gear) - 1 if gear == -1: ac.setText(output_gear, "R") elif gear == 0: ac.setText(output_gear, "N") else: ac.setText(output_gear, "%01d" % (gear)) #ABS absVal = info.physics.abs if absVal == 0: ac.setFontColor(text_abs, 1, 1, 1, 0.4) else: ac.setFontColor(text_abs, 1, 1, 1, 0.83) #TCS tcsVal = info.physics.tc if tcsVal == 0: ac.setFontColor(text_tcs, 1, 1, 1, 0.4) else: ac.setFontColor(text_tcs, 1, 1, 1, 0.83) # RPM Actions rpm = info.physics.rpms max_rpm = info.static.maxRpm max_rpm_remap = round(((rpm) * (20) / (max_rpm))) # Assign image per Rounded RPM for i in hud20: ac.setBackgroundTexture( appWindow, imagePath + "hud/h" + str(max_rpm_remap) + ".png") # max_rpm_remap gets rounded to a solid number (based on the amount of images) # That number gets used as the image number # Fuel_Remaining fuel_R = info.physics.fuel ac.setText(output_Fuel_R, "{:.2f} l".format(fuel_R)) ac.setBackgroundOpacity(appWindow, 0)
def acUpdate(deltaT): global timer, gOpacity timer += deltaT if timer > 0.05: timer = 0.0 CheckOffTrack() ac.setBackgroundOpacity(appWindow, gOpacity) if gOpacity == 0: ac.drawBorder(appWindow, 0) else: ac.drawBorder(appWindow, 1)
def acUpdate(deltaT): global appWindow, windowOpacity, appPosX, appPosY, labelStorage, show_name if show_name == 1: appPosX, appPosY = ac.getPosition(appWindow) ac.setBackgroundOpacity(appWindow, windowOpacity) detectionArea = getDetectionArea() #ac.console(detectionArea) getDriverInformation(detectionArea) else: for x in range(ac.getCarsCount()): ac.setPosition(labelStorage[x], 0, 0) ac.setText(labelStorage[x], "")
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 acMain(ac_version): global fuelUsage appWindow = ac.newApp("Fuel Usage") ac.drawBackground(appWindow, background) ac.drawBorder(appWindow, background) ac.setBackgroundOpacity(appWindow, background) ac.setSize(appWindow, x_app_size, y_app_size) fuelUsage = Fuel_Usage(appWindow, x_start, y_start) ac.addRenderCallback(appWindow, onFormRender) ac.log("Fuel Usage App loaded") return "Fuel Usage App"
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 acMain(ac_version): global rpm_display, boost_display, gear_display, speed_display, fuel_display global min_rpm_spinner_Label, min_rpm_spinner, max_rpm_spinner_Label, max_rpm_spinner, settings_box_Label global units_spinner_Label, units_spinner global rpm_tag, speed_tag, boost_tag, fuel_tag appWindow = ac.newApp("RevHunterSkunkworks") ac.setTitle(appWindow, " ") ac.setSize(appWindow, windowx, windowy) ac.drawBorder(appWindow, 0) ac.setBackgroundOpacity(appWindow, 0) ac.addRenderCallback(appWindow, onFormRender) rpm_display = Label(appWindow, "").setSize(0, 0).setPosition( (2.05 * windowx / 3), (1.05 * windowy / 3)).setFontSize(50).setFontAlign("right") gear_display = Label(appWindow).setSize(0, 0).setPosition( (windowx / 2), -50).setFontSize(140).setFontAlign("center") speed_display = Label(appWindow, "").setSize(0, 0).setPosition( (1.25 * windowx / 3), (1.05 * windowy / 3)).setFontSize(50).setFontAlign("right") fuel_display = Label(appWindow, "").setSize(0, 0).setPosition( (0.8 * windowx / 3), (1.25 * windowy / 3)).setFontSize(35).setFontAlign("right") settings_box_Label = Label(appWindow, "").setSize(0, 0).setPosition( 940, 83).setFontSize(15).setFontAlign("left") rpm_tag = Label(appWindow, "").setText("RPM").setSize(0, 0).setPosition( (2.06 * windowx / 3), (2.1 * windowy / 3)).setFontSize(15).setFontAlign("left") speed_tag = Label(appWindow, "").setText("MPH").setSize(0, 0).setPosition( (1.26 * windowx / 3), (2.1 * windowy / 3)).setFontSize(15).setFontAlign("left") fuel_tag = Label(appWindow, "").setText("%FUEL").setSize(0, 0).setPosition( (0.81 * windowx / 3), (1.9 * windowy / 3)).setFontSize(15).setFontAlign("left") min_rpm_spinner = ac.addSpinner(appWindow, "Min %RPM") spinnerConfig(min_rpm_spinner, 0, 125, 80, 20, 0, 1, 100, 80, setMinRPM, 0) max_rpm_spinner = ac.addSpinner(appWindow, "Max %RPM") spinnerConfig(max_rpm_spinner, 100, 125, 80, 20, 90, 1, 100, 97, setMaxRPM, 0) units_spinner = ac.addSpinner(appWindow, "Units") spinnerConfig(units_spinner, 200, 125, 80, 20, 1, 1, 2, 1, setUnits, 0) settings_box = ac.addCheckBox(appWindow, "") ac.setPosition(settings_box, 950, 95) ac.setSize(settings_box, 10, 10) ac.addOnCheckBoxChanged(settings_box, toggle_settings_visiblity) return "RevHunterSkunkworks"
def update(self): self.position_changed = False col = self._background_color if self._ac_obj is not None: ac.setBackgroundColor(self._ac_obj, col.r, col.g, col.b) ac.setBackgroundOpacity(self._ac_obj, col.a) x, y = ACWidget.getPosition(self._ac_obj) if self._pos[0] != x or self._pos[1] != y: self._pos = (x, y) self.position_changed = True
def acUpdate(deltaT): global gear, appWindow ac.setBackgroundOpacity(appWindow, 0) gear = ac.getCarState(0, acsys.CS.Gear) if (gear == 0): ac.setText(label, "R") ac.setText(shadow, "R") elif (gear == 1): ac.setText(label, "N") ac.setText(shadow, "N") else: ac.setText(label, "{}".format(gear - 1)) ac.setText(shadow, "{}".format(gear - 1))
def __init__(self, acd: ACD, configs: Config, wheel_index: int) -> None: """ Default constructor receive the index of the wheel it will draw info. """ self.__wheel = WheelPos(wheel_index) self.__active = False self.__data = Data() self.__data_log = [] self.__info = info 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"), "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 {}".format( self.__wheel.name())) ac.drawBorder(self.__window_id, 0) ac.setBackgroundOpacity(self.__window_id, 0.0) ac.setIconPosition(self.__window_id, 0, -10000) ac.setTitle(self.__window_id, "") position = configs.get_window_position(self.__wheel.name()) ac.setPosition(self.__window_id, *position) size = configs.get_option("Size") mult = BoxComponent.resolution_map[size] ac.setSize(self.__window_id, 512 * mult, 271 * mult) self.__components = [] self.__components.append(Temps(acd, size, self.__wheel)) self.__components.append(Dirt(size)) self.__components.append(Lock(acd, size, self.__wheel)) self.__components.append(Tire(acd, size, self.__wheel)) self.__components.append(Camber(size)) self.__components.append(Suspension(size, self.__wheel)) self.__components.append(Height(size, self.__wheel, self.__window_id)) self.__components.append( Pressure(acd, size, self.__wheel, self.__window_id)) self.__components.append(Wear(size, self.__wheel)) # Needs to be the last to render above all components self.__components.append(Load(size, self.__wheel)) # Only draw after the setup self.set_active(configs.is_window_active(self.__wheel.name()))
def setBgColor(self, color, animated=False): self.f_params["br"].setValue(color[0]) self.f_params["bg"].setValue(color[1]) self.f_params["bb"].setValue(color[2]) if not animated: self.o_params["br"].setValue(color[0]) self.o_params["bg"].setValue(color[1]) self.o_params["bb"].setValue(color[2]) self.params["br"].setValue(color[0]) self.params["bg"].setValue(color[1]) self.params["bb"].setValue(color[2]) ac.setBackgroundColor(self.label, *color) if self.f_params["o"].value > 0: ac.setBackgroundOpacity(self.label, self.params["o"].value) return self
def acUpdate(deltaT): global appWindow, inputWindow, currentTrans, updateTrans, currentText, updateText, lines, maxLines if currentTrans != 0: if currentTrans < updateTrans: currentTrans += 1 else: ac.setBackgroundOpacity(appWindow, 0) ac.setBackgroundOpacity(inputWindow, 0) currentTrans = 0 if currentText != 0: if currentText < updateText: currentText += 1 else: for i in range(0, maxLines): for x in range(0, 2): ac.setVisible(lines[i][x], 0)
def onRender(self, delta_t): if self.first_update: return # bail out, nothing is ready # AC resets background opacity if the user moves the window. # Set it on every frame to force it. ac.setBackgroundOpacity(self.data.app_id, 0.0) # Our demo of frame count. self.local_frame_count += 1 self.data.frame_count += 1 # Example of hiding your label when in replay mode. if (sim_info.info.graphics.status not in (sim_info.AC_LIVE, sim_info.AC_PAUSE)): ac.setVisible(self.data.banner, 0) else: ac.setVisible(self.data.banner, 1)
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): # use global variables global appWindow, FL, FR, RL, RR, space # create the app appWindow = ac.newApp("Tyre Temps") # setup the app window ac.setSize(appWindow,160,209) ac.drawBorder(appWindow,0) ac.setBackgroundOpacity(appWindow,0) # make the background a set of tyre outlines ac.setBackgroundTexture(appWindow,"apps/python/tyreTemps/tyretempsBackground.png") # create an object for each tyre FL = TyreTempText(appWindow, "FL", 25, 85) FR = TyreTempText(appWindow, "FR", 95, 85) RL = TyreTempText(appWindow, "RL", 25, 105) RR = TyreTempText(appWindow, "RR", 95, 105) return "Tyre Temps"
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 acMain(ac_version): global rpm_display, boost_display, gear_display, speed_display, fuel_display global min_rpm_spinner_Label, min_rpm_spinner, max_rpm_spinner_Label, max_rpm_spinner, settings_box_Label global units_spinner_Label, units_spinner global rpm_tag, speed_tag, boost_tag, fuel_tag appWindow=ac.newApp("RevHunterSkunkworks") ac.setTitle(appWindow, " ") ac.setSize(appWindow,windowx,windowy) ac.drawBorder(appWindow,0) ac.setBackgroundOpacity(appWindow,0) ac.addRenderCallback(appWindow, onFormRender) rpm_display = Label(appWindow, "").setSize(0,0).setPosition((2.05*windowx/3),(1.05*windowy/3)).setFontSize(50).setFontAlign("right") gear_display = Label(appWindow).setSize(0,0).setPosition((windowx / 2),-50).setFontSize(140).setFontAlign("center") speed_display= Label(appWindow, "").setSize(0,0).setPosition((1.25*windowx/3),(1.05*windowy/3)).setFontSize(50).setFontAlign("right") fuel_display = Label(appWindow, "").setSize(0,0).setPosition((0.8*windowx/3),(1.25*windowy/3)).setFontSize(35).setFontAlign("right") settings_box_Label = Label(appWindow, "").setSize(0,0).setPosition(940,83).setFontSize(15).setFontAlign("left") rpm_tag = Label(appWindow, "").setText("RPM").setSize(0,0).setPosition((2.06*windowx/3),(2.1*windowy/3)).setFontSize(15).setFontAlign("left") speed_tag=Label(appWindow, "").setText("MPH").setSize(0,0).setPosition((1.26*windowx/3),(2.1*windowy/3)).setFontSize(15).setFontAlign("left") fuel_tag = Label(appWindow, "").setText("%FUEL").setSize(0,0).setPosition((0.81*windowx/3),(1.9*windowy/3)).setFontSize(15).setFontAlign("left") min_rpm_spinner = ac.addSpinner(appWindow, "Min %RPM") spinnerConfig(min_rpm_spinner,0,125,80,20,0,1,100,80,setMinRPM,0) max_rpm_spinner = ac.addSpinner(appWindow, "Max %RPM") spinnerConfig(max_rpm_spinner,100,125,80,20,90,1,100,97,setMaxRPM,0) units_spinner = ac.addSpinner(appWindow, "Units") spinnerConfig(units_spinner,200,125,80,20,1,1,2,1,setUnits,0) settings_box = ac.addCheckBox(appWindow, "") ac.setPosition(settings_box,950,95) ac.setSize(settings_box,10,10) ac.addOnCheckBoxChanged(settings_box,toggle_settings_visiblity) return "RevHunterSkunkworks"
def onRenderCallback(self, deltaT): # Update background in case the app has been moved ac.setBackgroundOpacity(self.window, 1.0)
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 acUpdate(delta_t): ac.setBackgroundOpacity(appWindow, 0)
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 setBgOpacity(self, alpha): ac.setBackgroundOpacity(self.app, alpha) return self
def setBgOpacity(self, opacity): ac.setBackgroundOpacity(self.label, opacity) return self
def __init__(self, name="defaultAppWindow", width=100, height=100): self.app = ac.newApp(name) ac.drawBorder(self.app, 0) ac.setBackgroundOpacity(self.app, 0) self.setSize(width, height)
def onRenderCallback(self, deltaT): # Update background and border in case the app has been moved ac.setBackgroundOpacity(self.window, float(opacity)/100) ac.drawBorder(self.window, showBorder)
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 hasCustomBackground(self): ac.drawBorder(self.button, 0) ac.setBackgroundOpacity(self.button, 0) return self
def _create_widget(self): self.widget = ac.newApp('ACTracker') ac.setSize(self.widget, app_size_x, app_size_y) ac.setBackgroundOpacity(self.widget, 0.75)