update paths to pathlib for linux/mac support

This commit is contained in:
Yonokid
2025-04-26 02:09:18 -04:00
parent 3f0b538e2e
commit 2eb39610de
8 changed files with 47 additions and 29 deletions

View File

@@ -7,13 +7,13 @@ tja_path = 'Songs'
video_path = 'Videos' video_path = 'Videos'
[keybinds] [keybinds]
left_kat = ['E','R'] left_kat = ['D']
left_don = ['F','K'] left_don = ['F']
right_don = ['J','D'] right_don = ['J']
right_kat = ['I','U'] right_kat = ['K']
[audio] [audio]
device_type = 'ASIO' device_type = 'WASAPI'
asio_buffer = 6 asio_buffer = 6
[video] [video]

1
install.bat Normal file
View File

@@ -0,0 +1 @@
pip install -r requirements.txt

View File

@@ -1,5 +1,6 @@
import math import math
from collections import deque from collections import deque
from pathlib import Path
from libs.utils import get_pixels_per_frame, strip_comments from libs.utils import get_pixels_per_frame, strip_comments
@@ -28,9 +29,9 @@ def calculate_base_score(play_note_list: deque[dict]) -> int:
class TJAParser: class TJAParser:
def __init__(self, path: str): def __init__(self, path: str):
#Defined on startup #Defined on startup
self.folder_path = path self.folder_path = Path(path)
self.folder_name = self.folder_path.split('\\')[-1] self.folder_name = self.folder_path.name
self.file_path = f'{self.folder_path}\\{self.folder_name}.tja' self.file_path = self.folder_path / f"{self.folder_name}.tja"
#Defined on file_to_data() #Defined on file_to_data()
self.data = [] self.data = []
@@ -40,7 +41,7 @@ class TJAParser:
self.title_ja = '' self.title_ja = ''
self.subtitle = '' self.subtitle = ''
self.subtitle_ja = '' self.subtitle_ja = ''
self.wave = f'{self.folder_path}\\' self.wave = self.folder_path / ""
self.offset = 0 self.offset = 0
self.demo_start = 0 self.demo_start = 0
self.course_data = dict() self.course_data = dict()
@@ -81,7 +82,8 @@ class TJAParser:
elif 'BPM' in item: elif 'BPM' in item:
self.bpm = float(item.split(':')[1]) self.bpm = float(item.split(':')[1])
elif 'WAVE' in item: elif 'WAVE' in item:
self.wave += str(item.split(':')[1]) filename = item.split(':')[1].strip()
self.wave = self.folder_path / filename
elif 'OFFSET' in item: elif 'OFFSET' in item:
self.offset = float(item.split(':')[1]) self.offset = float(item.split(':')[1])
elif 'DEMOSTART' in item: elif 'DEMOSTART' in item:

View File

@@ -3,6 +3,7 @@ import tempfile
import time import time
import zipfile import zipfile
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path
from typing import Any from typing import Any
import pyray as ray import pyray as ray
@@ -12,14 +13,16 @@ import tomllib
def get_zip_filenames(zip_path: str) -> list[str]: def get_zip_filenames(zip_path: str) -> list[str]:
result = [] result = []
with zipfile.ZipFile(zip_path, 'r') as zip_ref: new_path = Path(zip_path)
with zipfile.ZipFile(new_path, 'r') as zip_ref:
file_list = zip_ref.namelist() file_list = zip_ref.namelist()
for file_name in file_list: for file_name in file_list:
result.append(file_name) result.append(file_name)
return result return result
def load_image_from_zip(zip_path: str, filename: str) -> ray.Image: def load_image_from_zip(zip_path: str, filename: str) -> ray.Image:
with zipfile.ZipFile(zip_path, 'r') as zip_ref: new_path = Path(zip_path)
with zipfile.ZipFile(new_path, 'r') as zip_ref:
with zip_ref.open(filename) as image_file: with zip_ref.open(filename) as image_file:
with tempfile.NamedTemporaryFile(delete=False, suffix='.png') as temp_file: with tempfile.NamedTemporaryFile(delete=False, suffix='.png') as temp_file:
temp_file.write(image_file.read()) temp_file.write(image_file.read())
@@ -29,7 +32,8 @@ def load_image_from_zip(zip_path: str, filename: str) -> ray.Image:
return image return image
def load_texture_from_zip(zip_path: str, filename: str) -> ray.Texture: def load_texture_from_zip(zip_path: str, filename: str) -> ray.Texture:
with zipfile.ZipFile(zip_path, 'r') as zip_ref: new_path = Path(zip_path)
with zipfile.ZipFile(new_path, 'r') as zip_ref:
with zip_ref.open(filename) as image_file: with zip_ref.open(filename) as image_file:
with tempfile.NamedTemporaryFile(delete=False, suffix='.png') as temp_file: with tempfile.NamedTemporaryFile(delete=False, suffix='.png') as temp_file:
temp_file.write(image_file.read()) temp_file.write(image_file.read())
@@ -40,7 +44,8 @@ def load_texture_from_zip(zip_path: str, filename: str) -> ray.Texture:
def load_all_textures_from_zip(zip_path: str) -> dict[str, list[ray.Texture]]: def load_all_textures_from_zip(zip_path: str) -> dict[str, list[ray.Texture]]:
result_dict = dict() result_dict = dict()
with zipfile.ZipFile(zip_path, 'r') as zip_ref: new_path = Path(zip_path)
with zipfile.ZipFile(new_path, 'r') as zip_ref:
files = zip_ref.namelist() files = zip_ref.namelist()
for file in files: for file in files:
with zip_ref.open(file) as image_file: with zip_ref.open(file) as image_file:

View File

@@ -1,6 +1,7 @@
import bisect import bisect
import math import math
from collections import deque from collections import deque
from pathlib import Path
import pyray as ray import pyray as ray
@@ -139,11 +140,11 @@ class GameScreen:
self.result_transition_2 = load_texture_from_zip('Graphics\\lumendata\\enso_result.zip', 'retry_game_img00126.png') self.result_transition_2 = load_texture_from_zip('Graphics\\lumendata\\enso_result.zip', 'retry_game_img00126.png')
def load_sounds(self): def load_sounds(self):
self.sound_don = audio.load_sound('Sounds\\inst_00_don.wav') sounds_dir = Path("Sounds")
self.sound_kat = audio.load_sound('Sounds\\inst_00_katsu.wav') self.sound_don = audio.load_sound(str(sounds_dir / "inst_00_don.wav"))
self.sound_balloon_pop = audio.load_sound('Sounds\\balloon_pop.wav') self.sound_kat = audio.load_sound(str(sounds_dir / "inst_00_katsu.wav"))
self.sound_balloon_pop = audio.load_sound(str(sounds_dir / "balloon_pop.wav"))
self.sound_result_transition = audio.load_sound('Sounds\\result\\VO_RESULT [1].ogg') self.sound_result_transition = audio.load_sound(str(sounds_dir / "result" / "VO_RESULT [1].ogg"))
def init_tja(self, song: str, difficulty: int): def init_tja(self, song: str, difficulty: int):
self.load_textures() self.load_textures()
@@ -170,7 +171,7 @@ class GameScreen:
global_data.song_title = self.tja.title global_data.song_title = self.tja.title
self.player_1 = Player(self, 1, difficulty, get_config()["general"]["judge_offset"]) self.player_1 = Player(self, 1, difficulty, get_config()["general"]["judge_offset"])
self.song_music = audio.load_sound(self.tja.wave) self.song_music = audio.load_sound(str(Path(self.tja.wave)))
self.start_ms = (get_current_ms() - self.tja.offset*1000) + self.start_delay self.start_ms = (get_current_ms() - self.tja.offset*1000) + self.start_delay
audio.play_sound(self.song_music) audio.play_sound(self.song_music)
@@ -618,7 +619,7 @@ class Player:
self.draw_balloon(game_screen, note, position, i) self.draw_balloon(game_screen, note, position, i)
else: else:
self.draw_note(game_screen, note_type, position, 255, note['se_note']) self.draw_note(game_screen, note_type, position, 255, note['se_note'])
ray.draw_text(str(i), position+64, 192, 25, ray.GREEN) #ray.draw_text(str(i), position+64, 192, 25, ray.GREEN)
def draw_gauge(self, game_screen: GameScreen): def draw_gauge(self, game_screen: GameScreen):
ray.draw_texture(game_screen.textures['gage_don_1p_hard'][0], 327, 128, ray.WHITE) ray.draw_texture(game_screen.textures['gage_don_1p_hard'][0], 327, 128, ray.WHITE)

View File

@@ -1,3 +1,5 @@
from pathlib import Path
import pyray as ray import pyray as ray
from libs.animation import Animation from libs.animation import Animation
@@ -21,8 +23,10 @@ class ResultScreen:
def __init__(self, width: int, height: int): def __init__(self, width: int, height: int):
self.width = width self.width = width
self.height = height self.height = height
self.sound_don = audio.load_sound('Sounds\\inst_00_don.wav') sounds_dir = Path("Sounds")
self.bgm = audio.load_sound('Sounds\\result\\JINGLE_SEISEKI [1].ogg') self.sound_don = audio.load_sound(str(sounds_dir / "inst_00_don.wav"))
self.sound_kat = audio.load_sound(str(sounds_dir / "inst_00_katsu.wav"))
self.bgm = audio.load_sound(str(sounds_dir / "result" / "JINGLE_SEISEKI [1].ogg"))
zip_file = 'Graphics\\lumendata\\enso_result.zip' zip_file = 'Graphics\\lumendata\\enso_result.zip'
self.textures = load_all_textures_from_zip(zip_file) self.textures = load_all_textures_from_zip(zip_file)

View File

@@ -1,4 +1,5 @@
import os import os
from pathlib import Path
import pyray as ray import pyray as ray
@@ -17,8 +18,9 @@ class SongSelectScreen:
self.selected_song = 0 self.selected_song = 0
self.selected_difficulty = 0 self.selected_difficulty = 0
self.selected_index = 0 self.selected_index = 0
self.sound_don = audio.load_sound('Sounds\\inst_00_don.wav') sounds_dir = Path("Sounds")
self.sound_kat = audio.load_sound('Sounds\\inst_00_katsu.wav') self.sound_don = audio.load_sound(str(sounds_dir / "inst_00_don.wav"))
self.sound_kat = audio.load_sound(str(sounds_dir / "inst_00_katsu.wav"))
for dirpath, dirnames, filenames in os.walk(f'{get_config()["paths"]["tja_path"]}'): for dirpath, dirnames, filenames in os.walk(f'{get_config()["paths"]["tja_path"]}'):
for filename in filenames: for filename in filenames:
if filename.endswith(".tja"): if filename.endswith(".tja"):

View File

@@ -36,10 +36,13 @@ class TitleScreen:
def load_textures(self): def load_textures(self):
self.textures = load_all_textures_from_zip('Graphics\\lumendata\\attract\\keikoku.zip') self.textures = load_all_textures_from_zip('Graphics\\lumendata\\attract\\keikoku.zip')
self.sound_bachi_swipe = audio.load_sound('Sounds\\title\\SE_ATTRACT_2.ogg') sounds_dir = Path("Sounds")
self.sound_bachi_hit = audio.load_sound('Sounds\\title\\SE_ATTRACT_3.ogg') title_dir = sounds_dir / "title"
self.sound_warning_message = audio.load_sound('Sounds\\title\\VO_ATTRACT_3.ogg')
self.sound_warning_error = audio.load_sound('Sounds\\title\\SE_ATTRACT_1.ogg') self.sound_bachi_swipe = audio.load_sound(str(title_dir / "SE_ATTRACT_2.ogg"))
self.sound_bachi_hit = audio.load_sound(str(title_dir / "SE_ATTRACT_3.ogg"))
self.sound_warning_message = audio.load_sound(str(title_dir / "VO_ATTRACT_3.ogg"))
self.sound_warning_error = audio.load_sound(str(title_dir / "SE_ATTRACT_1.ogg"))
self.texture_black = load_texture_from_zip('Graphics\\lumendata\\attract\\movie.zip', 'movie_img00000.png') self.texture_black = load_texture_from_zip('Graphics\\lumendata\\attract\\movie.zip', 'movie_img00000.png')