def loadDelta(self): self.deltaLoaded = True file = self.getDeltaFilePath() if os.path.exists(file): try: with gzip.open(file, "rt") as data_file: data = json.load(data_file) self.referenceLapTime.setValue(data["lap"]) times = data["times"] self.referenceLap = [] for t in times: self.referenceLap.append(raceGaps(t[0], t[1])) ac.console("AC Delta: File loaded") except: Log.w("Error tower")
def listen_key(self): try: # ctypes.windll.user32.RegisterHotKey(None, 1, 0, apps.util.win32con.VK_F7) ctypes.windll.user32.RegisterHotKey(None, 1, apps.util.win32con.MOD_CONTROL, 0x44) # CTRL+D msg = ctypes.wintypes.MSG() while self.listen_active: if ctypes.windll.user32.GetMessageA(ctypes.byref(msg), None, 0, 0) != 0: # ac.console("loopmess."+ str(msg.message)) if msg.message == apps.util.win32con.WM_HOTKEY: self.hotkey_pressed() ctypes.windll.user32.TranslateMessage(ctypes.byref(msg)) ctypes.windll.user32.DispatchMessageA(ctypes.byref(msg)) except: Log.w("Error") finally: ctypes.windll.user32.UnregisterHotKey(None, 1)
def saveDelta(self): # ac.log(str(time.time())+" saveDelta start:") referenceLap = list(self.referenceLap) # referenceLap=self.referenceLap referenceLapTime = self.referenceLapTime.value if len(referenceLap) > 0: try: times = [] for l in referenceLap: times.append((l.sector, l.time)) data_file = { "lap": referenceLapTime, "times": times, "track": ac.getTrackName(0), "config": ac.getTrackConfiguration(0), "car": ac.getCarName(0), "user": ac.getDriverName(0), } file = self.getDeltaFilePath() with gzip.open(file, "wt") as outfile: json.dump(data_file, outfile) except: Log.w("Error tower")
def acMain(ac_version): global sim_info, timer, info, tower, speed, timerInit, infoInit, towerInit, speedInit, config, configInit, delta, deltaInit try: config = Configuration() configInit = True except: Log.w("Error init config") try: timer = ACTimer(sim_info) timerInit = True except: Log.w("Error init timer") try: info = ACInfo(sim_info) infoInit = True except: Log.w("Error init info") try: tower = ACTower(sim_info) towerInit = True except: Log.w("Error init tower") try: speed = ACSpeedTrap() speedInit = True except: Log.w("Error init speedtrap") try: delta = ACDelta() deltaInit = True except: Log.w("Error init delta") return "Prunn"
def acUpdate(deltaT): global refresh_time current_time = time.time() refresh_time.setValue(int(current_time * Configuration.refresh_rate)) # 50 = 0.02 sec if refresh_time.hasChanged(): global sim_info, game_data, timer, info, tower, speed, timerInit, infoInit, towerInit, speedInit, config, drivers_info_init, configInit, delta, deltaInit fl = 0 standings = [] drivers_info = [] game_data.update(sim_info) if configInit: try: config_changed = config.on_update(game_data) if config_changed: if timerInit: timer.load_cfg() if infoInit: info.load_cfg() if towerInit: tower.load_cfg() if speedInit: speed.load_cfg() except: Log.w("Error config") if timerInit: try: timer.on_update(sim_info, game_data) except: Log.w("Error timer") if towerInit: try: tower.on_update(sim_info, game_data) fl = tower.get_fastest_lap() standings = tower.get_standings() if not drivers_info_init or tower.drivers_info_is_updated(): drivers_info = tower.get_drivers_info() except: Log.w("Error tower") if infoInit: try: if len(drivers_info): info.set_drivers_info(drivers_info) drivers_info_init = True info.on_update(sim_info, fl, standings, game_data) except: Log.w("Error info") if speedInit: try: speed.on_update(sim_info, game_data) except: Log.w("Error speedtrap") if deltaInit: try: delta.on_update(sim_info, game_data) except: Log.w("Error delta")
def acMain(ac_version): global timer,info,tower,speed,timerInit,infoInit,towerInit,speedInit,config,configInit,delta,deltaInit try: config=Configuration() configInit=True except: Log.w("Error init config") try: timer=ACTimer() timerInit=True except: Log.w("Error init timer") try: info=ACInfo() infoInit=True except: Log.w("Error init info") try: tower=ACTower() towerInit=True except: Log.w("Error init tower") try: speed=ACSpeedTrap() speedInit=True except: Log.w("Error init speedtrap") try: delta=ACDelta() deltaInit=True except: Log.w("Error init delta") ''' try: fontName="Khula" #fontName="Noto Sans UI Light" if ac.initFont(0,fontName,0,0) > 0: if timerInit: timer.setFont(fontName) if infoInit: info.setFont(fontName) if towerInit: tower.setFont(fontName) if speedInit: speed.setFont(fontName) else: ac.console("font init failed") except: Log.w("Error init font") ''' return "Prunn"
def acUpdate(deltaT): global timer,info,tower,speed,timerInit,infoInit,towerInit,speedInit,config,configInit,delta,deltaInit configChanged=False fl=0 if configInit: try: configChanged = config.onUpdate(sim_info) if configChanged: if timerInit: timer.loadCFG() if infoInit: info.loadCFG() if towerInit: tower.loadCFG() if speedInit: speed.loadCFG() except: Log.w("Error config") if timerInit: try: timer.onUpdate(sim_info) except: Log.w("Error timer") if towerInit: try: tower.onUpdate(sim_info) fl=tower.getFastestLap() except: Log.w("Error tower") if infoInit: try: info.onUpdate(sim_info,fl) except: Log.w("Error info") if speedInit: try: speed.onUpdate(sim_info) except: Log.w("Error speedtrap") if deltaInit: try: delta.onUpdate(sim_info) except: Log.w("Error delta")
def acUpdate(deltaT): global timer, info, tower, speed, timerInit, infoInit, towerInit, speedInit, config, configInit, delta, deltaInit fl = 0 standings = [] if configInit: try: config_changed = config.on_update(sim_info) if config_changed: if timerInit: timer.load_cfg() if infoInit: info.load_cfg() if towerInit: tower.load_cfg() if speedInit: speed.load_cfg() except: Log.w("Error config") if timerInit: try: timer.on_update(sim_info) except: Log.w("Error timer") if towerInit: try: tower.on_update(sim_info) fl = tower.get_fastest_lap() standings = tower.get_standings() except: Log.w("Error tower") if infoInit: try: info.on_update(sim_info, fl, standings) except: Log.w("Error info") if speedInit: try: speed.on_update(sim_info) except: Log.w("Error speedtrap") if deltaInit: try: delta.on_update(sim_info) except: Log.w("Error delta")