Fix stretched music logo and paths for Windows

This commit is contained in:
csd4ni3l
2025-06-10 19:07:43 +02:00
parent caf567b003
commit 866d5461a9
5 changed files with 18 additions and 11 deletions

View File

@@ -27,7 +27,7 @@ class Downloader(arcade.gui.UIView):
with open("settings.json", "r", encoding="utf-8") as file:
self.settings_dict = json.load(file)
self.tab_options = self.settings_dict.get("tab_options", ["~/Music", "~/Downloads"])
self.tab_options = self.settings_dict.get("tab_options", [os.path.join("~", "Music"), os.path.join("~", "Downloads")])
self.yt_dl_buffer = ""
def on_show_view(self):

View File

@@ -54,7 +54,7 @@ class Main(arcade.gui.UIView):
self.pypresence_client = FakePyPresence()
self.pypresence_client.start_time = time.time()
self.tab_options = self.settings_dict.get("tab_options", ["~/Music", "~/Downloads"])
self.tab_options = self.settings_dict.get("tab_options", [os.path.join("~", "Music"), os.path.join("~", "Downloads")])
self.tab_content = {}
self.playlist_content = {}
self.thumbnails = {}
@@ -158,6 +158,9 @@ class Main(arcade.gui.UIView):
self.volume_slider = self.control_box.add(arcade.gui.UISlider(style=slider_style, width=self.window.width / 10, height=35, value=self.volume, max_value=100))
self.volume_slider.on_change = self.on_volume_slider_change
self.no_music_label = self.anchor.add(arcade.gui.UILabel(text="No music files were found in this directory or playlist.", font_name="Roboto", font_size=24), anchor_x="center", anchor_y="center")
self.no_music_label.visible = False
if self.current_mode == "files":
self.show_content(os.path.expanduser(self.current_tab))
elif self.current_mode == "playlist":
@@ -256,18 +259,20 @@ class Main(arcade.gui.UIView):
self.highest_score_file = f"{self.current_tab}/{matches[0][0]}"
for n, match in enumerate(matches):
music_filename = match[0]
self.music_buttons[music_filename] = self.music_grid.add(Card(card_texture=self.thumbnails[f"{tab}/{music_filename}"], font_name="Roboto", font_size=13, text=music_filename, width=self.window.width / 6, height=self.window.height / 5), row=0, column=n)
self.music_buttons[music_filename] = self.music_grid.add(Card(card_texture=self.thumbnails[f"{tab}/{music_filename}"], font_name="Roboto", font_size=13, text=music_filename, width=self.window.width / 7, height=self.window.height / 7), row=0, column=n)
self.music_buttons[music_filename].button.on_click = lambda event, tab=tab, music_filename=music_filename: self.queue.append(f"{tab}/{music_filename}")
else:
self.music_grid.row_count = ceil(len(self.tab_content[tab]) / 5)
self.music_grid._update_size_hints()
self.highest_score_file = ""
self.no_music_label.visible = not self.tab_content[tab]
for n, music_filename in enumerate(self.tab_content[tab]):
row = n // 5
col = n % 5
self.music_buttons[music_filename] = self.music_grid.add(Card(card_texture=self.thumbnails[f"{tab}/{music_filename}"], font_name="Roboto", font_size=13, text=music_filename, width=self.window.width / 6, height=self.window.height / 5), row=row, column=col)
self.music_buttons[music_filename] = self.music_grid.add(Card(card_texture=self.thumbnails[f"{tab}/{music_filename}"], font_name="Roboto", font_size=13, text=music_filename, width=self.window.width / 7, height=self.window.height / 7), row=row, column=col)
self.music_buttons[music_filename].button.on_click = lambda event, tab=tab, music_filename=music_filename: self.queue.append(f"{tab}/{music_filename}")
elif self.current_mode == "playlist":
@@ -288,6 +293,8 @@ class Main(arcade.gui.UIView):
self.highest_score_file = ""
self.no_music_label.visible = not self.playlist_content[tab]
for n, music_filename in enumerate(self.playlist_content[tab]):
row = n // 5
col = n % 5

View File

@@ -20,7 +20,7 @@ class NewTab(arcade.gui.UIView):
with open("settings.json", "r", encoding="utf-8") as file:
self.settings_dict = json.load(file)
self.tab_options = self.settings_dict.get("tab_options", ["~/Music", "~/Downloads"])
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.pypresence_client = pypresence_client

2
run.py
View File

@@ -19,7 +19,7 @@ from arcade.experimental.controller_window import ControllerWindow
sys.excepthook = on_exception
pyglet.resource.path.append(os.getcwd())
pyglet.font.add_directory('./assets/fonts')
pyglet.font.add_directory(os.path.join(os.getcwd(), 'assets', 'fonts'))
if not log_dir in os.listdir():
os.makedirs(log_dir)

View File

@@ -81,15 +81,15 @@ class UIFocusTextureButton(arcade.gui.UITextureButton):
class Card(arcade.gui.UIBoxLayout):
def __init__(self, width: int, height: int, font_name: str, font_size: int, text: str, card_texture: arcade.Texture, padding=10):
super().__init__(width=width, height=height, space_between=padding, align="bottom")
super().__init__(width=width, height=height, space_between=padding, align="top")
self.button = self.add(arcade.gui.UITextureButton(
texture=card_texture,
texture_hovered=card_texture,
texture_pressed=card_texture,
texture_disabled=card_texture,
width=width / 2,
height=height * 0.5,
width=width,
height=height,
))
wrapped_lines = textwrap.wrap(text, width=int(width / (font_size * 0.6)))
@@ -100,8 +100,8 @@ class Card(arcade.gui.UIBoxLayout):
font_name=font_name,
font_size=font_size,
width=width,
height=height * 0.5,
multiline=True
height=height * 0.1,
multiline=True,
))
def on_exception(*exc_info):