Beispiel #1
0
 def set_current_track(self, currently_selected_track):
     if len(currently_selected_track) == 1:
         selection_id = int(currently_selected_track[0])
         print(self.track_sorted_list)
         Config().current_track = self.track_sorted_list[selection_id]
         print("... set current selected track : " +
               str(Config().current_track))
Beispiel #2
0
 def toggle_track_sort(self, sort_bool):
     config = Config()
     if sort_bool:
         config.sort_tracks = True
     else:
         config.sort_tracks = False
     self.track_sorted_list = list(self.tracks)
Beispiel #3
0
 def box_event(self, *args):
     config = Config()
     config.dump("weather_box", self.weather_box.get())
     config.dump("game_mode_box", self.game_mode_box.get())
     config.dump("cars_box", self.cars_box.get())
     self.keep_track_selection_highlighted()
     self.show_track_selection()
Beispiel #4
0
    def set_starting_values(self):
        print(" - - - - - - - - set starting values  - - - - - - - - ")
        race = Config().race
        self.track_box.selection_set(0)
        self.race_box.set(race)
        self.cars_box['values'] = self.raceSettings[race]
        self.cars_box.set(Config().cars)
        self.weather_box.set(Config().weather)
        self.game_mode_box.set(Config().game_mode)
        self.preset_box.set("Load Preset")
        self.status_message.set('')
        self.top_menu.set_starting_values()

        self.toggle_race_sliders(race)
        Events(self).show_track_selection()
Beispiel #5
0
 def track_id(self):
     config = Config()
     print(config.current_track,
           TrackSql().get_track_id_by_country(config.current_track))
     return TrackSql().get_track_id_by_country(
         config.current_track
     )  # self.get_list(self.tracks_id).index(self.current_track)
Beispiel #6
0
 def race_box_event(self, *args):
     """"called whenever the race box is updated by user"""
     race = self.race_box.get()
     self.widgets.toggle_race_sliders(race)
     Config().race = race
     self.cars_box['values'] = self.widgets.raceSettings[race]
     self.cars_box.current(0)
     self.box_event()
Beispiel #7
0
 def slider_event(self, *args):
     config = Config()
     auto_use = config.auto_use_changes
     auto_save = config.auto_save_changes
     if auto_use and auto_save:
         self.widgets.use_save_cmd()
     elif auto_use:
         self.setup.use_setup()
     elif auto_save:
         self.widgets.save_cmd()
Beispiel #8
0
    def show_track_selection(self, *args):
        print("events - show track")
        self.tracks.set_current_track(self.widgets.track_box.curselection())
        """select the file to open, unpack the file, update sliders, if autoUse is checked;  write to workshop file"""
        league: str = self.race_box.get()
        team: str = self.cars_box.get()
        weather: str = self.weather_box.get()
        game_mode: str = self.game_mode_box.get()
        track: str = Config().current_track

        ids: tuple = self.db.get_ids(league, track, weather, game_mode, team)

        print("selected: \n", league, track, weather, game_mode, team)
        print("ids: \n", ids)
        setup_db = self.db.setups.get_setup_by_ids(*ids)
        print("setup_db: \n", setup_db)
        try:
            setup_id = setup_db[0][0]
            print("Found setup id in db : " + str(setup_id))
            self.widgets.sliders = (
                True, *self.db.setups.get_setup_by_setup_id(setup_id))
        except IndexError:
            """ if its not in db """
            print("file not in db")
            ids = self.db.get_ids(league, track, weather, "Invitational",
                                  "All Cars")
            setup_db = self.db.setups.get_setup_by_ids(*ids)

            try:
                self.widgets.sliders = (True,
                                        *self.db.setups.get_setup_by_setup_id(
                                            setup_db[0][0]))
            except IndexError:
                self.widgets.sliders = (
                    True, *presets_sql.PresetSql().get_preset_by_id(3))

        if Config().auto_use_track:
            self.setup.use_setup()

        self.widgets.status_message.set(
            " %s | %s | (%s) %s [%s]" %
            (league, team, track, self.tracks.tracks[track],
             self.widgets.weatherTypes[weather]))
Beispiel #9
0
 def set_starting_values(self):
     config = Config()
     if config.sort_tracks:
         self.settings_menu.invoke(2)
     if config.auto_use_changes:
         self.settings_menu.invoke(3)
     if config.auto_save_changes:
         self.settings_menu.invoke(4)
     if config.auto_use_track:
         self.settings_menu.invoke(5)
Beispiel #10
0
    def pack_setup(self):

        # syntax:  b'string', values (based on packing format), check value
        # all vars have a check value at the end,
        # Remove them and the game crashes. ¯\_(ツ)_/¯
        def b(s):
            return bytes(s, 'utf-8')

        self.save_name = 'All setups | scruffe'
        self.size = len(self.save_name)

        # self.setupStructPackingFormat = self.get_packing_format()
        packed_setup = pack(
            self.packing_format,
            b(self.header), 0, 1, 0, 32, 0, 7,
            # \x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x07
            b(self.versions), 0, 9,  # \x00\x00\x00\x00\t
            b(self.save_name_length), self.size,  # \x14      probably string length of next name
            b(self.save_name), 7,  # \x07
            b(self.team_id), self.widgets.team_id, 0, 8,  # \x00\x00\x08
            b(self.track_id), TrackSql().get_track_id_by_country(Config().current_track), 12,  # \x03\x0c
            b(self.game_mode_id), self.widgets.game_mode_id, 0, 0, 0, 12,
            # \x05\x00\x00\x00 \x0c
            b(self.weather_bool), self.widgets.weather_id, 9,  # \x01\t
            b(self.timestamp), 19, 14, 5, 95, 0, 0, 0, 0, 15,  # \x13\x0e\x05_\x00\x00\x00\x00\x0f
            b(self.game_setup_mode), 0, 10,  # \x00\n
            b(self.fw), self.widgets.front_wing_Scale.get(), 9,
            b(self.rw), self.widgets.rear_wing_Scale.get(), 11,
            b(self.ot), self.widgets.on_throttle_Scale.get(), 12,
            b(self.oft), self.widgets.off_throttle_Scale.get(), 12,
            b(self.fc), self.widgets.front_camber_Scale.get(), 11,
            b(self.rc), self.widgets.rear_camber_Scale.get(), 9,
            b(self.ft), self.widgets.front_toe_Scale.get(), 8,
            b(self.rt), self.widgets.rear_toe_Scale.get(), 16,
            b(self.fs), self.widgets.front_suspension_Scale.get(), 15,
            b(self.rs), self.widgets.rear_suspension_Scale.get(), 23,
            b(self.fsh), self.widgets.front_suspension_height_Scale.get(), 22,
            b(self.rsh), self.widgets.rear_suspension_height_Scale.get(), 18,
            b(self.fab), self.widgets.front_antiroll_bar_Scale.get(), 17,
            b(self.rab), self.widgets.rear_antiroll_bar_Scale.get(), 14,
            b(self.bp), self.widgets.brake_pressure_Scale.get(), 10,
            b(self.bb), self.widgets.brake_bias_Scale.get(), 25,
            b(self.frtp), self.widgets.front_right_tyre_pressure_Scale.get(), 24,
            b(self.fltp), self.widgets.front_left_tyre_pressure_Scale.get(), 24,
            b(self.rrtp), self.widgets.rear_right_tyre_pressure_Scale.get(), 23,
            b(self.rltp), self.widgets.rear_left_tyre_pressure_Scale.get(), 7,
            b(self.b), self.widgets.ballast_Scale.get(), 9,
            b(self.fl), self.widgets.fuel_load_Scale.get(), 17,
            b(self.rd), self.widgets.ramp_differential_Scale.get(), 17,
            b(self.footer), 31, 174, 162, 128, 0, 0, 0, 0
            # b'published_file_idui64\x1f\xae\xa2\x80\x00\x00\x00\x00'
        )

        return packed_setup
Beispiel #11
0
    def toggle_track_list_order(self, sort_bool):
        print(" - - - - - - - - sorting track list  - - - - - - - - ")
        """sort track list based on calendar or Alphabet"""
        # save new value to config file
        Config().sort_tracks = sort_bool

        # update track list
        self.tracks.toggle_track_sort(sort_bool)
        self.track_box.delete(0, END)
        self.track_box.insert(END, *self.tracks.track_sorted_list)

        # redo background color
        self.tracks_background_color()

        # show the previous selected track
        Events(self).box_event()
Beispiel #12
0
    def create_car_setup_from_widgets(self):
        print("... creating car setup from widgets")
        current_track = Config().current_track
        league_id = league_sql.LeagueSql().get_id_from_name(self.league_id)
        track_id = TrackSql().get_track_id_by_country(current_track)
        print("self.config.current_track", current_track)
        print("track id", track_id)
        team_id = self.db.teams.get_team_id(self.cars_box.get(), league_id)

        car_setup = CarSetup(
            league_id=league_id,
            save_name=" save name test",
            team_id=team_id,
            track_id=track_id,
            game_mode_id=self.game_mode_id,
            weather_id=self.weather_id,

            front_wing=self.front_wing_Scale.get(),
            rear_wing=self.rear_wing_Scale.get(),
            on_throttle=self.on_throttle_Scale.get(),
            off_throttle=self.off_throttle_Scale.get(),
            front_camber=self.front_camber_Scale.get(),
            rear_camber=self.rear_camber_Scale.get(),
            front_toe=self.front_toe_Scale.get(),
            rear_toe=self.rear_toe_Scale.get(),
            front_suspension=self.front_suspension_Scale.get(),
            rear_suspension=self.rear_suspension_Scale.get(),
            front_suspension_height=self.front_suspension_height_Scale.get(),
            rear_suspension_height=self.rear_suspension_height_Scale.get(),
            front_antiroll_bar=self.front_antiroll_bar_Scale.get(),
            rear_antiroll_bar=self.rear_antiroll_bar_Scale.get(),
            brake_pressure=self.brake_pressure_Scale.get(),
            brake_bias=self.brake_bias_Scale.get(),
            front_right_tyre_pressure=self.front_right_tyre_pressure_Scale.get(),
            front_left_tyre_pressure=self.front_left_tyre_pressure_Scale.get(),
            rear_right_tyre_pressure=self.rear_right_tyre_pressure_Scale.get(),
            rear_left_tyre_pressure=self.rear_left_tyre_pressure_Scale.get(),
            ballast=self.ballast_Scale.get(),
            fuel_load=self.fuel_load_Scale.get(),
            ramp_differential=self.ramp_differential_Scale.get()
        )
        return car_setup
Beispiel #13
0
    sqlite_create.make_game_modes(Json())
    sqlite_create.make_weathers()
    preset1 = CarSetup(1, 0, "Preset 1", 0, 0, 0, 0, 8, 9, 70, 65, -3.1, -1.6,
                       0.09, 0.32, 3, 1, 3, 5, 4, 3, 100, 58, 21.4, 21.4, 19.5,
                       19.5, 0, 10, 0)
    preset2 = CarSetup(2, 0, "Preset 2", 0, 0, 0, 0, 6, 7, 70, 65, -3, -1.5,
                       0.1, 0.35, 4, 3, 5, 7, 7, 7, 100, 58, 22.6, 22.6, 21.1,
                       21.1, 0, 10, 0)
    preset3 = CarSetup(3, 0, "Preset 3", 0, 0, 0, 0, 5, 6, 70, 65, -3.1, -1.6,
                       0.09, 0.32, 5, 3, 5, 7, 6, 5, 100, 58, 22.6, 22.6, 21.1,
                       21.1, 0, 10, 0)
    preset4 = CarSetup(4, 0, "Preset 4", 0, 0, 0, 0, 4, 4, 70, 65, -2.6, -1.1,
                       0.06, 0.2, 4, 4, 4, 5, 5, 5, 100, 58, 21.8, 21.8, 20.7,
                       20.7, 0, 10, 0)
    preset5 = CarSetup(5, 0, "Preset 5", 0, 0, 0, 0, 2, 2, 70, 65, -2.5, -1,
                       0.05, 0.2, 3, 3, 4, 5, 4, 3, 100, 58, 25, 25, 23.5,
                       23.5, 0, 10, 0)

    _presets = [preset1, preset2, preset3, preset4, preset5]
    sqlite_create.make_presets(_presets)


config = Config()
if config.install_db:
    create_local_db()
    config.install_db = False
use_theme()
Widgets(root).set_starting_values()

root.mainloop()
Beispiel #14
0
 def update_auto_use_track(b: bool):
     Config().auto_use_track = b
Beispiel #15
0
 def update_auto_save(b: bool):
     Config().auto_save_changes = b
Beispiel #16
0
 def update_auto_use(b: bool):
     Config().auto_use_changes = b
Beispiel #17
0
 def load_setup_file(self, p):
     self.widgets.sliders = self.unpack_setup(p)
     if Config().auto_use_track:
         self.use_setup()
Beispiel #18
0
 def use_setup(self):
     config = Config()
     config.workshop_file = config.get_workshop_race_id(self.widgets.race_box.get())
     self.write_setup(config.workshop_file)
Beispiel #19
0
 def tracks(self):
     config = Config()
     if config.sort_tracks:
         return self.tracks_sorted
     else:
         return self.tracks_id
Beispiel #20
0
 def keep_track_selection_highlighted(self):
     track_list = self.tracks.track_sorted_list
     self.track_box.selection_set(track_list.index(Config().current_track))