diff --git a/menus/add_music.py b/menus/add_music.py index 5a0176a..70adc9a 100644 --- a/menus/add_music.py +++ b/menus/add_music.py @@ -6,16 +6,10 @@ from menus.file_manager import FileManager from arcade.gui.experimental.focus import UIFocusGroup class AddMusic(arcade.gui.UIView): - def __init__(self, pypresence_client, current_mode, current_music_name, current_length, current_music_player, queue, loaded_sounds, shuffle, music_file_selected=None): + def __init__(self, pypresence_client, *args, music_file_selected=None): super().__init__() - self.current_mode = current_mode - self.current_music_name = current_music_name - self.current_length = current_length - self.current_music_player = current_music_player - self.queue = queue - self.loaded_sounds = loaded_sounds - self.shuffle = shuffle + self.args = args self.music_file_selected = music_file_selected with open("settings.json", "r", encoding="utf-8") as file: @@ -50,7 +44,7 @@ class AddMusic(arcade.gui.UIView): self.anchor.detect_focusable_widgets() def select_file(self): - self.window.show_view(FileManager(os.path.expanduser("~"), [f".{extension}" for extension in audio_extensions], "file", self.pypresence_client, self.current_mode, self.current_music_name, self.current_length, self.current_music_player, self.queue, self.loaded_sounds, self.shuffle)) + self.window.show_view(FileManager(os.path.expanduser("~"), [f".{extension}" for extension in audio_extensions], "file", self.pypresence_client, *self.args)) def add_music(self): music_path = self.music_file_selected @@ -73,4 +67,4 @@ class AddMusic(arcade.gui.UIView): def main_exit(self): from menus.main import Main - self.window.show_view(Main(self.pypresence_client, self.current_mode, self.current_music_name, self.current_length, self.current_music_player, self.queue, self.loaded_sounds, self.shuffle)) + self.window.show_view(Main(self.pypresence_client, *self.args)) diff --git a/menus/downloader.py b/menus/downloader.py index 402fe1d..5a84b2f 100644 --- a/menus/downloader.py +++ b/menus/downloader.py @@ -10,16 +10,10 @@ from utils.constants import button_style from utils.preload import button_texture, button_hovered_texture class Downloader(arcade.gui.UIView): - def __init__(self, pypresence_client, current_mode, current_music_name, current_length, current_music_player, queue, loaded_sounds, shuffle): + def __init__(self, pypresence_client, *args): super().__init__() - self.current_mode = current_mode - self.current_music_name = current_music_name - self.current_length = current_length - self.current_music_player = current_music_player - self.queue = queue - self.loaded_sounds = loaded_sounds - self.shuffle = shuffle + self.args = args self.pypresence_client = pypresence_client self.pypresence_client.update(state="Downloading music", start=self.pypresence_client.start_time) @@ -191,4 +185,4 @@ class Downloader(arcade.gui.UIView): def main_exit(self): from menus.main import Main - self.window.show_view(Main(self.pypresence_client, self.current_mode, self.current_music_name, self.current_length, self.current_music_player, self.queue, self.loaded_sounds, self.shuffle)) + self.window.show_view(Main(self.pypresence_client, *self.args)) diff --git a/menus/main.py b/menus/main.py index 2e242c9..d491949 100644 --- a/menus/main.py +++ b/menus/main.py @@ -439,6 +439,10 @@ class Main(arcade.gui.UIView): self.should_reload = True # needed because the observer runs in another thread and OpenGL is single-threaded. def load_tabs(self): + for button in self.tab_buttons.values(): + self.tab_box.remove(button) + self.tab_buttons.clear() + if self.current_mode == "files": for tab in self.tab_options: self.tab_buttons[os.path.expanduser(tab)] = self.tab_box.add(arcade.gui.UITextureButton(texture=button_texture, texture_hovered=button_hovered_texture, text=os.path.basename(os.path.normpath(os.path.expanduser(tab))), style=button_style, width=self.window.width / 10, height=self.window.height / 15)) diff --git a/menus/new_tab.py b/menus/new_tab.py index 7692f54..63630c4 100644 --- a/menus/new_tab.py +++ b/menus/new_tab.py @@ -8,16 +8,10 @@ from menus.file_manager import FileManager from arcade.gui.experimental.focus import UIFocusGroup class NewTab(arcade.gui.UIView): - def __init__(self, pypresence_client, current_mode, current_music_name, current_length, current_music_player, queue, loaded_sounds, shuffle, directory_selected=None): + def __init__(self, pypresence_client, *args, directory_selected=None): super().__init__() - self.current_mode = current_mode - self.current_music_name = current_music_name - self.current_length = current_length - self.current_music_player = current_music_player - self.queue = queue - self.loaded_sounds = loaded_sounds - self.shuffle = shuffle + self.args = args self.directory_selected = directory_selected with open("settings.json", "r", encoding="utf-8") as file: @@ -26,6 +20,8 @@ class NewTab(arcade.gui.UIView): self.tab_options = self.settings_dict.get("tab_options", [os.path.join("~", "Music"), os.path.join("~", "Downloads")]) self.playlists = self.settings_dict.get("playlists", {}) + self.current_mode = self.args[0] + self.pypresence_client = pypresence_client self.pypresence_client.update(state="Adding new tab", start=self.pypresence_client.start_time) @@ -43,6 +39,7 @@ class NewTab(arcade.gui.UIView): self.new_tab_button = self.box.add(arcade.gui.UITextureButton(texture=button_texture, texture_hovered=button_hovered_texture, text='Add new tab', style=button_style, width=self.window.width / 2, height=self.window.height / 10)) self.new_tab_button.on_click = lambda event: self.add_tab() + elif self.current_mode == "playlist": self.new_tab_label = self.box.add(arcade.gui.UILabel(text="New Playlist Name:", font_name="Roboto", font_size=32)) @@ -57,7 +54,7 @@ class NewTab(arcade.gui.UIView): self.anchor.detect_focusable_widgets() def select_directory(self): - self.window.show_view(FileManager(os.path.expanduser("~"), [], "directory", self.pypresence_client, self.current_mode, self.current_music_name, self.current_length, self.current_music_player, self.queue, self.loaded_sounds, self.shuffle)) + self.window.show_view(FileManager(os.path.expanduser("~"), [], "directory", self.pypresence_client, *self.args)) def add_tab(self): if self.current_mode == "files": @@ -84,4 +81,4 @@ class NewTab(arcade.gui.UIView): def main_exit(self): from menus.main import Main - self.window.show_view(Main(self.pypresence_client, self.current_mode, self.current_music_name, self.current_length, self.current_music_player, self.queue, self.loaded_sounds, self.shuffle)) + self.window.show_view(Main(self.pypresence_client, *self.args))