コード例 #1
0
    def setValue(self, value, deltaT, optimal):
        global Options

        try:
            self.value = value
            deg = math.degrees(self.value)
            #~ otherdeg = math.degrees(othervalue)
            #~ diff = deg - otherdeg
            ac.setText(self.valueLabel, "{0:.3f}°".format(deg))
            #~ text = getGripFactor(Options["dcamber0"], Options["dcamber1"], value)
            #~ ac.setText(self.valueLabel,"{0:.1f}%".format(text)

            self.color = getColor(deg, optimal)
            self.serie.append({"value": deg, "color": self.color})

            serieSum = 0
            for s in self.serie:
                serieSum += s["value"]
            self.avgValue = serieSum / len(self.serie)
            ac.setFontColor(self.avgValueLabel, self.color['r'],
                            self.color['g'], self.color['b'], self.color['a'])
            ac.setText(self.avgValueLabel, "{0:.3f}°".format(self.avgValue))
        except Exception:
            ac.log("CamberExtravaganza ERROR: setValue(): %s" %
                   traceback.format_exc())
コード例 #2
0
 def setFontColor(self, red, green, blue, alpha):
     self.labelFontColor["red"] = red
     self.labelFontColor["green"] = green
     self.labelFontColor["blue"] = blue
     self.labelFontColor["alpha"] = alpha
     ac.setFontColor(self.label, self.labelFontColor["red"],self.labelFontColor["green"],self.labelFontColor["blue"],self.labelFontColor["alpha"])
     return self
コード例 #3
0
    def text_color(self, text_color):
        self._text_color = text_color

        if self._ac_obj is not None:
            ac.setFontColor(self._ac_obj, self._text_color.r,
                            self._text_color.g, self._text_color.b,
                            self._text_color.a)
コード例 #4
0
ファイル: ac_label.py プロジェクト: fzalm/ac-blueprint
    def set_color(self, color):
        """Set Color for Label.

        Args:
            color (tuple): r,g,b,a on a 0-1 scale.
        """
        ac.setFontColor(self.id, color[0], color[1], color[2], color[3])
コード例 #5
0
    def _update_delta_label(self, time_delta, position, bar_moves):
        """
    Updates delta label with new value if needed.
    :param time_delta: time delta value
    :param position: x coordinate of label center
    """
        plus = '-' if time_delta < 0 else '+'
        # NOTE: The below .format()s are too much magic.
        #       We want 234 to be '0.23' and 12345 to be '12.34'
        ms = '{:04d}'.format(abs(int(time_delta)))
        label_text = '{}{}{}.{}'.format(plus, self.data.star, ms[0:-3],
                                        ms[-3:-1])
        label_changed = self.label_tracker.should_update(label_text)

        if not label_changed:
            # bail out, do not change the actual label (and do not move it)
            return

        font_color = self._delta_label_color(time_delta)
        ac.setFontColor(self.data.delta_label, *font_color)

        if bar_moves:
            if time_delta < 0:
                position = min(position - config.DELTA_LABEL_WIDTH_HALF,
                               config.BAR_WIDTH - config.DELTA_LABEL_WIDTH)
            else:
                position = max(0, position - config.DELTA_LABEL_WIDTH_HALF)
            self._set_delta_label_position(position)

        self.set_delta_label_text(label_text)
コード例 #6
0
  def _update_delta_label(self, time_delta, position, bar_moves):
    """
    Updates delta label with new value if needed.
    :param time_delta: time delta value
    :param position: x coordinate of label center
    """
    plus = '-' if time_delta < 0 else '+'
    # NOTE: The below .format()s are too much magic.
    #       We want 234 to be '0.23' and 12345 to be '12.34'
    ms = '{:04d}'.format(abs(int(time_delta)))
    label_text = '{}{}{}.{}'.format(plus, self.data.star, ms[0:-3], ms[-3:-1])
    label_changed = self.label_tracker.should_update(label_text)

    if not label_changed:
      # bail out, do not change the actual label (and do not move it)
      return

    font_color = self._delta_label_color(time_delta)
    ac.setFontColor(self.data.delta_label, *font_color)

    if bar_moves:
      if time_delta < 0:
        position = min(position - config.DELTA_LABEL_WIDTH_HALF,
                       config.BAR_WIDTH - config.DELTA_LABEL_WIDTH)
      else:
        position = max(0, position - config.DELTA_LABEL_WIDTH_HALF)
      self._set_delta_label_position(position)

    self.set_delta_label_text(label_text)
コード例 #7
0
    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)
コード例 #8
0
    def font_color(self, font_color):
        if isinstance(font_color, Color):
            self._font_color = font_color

        if self.ac_obj is not None:
            ac.setFontColor(self.ac_obj, self._font_color.r,
                            self._font_color.g, self._font_color.b,
                            self._font_color.a)
コード例 #9
0
 def mark_left_pits(self):
     if self.out or not self.pit: return
     self.pit = False
     if LeaderboardRow.update_type == INFO_TYPE.POSITIONS:
         ac.setVisible(self.positionChangeLabel, 1)
     if self.driverId == 0:
         ac.setText(self.infoLabel, "Interval")
     ac.setFontColor(self.infoLabel, 0.86, 0.86, 0.86, 1)
コード例 #10
0
    def draw(self, data, delta_t: float) -> None:
        psi = data.tire_p
        ac.setText(self.__lb, "{:3.1f} psi".format(psi))

        color = self.__calc.interpolate_color(psi)
        ac.setFontColor(self.__lb, color[0], color[1], color[2], color[3])
        self._back.color = color
        self._draw(Pressure.texture_id)
コード例 #11
0
  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)
コード例 #12
0
ファイル: classes.py プロジェクト: prunn/ACTV
	def animate(self):
		#adjust size +1
		self.adjustParam("w").adjustParam("h")		
		#adjust position +3
		self.adjustParam("x").adjustParam("y")	
		#adjust background
		self.adjustParam("br").adjustParam("bg").adjustParam("bb").adjustParam("o")		
		#adjust colors + 0.02
		self.adjustParam("r").adjustParam("g").adjustParam("b").adjustParam("a")
			
		#commit changes
		if self.params["x"].hasChanged() or self.params["y"].hasChanged():
			ac.setPosition(self.label, self.params["x"].value, self.params["y"].value)
		if self.params["w"].hasChanged() or self.params["h"].hasChanged():
			ac.setSize(self.label, self.params["w"].value, self.params["h"].value)
			if self.params["h"].value == 0:
				self.isVisible.setValue(False)
			else:
				self.isVisible.setValue(True)
		if self.params["br"].hasChanged() or self.params["bg"].hasChanged() or self.params["bb"].hasChanged():
			ac.setBackgroundColor(self.label, self.params["br"].value, self.params["bg"].value, self.params["bb"].value)			
			if self.f_params["o"].value > 0:			
				ac.setBackgroundOpacity(self.label, self.params["o"].value)
		if self.params["o"].hasChanged():	
			if self.params["o"].value == 0:
				self.isVisible.setValue(False)
			else:
				self.isVisible.setValue(True)
			changed=self.isVisible.hasChanged()
			if changed and self.params["o"].value > 0:
				self.setVisible(1)  
			elif changed:
				self.setVisible(0)
			#fg opacity
			ac.setBackgroundOpacity(self.label, self.params["o"].value)
			if self.params["o"].value >= 0.4 :
				self.isTextVisible.setValue(True)
			else:
				self.isTextVisible.setValue(False)
			if self.isTextVisible.hasChanged():
				if self.isTextVisible.value:
					ac.setText(self.label, self.text)
				else:
					ac.setText(self.label, "")
					
		if self.params["r"].hasChanged() or self.params["g"].hasChanged() or self.params["b"].hasChanged() or self.params["a"].hasChanged():
			ac.setFontColor(self.label, self.params["r"].value, self.params["g"].value, self.params["b"].value, self.params["a"].value)				
			if self.params["a"].value == 0:
				self.isVisible.setValue(False)
			else:
				self.isVisible.setValue(True)
			changed=self.isVisible.hasChanged()
			if changed and self.params["a"].value > 0:
				self.setVisible(1)  
			elif changed:
				self.setVisible(0)
コード例 #13
0
 def mark_in(self):
     if not self.out: return
     self.out = False
     if LeaderboardRow.update_type == INFO_TYPE.POSITIONS:
         ac.setVisible(self.positionChangeLabel, 1)
     ac.setVisible(self.positionLabel, 1)
     ac.setPosition(self.teamLabel, self.px + 47, self.py + 2)
     ac.setPosition(self.nameLabel, self.px + 65, self.py + 4)
     ac.setFontColor(self.nameLabel, 0.86, 0.86, 0.86, 1)
     ac.setFontColor(self.infoLabel, 0.86, 0.86, 0.86, 1)
コード例 #14
0
 def setFontColor(self, red, green, blue, alpha):
     self.labelFontColor["red"] = red
     self.labelFontColor["green"] = green
     self.labelFontColor["blue"] = blue
     self.labelFontColor["alpha"] = alpha
     ac.setFontColor(self.label, self.labelFontColor["red"],
                     self.labelFontColor["green"],
                     self.labelFontColor["blue"],
                     self.labelFontColor["alpha"])
     return self
コード例 #15
0
 def mark_out(self):
     if self.out: return
     self.out = True
     ac.setVisible(self.positionLabel, 0)
     ac.setVisible(self.positionChangeLabel, 0)
     ac.setPosition(self.teamLabel, self.px + 12, self.py + 2)
     ac.setPosition(self.nameLabel, self.px + 30, self.py + 4)
     ac.setFontColor(self.nameLabel, .58, .53, .53, 1)
     ac.setText(self.infoLabel, "OUT")
     ac.setFontColor(self.infoLabel, .58, .53, .53, 1)
コード例 #16
0
def acMain(ac_version):
    global appWindow, Labels, gearSpacing, fontSize, gears, PxPer1000RPM, RPMdivs
    appWindow = ac.newApp("Reventach")
    ac.setSize(appWindow, appWidth, appHeight)
    ac.drawBorder(appWindow, 0)
    ac.setBackgroundOpacity(appWindow, 0)
    ac.setIconPosition(appWindow, 0, -10000)
    ac.setTitle(appWindow, "")

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

    loadCarData()
    PxPer1000RPM = 1000 * appHeight / CarData["maxRPM"]
    RPMdivs = CarData["maxRPM"] // 10000 + 1
    #~ fontSize = PxPer1000RPM * 0.5 * RPMdivs
    fontSize = appHeight / 15

    y = appHeight - PxPer1000RPM * RPMdivs
    count = RPMdivs
    while y > -1:
        dx = (appHeight - y) / lineSlope
        Labels["rpmL" + str(count)] = ac.addLabel(appWindow, str(count))
        ac.setPosition(Labels["rpmL" + str(count)], dx - fontSize,
                       y - fontSize / 2)
        ac.setFontSize(Labels["rpmL" + str(count)], fontSize)
        ac.setFontAlignment(Labels["rpmL" + str(count)], "center")
        Labels["rpmR" + str(count)] = ac.addLabel(appWindow, str(count))
        ac.setPosition(Labels["rpmR" + str(count)], appWidth - dx + fontSize,
                       y - fontSize / 2)
        ac.setFontSize(Labels["rpmR" + str(count)], fontSize)
        ac.setFontAlignment(Labels["rpmR" + str(count)], "center")

        if y < PxPer1000RPM * RPMdivs - 1:
            ac.setFontColor(Labels["rpmL" + str(count)], 0.7, 0.0, 0.0, 0.9)
            ac.setFontColor(Labels["rpmR" + str(count)], 0.7, 0.0, 0.0, 0.9)

        y -= (PxPer1000RPM * RPMdivs)
        count += RPMdivs

    for n in range(CarData["totalGears"]):
        gears.insert(0, str(n + 1))

    gearSpacing = appHeight / (CarData["totalGears"] + 2)
    fontSize = gearSpacing * 0.8

    for n, c in enumerate(gears):
        Labels["gear" + c] = ac.addLabel(appWindow, c)
        ac.setPosition(Labels["gear" + c], appWidth / 2, (n * gearSpacing))
        ac.setFontSize(Labels["gear" + c], fontSize)
        ac.setFontAlignment(Labels["gear" + c], "center")

    ac.addRenderCallback(appWindow, onFormRender)
    return "Reventach"
コード例 #17
0
def updateButtons():
	global Options, Buttons
	for key, button in Buttons.items():
		if Options[key]:
			ac.setBackgroundColor(button, 1, 0, 0)
			ac.setFontColor(button, 1, 1, 1, 1)
			ac.setBackgroundOpacity(button, 1)
		else:
			ac.setBackgroundColor(button, 1, 1, 1)
			ac.setFontColor(button, 0, 0, 0, 1)
			ac.setBackgroundOpacity(button, 1)
コード例 #18
0
ファイル: ac_widget.py プロジェクト: styinx/ACLIB
    def font(self, font: Font):
        if font:
            if self._font:
                self._font.remove_observer(self)

            self._font = font
            self._font.add_observer(self)

            if self.has_id:
                ac.setFontSize(self.id, font.size)
                ac.setFontColor(self.id, font.color.r, font.color.g,
                                font.color.b, font.color.a)
                ac.setCustomFont(self.id, font.name, font.italic, font.bold)
コード例 #19
0
ファイル: InRaceChat.py プロジェクト: nosnickid/inracechat
    def initGui(self):
        width = 400
        height = (self.historySize * self.CHAT_LINE_HEIGHT)
        height += 40  # Title area
        height += 40  # Text input
        height += 10  # Padding between text input and messages

        ac.setSize(self.appWindow, width, height)
        ac.setPosition(self.textInput, 15, height - 40)
        ac.setSize(self.textInput, 360, 30)

        if self.firstLayout:
            ac.setPosition(self.shrinkButton, width - 50, 40)
            ac.setSize(self.shrinkButton, 20, 20)
            ac.setPosition(self.expandButton, width - 25, 40)
            ac.setSize(self.expandButton, 20, 20)
            self.firstLayout = False

        for row in self.labels:
            ac.setVisible(row['author'], 0)
            ac.setVisible(row['message'], 0)

        self.unusedLabels = self.labels

        self.labels = []
        nameX = 10
        nameWidth = 70

        messageX = nameX + nameWidth + 5

        labelY = 40

        for i in range(0, self.historySize):
            row = self.getUnusedRow()
            ac.setPosition(row['author'], nameX, labelY)
            ac.setSize(row['author'], nameWidth, 20)
            ac.setFontColor(row['author'], 1, 1, 0, 1)
            ac.setFontSize(row['author'], 12)
            ac.setFontAlignment(row['author'], "right")

            ac.setPosition(row['message'], messageX, labelY)
            ac.setSize(row['message'], width - messageX, 20)
            ac.setFontSize(row['message'], 12)

            ac.setVisible(row['author'], 1)
            ac.setVisible(row['message'], 1)

            self.labels.append(row)
            labelY += self.CHAT_LINE_HEIGHT

        self.update_messages()
コード例 #20
0
def displayRefresh():
    global messageList,messageLabel,offsetMessage
    lenList = len(messageList)
    for i in range(0,7):
        curr_mess = messageList[i+(lenList-7)-offsetMessage]
        if isinstance(curr_mess, tuple):
            message = curr_mess[0]
            ColorIndex = curr_mess[1]
            ac.setText(messageLabel[i], "{}".format(message))
            R = rangeColor(colors[ColorIndex][0])
            G = rangeColor(colors[ColorIndex][1])
            B = rangeColor(colors[ColorIndex][2])
            ac.setFontColor(messageLabel[i],R,G,B,1)
        else:
            ac.setText(messageLabel[i], "{}".format(curr_mess))
コード例 #21
0
    def draw(self, data, delta_t: float) -> None:
        self._draw()

        rpm = data.rpm
        ratio = min(rpm / data.max_rpm, 1.0)

        bar = copy.copy(self._box.rect)
        bar[2] *= ratio

        color = self.__calc.interpolate_color(rpm)
        ac.glColor4f(*color)
        ac.glQuad(*bar)

        ac.setFontColor(self.__lb, color[0], color[1], color[2], color[3])
        ac.setText(self.__lb, "{} RPM".format(rpm))
コード例 #22
0
ファイル: Display.py プロジェクト: wsracing-esports/RaceDash
 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
コード例 #23
0
def update_laptimes():
    """Update the laptimes labels with the laptimes from server."""
    if LAPTIMES.empty():
        return
    laptimes = LAPTIMES.get()
    for index, (label, laptime) in enumerate(zip(LAPTIME_LABELS, laptimes)):
        if str(laptime['user']) == AUTH['user']:
            ac.setFontColor(label, 0, 0, 1, 1)
            ac.setBackgroundColor(label, 0, 0, 0)
            ac.setBackgroundOpacity(label, 1)
        ac.setText(label, '#{} - {}'.format(index + 1, laptime['laptime']))

    for label in LAPTIME_LABELS[len(laptimes):]:  # clear rest of labels
        ac.setText(label, '')
    with LAPTIMES.mutex:  # clear the rest queue
        LAPTIMES.queue.clear()
コード例 #24
0
ファイル: classes.py プロジェクト: prunn/ACTV
	def setColor(self, color, animated=False):
		self.f_params["r"].setValue(color[0])
		self.f_params["g"].setValue(color[1])
		self.f_params["b"].setValue(color[2])
		self.f_params["a"].setValue(color[3])
		if not animated:
			self.o_params["r"].setValue(color[0])
			self.o_params["g"].setValue(color[1])
			self.o_params["b"].setValue(color[2])
			self.o_params["a"].setValue(color[3])
			self.params["r"].setValue(color[0])
			self.params["g"].setValue(color[1])
			self.params["b"].setValue(color[2])
			self.params["a"].setValue(color[3])
			ac.setFontColor(self.label, *color)
		return self
コード例 #25
0
ファイル: tyre_apps.py プロジェクト: cientista/ac_dashboard
 def draw_tyre_temp_colors(self, temp):
     if not (self.tyre.low_opt or self.tyre.high_opt):
         ac.setFontColor(self.starting_label_no, 1, 1, 1, 1)
         return
     if temp < self.tyre.low_opt:
         ac.setFontColor(self.starting_label_no, 0, 0, 1, 1)
     elif temp > self.tyre.high_opt:
         ac.setFontColor(self.starting_label_no, 1, 0, 0, 1)
     else:
         ac.setFontColor(self.starting_label_no, 0, 1, 0, 1)
コード例 #26
0
ファイル: FFI HUD.py プロジェクト: bridget512/FFI-HUD
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)
コード例 #27
0
    def add(self, text, x1, x2, x3):
        single_column = not any((x2, x3))

        for column_number, col in enumerate((x1, x2, x3)):
            if col is None:
                continue
            if not hasattr(self.data, col):
                setattr(self.data, col, ac.addLabel(self.window_id, ""))
            ident = getattr(self.data, col)
            ac.setPosition(ident, column_number * 100, self._next_line)
            width = 300 if single_column else 100
            ac.setSize(ident, width, self._line_size)
            ac.setFontSize(ident, self._font_size)
            if not single_column:
                ac.setFontAlignment(ident, 'right')
            ac.setFontColor(ident, 1.0, 1.0, 1.0, 1.0)

        self._next_line += self._line_size
        self.set(x1, text)
コード例 #28
0
  def add(self, text, x1, x2, x3):
    single_column = not any((x2, x3))

    for column_number, col in enumerate((x1, x2, x3)):
      if col is None:
        continue
      if not hasattr(self.data, col):
        setattr(self.data, col, ac.addLabel(self.window_id, ""))
      ident = getattr(self.data, col)
      ac.setPosition(ident, column_number * 100, self._next_line)
      width = 300 if single_column else 100
      ac.setSize(ident, width, self._line_size)
      ac.setFontSize(ident, self._font_size)
      if not single_column:
        ac.setFontAlignment(ident, 'right')
      ac.setFontColor(ident, 1.0, 1.0, 1.0, 1.0)

    self._next_line += self._line_size
    self.set(x1, text)
コード例 #29
0
  def reinitialize_app(self):

    # Initialize all 'data' fields we use.
    if not hasattr(self.data, 'frame_count'):
      self.data.frame_count = 0

    # Only create the text label once.
    if not hasattr(self.data, 'banner'):
      self.data.banner = ac.addLabel(self.data.app_id, '')

    # But set the size and positioning every time the app is hot reloaded.
    ac.setPosition(self.data.banner, 0, 0)  # X, Y relative to main app window
    ac.setSize(self.data.banner, config.LABEL_WIDTH, config.LABEL_HEIGHT)

    ac.setFontAlignment(self.data.banner, 'center')
    ac.setFontSize(self.data.banner, config.FONT_SIZE)
    ac.setFontColor(self.data.banner, 0.945, 0.933, 0.102, 1.0) # yellow

    ac.setText(self.data.banner, '')
コード例 #30
0
    def reinitialize_app(self):

        # Initialize all 'data' fields we use.
        if not hasattr(self.data, 'frame_count'):
            self.data.frame_count = 0

        # Only create the text label once.
        if not hasattr(self.data, 'banner'):
            self.data.banner = ac.addLabel(self.data.app_id, '')

        # But set the size and positioning every time the app is hot reloaded.
        ac.setPosition(self.data.banner, 0,
                       0)  # X, Y relative to main app window
        ac.setSize(self.data.banner, config.LABEL_WIDTH, config.LABEL_HEIGHT)

        ac.setFontAlignment(self.data.banner, 'center')
        ac.setFontSize(self.data.banner, config.FONT_SIZE)
        ac.setFontColor(self.data.banner, 0.945, 0.933, 0.102, 1.0)  # yellow

        ac.setText(self.data.banner, '')
コード例 #31
0
ファイル: nChat.py プロジェクト: nuggs/nChat
def onChatMessage(message, author) :
    global messages, lines, maxLines, currentText

    currentText = 1
    messages.append([author, message])
    if len(messages) > maxLines:
        messages = messages[len(messages)-maxLines:]

    for i in range(0, maxLines):
        if i < len(messages):
            msg = messages[len(messages)-1-i]
            scale = abs(float(-2))
            n_width = 14*len(msg[0])/scale
            m_width = 14*len(msg[1])/scale

            ac.setText(lines[maxLines-1-i][1], msg[1])
            ac.setSize(lines[maxLines-1-i][0], n_width, 14*1.4)
            ac.setSize(lines[maxLines-1-i][1], m_width, 14*1.4)
            if msg[0].strip().find(driver) > -1:
                ac.setFontColor(lines[maxLines-1-i][0], 0, 1, 0, 1)
            else:
                ac.setFontColor(lines[maxLines-1-i][0], random.random(), random.random(), random.random(), 1)
            ac.setFontColor(lines[maxLines-1-i][1], 1, 1, 1, 1)
            ac.setVisible(lines[maxLines-1-i][0], 1)
            ac.setVisible(lines[maxLines-1-i][1], 1)
            ac.setPosition(lines[maxLines-1-i][0], 0, ac.getPosition(lines[maxLines-1-i][0])[1])
            ac.setFontAlignment(lines[maxLines-1-i][0], "left")
            ac.setPosition(lines[maxLines-1-i][1], n_width+5, ac.getPosition(lines[maxLines-1-i][1])[1])
            ac.setFontAlignment(lines[maxLines-1-i][1], "left")
            ac.setText(lines[maxLines-1-i][0], msg[0]+":")
コード例 #32
0
def acMain(ac_version):
    global AngleLabel, PeakAngleLabel, PeakKMHLabel

    # init Window
    appWindow = ac.newApp("D_Angle")
    ac.setSize(appWindow, 200, 113)
    ac.setTitle(appWindow, "D_Angle")
    ac.drawBorder(appWindow, 0)
    ac.setBackgroundOpacity(appWindow, 0.1)

    # label configure
    AngleLabel = ac.addLabel(appWindow, "0°")
    ac.setPosition(AngleLabel, 100, 20)
    ac.setFontAlignment(AngleLabel, "center")
    ac.setFontSize(AngleLabel, 55)
    ac.setFontColor(AngleLabel, 1, 1, 1, 1)

    PeakAngleLabel = ac.addLabel(appWindow, "0°")
    ac.setPosition(PeakAngleLabel, 110, 87)
    ac.setFontAlignment(PeakAngleLabel, "right")
    ac.setFontSize(PeakAngleLabel, 12)
    ac.setFontColor(PeakAngleLabel, 1, 1, 1, 0.6)

    PeakKMHLabel = ac.addLabel(appWindow, "0")
    ac.setPosition(PeakKMHLabel, 130, 87)
    ac.setFontAlignment(PeakKMHLabel, "right")
    ac.setFontSize(PeakKMHLabel, 12)
    ac.setFontColor(PeakKMHLabel, 1, 1, 1, 0.6)

    peakTitleLabel = ac.addLabel(appWindow, "peak :")
    ac.setPosition(peakTitleLabel, 50, 87)
    ac.setFontAlignment(peakTitleLabel, "left")
    ac.setFontSize(peakTitleLabel, 10)
    ac.setFontColor(peakTitleLabel, 1, 1, 1, 0.6)

    peakKMHUnitLabel = ac.addLabel(appWindow, "km/h")
    ac.setPosition(peakKMHUnitLabel, 135, 90)
    ac.setFontAlignment(peakKMHUnitLabel, "left")
    ac.setFontSize(peakKMHUnitLabel, 8)
    ac.setFontColor(peakKMHUnitLabel, 1, 1, 1, 0.6)
コード例 #33
0
def acMain(ac_version):
    global shadow, label, appWindow
    appWindow = ac.newApp("SimpleSpeedo")
    ac.setSize(appWindow, 120, 60)
    ac.setBackgroundOpacity(appWindow, 0)
    ac.drawBorder(appWindow, 0)
    ac.setIconPosition(appWindow, 0, -9000)
    -ac.setTitlePosition(appWindow, 0, -9000)

    shadow = ac.addLabel(appWindow, "?")
    ac.setFontSize(shadow, 44)
    ac.setPosition(shadow, 61, 1)
    ac.setFontColor(shadow, 0.2, 0.2, 0.2, 0.2)
    ac.setFontAlignment(shadow, "center")

    label = ac.addLabel(appWindow, "?")
    ac.setFontSize(label, 44)
    ac.setPosition(label, 60, 0)
    ac.setFontColor(label, 1, 1, 1, 0.4)
    ac.setFontAlignment(label, "center")

    return "SimpleSpeedo"
コード例 #34
0
ファイル: classes.py プロジェクト: H0sch/HoschTV
	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)
		"""
		
コード例 #35
0
    def update_ui(self):
        # Order cars
        cars = self._get_sorted_cars()

        # Clear labels
        for dummy, label in self.ui.labels.items():
            ac.setText(label, '')

        if cars is None:
            # In pits
            label = self.ui.labels['line_0']
            ac.setFontColor(label, *WHITE)
            ac.setText(label, 'In Pits')
            return

        for i, car in enumerate(cars):
            try:
                label = self.ui.labels['line_%d' % i]
                label_delta = self.ui.labels['line_%d_delta' % i]
            except KeyError:
                break

            text = '%2d (%d) %s' % (car.position, car.lap, car.get_name())
            text_delta = ''
            color = WHITE

            status = car.status(self.player)

            if status == 'player':
                color = GREY_60
            elif status == 'lapping-behind':
                text_delta = '%.1f' % (car.delta / 1000)
                color = RED
            elif status == 'lapped-behind':
                text_delta = '%.1f' % (car.delta / 1000)
                color = DARK_GREEN
            elif status == 'lapped-ahead':
                text_delta = '+%.1f' % (car.delta / 1000)
                color = GREEN
            elif status == 'lapping-ahead':
                text_delta = '+%.1f' % (car.delta / 1000)
                color = DARK_RED
            elif status == 'racing-behind':
                text_delta = '%.1f' % (car.delta / 1000)
            elif status == 'racing-ahead':
                text_delta = '+%.1f' % (car.delta / 1000)

            if info.graphics.session != 2 and color != GREY_60:
                # Only use colors in race mode
                color = WHITE

            ac.setFontColor(label, *color)
            ac.setFontColor(label_delta, *color)
            ac.setText(label, text)
            ac.setText(label_delta, text_delta)
コード例 #36
0
ファイル: actracker.py プロジェクト: mathiasuk/actracker
    def update_ui(self):
        # Order cars
        cars = self._get_sorted_cars()

        # Clear labels
        for dummy, label in self.ui.labels.items():
            ac.setText(label, '')

        if cars is None:
            # In pits
            label = self.ui.labels['line_0']
            ac.setFontColor(label, *WHITE)
            ac.setText(label, 'In Pits')
            return

        for i, car in enumerate(cars):
            try:
                label = self.ui.labels['line_%d' % i]
                label_delta = self.ui.labels['line_%d_delta' % i]
            except KeyError:
                break

            text = '%2d (%d) %s' % (car.position, car.lap, car.get_name())
            text_delta = ''
            color = WHITE

            status = car.status(self.player)

            if status == 'player':
                color = GREY_60
            elif status == 'lapping-behind':
                text_delta = '%.1f' % (car.delta / 1000)
                color = RED
            elif status == 'lapped-behind':
                text_delta = '%.1f' % (car.delta / 1000)
                color = DARK_GREEN
            elif status == 'lapped-ahead':
                text_delta = '+%.1f' % (car.delta / 1000)
                color = GREEN
            elif status == 'lapping-ahead':
                text_delta = '+%.1f' % (car.delta / 1000)
                color = DARK_RED
            elif status == 'racing-behind':
                text_delta = '%.1f' % (car.delta / 1000)
            elif status == 'racing-ahead':
                text_delta = '+%.1f' % (car.delta / 1000)

            if info.graphics.session != 2 and color != GREY_60:
                # Only use colors in race mode
                color = WHITE

            ac.setFontColor(label, *color)
            ac.setFontColor(label_delta, *color)
            ac.setText(label, text)
            ac.setText(label_delta, text_delta)
コード例 #37
0
ファイル: MultiLaps.py プロジェクト: robhaswell/MultiLaps
    def updateViewNewLap(self):
        for index in range(lapDisplayedCount):
            lapIndex = index
            if len(self.laps) > lapDisplayedCount:
                lapIndex += len(self.laps)-lapDisplayedCount

            # Refresh lap number
            if (self.pitExitLap > 0) and (self.pitExitLap <= lapIndex < self.lapDone):
                ac.setText(self.lapNumberLabel[index], "{0}. ({1})".format(lapIndex+1, lapIndex-self.pitExitLap+1))
            else:
                ac.setText(self.lapNumberLabel[index], "%d." % (lapIndex+1))

            # Refresh lap times and deltas
            if lapIndex < len(self.laps):
                ac.setText(self.timeLabel[index], timeToString(self.laps[lapIndex]))
                
                # Best lap in green
                if self.laps[lapIndex] == self.bestLapAc:
                    ac.setFontColor(self.timeLabel[index], 0, 1, 0, 1)
                else:
                    ac.setFontColor(self.timeLabel[index], 1, 1, 1, 1)
                
                # Refresh delta label
                setDelta(self.deltaLabel[index], self.laps[lapIndex] - self.referenceTime)

            else:
                ac.setText(self.timeLabel[index], timeToString(0))
                ac.setFontColor(self.timeLabel[index], 1, 1, 1, 1)
                ac.setText(self.deltaLabel[index], "-.---")
                ac.setFontColor(self.deltaLabel[index], 1, 1, 1, 1)

        # Refresh Total
        ac.setText(self.timeLabel[self.totalLabelId], timeToString(self.total))

        # Refresh reference
        ac.setText(self.timeLabel[self.refLabelId], timeToString(self.referenceTime))

        self.lastLapViewRefreshed = self.lastLapDataRefreshed
コード例 #38
0
ファイル: MultiLaps.py プロジェクト: robhaswell/MultiLaps
    def updateViewFast(self):
        # Refresh current lap projection and performance
        if self.sfCrossed and len(self.bestLapData) > 0 and info.graphics.status != 1 and self.position > 0.00001:
            ac.setText(self.timeLabel[self.currLabelId], timeToString(self.projection))
            if self.pitExitState == PIT_EXIT_STATE_APPLY_OFFSET:
                setDelta(self.deltaLabel[self.currLabelId], self.performance-self.pitExitDeltaOffset)
            else:
                setDelta(self.deltaLabel[self.currLabelId], self.performance)
        else:
            ac.setText(self.timeLabel[self.currLabelId], timeToString(self.currentTime))
            ac.setText(self.deltaLabel[self.currLabelId], "-.---")
            ac.setFontColor(self.deltaLabel[self.currLabelId], 1, 1, 1, 1)

        if self.lapInvalidated:
            ac.setFontColor(self.timeLabel[self.currLabelId], 1, 0, 0, 1)
        else:
            ac.setFontColor(self.timeLabel[self.currLabelId], 1, 1, 1, 1)
コード例 #39
0
    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")
コード例 #40
0
def setupUI(appWindow):
    global statusLabel
    statusLabel = ac.addLabel(appWindow, "Disconnected");
    ac.setFontColor(statusLabel, 255, 0, 0, 0)
    ac.setPosition(statusLabel, 3, 30)
コード例 #41
0
ファイル: PitVoice.py プロジェクト: Marocco2/PitVoice
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"
コード例 #42
0
ファイル: BoxRadio.py プロジェクト: Marocco2/BoxRadio
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"
コード例 #43
0
ファイル: classes.py プロジェクト: acclub/apps
	def setColor(self, color):
		self.color = color
		ac.setFontColor(self.label, *self.color)
		return self
コード例 #44
0
 def setColor(self, colour):
     ac.setFontColor(self.label, *colour)
     return self
コード例 #45
0
ファイル: MultiLaps.py プロジェクト: robhaswell/MultiLaps
def setDelta(label, delta):
    ac.setText(label, deltaToString(delta))

    if delta >= redAt:
        ac.setFontColor(label, 1, 0, 0, 1)
    elif delta <= greenAt:
        ac.setFontColor(label, 0, 1, 0, 1)
    else:
        if deltaColor == "yellow":
            if delta > 0:
                # color factor [0..1]
                colorFactor = float(delta)/redAt
                ac.setFontColor(label, 1, 1-colorFactor, 0, 1)
            else:
                # color factor [0..1]
                colorFactor = float(delta)/greenAt
                ac.setFontColor(label, 1-colorFactor, 1, 0, 1)

        elif deltaColor == "white":
            if delta > 0:
                # color factor [0..1]
                colorFactor = float(delta)/redAt
                ac.setFontColor(label, 1, 1-colorFactor, 1-colorFactor, 1)
            else:
                # color factor [0..1]
                colorFactor = float(delta)/greenAt
                ac.setFontColor(label, 1-colorFactor, 1, 1-colorFactor, 1)
コード例 #46
0
ファイル: EpicRace.py プロジェクト: Marocco2/EpicRace
def acMain(ac_version):
    global appWindow
    global sound_player, SoundPackSpinner, VolumeSpinner
    global Beforerace, Overtake, Suspense, Win, Lose, labeldesc, Hotlap
    global StatusLabel, NotificationLabel, audio, audiolist, BeforeraceLabel, OvertakeLabel, SuspenseLabel
    global WinLabel, LoseLabel, audiolabel, position, debuglabel
    # DEBUG INFO
    global enable_overtake, enable_lose, enable_win, enable_hotlap
    global enable_before_race, enable_suspense, suspense_laps, log
    global audio, overtake, position, newposition, start_time, finish_time, count_overtake
    global session, sessionTime, numberOfLaps, completedLaps

    appWindow = ac.newApp("Epic Race")
    ac.setSize(appWindow, 430, 350)
    ac.setTitle(appWindow, "Epic Race")
    ac.setBackgroundOpacity(appWindow, 0.5)
    ac.drawBorder(appWindow, 0)
    #
    SoundPackSpinner = ac.addSpinner(appWindow, "")
    ac.setFontColor(SoundPackSpinner, 1, 1, 1, 1)
    ac.setFontSize(SoundPackSpinner, 12)
    spinner_config(SoundPackSpinner, 10, 55, 80, 18, 0, 1, 10, 0, onSoundPackChanged)
    #
    VolumeSpinner = ac.addSpinner(appWindow, "")
    ac.setFontColor(VolumeSpinner, 1, 1, 1, 1)
    ac.setFontSize(VolumeSpinner, 12)
    spinner_config(VolumeSpinner, 10, 105, 80, 18, 0, 1, 100, audio_volume, onVolumeChanged)
    #
    audiolabel = ac.addLabel(appWindow, "")
    ac.setPosition(audiolabel, 10, 30)
    ac.setFontColor(audiolabel, 1, 1, 1, 1)
    ac.setFontSize(audiolabel, 15)
    #
    volumelabel = ac.addLabel(appWindow, "Volume")
    ac.setPosition(volumelabel, 10, 80)
    ac.setFontColor(volumelabel, 1, 1, 1, 1)
    ac.setFontSize(volumelabel, 15)

    Beforerace = ac.addCheckBox(appWindow, "")
    ac.setValue(Beforerace, enable_before_race)
    ac.setPosition(Beforerace, 10, 130)
    ac.setSize(Beforerace, 20, 20)
    ac.drawBorder(Beforerace, 1)
    ac.addOnCheckBoxChanged(Beforerace, onEnableBeforeRace)
    #
    Overtake = ac.addCheckBox(appWindow, "")
    ac.setValue(Overtake, enable_overtake)
    ac.setPosition(Overtake, 10, 160)
    ac.setSize(Overtake, 20, 20)
    ac.drawBorder(Overtake, 1)
    ac.addOnCheckBoxChanged(Overtake, onEnableOverTake)
    #
    Suspense = ac.addCheckBox(appWindow, "")
    ac.setValue(Suspense, enable_suspense)
    ac.setPosition(Suspense, 10, 190)
    ac.setSize(Suspense, 20, 20)
    ac.drawBorder(Suspense, 1)
    ac.addOnCheckBoxChanged(Suspense, onEnableSuspense)
    #
    Win = ac.addCheckBox(appWindow, "")
    ac.setValue(Win, enable_win)
    ac.setPosition(Win, 10, 220)
    ac.setSize(Win, 20, 20)
    ac.drawBorder(Win, 1)
    ac.addOnCheckBoxChanged(Win, onEnableWin)
    #
    Lose = ac.addCheckBox(appWindow, "")
    ac.setValue(Lose, enable_lose)
    ac.setPosition(Lose, 10, 250)
    ac.setSize(Lose, 20, 20)
    ac.drawBorder(Lose, 1)
    ac.addOnCheckBoxChanged(Lose, onEnableLose)
    #
    Hotlap = ac.addCheckBox(appWindow, "")
    ac.setValue(Hotlap, enable_hotlap)
    ac.setPosition(Hotlap, 10, 280)
    ac.setSize(Hotlap, 20, 20)
    ac.drawBorder(Hotlap, 1)
    ac.addOnCheckBoxChanged(Hotlap, onEnableHotlap)
    #
    BeforeraceLabel = ac.addLabel(appWindow, "Enable before race")
    ac.setPosition(BeforeraceLabel, 40, 130)
    ac.setFontColor(BeforeraceLabel, 1, 1, 1, 1)
    ac.setFontSize(BeforeraceLabel, 15)
    #
    OvertakeLabel = ac.addLabel(appWindow, "Enable overtake")
    ac.setPosition(OvertakeLabel, 40, 160)
    ac.setFontColor(OvertakeLabel, 1, 1, 1, 1)
    ac.setFontSize(OvertakeLabel, 15)
    #
    SuspenseLabel = ac.addLabel(appWindow, "Enable suspense")
    ac.setPosition(SuspenseLabel, 40, 190)
    ac.setFontColor(SuspenseLabel, 1, 1, 1, 1)
    ac.setFontSize(SuspenseLabel, 15)
    #
    WinLabel = ac.addLabel(appWindow, "Enable win")
    ac.setPosition(WinLabel, 40, 220)
    ac.setFontColor(WinLabel, 1, 1, 1, 1)
    ac.setFontSize(WinLabel, 15)
    #
    LoseLabel = ac.addLabel(appWindow, "Enable lose")
    ac.setPosition(LoseLabel, 40, 250)
    ac.setFontColor(LoseLabel, 1, 1, 1, 1)
    ac.setFontSize(LoseLabel, 15)
    #
    HotlapLabel = ac.addLabel(appWindow, "Enable hotlap")
    ac.setPosition(HotlapLabel, 40, 280)
    ac.setFontColor(HotlapLabel, 1, 1, 1, 1)
    ac.setFontSize(HotlapLabel, 15)
    #
    labeldesc = ac.addLabel(appWindow, "Something is broken")
    ac.setPosition(labeldesc, 180, 40)
    ac.setSize(labeldesc, 200, 200)
    #
    StatusLabel = ac.addLabel(appWindow, Status)
    ac.setPosition(StatusLabel, 10, 305)
    ac.setFontColor(StatusLabel, 1, 1, 1, 1)
    ac.setFontSize(StatusLabel, 15)
    #
    NotificationLabel = ac.addLabel(appWindow, Notify)
    ac.setPosition(NotificationLabel, 10, 325)
    ac.setFontColor(NotificationLabel, 1, 1, 1, 1)
    ac.setFontSize(NotificationLabel, 12)
    ac.setSize(NotificationLabel, 24, 310)
    #
    # DEBUG INFO
    #
    debuglabel = ac.addLabel(appWindow, "")
    ac.setPosition(debuglabel, 215, 30)
    ac.setSize(debuglabel, 200, 200)
    #
    #
    #
    box.FModSystem.init()
    sound_player = box.SoundPlayer(box.FModSystem)
    sound_player.set_volume(audio_volume / 100)
    sound_player.set_gain(2.0)

    audiolist = os.listdir(os.path.join(os.path.dirname(__file__), "SoundPacks"))
    ac.setRange(SoundPackSpinner, 0, len(audiolist) - 1)
    ac.setStep(SoundPackSpinner, 1)
    ac.setValue(SoundPackSpinner, audiolist.index(audio))

    getNotification()
    if AutoUpdate:
        CheckNewUpdate()
    position = ac.getCarRealTimeLeaderboardPosition(0)

    return "EpicRace"
コード例 #47
0
def acUpdate(deltaT):
    global timer0, timer1
    global tyreLabels, tyrePressureLabels
    global drsLabel, ersLabel, ersModeLabel, ersRecoveryLabel, fuelLabel, drsPenaltyLabel, drsPenaltyBackgroundLabel
    global carValue, trackConfigValue, trackValue

    global currentLapValue, lapValue, previousLapValue, carWasInPit

    global totalDrivers, trackLength, driversList, totalPenalty, soundPlaying, drsAvailableZones, currentDrsZone, drsPenaltyAwardedInZone, lastTime

    global tyreCompoundShort, tyreCompoundCleaned, previousTyreCompoundValue, minimumOptimalTemperature, maximumOptimalTemperature, idealPressureFront, idealPressureRear
    global tyreTemperatureValue, tyreTemperatureValueI, tyreTemperatureValueM, tyreTemperatureValueO, tyrePressureValue, tyreCompoundValue
    global temperatureTransitionRange, tyrePracticalTemperatureValue
    global fuelAmountValue, fuelStartValue, relevantLapsNumber, fuelSpentValue, fuelPerLapValue

    global compounds, modCompounds

    timer0 += deltaT
    timer1 += deltaT

    # Once per second
    if timer0 > 1:
        timer0 = 0

        # =================================================================================================================
        #                                    GET A BUNCH OF INFO
        # =================================================================================================================
        tyreCompoundValue = info.graphics.tyreCompound
        tyreTemperatureValue = info.physics.tyreCoreTemperature
        tyreTemperatureValueI = info.physics.tyreTempI
        tyreTemperatureValueM = info.physics.tyreTempM
        tyreTemperatureValueO = info.physics.tyreTempO
        tyrePressureValue = info.physics.wheelsPressure

        fuelAmountValue = info.physics.fuel

        if ac.isCarInPitline(0):
            carWasInPit = 1

        # =================================================================================================================
        #                                   SET IDEAL TYRE PRESSURES AND TEMPERATURES
        # =================================================================================================================
        if previousTyreCompoundValue != tyreCompoundValue:
            previousTyreCompoundValue = tyreCompoundValue
            tyreCompoundShort = tyreCompoundValue[tyreCompoundValue.find("(") +
                                                  1:tyreCompoundValue.find(")"
                                                                           )]
            tyreCompoundCleaned = re.sub(
                '\_+$', '', re.sub(r'[^\w]+', '_', tyreCompoundValue)).lower()

            if compounds.has_section(carValue + "_" + tyreCompoundCleaned):
                try:
                    idealPressureFront = int(
                        compounds.get(carValue + "_" + tyreCompoundCleaned,
                                      "IDEAL_PRESSURE_F"))
                    idealPressureRear = int(
                        compounds.get(carValue + "_" + tyreCompoundCleaned,
                                      "IDEAL_PRESSURE_R"))
                    minimumOptimalTemperature = int(
                        compounds.get(carValue + "_" + tyreCompoundCleaned,
                                      "MIN_OPTIMAL_TEMP"))
                    maximumOptimalTemperature = int(
                        compounds.get(carValue + "_" + tyreCompoundCleaned,
                                      "MAX_OPTIMAL_TEMP"))
                except:
                    ac.console("Error loading tyre data.")
            elif modCompounds.has_section(carValue + "_" +
                                          tyreCompoundCleaned):
                try:
                    idealPressureFront = int(
                        modCompounds.get(carValue + "_" + tyreCompoundCleaned,
                                         "IDEAL_PRESSURE_F"))
                    idealPressureRear = int(
                        modCompounds.get(carValue + "_" + tyreCompoundCleaned,
                                         "IDEAL_PRESSURE_R"))
                    minimumOptimalTemperature = int(
                        float(
                            modCompounds.get(
                                carValue + "_" + tyreCompoundCleaned,
                                "MIN_OPTIMAL_TEMP")))
                    maximumOptimalTemperature = int(
                        float(
                            modCompounds.get(
                                carValue + "_" + tyreCompoundCleaned,
                                "MAX_OPTIMAL_TEMP")))
                    # ac.console("Tyres: {}, {}psi/{}psi, {}°C-{}°C".format(tyreCompoundValue, idealPressureFront, idealPressureRear, minimumOptimalTemperature, maximumOptimalTemperature))
                except:
                    ac.console("Error loading mod tyre data.")
            else:
                ac.console(
                    "Tyres: {}, no data found".format(tyreCompoundValue))

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

        currentLapValue = info.graphics.iCurrentTime
        lapValue = ac.getCarState(0, acsys.CS.LapCount)
        lapProgressValue = ac.getCarState(0, acsys.CS.NormalizedSplinePosition)

        # =================================================================================================================
        #                                                  DRS
        # =================================================================================================================
        drsAvailableValue = ac.getCarState(0, acsys.CS.DrsAvailable)
        drsEnabledValue = ac.getCarState(0, acsys.CS.DrsEnabled)

        # =================================================================================================================
        #                                        DRS SIMPLE (not races)
        # =================================================================================================================

        if info.graphics.session != 2 and ac.getCarName(0) in DRS_ALLOWED_CARS:
            if drsEnabledValue:
                set_drs_good()
            elif drsAvailableValue:
                set_drs_available()

                if not soundPlaying and SOUND_ON:  # use this variable to control drs beep at begining of drs
                    sound_player.play(audio)
                    sound_player.stop()
                    soundPlaying = True
            else:
                soundPlaying = False
                ac.setVisible(drsLabel, 0)

        # =================================================================================================================
        #                                          DRS DATA COLLECTION
        # =================================================================================================================

        if info.graphics.session == 2 and ac.getCarName(0) in DRS_ALLOWED_CARS:

            crossedDetectionZone = -1
            crossedEndZone = -1
            crossedStartZone = -1
            curTime = time.time()
            for i in range(totalDrivers):
                spline = ac.getCarState(i, acsys.CS.NormalizedSplinePosition)
                for zid, zone in enumerate(drsZones):
                    if driver_crossed_zone(driversList[i].last_pos,
                                           zone['detection'], spline):
                        driversList[i].drs_detection_times[zid] = curTime
                        if i == 0:  # current driver
                            crossedDetectionZone = zid  # mark zone crossed by driver (not possible to cross multiple zone)
                    if i == 0 and driver_crossed_zone(driversList[i].last_pos,
                                                      zone['end'], spline):
                        crossedEndZone = zid
                    if i == 0 and driver_crossed_zone(driversList[i].last_pos,
                                                      zone['start'], spline):
                        crossedStartZone = zid
                driversList[i].last_pos = spline

        # =================================================================================================================
        #                                          DRS ALLOWANCE MANAGEMENT
        # =================================================================================================================

        # Race Restart
            if info.graphics.completedLaps == 0 and info.graphics.iCurrentTime == 0:
                totalPenalty = 0  # reset penalty
                set_drs_penalty(0)

            # DRS DETECTION Zone crossed
            if crossedDetectionZone != -1:
                if info.graphics.completedLaps + 1 >= DRS_STARTS_ON_LAP:  # if this is a valid lap
                    ac.log("Checking Detection Zone: " +
                           str(crossedDetectionZone) + " on lap: " +
                           str(info.graphics.completedLaps))
                    # check if there is any driver within DRS_GAP
                    if any(driversList[0].
                           drs_detection_times[crossedDetectionZone] -
                           driver.drs_detection_times[crossedDetectionZone] <=
                           DRS_GAP and driversList[0].
                           drs_detection_times[crossedDetectionZone] - driver.
                           drs_detection_times[crossedDetectionZone] >= 0
                           for driver in driversList[1:]):
                        set_drs_possible()
                        drsAvailableZones[crossedDetectionZone] = True

            # DRS END Zone crossed
            if crossedEndZone != -1:
                drsAvailableZones[crossedEndZone] = False
                currentDrsZone = -1
                drsPenaltyAwardedInZone = False
                # if next zone allows for drs already -- for cases where 1 DRS detection is used in 2 zones
                if drsAvailableZones[(crossedEndZone + 1) %
                                     len(drsAvailableZones)]:
                    set_drs_possible()
                set_drs_hidden()

            # DRS START Zone crossed
            if crossedStartZone != -1:
                currentDrsZone = crossedStartZone

            # IN DRS ZONE
            if drsAvailableValue:
                if drsAvailableZones[currentDrsZone]:
                    if drsEnabledValue:
                        set_drs_good()
                    else:
                        set_drs_available()
                        if totalPenalty > 0: totalPenalty -= curTime - lastTime
                        set_drs_penalty(totalPenalty)
                else:
                    if drsEnabledValue:
                        set_drs_bad()
                        if not drsPenaltyAwardedInZone:
                            drsPenaltyAwardedInZone = True
                            announcePenalty(
                                ac.getDriverName(0),
                                info.graphics.completedLaps + 1,
                                "Illegal DRS use, Zone %d" % (currentDrsZone))
                        # Add penalty amount
                        if abs(curTime - lastTime) < 1:
                            totalPenalty += curTime - lastTime
                        set_drs_penalty(totalPenalty)
                    else:
                        set_drs_hidden()

            # end of drs update save current values into lasts
            lastTime = curTime

        # =================================================================================================================
        #                                              ERS LABEL
        # =================================================================================================================

        ersRecoveryLevel = info.physics.ersRecoveryLevel
        ersMode = info.physics.ersPowerLevel
        ac.setText(ersModeLabel, "🗲{}".format(ersMode))
        ac.setText(ersRecoveryLabel, "↺{}".format(ersRecoveryLevel))
        ac.setFontColor(ersModeLabel, *ERS_COLORS[ersMode])
        ac.setFontColor(ersLabel, *ERS_COLORS[ersMode])
        ac.setFontColor(ersRecoveryLabel, *ERS_COLORS[ersMode])

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

        if fuelPerLapValue:
            ac.setText(
                fuelLabel,
                "💧 {:.1f} Laps".format(fuelAmountValue / fuelPerLapValue))

        # =================================================================================================================
        #                                          TYRE TEMPERATURES
        # =================================================================================================================

        for i in range(4):
            tyrePracticalTemperatureValue[i] = 0.25 * (
                (tyreTemperatureValueI[i] + tyreTemperatureValueM[i] +
                 tyreTemperatureValueO[i]) /
                3) + 0.75 * tyreTemperatureValue[i]

        for i, label in enumerate(tyreLabels):
            # ac.setText(label, "{:.0f}".format(tyrePracticalTemperatureValue[i]))
            if minimumOptimalTemperature and maximumOptimalTemperature:
                if int(round(tyrePracticalTemperatureValue[i])
                       ) >= minimumOptimalTemperature and int(
                           round(tyrePracticalTemperatureValue[i])
                       ) <= maximumOptimalTemperature:
                    ac.setBackgroundColor(label, 0.17, 1, 0)
                elif int(round(tyrePracticalTemperatureValue[i])
                         ) < minimumOptimalTemperature:
                    idealTemperatureDifference = min(
                        temperatureTransitionRange, minimumOptimalTemperature -
                        tyrePracticalTemperatureValue[i]
                    ) / temperatureTransitionRange
                    ac.setBackgroundColor(
                        label, max(0,
                                   0.17 - idealTemperatureDifference / 5.88),
                        max(0.51, 1 - idealTemperatureDifference / 1.96),
                        min(1, 0 + idealTemperatureDifference))
                elif int(round(tyrePracticalTemperatureValue[i])
                         ) > maximumOptimalTemperature:
                    idealTemperatureDifference = min(
                        temperatureTransitionRange,
                        tyrePracticalTemperatureValue[i] -
                        maximumOptimalTemperature) / temperatureTransitionRange
                    ac.setBackgroundColor(
                        label, min(1,
                                   0.17 + idealTemperatureDifference / 0.83),
                        max(0.17, 1 - idealTemperatureDifference / 0.83), 0)
            else:
                ac.setBackgroundOpacity(label, 0)
            ac.setBackgroundOpacity(
                label, 1
            )  # background colors start to hyde for some reason so this is needed

        for i, label in enumerate(tyrePressureLabels):
            if idealPressureFront and idealPressureRear:
                if i < 2:  # front
                    ac.setText(
                        label, "{:+.1f}".format(tyrePressureValue[i] -
                                                idealPressureFront))
                else:  # rear
                    ac.setText(
                        label, "{:+.1f}".format(tyrePressureValue[i] -
                                                idealPressureRear))
            else:
                ac.setText(label, "{:.0f}".format(tyrePressureValue[i]))

    # =================================================================================================================
    #                                     CALCULATE AT LAP ENDING OR LAP START
    # =================================================================================================================

    #Display/calculate on lap start
    if currentLapValue > 500 and currentLapValue < 1000:
        carWasInPit = 0
        fuelStartValue = fuelAmountValue

    #Display/calculate on lap finish
    if previousLapValue < lapValue:
        # announce any penalty at the end of a lap
        if totalPenalty > 0:
            announceTotalPenalty(ac.getDriverName(0),
                                 info.graphics.completedLaps + 1)
        previousLapValue = lapValue

        #Fuel per lap
        if fuelAmountValue < fuelStartValue and not carWasInPit:
            relevantLapsNumber += 1
            fuelSpentValue += fuelStartValue - fuelAmountValue
            fuelPerLapValue = fuelSpentValue / relevantLapsNumber
コード例 #48
0
 def font_color(self, value):
     self._font_color = value
     ac.setFontColor(self.id, *value)