mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 19:28:25 +02:00
optimised get_track_possibilities and fixed some sorting issue ?
This commit is contained in:
parent
b5da151c73
commit
e5fefd0624
2 changed files with 13 additions and 18 deletions
|
@ -12,7 +12,7 @@ class CT_Config:
|
||||||
game_variant: str = "01", region: int = None, cheat_region: int = None,
|
game_variant: str = "01", region: int = None, cheat_region: int = None,
|
||||||
tags_color: dict = None, prefix_list: list = None, suffix_list: list = None,
|
tags_color: dict = None, prefix_list: list = None, suffix_list: list = None,
|
||||||
tag_retro: str = "Retro", default_track: Track = None, pack_path: str = "",
|
tag_retro: str = "Retro", default_track: Track = None, pack_path: str = "",
|
||||||
file_process: dict = None, file_structure: dict = None, default_sort: str = "name"):
|
file_process: dict = None, file_structure: dict = None, default_sort: str = ""):
|
||||||
|
|
||||||
self.version = version
|
self.version = version
|
||||||
self.name = name
|
self.name = name
|
||||||
|
@ -195,7 +195,7 @@ class CT_Config:
|
||||||
|
|
||||||
if "name" in ctconfig_json: self.name = ctconfig_json["name"]
|
if "name" in ctconfig_json: self.name = ctconfig_json["name"]
|
||||||
if "game_variant" in ctconfig_json: self.game_variant = ctconfig_json["game_variant"]
|
if "game_variant" in ctconfig_json: self.game_variant = ctconfig_json["game_variant"]
|
||||||
if "default_sort" in ctconfig_json: self.default_sort = ctconfig_json["default_sort"]
|
if "default_sort" in ctconfig_json: self.sort_track_attr = ctconfig_json["default_sort"]
|
||||||
self.nickname = ctconfig_json["nickname"] if "nickname" in ctconfig_json else self.name
|
self.nickname = ctconfig_json["nickname"] if "nickname" in ctconfig_json else self.name
|
||||||
|
|
||||||
for param in ["region", "cheat_region", "tags_color", "prefix_list", "suffix_list", "tag_retro"]:
|
for param in ["region", "cheat_region", "tags_color", "prefix_list", "suffix_list", "tag_retro"]:
|
||||||
|
@ -214,17 +214,11 @@ class CT_Config:
|
||||||
def get_tracks_count(self) -> int:
|
def get_tracks_count(self) -> int:
|
||||||
return sum(1 for _ in self.get_tracks())
|
return sum(1 for _ in self.get_tracks())
|
||||||
|
|
||||||
def get_all_track_possibilities(self) -> dict:
|
def get_all_track_possibilities(self) -> list:
|
||||||
possibilities = {}
|
possibilities = set()
|
||||||
for track in self.get_tracks():
|
for track in self.get_tracks():
|
||||||
for key, value in track.__dict__.items():
|
for key in track.__dict__.keys():
|
||||||
if not key in possibilities: possibilities[key] = []
|
if key.startswith("_"): continue # if attr start with a _, the attribute is supposed to be hidden
|
||||||
|
possibilities.add(key)
|
||||||
|
|
||||||
if type(value) == list:
|
return sorted(possibilities)
|
||||||
for value2 in value: possibilities[key].append(value2)
|
|
||||||
else: possibilities[key].append(value)
|
|
||||||
|
|
||||||
for k, v in possibilities.items():
|
|
||||||
possibilities[k] = list(sorted(set(filter(None, v)))) # remove duplicate
|
|
||||||
|
|
||||||
return possibilities
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ class TrackSelection:
|
||||||
Label(self.track_sort, text="Sort track by : ").grid(row=1, column=1)
|
Label(self.track_sort, text="Sort track by : ").grid(row=1, column=1)
|
||||||
self.combobox_track_sort = ttk.Combobox(
|
self.combobox_track_sort = ttk.Combobox(
|
||||||
self.track_sort,
|
self.track_sort,
|
||||||
values=list(self.common.ct_config.get_all_track_possibilities().keys())
|
values=list(self.common.ct_config.get_all_track_possibilities())
|
||||||
)
|
)
|
||||||
self.combobox_track_sort.grid(row=1, column=2, sticky="NEWS")
|
self.combobox_track_sort.grid(row=1, column=2, sticky="NEWS")
|
||||||
self.combobox_track_sort.insert(END, self.common.ct_config.sort_track_attr)
|
self.combobox_track_sort.insert(END, self.common.ct_config.sort_track_attr)
|
||||||
|
@ -187,7 +187,7 @@ class TrackSelection:
|
||||||
frame = Frame(root)
|
frame = Frame(root)
|
||||||
frame.grid(row=len(frames_filter) + 10, column=1, sticky="NEWS")
|
frame.grid(row=len(frames_filter) + 10, column=1, sticky="NEWS")
|
||||||
Label(frame, text="If track's").grid(row=1, column=1)
|
Label(frame, text="If track's").grid(row=1, column=1)
|
||||||
track_property = ttk.Combobox(frame, values=list(self.common.ct_config.get_all_track_possibilities().keys()))
|
track_property = ttk.Combobox(frame, values=list(self.common.ct_config.get_all_track_possibilities()))
|
||||||
track_property.current(0)
|
track_property.current(0)
|
||||||
track_property.grid(row=1, column=2)
|
track_property.grid(row=1, column=2)
|
||||||
|
|
||||||
|
@ -265,6 +265,7 @@ class TrackSelection:
|
||||||
def apply_configuration(self):
|
def apply_configuration(self):
|
||||||
self.common.gui_main.is_track_configuration_edited = True
|
self.common.gui_main.is_track_configuration_edited = True
|
||||||
self.common.ct_config.sort_track_attr = self.combobox_track_sort.get()
|
self.common.ct_config.sort_track_attr = self.combobox_track_sort.get()
|
||||||
|
|
||||||
self.common.ct_config.filter_track_selection = self.get_filter(
|
self.common.ct_config.filter_track_selection = self.get_filter(
|
||||||
self.variable_enable_track_filter,
|
self.variable_enable_track_filter,
|
||||||
self.frames_track_filter
|
self.frames_track_filter
|
||||||
|
@ -359,7 +360,7 @@ class TrackSelection:
|
||||||
filename = filedialog.asksaveasfilename(
|
filename = filedialog.asksaveasfilename(
|
||||||
title="Save track configuration",
|
title="Save track configuration",
|
||||||
defaultextension=".mkwf.tc",
|
defaultextension=".mkwf.tc",
|
||||||
filetypes=[("track configuration (*.mkwf.tc)", "*.mkwf.tc")]
|
filetypes=[("track configuration", "*.mkwf.tc")]
|
||||||
)
|
)
|
||||||
if filename: self.save_to_file(filename)
|
if filename: self.save_to_file(filename)
|
||||||
|
|
||||||
|
@ -396,6 +397,6 @@ class TrackSelection:
|
||||||
filename = filedialog.askopenfilename(
|
filename = filedialog.askopenfilename(
|
||||||
title="Load track configuration",
|
title="Load track configuration",
|
||||||
defaultextension=".mkwf.tc",
|
defaultextension=".mkwf.tc",
|
||||||
filetypes=[("track configuration (*.mkwf.tc)", "*.mkwf.tc")]
|
filetypes=[("track configuration", "*.mkwf.tc")]
|
||||||
)
|
)
|
||||||
if filename: self.load_from_file(filename)
|
if filename: self.load_from_file(filename)
|
Loading…
Reference in a new issue