示例#1
0
 def __init__(self, app, x, y):
   
   self.AverageFuelPerLap = 0.0
   self.FuelLastLap = 0.0
   self.completedLaps = 0.0
   self.fuelAtLapStart = 0.0
   self.distanceTraveledAtStart = 0.0
   self.fuelAtStart = 0.0
   self.lastFuelMeasurement = 0.0
   self.lastDistanceTraveled = 0.0
   self.counter = 0
   self.updatecounter = 0
   
   self.inifilepath = inidir + self.getValidFileName(ac.getCarName(0)) +"_" + self.getValidFileName(ac.getTrackName(0)) + self.getValidFileName(ac.getTrackConfiguration(0)) + ".ini"
   
   ##initialize labels
   
   self.remainingLabel = ac.addLabel(app, "remainingLabel")
   self.averageFuelPerLapLabel = ac.addLabel(app, "averageFuelPerLapLabel")
   self.lapsLeftLabel = ac.addLabel(app, "lapsLeftLabel")
   self.averageFuelPer100kmLabel = ac.addLabel(app, "averageFuelPer100km")
   self.instFuelLabel = ac.addLabel(app, "instFuel")
   
   ##set label positions
   
   ac.setPosition(self.remainingLabel, x, y)
   ac.setPosition(self.averageFuelPerLapLabel, x + 208, y)
   ac.setPosition(self.lapsLeftLabel, 150 - x, y)
   ac.setPosition(self.averageFuelPer100kmLabel, x + 208, y + 19)
   ac.setPosition(self.instFuelLabel, 150 - x, y + 19)
   
   ##set label alignments
   
   ac.setFontAlignment(self.remainingLabel, "left")
   ac.setFontAlignment(self.averageFuelPerLapLabel, "left")
   ac.setFontAlignment(self.lapsLeftLabel, "right")
   ac.setFontAlignment(self.averageFuelPer100kmLabel, "left")
   ac.setFontAlignment(self.instFuelLabel, "right")
   
   ##set font size
   
   ac.setFontSize(self.remainingLabel, 32)
   ac.setFontSize(self.averageFuelPerLapLabel, 16)
   ac.setFontSize(self.lapsLeftLabel, 16)
   ac.setFontSize(self.averageFuelPer100kmLabel, 16)
   ac.setFontSize(self.instFuelLabel, 16)
   
   if os.path.exists(self.inifilepath):
     f = open(self.inifilepath, "r")
     self.AverageFuelPerLap = float(f.readline()[6:])
     f.close()
   
   ac.setText(self.remainingLabel, "--- l")
   ac.setText(self.averageFuelPerLapLabel, "--- l/lap")
   ac.setText(self.lapsLeftLabel, "--- laps")
   if milesPerGallon:
     ac.setText(self.averageFuelPer100kmLabel, "--- mpg")
   else:
     ac.setText(self.averageFuelPer100kmLabel, "--- l/100km")
   ac.setText(self.instFuelLabel, "--- inst.")
示例#2
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]+":")
    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)
示例#4
0
    def set_alignment(self, alignment='left'):
        """Set text horizontal alignment

        Args:
            alignment (str): 'left', 'center', 'right'.
                defaults to left.
        """
        ac.setFontAlignment(self.id, alignment)
示例#5
0
文件: classes.py 项目: H0sch/HoschTV
	def __init__(self, parent, text, size, posx, posy, font, align):
		self.lbl = ac.addLabel(parent, str(text))
		ac.setPosition(self.lbl, posx, posy)
		if size:
			ac.setFontSize(self.lbl, size)
		if font:
			ac.setCustomFont(self.lbl, font, 0, 0)
		if align:
			ac.setFontAlignment(self.lbl, align)
  def 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)
示例#7
0
def createLabel(name, text, x, y, font_size = 14, align = "center"):
    global mainApp

    label = ac.addLabel(mainApp, name)
    ac.setText(label, text)
    ac.setPosition(label, x, y)
    ac.setFontSize(label, font_size)
    ac.setFontAlignment(label, align)

    return label
示例#8
0
 def setup(self):
     ac.setFontSize(self.label, self.fontSize)
     ac.setFontAlignment(self.label, self.alignment)
     ac.setFontSize(self.unitLabel, self.fontSize//2)
     ac.setPosition(self.label, self.x, self.y)  
     ac.setPosition(self.unitLabel, self.x+self.fontSize//10, self.y+self.fontSize//2)
     if self.title is not None:
         ac.setFontAlignment(self.titleLabel, "right")
         ac.setFontSize(self.titleLabel, self.fontSize//2)
         ac.setPosition(self.titleLabel, self.x, self.y + self.fontSize)  
示例#9
0
 def setupButtons(self):
     ac.setSize(self.btn1, 165, 26)
     ac.setSize(self.btn2 , 165, 26)
     ac.setFontSize(self.btn1, 18)
     ac.setFontSize(self.btn2 , 18)
     ac.setFontAlignment(self.btn1, "center")
     ac.setFontAlignment(self.btn2, "center")
     ac.setPosition(self.btn1, 1  , 398)
     ac.setPosition(self.btn2 , 168, 398)
     ac.addOnClickedListener(self.btn1, btn1_clicked)
     ac.addOnClickedListener(self.btn2 , btn2_clicked)
示例#10
0
    def __init__(self, acd: ACD, resolution: str, window_id: int):
        self.__calc = Power(acd.get_power_curve())

        # Initial size is 512x85
        super(RPMPower, self).__init__(0.0, 0.0, 512.0, 50.0)
        self._back.color = Colors.black

        self.__lb = ac.addLabel(window_id, "- RPM")
        ac.setFontAlignment(self.__lb, "center")

        self.resize(resolution)
示例#11
0
 def setTextAlignment(self, alignment="center"):
     if self.ac_obj is not None:
         if alignment == "left":
             ac.setPosition(self.ac_obj, self.pos[0], self.pos[1])
         elif alignment == "center":
             ac.setPosition(self.ac_obj,
                            int(self.pos[0] + self.size[0] / 2),
                            self.pos[1])
         elif alignment == "right":
             ac.setPosition(self.ac_obj, int(self.pos[0] + self.size[0]),
                            self.pos[1])
         ac.setFontAlignment(self.ac_obj, alignment)
示例#12
0
    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()
示例#13
0
    def __init__(self, resolution, wheel, window_id):
        # Initial size is 64x48
        super(Height, self).__init__(
            430.0 if wheel.is_left() else 18.0, 208.0, 64.0, 48.0)
        self._back.color = Colors.white

        if Height.texture_id == 0:
            Height.texture_id = ac.newTexture(
                "apps/python/LiveTelemetry/img/height.png")

        self.__lb = ac.addLabel(window_id, "")
        ac.setFontAlignment(self.__lb, "center")

        self.resize(resolution)
示例#14
0
    def text_h_alignment(self, text_h_alignment="left"):
        self._text_h_alignment = text_h_alignment

        if self._ac_obj is not None:
            if text_h_alignment == "left":
                ac.setPosition(self._ac_obj, self.pos[0], self.pos[1])
            elif text_h_alignment == "center":
                ac.setPosition(self._ac_obj,
                               int(self.pos[0] + self.size[0] / 2),
                               self.pos[1])
            elif text_h_alignment == "right":
                ac.setPosition(self._ac_obj, int(self.pos[0] + self.size[0]),
                               self.pos[1])
            ac.setFontAlignment(self._ac_obj, text_h_alignment)
示例#15
0
def acUpdate(deltaT):
    global AngleLabel, Angle, PeakAngleLabel, PeakAngle, Timer, MinKMH, PeakKMHLabel
    ac.setFontAlignment(AngleLabel, "center")
    ac.setPosition(AngleLabel, 100, 20)

    # raw data
    carKMH = ac.getCarState(0, acsys.CS.SpeedKMH)
    fl, fr, rl, rr = ac.getCarState(0, acsys.CS.SlipAngle)
    vx, vy, vz = ac.getCarState(0, acsys.CS.LocalVelocity)

    # model data
    Angle = getDriftAngle(rl, rr, vz)

    # spin : over angle
    if Angle > MaxAngle and carKMH > MinKMH:
        ac.setText(AngleLabel, "Spin")
        ac.setText(peakKMHLabel, "0")
        PeakAngle = 0
        return

    # spin : lower speed
    if Angle > 60 and carKMH < MinKMH and vz > 0:
        ac.setText(AngleLabel, "Spin")
        ac.setText(peakKMHLabel, "0")
        PeakAngle = 0
        return

    # drifting
    if carKMH > MinKMH:
        ac.setText(AngleLabel, "{:.0f}°".format(Angle))
        if Angle > PeakAngle:
            PeakAngle = Angle
            ac.setText(PeakAngleLabel, "{:.0f}°".format(PeakAngle))
            ac.setText(PeakKMHLabel, "{:.0f}".format(carKMH))
    # Wait anim
    else:
        ac.setPosition(AngleLabel, 37, 20)
        Timer += deltaT
        ac.setFontAlignment(AngleLabel, "left")
        if int(Timer) % 3 == 0:
            ac.setText(AngleLabel, "ready")
        if int(Timer) % 3 == 1:
            ac.setText(AngleLabel, "ready.")
        if int(Timer) % 3 == 2:
            ac.setText(AngleLabel, "ready..")

        PeakAngle = 0
        ac.setText(PeakAngleLabel, "{:.0f}°".format(PeakAngle))
        ac.setText(PeakKMHLabel, "0")
示例#16
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
示例#17
0
    def __init__(self, acd: ACD, resolution: str, wheel, window_id: int):
        self.__calc = TirePsi(
            acd.get_ideal_pressure(ac.getCarTyreCompound(0), wheel))

        # Initial size is 85x85
        super(Pressure, self).__init__(70.0 if wheel.is_left() else 382.0,
                                       171.0, 60.0, 60.0)
        self._back.color = Colors.white

        if Pressure.texture_id == 0:
            Pressure.texture_id = ac.newTexture(
                "apps/python/LiveTelemetry/img/pressure.png")

        self.__lb = ac.addLabel(window_id, "")
        ac.setFontAlignment(self.__lb, "center")

        self.resize(resolution)
    def add(self, text, x1, x2, x3):
        single_column = not any((x2, x3))

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

        self._next_line += self._line_size
        self.set(x1, text)
  def reinitialize_app(self):

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

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

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

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

    ac.setText(self.data.banner, '')
  def add(self, text, x1, x2, x3):
    single_column = not any((x2, x3))

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

    self._next_line += self._line_size
    self.set(x1, text)
    def reinitialize_app(self):

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

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

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

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

        ac.setText(self.data.banner, '')
def acMain(ac_version):
    global mainLabel, audioSpinner, audioLabel, audioList, audioVolSpinner, enableCheck, replayEnableCheck, app
    app = ac.newApp("Ultimate Spotter Settings")
    ac.log("SPOTTER: Initializing UI...")

    audioSpinner = ac.addSpinner(app, "Audio")
    audioLabel = ac.addLabel(app, "{}".format(audio))
    audioVolSpinner = ac.addSpinner(app, "Volume")

    enableCheck = ac.addCheckBox(app, "Enable Spotter")
    replayEnableCheck = ac.addCheckBox(app, "Enabled in Replays")

    ac.setSize(app, 300, 220)

    ac.setPosition(enableCheck, 60, 50)
    ac.setValue(enableCheck, USEnabled)
    ac.addOnCheckBoxChanged(enableCheck, onEnableCheck)

    ac.setPosition(replayEnableCheck, 60, 100)
    ac.setValue(replayEnableCheck, USReplayEnabled)
    ac.addOnCheckBoxChanged(replayEnableCheck, onReplayEnableCheck)

    ac.setFontAlignment(audioLabel, "center")
    ac.setPosition(audioLabel, 90, 150)
    ac.setSize(audioSpinner, 100, 20)
    ac.setPosition(audioSpinner, 40, 150)

    audioList = os.listdir(os.path.join(os.path.dirname(__file__), "audio"))
    ac.setRange(audioSpinner, 0, len(audioList) - 1)
    ac.setStep(audioSpinner, 1)
    #ac.setValue(audioSpinner,audioList.index(audio))
    ac.addOnValueChangeListener(audioSpinner, onAudioSpin)

    ac.setSize(audioVolSpinner, 80, 20)
    ac.setPosition(audioVolSpinner, 180, 150)
    ac.setStep(audioVolSpinner, 1)
    ac.setRange(audioVolSpinner, 1, 10)
    ac.setValue(audioVolSpinner, audioVol)
    ac.addOnValueChangeListener(audioVolSpinner, onAudioVolSpin)
    ac.log("SPOTTER: UI Loaded")
示例#23
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)
示例#24
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"
示例#25
0
    def __init__(self, configs: Config):
        """ Default constructor. """
        self.__buttons = {}
        self.__options = {
            "Camber": configs.get_bool_option("Camber"),
            "Dirt": configs.get_bool_option("Dirt"),
            "Height": configs.get_bool_option("Height"),
            "Load": configs.get_bool_option("Load"),
            "Lock": configs.get_bool_option("Lock"),
            "Logging": configs.get_bool_option("Logging"),
            "Pressure": configs.get_bool_option("Pressure"),
            "RPMPower": configs.get_bool_option("RPMPower"),
            "Size": configs.get_option("Size"),
            "Suspension": configs.get_bool_option("Suspension"),
            "Temps": configs.get_bool_option("Temps"),
            "Tire": configs.get_bool_option("Tire"),
            "Wear": configs.get_bool_option("Wear")
        }

        self.__window_id = ac.newApp("Live Telemetry")
        ac.setIconPosition(self.__window_id, 0, -10000)
        title = "Live Telemetry {}".format(configs.get_version())
        ac.setTitle(self.__window_id, title)

        position = configs.get_window_position("OP")
        ac.setPosition(self.__window_id, *position)

        ac.setSize(self.__window_id, 395, 195)

        for index, name in enumerate(sorted(self.__options.keys())):
            text = str(name) if name != "Size" else self.__options[name]
            self.__buttons[name] = ac.addButton(self.__window_id, text)
            x = 30 + (floor(index / 4) * 85)
            y = 30 + (floor(index % 4) * 35)
            ac.setPosition(self.__buttons[name], x, y)
            ac.setSize(self.__buttons[name], 80, 30)
            ac.setFontAlignment(self.__buttons[name], "center")
            self.set_option(name, self.__options[name])
def acMain(ac_version):
    global ui_flag, flag, appWindow, font_size

    width = 8 * font_size
    height = 2 * font_size

    appName = "Better Flags"
    appWindow = ac.newApp(appName)
    ac.setTitle(appWindow, "")
    ac.setSize(appWindow, int(width), int(height))
    ac.drawBorder(appWindow, 0)
    ac.setBackgroundOpacity(appWindow, 0)
    ac.setIconPosition(appWindow, 0, -10000)

    ui_flag = ac.addLabel(appWindow, "")
    ac.setCustomFont(ui_flag, "Roboto", 0, 1)
    ac.setFontAlignment(ui_flag, "center")
    ac.setPosition(ui_flag, int(width / 2),
                   (int(height / 2) - int(font_size / 2)))
    ac.setFontSize(ui_flag, int(font_size))
    ac.setText(ui_flag, "")

    return appName
示例#27
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"
示例#28
0
def create_debug_labels():
    global flLabel, frLabel, rlLabel, rrLabel, upperDistance, distanceFromLeft, tyreWidth, tyreHeight, angle_delta_label
    flLabel = ac.addLabel(appWindow, "0.0")
    ac.setPosition(flLabel, distanceFromLeft, upperDistance + tyreHeight)
    ac.setFontAlignment(flLabel, "right")

    frLabel = ac.addLabel(appWindow, "0.0")
    ac.setPosition(frLabel, distanceFromLeft + tyreWidth + tyreWidth, upperDistance + tyreHeight)
    ac.setFontAlignment(frLabel, "left")

    rlLabel = ac.addLabel(appWindow, "0.0")
    ac.setPosition(rlLabel, distanceFromLeft, upperDistance + tyreHeight * 2 + tyreHeight)
    ac.setFontAlignment(rlLabel, "right")

    rrLabel = ac.addLabel(appWindow, "0.0")
    ac.setPosition(rrLabel, distanceFromLeft + tyreWidth + tyreWidth, upperDistance + tyreHeight * 2 + tyreHeight)
    ac.setFontAlignment(rrLabel, "left")

    angle_delta_label = ac.addLabel(appWindow, "0.0")
    ac.setPosition(angle_delta_label, 0, upperDistance + tyreHeight * 3 + 50)
示例#29
0
    def __init__(self, name, headerName):    
        self.headerName = headerName
        self.window = ac.newApp(name)

        self.lapNumberLabel = []
        self.timeLabel = []
        self.deltaLabel = []
        self.lastLapDataRefreshed = -1
        self.lastLapViewRefreshed = 0
        self.total = 0
        self.bestLapAc = 0
        self.bestLapTimeSession = 0
        self.bestLapTime = 0
        self.referenceTime = 0
        self.laps = []
        self.bestLapData = []
        self.currentLapData = [(0.0,0.0)]
        self.sfCrossed = 0
        self.session = info.graphics.session
        self.lastSession = 0
        self.lapInvalidated = 0
        self.justCrossedSf = False
        self.position = 0
        self.lastPosition = 0
        self.currentTime = 0
        self.lastCurrentTime = 0
        self.pitExitState = 0
        self.pitExitDeltaOffset = 0
        self.pitExitLap = 0

        self.readBestLap()

        self.currLabelId = lapLabelCount
        self.refLabelId = lapLabelCount+1
        self.totalLabelId = lapLabelCount+2

        for index in range(lapLabelCount+3):
            self.lapNumberLabel.append(ac.addLabel(self.window, "%d." % (index+1)))
            ac.setFontAlignment(self.lapNumberLabel[index], 'left')

            self.timeLabel.append(ac.addLabel(self.window, timeToString(0)))
            ac.setFontAlignment(self.timeLabel[index], 'right')

            self.deltaLabel.append(ac.addLabel(self.window, "-.---"))
            ac.setFontAlignment(self.deltaLabel[index], 'right')

        ac.setText(self.lapNumberLabel[self.currLabelId],  "Curr.")
        ac.setText(self.lapNumberLabel[self.totalLabelId], "Tot.")
    def __init__(self, appName):
        self.timer = 0

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

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

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

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

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

        self.timeLabel = ac.addLabel(self.window, "")
        ac.setPosition(self.timeLabel, w + 385, 22)
        ac.setFontSize(self.timeLabel, 35)
        ac.setCustomFont(self.timeLabel, FC.FONT_NAME, 0, 1)
        ac.setFontColor(self.timeLabel, 0.86, 0.86, 0.86, 1)
        ac.setFontAlignment(self.timeLabel, "right")
def 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
示例#32
0
 def __init__(self, app, x, y):
   x_pressure = x
   x_dirt = x_pressure
   x_maxt = x + 80
   x_maxp = x_maxt
   
   y_pressure = y + 20
   y_dirt = y_pressure + 20
   y_maxt = y + 8
   y_maxp = y_maxt + 20
   
   self.maxtFL = 0
   self.maxtFR = 0
   self.maxtRL = 0
   self.maxtRR = 0
   
   self.maxpFL = 0
   self.maxpFR = 0
   self.maxpRL = 0
   self.maxpRR = 0
   
   self.unitChar = "C"
   
   if inFahrenheit:
     self.unitChar = "F"
   
   ##initialize labels
   
   self.tFLValue = ac.addLabel(app, "temp fl")
   self.tFRValue = ac.addLabel(app, "temp fr")
   self.tRLValue = ac.addLabel(app, "temp rl")
   self.tRRValue = ac.addLabel(app, "temp rr")
   self.pFLValue = ac.addLabel(app, "psi fl")
   self.pFRValue = ac.addLabel(app, "psi fr")
   self.pRLValue = ac.addLabel(app, "psi rl")
   self.pRRValue = ac.addLabel(app, "psi rr")
   self.dFLValue = ac.addLabel(app, "dirt fl")
   self.dFRValue = ac.addLabel(app, "dirt fr")
   self.dRLValue = ac.addLabel(app, "dirt rl")
   self.dRRValue = ac.addLabel(app, "dirt rr")
   self.maxFont = ac.addLabel(app, "Max")
   self.maxtFont = ac.addLabel(app, self.unitChar)
   self.maxpFont = ac.addLabel(app, "psi")
   self.maxtFontBottom = ac.addLabel(app, self.unitChar)
   self.maxpFontBottom = ac.addLabel(app, "psi")
   self.maxtFLValue = ac.addLabel(app, "maxtemp fl")
   self.maxtFRValue = ac.addLabel(app, "maxtemp fr")
   self.maxtRLValue = ac.addLabel(app, "maxtemp rl")
   self.maxtRRValue = ac.addLabel(app, "maxtemp rr")
   self.maxpFLValue = ac.addLabel(app, "maxpress fl")
   self.maxpFRValue = ac.addLabel(app, "maxpress fr")
   self.maxpRLValue = ac.addLabel(app, "maxpress rl")
   self.maxpRRValue = ac.addLabel(app, "maxpress rr")
   
   ##set label positions
   
   ac.setPosition(self.tFLValue, x - 152, y)
   ac.setPosition(self.tFRValue, x + x_space, y)
   ac.setPosition(self.tRLValue, x - 152, y + y_space)
   ac.setPosition(self.tRRValue, x + x_space, y + y_space)
   ac.setPosition(self.pFLValue, x_pressure - 152, y_pressure)
   ac.setPosition(self.pFRValue, x_pressure + x_space, y_pressure)
   ac.setPosition(self.pRLValue, x_pressure - 152, y_pressure + y_space)
   ac.setPosition(self.pRRValue, x_pressure + x_space, y_pressure + y_space)
   ac.setPosition(self.dFLValue, x_dirt - 152, y_dirt)
   ac.setPosition(self.dFRValue, x_dirt + x_space, y_dirt)
   ac.setPosition(self.dRLValue, x_dirt - 152, y_dirt + y_space)
   ac.setPosition(self.dRRValue, x_dirt + x_space, y_dirt + y_space)
   ac.setPosition(self.maxFont, 137, 28)
   ac.setPosition(self.maxtFont, 145, 48)
   ac.setPosition(self.maxpFont, 140, 68)
   ac.setPosition(self.maxtFontBottom, 145, 123)
   ac.setPosition(self.maxpFontBottom, 140, 143)
   ac.setPosition(self.maxtFLValue, x_maxt, y_maxt)
   ac.setPosition(self.maxtFRValue, x_maxt - 96, y_maxt)
   ac.setPosition(self.maxtRLValue, x_maxt, y_maxt + y_space)
   ac.setPosition(self.maxtRRValue, x_maxt - 96, y_maxt + y_space)
   ac.setPosition(self.maxpFLValue, x_maxp, y_maxp)
   ac.setPosition(self.maxpFRValue, x_maxp - 96, y_maxp)
   ac.setPosition(self.maxpRLValue, x_maxp, y_maxp + y_space)
   ac.setPosition(self.maxpRRValue, x_maxp - 96, y_maxp + y_space)
   
   ##set label alignments
   
   ac.setFontAlignment(self.tFLValue, "right")
   ac.setFontAlignment(self.tRLValue, "right")
   ac.setFontAlignment(self.pFLValue, "right")
   ac.setFontAlignment(self.pRLValue, "right")
   ac.setFontAlignment(self.dFLValue, "right")
   ac.setFontAlignment(self.dRLValue, "right")
   ac.setFontAlignment(self.maxtFLValue, "left")    
   ac.setFontAlignment(self.maxtFRValue, "right")
   ac.setFontAlignment(self.maxtRLValue, "left")
   ac.setFontAlignment(self.maxtRRValue, "right")
   ac.setFontAlignment(self.maxpFLValue, "left")
   ac.setFontAlignment(self.maxpFRValue, "right")
   ac.setFontAlignment(self.maxpRLValue, "left")
   ac.setFontAlignment(self.maxpRRValue, "right")
   
   ##set font size
   
   ac.setFontSize(self.maxFont, 12)
   ac.setFontSize(self.maxtFont, 12)
   ac.setFontSize(self.maxpFont, 12)
   ac.setFontSize(self.maxtFontBottom, 12)
   ac.setFontSize(self.maxpFontBottom, 12)
   ac.setFontSize(self.maxtFLValue, 12)
   ac.setFontSize(self.maxtFRValue, 12)  
   ac.setFontSize(self.maxtRLValue, 12)
   ac.setFontSize(self.maxtRRValue, 12)
   ac.setFontSize(self.maxpFLValue, 12)
   ac.setFontSize(self.maxpFRValue, 12)
   ac.setFontSize(self.maxpRLValue, 12)
   ac.setFontSize(self.maxpRRValue, 12)
 def text_align(self, value):
     self._text_align = value
     if value in ('left', 'center', 'right'):
         ac.setFontAlignment(self.id, value)
     else:
         ac.console("Text align <{}> is not supported.".format(value))
 def setAlign(self, align):
     ac.setFontAlignment(self.button, align)
     return self
 def setFontAlign(self, fontAlign = "left"):
     self.labelFontAlign = fontAlign
     ac.setFontAlignment(self.label, self.labelFontAlign)
     return self
示例#36
0
    def __init__(self, name, headerName, fontSize, showHeader):
        self.headerName = headerName
        self.window = ac.newApp(name)
        if showHeader == 1:
            ac.setTitle(self.window, "")
            ac.setIconPosition(self.window, -10000, -10000)
            self.firstSpacing = 0
        else:
            ac.setTitle(self.window, headerName)
            self.firstSpacing = firstSpacing

        self.fontSize = fontSize

        widthLeft       = fontSize*8
        widthCenter     = fontSize*5
        widthRight      = fontSize*5
        self.width      = widthLeft + widthCenter + widthRight + 2*spacing
        height          = self.firstSpacing + (fontSize*1.5 + spacing)*20

        ac.setSize(self.window, self.width, height)

        self.leftLabel = []
        self.centerLabel = []
        self.changeButton = []
        self.plusButton = []
        self.minusButton = []

        for index in range(20):
            self.leftLabel.append(ac.addLabel(self.window, ""))
            ac.setFontSize(self.leftLabel[index], fontSize)
            ac.setPosition(self.leftLabel[index], spacing, self.firstSpacing + index*(fontSize*1.5+spacing))
            ac.setSize(self.leftLabel[index], widthLeft, fontSize+spacing)
            ac.setFontAlignment(self.leftLabel[index], 'left')

            self.centerLabel.append(ac.addLabel(self.window, ""))
            ac.setFontSize(self.centerLabel[index], fontSize)
            ac.setPosition(self.centerLabel[index], spacing + widthLeft, self.firstSpacing + index*(fontSize*1.5+spacing))
            ac.setSize(self.centerLabel[index], widthCenter, fontSize+spacing)
            ac.setFontAlignment(self.centerLabel[index], 'left')

            self.changeButton.append(ac.addButton(self.window, "Change"))
            ac.setFontSize(self.changeButton[index], self.fontSize)
            ac.setPosition(self.changeButton[index], spacing + widthLeft + widthCenter, self.firstSpacing + index*(fontSize*1.5+spacing))
            ac.setSize(self.changeButton[index], fontSize*4, fontSize*1.5)

            self.plusButton.append(ac.addButton(self.window, "+"))
            ac.setFontSize(self.plusButton[index], self.fontSize)
            ac.setPosition(self.plusButton[index], spacing + widthLeft + widthCenter, self.firstSpacing + index*(fontSize*1.5+spacing))
            ac.setSize(self.plusButton[index], fontSize*1.5, fontSize*1.5)

            self.minusButton.append(ac.addButton(self.window, "-"))
            ac.setFontSize(self.minusButton[index], self.fontSize)
            ac.setPosition(self.minusButton[index], spacing + widthLeft + widthCenter + fontSize*2.5, self.firstSpacing + index*(fontSize*1.5+spacing))
            ac.setSize(self.minusButton[index], fontSize*1.5, fontSize*1.5)
            
        rowIndex = 0

        ac.setText(self.leftLabel[rowIndex], "Show header:")
        ac.addOnClickedListener(self.changeButton[rowIndex], toggleHeader)
        ac.setVisible(self.plusButton[rowIndex], 0)
        ac.setVisible(self.minusButton[rowIndex], 0)
        self.showHeaderId = rowIndex

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Font size:")
        ac.setVisible(self.changeButton[rowIndex], 0)
        ac.addOnClickedListener(self.plusButton[rowIndex], fontSizePlus)
        ac.addOnClickedListener(self.minusButton[rowIndex], fontSizeMinus)
        self.fontSizeId = rowIndex

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Opacity:")
        ac.setVisible(self.changeButton[rowIndex], 0)
        ac.addOnClickedListener(self.plusButton[rowIndex], opacityPlus)
        ac.addOnClickedListener(self.minusButton[rowIndex], opacityMinus)
        self.opacityId = rowIndex

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Show border:")
        ac.addOnClickedListener(self.changeButton[rowIndex], toggleBorder)
        ac.setVisible(self.plusButton[rowIndex], 0)
        ac.setVisible(self.minusButton[rowIndex], 0)
        self.showBorderId = rowIndex

        rowIndex += 1

        ac.setVisible(self.changeButton[rowIndex], 0)
        ac.setVisible(self.plusButton[rowIndex], 0)
        ac.setVisible(self.minusButton[rowIndex], 0)

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Lap count:")
        ac.setVisible(self.changeButton[rowIndex], 0)
        ac.addOnClickedListener(self.plusButton[rowIndex], lapCountPlus)
        ac.addOnClickedListener(self.minusButton[rowIndex], lapCountMinus)
        self.lapCountId = rowIndex

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Show delta:")
        ac.addOnClickedListener(self.changeButton[rowIndex], toggleDelta)
        ac.setVisible(self.plusButton[rowIndex], 0)
        ac.setVisible(self.minusButton[rowIndex], 0)
        self.showDeltaId = rowIndex

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Delta color:")
        ac.addOnClickedListener(self.changeButton[rowIndex], toggleColor)
        ac.setVisible(self.plusButton[rowIndex], 0)
        ac.setVisible(self.minusButton[rowIndex], 0)
        self.deltaColorId = rowIndex

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Red at:")
        ac.setVisible(self.changeButton[rowIndex], 0)
        ac.addOnClickedListener(self.plusButton[rowIndex], redAtPlus)
        ac.addOnClickedListener(self.minusButton[rowIndex], redAtMinus)
        self.redAtId = rowIndex

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Green at:")
        ac.setVisible(self.changeButton[rowIndex], 0)
        ac.addOnClickedListener(self.plusButton[rowIndex], greenAtPlus)
        ac.addOnClickedListener(self.minusButton[rowIndex], greenAtMinus)
        self.greenAtId = rowIndex

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Show curr.:")
        ac.addOnClickedListener(self.changeButton[rowIndex], toggleCurrent)
        ac.setVisible(self.plusButton[rowIndex], 0)
        ac.setVisible(self.minusButton[rowIndex], 0)
        self.showCurrentId = rowIndex

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Reference:")
        ac.addOnClickedListener(self.changeButton[rowIndex], toggleRefSource)
        ac.setVisible(self.plusButton[rowIndex], 0)
        ac.setVisible(self.minusButton[rowIndex], 0)
        self.referenceId = rowIndex

        rowIndex += 1
        
        ac.setText(self.leftLabel[rowIndex], "Show ref.:")
        ac.addOnClickedListener(self.changeButton[rowIndex], toggleRef)
        ac.setVisible(self.plusButton[rowIndex], 0)
        ac.setVisible(self.minusButton[rowIndex], 0)
        self.showReferenceId = rowIndex

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Show total:")
        ac.addOnClickedListener(self.changeButton[rowIndex], toggleTotal)
        ac.setVisible(self.plusButton[rowIndex], 0)
        ac.setVisible(self.minusButton[rowIndex], 0)
        self.showTotalId = rowIndex

        rowIndex += 1
        
        ac.setVisible(self.changeButton[rowIndex], 0)
        ac.setVisible(self.plusButton[rowIndex], 0)
        ac.setVisible(self.minusButton[rowIndex], 0)

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Refresh every:")
        ac.setVisible(self.changeButton[rowIndex], 0)
        ac.addOnClickedListener(self.plusButton[rowIndex], refreshPlus)
        ac.addOnClickedListener(self.minusButton[rowIndex], refreshMinus)
        self.refreshId = rowIndex

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Log sessions:")
        ac.addOnClickedListener(self.changeButton[rowIndex], toggleLogLaps)
        ac.setVisible(self.plusButton[rowIndex], 0)
        ac.setVisible(self.minusButton[rowIndex], 0)
        self.logLapsId = rowIndex

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Remember best:")
        ac.addOnClickedListener(self.changeButton[rowIndex], toggleLogBest)
        ac.setVisible(self.plusButton[rowIndex], 0)
        ac.setVisible(self.minusButton[rowIndex], 0)
        self.logBestId = rowIndex

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Best lap:")
        ac.addOnClickedListener(self.changeButton[rowIndex], resetBestLap)
        ac.setText(self.changeButton[rowIndex], "Reset")
        ac.setVisible(self.plusButton[rowIndex], 0)
        ac.setVisible(self.minusButton[rowIndex], 0)
        self.resetBestLapId = rowIndex

        rowIndex += 1

        ac.setText(self.leftLabel[rowIndex], "Lock best:")
        ac.addOnClickedListener(self.changeButton[rowIndex], toggleLockBest)
        ac.setVisible(self.plusButton[rowIndex], 0)
        ac.setVisible(self.minusButton[rowIndex], 0)
        self.lockBestId = rowIndex
 def setAlign(self, align):
     ac.setFontAlignment(self.label, align)
     return self
示例#38
0
    def __init__(self, app, x, y):
        x_pressure = x
        x_dirt = x_pressure
        x_maxt = x + 80
        x_maxp = x_maxt

        y_pressure = y + 20
        y_dirt = y_pressure + 20
        y_maxt = y + 8
        y_maxp = y_maxt + 20

        self.maxtFL = 0
        self.maxtFR = 0
        self.maxtRL = 0
        self.maxtRR = 0

        self.maxpFL = 0
        self.maxpFR = 0
        self.maxpRL = 0
        self.maxpRR = 0

        self.unitChar = "C"

        if inFahrenheit:
            self.unitChar = "F"

        ##initialize labels

        self.tFLValue = ac.addLabel(app, "temp fl")
        self.tFRValue = ac.addLabel(app, "temp fr")
        self.tRLValue = ac.addLabel(app, "temp rl")
        self.tRRValue = ac.addLabel(app, "temp rr")
        self.pFLValue = ac.addLabel(app, "psi fl")
        self.pFRValue = ac.addLabel(app, "psi fr")
        self.pRLValue = ac.addLabel(app, "psi rl")
        self.pRRValue = ac.addLabel(app, "psi rr")
        self.dFLValue = ac.addLabel(app, "dirt fl")
        self.dFRValue = ac.addLabel(app, "dirt fr")
        self.dRLValue = ac.addLabel(app, "dirt rl")
        self.dRRValue = ac.addLabel(app, "dirt rr")
        self.maxFont = ac.addLabel(app, "Max")
        self.maxtFont = ac.addLabel(app, self.unitChar)
        self.maxpFont = ac.addLabel(app, "psi")
        self.maxtFontBottom = ac.addLabel(app, self.unitChar)
        self.maxpFontBottom = ac.addLabel(app, "psi")
        self.maxtFLValue = ac.addLabel(app, "maxtemp fl")
        self.maxtFRValue = ac.addLabel(app, "maxtemp fr")
        self.maxtRLValue = ac.addLabel(app, "maxtemp rl")
        self.maxtRRValue = ac.addLabel(app, "maxtemp rr")
        self.maxpFLValue = ac.addLabel(app, "maxpress fl")
        self.maxpFRValue = ac.addLabel(app, "maxpress fr")
        self.maxpRLValue = ac.addLabel(app, "maxpress rl")
        self.maxpRRValue = ac.addLabel(app, "maxpress rr")

        ##set label positions

        ac.setPosition(self.tFLValue, x - 152, y)
        ac.setPosition(self.tFRValue, x + x_space, y)
        ac.setPosition(self.tRLValue, x - 152, y + y_space)
        ac.setPosition(self.tRRValue, x + x_space, y + y_space)
        ac.setPosition(self.pFLValue, x_pressure - 152, y_pressure)
        ac.setPosition(self.pFRValue, x_pressure + x_space, y_pressure)
        ac.setPosition(self.pRLValue, x_pressure - 152, y_pressure + y_space)
        ac.setPosition(self.pRRValue, x_pressure + x_space,
                       y_pressure + y_space)
        ac.setPosition(self.dFLValue, x_dirt - 152, y_dirt)
        ac.setPosition(self.dFRValue, x_dirt + x_space, y_dirt)
        ac.setPosition(self.dRLValue, x_dirt - 152, y_dirt + y_space)
        ac.setPosition(self.dRRValue, x_dirt + x_space, y_dirt + y_space)
        ac.setPosition(self.maxFont, 137, 28)
        ac.setPosition(self.maxtFont, 145, 48)
        ac.setPosition(self.maxpFont, 140, 68)
        ac.setPosition(self.maxtFontBottom, 145, 123)
        ac.setPosition(self.maxpFontBottom, 140, 143)
        ac.setPosition(self.maxtFLValue, x_maxt, y_maxt)
        ac.setPosition(self.maxtFRValue, x_maxt - 96, y_maxt)
        ac.setPosition(self.maxtRLValue, x_maxt, y_maxt + y_space)
        ac.setPosition(self.maxtRRValue, x_maxt - 96, y_maxt + y_space)
        ac.setPosition(self.maxpFLValue, x_maxp, y_maxp)
        ac.setPosition(self.maxpFRValue, x_maxp - 96, y_maxp)
        ac.setPosition(self.maxpRLValue, x_maxp, y_maxp + y_space)
        ac.setPosition(self.maxpRRValue, x_maxp - 96, y_maxp + y_space)

        ##set label alignments

        ac.setFontAlignment(self.tFLValue, "right")
        ac.setFontAlignment(self.tRLValue, "right")
        ac.setFontAlignment(self.pFLValue, "right")
        ac.setFontAlignment(self.pRLValue, "right")
        ac.setFontAlignment(self.dFLValue, "right")
        ac.setFontAlignment(self.dRLValue, "right")
        ac.setFontAlignment(self.maxtFLValue, "left")
        ac.setFontAlignment(self.maxtFRValue, "right")
        ac.setFontAlignment(self.maxtRLValue, "left")
        ac.setFontAlignment(self.maxtRRValue, "right")
        ac.setFontAlignment(self.maxpFLValue, "left")
        ac.setFontAlignment(self.maxpFRValue, "right")
        ac.setFontAlignment(self.maxpRLValue, "left")
        ac.setFontAlignment(self.maxpRRValue, "right")

        ##set font size

        ac.setFontSize(self.maxFont, 12)
        ac.setFontSize(self.maxtFont, 12)
        ac.setFontSize(self.maxpFont, 12)
        ac.setFontSize(self.maxtFontBottom, 12)
        ac.setFontSize(self.maxpFontBottom, 12)
        ac.setFontSize(self.maxtFLValue, 12)
        ac.setFontSize(self.maxtFRValue, 12)
        ac.setFontSize(self.maxtRLValue, 12)
        ac.setFontSize(self.maxtRRValue, 12)
        ac.setFontSize(self.maxpFLValue, 12)
        ac.setFontSize(self.maxpFRValue, 12)
        ac.setFontSize(self.maxpRLValue, 12)
        ac.setFontSize(self.maxpRRValue, 12)
示例#39
0
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
示例#40
0
文件: classes.py 项目: acclub/apps
	def setAlign(self, align = "left"):
		self.align = align
		ac.setFontAlignment(self.label, self.align)
		return self