Exemple #1
0
	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))
Exemple #2
0
    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 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)
Exemple #4
0
    def background_texture(self, tex):
        if isinstance(tex, str):
            self._background_texture = ac.newTexture(tex)
        else:
            self._background_texture = tex

        if self._ac_obj is not None:
            ac.setBackgroundTexture(self._ac_obj, self._background_texture)
Exemple #5
0
def FuelEvent(x):
    global Fill, FuelSelection, Gas, FuelAdd, FuelMax, Resolution

    Gas = int(ac.getValue(FuelSelection))

    if Gas == FuelMax:
        ac.setBackgroundTexture(Fill, "apps/python/BoxRadio/img/fuel_fill_ON.png")
    else:
        ac.setBackgroundTexture(Fill, "apps/python/BoxRadio/img/fuel_fill_OFF.png")
  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)
Exemple #7
0
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)
Exemple #8
0
def EngineEvent(name, state):
    global Engine, FixEngine, Enginecoord, Resolution

    if FixEngine == 'no':
        Enginecoord = int(Resolution / 2 + 243)
        FixEngine = 'yes'
        ac.setBackgroundTexture(Engine, "content/gui/pitstop/repair_engine_ON.png")
    else:
        Enginecoord = int(Resolution / 2 + 140)
        FixEngine = 'no'
        ac.setBackgroundTexture(Engine, "content/gui/pitstop/repair_engine_OFF.png")
Exemple #9
0
def SuspensionEvent(name, state):
    global Suspension, FixSuspen, Suspensioncoord, Resolution

    if FixSuspen == 'no':
        Suspensioncoord = int(Resolution / 2 - 227)
        FixSuspen = 'yes'
        ac.setBackgroundTexture(Suspension, "content/gui/pitstop/repair_sus_ON.png")
    else:
        Suspensioncoord = int(Resolution / 2 + 140)
        FixSuspen = 'no'
        ac.setBackgroundTexture(Suspension, "content/gui/pitstop/repair_sus_OFF.png")
Exemple #10
0
def FuelEvent(x):
    global Fill, FuelSelection, Gas, FuelAdd, FuelMax, Resolution

    Gas = int(ac.getValue(FuelSelection))

    if Gas == FuelMax:
        ac.setBackgroundTexture(Fill,
                                "apps/python/BoxRadio/img/fuel_fill_ON.png")
    else:
        ac.setBackgroundTexture(Fill,
                                "apps/python/BoxRadio/img/fuel_fill_OFF.png")
Exemple #11
0
def BodyEvent(name, state):
    global Body, FixBody, Bodycoord, Resolution

    if FixBody == 'no':
        Bodycoord = int(Resolution / 2 - 2)
        FixBody = 'yes'
        ac.setBackgroundTexture(Body, "content/gui/pitstop/repair_body_ON.png")
    else:
        Bodycoord = int(Resolution / 2 + 140)
        FixBody = 'no'
        ac.setBackgroundTexture(Body, "content/gui/pitstop/repair_body_OFF.png")
Exemple #12
0
def BodyEvent(name, state):
    global Body, FixBody, Bodycoord, Resolution

    if FixBody == 'no':
        Bodycoord = int(Resolution / 2 - 2)
        FixBody = 'yes'
        ac.setBackgroundTexture(Body, "content/gui/pitstop/repair_body_ON.png")
    else:
        Bodycoord = int(Resolution / 2 + 140)
        FixBody = 'no'
        ac.setBackgroundTexture(Body,
                                "content/gui/pitstop/repair_body_OFF.png")
Exemple #13
0
 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
Exemple #14
0
 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
Exemple #15
0
def EngineEvent(name, state):
    global Engine, FixEngine, Enginecoord, Resolution

    if FixEngine == 'no':
        Enginecoord = int(Resolution / 2 + 243)
        FixEngine = 'yes'
        ac.setBackgroundTexture(Engine,
                                "content/gui/pitstop/repair_engine_ON.png")
    else:
        Enginecoord = int(Resolution / 2 + 140)
        FixEngine = 'no'
        ac.setBackgroundTexture(Engine,
                                "content/gui/pitstop/repair_engine_OFF.png")
Exemple #16
0
def SuspensionEvent(name, state):
    global Suspension, FixSuspen, Suspensioncoord, Resolution

    if FixSuspen == 'no':
        Suspensioncoord = int(Resolution / 2 - 227)
        FixSuspen = 'yes'
        ac.setBackgroundTexture(Suspension,
                                "content/gui/pitstop/repair_sus_ON.png")
    else:
        Suspensioncoord = int(Resolution / 2 + 140)
        FixSuspen = 'no'
        ac.setBackgroundTexture(Suspension,
                                "content/gui/pitstop/repair_sus_OFF.png")
Exemple #17
0
 def update_name(self, id):
     if id == ac.getFocusedCar():
         ac.setVisible(self.highlightLabel, 1)
     else:
         ac.setVisible(self.highlightLabel, 0)
     if self.driverId == id: return  # no need to update
     self.driverId = id
     self.driverName = ac.getDriverName(id)
     displayName = self.driverName.split()[-1][:3].upper()
     ac.setText(self.nameLabel, displayName)
     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))
def acUpdate(deltaT):
	global brake_display
	global gas_display

	steps = 20
	
	ac_brake = round(ac.getCarState(0, acsys.CS.Brake) * 100)
	
	current_brake_step = str(round(steps * ac_brake / 100)).zfill(2)
	# ac.console(current_brake_step)
	ac.setBackgroundTexture(brake_display, "apps/python/pedalCircles/textures/brake_steps/brake_" + current_brake_step + ".png")

	ac_gas = round(ac.getCarState(0, acsys.CS.Gas) * 100)
	current_gas_step = str(round(steps * ac_gas / 100)).zfill(2)
	# ac.console(current_gas_step)
	ac.setBackgroundTexture(gas_display, "apps/python/pedalCircles/textures/gas_steps/gas_" + current_gas_step + ".png")
def acMain(ac_version):
    """Main function that is invoked by Assetto Corsa."""
    global app_window
    app_window = ac.newApp("")
    ac.setSize(app_window, 343, 78)
    ac.drawBorder(app_window, 0)
    app_dir = os.path.dirname(os.path.realpath(__file__))
    ac.setBackgroundTexture(app_window, app_dir + "/Images/Dashboard.png")
    ac.addRenderCallback(app_window, render_app)

    CAR.name = ac.getCarName(0)
    dashboard_elements.init(MAIN_APP_TELEMETRY, app_window, CAR.name)

    tyre_apps.init(MAIN_APP_TELEMETRY)
    info_app.init()

    threading.Thread(target=read_static_shared_memory).start()

    return "AC Dashboard"
    def __init__(self, appName):
        self.timer = 0

        self.window = ac.newApp(appName)
        ac.setTitle(self.window, "")
        ac.drawBorder(self.window, 0)
        ac.setIconPosition(self.window, 0, -10000)
        ac.setSize(self.window, 367, 73)
        ac.setBackgroundOpacity(self.window, 0)

        self.fastestLapBanner = ac.addLabel(self.window, "")
        ac.setPosition(self.fastestLapBanner, 0, 0)
        w, h = get_image_size(FC.FASTEST_LAP_BANNER)
        ac.setSize(self.fastestLapBanner, w, h)
        ac.setBackgroundTexture(self.fastestLapBanner, FC.FASTEST_LAP_BANNER)

        self.fastestLapBackground = ac.addLabel(self.window, "")
        ac.setPosition(self.fastestLapBackground, w, 0)
        ac.setSize(self.fastestLapBackground, 400, h)
        ac.setBackgroundTexture(self.fastestLapBackground,
                                FC.DRIVER_WIDGET_BACKGROUND)

        self.nameLabel = ac.addLabel(self.window, "")
        ac.setPosition(self.nameLabel, w + 10, 11)
        ac.setFontSize(self.nameLabel, 22)
        ac.setCustomFont(self.nameLabel, FC.FONT_NAME, 0, 0)
        ac.setFontColor(self.nameLabel, 0.86, 0.86, 0.86, 1)
        ac.setFontAlignment(self.nameLabel, "left")

        self.lastNameLabel = ac.addLabel(self.window, "")
        ac.setPosition(self.lastNameLabel, w + 10, 37)
        ac.setFontSize(self.lastNameLabel, 28)
        ac.setCustomFont(self.lastNameLabel, FC.FONT_NAME, 0, 1)
        ac.setFontColor(self.lastNameLabel, 0.86, 0.86, 0.86, 1)
        ac.setFontAlignment(self.lastNameLabel, "left")

        self.timeLabel = ac.addLabel(self.window, "")
        ac.setPosition(self.timeLabel, w + 385, 22)
        ac.setFontSize(self.timeLabel, 35)
        ac.setCustomFont(self.timeLabel, FC.FONT_NAME, 0, 1)
        ac.setFontColor(self.timeLabel, 0.86, 0.86, 0.86, 1)
        ac.setFontAlignment(self.timeLabel, "right")
Exemple #21
0
    def background_texture(self, background_texture: str):
        self._background_texture = background_texture

        self.background = True if self.background_texture else False

        if self.background_texture:
            if self.has_id:
                self.background = True
                if ac.setBackgroundTexture(self.id, background_texture) == -1:
                    console('{}: Texture "{}" could not be set.'.format(
                        self, background_texture))
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"
Exemple #23
0
	def __init__(self, parent, number):
		self.back = defbutton(parent, "", 320, 34, 0, number*34)
		ac.drawBorder(self.back.btn, 0)
		ac.setBackgroundTexture(self.back.btn, "apps/python/HoschTV/img/tower-back.png")
		ac.drawBorder(self.back.btn, 0)
		ac.setBackgroundOpacity(self.back.btn, 0)
		self.pos = deflabel(parent, str(number +1), 32, 17, 2+number*34, "voxbox", "center")
		ac.setFontColor(self.pos.lbl, 0, 0, 0, 1)
		if number>18:
			ac.setFontSize(self.pos.lbl, 19)
			ac.setPosition(self.pos.lbl, 17, 8+number*34)
		elif number>8:
			ac.setFontSize(self.pos.lbl, 26)
			ac.setPosition(self.pos.lbl, 17, 5+number*34)
		
		
		# ac.addOnClickedListener(self.back, focus(i))
		# ac.addOnClickedListener(self.back, focus(p[i+1]))
		# ac.addOnClickedListener(id, func)
		"""
		self.pos = ac.addLabel(ACtower, str(i+1))
		ac.setPosition(self.pos, 19, (40*i)+6)
		ac.setFontSize(self.pos, 25)
		ac.setCustomFont(self.pos, "Arial", 0, 0)
		ac.setFontAlignment(self.pos, "center")
		ac.setFontColor(self.pos, 0, 0, 0, 1)
		
		self.name = ac.addLabel(ACtower, "BSP")
		ac.setPosition(self.name, 40, (40*i)+4)
		ac.setFontSize(self.name, 29)
		ac.setCustomFont(self.name, "Arial", 0, 0)
		
		self.info = ac.addLabel(ACtower, "0:00.000")
		ac.setPosition(self.info, 116, (40*i)+6)
		ac.setFontSize(self.info, 25)
		ac.setCustomFont(self.info, "Arial", 0, 0)
		"""
		
Exemple #24
0
class Display:
    def __init__(self, options):
        self.appWindow = ac.appWindow
        self.scale = scale | 1
        self.x = x * self.scale | 0
        self.y = y * self.scale | 0

    def addLabel(self, options):
        options.x = options.x | 0
        options.y = options.y | 0
        options.fontSize = options.fontSize | 10
        options.fontFamily = options.fontFamily | "Roboto"
        options.fontAlignment = options.fontAlignment | "center"
        options.color = options.color | [0.8, 0.8, 0.8, 1]
        
        item = ac.addLabel(self.appWindow, options.content)
        ac.setPosition(item, self.x + options.x * self.scale, self.y + options.y * self.scale)
        ac.setFontSize(item, self.fontSize)
        ac.setFontAlignment(item, self.fontAlignment)
        ac.setCustomFont(item, options.fontFamily, 1, 0)
        ac.setFontColor(item, options.color[0], options.color[1], options.color[2], options.color[3])
        
        return item

    def updateLabel(self, label, options):
        if (options.value):
            ac.setText(label, options.value)

        if (options.color):
            ac.setFontColor(label, options.color[0], options.color[1], options.color[2], options.color[3])

    def addImage(self, texture, options):
        options.x = options.x | 0
        options.y = options.y | 0
        options.width = options.width | 100
        options.height = options.height | 100

        item = ac.addLabel(self.appWindow, "")
        ac.setPosition(item, self.x + options.x * self.scale, self.y + options.y * self.scale)
	    ac.setSize(item, options.width * self.scale, options.height * self.scale)
        ac.setVisible()
        ac.setBackgroundTexture(item, IMAGE_FOLDER + texture)

        return item
Exemple #25
0
 def update_positions(self, pos_diff):
     if self.out or self.pit: return  # no need to update
     if self.update_type == INFO_TYPE.POSITIONS:
         ac.setVisible(self.positionChangeLabel, 1)
         if pos_diff > 0:
             ac.setBackgroundTexture(self.positionChangeLabel,
                                     FC.POSITION_GAINED)
         elif pos_diff < 0:
             ac.setBackgroundTexture(self.positionChangeLabel,
                                     FC.POSITION_LOST)
         else:
             ac.setBackgroundTexture(self.positionChangeLabel,
                                     FC.POSITION_MAINTAINED)
         ac.setText(self.infoLabel, str(abs(pos_diff)))
Exemple #26
0
def acMain(ac_version):
    global appWindow, appName, logPrefix, flag1Label, flag2Label, flag3Label
    global cfg_flag1Image
    global cfg_flag2Image
    global cfg_flag3Image
    global cfg_flagWidth, cfg_flagHeight

    ac.console(logPrefix + "acMain")
    try:
        appWindow = ac.newApp(appName)
        ac.setTitle(appWindow, "")
        ac.setIconPosition(appWindow, -7000, -3000)
        ac.setSize(appWindow, cfg_flagWidth, cfg_flagHeight + 30)
        ac.drawBorder(appWindow, 0)
        ac.setBackgroundOpacity(appWindow, 0)

        flag1Label = ac.addLabel(appWindow, "")
        ac.setPosition(flag1Label, 0, 30)
        ac.setSize(flag1Label, cfg_flagWidth, cfg_flagHeight)
        ac.setBackgroundTexture(flag1Label, cfg_flag1Image)
        ac.setVisible(flag1Label, 0)

        flag2Label = ac.addLabel(appWindow, "")
        ac.setPosition(flag2Label, 0, 30)
        ac.setSize(flag2Label, cfg_flagWidth, cfg_flagHeight)
        ac.setBackgroundTexture(flag2Label, cfg_flag2Image)
        ac.setVisible(flag2Label, 0)

        flag3Label = ac.addLabel(appWindow, "")
        ac.setPosition(flag3Label, 0, 30)
        ac.setSize(flag3Label, cfg_flagWidth, cfg_flagHeight)
        ac.setBackgroundTexture(flag3Label, cfg_flag3Image)
        ac.setVisible(flag3Label, 0)

        ac.addRenderCallback(appWindow, onRender)
        ac.console(logPrefix + "Initialized")
    except:
        ac.console(logPrefix + "Initialize failed:", sys.exc_info()[0])

    return appName
 def setBackgroundTexture(self, texture):
     ac.setBackgroundTexture(self.button, texture)
     return self
Exemple #28
0
    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 setBackgroundTexture(self, texture):
     ac.setBackgroundTexture(self.app, texture)
     return self
def acUpdate(deltaT):
    # TIMERS
    global timer0, timer1, timer2

    # VARIABLES
    global totalDrivers
    global drivers
    global fastest_lap

    global race_started, replay_started, quali_started

    global qualify_session_time

    global replay_file
    global replay_data

    # Widgets
    global leaderboardWindow, driverWidget, driverComparisonWidget

    # LABELS
    global leaderboard
    global lapCountTimerLabel, leaderboardBaseLabel, leaderboardInfoBackgroundLabel, leaderboardBackgroundLabel
    global flagLabel

    # ============================
    # UPDATE TIMERS
    timer0 += deltaT
    timer1 += deltaT
    timer2 += deltaT
    # ============================

    # ================================================================
    #                            RACES
    # ================================================================
    if info.graphics.session == 2:

        # 10 times per second
        if timer2 > 0.1:
            timer2 = 0

            # =============================
            # SAVE SPLIT TIMES
            for d in drivers:
                if ac.isConnected(d.id) == 0: continue
                current_split = d.get_split_id(ac.getCarState(d.id, acsys.CS.NormalizedSplinePosition))
                if d.current_split != current_split: # save split time at each split of the track
                    d.split_times[current_split-1] = time.time()
                    d.current_split = current_split

        # 3 times per second
        if timer1 > 0.3:
            # CHECK RACE RESTART
            if race_started and info.graphics.completedLaps == 0 and info.graphics.iCurrentTime == 0:
                race_started = False

            # CHECK RACE START
            if not race_started and info.graphics.iCurrentTime > 0:
                # RESET THINGS
                fastest_lap = MAX_LAP_TIME
                LeaderboardRow.FASTEST_LAP_ID = -1
                for row in leaderboard: # clean the fastest lap marker
                    row.mark_fastest_lap()
                # in case we are coming from a qualify
                ac.setFontColor(lapCountTimerLabel, 0.86, 0.86, 0.86, 1)
                ac.setBackgroundTexture(leaderboardBaseLabel, FC.LEADERBOARD_BASE_RACE)
                ac.setVisible(lapCountTimerLabel, 1)

                race_started = True
                quali_started = False
                for d in drivers:
                    d.starting_position = ac.getCarLeaderboardPosition(d.id)
                    d.tyre = ac.getCarTyreCompound(d.id)
                    d.pits = 0
                replay_file = setup_replay_file(drivers, info.graphics.numberOfLaps) # save starting info on the drivers

            # ============================
            # POSITION UPDATE
            for i in range(totalDrivers):
                pos = ac.getCarRealTimeLeaderboardPosition(i)
                connected = ac.isConnected(i)
                if connected == 0: # mark unconnected drivers
                    leaderboard[pos].mark_out()
                    drivers[i].out = True
                else:
                    leaderboard[pos].mark_in()
                    drivers[i].out = False
                leaderboard[pos].update_name(i)

                # OVERTAKE
                if pos != drivers[i].position: # there was an overtake
                    drivers[i].timer = FC.OVERTAKE_POSITION_LABEL_TIMER # set timer
                    if pos < drivers[i].position:
                        leaderboard[pos].mark_green_position()
                    elif pos > drivers[i].position:
                        leaderboard[pos].mark_red_position()
                elif drivers[i].timer <= 0:
                    leaderboard[pos].mark_white_position()
                else:
                    drivers[i].timer -= timer1
                drivers[i].position = pos
                # END OVERTAKE

            # ============================
            # FASTEST LAP BANNER TIMER
            if fastest_lap_banner.timer > 0:
                fastest_lap_banner.timer -= timer1
                fastest_lap_banner.hide()

            # ============================
            # FLAGS
            if info.graphics.flag == 1:
                ac.setBackgroundTexture(flagLabel, FC.BLUE_FLAG)
                ac.setVisible(flagLabel, 1)
            elif info.graphics.flag == 2:
                ac.setBackgroundTexture(flagLabel, FC.YELLOW_FLAG)
                ac.setVisible(flagLabel, 1)
            elif info.graphics.flag == 5:
                ac.setBackgroundTexture(flagLabel, FC.CHECKERED_FLAG)
                ac.setVisible(flagLabel, 1)
            elif info.graphics.flag == 0:
                ac.setVisible(flagLabel, 0)

            timer1 = 0

        # Once per second
        if timer0 > 1:
            timer0 = 0
            ac.setBackgroundOpacity(leaderboardWindow, 0)
            ac.setBackgroundOpacity(driverWidget.window, 0)
            ac.setBackgroundOpacity(driverComparisonWidget.window, 0)
            ac.setBackgroundOpacity(fastest_lap_banner.window, 0)

            # ============================
            # SERVER LAP
            for i in range(totalDrivers):
                drivers[i].current_lap = ac.getCarState(i, acsys.CS.LapCount)
            lc = max((drivers[i].current_lap for i in range(totalDrivers))) + 1
            if lc >= info.graphics.numberOfLaps:
                ac.setVisible(lapCountTimerLabel, 0)
                ac.setBackgroundTexture(leaderboardBaseLabel, FC.LEADERBOARD_FINAL_LAP)
            else:
                ac.setText(lapCountTimerLabel, "%d / %d" % (lc, info.graphics.numberOfLaps))

            # ===========================
            # CALCULATE TIME DIFERENCES
            dPosition = sorted(drivers, key=lambda x: x.position)
            if LeaderboardRow.update_type == INFO_TYPE.GAPS:
                for i in range(1, len(dPosition)):
                    driver_ahead, driver = dPosition[i-1], dPosition[i]
                    timeDiff = driver.split_times[driver.current_split - 1] - driver_ahead.split_times[driver.current_split - 1]
                    if timeDiff < 0: continue # ignore these times, happens on overtakes
                    if driver.position > totalDrivers: continue # might try to update before it is possible
                    driver.timeDiff = timeDiff
                    if timeDiff > 60:
                        leaderboard[driver.position].update_time("+1 MIN")
                    else:
                        leaderboard[driver.position].update_time("+" + time_to_string(timeDiff*1000))
                leaderboard[0].update_time("Interval") # Force it
            elif LeaderboardRow.update_type == INFO_TYPE.POSITIONS:
                for d in dPosition:
                    posDiff = d.starting_position - d.position - 1
                    leaderboard[d.position].update_positions(posDiff)

            # ============================
            # MARK FASTEST LAP
            if lc > FC.FASTEST_LAP_STARTING_LAP:
                for d in drivers:
                    lap = ac.getCarState(d.id, acsys.CS.BestLap)
                    if lap != 0 and lap < fastest_lap:
                        fastest_lap = lap
                        fastest_lap_banner.show(lap, ac.getDriverName(d.id))
                        LeaderboardRow.FASTEST_LAP_ID = d.id
                        if replay_file:
                            write_fastest_lap(replay_file, info.graphics.completedLaps, info.graphics.iCurrentTime, d, fastest_lap)
                for row in leaderboard:
                    row.mark_fastest_lap()

            # ============================
            # PITS MARKER
            for row in leaderboard:
                if ac.isCarInPitline(row.driverId) == 1:
                    row.mark_enter_pits()
                    drivers[row.driverId].tyre = ac.getCarTyreCompound(row.driverId) # maybe will change tyre
                else:
                    row.mark_left_pits()
                if time.time() - drivers[row.driverId].pit_time > 20 and ac.isCarInPit(row.driverId):
                    drivers[row.driverId].pits += 1
                    drivers[row.driverId].pit_time = time.time()

            # ============================
            # CHANGE CAR FOCUS AND DRIVER WIDGET
            if race_started:
                id = ac.getFocusedCar()
                if drivers[id].position <= totalDrivers: # in case it wasnt updated yet
                    driverWidget.show(id, drivers[id].position, drivers[id].starting_position, drivers[id].tyre, drivers[id].pits)
                    if drivers[id].position == 0:
                        driverComparisonWidget.hide()
                    else:
                        for d in drivers: # find driver ahead
                            if d.position == drivers[id].position - 1:
                                driverComparisonWidget.show(d.id, d.position, id, drivers[id].position, drivers[id].timeDiff*1000)
                                break
            else:
                driverWidget.hide()
                driverComparisonWidget.hide()

            # ========================================================
            # SAVE DRIVER STATUS IN A FILE TO LOAD ON REPLAY
            if replay_file:
                write_driver_info(replay_file, info.graphics.completedLaps, info.graphics.iCurrentTime, drivers)
            # ========================================================


    # ================================================================
    #                        QUALIFY / PRACTICE
    # ================================================================
    elif info.graphics.session == 1 or (info.graphics.session == 0 and info.graphics.status != 1):

        # 3 times per second
        if timer1 > 0.3:
            # =============================================
            # QUALIFY RESTART
            if quali_started and qualify_session_time - info.graphics.sessionTimeLeft < 1:
                quali_started = False

            # =============================================
            # QUALIFY START
            if not quali_started:
                ac.setBackgroundTexture(leaderboardBaseLabel, FC.LEADERBOARD_BASE_QUALI)
                if (info.graphics.session == 0 and info.graphics.status != 0):
                    ac.setBackgroundTexture(leaderboardBaseLabel, FC.LEADERBOARD_BASE_PRACTICE)
                ac.setFontColor(lapCountTimerLabel, 0.86, 0.86, 0.86, 1)
                qualify_session_time = info.graphics.sessionTimeLeft
                fastest_lap = MAX_LAP_TIME
                LeaderboardRow.FASTEST_LAP_ID = -1
                quali_started = True
                race_started = False

            # =============================================
            # SAVE BEST LAPS FOR EACH DRIVER
            for i in range(totalDrivers):
                lap = ac.getCarState(i, acsys.CS.BestLap)
                if lap != 0:
                    drivers[i].best_lap = lap
                if lap != 0 and lap < fastest_lap:
                    fastest_lap = lap
                    fastest_lap_banner.show(lap, ac.getDriverName(i))

                # MARK IN/OUT DRIVERS
                connected = ac.isConnected(i)
                if connected == 0: # mark unconnected drivers
                    drivers[i].out = True
                else:
                    drivers[i].out = False
                
            # =============================================
            # MANAGE LEADERBOARD

            # Sorting: sort drivers by this order 1. in or out drivers, 2. best lap, 3. driver id
            dPosition = sorted(drivers, key=lambda d: (d.out, d.best_lap, d.id))

            for i in range(totalDrivers):
                if dPosition[i].out:
                    leaderboard[i].mark_out()
                else:
                    leaderboard[i].mark_in()

                leaderboard[i].update_name(dPosition[i].id)
                if dPosition[i].best_lap == MAX_LAP_TIME:
                    leaderboard[i].update_time("NO TIME")
                elif i == 0:
                    leaderboard[i].update_time(time_to_string(dPosition[i].best_lap))
                else:
                    timeDiff = dPosition[i].best_lap - dPosition[0].best_lap
                    if timeDiff > 60000:
                        leaderboard[i].update_time("+1 MIN")
                    else:
                        leaderboard[i].update_time("+" + time_to_string(timeDiff))

                # OVERTAKES
                if i != dPosition[i].position: # there was an overtake on this driver
                    dPosition[i].timer = FC.OVERTAKE_POSITION_LABEL_TIMER
                    if i < dPosition[i].position:
                        leaderboard[i].mark_green_position()
                    elif i > dPosition[i].position:
                        leaderboard[i].mark_red_position()
                elif dPosition[i].timer <= 0:
                    leaderboard[i].mark_white_position()
                else:
                    dPosition[i].timer -= timer1
                dPosition[i].position = i
                # END OVERTAKE

            # ============================
            # FASTEST LAP BANNER TIMER
            if fastest_lap_banner.timer > 0:
                fastest_lap_banner.timer -= timer1
                fastest_lap_banner.hide()

            timer1 = 0

        # Once per second
        if timer0 > 1:
            timer0 = 0
            ac.setBackgroundOpacity(leaderboardWindow, 0)
            ac.setBackgroundOpacity(driverWidget.window, 0)
            ac.setBackgroundOpacity(driverComparisonWidget.window, 0)
            ac.setBackgroundOpacity(fastest_lap_banner.window, 0)

            if quali_started:
                if info.graphics.sessionTimeLeft < 0:
                    ac.setText(lapCountTimerLabel, "0:00")
                else:
                    timeText = time_to_string(info.graphics.sessionTimeLeft)[:-4]
                    ac.setText(lapCountTimerLabel, "0:00"[:-len(timeText)] + timeText)
                if info.graphics.sessionTimeLeft < qualify_session_time / 5:
                    ac.setFontColor(lapCountTimerLabel, 1,0,0,1)

            driverWidget.hide()
            driverComparisonWidget.hide()


    # ================================================================
    #                            REPLAYS
    # ================================================================
    elif info.graphics.status == 1:

        # three times per second
        if timer1 > 0.3:
            if not replay_started:
                if info.graphics.iCurrentTime > 0:
                    replay_data = load_replay_file(drivers)
                    replay_started = True

            # ============================
            # FASTEST LAP BANNER TIMER
            if fastest_lap_banner.timer > 0:
                fastest_lap_banner.timer -= timer1
                fastest_lap_banner.hide()

            # ============================
            # GET DATA FOR THIS UPDATE
            if replay_data:
                new_positions = lookup_data(info.graphics.completedLaps, info.graphics.iCurrentTime, replay_data, drivers)

                # ============================
                # POSITION UPDATE
                for i in range(totalDrivers):
                    pos = new_positions[i]
                    if drivers[i].out: # mark unconnected drivers
                        leaderboard[pos].mark_out()
                    else:
                        leaderboard[pos].mark_in()
                    leaderboard[pos].update_name(i)

                    # OVERTAKE
                    if pos != drivers[i].position: # there was an overtake
                        drivers[i].timer = FC.OVERTAKE_POSITION_LABEL_TIMER # set timer
                        if pos < drivers[i].position:
                            leaderboard[pos].mark_green_position()
                        elif pos > drivers[i].position:
                            leaderboard[pos].mark_red_position()
                    elif drivers[i].timer <= 0:
                        leaderboard[pos].mark_white_position()
                    else:
                        drivers[i].timer -= timer1
                    drivers[i].position = pos
                    # END OVERTAKE

            timer1 = 0

        # Once per second
        if timer0 > 1:
            timer0 = 0
            ac.setBackgroundOpacity(leaderboardWindow, 0)
            ac.setBackgroundOpacity(driverWidget.window, 0)
            ac.setBackgroundOpacity(driverComparisonWidget.window, 0)
            ac.setBackgroundOpacity(fastest_lap_banner.window, 0)

            # ============================
            # GET FASTEST LAP UPDATE
            if replay_data:
                fl_data = lookup_fastest_lap(info.graphics.completedLaps, info.graphics.iCurrentTime, replay_data)
                if fl_data:
                    display_time = FC.FASTEST_LAP_DISPLAY_TIME - (info.graphics.iCurrentTime - fl_data[0]) / 1000
                    fastest_lap_banner.show(fl_data[2], ac.getDriverName(fl_data[1]), timer=display_time) # display only for the time left

            # ============================
            # SERVER LAP
            if replay_data:
                lc = max((drivers[i].current_lap for i in range(totalDrivers))) + 1
                if lc >= replay_data['nLaps']:
                    ac.setVisible(lapCountTimerLabel, 0)
                    ac.setBackgroundTexture(leaderboardBaseLabel, FC.LEADERBOARD_FINAL_LAP)
                else:
                    ac.setText(lapCountTimerLabel, "%d / %d" % (lc, replay_data['nLaps']))
                    ac.setVisible(lapCountTimerLabel, 1)
                    ac.setBackgroundTexture(leaderboardBaseLabel, FC.LEADERBOARD_BASE_RACE)

            # ============================
            # PITS MARKER
            for row in leaderboard:
                if ac.isCarInPitline(row.driverId) == 1:
                    row.mark_enter_pits()
                else:
                    row.mark_left_pits()

            # ============================
            # DRIVER WIDGET UPDATE
            if replay_started:
                id = ac.getFocusedCar()
                if drivers[id].position <= totalDrivers: # in case it wasnt updated yet
                    driverWidget.show(id, drivers[id].position, drivers[id].starting_position, drivers[id].tyre, drivers[id].pits)
                    if drivers[id].position == 0:
                        driverComparisonWidget.hide()
                    else:
                        for d in drivers: # find driver ahead
                            if d.position == drivers[id].position - 1:
                                driverComparisonWidget.show(d.id, d.position, id, drivers[id].position, drivers[id].timeDiff*1000)
                                break
            else:
                driverWidget.hide()
                driverComparisonWidget.hide()

            # ============================
            # UPDATE TIMES
            if replay_data:
                for row in leaderboard:
                    if LeaderboardRow.update_type == INFO_TYPE.GAPS:
                        row.update_time("+" + time_to_string(drivers[row.driverId].timeDiff*1000))
                        if row.row == 0:
                            row.update_time("Interval") # Force it
                    elif LeaderboardRow.update_type == INFO_TYPE.POSITIONS:
                        posDiff = drivers[row.driverId].starting_position - drivers[row.driverId].position - 1
                        row.update_positions(posDiff)
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
Exemple #32
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)
Exemple #33
0
 def mark_white_position(self):
     if self.out or self.positionLabelId == 0: return  # no need to update
     ac.setBackgroundTexture(self.positionLabel,
                             FC.LEADERBOARD_POSITION_LABEL[self.row + 1])
     self.positionLabelId = 0
 def bg_texture(self, value):
     self._bg_texture = value
     if value:
         ac.setBackgroundTexture(self.id, self._bg_texture)
Exemple #35
0
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"
Exemple #36
0
def Option5Event(name, state):
    global Option5, Tires, Tirecoord, Resolution

    Tires = "Option5"
    Tirecoord = int(Resolution / 2 + 353)
    ac.setBackgroundTexture(NoChange, "content/gui/pitstop/tyre_no_change_OFF.png")
    ac.setBackgroundTexture(Option1, "content/gui/pitstop/tyre_1_OFF.png")
    ac.setBackgroundTexture(Option2, "content/gui/pitstop/tyre_2_OFF.png")
    ac.setBackgroundTexture(Option3, "content/gui/pitstop/tyre_3_OFF.png")
    ac.setBackgroundTexture(Option4, "content/gui/pitstop/tyre_4_OFF.png")
    ac.setBackgroundTexture(Option5, "content/gui/pitstop/tyre_5_ON.png")
def acMain(ac_version):
	global imperial, debug_mode, window_x_pos, window_y_pos, tyre_mon_xpos, tyre_mon_ypos
	global gear_color, gear_background, speed_color, speed_background, throttle_gauge_color, brake_gauge_color, clutch_gauge_color, boost_bar_color, fuel_bar_color
	global draw_digital_speedo, draw_shift_light, draw_gear_indicator, draw_speedometer, draw_tachometer, draw_odometer, draw_g_meter, draw_boost_gauge
	global draw_fuel_gauge, draw_throttle_gauge, draw_brake_gauge, draw_clutch_gauge, draw_tyre_monitor, draw_background
	global tach_needle_end, speedo_needle_end, tach_radius, speedo_radius, rpm_pivot_y, speed_pivot_y, rpm_pivot_x, speed_pivot_x, speedo_tl_x, speedo_tl_y
	global speedo_total_width, speedo_total_height
	global tach_redline_color, tach_bigline_color, tach_smallline_color, tach_needle_color1
	global speedo_bigline_color, speedo_smallline_color, speedo_needle_color1
	global throttle_gauge_inner_radius, throttle_gauge_outer_radius, throttle_gauge_min_y, throttle_gauge_max_y
	global brake_gauge_inner_radius, brake_gauge_outer_radius, brake_gauge_min_y, brake_gauge_max_y
	global clutch_gauge_inner_radius, clutch_gauge_outer_radius, clutch_gauge_min_y, clutch_gauge_max_y
	global throttle_gauge_root_x, throttle_gauge_root_y
	global brake_gauge_root_x, brake_gauge_root_y
	global clutch_gauge_root_x, clutch_gauge_root_y
	global throttle_gauge_right, brake_gauge_right, clutch_gauge_right
	global boost_radius, fuel_radius, boost_pivot_y, fuel_pivot_y, boost_pivot_x, fuel_pivot_x, boost_needle_end, fuel_needle_end, boost_needle_color, fuel_needle_color
	global odometer_fg, odometer_bg, g_meter_range, g_meter_x_anchor, g_meter_y_anchor, g_meter_opacity, window_width, window_height, background_image_path, background_image_path_noboost
	global tyre_monitor_opacity, g_meter_opacity
	global window, debug_label, indicated_max_rpm
	global flt_label1, frt_label1, rlt_label1, rrt_label1
	global flt_label2, frt_label2, rlt_label2, rrt_label2
	global fuel_warning_label
	global config
	global telemetry_client
	global draw_abs_status, draw_tcs_status, abs_label, abs_off_label, tcs_label, tcs_off_label
	global gear_x, gear_y, shift_light_x, shift_light_y, shift_light_radius, gear_width, gear_height
	global tach_min_angle, tach_max_angle, speedo_min_angle, speedo_max_angle
	global shift_light_on_color, shift_light_off_color
	global rpms_file
	config_file = configparser.ConfigParser()
	config_file.read('apps/python/AnalogInstruments/settings.ini')
	config = config_file[config_file['settings']['theme']]
	rpms_file = configparser.ConfigParser()
	rpms_file.read('apps/python/AnalogInstruments/rpms.ini')

	# SETTINGS #

	# Change this to 'True' to have speed measured in MPH
	imperial = config.getboolean('imperial')
	# Debug mode (basically just some numbers)
	debug_mode = config.getboolean('debug_mode')
	# Main window positions, change those if you're not using a single monitor 1080p setup
	window_x_pos  = int(config['window_x_pos'])# (Your horz. res-1320)/2
	window_y_pos  = int(config['window_y_pos']) # Your vert. res - 250
	# These are relative to the window's position
	tyre_mon_xpos = int(config['tyre_mon_x_pos'])# 20 px from the left on single mon 1080p
	tyre_mon_ypos = int(config['tyre_mon_y_pos'])# 920 px from the top
	# Color settings
	gear_color           = parse_color(config['gear_color'])
	gear_background      = parse_color(config['gear_background'])
	speed_color          = parse_color(config['digi_speedo_color'])
	speed_background     = parse_color(config['digi_speedo_background'])
	throttle_gauge_color = parse_color(config['throttle_gauge_color'])
	brake_gauge_color    = parse_color(config['brake_gauge_color'])
	clutch_gauge_color   = parse_color(config['clutch_gauge_color'])
	boost_bar_color      = parse_color(config['boost_bar_color']) 
	fuel_bar_color       = parse_color(config['fuel_bar_color'])
	shift_light_on_color = parse_color(config['shift_light_on_color'])
	shift_light_off_color = parse_color(config['shift_light_off_color'])
	# Some more settings, hopefully pretty self-explanatory
	draw_digital_speedo = config.getboolean('draw_digital_speedo')
	draw_shift_light    = config.getboolean('draw_shift_light')
	draw_gear_indicator = config.getboolean('draw_gear_indicator')
	draw_speedometer    = config.getboolean('draw_speedometer')
	draw_tachometer     = config.getboolean('draw_tachometer')
	draw_odometer       = config.getboolean('draw_odometer')
	draw_g_meter        = config.getboolean('draw_g_meter')
	draw_boost_gauge    = config.getboolean('draw_boost_gauge')
	draw_fuel_gauge     = config.getboolean('draw_fuel_gauge')
	draw_throttle_gauge = config.getboolean('draw_throttle_gauge')
	draw_brake_gauge    = config.getboolean('draw_brake_gauge')
	draw_clutch_gauge   = config.getboolean('draw_clutch_gauge')
	draw_tyre_monitor   = config.getboolean('draw_tyre_monitor')
	draw_background     = config.getboolean('draw_background')
	draw_abs_status     = config.getboolean('draw_abs_status')
	draw_tcs_status     = config.getboolean('draw_tcs_status')

	# Dimensions of things, mess with those at your own risk
	tach_needle_end     = int(config['tach_needle_end'])
	speedo_needle_end   = int(config['speedo_needle_end'])
	tach_radius         = int(config['tach_radius'])
	speedo_radius       = int(config['speedo_radius'])
	rpm_pivot_y         = int(config['tach_y_anchor'])
	speed_pivot_y       = int(config['speedo_y_anchor'])
	rpm_pivot_x         = int(config['tach_x_anchor'])
	speed_pivot_x       = int(config['speedo_x_anchor'])
	speedo_tl_x         = int(config['digi_speedo_x'])
	speedo_tl_y         = int(config['digi_speedo_y'])
	speedo_total_width  = int(config['digi_speedo_width'])
	speedo_total_height = int(config['digi_speedo_height'])
	tach_min_angle      = int(config['tach_min_angle'])
	tach_max_angle      = int(config['tach_max_angle'])
	speedo_min_angle    = int(config['speedo_min_angle'])
	speedo_max_angle    = int(config['speedo_max_angle'])

	tach_redline_color = parse_color(config['tach_redline_color'])
	tach_bigline_color = parse_color(config['tach_bigline_color'])
	tach_smallline_color = parse_color(config['tach_smallline_color'])
	tach_needle_color1 = parse_color(config['tach_needle_color1'])

	speedo_bigline_color = parse_color(config['speedo_bigline_color'])
	speedo_smallline_color = parse_color(config['speedo_smallline_color'])
	speedo_needle_color1 = parse_color(config['speedo_needle_color1'])

	# G-Meter: 500-820
	# Brake/Throttle Max Y: 70 Min: 160
	throttle_gauge_inner_radius = int(config['throttle_gauge_inner_radius'])
	throttle_gauge_outer_radius = int(config['throttle_gauge_outer_radius'])
	throttle_gauge_min_y        = int(config['throttle_gauge_min_y'])
	throttle_gauge_max_y        = int(config['throttle_gauge_max_y'])
	throttle_gauge_root_x       = int(config['throttle_gauge_root_x'])
	throttle_gauge_root_y       = int(config['throttle_gauge_root_y'])
	throttle_gauge_right        = config.getboolean('throttle_gauge_right')
	
	brake_gauge_inner_radius = int(config['brake_gauge_inner_radius'])
	brake_gauge_outer_radius = int(config['brake_gauge_outer_radius'])
	brake_gauge_min_y        = int(config['brake_gauge_min_y'])
	brake_gauge_max_y        = int(config['brake_gauge_max_y'])
	brake_gauge_root_x       = int(config['brake_gauge_root_x'])
	brake_gauge_root_y       = int(config['brake_gauge_root_y'])
	brake_gauge_right        = config.getboolean('brake_gauge_right')
	
	clutch_gauge_inner_radius = int(config['clutch_gauge_inner_radius'])
	clutch_gauge_outer_radius = int(config['clutch_gauge_outer_radius'])
	clutch_gauge_min_y        = int(config['clutch_gauge_min_y'])
	clutch_gauge_max_y        = int(config['clutch_gauge_max_y'])
	clutch_gauge_root_x       = int(config['clutch_gauge_root_x'])
	clutch_gauge_root_y       = int(config['clutch_gauge_root_y'])
	clutch_gauge_right        = config.getboolean('clutch_gauge_right')


	boost_radius     = int(config['boost_radius'])
	fuel_radius      = int(config['fuel_radius'])
	boost_pivot_y    = int(config['boost_y_anchor'])
	fuel_pivot_y     = int(config['fuel_y_anchor'])
	boost_pivot_x    = int(config['boost_x_anchor'])
	fuel_pivot_x     = int(config['fuel_x_anchor'])
	boost_needle_end = int(config['boost_needle_end'])
	fuel_needle_end  = int(config['fuel_needle_end'])
	boost_needle_color = parse_color(config['boost_needle_color'])
	fuel_needle_color = parse_color(config['fuel_needle_color'])


	odometer_fg = parse_color(config['odometer_foreground'])
	odometer_bg = parse_color(config['odometer_background'])

	tyre_monitor_opacity = float(config['tyre_monitor_opacity'])

	g_meter_range = int(config['g_meter_range'])
	g_meter_x_anchor = int(config['g_meter_x_anchor'])
	g_meter_y_anchor = int(config['g_meter_y_anchor'])
	g_meter_opacity = float(config['g_meter_opacity'])
	
	gear_x = int(config['gear_x'])
	gear_y = int(config['gear_y'])
	gear_width = int(config['gear_width'])
	gear_height = int(config['gear_height'])
	shift_light_x = int(config['shift_light_x'])
	shift_light_y = int(config['shift_light_y'])
	shift_light_radius = int(config['shift_light_radius'])

	# Kind of configurable but you'll have change most of the dimensions above so not recommended
	window_width  = int(config['window_width'])
	window_height = int(config['window_height'])
	background_image_path = config['background_path']
	background_image_path_noboost = config['background_noboost_path']
	abs_img = config['abs_img']
	abs_off_img = config['abs_off_img']
	tcs_img = config['tcs_img']
	tcs_off_img = config['tcs_off_img']
	window = ac.newApp("AnalogInstruments")
	ac.setTitle(window," ")
	ac.setBackgroundOpacity(window,0)
	ac.drawBorder(window,0)
	ac.setIconPosition(window,0,-10000)
	if draw_background:
		ac.drawBackground(window,1)
		ac.setBackgroundTexture(window,background_image_path)
	ac.setSize(window,window_width,window_height)
	ac.setPosition(window,window_x_pos,window_y_pos)
	debug_label = ac.addLabel(window,"")
	ac.setPosition(debug_label,20,window_height/10*9)
	ac.addRenderCallback(window,onWindowRender)
	# Setting up the tyre monitor labels (this can be done here because it doesn't depend on any car info)
	if draw_tyre_monitor:
		flt_label1 = ac.addLabel(window," ")
		ac.setPosition(flt_label1,tyre_mon_xpos+37,tyre_mon_ypos+5)
		flt_label2 = ac.addLabel(window," ")
		ac.setPosition(flt_label2,tyre_mon_xpos+37,tyre_mon_ypos+37)
		frt_label1 = ac.addLabel(window," ")
		ac.setPosition(frt_label1,tyre_mon_xpos+117,tyre_mon_ypos+5)
		frt_label2 = ac.addLabel(window," ")
		ac.setPosition(frt_label2,tyre_mon_xpos+117,tyre_mon_ypos+37)
		rlt_label1 = ac.addLabel(window," ")
		ac.setPosition(rlt_label1,tyre_mon_xpos+37,tyre_mon_ypos+101)
		rlt_label2 = ac.addLabel(window," ")
		ac.setPosition(rlt_label2,tyre_mon_xpos+37,tyre_mon_ypos+133)
		rrt_label1 = ac.addLabel(window," ")
		ac.setPosition(rrt_label1,tyre_mon_xpos+117,tyre_mon_ypos+101)
		rrt_label2 = ac.addLabel(window," ")
		ac.setPosition(rrt_label2,tyre_mon_xpos+117,tyre_mon_ypos+133)
	if draw_fuel_gauge:
		fuel_warning_label = ac.addLabel(window,"")
		ac.setSize(fuel_warning_label,12,14)
		ac.setPosition(fuel_warning_label,fuel_pivot_x - 6,fuel_pivot_y - 30)
		ac.setBackgroundTexture(fuel_warning_label,fuel_icon_warning_path)
	if draw_abs_status:
		abs_label = ac.addLabel(window,"")
		ac.setSize(abs_label,window_width,window_height)
		ac.setPosition(abs_label,0,0)
		ac.setBackgroundTexture(abs_label,abs_img)
		abs_off_label = ac.addLabel(window,"")
		ac.setSize(abs_off_label,window_width,window_height)
		ac.setPosition(abs_off_label,0,0)
		ac.setBackgroundTexture(abs_off_label,abs_off_img)
	if draw_tcs_status:
		tcs_label = ac.addLabel(window,"")
		ac.setSize(tcs_label,window_width,window_height)
		ac.setPosition(tcs_label,0,0)
		ac.setBackgroundTexture(tcs_label,tcs_img)
		tcs_off_label = ac.addLabel(window,"")
		ac.setSize(tcs_off_label,window_width,window_height)
		ac.setPosition(tcs_off_label,0,0)
		ac.setBackgroundTexture(tcs_off_label,tcs_off_img)
	return "Analog Instruments"
def acMain(ac_version):
    global DRS_ALLOWED_CARS, SOUND_ON, SERVERS
    global tyreLabels, tyrePressureLabels
    global drsLabel, ersLabel, ersModeLabel, ersRecoveryLabel, fuelLabel, drsPenaltyLabel, drsPenaltyBackgroundLabel

    global drsZones, totalDrivers, trackLength, drsAvailableZones, driversList

    global carValue, trackConfigValue, trackValue

    global compounds, modCompounds

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

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

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

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

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

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

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

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

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

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

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

    #position all the labels
    tlpx = 180
    tlpy = 10

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

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

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

    elpx = 15
    elpy = 10

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

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

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

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

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

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

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

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

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

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

    return APP_NAME
Exemple #39
0
def Option5Event(name, state):
    global Option5, Tires, Tirecoord, Resolution

    Tires = "Option5"
    Tirecoord = int(Resolution / 2 + 353)
    ac.setBackgroundTexture(NoChange,
                            "content/gui/pitstop/tyre_no_change_OFF.png")
    ac.setBackgroundTexture(Option1, "content/gui/pitstop/tyre_1_OFF.png")
    ac.setBackgroundTexture(Option2, "content/gui/pitstop/tyre_2_OFF.png")
    ac.setBackgroundTexture(Option3, "content/gui/pitstop/tyre_3_OFF.png")
    ac.setBackgroundTexture(Option4, "content/gui/pitstop/tyre_4_OFF.png")
    ac.setBackgroundTexture(Option5, "content/gui/pitstop/tyre_5_ON.png")
def set_drs_available():
    global drsLabel
    ac.setBackgroundTexture(drsLabel, DRS_AVAILABLE_TEXTURE)
    ac.setVisible(drsLabel, 1)
Exemple #41
0
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 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 set_drs_possible():
    global drsLabel
    ac.setBackgroundTexture(drsLabel, DRS_POSSIBLE_TEXTURE)
    ac.setVisible(drsLabel, 1)
Exemple #44
0
	def setBgTexture(self, texture):
		self.bgTexture = texture
		ac.setBackgroundTexture(self.label, self.bgTexture)
		return self
def set_drs_good():
    global drsLabel
    ac.setBackgroundTexture(drsLabel, DRS_GOOD_TEXTURE)
    ac.setVisible(drsLabel, 1)
Exemple #46
0
def acMain(ac_version):
    global appWindow,FuelSelection,label1,label2,label3,NoChange,SuperSoft
    global SoftSlick,MediumSlick,HardSlick,SuperHard,Body,Engine,Suspension
    global DoOnce,ahk,response

    if DoOnce == 0:
    	ahk = subprocess.Popen(["apps\python\PitVoice\Pitvoice.exe"])
    	DoOnce = 1
    	
    #
    appWindow = ac.newApp("PitVoice")
    ac.setSize(appWindow,350,250)
    ac.setTitle(appWindow,"")
    ac.setBackgroundOpacity(appWindow,0.5)
    ac.setBackgroundTexture(appWindow,"apps/python/PitVoice/PitMenu.png")
    #
    FuelSelection = ac.addSpinner(appWindow,"")#Fuel
    ac.setPosition(FuelSelection,87,110)
    ac.setSize(FuelSelection,175,25)
    ac.setFontColor(FuelSelection,1,1,0,1)
    ac.setFontSize(FuelSelection, 15)
    ac.setRange(FuelSelection,0,190)
    ac.setStep(FuelSelection,1)
    ac.addOnValueChangeListener(FuelSelection,FuelEvent)
    #
    NoChange = ac.addCheckBox(appWindow,"")
    ac.setPosition(NoChange,22,86)
    ac.setSize(NoChange,15,15)
    ac.addOnCheckBoxChanged(NoChange,NoChangeEvent)
    #
    SuperSoft = ac.addCheckBox(appWindow,"")
    ac.setPosition(SuperSoft,82,86)
    ac.setSize(SuperSoft,15,15)
    ac.addOnCheckBoxChanged(SuperSoft,SuperSoftEvent)
    #
    SoftSlick = ac.addCheckBox(appWindow,"")
    ac.setPosition(SoftSlick,138,86)
    ac.setSize(SoftSlick,15,15)
    ac.addOnCheckBoxChanged(SoftSlick,SoftSlickEvent)
    #
    MediumSlick = ac.addCheckBox(appWindow,"")
    ac.setPosition(MediumSlick,197,86)
    ac.setSize(MediumSlick,15,15)
    ac.addOnCheckBoxChanged(MediumSlick,MediumSlickEvent)
    #
    HardSlick = ac.addCheckBox(appWindow,"")
    ac.setPosition(HardSlick,255,86)
    ac.setSize(HardSlick,15,15)
    ac.addOnCheckBoxChanged(HardSlick,HardSlickEvent)
    #
    SuperHard = ac.addCheckBox(appWindow,"")
    ac.setPosition(SuperHard,313,86)
    ac.setSize(SuperHard,15,15)
    ac.addOnCheckBoxChanged(SuperHard,SuperHardEvent)
    #
    Body = ac.addCheckBox(appWindow,"")
    ac.setPosition(Body,59,229)
    ac.setSize(Body,15,15)
    ac.addOnCheckBoxChanged(Body,BodyEvent)
    #
    Engine = ac.addCheckBox(appWindow,"")
    ac.setPosition(Engine,169,229)
    ac.setSize(Engine,15,15)
    ac.addOnCheckBoxChanged(Engine,EngineEvent)
    #
    Suspension = ac.addCheckBox(appWindow,"")
    ac.setPosition(Suspension,276,229)
    ac.setSize(Suspension,15,15)
    ac.addOnCheckBoxChanged(Suspension,SuspensionEvent)
    #
    label1=ac.addLabel(appWindow,"Fuel +")
    ac.setPosition(label1,275,113)
    ac.setFontColor(label1,1,1,0,1)
    ac.setFontSize(label1, 15)
    #
    label2=ac.addLabel(appWindow,"Fuel -")
    ac.setPosition(label2,30,113)
    ac.setFontColor(label2,1,1,0,1)
    ac.setFontSize(label2, 15)
    #
    label3=ac.addLabel(appWindow,"0")
    ac.setPosition(label3,166,110)
    ac.setFontColor(label3,1,1,0,0)
    ac.setFontSize(label3, 15)
    # 

    ResponseWit()
    return "PitVoice"