def get_sessions_data_from_server(self): try: server_ip = ac.getServerIP() port = ac.getServerHttpPort() if server_ip != '' and port > 0: conn = http.client.HTTPConnection(ac.getServerIP(), port=port) conn.request("GET", "/INFO") response = conn.getresponse() data = json.loads(response.read().decode('utf-8', errors='ignore')) conn.close() ''' timeofday: -72 sessiontypes [ 1, 2, 3 ] durations [ 2, 2, 12 ] ''' i=0 for t in data["sessiontypes"]: self.sessions_duration[t-1] = float(data["durations"][i])*60000 i+=1 self.sessionMaxTime = self.sessions_duration[2] # from server self.time_multiplier = 1 # no way of knowing, game log? self.start_time_of_day_original = self.start_time_of_day = (780 + 3.75 * float(data["timeofday"])) * 60000 self.last_start_time_offset = self.start_time_of_day + (self.sessions_duration[self.session.value] - self.session_time_left)*self.time_multiplier except: Log.w("Error tower") self.session_info_imported = True
def __init__(self): self.player = None self.prepare() helipicapewthreading.initConstants() self.isSingleplayer = not ac.getServerIP() or ac.getServerIP().isspace()
def __init__(self): self.window = Window(name="ACTV CP Delta", width=180, height=300) self.cursor = Value(False) self.session = Value(-1) self.performance = Value(0) self.spline = Value(0) self.currentVehicle = Value(-1) self.laptime = Value(0) self.TimeLeftUpdate = Value(0) self.referenceLap = [] self.referenceLapTime = Value(0) self.lastLapTime = Value(0) self.lapCount = 0 self.performance_display = 0 self.current_car_class = Value("") self.lastLapIsValid = True self.best_lap_time = 0 self.visual_timeout = -1 self.currentLap = [] self.drivers_info = [] self.deltaLoaded = False self.thread_save = False self.last_yellow_flag_end = False self.standings = None self.rowHeight = Value(-1) self.is_multiplayer = ac.getServerIP() != '' self.numCars = self.cars_count = ac.getCarsCount() self.font_size = 16 self.is_touristenfahrten = False track = ac.getTrackName(0) config = ac.getTrackConfiguration(0) if track.find("ks_nordschleife") >= 0 and config.find( "touristenfahrten") >= 0: self.is_touristenfahrten = True self.current_lap_others = [] self.spline_others = [] self.drivers_lap_count = [] self.reference_lap_time_others = [] for i in range(self.cars_count): self.drivers_lap_count.append(Value(0)) self.spline_others.append(Value(0)) self.current_lap_others.append([]) self.reference_lap_time_others.append([]) self.last_lap_start = [-1] * self.cars_count self.lbl_flag = Label(self.window.app)\ .set(w=77, h=50, x=1, y=-80, background=Colors.white(bg=True), opacity=1) self.lbl_number_bg = Label(self.window.app)\ .set(w=77, h=0, x=0, y=0, background=Colors.white(bg=True), opacity=1, visible=1) self.lbl_number_text = Label(self.window.app, "000")\ .set(w=77, h=0, x=0, y=0, opacity=0, color=Colors.black_txt(), font_size=26, align="center", visible=1) self.lbl_name_bg = Label(self.window.app)\ .set(w=77, h=0, x=0, y=0, opacity=1, visible=1) self.lbl_name_text = Label(self.window.app, "PLY")\ .set(w=77, h=0, x=0, y=0, opacity=0, font_size=26, align="center", visible=1) self.lbl_position_text_shadow = Label(self.window.app, "0")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="right", visible=1) self.lbl_position_text = Label(self.window.app, "0")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="right", visible=1) self.lbl_position_text_multi_shadow = Label(self.window.app, "0")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="right", visible=1) self.lbl_position_text_multi = Label(self.window.app, "0")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="right", visible=1) self.lbl_position_total_text_shadow = Label(self.window.app, "/0")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="left", visible=1) self.lbl_position_total_text = Label(self.window.app, "/0")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="left", visible=1) self.lbl_position_total_text_multi_shadow = Label(self.window.app, "/0")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="left", visible=1) self.lbl_position_total_text_multi = Label(self.window.app, "/0")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="left", visible=1) self.lbl_delta_bg = Label(self.window.app)\ .set(w=77, h=0, x=0, y=0, opacity=0, background=Colors.delta_neutral(), visible=1) self.lbl_current_time_bg = Label(self.window.app)\ .set(w=77, h=0, x=0, y=0, opacity=1, visible=1) self.lbl_current_time_text = Label(self.window.app, "--:--.---")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="left", visible=1) self.lbl_best_time_title_bg = Label(self.window.app)\ .set(w=0, h=0, x=0, y=0, opacity=1, visible=1) self.lbl_best_title_text = Label(self.window.app, "BEST")\ .set(w=77, h=0, x=0, y=0, opacity=0, font_size=26, align="left", visible=1) self.lbl_best_time_text = Label(self.window.app, "--:--.---")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="right", visible=1) self.lbl_last_title_bg = Label(self.window.app)\ .set(w=0, h=0, x=0, y=0, opacity=1, visible=1) self.lbl_last_title_text = Label(self.window.app, "LAST")\ .set(w=77, h=0, x=0, y=0, opacity=0, font_size=26, align="left", visible=1) self.lbl_last_time_text = Label(self.window.app, "--:--.---")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="right", visible=1) self.lbl_prediction_title_bg = Label(self.window.app)\ .set(w=0, h=0, x=0, y=0, opacity=1, visible=1) self.lbl_prediction_title_text = Label(self.window.app, "PRED")\ .set(w=77, h=0, x=0, y=0, opacity=0, font_size=26, align="left", visible=1) self.lbl_prediction_time_text = Label(self.window.app, "--:--.---")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="right", visible=1) self.lbl_delta_text = Label(self.window.app, "+0.00")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, color=Colors.black_txt(), align="center", visible=1) self.lbl_laps_completed_text_shadow = Label(self.window.app, "0")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="right", visible=1) self.lbl_laps_completed_text = Label(self.window.app, "0")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="right", visible=1) self.lbl_laps_text_shadow = Label(self.window.app, "LAPS")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="left", visible=1) self.lbl_laps_text = Label(self.window.app, "LAPS")\ .set(w=0, h=0, x=0, y=0, opacity=0, font_size=26, align="left", visible=1) self.btn_reset = Button(self.window.app, self.on_reset_press)\ .setPos(90, 68).setSize(120, 20)\ .setText("Reset saved lap")\ .setAlign("center")\ .setBgColor(rgb([255, 12, 12], bg=True))\ .setVisible(0) self.btn_import_from = Button(self.window.app, self.on_import_from_press)\ .setPos(90, 68).setSize(120, 20)\ .setText("Import Delta")\ .setAlign("center")\ .setBgColor(rgb([255, 12, 12], bg=True))\ .setVisible(0) self.load_cfg()
def initConstants(): global urlstr urlstr = 'http://app.minorating.com:806/minodata/drivers/?serverIp={}&serverPort={}'.format( ac.getServerIP(), ac.getServerHttpPort())
def ip(self): return ac.getServerIP()
def __init__(self, sim_info): self.replay_initialised = False self.replay_asc = False self.replay_rgb = 255 self.session = Value(-1) self.theme = Value(-1) self.cursor = Value(False) self.row_height = Value(-1) self.font = Value(0) self.numberOfLaps = -1 self.corner_width=0 self.hasExtraLap = sim_info.static.hasExtraLap self.numberOfLapsTimedRace = -1 self.sessionMaxTime = -1 self.pitWindowVisibleEnd = 0 self.pitWindowStart = sim_info.static.PitWindowStart self.pitWindowEnd = sim_info.static.PitWindowEnd self.pitWindowActive = False self.numberOfLapsCompleted = Value(0) self.cars_count = ac.getCarsCount() self.window = Window(name="ACTV CP Timer", width=228, height=42) # background corners self.lbl_left_corner = Label(self.window.app)\ .set(w=27, h=42, x=0, y=-80, opacity=0, background=Colors.timer_left_corner()) self.lbl_right_corner = Label(self.window.app)\ .set(w=27, h=42, x=0, y=-80, opacity=0, background=Colors.timer_right_corner()) # background self.lbl_session_info = Label(self.window.app)\ .set(w=331, h=36, x=self.row_height.value, y=-80) # Timer / lap self.lbl_session_info_txt = Label(self.window.app, "00:00")\ .set(w=0, h=36, x=self.row_height.value, y=-76, opacity=0, font_size=26, align="right") # Time self.lbl_time_of_day_txt = Label(self.window.app, "12:00")\ .set(w=0, h=36, x=self.row_height.value, y=-76, opacity=0, font_size=26, align="left") self.lbl_am_pm_txt = Label(self.window.app, "PM")\ .set(w=0, h=36, x=self.row_height.value, y=-76, opacity=0, font_size=26, align="left") self.lbl_extra_lap_txt = Label(self.window.app, "+1 LAP")\ .set(w=0, h=36, x=self.row_height.value, y=-76, opacity=0, font_size=26, align="right") # background pit window self.lbl_session_title = Label(self.window.app)\ .set(w=36, h=36, x=0, y=-74, opacity=1) # Race, Qual, Practice self.lbl_session_title_txt = Label(self.window.app, "FREE PRACTICE")\ .set(w=0, h=36, x=114, y=-76, opacity=0, font_size=26, align="center") # Status self.lbl_session_border = Label(self.window.app)\ .set(w=154 + 36, h=2, x=0, y=-74) self.lbl_session_border_2 = Label(self.window.app)\ .set(w=154 + 36, h=2, x=200, y=-74) # Open race.ini conf = Config(Config.get_user_documents_path() + "cfg/", "race.ini") start = conf.get("LIGHTING", "SUN_ANGLE") self.time_multiplier = float(conf.get("LIGHTING", "TIME_MULT")) session_0=session_1=session_2=session_3=session_4=session_5=session_6=0 for i in range(6): session_name = conf.get("SESSION_" + str(i), "NAME") if session_name == "Practice": session_0 = conf.get("SESSION_" + str(i), "DURATION_MINUTES") elif session_name == "Qualifying": session_1 = conf.get("SESSION_" + str(i), "DURATION_MINUTES") elif session_name == "Race": session_2 = conf.get("SESSION_" + str(i), "DURATION_MINUTES") elif session_name == "Hotlap": session_3 = conf.get("SESSION_" + str(i), "DURATION_MINUTES") elif session_name == "Time Attack": session_4 = conf.get("SESSION_" + str(i), "DURATION_MINUTES") elif session_name == "Drift": session_5 = conf.get("SESSION_" + str(i), "DURATION_MINUTES") elif session_name == "Drag": session_6 = conf.get("SESSION_" + str(i), "DURATION_MINUTES") self.sessions_duration = [float(session_0)*60000, float(session_1)*60000, float(session_2)*60000, float(session_3)*60000, float(session_4)*60000, float(session_5)*60000, float(session_6)*60000 ] self.start_time_of_day_original = self.start_time_of_day=(780 + 3.75 * float(start)) * 60000 - (4000 * self.time_multiplier) #ac.console("ini:" + str(self.start_time_of_day) + " = " + self.time_of_day(self.start_time_of_day)) self.last_start_time_offset=-1 self.session_time_left=0 self.session_info_imported=False self.is_multiplayer = ac.getServerIP() != '' self.lbl_time_of_day_txt.setText(self.time_of_day(self.start_time_of_day)) self.load_cfg()